KiCad PCB EDA Suite
BOARD_COMMIT Class Reference

#include <board_commit.h>

Inheritance diagram for BOARD_COMMIT:
COMMIT

Public Member Functions

 BOARD_COMMIT (TOOL_MANAGER *aToolMgr)
 
 BOARD_COMMIT (EDA_DRAW_FRAME *aFrame)
 
 BOARD_COMMIT (PCB_TOOL_BASE *aTool)
 
virtual ~BOARD_COMMIT ()
 
BOARDGetBoard () const
 
virtual void Push (const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
 Revert the commit by restoring the modified items state. More...
 
virtual void Revert () override
 
COMMITStage (EDA_ITEM *aItem, CHANGE_TYPE aChangeType) override
 
COMMITStage (std::vector< EDA_ITEM * > &container, CHANGE_TYPE aChangeType) override
 
COMMITStage (const PICKED_ITEMS_LIST &aItems, UNDO_REDO aModFlag=UNDO_REDO::UNSPECIFIED) override
 Execute the changes. More...
 
void SetResolveNetConflicts (bool aResolve=true)
 Sets a flag that will cause Push() to resolve net conflicts on track/via clusters instead of the default behavior which is to skip updating track/via clusters that have conflicts. More...
 
COMMITAdd (EDA_ITEM *aItem)
 Notify observers that aItem has been added. More...
 
COMMITAdded (EDA_ITEM *aItem)
 Remove a new item from the model. More...
 
COMMITRemove (EDA_ITEM *aItem)
 Notify observers that aItem has been removed. More...
 
COMMITRemoved (EDA_ITEM *aItem)
 Modify a given item in the model. More...
 
COMMITModify (EDA_ITEM *aItem)
 Create an undo entry for an item that has been already modified. More...
 
COMMITModified (EDA_ITEM *aItem, EDA_ITEM *aCopy)
 
template<class Range >
COMMITStageItems (const Range &aRange, CHANGE_TYPE aChangeType)
 Add a change of the item aItem of type aChangeType to the change list. More...
 
bool Empty () const
 Returns status of an item. More...
 
int GetStatus (EDA_ITEM *aItem)
 

Protected Member Functions

void clear ()
 
COMMITcreateModified (EDA_ITEM *aItem, EDA_ITEM *aCopy, int aExtraFlags=0)
 
virtual void makeEntry (EDA_ITEM *aItem, CHANGE_TYPE aType, EDA_ITEM *aCopy=nullptr)
 
COMMIT_LINEfindEntry (EDA_ITEM *aItem)
 Search for an entry describing change for a particular item. More...
 
CHANGE_TYPE convert (UNDO_REDO aType) const
 

Protected Attributes

std::set< EDA_ITEM * > m_changedItems
 
std::vector< COMMIT_LINEm_changes
 

Private Member Functions

virtual EDA_ITEMparentObject (EDA_ITEM *aItem) const override
 

Private Attributes

TOOL_MANAGERm_toolMgr
 
bool m_isFootprintEditor
 
bool m_resolveNetConflicts
 

Detailed Description

Definition at line 38 of file board_commit.h.

Constructor & Destructor Documentation

◆ BOARD_COMMIT() [1/3]

BOARD_COMMIT::BOARD_COMMIT ( TOOL_MANAGER aToolMgr)

Definition at line 40 of file board_commit.cpp.

40  :
41  m_toolMgr( aToolMgr ),
42  m_isFootprintEditor( false ),
43  m_resolveNetConflicts( false )
44 {
45 }
bool m_isFootprintEditor
Definition: board_commit.h:73
TOOL_MANAGER * m_toolMgr
Definition: board_commit.h:72
bool m_resolveNetConflicts
Definition: board_commit.h:74

◆ BOARD_COMMIT() [2/3]

BOARD_COMMIT::BOARD_COMMIT ( EDA_DRAW_FRAME aFrame)

Definition at line 56 of file board_commit.cpp.

56  :
57  m_resolveNetConflicts( false )
58 {
59  m_toolMgr = aFrame->GetToolManager();
61 }
bool m_isFootprintEditor
Definition: board_commit.h:73
TOOL_MANAGER * m_toolMgr
Definition: board_commit.h:72
bool m_resolveNetConflicts
Definition: board_commit.h:74
bool IsType(FRAME_T aType) const
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54

References FRAME_FOOTPRINT_EDITOR, TOOLS_HOLDER::GetToolManager(), EDA_BASE_FRAME::IsType(), m_isFootprintEditor, and m_toolMgr.

◆ BOARD_COMMIT() [3/3]

BOARD_COMMIT::BOARD_COMMIT ( PCB_TOOL_BASE aTool)

Definition at line 48 of file board_commit.cpp.

48  :
49  m_resolveNetConflicts( false )
50 {
51  m_toolMgr = aTool->GetManager();
53 }
bool m_isFootprintEditor
Definition: board_commit.h:73
TOOL_MANAGER * m_toolMgr
Definition: board_commit.h:72
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143
bool m_resolveNetConflicts
Definition: board_commit.h:74
bool IsFootprintEditor() const

References TOOL_BASE::GetManager(), PCB_TOOL_BASE::IsFootprintEditor(), m_isFootprintEditor, and m_toolMgr.

◆ ~BOARD_COMMIT()

BOARD_COMMIT::~BOARD_COMMIT ( )
virtual

Definition at line 64 of file board_commit.cpp.

65 {
66 }

Member Function Documentation

◆ Add()

◆ Added()

COMMIT& COMMIT::Added ( EDA_ITEM aItem)
inlineinherited

Remove a new item from the model.

Definition at line 84 of file commit.h.

References CHT_ADD, CHT_DONE, and COMMIT::Stage().

Referenced by PCB_EDIT_FRAME::RunActionPlugin().

◆ clear()

void COMMIT::clear ( )
inlineprotectedinherited

Definition at line 157 of file commit.h.

158  {
159  m_changedItems.clear();
160  m_changes.clear();
161  }
std::set< EDA_ITEM * > m_changedItems
Definition: commit.h:178
std::vector< COMMIT_LINE > m_changes
Definition: commit.h:179

References COMMIT::m_changedItems, and COMMIT::m_changes.

Referenced by Push(), and Revert().

◆ convert()

CHANGE_TYPE COMMIT::convert ( UNDO_REDO  aType) const
protectedinherited

Definition at line 192 of file commit.cpp.

193 {
194  switch( aType )
195  {
196  case UNDO_REDO::NEWITEM:
197  return CHT_ADD;
198 
199  case UNDO_REDO::DELETED:
200  return CHT_REMOVE;
201 
202  default:
203  assert( false );
205 
206  case UNDO_REDO::CHANGED:
207  return CHT_MODIFY;
208  }
209 }
Definition: commit.h:40
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83

References CHANGED, CHT_ADD, CHT_MODIFY, CHT_REMOVE, DELETED, KI_FALLTHROUGH, and NEWITEM.

Referenced by COMMIT::Stage().

◆ createModified()

COMMIT & COMMIT::createModified ( EDA_ITEM aItem,
EDA_ITEM aCopy,
int  aExtraFlags = 0 
)
protectedinherited

Definition at line 139 of file commit.cpp.

140 {
141  EDA_ITEM* parent = parentObject( aItem );
142  auto entryIt = m_changedItems.find( parent );
143 
144  if( entryIt != m_changedItems.end() )
145  {
146  delete aCopy;
147  return *this; // item has been already modified once
148  }
149 
150  makeEntry( parent, CHT_MODIFY | aExtraFlags, aCopy );
151 
152  return *this;
153 }
virtual void makeEntry(EDA_ITEM *aItem, CHANGE_TYPE aType, EDA_ITEM *aCopy=nullptr)
Definition: commit.cpp:156
std::set< EDA_ITEM * > m_changedItems
Definition: commit.h:178
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
virtual EDA_ITEM * parentObject(EDA_ITEM *aItem) const =0

References CHT_MODIFY, COMMIT::m_changedItems, COMMIT::makeEntry(), and COMMIT::parentObject().

Referenced by COMMIT::Modified(), and COMMIT::Stage().

◆ Empty()

bool COMMIT::Empty ( ) const
inlineinherited

Returns status of an item.

Definition at line 140 of file commit.h.

References COMMIT::m_changes.

Referenced by DIALOG_CLEANUP_GRAPHICS::doCleanup(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), and Push().

◆ findEntry()

COMMIT::COMMIT_LINE * COMMIT::findEntry ( EDA_ITEM aItem)
protectedinherited

Search for an entry describing change for a particular item.

Returns
null if there is no related entry.

Definition at line 180 of file commit.cpp.

181 {
182  for( COMMIT_LINE& change : m_changes )
183  {
184  if( change.m_item == aItem )
185  return &change;
186  }
187 
188  return nullptr;
189 }
std::vector< COMMIT_LINE > m_changes
Definition: commit.h:179

References COMMIT::m_changes.

Referenced by COMMIT::GetStatus().

◆ GetBoard()

BOARD * BOARD_COMMIT::GetBoard ( ) const

Definition at line 69 of file board_commit.cpp.

70 {
71  return static_cast<BOARD*>( m_toolMgr->GetModel() );
72 }
TOOL_MANAGER * m_toolMgr
Definition: board_commit.h:72
EDA_ITEM * GetModel() const
Definition: tool_manager.h:290

References TOOL_MANAGER::GetModel(), and m_toolMgr.

Referenced by GRAPHICS_CLEANER::CleanupBoard().

◆ GetStatus()

int COMMIT::GetStatus ( EDA_ITEM aItem)
inherited

Definition at line 131 of file commit.cpp.

132 {
133  COMMIT_LINE* entry = findEntry( parentObject( aItem ) );
134 
135  return entry ? entry->m_type : 0;
136 }
COMMIT_LINE * findEntry(EDA_ITEM *aItem)
Search for an entry describing change for a particular item.
Definition: commit.cpp:180
virtual EDA_ITEM * parentObject(EDA_ITEM *aItem) const =0

References COMMIT::findEntry(), COMMIT::COMMIT_LINE::m_type, and COMMIT::parentObject().

Referenced by BOARD_NETLIST_UPDATER::updateComponentPadConnections(), and BOARD_NETLIST_UPDATER::updateFootprintParameters().

◆ makeEntry()

void COMMIT::makeEntry ( EDA_ITEM aItem,
CHANGE_TYPE  aType,
EDA_ITEM aCopy = nullptr 
)
protectedvirtualinherited

Definition at line 156 of file commit.cpp.

157 {
158  // Expect an item copy if it is going to be modified
159  wxASSERT( !!aCopy == ( ( aType & CHT_TYPE ) == CHT_MODIFY ) );
160 
161  if( m_changedItems.find( aItem ) != m_changedItems.end() )
162  {
163  alg::delete_if( m_changes, [aItem]( const COMMIT_LINE& aEnt )
164  {
165  return aEnt.m_item == aItem;
166  } );
167  }
168 
169  COMMIT_LINE ent;
170 
171  ent.m_item = aItem;
172  ent.m_type = aType;
173  ent.m_copy = aCopy;
174 
175  m_changedItems.insert( aItem );
176  m_changes.push_back( ent );
177 }
Flag to indicate the change is already applied, just notify observers (not compatible with CHT_MODIFY...
Definition: commit.h:43
std::set< EDA_ITEM * > m_changedItems
Definition: commit.h:178
std::vector< COMMIT_LINE > m_changes
Definition: commit.h:179
void delete_if(_Container &__c, _Function &&__f)
Deletes all values from __c for which __f returns true.
Definition: kicad_algo.h:173

References CHT_MODIFY, CHT_TYPE, alg::delete_if(), COMMIT::m_changedItems, COMMIT::m_changes, COMMIT::COMMIT_LINE::m_copy, COMMIT::COMMIT_LINE::m_item, and COMMIT::COMMIT_LINE::m_type.

Referenced by COMMIT::createModified(), and COMMIT::Stage().

◆ Modified()

COMMIT& COMMIT::Modified ( EDA_ITEM aItem,
EDA_ITEM aCopy 
)
inlineinherited

Definition at line 110 of file commit.h.

111  {
112  return createModified( aItem, aCopy );
113  }
COMMIT & createModified(EDA_ITEM *aItem, EDA_ITEM *aCopy, int aExtraFlags=0)
Definition: commit.cpp:139

References COMMIT::createModified().

Referenced by COMMIT::Stage(), BOARD_NETLIST_UPDATER::updateComponentPadConnections(), and BOARD_NETLIST_UPDATER::updateFootprintParameters().

◆ Modify()

COMMIT& COMMIT::Modify ( EDA_ITEM aItem)
inlineinherited

Create an undo entry for an item that has been already modified.

Requires a copy done before the modification.

Definition at line 103 of file commit.h.

References CHT_MODIFY, and COMMIT::Stage().

Referenced by PCB_POINT_EDITOR::addCorner(), AR_AUTOPLACER::AutoplaceFootprints(), doPushPadProperties(), DRAWING_TOOL::DrawVia(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), ZONE_FILLER::Fill(), ARRAY_CREATOR::Invoke(), TRACKS_CLEANER::mergeCollinearSegments(), mergeZones(), BOARD_EDITOR_CONTROL::modifyLockSelected(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), PAD_TOOL::pastePadProperties(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), CN_CONNECTIVITY_ALGO::propagateConnections(), DIALOG_BOARD_REANNOTATE::ReannotateBoard(), PAD_TOOL::recombinePad(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), DRAWING_TOOL::SetAnchor(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_GROUP_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), BOARD_NETLIST_UPDATER::updateCopperZoneNets(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), ZONE_FILLER_TOOL::ZoneUnfill(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ parentObject()

EDA_ITEM * BOARD_COMMIT::parentObject ( EDA_ITEM aItem) const
overrideprivatevirtual

Implements COMMIT.

Definition at line 442 of file board_commit.cpp.

443 {
444  switch( aItem->Type() )
445  {
446  case PCB_PAD_T:
447  case PCB_FP_SHAPE_T:
448  case PCB_FP_TEXT_T:
449  case PCB_FP_ZONE_T:
450  return aItem->GetParent();
451 
452  case PCB_ZONE_T:
453  wxASSERT( !dynamic_cast<FOOTPRINT*>( aItem->GetParent() ) );
454  return aItem;
455 
456  default:
457  break;
458  }
459 
460  return aItem;
461 }
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PAD, a pad in a footprint
Definition: typeinfo.h:89
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
class ZONE, a copper pour area
Definition: typeinfo.h:105
class ZONE, managed by a footprint
Definition: typeinfo.h:94
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References EDA_ITEM::GetParent(), PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_ZONE_T, PCB_PAD_T, PCB_ZONE_T, and EDA_ITEM::Type().

◆ Push()

void BOARD_COMMIT::Push ( const wxString &  aMessage = wxT("A commit"),
bool  aCreateUndoEntry = true,
bool  aSetDirtyBit = true 
)
overridevirtual

Revert the commit by restoring the modified items state.

Implements COMMIT.

Definition at line 103 of file board_commit.cpp.

104 {
105  // Objects potentially interested in changes:
106  PICKED_ITEMS_LIST undoList;
107  KIGFX::VIEW* view = m_toolMgr->GetView();
108  BOARD* board = (BOARD*) m_toolMgr->GetModel();
109  PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
110  auto connectivity = board->GetConnectivity();
111  std::set<EDA_ITEM*> savedModules;
113  bool itemsDeselected = false;
114 
115  std::vector<BOARD_ITEM*> bulkAddedItems;
116  std::vector<BOARD_ITEM*> bulkRemovedItems;
117  std::vector<BOARD_ITEM*> itemsChanged;
118 
119  if( Empty() )
120  return;
121 
122  for( COMMIT_LINE& ent : m_changes )
123  {
124  int changeType = ent.m_type & CHT_TYPE;
125  int changeFlags = ent.m_type & CHT_FLAGS;
126  BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
127 
128  wxASSERT( ent.m_item );
129 
130  // Module items need to be saved in the undo buffer before modification
131  if( m_isFootprintEditor )
132  {
133  // Be sure that we are storing a footprint
134  if( ent.m_item->Type() != PCB_FOOTPRINT_T )
135  {
136  ent.m_item = ent.m_item->GetParent();
137  wxASSERT( ent.m_item );
138  }
139 
140  // We have not saved the footprint yet, so let's create an entry
141  if( savedModules.count( ent.m_item ) == 0 )
142  {
143  if( !ent.m_copy )
144  {
145  wxASSERT( changeType != CHT_MODIFY ); // too late to make a copy..
146  ent.m_copy = ent.m_item->Clone();
147  }
148 
149  wxASSERT( ent.m_item->Type() == PCB_FOOTPRINT_T );
150  wxASSERT( ent.m_copy->Type() == PCB_FOOTPRINT_T );
151 
152  if( aCreateUndoEntry && frame )
153  {
154  ITEM_PICKER itemWrapper( nullptr, ent.m_item, UNDO_REDO::CHANGED );
155  itemWrapper.SetLink( ent.m_copy );
156  undoList.PushItem( itemWrapper );
157  frame->SaveCopyInUndoList( undoList, UNDO_REDO::CHANGED );
158  }
159 
160  savedModules.insert( ent.m_item );
161  }
162  }
163 
164  switch( changeType )
165  {
166  case CHT_ADD:
167  {
168  if( m_isFootprintEditor )
169  {
170  // footprints inside footprints are not supported yet
171  wxASSERT( boardItem->Type() != PCB_FOOTPRINT_T );
172 
173  boardItem->SetParent( board->Footprints().front() );
174 
175  if( !( changeFlags & CHT_DONE ) )
176  board->Footprints().front()->Add( boardItem );
177  }
178  else if( boardItem->Type() == PCB_PAD_T ||
179  boardItem->Type() == PCB_FP_TEXT_T ||
180  boardItem->Type() == PCB_FP_SHAPE_T ||
181  boardItem->Type() == PCB_FP_ZONE_T )
182  {
183  wxASSERT( boardItem->GetParent() &&
184  boardItem->GetParent()->Type() == PCB_FOOTPRINT_T );
185  }
186  else
187  {
188  if( aCreateUndoEntry )
189  undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::NEWITEM ) );
190 
191  if( !( changeFlags & CHT_DONE ) )
192  {
193  board->Add( boardItem, ADD_MODE::BULK_INSERT ); // handles connectivity
194  bulkAddedItems.push_back( boardItem );
195  }
196  }
197 
198  if( view && boardItem->Type() != PCB_NETINFO_T )
199  view->Add( boardItem );
200 
201  break;
202  }
203 
204  case CHT_REMOVE:
205  {
206  PCB_GROUP* parentGroup = boardItem->GetParentGroup();
207 
208  if( !m_isFootprintEditor && aCreateUndoEntry )
209  undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::DELETED ) );
210 
211  if( boardItem->IsSelected() )
212  {
213  selTool->RemoveItemFromSel( boardItem, true /* quiet mode */ );
214  itemsDeselected = true;
215  }
216 
217  switch( boardItem->Type() )
218  {
219  // Footprint items
220  case PCB_PAD_T:
221  case PCB_FP_SHAPE_T:
222  case PCB_FP_TEXT_T:
223  case PCB_FP_ZONE_T:
224  // This level can only handle footprint children in the footprint editor as
225  // only in that case has the entire footprint (and all its children) already
226  // been saved for undo.
227  wxASSERT( m_isFootprintEditor );
228 
229  if( boardItem->Type() == PCB_FP_TEXT_T )
230  {
231  FP_TEXT* text = static_cast<FP_TEXT*>( boardItem );
232 
233  // don't allow deletion of Reference or Value
234  if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
235  break;
236  }
237 
238  if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
239  parentGroup->RemoveItem( boardItem );
240 
241  if( view )
242  view->Remove( boardItem );
243 
244  if( !( changeFlags & CHT_DONE ) )
245  {
246  FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem->GetParent() );
247  wxASSERT( footprint && footprint->Type() == PCB_FOOTPRINT_T );
248  footprint->Delete( boardItem );
249  }
250 
251  break;
252 
253  // Board items
254  case PCB_SHAPE_T: // a shape (normally not on copper layers)
255  case PCB_TEXT_T: // a text on a layer
256  case PCB_TRACE_T: // a track segment (segment on a copper layer)
257  case PCB_ARC_T: // an arced track segment (segment on a copper layer)
258  case PCB_VIA_T: // a via (like track segment on a copper layer)
259  case PCB_DIM_ALIGNED_T: // a dimension (graphic item)
260  case PCB_DIM_CENTER_T:
262  case PCB_DIM_LEADER_T: // a leader dimension
263  case PCB_TARGET_T: // a target (graphic item)
264  case PCB_MARKER_T: // a marker used to show something
265  case PCB_ZONE_T:
266  if( view )
267  view->Remove( boardItem );
268 
269  if( !( changeFlags & CHT_DONE ) )
270  {
271  board->Remove( boardItem, REMOVE_MODE::BULK );
272  bulkRemovedItems.push_back( boardItem );
273  }
274 
275  break;
276 
277  case PCB_FOOTPRINT_T:
278  {
279  // No support for nested footprints (yet)
280  wxASSERT( !m_isFootprintEditor );
281 
282  FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem );
283 
284  if( view )
285  view->Remove( footprint );
286 
287  footprint->ClearFlags();
288 
289  if( !( changeFlags & CHT_DONE ) )
290  {
291  board->Remove( footprint, REMOVE_MODE::BULK ); // handles connectivity
292  bulkRemovedItems.push_back( footprint );
293  }
294  }
295  break;
296 
297  case PCB_GROUP_T:
298  if( view )
299  view->Remove( boardItem );
300 
301  if( !( changeFlags & CHT_DONE ) )
302  {
303  if( m_isFootprintEditor )
304  board->GetFirstFootprint()->Remove( boardItem );
305  else
306  {
307  board->Remove( boardItem, REMOVE_MODE::BULK );
308  bulkRemovedItems.push_back( boardItem );
309  }
310  }
311  break;
312 
313  // Metadata items
314  case PCB_NETINFO_T:
315  board->Remove( boardItem, REMOVE_MODE::BULK );
316  bulkRemovedItems.push_back( boardItem );
317  break;
318 
319  default: // other types do not need to (or should not) be handled
320  wxASSERT( false );
321  break;
322  }
323 
324  break;
325  }
326 
327  case CHT_MODIFY:
328  {
329  if( !m_isFootprintEditor && aCreateUndoEntry )
330  {
331  ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
332  wxASSERT( ent.m_copy );
333  itemWrapper.SetLink( ent.m_copy );
334  undoList.PushItem( itemWrapper );
335  }
336 
337  if( ent.m_copy )
338  connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
339 
340  connectivity->Update( boardItem );
341 
342  if( view )
343  {
344  view->Update( boardItem );
345 
346  if( m_isFootprintEditor )
347  {
348  static_cast<FOOTPRINT*>( boardItem )->RunOnChildren(
349  [&]( BOARD_ITEM* aChild )
350  {
351  view->Update( aChild );
352  });
353  }
354  }
355 
356  itemsChanged.push_back( boardItem );
357 
358  // if no undo entry is needed, the copy would create a memory leak
359  if( !aCreateUndoEntry )
360  delete ent.m_copy;
361 
362  break;
363  }
364 
365  default:
366  wxASSERT( false );
367  break;
368  }
369  }
370 
371  if( bulkAddedItems.size() > 0 )
372  board->FinalizeBulkAdd( bulkAddedItems );
373 
374  if( bulkRemovedItems.size() > 0 )
375  board->FinalizeBulkRemove( bulkRemovedItems );
376 
377  if( itemsChanged.size() > 0 )
378  board->OnItemsChanged( itemsChanged );
379 
380  if( !m_isFootprintEditor )
381  {
382  size_t num_changes = m_changes.size();
383 
385  connectivity->PropagateNets( this, PROPAGATE_MODE::RESOLVE_CONFLICTS );
386 
387  connectivity->RecalculateRatsnest( this );
388  connectivity->ClearDynamicRatsnest();
389 
390  if( frame )
391  frame->GetCanvas()->RedrawRatsnest();
392 
393  if( m_changes.size() > num_changes )
394  {
395  for( size_t i = num_changes; i < m_changes.size(); ++i )
396  {
397  COMMIT_LINE& ent = m_changes[i];
398 
399  // This should only be modifications from the connectivity algo
400  wxASSERT( ( ent.m_type & CHT_TYPE ) == CHT_MODIFY );
401 
402  BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
403 
404  if( aCreateUndoEntry )
405  {
406  ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
407  wxASSERT( ent.m_copy );
408  itemWrapper.SetLink( ent.m_copy );
409  undoList.PushItem( itemWrapper );
410  }
411  else
412  {
413  delete ent.m_copy;
414  }
415 
416  if( view )
417  view->Update( boardItem );
418  }
419  }
420  }
421 
422  if( !m_isFootprintEditor && aCreateUndoEntry && frame )
423  frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED );
424 
426 
427  if( itemsDeselected )
429 
430  if( frame )
431  {
432  if( aSetDirtyBit )
433  frame->OnModify();
434  else
435  frame->Update3DView( true, frame->GetDisplayOptions().m_Live3DRefresh );
436  }
437 
438  clear();
439 }
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:60
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:100
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:101
void clear()
Definition: commit.h:157
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
bool IsSelected() const
Definition: eda_item.h:122
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:201
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:102
Flag to indicate the change is already applied, just notify observers (not compatible with CHT_MODIFY...
Definition: commit.h:43
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: commit.h:40
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:350
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: footprint.cpp:566
bool m_isFootprintEditor
Definition: board_commit.h:73
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PAD, a pad in a footprint
Definition: typeinfo.h:89
TOOL_MANAGER * m_toolMgr
Definition: board_commit.h:72
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
EDA_ITEM * GetModel() const
Definition: tool_manager.h:290
Clusters with conflicting drivers are not updated (default)
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:115
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void FinalizeBulkRemove(std::vector< BOARD_ITEM * > &aRemovedItems)
Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners.
Definition: board.cpp:704
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
bool m_resolveNetConflicts
Definition: board_commit.h:74
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:318
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:206
FOOTPRINTS & Footprints()
Definition: board.h:234
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:345
void OnItemsChanged(std::vector< BOARD_ITEM * > &aItems)
Notify the board and its listeners that an item on the board has been modified in some way.
Definition: board.cpp:1940
#define STRUCT_DELETED
flag indication structures to be erased
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
Definition: pcb_group.cpp:51
class ZONE, a copper pour area
Definition: typeinfo.h:105
A holder to handle information on schematic or board items.
bool Empty() const
Returns status of an item.
Definition: commit.h:140
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:154
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
void FinalizeBulkAdd(std::vector< BOARD_ITEM * > &aNewItems)
Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners.
Definition: board.cpp:698
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:294
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:98
Global action (toolbar/main menu event, global shortcut)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
bool m_Live3DRefresh
If true, 3D viewer will redraw on every modification operation.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:107
std::vector< COMMIT_LINE > m_changes
Definition: commit.h:179
class ZONE, managed by a footprint
Definition: typeinfo.h:94
The selection tool: currently supports:
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:710
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)=0
Create a new entry in undo list of commands.
virtual void Delete(BOARD_ITEM *aItem)
Removes an item from the container and deletes it.
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:103
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:320
void RemoveItemFromSel(BOARD_ITEM *aItem, bool aQuietMode=false)
Multiple item unselection event handler.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:136
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1570
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References KIGFX::VIEW::Add(), BOARD::Add(), AS_GLOBAL, BULK, BULK_INSERT, CHANGED, CHT_ADD, CHT_DONE, CHT_FLAGS, CHT_MODIFY, CHT_REMOVE, CHT_TYPE, COMMIT::clear(), EDA_ITEM::ClearFlags(), BOARD_ITEM_CONTAINER::Delete(), DELETED, COMMIT::Empty(), BOARD::FinalizeBulkAdd(), BOARD::FinalizeBulkRemove(), BOARD::Footprints(), PCB_BASE_FRAME::GetCanvas(), BOARD::GetConnectivity(), PCB_BASE_FRAME::GetDisplayOptions(), BOARD::GetFirstFootprint(), EDA_ITEM::GetFlags(), TOOL_MANAGER::GetModel(), BOARD_ITEM::GetParent(), BOARD_ITEM::GetParentGroup(), TOOL_MANAGER::GetTool(), TOOL_MANAGER::GetToolHolder(), TOOL_MANAGER::GetView(), EDA_ITEM::IsSelected(), COMMIT::m_changes, COMMIT::COMMIT_LINE::m_copy, m_isFootprintEditor, COMMIT::COMMIT_LINE::m_item, PCB_DISPLAY_OPTIONS::m_Live3DRefresh, m_resolveNetConflicts, m_toolMgr, COMMIT::COMMIT_LINE::m_type, TOOL_BASE::m_type, NEWITEM, BOARD::OnItemsChanged(), PCB_BASE_FRAME::OnModify(), PCB_ARC_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_MARKER_T, PCB_NETINFO_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, TOOL_MANAGER::PostEvent(), PICKED_ITEMS_LIST::PushItem(), PCB_DRAW_PANEL_GAL::RedrawRatsnest(), KIGFX::VIEW::Remove(), FOOTPRINT::Remove(), BOARD::Remove(), PCB_GROUP::RemoveItem(), PCB_SELECTION_TOOL::RemoveItemFromSel(), RESOLVE_CONFLICTS, PCB_BASE_FRAME::SaveCopyInUndoList(), ITEM_PICKER::SetLink(), EDA_ITEM::SetParent(), STRUCT_DELETED, TA_MODEL_CHANGE, TC_MESSAGE, text, FP_TEXT::TEXT_is_DIVERS, EDA_ITEM::Type(), EVENTS::UnselectedEvent, UNSPECIFIED, KIGFX::VIEW::Update(), and PCB_BASE_FRAME::Update3DView().

