42using namespace std::placeholders;
46 m_toolMgr( aTool->GetManager() ),
47 m_isBoardEditor( false ),
48 m_isFootprintEditor( false )
59 m_toolMgr( aFrame->GetToolManager() ),
68 m_isBoardEditor( false ),
69 m_isFootprintEditor( false )
88 wxCHECK( aItem, *
this );
99 Stage( child, aChangeType );
146 if( zone->GetIsRuleArea() )
149 if( ( zone->GetLayerSet() & layers ).any()
150 && zone->GetBoundingBox().Intersects( bbox ) )
168 bool itemsDeselected =
false;
169 bool selectedModified =
false;
172 bool solderMaskDirty =
false;
173 bool autofillZones =
false;
174 std::vector<BOARD_ITEM*> staleTeardropPadsAndVias;
175 std::set<PCB_TRACK*> staleTeardropTracks;
181 undoList.SetDescription( aMessage );
184 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
188 std::vector<BOARD_ITEM*> bulkAddedItems;
189 std::vector<BOARD_ITEM*> bulkRemovedItems;
190 std::vector<BOARD_ITEM*> itemsChanged;
196 autofillZones =
true;
199 zone->CacheBoundingBox();
211 solderMaskDirty =
true;
219 staleTeardropPadsAndVias.push_back(
pad );
223 staleTeardropPadsAndVias.push_back( boardItem );
229 staleTeardropTracks.insert( track );
231 std::vector<PAD*> connectedPads;
232 std::vector<PCB_VIA*> connectedVias;
234 connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
236 for(
PAD*
pad : connectedPads )
237 staleTeardropPadsAndVias.push_back(
pad );
240 staleTeardropPadsAndVias.push_back(
via );
246 selectedModified =
true;
250 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
251 teardropMgr.
RemoveTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks );
255 int changeType = ent.m_type &
CHT_TYPE;
256 int changeFlags = ent.m_type &
CHT_FLAGS;
259 wxASSERT( ent.m_item );
260 wxCHECK2( boardItem,
continue );
272 undoList.PushItem(
ITEM_PICKER(
nullptr, boardItem, UNDO_REDO::NEWITEM ) );
279 wxCHECK2_MSG( parentFP,
continue,
"Commit thinks this is footprint editor, but "
280 "there is no first footprint!" );
281 parentFP->
Add( boardItem );
285 parentFP->Add( boardItem );
289 board->
Add( boardItem, ADD_MODE::BULK_INSERT );
290 bulkAddedItems.push_back( boardItem );
295 addedGroup =
static_cast<PCB_GROUP*
>( boardItem );
301 view->
Add( boardItem );
311 undoList.PushItem(
ITEM_PICKER(
nullptr, boardItem, UNDO_REDO::DELETED ) );
318 itemsDeselected =
true;
325 ent.m_parent = parentFP->
m_Uuid;
330 switch( boardItem->
Type() )
333 static_cast<PCB_FIELD*
>( boardItem )->SetVisible(
false );
356 view->
Remove( boardItem );
362 parentFP->
Remove( boardItem );
366 board->
Remove( boardItem, REMOVE_MODE::BULK );
367 bulkRemovedItems.push_back( boardItem );
375 view->
Remove( boardItem );
381 parentFP->
Remove( boardItem );
385 board->
Remove( boardItem, REMOVE_MODE::BULK );
386 bulkRemovedItems.push_back( boardItem );
394 board->
Remove( boardItem, REMOVE_MODE::BULK );
395 bulkRemovedItems.push_back( boardItem );
414 ITEM_PICKER itemWrapper(
nullptr, boardItem, UNDO_REDO::UNGROUP );
416 undoList.PushItem( itemWrapper );
419 group->RemoveItem( boardItem );
427 addedGroup->
AddItem( boardItem );
430 undoList.PushItem(
ITEM_PICKER(
nullptr, boardItem, UNDO_REDO::REGROUP ) );
441 ITEM_PICKER itemWrapper(
nullptr, boardItem, UNDO_REDO::CHANGED );
442 wxASSERT( boardItemCopy );
443 itemWrapper.
SetLink( boardItemCopy );
444 undoList.PushItem( itemWrapper );
450 connectivity->MarkItemNetAsDirty( boardItemCopy );
452 connectivity->Update( boardItem );
462 view->
Update( boardItem );
464 itemsChanged.push_back( boardItem );
486 if( bulkAddedItems.size() > 0 )
489 if( bulkRemovedItems.size() > 0 )
492 if( itemsChanged.size() > 0 )
501 connectivity->ClearRatsnest();
502 connectivity->ClearLocalRatsnest();
506 connectivity->RecalculateRatsnest(
this );
508 connectivity->ClearLocalRatsnest();
516 if( solderMaskDirty )
522 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
523 teardropMgr.
UpdateTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks );
526 for(
size_t i = num_changes; i <
m_changes.size(); ++i )
532 wxCHECK2( boardItem,
continue );
537 itemWrapper.
SetLink( boardItemCopy );
538 undoList.PushItem( itemWrapper );
548 view->
Add( boardItem );
550 view->
Remove( boardItem );
552 view->
Update( boardItem );
570 if( itemsDeselected )
576 if( selectedModified )
608 board_item->SetParentGroup(
nullptr );
621 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
625 std::vector<BOARD_ITEM*> bulkAddedItems;
626 std::vector<BOARD_ITEM*> bulkRemovedItems;
627 std::vector<BOARD_ITEM*> itemsChanged;
636 wxCHECK2( boardItem,
continue );
646 parentGroup->RemoveItem( boardItem );
652 view->
Remove( boardItem );
653 connectivity->Remove( boardItem );
657 parentFP->Remove( boardItem );
661 board->
Remove( boardItem, REMOVE_MODE::BULK );
662 bulkRemovedItems.push_back( boardItem );
671 view->
Add( boardItem );
672 connectivity->Add( boardItem );
676 parentFP->Add( boardItem, ADD_MODE::INSERT );
680 board->
Add( boardItem, ADD_MODE::INSERT );
681 bulkAddedItems.push_back( boardItem );
688 view->
Remove( boardItem );
689 connectivity->Remove( boardItem );
692 wxASSERT( boardItemCopy );
697 group->RunOnChildren(
704 view->
Add( boardItem );
705 connectivity->Add( boardItem );
706 itemsChanged.push_back( boardItem );
720 if( bulkAddedItems.size() > 0 )
723 if( bulkRemovedItems.size() > 0 )
726 if( itemsChanged.size() > 0 )
731 connectivity->RecalculateRatsnest();
#define SKIP_CONNECTIVITY
Handles how to draw a screen (a board, a schematic ...)
void dirtyIntersectingZones(BOARD_ITEM *item, int aChangeType)
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr) override
EDA_ITEM * parentObject(EDA_ITEM *aItem) const override
virtual void Revert() override
static EDA_ITEM * MakeImage(EDA_ITEM *aItem)
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
BOARD_COMMIT(EDA_DRAW_FRAME *aFrame)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SetParentGroup(PCB_GROUP *aGroup)
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
PCB_GROUP * GetParentGroup() const
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual void RunOnDescendants(const std::function< void(BOARD_ITEM *)> &aFunction, int aDepth=0) const
Invoke a function on all descendants.
virtual void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all children.
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
BOARD_ITEM * GetItem(const KIID &aID) const
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
void IncrementTimeStamp()
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.
void OnRatsnestChanged()
Notify the board and its listeners that the ratsnest has been recomputed.
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.
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
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.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Represent a set of changes (additions, deletions or modifications) of a data model (e....
virtual COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr)
bool Empty() const
Returns status of an item.
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
std::vector< COMMIT_LINE > m_changes
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
virtual wxString GetClass() const =0
Return the class name.
EDA_ITEM_FLAGS GetFlags() const
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
static const TOOL_EVENT UnselectedEvent
void SetGroupId(KIID aId)
void SetLink(EDA_ITEM *aItem)
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
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...
LSET is a set of PCB_LAYER_IDs.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
DISPLAY_OPTIONS m_Display
static TOOL_ACTION zoneFillDirty
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 ...
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)
Create a new entry in undo list of commands.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
virtual void AppendCopyToUndoList(const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aTypeCommand)
As SaveCopyInUndoList, but appends the changes to the last undo item on the stack.
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
A set of BOARD_ITEMs (i.e., without duplicates).
static bool IsGroupableType(KICAD_T aType)
Check if the proposed type can be added to a group.
virtual bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
virtual bool AddItem(BOARD_ITEM *aItem)
Add item to group.
A holder to handle information on schematic or board items.
TEARDROP_MANAGER manage and build teardrop areas A teardrop area is a polygonal area (a copper ZONE) ...
void UpdateTeardrops(BOARD_COMMIT &aCommit, const std::vector< BOARD_ITEM * > *dirtyPadsAndVias, const std::set< PCB_TRACK * > *dirtyTracks, bool aForceFullUpdate=false)
Update teardrops on a list of items.
void RemoveTeardrops(BOARD_COMMIT &aCommit, const std::vector< BOARD_ITEM * > *dirtyPadsAndVias, const std::set< PCB_TRACK * > *dirtyTracks)
Remove teardrops connected to any dirty pads, vias or tracks.
Handle a list of polygons defining a copper zone.
CHANGE_TYPE
Types of changes.
@ CHT_DONE
Flag to indicate the change is already applied.
#define STRUCT_DELETED
flag indication structures to be erased
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
Class to handle a set of BOARD_ITEMs.
EDA_ITEM * m_copy
Optional copy of the item.
CHANGE_TYPE m_type
Modification type.
KIID m_parent
Parent item (primarily for undo of deleted items)
EDA_ITEM * m_item
Main item that is added/deleted/modified.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...