39using namespace std::placeholders;
43 m_toolMgr( aToolMgr ),
44 m_isFootprintEditor( false ),
45 m_isBoardEditor( false )
79 wxCHECK( aItem, *
this );
90 static_cast<FOOTPRINT*
>( aItem )->RunOnChildren(
100 static_cast<PCB_GROUP*
>( aItem )->RunOnChildren(
117 static_cast<PCB_GROUP*
>( aItem )->RunOnChildren(
152 static_cast<FOOTPRINT*
>( item )->RunOnChildren(
163 static_cast<PCB_GROUP*
>( item )->RunOnChildren(
185 if( zone->GetIsRuleArea() )
188 if( ( zone->GetLayerSet() & layers ).any()
189 && zone->GetBoundingBox().Intersects( bbox ) )
208 std::set<EDA_ITEM*> savedModules;
210 bool itemsDeselected =
false;
211 bool solderMaskDirty =
false;
212 bool autofillZones =
false;
213 bool selectedModified =
false;
218 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
225 std::vector<BOARD_ITEM*> bulkAddedItems;
226 std::vector<BOARD_ITEM*> bulkRemovedItems;
227 std::vector<BOARD_ITEM*> itemsChanged;
233 autofillZones =
true;
236 zone->CacheBoundingBox();
241 int changeType = ent.m_type &
CHT_TYPE;
242 int changeFlags = ent.m_type &
CHT_FLAGS;
245 wxASSERT( ent.m_item );
253 ent.m_item = ent.m_item->GetParent();
254 wxASSERT( ent.m_item );
258 if( savedModules.count( ent.m_item ) == 0 )
269 if( !( aCommitFlags &
SKIP_UNDO ) && frame )
272 itemWrapper.
SetLink( ent.m_copy );
277 savedModules.insert( ent.m_item );
284 solderMaskDirty =
true;
288 selectedModified =
true;
293 static_cast<FOOTPRINT*
>( boardItem )->RunOnChildren(
297 selectedModified =
true;
319 board->
Footprints().front()->Add( boardItem );
343 bulkAddedItems.push_back( boardItem );
351 view->
Add( boardItem );
368 itemsDeselected =
true;
377 switch( boardItem->
Type() )
405 view->
Remove( boardItem );
411 footprint->
Delete( boardItem );
433 view->
Remove( boardItem );
438 bulkRemovedItems.push_back( boardItem );
451 view->
Remove( footprint );
458 bulkRemovedItems.push_back( footprint );
466 view->
Remove( boardItem );
475 bulkRemovedItems.push_back( boardItem );
484 bulkRemovedItems.push_back( boardItem );
500 wxASSERT( ent.m_copy );
501 itemWrapper.
SetLink( ent.m_copy );
508 connectivity->MarkItemNetAsDirty(
static_cast<BOARD_ITEM*
>( ent.m_copy ) );
510 connectivity->Update( boardItem );
521 view->
Update( boardItem );
525 static_cast<FOOTPRINT*
>( boardItem )->RunOnChildren(
533 itemsChanged.push_back( boardItem );
548 if( bulkAddedItems.size() > 0 )
551 if( bulkRemovedItems.size() > 0 )
554 if( itemsChanged.size() > 0 )
563 connectivity->ClearRatsnest();
564 connectivity->ClearLocalRatsnest();
568 connectivity->RecalculateRatsnest(
this );
570 connectivity->ClearLocalRatsnest();
576 if( solderMaskDirty )
583 for(
size_t i = num_changes; i <
m_changes.size(); ++i )
604 view->
Update( boardItem );
618 if( itemsDeselected )
624 if( selectedModified )
641 switch( aItem->
Type() )
681 std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
685 std::vector<BOARD_ITEM*> bulkAddedItems;
686 std::vector<BOARD_ITEM*> bulkRemovedItems;
687 std::vector<BOARD_ITEM*> itemsChanged;
704 connectivity->Remove( item );
706 bulkRemovedItems.push_back( item );
714 connectivity->Add( item );
716 bulkAddedItems.push_back( item );
722 connectivity->Remove( item );
737 connectivity->Add( item );
739 itemsChanged.push_back( item );
751 if( bulkAddedItems.size() > 0 )
754 if( bulkRemovedItems.size() > 0 )
757 if( itemsChanged.size() > 0 )
762 connectivity->RecalculateRatsnest();
#define SKIP_CONNECTIVITY
void dirtyIntersectingZones(BOARD_ITEM *item, int aChangeType)
EDA_ITEM * parentObject(EDA_ITEM *aItem) const override
BOARD_COMMIT(TOOL_MANAGER *aToolMgr)
virtual void Revert() override
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
EDA_ITEM * makeImage(EDA_ITEM *aItem) const override
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType) override
virtual void Delete(BOARD_ITEM *aItem)
Removes an item from the container and deletes it.
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 LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual bool IsOnLayer(PCB_LAYER_ID aLayer, bool aIncludeCourtyards=false) const
Test to see if this object is on the given layer.
BOARD_ITEM_CONTAINER * GetParent() const
Information pertinent to a Pcbnew printed circuit board.
void OnItemChanged(BOARD_ITEM *aItem)
Notify the board and its listeners that an item on the board has been modified in some way.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
FOOTPRINTS & Footprints()
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 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)
bool Empty() const
Returns status of an item.
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.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM * GetParent() const
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
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)
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 ...
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void AppendCopyToUndoList(const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aTypeCommand)=0
As SaveCopyInUndoList, but appends the changes to the last undo item on the stack.
virtual void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand)=0
Create a new entry in undo list of commands.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
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.
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
Handle a list of polygons defining a copper zone.
CHANGE_TYPE
Types of changes.
@ CHT_TYPE
Flag to indicate the change is already applied, just notify observers (not compatible with CHT_MODIFY...
#define IS_MODIFIED_CHILD
when a child is promoted to its parent for a COMMIT, this flag indicates the modified child
#define STRUCT_DELETED
flag indication structures to be erased
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_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ 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_FP_SHAPE_T
class FP_SHAPE, a footprint edge
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
@ 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_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ 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...