Referenced by PCB_POINT_EDITOR::addCorner(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), AUTOPLACE_TOOL::autoplace(), ZONE_FILLER_TOOL::CheckAllZones(), ZONE_CREATE_HELPER::commitZone(), MICROWAVE_TOOL::createInductorBetween(), CONVERT_TOOL::CreateLines(), CONVERT_TOOL::CreatePolys(), ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), ALIGN_DISTRIBUTE_TOOL::DistributeVertically(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), DIALOG_CLEANUP_GRAPHICS::doCleanup(), DIALOG_GLOBAL_DELETION::DoGlobalDeletions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawBoardCharacteristics(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawSpecificationStackup(), PCB_EDIT_FRAME::Edit_Zone_Params(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), ZONE_FILLER_TOOL::FillAllZones(), KI_TEST::FillZones(), DRAWING_TOOL::InteractivePlaceWithPreview(), ARRAY_CREATOR::Invoke(), BOARD_EDITOR_CONTROL::modifyLockSelected(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), DIALOG_EXCHANGE_FOOTPRINTS::OnOKClicked(), PCB_POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), ZONE_CREATE_HELPER::performZoneCutout(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImportedGraphics(), DRAWING_TOOL::PlaceText(), PAD_TOOL::pushPadSettings(), DIALOG_BOARD_REANNOTATE::ReannotateBoard(), PAD_TOOL::recombinePad(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), PCB_EDIT_FRAME::ResolveDRCExclusions(), PCB_EDIT_FRAME::RunActionPlugin(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), CONVERT_TOOL::SegmentToArc(), DRAWING_TOOL::SetAnchor(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_GROUP_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), BOARD_NETLIST_UPDATER::UpdateNetlist(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), BOARD_EDITOR_CONTROL::ZoneMerge(), ZONE_FILLER_TOOL::ZoneUnfill(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ Remove()

◆ Removed()

COMMIT& COMMIT::Removed ( EDA_ITEM aItem)
inlineinherited

Modify a given item in the model.

Must be called before modification is performed.

Definition at line 96 of file commit.h.

References CHT_DONE, CHT_REMOVE, and COMMIT::Stage().

Referenced by TRACKS_CLEANER::deleteDanglingTracks(), TRACKS_CLEANER::mergeCollinearSegments(), TRACKS_CLEANER::removeItems(), PCB_EDIT_FRAME::RunActionPlugin(), and BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ Revert()

void BOARD_COMMIT::Revert ( )
overridevirtual

Implements COMMIT.

Definition at line 464 of file board_commit.cpp.

465 {
466  PICKED_ITEMS_LIST undoList;
467  KIGFX::VIEW* view = m_toolMgr->GetView();
468  BOARD* board = (BOARD*) m_toolMgr->GetModel();
469  auto connectivity = board->GetConnectivity();
470 
471  std::vector<BOARD_ITEM*> bulkAddedItems;
472  std::vector<BOARD_ITEM*> bulkRemovedItems;
473  std::vector<BOARD_ITEM*> itemsChanged;
474 
475  for( auto it = m_changes.rbegin(); it != m_changes.rend(); ++it )
476  {
477  COMMIT_LINE& ent = *it;
478  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( ent.m_item );
479  BOARD_ITEM* copy = static_cast<BOARD_ITEM*>( ent.m_copy );
480  int changeType = ent.m_type & CHT_TYPE;
481  int changeFlags = ent.m_type & CHT_FLAGS;
482 
483  switch( changeType )
484  {
485  case CHT_ADD:
486  if( !( changeFlags & CHT_DONE ) )
487  break;
488 
489  view->Remove( item );
490  connectivity->Remove( item );
491  board->Remove( item, REMOVE_MODE::BULK );
492  bulkRemovedItems.push_back( item );
493  break;
494 
495  case CHT_REMOVE:
496  if( !( changeFlags & CHT_DONE ) )
497  break;
498 
499  view->Add( item );
500  connectivity->Add( item );
501  board->Add( item, ADD_MODE::INSERT );
502  bulkAddedItems.push_back( item );
503  break;
504 
505  case CHT_MODIFY:
506  {
507  view->Remove( item );
508  connectivity->Remove( item );
509 
510  item->SwapData( copy );
511 
512  view->Add( item );
513  connectivity->Add( item );
514  board->OnItemChanged( item );
515  itemsChanged.push_back( item );
516 
517  delete copy;
518  break;
519  }
520 
521  default:
522  wxASSERT( false );
523  break;
524  }
525  }
526 
527  if( bulkAddedItems.size() > 0 )
528  board->FinalizeBulkAdd( bulkAddedItems );
529 
530  if( bulkRemovedItems.size() > 0 )
531  board->FinalizeBulkRemove( bulkRemovedItems );
532 
533  if( itemsChanged.size() > 0 )
534  board->OnItemsChanged( itemsChanged );
535 
536  if ( !m_isFootprintEditor )
537  connectivity->RecalculateRatsnest();
538 
540  selTool->RebuildSelection();
541 
542  clear();
543 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
void clear()
Definition: commit.h:157
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
Flag to indicate the change is already applied, just notify observers (not compatible with CHT_MODIFY...
Definition: commit.h:43
Definition: commit.h:40
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:350
bool m_isFootprintEditor
Definition: board_commit.h:73
TOOL_MANAGER * m_toolMgr
Definition: board_commit.h:72
EDA_ITEM * GetModel() const
Definition: tool_manager.h:290
void FinalizeBulkRemove(std::vector< BOARD_ITEM * > &aRemovedItems)
Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners.
Definition: board.cpp:704
void RebuildSelection()
Rebuild the selection from the EDA_ITEMs' selection flags.
virtual void SwapData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
Definition: board_item.cpp:139
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:345
void OnItemsChanged(std::vector< BOARD_ITEM * > &aItems)
Notify the board and its listeners that an item on the board has been modified in some way.
Definition: board.cpp:1940
A holder to handle information on schematic or board items.
void FinalizeBulkAdd(std::vector< BOARD_ITEM * > &aNewItems)
Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners.
Definition: board.cpp:698
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
std::vector< COMMIT_LINE > m_changes
Definition: commit.h:179
The selection tool: currently supports:
void OnItemChanged(BOARD_ITEM *aItem)
Notify the board and its listeners that an item on the board has been modified in some way.
Definition: board.cpp:1934
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:710
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:320
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68

References KIGFX::VIEW::Add(), BOARD::Add(), BULK, CHT_ADD, CHT_DONE, CHT_FLAGS, CHT_MODIFY, CHT_REMOVE, CHT_TYPE, COMMIT::clear(), copy, BOARD::FinalizeBulkAdd(), BOARD::FinalizeBulkRemove(), BOARD::GetConnectivity(), TOOL_MANAGER::GetModel(), TOOL_MANAGER::GetTool(), TOOL_MANAGER::GetView(), INSERT, COMMIT::m_changes, COMMIT::COMMIT_LINE::m_copy, m_isFootprintEditor, COMMIT::COMMIT_LINE::m_item, m_toolMgr, COMMIT::COMMIT_LINE::m_type, BOARD::OnItemChanged(), BOARD::OnItemsChanged(), PCB_SELECTION_TOOL::RebuildSelection(), KIGFX::VIEW::Remove(), BOARD::Remove(), and BOARD_ITEM::SwapData().

Referenced by AUTOPLACE_TOOL::autoplace(), ZONE_FILLER_TOOL::CheckAllZones(), PAD_TOOL::EnumeratePads(), ZONE_FILLER_TOOL::FillAllZones(), mergeZones(), PCB_POINT_EDITOR::OnSelectionChange(), BOARD_EDITOR_CONTROL::PlaceFootprint(), and ZONE_FILLER_TOOL::ZoneFill().

◆ SetResolveNetConflicts()

void BOARD_COMMIT::SetResolveNetConflicts ( bool  aResolve = true)
inline

Sets a flag that will cause Push() to resolve net conflicts on track/via clusters instead of the default behavior which is to skip updating track/via clusters that have conflicts.

This is used in the netlist updater to update any clusters that were changed due to pad nets changing, but should not be used for other changes as you typically don't want to change track/via nets due to temporary conflicts created by board editing operations.

Parameters
aResolveis true if this commit should resolve conflicting track/via net assignments

Definition at line 66 of file board_commit.h.

66 { m_resolveNetConflicts = aResolve; }
bool m_resolveNetConflicts
Definition: board_commit.h:74

References m_resolveNetConflicts.

Referenced by BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ Stage() [1/3]

COMMIT & BOARD_COMMIT::Stage ( EDA_ITEM aItem,
CHANGE_TYPE  aChangeType 
)
overridevirtual

Reimplemented from COMMIT.

Definition at line 75 of file board_commit.cpp.

76 {
77  // if aItem belongs a footprint, the full footprint will be saved
78  // because undo/redo does not handle "sub items" modifications
79  if( aItem && aItem->Type() != PCB_FOOTPRINT_T && aChangeType == CHT_MODIFY )
80  {
81  EDA_ITEM* item = aItem->GetParent();
82 
83  if( item && item->Type() == PCB_FOOTPRINT_T ) // means aItem belongs a footprint
84  aItem = item;
85  }
86 
87  return COMMIT::Stage( aItem, aChangeType );
88 }
virtual COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType)
Definition: commit.cpp:48
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References CHT_MODIFY, EDA_ITEM::GetParent(), PCB_FOOTPRINT_T, COMMIT::Stage(), and EDA_ITEM::Type().

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), and PCB_EDIT_FRAME::Edit_Zone_Params().

◆ Stage() [2/3]

COMMIT & BOARD_COMMIT::Stage ( std::vector< EDA_ITEM * > &  container,
CHANGE_TYPE  aChangeType 
)
overridevirtual

Reimplemented from COMMIT.

Definition at line 91 of file board_commit.cpp.

92 {
93  return COMMIT::Stage( container, aChangeType );
94 }
virtual COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType)
Definition: commit.cpp:48

References COMMIT::Stage().

◆ Stage() [3/3]

COMMIT & BOARD_COMMIT::Stage ( const PICKED_ITEMS_LIST aItems,
UNDO_REDO  aModFlag = UNDO_REDO::UNSPECIFIED 
)
overridevirtual

Execute the changes.

Reimplemented from COMMIT.

Definition at line 97 of file board_commit.cpp.

98 {
99  return COMMIT::Stage( aItems, aModFlag );
100 }
virtual COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType)
Definition: commit.cpp:48

