49#include <unordered_set>
51using namespace std::placeholders;
121 board->bumpDrillModelFor( {
static_cast<BOARD_ITEM*
>( aItem ) } );
128 Stage( member, aChangeType, aScreen, aRecurse );
170 parentGroup->RemoveItem( aItem );
181 std::vector<BOX2I>& aStaleRuleAreas )
183 wxCHECK( aChangedItem, );
186 aStaleZones->push_back(
static_cast<ZONE*
>( aChangedItem ) );
198 if( !
static_cast<ZONE*
>( aChangedItem )->GetZoneName().IsEmpty() )
199 aStaleRuleAreas.push_back( damageBBox );
209 if( damageLayers.any() )
213 if( zone->GetIsRuleArea() )
216 if( ( zone->GetLayerSet() & damageLayers ).any() && zone->GetBoundingBox().Intersects( damageBBox ) )
217 aStaleZones->push_back( zone );
234 bool itemsDeselected =
false;
235 bool selectedModified =
false;
237 std::unordered_set<EDA_ITEM*> removedItems;
240 bool solderMaskDirty =
false;
241 bool autofillZones =
false;
242 bool updateBoardBoundingBox =
false;
243 std::vector<BOARD_ITEM*> staleTeardropPadsAndVias;
244 std::set<PCB_TRACK*> staleTeardropTracks;
245 std::vector<BOARD_ITEM*> dirtyCopper;
246 std::set<BOARD_ITEM*> dirtyCopperSeen;
247 std::vector<ZONE*> staleZonesStorage;
248 std::vector<ZONE*>* staleZones =
nullptr;
249 std::vector<BOX2I> staleRuleAreas;
254 bool containsDrillMap =
false;
255 bool containsGeneratedTable =
false;
259 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
278 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
285 std::vector<BOARD_ITEM*> bulkAddedItems;
286 std::vector<BOARD_ITEM*> bulkRemovedItems;
287 std::vector<BOARD_ITEM*> itemsChanged;
292 autofillZones =
true;
293 staleZones = &staleZonesStorage;
296 zone->CacheBoundingBox();
301 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
310 if( entry.m_copy && entry.m_copy->IsBOARD_ITEM() )
311 preEditItem =
static_cast<BOARD_ITEM*
>( entry.m_copy );
319 solderMaskDirty =
true;
325 updateBoardBoundingBox =
true;
347 && dirtyCopperSeen.insert( aItem ).second )
349 dirtyCopper.push_back( aItem );
353 collectCopper( boardItem );
358 if( entry.m_copy && entry.m_copy->IsBOARD_ITEM() )
362 collectCopper(
copy );
369 staleTeardropPadsAndVias.push_back(
pad );
373 staleTeardropPadsAndVias.push_back( boardItem );
379 staleTeardropTracks.insert( track );
381 std::vector<PAD*> connectedPads;
382 std::vector<PCB_VIA*> connectedVias;
384 connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
386 for(
PAD*
pad : connectedPads )
387 staleTeardropPadsAndVias.push_back(
pad );
390 staleTeardropPadsAndVias.push_back(
via );
396 selectedModified =
true;
400 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() || !dirtyCopper.empty() )
401 teardropMgr.
RemoveTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks, &dirtyCopper );
403 auto updateComponentClasses =
415 if( enteredGroup &&
GetStatus( enteredGroup ) == 0 )
420 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
424 int changeType = entry.m_type &
CHT_TYPE;
425 int changeFlags = entry.m_type &
CHT_FLAGS;
431 enteredGroup->AddItem( boardItem );
442 parentFP->Add( boardItem );
447 bulkAddedItems.push_back( boardItem );
455 view->
Add( boardItem );
457 updateComponentClasses( boardItem );
468 ITEM_PICKER itemWrapper(
nullptr, boardItem, status );
469 itemWrapper.
SetLink( entry.m_copy );
470 entry.m_copy =
nullptr;
484 itemsDeselected =
true;
487 removedItems.insert( boardItem );
495 switch( boardItem->
Type() )
498 static_cast<PCB_FIELD*
>( boardItem )->SetVisible(
false );
501 view->
Update( boardItem );
531 view->
Remove( boardItem );
539 parentFP->Remove( boardItem );
540 connectivity->Remove( boardItem );
541 itemsChanged.push_back( parentFP );
546 parentFP->Remove( boardItem );
547 connectivity->Remove( boardItem );
548 itemsChanged.push_back( parentFP );
553 bulkRemovedItems.push_back( boardItem );
561 view->
Remove( boardItem );
567 bulkRemovedItems.push_back( boardItem );
581 parentFP->Remove( boardItem );
582 itemsChanged.push_back( parentFP );
587 parentFP->Remove( boardItem );
588 itemsChanged.push_back( parentFP );
593 bulkRemovedItems.push_back( boardItem );
602 bulkRemovedItems.push_back( boardItem );
624 itemWrapper.
SetLink( entry.m_copy );
625 entry.m_copy =
nullptr;
631 connectivity->MarkItemNetAsDirty( boardItemCopy );
632 connectivity->Update( boardItem );
641 updateComponentClasses( boardItem );
644 view->
Update( boardItem );
646 itemsChanged.push_back( boardItem );
657 entry.m_copy =
nullptr;
672 if( selTool && !removedItems.empty() )
676 for(
EDA_ITEM* ancestor = selectedItem; ancestor; ancestor = ancestor->
GetParent() )
678 if( removedItems.count( ancestor ) )
681 itemsDeselected =
true;
697 connectivity->ClearRatsnest();
698 connectivity->ClearLocalRatsnest();
702 connectivity->RecalculateRatsnest(
this );
704 connectivity->ClearLocalRatsnest();
712 if( solderMaskDirty )
718 if( updateBoardBoundingBox )
729 view->
Add( outline );
739 || cfg->m_Display.m_PadClearance ) )
746 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
748 teardropMgr.
UpdateTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks );
751 connectivity->RecalculateRatsnest(
this );
755 for(
size_t i = originalCount; i <
m_entries.size(); ++i )
767 wxCHECK2( boardItem,
continue );
772 itemWrapper.
SetLink( boardItemCopy );
783 view->
Add( boardItem );
785 view->
Remove( boardItem );
787 view->
Update( boardItem );
792 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
797 if( containsGeneratedTable && selTool )
813 if( itemsDeselected )
820 for(
ZONE* zone : *staleZones )
831 if( selectedModified )
843 if( !itemsDeselected && !autofillZones && !selectedModified )
845 std::vector<MSG_PANEL_ITEM> msg_list;
851 if( containsDrillMap && frame )
906 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
910 auto updateComponentClasses =
920 std::vector<BOARD_ITEM*> bulkAddedItems;
921 std::vector<BOARD_ITEM*> bulkRemovedItems;
922 std::vector<BOARD_ITEM*> itemsChanged;
923 std::vector<BOARD_ITEM*> itemsToDelete;
924 bool containsDrillMap =
false;
926 for(
int ii = aCheckpoint; ii < (int)
m_entries.size(); ++ii )
948 view->
Remove( boardItem );
950 connectivity->Remove( boardItem );
956 parentFP->Remove( boardItem );
957 itemsChanged.push_back( parentFP );
962 parentFP->Remove( boardItem );
963 itemsChanged.push_back( parentFP );
968 bulkRemovedItems.push_back( boardItem );
977 itemsToDelete.push_back( boardItem );
987 view->
Add( boardItem );
994 connectivity->Add( boardItem );
995 itemsChanged.push_back( parentFP );
1001 connectivity->Add( boardItem );
1002 itemsChanged.push_back( parentFP );
1007 bulkAddedItems.push_back( boardItem );
1010 updateComponentClasses( boardItem );
1017 view->
Remove( boardItem );
1019 connectivity->Remove( boardItem );
1026 view->
Add( boardItem );
1028 connectivity->Add( boardItem );
1029 itemsChanged.push_back( boardItem );
1031 updateComponentClasses( boardItem );
1050 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
1056 connectivity->Remove( item );
1064 connectivity->RecalculateRatsnest();
1070 selTool->RebuildSelection();
1075 if( containsDrillMap )
1094 if( entry.m_item && entry.m_item->IsBOARD_ITEM() && entry.m_item->m_Uuid == aID )
1095 return entry.m_item;
static bool isNoGeometryItem(const BOARD_ITEM *aItem)
#define SKIP_CONNECTIVITY
#define SKIP_ENTERED_GROUP
Handles how to draw a screen (a board, a schematic ...)
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
bool RemoveOrDiscard(BOARD_ITEM *aItem)
Remove aItem, or free it if it was added earlier in this commit and never reached the board.
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 EDA_ITEM * ResolveItem(KIID &aID) override
Search for an item in this commit that matches the provided KIID.
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
void RevertToCheckpoint(int aCheckpoint) 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...
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.
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
std::set< std::pair< EDA_ITEM *, BASE_SCREEN * > > m_deletedItems
void Unstage(EDA_ITEM *aItem, BASE_SCREEN *aScreen)
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT_LINE * findEntry(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Search for an entry describing change for a particular item.
virtual void makeEntry(EDA_ITEM *aItem, CHANGE_TYPE aType, EDA_ITEM *aCopy=nullptr, BASE_SCREEN *aScreen=nullptr)
std::vector< COMMIT_LINE > m_entries
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
void dropEntriesAfter(int aCheckpoint)
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 item had a property changed (except movement)
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 LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
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 RefreshDrillSymbols(int aUpdateFlags)
Refresh cached drill symbols in frames that render drill maps.
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()
Force refresh of the ratsnest visual representation.
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, std::vector< BOARD_ITEM * > *dirtyPadsAndVias, std::set< PCB_TRACK * > *dirtyTracks, const std::vector< BOARD_ITEM * > *dirtyCopper=nullptr)
Remove teardrops on dirty pads, vias or tracks, and any whose neighbouring copper moved,...
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 SELECTED
Item was manually selected by the user.
#define STRUCT_DELETED
flag indication structures to be erased
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
int RefreshGeneratedTables(BOARD &aBoard)
Bring every generated table on the board up to date and return how many were rebuilt.
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
@ REPAINT
Item needs to be redrawn.
@ GEOMETRY
Position or shape has changed.
@ LAYERS
Layers have changed.
void RefreshDrillMapOutlines(const BOARD &aBoard, KIGFX::VIEW *aView)
Repaint every drill map after an Edge.Cuts edit.
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.
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
@ PCB_CONSTRAINT_T
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_DRILL_MAP_T
class PCB_DRILL_MAP, drill symbols drawn at the holes
@ 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_3D_BODY_T
class PCB_3D_BODY, a 3D body (extruded or model) on a footprint
@ 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_GRID_ITEM_T
a subgrid placed on a board
@ 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_STACKUP_TABLE_T
class PCB_STACKUP_TABLE, a live stackup table derived from PCB_TABLE
@ 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
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
constexpr bool IsGeneratedTableType(const KICAD_T aType)
A PCB_TABLE subclass whose cells are generated from the board rather than typed by the user.
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...