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"), int aCommitFlags=0) 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

EDA_ITEMparentObject (EDA_ITEM *aItem) const override
 
EDA_ITEMmakeImage (EDA_ITEM *aItem) const override
 
void dirtyIntersectingZones (BOARD_ITEM *item)
 

Private Attributes

TOOL_MANAGERm_toolMgr
 
bool m_isFootprintEditor
 
bool m_isBoardEditor
 
bool m_resolveNetConflicts
 

Detailed Description

Definition at line 45 of file board_commit.h.

Constructor & Destructor Documentation

◆ BOARD_COMMIT() [1/3]

BOARD_COMMIT::BOARD_COMMIT ( TOOL_MANAGER aToolMgr)

Definition at line 42 of file board_commit.cpp.

42 :
43 m_toolMgr( aToolMgr ),
44 m_isFootprintEditor( false ),
45 m_isBoardEditor( false ),
47{
48}
bool m_isBoardEditor
Definition: board_commit.h:85
TOOL_MANAGER * m_toolMgr
Definition: board_commit.h:83
bool m_isFootprintEditor
Definition: board_commit.h:84
bool m_resolveNetConflicts
Definition: board_commit.h:86

◆ BOARD_COMMIT() [2/3]

BOARD_COMMIT::BOARD_COMMIT ( EDA_DRAW_FRAME aFrame)

Definition at line 60 of file board_commit.cpp.

60 :
62{
63 m_toolMgr = aFrame->GetToolManager();
66}
bool IsType(FRAME_T aType) const
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41

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

◆ BOARD_COMMIT() [3/3]

BOARD_COMMIT::BOARD_COMMIT ( PCB_TOOL_BASE aTool)

Definition at line 51 of file board_commit.cpp.

51 :
53{
54 m_toolMgr = aTool->GetManager();
57}
bool IsFootprintEditor() const
bool IsBoardEditor() const
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143

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

◆ ~BOARD_COMMIT()

BOARD_COMMIT::~BOARD_COMMIT ( )
virtual

Definition at line 69 of file board_commit.cpp.

70{
71}

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 TEARDROP_MANAGER::addTeardropsOnTracks(), PCB_EDIT_FRAME::RunActionPlugin(), and TEARDROP_MANAGER::SetTeardrops().

◆ clear()

void COMMIT::clear ( )
inlineprotectedinherited

Definition at line 156 of file commit.h.

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

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 184 of file commit.cpp.

185{
186 switch( aType )
187 {
189 return CHT_ADD;
190
192 return CHT_REMOVE;
193
194 default:
195 assert( false );
196 // Can't fall through if the assert fires, so quiet our warning
197#ifdef NDEBUG
199#endif
200
202 return CHT_MODIFY;
203 }
204}
@ CHT_MODIFY
Definition: commit.h:42
@ CHT_REMOVE
Definition: commit.h:41
@ CHT_ADD
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 131 of file commit.cpp.

132{
133 EDA_ITEM* parent = parentObject( aItem );
134 auto entryIt = m_changedItems.find( parent );
135
136 if( entryIt != m_changedItems.end() )
137 {
138 delete aCopy;
139 return *this; // item has been already modified once
140 }
141
142 makeEntry( parent, CHT_MODIFY | aExtraFlags, aCopy );
143
144 return *this;
145}
virtual void makeEntry(EDA_ITEM *aItem, CHANGE_TYPE aType, EDA_ITEM *aCopy=nullptr)
Definition: commit.cpp:148
virtual EDA_ITEM * parentObject(EDA_ITEM *aItem) const =0
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85

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

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

◆ dirtyIntersectingZones()

void BOARD_COMMIT::dirtyIntersectingZones ( BOARD_ITEM item)
private

Definition at line 108 of file board_commit.cpp.

