46using namespace std::placeholders;
50 m_toolMgr( aTool->GetManager() ),
51 m_isBoardEditor( false ),
52 m_isFootprintEditor( false )
63 m_toolMgr( aFrame->GetToolManager() ),
72 m_isBoardEditor( false ),
73 m_isFootprintEditor( false )
85 m_isBoardEditor( aIsBoardEditor ),
86 m_isFootprintEditor( false )
105 group->RunOnChildren(
108 Stage( child, aChangeType );
110 RECURSE_MODE::NO_RECURSE );
133 std::vector<PCB_SHAPE*>* aStaleHatchedShapes )
135 wxCHECK( aChangedItem, );
138 aStaleZones->push_back(
static_cast<ZONE*
>( aChangedItem ) );
142 RECURSE_MODE::NO_RECURSE );
155 if( damageLayers.any() )
159 if( zone->GetIsRuleArea() )
162 if( ( zone->GetLayerSet() & damageLayers ).any()
163 && zone->GetBoundingBox().Intersects( damageBBox ) )
165 aStaleZones->push_back( zone );
185 aStaleHatchedShapes->push_back( shape );
207 footprint->RunOnChildren(
212 RECURSE_MODE::RECURSE );
232 bool itemsDeselected =
false;
233 bool selectedModified =
false;
236 bool solderMaskDirty =
false;
237 bool autofillZones =
false;
238 std::vector<BOARD_ITEM*> staleTeardropPadsAndVias;
239 std::set<PCB_TRACK*> staleTeardropTracks;
241 std::vector<ZONE*> staleZonesStorage;
242 std::vector<ZONE*>* staleZones =
nullptr;
243 std::vector<PCB_SHAPE*> staleHatchedShapes;
248 undoList.SetDescription( aMessage );
251 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
255 std::vector<BOARD_ITEM*> bulkAddedItems;
256 std::vector<BOARD_ITEM*> bulkRemovedItems;
257 std::vector<BOARD_ITEM*> itemsChanged;
263 autofillZones =
true;
264 staleZones = &staleZonesStorage;
267 zone->CacheBoundingBox();
272 if( !ent.m_item || !ent.m_item->IsBOARD_ITEM() )
282 solderMaskDirty =
true;
290 staleTeardropPadsAndVias.push_back(
pad );
294 staleTeardropPadsAndVias.push_back( boardItem );
300 staleTeardropTracks.insert( track );
302 std::vector<PAD*> connectedPads;
303 std::vector<PCB_VIA*> connectedVias;
305 connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
307 for(
PAD*
pad : connectedPads )
308 staleTeardropPadsAndVias.push_back(
pad );
311 staleTeardropPadsAndVias.push_back(
via );
317 selectedModified =
true;
321 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
322 teardropMgr.
RemoveTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks );
324 auto updateComponentClasses = [
this](
BOARD_ITEM* boardItem )
335 if( !ent.m_item || !ent.m_item->IsBOARD_ITEM() )
339 int changeType = ent.m_type &
CHT_TYPE;
340 int changeFlags = ent.m_type &
CHT_FLAGS;
352 undoList.PushItem(
ITEM_PICKER(
nullptr, boardItem, UNDO_REDO::NEWITEM ) );
359 wxCHECK2_MSG( parentFP,
continue,
"Commit thinks this is footprint editor, but "
360 "there is no first footprint!" );
361 parentFP->
Add( boardItem );
365 parentFP->Add( boardItem );
369 board->
Add( boardItem, ADD_MODE::BULK_INSERT );
370 bulkAddedItems.push_back( boardItem );
375 addedGroup =
static_cast<PCB_GROUP*
>( boardItem );
381 view->
Add( boardItem );
383 updateComponentClasses( boardItem );
393 undoList.PushItem(
ITEM_PICKER(
nullptr, boardItem, UNDO_REDO::DELETED ) );
400 itemsDeselected =
true;
407 ent.m_parent = parentFP->
m_Uuid;
412 switch( boardItem->
Type() )
415 static_cast<PCB_FIELD*
>( boardItem )->SetVisible(
false );
439 view->
Remove( boardItem );
445 parentFP->
Remove( boardItem );
449 board->
Remove( boardItem, REMOVE_MODE::BULK );
450 bulkRemovedItems.push_back( boardItem );
458 board->
Remove( boardItem, REMOVE_MODE::BULK );
459 bulkRemovedItems.push_back( boardItem );
478 ITEM_PICKER itemWrapper(
nullptr, boardItem, UNDO_REDO::UNGROUP );
480 undoList.PushItem( itemWrapper );
483 group->RemoveItem( boardItem );
491 addedGroup->
AddItem( boardItem );
494 undoList.PushItem(
ITEM_PICKER(
nullptr, boardItem, UNDO_REDO::REGROUP ) );
503 if( ent.m_copy && ent.m_copy->IsBOARD_ITEM() )
504 boardItemCopy =
static_cast<BOARD_ITEM*
>( ent.m_copy );
508 ITEM_PICKER itemWrapper(
nullptr, boardItem, UNDO_REDO::CHANGED );
509 wxASSERT( boardItemCopy );
510 itemWrapper.
SetLink( boardItemCopy );
511 undoList.PushItem( itemWrapper );
517 connectivity->MarkItemNetAsDirty( boardItemCopy );
519 connectivity->Update( boardItem );
528 updateComponentClasses( boardItem );
531 view->
Update( boardItem );
533 itemsChanged.push_back( boardItem );
553 RECURSE_MODE::RECURSE );
565 connectivity->ClearRatsnest();
566 connectivity->ClearLocalRatsnest();
570 connectivity->RecalculateRatsnest(
this );
572 connectivity->ClearLocalRatsnest();
580 if( solderMaskDirty )
586 if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
588 teardropMgr.
UpdateTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks );
591 connectivity->RecalculateRatsnest(
this );
595 for(
size_t i = num_changes; i <
m_changes.size(); ++i )
607 wxCHECK2( boardItem,
continue );
612 itemWrapper.
SetLink( boardItemCopy );
613 undoList.PushItem( itemWrapper );
623 view->
Add( boardItem );
625 view->
Remove( boardItem );
627 view->
Update( boardItem );
632 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
648 if( itemsDeselected )
655 for(
ZONE* zone : *staleZones )
661 for(
PCB_SHAPE* shape : staleHatchedShapes )
663 shape->SetHatchingDirty();
669 if( selectedModified )
681 if( !itemsDeselected && !autofillZones && !selectedModified )
683 std::vector<MSG_PANEL_ITEM> msg_list;
710 static_cast<BOARD_ITEM*
>( clone )->SetParentGroup(
nullptr );
723 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
727 auto updateComponentClasses = [
this](
BOARD_ITEM* boardItem )
736 std::vector<BOARD_ITEM*> bulkAddedItems;
737 std::vector<BOARD_ITEM*> bulkRemovedItems;
738 std::vector<BOARD_ITEM*> itemsChanged;
742 if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
746 int changeType = entry.m_type &
CHT_TYPE;
747 int changeFlags = entry.m_type &
CHT_FLAGS;
757 parentGroup->RemoveItem( boardItem );
763 view->
Remove( boardItem );
764 connectivity->Remove( boardItem );
768 parentFP->Remove( boardItem );
772 board->
Remove( boardItem, REMOVE_MODE::BULK );
773 bulkRemovedItems.push_back( boardItem );
783 view->
Add( boardItem );
784 connectivity->Add( boardItem );
792 static_cast<FOOTPRINT*
>( parent )->
Add( boardItem, ADD_MODE::INSERT );
796 board->
Add( boardItem, ADD_MODE::INSERT );
797 bulkAddedItems.push_back( boardItem );
800 updateComponentClasses( boardItem );
807 view->
Remove( boardItem );
808 connectivity->Remove( boardItem );
810 wxASSERT( entry.m_copy && entry.m_copy->IsBOARD_ITEM() );
816 group->RunOnChildren(
821 RECURSE_MODE::NO_RECURSE );
824 view->
Add( boardItem );
825 connectivity->Add( boardItem );
826 itemsChanged.push_back( boardItem );
828 updateComponentClasses( boardItem );
845 if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
850 connectivity->RecalculateRatsnest();
#define SKIP_CONNECTIVITY
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) override
Add a change of the item aItem of type aChangeType to the change list.
EDA_ITEM * parentObject(EDA_ITEM *aItem) const override
virtual void Revert() override
Revert the commit by restoring the modified items state.
static EDA_ITEM * MakeImage(EDA_ITEM *aItem)
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
BOARD_COMMIT(EDA_DRAW_FRAME *aFrame)
void propagateDamage(BOARD_ITEM *aItem, std::vector< ZONE * > *aStaleZones, std::vector< PCB_SHAPE * > *aStaleHatchedShapes)
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 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.
BOARD_ITEM * GetItem(const KIID &aID) const
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()
const FOOTPRINTS & Footprints() const
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.
const DRAWINGS & Drawings() const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
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)
Add a change of the item aItem of type aChangeType to the change list.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
int GetStatus(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Returns status of an item.
void clear()
Should be called in Push() & Revert() methods.
std::vector< COMMIT_LINE > m_changes
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 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)
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
bool IsHatchedFill() 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)
bool IsBOARD_ITEM() const
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.
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
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.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
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.
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...