46#include <unordered_set>
48using namespace std::placeholders;
120 Stage( member, aChangeType, aScreen, aRecurse );
151 std::vector<BOX2I>& aStaleRuleAreas )
153 wxCHECK( aChangedItem, );
156 aStaleZones->push_back(
static_cast<ZONE*
>( aChangedItem ) );
168 if( !
static_cast<ZONE*
>( aChangedItem )->GetZoneName().IsEmpty() )
169 aStaleRuleAreas.push_back( damageBBox );
179 if( damageLayers.any() )
183 if( zone->GetIsRuleArea() )
186 if( ( zone->GetLayerSet() & damageLayers ).any() && zone->GetBoundingBox().Intersects( damageBBox ) )
187 aStaleZones->push_back( zone );
204 bool itemsDeselected =
false;
205 bool selectedModified =
false;
207 std::unordered_set<EDA_ITEM*> removedItems;
210 bool solderMaskDirty =
false;
211 bool autofillZones =
false;
212 bool updateBoardBoundingBox =
false;
213 std::vector<BOARD_ITEM*> staleTeardropPadsAndVias;
214 std::set<PCB_TRACK*> staleTeardropTracks;
215 std::vector<ZONE*> staleZonesStorage;
216 std::vector<ZONE*>* staleZones =
nullptr;
217 std::vector<BOX2I> staleRuleAreas;
225 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
229 std::vector<BOARD_ITEM*> bulkAddedItems;
230 std::vector<BOARD_ITEM*> bulkRemovedItems;
231 std::vector<BOARD_ITEM*> itemsChanged;
236 autofillZones =
true;
237 staleZones = &staleZonesStorage;
240 zone->CacheBoundingBox();
245 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
255 solderMaskDirty =
true;
260 updateBoardBoundingBox =
true;
268 staleTeardropPadsAndVias.push_back(
pad );
272 staleTeardropPadsAndVias.push_back( boardItem );
278 staleTeardropTracks.insert( track );
280 std::vector<PAD*> connectedPads;
281 std::vector<PCB_VIA*> connectedVias;
283 connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
285 for(
PAD*
pad : connectedPads )
286 staleTeardropPadsAndVias.push_back(
pad );
289 staleTeardropPadsAndVias.push_back(
via );
295 selectedModified =
true;
299 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
300 teardropMgr.
RemoveTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks );
302 auto updateComponentClasses =
320 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
324 int changeType = entry.m_type &
CHT_TYPE;
325 int changeFlags = entry.m_type &
CHT_FLAGS;
331 enteredGroup->AddItem( boardItem );
342 parentFP->Add( boardItem );
347 bulkAddedItems.push_back( boardItem );
355 view->
Add( boardItem );
357 updateComponentClasses( boardItem );
368 ITEM_PICKER itemWrapper(
nullptr, boardItem, status );
369 itemWrapper.
SetLink( entry.m_copy );
370 entry.m_copy =
nullptr;
379 itemsDeselected =
true;
382 removedItems.insert( boardItem );
390 switch( boardItem->
Type() )
393 static_cast<PCB_FIELD*
>( boardItem )->SetVisible(
false );
396 view->
Update( boardItem );
422 view->
Remove( boardItem );
429 parentFP->Remove( boardItem );
433 parentFP->Remove( boardItem );
438 bulkRemovedItems.push_back( boardItem );
446 view->
Remove( boardItem );
452 bulkRemovedItems.push_back( boardItem );
464 parentFP->Remove( boardItem );
468 parentFP->Remove( boardItem );
473 bulkRemovedItems.push_back( boardItem );
482 bulkRemovedItems.push_back( boardItem );
504 itemWrapper.
SetLink( entry.m_copy );
505 entry.m_copy =
nullptr;
511 connectivity->MarkItemNetAsDirty( boardItemCopy );
512 connectivity->Update( boardItem );
521 updateComponentClasses( boardItem );
524 view->
Update( boardItem );
526 itemsChanged.push_back( boardItem );
537 entry.m_copy =
nullptr;
552 if( selTool && !removedItems.empty() )
556 for(
EDA_ITEM* ancestor = selectedItem; ancestor; ancestor = ancestor->
GetParent() )
558 if( removedItems.count( ancestor ) )
561 itemsDeselected =
true;
577 connectivity->ClearRatsnest();
578 connectivity->ClearLocalRatsnest();
582 connectivity->RecalculateRatsnest(
this );
584 connectivity->ClearLocalRatsnest();
592 if( solderMaskDirty )
598 if( updateBoardBoundingBox && view )
607 view->
Add( outline );
614 || cfg->m_Display.m_PadClearance ) )
621 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
623 teardropMgr.
UpdateTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks );
626 connectivity->RecalculateRatsnest(
this );
630 for(
size_t i = originalCount; i <
m_entries.size(); ++i )
642 wxCHECK2( boardItem,
continue );
647 itemWrapper.
SetLink( boardItemCopy );
658 view->
Add( boardItem );
660 view->
Remove( boardItem );
662 view->
Update( boardItem );
667 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
683 if( itemsDeselected )
690 for(
ZONE* zone : *staleZones )
698 if( selectedModified )
710 if( !itemsDeselected && !autofillZones && !selectedModified )
712 std::vector<MSG_PANEL_ITEM> msg_list;
761 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
765 auto updateComponentClasses =
775 std::vector<BOARD_ITEM*> bulkAddedItems;
776 std::vector<BOARD_ITEM*> bulkRemovedItems;
777 std::vector<BOARD_ITEM*> itemsChanged;
778 std::vector<BOARD_ITEM*> itemsToDelete;
782 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
786 int changeType = entry.m_type &
CHT_TYPE;
787 int changeFlags = entry.m_type &
CHT_FLAGS;
795 view->
Remove( boardItem );
797 connectivity->Remove( boardItem );
802 parentFP->Remove( boardItem );
806 parentFP->Remove( boardItem );
811 bulkRemovedItems.push_back( boardItem );
817 itemsToDelete.push_back( boardItem );
818 entry.m_item =
nullptr;
827 view->
Add( boardItem );
841 bulkAddedItems.push_back( boardItem );
844 updateComponentClasses( boardItem );
851 view->
Remove( boardItem );
853 connectivity->Remove( boardItem );
855 wxASSERT( entry.m_copy && entry.m_copy->IsBOARD_ITEM() );
860 view->
Add( boardItem );
862 connectivity->Add( boardItem );
863 itemsChanged.push_back( boardItem );
865 updateComponentClasses( boardItem );
876 entry.m_copy =
nullptr;
884 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
890 connectivity->Remove( item );
898 connectivity->RecalculateRatsnest();
904 selTool->RebuildSelection();
static bool isNoGeometryItem(const BOARD_ITEM *aItem)
#define SKIP_CONNECTIVITY
#define SKIP_ENTERED_GROUP
Handles how to draw a screen (a board, a schematic ...)
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE) override
Add a change of the item aItem of type aChangeType to the change list.
virtual void Revert() override
Revert the commit by restoring the modified items state.
static EDA_ITEM * MakeImage(EDA_ITEM *aItem)
EDA_ITEM * undoLevelItem(EDA_ITEM *aItem) const override
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
void propagateDamage(BOARD_ITEM *aItem, std::vector< ZONE * > *aStaleZones, std::vector< BOX2I > &aStaleRuleAreas)
BOARD_COMMIT(EDA_DRAW_FRAME *aFrame)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
bool IsGroupableType() const
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
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 RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) 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.
PCB_BOARD_OUTLINE * BoardOutline()
void UpdateBoardOutline()
const ZONES & Zones() const
void OnItemsCompositeUpdate(std::vector< BOARD_ITEM * > &aAddedItems, std::vector< BOARD_ITEM * > &aRemovedItems, std::vector< BOARD_ITEM * > &aChangedItems)
Notify the board and its listeners that items on the board have been modified in a composite operatio...
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
void IncrementTimeStamp()
void OnRatsnestChanged()
Notify the board and its listeners that the ratsnest has been recomputed.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
COMPONENT_CLASS_MANAGER & GetComponentClassManager()
Gets the component class manager.
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
std::set< std::pair< EDA_ITEM *, BASE_SCREEN * > > m_deletedItems
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
virtual void makeEntry(EDA_ITEM *aItem, CHANGE_TYPE aType, EDA_ITEM *aCopy=nullptr, BASE_SCREEN *aScreen=nullptr)
std::vector< COMMIT_LINE > m_entries
void clear()
Should be called in Push() & Revert() methods.
virtual COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Add a change of the item aItem of type aChangeType to the change list.
void InvalidateComponentClasses()
Invalidates any caches component classes and recomputes caches if required.
void RebuildRequiredCaches(FOOTPRINT *aFootprint=nullptr) const
Rebuilds any caches that may be required by custom assignment rules.
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
A set of EDA_ITEMs (i.e., without duplicates).
void RemoveItem(EDA_ITEM *aItem)
Remove item from group.
virtual EDA_ITEM * AsEdaItem()=0
A base class for most all the KiCad significant classes used in schematics and boards.
virtual void ClearEditFlags()
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
void SetFlags(EDA_ITEM_FLAGS aMask)
virtual EDA_GROUP * GetParentGroup() const
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
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 SetLink(EDA_ITEM *aItem)
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
void UpdateCollidingItems(const std::vector< BOX2I > &aStaleAreas, std::initializer_list< KICAD_T > aTypes)
Sets the KIGFX::REPAINT on all items matching aTypes which intersect aStaleAreas.
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
bool IsBOARD_ITEM() const
virtual wxString GetClass() const =0
Return the class name.
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.
bool HasItem(const VIEW_ITEM *aItem) const
Indicates whether or not the given item has been added to the view.
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
static const LSET & PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
DISPLAY_OPTIONS m_Display
static TOOL_ACTION rehatchShapes
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).
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
void SetDescription(const wxString &aDescription)
const std::deque< EDA_ITEM * > GetItems() const
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.
T * GetAppSettings(const char *aFilename)
EDA_ITEM * m_copy
Optional copy of the item.
CHANGE_TYPE m_type
Modification type.
EDA_ITEM * m_item
Main item that is added/deleted/modified.
@ PCB_CONSTRAINT_T
class PCB_CONSTRAINT, a geometric constraint between board items
@ 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_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ 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_POINT_T
class PCB_POINT, a 0-dimensional point
@ 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...