References COMMIT::Stage().

◆ StageItems()

template<class Range >
COMMIT& COMMIT::StageItems ( const Range &  aRange,
CHANGE_TYPE  aChangeType 
)
inlineinherited

Add a change of the item aItem of type aChangeType to the change list.

Definition at line 117 of file commit.h.

References COMMIT::Stage().

Referenced by PCB_POINT_EDITOR::OnSelectionChange().

Member Data Documentation

◆ m_changedItems

std::set<EDA_ITEM*> COMMIT::m_changedItems
protectedinherited

Definition at line 178 of file commit.h.

Referenced by COMMIT::clear(), COMMIT::createModified(), COMMIT::makeEntry(), and COMMIT::Stage().

◆ m_changes

std::vector<COMMIT_LINE> COMMIT::m_changes
protectedinherited

◆ m_isFootprintEditor

bool BOARD_COMMIT::m_isFootprintEditor
private

Definition at line 73 of file board_commit.h.

Referenced by BOARD_COMMIT(), Push(), and Revert().

◆ m_resolveNetConflicts

bool BOARD_COMMIT::m_resolveNetConflicts
private

Definition at line 74 of file board_commit.h.

Referenced by Push(), and SetResolveNetConflicts().

◆ m_toolMgr

TOOL_MANAGER* BOARD_COMMIT::m_toolMgr
private

Definition at line 72 of file board_commit.h.

Referenced by BOARD_COMMIT(), GetBoard(), Push(), and Revert().


The documentation for this class was generated from the following files: