51using namespace std::placeholders;
114 Stage( member, aChangeType, aScreen, aRecurse );
145 std::vector<BOX2I>& aStaleRuleAreas )
147 wxCHECK( aChangedItem, );
150 aStaleZones->push_back(
static_cast<ZONE*
>( aChangedItem ) );
162 if( !
static_cast<ZONE*
>( aChangedItem )->GetZoneName().IsEmpty() )
163 aStaleRuleAreas.push_back( damageBBox );
173 if( damageLayers.any() )
177 if( zone->GetIsRuleArea() )
180 if( ( zone->GetLayerSet() & damageLayers ).any() && zone->GetBoundingBox().Intersects( damageBBox ) )
181 aStaleZones->push_back( zone );
198 bool itemsDeselected =
false;
199 bool selectedModified =
false;
202 bool solderMaskDirty =
false;
203 bool autofillZones =
false;
204 bool updateBoardBoundingBox =
false;
205 std::vector<BOARD_ITEM*> staleTeardropPadsAndVias;
206 std::set<PCB_TRACK*> staleTeardropTracks;
207 std::vector<ZONE*> staleZonesStorage;
208 std::vector<ZONE*>* staleZones =
nullptr;
209 std::vector<BOX2I> staleRuleAreas;
217 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
221 std::vector<BOARD_ITEM*> bulkAddedItems;
222 std::vector<BOARD_ITEM*> bulkRemovedItems;
223 std::vector<BOARD_ITEM*> itemsChanged;
228 autofillZones =
true;
229 staleZones = &staleZonesStorage;
232 zone->CacheBoundingBox();
237 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
247 solderMaskDirty =
true;
252 updateBoardBoundingBox =
true;
260 staleTeardropPadsAndVias.push_back(
pad );
264 staleTeardropPadsAndVias.push_back( boardItem );
270 staleTeardropTracks.insert( track );
272 std::vector<PAD*> connectedPads;
273 std::vector<PCB_VIA*> connectedVias;
275 connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
277 for(
PAD*
pad : connectedPads )
278 staleTeardropPadsAndVias.push_back(
pad );
281 staleTeardropPadsAndVias.push_back(
via );
287 selectedModified =
true;
291 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
292 teardropMgr.
RemoveTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks );
294 auto updateComponentClasses =
312 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
316 int changeType = entry.m_type &
CHT_TYPE;
317 int changeFlags = entry.m_type &
CHT_FLAGS;
323 enteredGroup->AddItem( boardItem );
334 parentFP->Add( boardItem );
339 bulkAddedItems.push_back( boardItem );
347 view->
Add( boardItem );
349 updateComponentClasses( boardItem );
360 itemWrapper.
SetLink( entry.m_copy );
361 entry.m_copy =
nullptr;
370 itemsDeselected =
true;
379 switch( boardItem->
Type() )
382 static_cast<PCB_FIELD*
>( boardItem )->SetVisible(
false );
407 view->
Remove( boardItem );
414 parentFP->Remove( boardItem );
418 parentFP->Remove( boardItem );
423 bulkRemovedItems.push_back( boardItem );
431 view->
Remove( boardItem );
437 bulkRemovedItems.push_back( boardItem );
445 bulkRemovedItems.push_back( boardItem );
465 itemWrapper.
SetLink( entry.m_copy );
466 entry.m_copy =
nullptr;
472 connectivity->MarkItemNetAsDirty( boardItemCopy );
473 connectivity->Update( boardItem );
482 updateComponentClasses( boardItem );
485 view->
Update( boardItem );
487 itemsChanged.push_back( boardItem );
498 entry.m_copy =
nullptr;
518 connectivity->ClearRatsnest();
519 connectivity->ClearLocalRatsnest();
523 connectivity->RecalculateRatsnest(
this );
525 connectivity->ClearLocalRatsnest();
533 if( solderMaskDirty )
539 if( updateBoardBoundingBox && view )
548 view->
Add( outline );
555 || cfg->m_Display.m_PadClearance ) )
562 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
564 teardropMgr.
UpdateTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks );
567 connectivity->RecalculateRatsnest(
this );
571 for(
size_t i = originalCount; i <
m_entries.size(); ++i )
583 wxCHECK2( boardItem,
continue );
588 itemWrapper.
SetLink( boardItemCopy );
599 view->
Add( boardItem );
601 view->
Remove( boardItem );
603 view->
Update( boardItem );
608 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
624 if( itemsDeselected )
631 for(
ZONE* zone : *staleZones )
639 if( selectedModified )
651 if( !itemsDeselected && !autofillZones && !selectedModified )
653 std::vector<MSG_PANEL_ITEM> msg_list;
702 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
706 auto updateComponentClasses =
716 std::vector<BOARD_ITEM*> bulkAddedItems;
717 std::vector<BOARD_ITEM*> bulkRemovedItems;
718 std::vector<BOARD_ITEM*> itemsChanged;
719 std::vector<BOARD_ITEM*> itemsToDelete;
723 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
727 int changeType = entry.m_type &
CHT_TYPE;
728 int changeFlags = entry.m_type &
CHT_FLAGS;
736 view->
Remove( boardItem );
738 connectivity->Remove( boardItem );
743 parentFP->Remove( boardItem );
747 parentFP->Remove( boardItem );
752 bulkRemovedItems.push_back( boardItem );
758 itemsToDelete.push_back( boardItem );
759 entry.m_item =
nullptr;
768 view->
Add( boardItem );
782 bulkAddedItems.push_back( boardItem );
785 updateComponentClasses( boardItem );
792 view->
Remove( boardItem );
794 connectivity->Remove( boardItem );
796 wxASSERT( entry.m_copy && entry.m_copy->IsBOARD_ITEM() );
801 view->
Add( boardItem );
803 connectivity->Add( boardItem );
804 itemsChanged.push_back( boardItem );
806 updateComponentClasses( boardItem );
817 entry.m_copy =
nullptr;
825 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
831 connectivity->Remove( item );
839 connectivity->RecalculateRatsnest();
#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)
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_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...