109{
110 wxCHECK( item, /* void */ );
111
113
114 if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
115 zoneFillerTool->DirtyZone( static_cast<ZONE*>( item ) );
116
117 if( item->Type() == PCB_FOOTPRINT_T )
118 {
119 static_cast<FOOTPRINT*>( item )->RunOnChildren(
120 [&]( BOARD_ITEM* child )
121 {
122 dirtyIntersectingZones( child );
123 } );
124 }
125 else if( item->Type() == PCB_GROUP_T )
126 {
127 static_cast<PCB_GROUP*>( item )->RunOnChildren(
128 [&]( BOARD_ITEM* child )
129 {
130 dirtyIntersectingZones( child );
131 } );
132 }
133 else
134 {
135 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
136 BOX2I bbox = item->GetBoundingBox();
137 LSET layers = item->GetLayerSet();
138
139 if( layers.test( Edge_Cuts ) || layers.test( Margin ) )
140 layers = LSET::PhysicalLayersMask();
141 else
142 layers &= LSET::AllCuMask();
143
144 if( layers.any() )
145 {
146 for( ZONE* zone : board->Zones() )
147 {
148 if( zone->GetIsRuleArea() )
149 continue;
150
151 if( ( zone->GetLayerSet() & layers ).any()
152 && zone->GetBoundingBox().Intersects( bbox ) )
153 {
154 zoneFillerTool->DirtyZone( zone );
155 }
156 }
157 }
158 }
159}
void dirtyIntersectingZones(BOARD_ITEM *item)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:185
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
ZONES & Zones()
Definition: board.h:313
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:870
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
EDA_ITEM * GetModel() const
Definition: tool_manager.h:292
Handle actions specific to filling copper zones.
void DirtyZone(ZONE *aZone)
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
@ Edge_Cuts
Definition: layer_ids.h:113
@ Margin
Definition: layer_ids.h:114
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100

References LSET::AllCuMask(), dirtyIntersectingZones(), ZONE_FILLER_TOOL::DirtyZone(), Edge_Cuts, EDA_ITEM::GetBoundingBox(), BOARD_ITEM::GetLayerSet(), TOOL_MANAGER::GetModel(), TOOL_MANAGER::GetTool(), m_toolMgr, Margin, PCB_FOOTPRINT_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_ZONE_T, LSET::PhysicalLayersMask(), EDA_ITEM::Type(), and BOARD::Zones().

Referenced by dirtyIntersectingZones(), and Push().

◆ Empty()

bool COMMIT::Empty ( ) const
inlineinherited

Returns status of an item.

Definition at line 139 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 172 of file commit.cpp.

173{
174 for( COMMIT_LINE& change : m_changes )
175 {
176 if( change.m_item == aItem )
177 return &change;
178 }
179
180 return nullptr;
181}

References COMMIT::m_changes.

Referenced by COMMIT::GetStatus().

◆ GetBoard()

BOARD * BOARD_COMMIT::GetBoard ( ) const

Definition at line 74 of file board_commit.cpp.

75{
76 return static_cast<BOARD*>( m_toolMgr->GetModel() );
77}

References TOOL_MANAGER::GetModel(), and m_toolMgr.

Referenced by GRAPHICS_CLEANER::CleanupBoard().

◆ GetStatus()

int COMMIT::GetStatus ( EDA_ITEM aItem)
inherited

Definition at line 123 of file commit.cpp.

124{
125 COMMIT_LINE* entry = findEntry( parentObject( aItem ) );
126
127 return entry ? entry->m_type : 0;
128}
COMMIT_LINE * findEntry(EDA_ITEM *aItem)
Search for an entry describing change for a particular item.
Definition: commit.cpp:172

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 148 of file commit.cpp.

149{
150 // Expect an item copy if it is going to be modified
151 wxASSERT( !!aCopy == ( ( aType & CHT_TYPE ) == CHT_MODIFY ) );
152
153 if( m_changedItems.find( aItem ) != m_changedItems.end() )
154 {
155 alg::delete_if( m_changes, [aItem]( const COMMIT_LINE& aEnt )
156 {
157 return aEnt.m_item == aItem;
158 } );
159 }
160
161 COMMIT_LINE ent;
162
163 ent.m_item = aItem;
164 ent.m_type = aType;
165 ent.m_copy = aCopy;
166
167 m_changedItems.insert( aItem );
168 m_changes.push_back( ent );
169}
@ CHT_TYPE
Flag to indicate the change is already applied, just notify observers (not compatible with CHT_MODIFY...
Definition: commit.h:43
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().

◆ makeImage()

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

Implements COMMIT.

Definition at line 613 of file board_commit.cpp.

614{
615 BOARD_ITEM* clone = static_cast<BOARD_ITEM*>( aItem->Clone() );
616
617 clone->SetParentGroup( nullptr );
618 return clone;
619}
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:71
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82

References EDA_ITEM::Clone(), and BOARD_ITEM::SetParentGroup().

Referenced by Push().

◆ 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:131

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(), EDIT_TOOL::PackAndMoveFootprints(), 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_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_GROUP_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), DIALOG_UNUSED_PAD_LAYERS::TransferDataFromWindow(), BOARD_NETLIST_UPDATER::updateCopperZoneNets(), PCB_PROPERTIES_PANEL::valueChanged(), 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 585 of file board_commit.cpp.

586{
587 switch( aItem->Type() )
588 {
589 case PCB_PAD_T:
590 case PCB_FP_SHAPE_T:
591 case PCB_FP_TEXT_T:
592 case PCB_FP_TEXTBOX_T:
598 case PCB_FP_ZONE_T:
599 return aItem->GetParent();
600
601 case PCB_ZONE_T:
602 wxASSERT( !dynamic_cast<FOOTPRINT*>( aItem->GetParent() ) );
603 return aItem;
604
605 default:
606 break;
607 }
608
609 return aItem;
610}
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:95
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:97
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:99
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:96
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:98
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92

References EDA_ITEM::GetParent(), PCB_FP_DIM_ALIGNED_T, PCB_FP_DIM_CENTER_T, PCB_FP_DIM_LEADER_T, PCB_FP_DIM_ORTHOGONAL_T, PCB_FP_DIM_RADIAL_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_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"),
int  aFlags = 0 
)
overridevirtual

Revert the commit by restoring the modified items state.

Implements COMMIT.

Definition at line 162 of file board_commit.cpp.

163{
164 // Objects potentially interested in changes:
165 PICKED_ITEMS_LIST undoList;
166 KIGFX::VIEW* view = m_toolMgr->GetView();
167 BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
168 PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( m_toolMgr->GetToolHolder() );
169 std::set<EDA_ITEM*> savedModules;
171 bool itemsDeselected = false;
172 bool solderMaskDirty = false;
173 bool autofillZones = false;
174
175 if( Empty() )
176 return;
177
178 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
179
180 // Note:
181 // frame == nullptr happens in QA tests
182 // in this case m_isBoardEditor and m_isFootprintEditor are set to false
183 // But we also test frame == nullptr mainly to make Coverity happy
184
185 std::vector<BOARD_ITEM*> bulkAddedItems;
186 std::vector<BOARD_ITEM*> bulkRemovedItems;
187 std::vector<BOARD_ITEM*> itemsChanged;
188
190 && !( aCommitFlags & ZONE_FILL_OP )
191 && ( frame && frame->GetPcbNewSettings()->m_AutoRefillZones ) )
192 {
193 autofillZones = true;
194
195 for( ZONE* zone : board->Zones() )
196 zone->CacheBoundingBox();
197 }
198
199 for( COMMIT_LINE& ent : m_changes )
200 {
201 int changeType = ent.m_type & CHT_TYPE;
202 int changeFlags = ent.m_type & CHT_FLAGS;
203 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
204
205 wxASSERT( ent.m_item );
206
207 // Module items need to be saved in the undo buffer before modification
209 {
210 // Be sure that we are storing a footprint
211 if( ent.m_item->Type() != PCB_FOOTPRINT_T )
212 {
213 ent.m_item = ent.m_item->GetParent();
214 wxASSERT( ent.m_item );
215 }
216
217 // We have not saved the footprint yet, so let's create an entry
218 if( savedModules.count( ent.m_item ) == 0 )
219 {
220 if( !ent.m_copy )
221 {
222 wxASSERT( changeType != CHT_MODIFY ); // too late to make a copy..
223 ent.m_copy = makeImage( ent.m_item );
224 }
225
226 wxASSERT( ent.m_item->Type() == PCB_FOOTPRINT_T );
227 wxASSERT( ent.m_copy->Type() == PCB_FOOTPRINT_T );
228
229 if( !( aCommitFlags & SKIP_UNDO ) && frame )
230 {
231 ITEM_PICKER itemWrapper( nullptr, ent.m_item, UNDO_REDO::CHANGED );
232 itemWrapper.SetLink( ent.m_copy );
233 undoList.PushItem( itemWrapper );
234 frame->SaveCopyInUndoList( undoList, UNDO_REDO::CHANGED );
235 }
236
237 savedModules.insert( ent.m_item );
238 }
239 }
240
241 if( boardItem->Type() == PCB_VIA_T || boardItem->Type() == PCB_FOOTPRINT_T
242 || boardItem->IsOnLayer( F_Mask ) || boardItem->IsOnLayer( B_Mask ) )
243 {
244 solderMaskDirty = true;
245 }
246
247 switch( changeType )
248 {
249 case CHT_ADD:
250 {
251 if( selTool && selTool->GetEnteredGroup() && !boardItem->GetParentGroup()
252 && PCB_GROUP::IsGroupableType( boardItem->Type() ) )
253 {
254 selTool->GetEnteredGroup()->AddItem( boardItem );
255 }
256
258 {
259 // footprints inside footprints are not supported yet
260 wxASSERT( boardItem->Type() != PCB_FOOTPRINT_T );
261
262 boardItem->SetParent( board->Footprints().front() );
263
264 if( !( changeFlags & CHT_DONE ) )
265 board->Footprints().front()->Add( boardItem );
266 }
267 else if( boardItem->Type() == PCB_PAD_T
268 || boardItem->Type() == PCB_FP_TEXT_T
269 || boardItem->Type() == PCB_FP_TEXTBOX_T
270 || boardItem->Type() == PCB_FP_SHAPE_T
271 || boardItem->Type() == PCB_FP_DIM_ALIGNED_T
272 || boardItem->Type() == PCB_FP_DIM_LEADER_T
273 || boardItem->Type() == PCB_FP_DIM_CENTER_T
274 || boardItem->Type() == PCB_FP_DIM_RADIAL_T
275 || boardItem->Type() == PCB_FP_DIM_ORTHOGONAL_T
276 || boardItem->Type() == PCB_FP_ZONE_T )
277 {
278 wxASSERT( boardItem->GetParent() &&
279 boardItem->GetParent()->Type() == PCB_FOOTPRINT_T );
280 }
281 else
282 {
283 if( !( aCommitFlags & SKIP_UNDO ) )
284 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::NEWITEM ) );
285
286 if( !( changeFlags & CHT_DONE ) )
287 {
288 board->Add( boardItem, ADD_MODE::BULK_INSERT ); // handles connectivity
289 bulkAddedItems.push_back( boardItem );
290 }
291 }
292
293 if( autofillZones && boardItem->Type() != PCB_MARKER_T )
294 dirtyIntersectingZones( boardItem );
295
296 if( view && boardItem->Type() != PCB_NETINFO_T )
297 view->Add( boardItem );
298
299 break;
300 }
301
302 case CHT_REMOVE:
303 {
304 PCB_GROUP* parentGroup = boardItem->GetParentGroup();
305
306 if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) )
307 undoList.PushItem( ITEM_PICKER( nullptr, boardItem, UNDO_REDO::DELETED ) );
308
309 if( boardItem->IsSelected() )
310 {
311 if( selTool )
312 selTool->RemoveItemFromSel( boardItem, true /* quiet mode */ );
313
314 itemsDeselected = true;
315 }
316
317 if( parentGroup && !( parentGroup->GetFlags() & STRUCT_DELETED ) )
318 parentGroup->RemoveItem( boardItem );
319
320 if( autofillZones )
321 dirtyIntersectingZones( boardItem );
322
323 switch( boardItem->Type() )
324 {
325 // Footprint items
326 case PCB_PAD_T:
327 case PCB_FP_SHAPE_T:
328 case PCB_FP_TEXT_T:
329 case PCB_FP_TEXTBOX_T:
335 case PCB_FP_ZONE_T:
336 // This level can only handle footprint children in the footprint editor as
337 // only in that case has the entire footprint (and all its children) already
338 // been saved for undo.
339 wxASSERT( m_isFootprintEditor );
340
341 if( boardItem->Type() == PCB_FP_TEXT_T )
342 {
343 FP_TEXT* text = static_cast<FP_TEXT*>( boardItem );
344
345 // don't allow deletion of Reference or Value
346 if( text->GetType() != FP_TEXT::TEXT_is_DIVERS )
347 break;
348 }
349
350 if( view )
351 view->Remove( boardItem );
352
353 if( !( changeFlags & CHT_DONE ) )
354 {
355 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem->GetParent() );
356 wxASSERT( footprint && footprint->Type() == PCB_FOOTPRINT_T );
357 footprint->Delete( boardItem );
358 }
359
360 break;
361
362 // Board items
363 case PCB_SHAPE_T: // a shape (normally not on copper layers)
364 case PCB_BITMAP_T: // a bitmap on a user layer
365 case PCB_TEXT_T: // a text on a layer
366 case PCB_TEXTBOX_T: // a wrapped text on a layer
367 case PCB_TRACE_T: // a track segment (segment on a copper layer)
368 case PCB_ARC_T: // an arced track segment (segment on a copper layer)
369 case PCB_VIA_T: // a via (like track segment on a copper layer)
370 case PCB_DIM_ALIGNED_T: // a dimension (graphic item)
371 case PCB_DIM_CENTER_T:
372 case PCB_DIM_RADIAL_T:
374 case PCB_DIM_LEADER_T: // a leader dimension
375 case PCB_TARGET_T: // a target (graphic item)
376 case PCB_MARKER_T: // a marker used to show something
377 case PCB_ZONE_T:
378 if( view )
379 view->Remove( boardItem );
380
381 if( !( changeFlags & CHT_DONE ) )
382 {
383 board->Remove( boardItem, REMOVE_MODE::BULK );
384 bulkRemovedItems.push_back( boardItem );
385 }
386
387 break;
388
389 case PCB_FOOTPRINT_T:
390 {
391 // No support for nested footprints (yet)
392 wxASSERT( !m_isFootprintEditor );
393
394 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( boardItem );
395
396 if( view )
397 view->Remove( footprint );
398
399 footprint->ClearFlags();
400
401 if( !( changeFlags & CHT_DONE ) )
402 {
403 board->Remove( footprint, REMOVE_MODE::BULK ); // handles connectivity
404 bulkRemovedItems.push_back( footprint );
405 }
406 }
407
408 break;
409
410 case PCB_GROUP_T:
411 if( view )
412 view->Remove( boardItem );
413
414 if( !( changeFlags & CHT_DONE ) )
415 {
417 board->GetFirstFootprint()->Remove( boardItem );
418 else
419 {
420 board->Remove( boardItem, REMOVE_MODE::BULK );
421 bulkRemovedItems.push_back( boardItem );
422 }
423 }
424
425 break;
426
427 // Metadata items
428 case PCB_NETINFO_T:
429 board->Remove( boardItem, REMOVE_MODE::BULK );
430 bulkRemovedItems.push_back( boardItem );
431 break;
432
433 default: // other types do not need to (or should not) be handled
434 wxASSERT( false );
435 break;
436 }
437
438 break;
439 }
440
441 case CHT_MODIFY:
442 {
443 if( !m_isFootprintEditor && !( aCommitFlags & SKIP_UNDO ) )
444 {
445 ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
446 wxASSERT( ent.m_copy );
447 itemWrapper.SetLink( ent.m_copy );
448 undoList.PushItem( itemWrapper );
449 }
450
451 if( !( aCommitFlags & SKIP_CONNECTIVITY ) )
452 {
453 if( ent.m_copy )
454 connectivity->MarkItemNetAsDirty( static_cast<BOARD_ITEM*>( ent.m_copy ) );
455
456 connectivity->Update( boardItem );
457 }
458
459 if( autofillZones )
460 {
461 dirtyIntersectingZones( static_cast<BOARD_ITEM*>( ent.m_copy )); // before
462 dirtyIntersectingZones( boardItem ); // after
463 }
464
465 if( view )
466 {
467 view->Update( boardItem );
468
470 {
471 static_cast<FOOTPRINT*>( boardItem )->RunOnChildren(
472 [&]( BOARD_ITEM* aChild )
473 {
474 view->Update( aChild );
475 });
476 }
477 }
478
479 itemsChanged.push_back( boardItem );
480
481 // if no undo entry is needed, the copy would create a memory leak
482 if( aCommitFlags & SKIP_UNDO )
483 delete ent.m_copy;
484
485 break;
486 }
487
488 default:
489 wxASSERT( false );
490 break;
491 }
492 }
493
494 if( bulkAddedItems.size() > 0 )
495 board->FinalizeBulkAdd( bulkAddedItems );
496
497 if( bulkRemovedItems.size() > 0 )
498 board->FinalizeBulkRemove( bulkRemovedItems );
499
500 if( itemsChanged.size() > 0 )
501 board->OnItemsChanged( itemsChanged );
502
503 if( m_isBoardEditor )
504 {
505 size_t num_changes = m_changes.size();
506
507 if( aCommitFlags & SKIP_CONNECTIVITY )
508 {
509 connectivity->ClearRatsnest();
510 connectivity->ClearLocalRatsnest();
511 }
512 else
513 {
515 connectivity->PropagateNets( this, PROPAGATE_MODE::RESOLVE_CONFLICTS );
516
517 connectivity->RecalculateRatsnest( this );
519 connectivity->ClearLocalRatsnest();
520
521 if( frame )
522 frame->GetCanvas()->RedrawRatsnest();
523 }
524
525 if( solderMaskDirty )
526 {
527 if( frame )
528 frame->HideSolderMask();
529 }
530
531 // Log undo items for any connectivity changes
532 for( size_t i = num_changes; i < m_changes.size(); ++i )
533 {
534 COMMIT_LINE& ent = m_changes[i];
535
536 wxASSERT( ( ent.m_type & CHT_TYPE ) == CHT_MODIFY );
537
538 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
539
540 if( !( aCommitFlags & SKIP_UNDO ) )
541 {
542 ITEM_PICKER itemWrapper( nullptr, boardItem, UNDO_REDO::CHANGED );
543 wxASSERT( ent.m_copy );
544 itemWrapper.SetLink( ent.m_copy );
545 undoList.PushItem( itemWrapper );
546 }
547 else
548 {
549 delete ent.m_copy;
550 }
551
552 if( view )
553 view->Update( boardItem );
554 }
555 }
556
557 if( m_isBoardEditor && !( aCommitFlags & SKIP_UNDO ) && frame )
558 {
559 if( aCommitFlags & APPEND_UNDO )
561 else
562 frame->SaveCopyInUndoList( undoList, UNDO_REDO::UNSPECIFIED );
563 }
564
566
567 if( itemsDeselected )
569
570 if( autofillZones )
572
573 if( frame )
574 {
575 if( !( aCommitFlags & SKIP_SET_DIRTY ) )
576 frame->OnModify();
577 else
579 }
580
581 clear();
582}
#define SKIP_CONNECTIVITY
Definition: board_commit.h:42
#define SKIP_SET_DIRTY
Definition: board_commit.h:41
#define APPEND_UNDO
Definition: board_commit.h:40
#define SKIP_UNDO
Definition: board_commit.h:39
#define ZONE_FILL_OP
Definition: board_commit.h:43
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
virtual void Delete(BOARD_ITEM *aItem)
Removes an item from the container and deletes it.
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:72
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:245
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:163
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:711
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:397
FOOTPRINTS & Footprints()
Definition: board.h:307
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:814
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:808
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
Definition: board.cpp:248
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: board.cpp:820
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:2015
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:424
bool Empty() const
Returns status of an item.
Definition: commit.h:139
void clear()
Definition: commit.h:156
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:143
bool IsSelected() const
Definition: eda_item.h:107
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:144
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:207
void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
Definition: footprint.cpp:621
@ TEXT_is_DIVERS
Definition: fp_text.h:51
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:346
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:1575
DISPLAY_OPTIONS m_Display
static TOOL_ACTION zoneFillDirty
Definition: pcb_actions.h:341
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCBNEW_SETTINGS * GetPcbNewSettings() const
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void AppendCopyToUndoList(const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aTypeCommand)=0
As SaveCopyInUndoList, but appends the changes to the last undo item on the stack.
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)=0
Create a new entry in undo list of commands.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
static bool IsGroupableType(KICAD_T aType)
Check if the proposed type can be added to a group.
Definition: pcb_group.cpp:43
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
Definition: pcb_group.cpp:95
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:80
The selection tool: currently supports:
PCB_GROUP * GetEnteredGroup()
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:296
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:285
@ CHT_DONE
Definition: commit.h:47
@ CHT_FLAGS
Definition: commit.h:48
@ RESOLVE_CONFLICTS
Clusters with conflicting drivers are not updated (default)
#define STRUCT_DELETED
flag indication structures to be erased
@ B_Mask
Definition: layer_ids.h:106
@ F_Mask
Definition: layer_ids.h:107
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition: tool_action.h:45
@ TA_MODEL_CHANGE
Definition: tool_event.h:116
@ TC_MESSAGE
Definition: tool_event.h:53
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:110
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:107
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:108
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:104
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:111
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:106
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
Definition: typeinfo.h:89
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:114
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:109

References BOARD::Add(), KIGFX::VIEW::Add(), PCB_GROUP::AddItem(), APPEND_UNDO, PCB_BASE_FRAME::AppendCopyToUndoList(), AS_GLOBAL, B_Mask, 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, dirtyIntersectingZones(), COMMIT::Empty(), F_Mask, BOARD::FinalizeBulkAdd(), BOARD::FinalizeBulkRemove(), BOARD::Footprints(), PCB_BASE_FRAME::GetCanvas(), BOARD::GetConnectivity(), PCB_SELECTION_TOOL::GetEnteredGroup(), BOARD::GetFirstFootprint(), EDA_ITEM::GetFlags(), TOOL_MANAGER::GetModel(), BOARD_ITEM::GetParent(), BOARD_ITEM::GetParentGroup(), PCB_BASE_FRAME::GetPcbNewSettings(), TOOL_MANAGER::GetTool(), TOOL_MANAGER::GetToolHolder(), TOOL_MANAGER::GetView(), PCB_BASE_FRAME::HideSolderMask(), PCB_GROUP::IsGroupableType(), BOARD_ITEM::IsOnLayer(), EDA_ITEM::IsSelected(), PCBNEW_SETTINGS::m_AutoRefillZones, COMMIT::m_changes, COMMIT::COMMIT_LINE::m_copy, PCBNEW_SETTINGS::m_Display, m_isBoardEditor, m_isFootprintEditor, COMMIT::COMMIT_LINE::m_item, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_Live3DRefresh, m_resolveNetConflicts, m_toolMgr, COMMIT::COMMIT_LINE::m_type, makeImage(), NEWITEM, BOARD::OnItemsChanged(), PCB_BASE_FRAME::OnModify(), PCB_ARC_T, PCB_BITMAP_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_DIM_RADIAL_T, PCB_FOOTPRINT_T, PCB_FP_DIM_ALIGNED_T, PCB_FP_DIM_CENTER_T, PCB_FP_DIM_LEADER_T, PCB_FP_DIM_ORTHOGONAL_T, PCB_FP_DIM_RADIAL_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_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_TEXTBOX_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, TOOL_MANAGER::PostEvent(), PICKED_ITEMS_LIST::PushItem(), PCB_DRAW_PANEL_GAL::RedrawRatsnest(), BOARD::Remove(), FOOTPRINT::Remove(), KIGFX::VIEW::Remove(), PCB_GROUP::RemoveItem(), SELECTION_TOOL::RemoveItemFromSel(), RESOLVE_CONFLICTS, TOOL_MANAGER::RunAction(), PCB_BASE_FRAME::SaveCopyInUndoList(), ITEM_PICKER::SetLink(), EDA_ITEM::SetParent(), SKIP_CONNECTIVITY, SKIP_SET_DIRTY, SKIP_UNDO, STRUCT_DELETED, TA_MODEL_CHANGE, TC_MESSAGE, text, FP_TEXT::TEXT_is_DIVERS, EDA_ITEM::Type(), EVENTS::UnselectedEvent, UNSPECIFIED, KIGFX::VIEW::Update(), PCB_BASE_FRAME::Update3DView(), BOARD::UpdateRatsnestExclusions(), ZONE_FILL_OP, PCB_ACTIONS::zoneFillDirty, and BOARD::Zones().

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::CreatePolys(), ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), ALIGN_DISTRIBUTE_TOOL::DistributeVertically(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), DIALOG_CLEANUP_GRAPHICS::doCleanup(), DIALOG_CLEANUP_TRACKS_AND_VIAS::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::drawShape(), DRAWING_TOOL::DrawSpecificationStackup(), PCB_EDIT_FRAME::Edit_Zone_Params(), PAD_TOOL::EditPad(), 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(), PCB_EDIT_FRAME::OpenProjectFiles(), EDIT_TOOL::PackAndMoveFootprints(), PAD_TOOL::pastePadProperties(), ZONE_CREATE_HELPER::performZoneCutout(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImportedGraphics(), DRAWING_TOOL::PlaceText(), PAD_TOOL::pushPadSettings(), DIALOG_BOARD_REANNOTATE::ReannotateBoard(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), TEARDROP_MANAGER::RemoveTeardrops(), PCB_EDIT_FRAME::ResolveDRCExclusions(), PCB_EDIT_FRAME::RunActionPlugin(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), DRAWING_TOOL::SetAnchor(), TEARDROP_MANAGER::SetTeardrops(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_GROUP_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), BOARD_NETLIST_UPDATER::UpdateNetlist(), PCB_PROPERTIES_PANEL::valueChanged(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), ZONE_FILLER_TOOL::ZoneFillDirty(), BOARD_EDITOR_CONTROL::ZoneMerge(), ZONE_FILLER_TOOL::ZoneUnfill(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ Remove()

◆ Removed()

COMMIT & COMMIT::Removed ( EDA_ITEM aItem)
inlineinherited

◆ Revert()

void BOARD_COMMIT::Revert ( )
overridevirtual

Implements COMMIT.

Definition at line 622 of file board_commit.cpp.

623{
624 PICKED_ITEMS_LIST undoList;
625 KIGFX::VIEW* view = m_toolMgr->GetView();
626 BOARD* board = (BOARD*) m_toolMgr->GetModel();
627 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
628
629 std::vector<BOARD_ITEM*> bulkAddedItems;
630 std::vector<BOARD_ITEM*> bulkRemovedItems;
631 std::vector<BOARD_ITEM*> itemsChanged;
632
633 for( auto it = m_changes.rbegin(); it != m_changes.rend(); ++it )
634 {
635 COMMIT_LINE& ent = *it;
636 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( ent.m_item );
637 BOARD_ITEM* copy = static_cast<BOARD_ITEM*>( ent.m_copy );
638 int changeType = ent.m_type & CHT_TYPE;
639 int changeFlags = ent.m_type & CHT_FLAGS;
640
641 switch( changeType )
642 {
643 case CHT_ADD:
644 if( !( changeFlags & CHT_DONE ) )
645 break;
646
647 view->Remove( item );
648 connectivity->Remove( item );
649 board->Remove( item, REMOVE_MODE::BULK );
650 bulkRemovedItems.push_back( item );
651 break;
652
653 case CHT_REMOVE:
654 if( !( changeFlags & CHT_DONE ) )
655 break;
656
657 view->Add( item );
658 connectivity->Add( item );
659 board->Add( item, ADD_MODE::INSERT );
660 bulkAddedItems.push_back( item );
661 break;
662
663 case CHT_MODIFY:
664 {
665 view->Remove( item );
666 connectivity->Remove( item );
667
668 item->SwapItemData( copy );
669
670 if( item->Type() == PCB_GROUP_T )
671 {
672 PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
673
674 group->RunOnChildren( [&]( BOARD_ITEM* child )
675 {
676 child->SetParentGroup( group );
677 } );
678 }
679
680 view->Add( item );
681 connectivity->Add( item );
682 board->OnItemChanged( item );
683 itemsChanged.push_back( item );
684
685 delete copy;
686 break;
687 }
688
689 default:
690 wxASSERT( false );
691 break;
692 }
693 }
694
695 if( bulkAddedItems.size() > 0 )
696 board->FinalizeBulkAdd( bulkAddedItems );
697
698 if( bulkRemovedItems.size() > 0 )
699 board->FinalizeBulkRemove( bulkRemovedItems );
700
701 if( itemsChanged.size() > 0 )
702 board->OnItemsChanged( itemsChanged );
703
704 if ( !m_isFootprintEditor )
705 {
706 connectivity->RecalculateRatsnest();
708 }
709
711 selTool->RebuildSelection();
712
713 clear();
714}
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
Definition: board_item.cpp:166
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:2009
void RebuildSelection()
Rebuild the selection from the EDA_ITEMs' selection flags.

References BOARD::Add(), KIGFX::VIEW::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(), group, 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_GROUP_T, PCB_SELECTION_TOOL::RebuildSelection(), BOARD::Remove(), KIGFX::VIEW::Remove(), BOARD_ITEM::SetParentGroup(), BOARD_ITEM::SwapItemData(), EDA_ITEM::Type(), and BOARD::UpdateRatsnestExclusions().

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(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillDirty().

◆ 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 73 of file board_commit.h.

73{ m_resolveNetConflicts = aResolve; }

References m_resolveNetConflicts.

Referenced by BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ Stage() [1/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 102 of file board_commit.cpp.

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

References COMMIT::Stage().

◆ Stage() [2/3]

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

Reimplemented from COMMIT.

Definition at line 80 of file board_commit.cpp.

81{
82 // if aItem belongs a footprint, the full footprint will be saved
83 // because undo/redo does not handle "sub items" modifications
84 if( aItem && aItem->Type() != PCB_FOOTPRINT_T && aChangeType == CHT_MODIFY )
85 {
86 EDA_ITEM* item = aItem->GetParent();
87
88 if( item && item->Type() == PCB_FOOTPRINT_T ) // means aItem belongs a footprint
89 aItem = item;
90 }
91
92 return COMMIT::Stage( aItem, aChangeType );
93}

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() [3/3]

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

Reimplemented from COMMIT.

Definition at line 96 of file board_commit.cpp.

97{
98 return COMMIT::Stage( container, aChangeType );
99}

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 179 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_isBoardEditor

bool BOARD_COMMIT::m_isBoardEditor
private

Definition at line 85 of file board_commit.h.

Referenced by BOARD_COMMIT(), and Push().

◆ m_isFootprintEditor

bool BOARD_COMMIT::m_isFootprintEditor
private

Definition at line 84 of file board_commit.h.

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

◆ m_resolveNetConflicts

bool BOARD_COMMIT::m_resolveNetConflicts
private

Definition at line 86 of file board_commit.h.

Referenced by Push(), and SetResolveNetConflicts().

◆ m_toolMgr

TOOL_MANAGER* BOARD_COMMIT::m_toolMgr
private

Definition at line 83 of file board_commit.h.

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


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