49using namespace std::placeholders;
 
  112                Stage( member, aChangeType, aScreen, aRecurse );
 
 
  133                                    std::vector<BOX2I>& aStaleRuleAreas )
 
  135    wxCHECK( aChangedItem,  );
 
  138        aStaleZones->push_back( 
static_cast<ZONE*
>( aChangedItem ) );
 
  150        if( !
static_cast<ZONE*
>( aChangedItem )->GetZoneName().IsEmpty() )
 
  151            aStaleRuleAreas.push_back( damageBBox );
 
  161        if( damageLayers.any() )
 
  165                if( zone->GetIsRuleArea() )
 
  168                if( ( zone->GetLayerSet() & damageLayers ).any() && zone->GetBoundingBox().Intersects( damageBBox ) )
 
  169                    aStaleZones->push_back( zone );
 
 
  186    bool                itemsDeselected = 
false;
 
  187    bool                selectedModified = 
false;
 
  190    bool                     solderMaskDirty = 
false;
 
  191    bool                     autofillZones = 
false;
 
  192    bool                     updateBoardBoundingBox = 
false;
 
  193    std::vector<BOARD_ITEM*> staleTeardropPadsAndVias;
 
  194    std::set<PCB_TRACK*>     staleTeardropTracks;
 
  195    std::vector<ZONE*>       staleZonesStorage;
 
  196    std::vector<ZONE*>*      staleZones = 
nullptr;
 
  197    std::vector<BOX2I>       staleRuleAreas;
 
  205    std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
 
  209    std::vector<BOARD_ITEM*> bulkAddedItems;
 
  210    std::vector<BOARD_ITEM*> bulkRemovedItems;
 
  211    std::vector<BOARD_ITEM*> itemsChanged;
 
  216        autofillZones = 
true;
 
  217        staleZones = &staleZonesStorage;
 
  220            zone->CacheBoundingBox();
 
  225        if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
 
  235                solderMaskDirty = 
true;
 
  240                updateBoardBoundingBox = 
true;
 
  248                        staleTeardropPadsAndVias.push_back( 
pad );
 
  252                    staleTeardropPadsAndVias.push_back( boardItem );
 
  258                    staleTeardropTracks.insert( track );
 
  260                    std::vector<PAD*>     connectedPads;
 
  261                    std::vector<PCB_VIA*> connectedVias;
 
  263                    connectivity->GetConnectedPadsAndVias( track, &connectedPads, &connectedVias );
 
  265                    for( 
PAD* 
pad : connectedPads )
 
  266                        staleTeardropPadsAndVias.push_back( 
pad );
 
  269                        staleTeardropPadsAndVias.push_back( 
via );
 
  275            selectedModified = 
true;
 
  279    if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
 
  280        teardropMgr.
RemoveTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks );
 
  282    auto updateComponentClasses =
 
  300        if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
 
  304        int         changeType = entry.m_type & 
CHT_TYPE;
 
  305        int         changeFlags = entry.m_type & 
CHT_FLAGS;
 
  311                enteredGroup->AddItem( boardItem );
 
  321                        parentFP->Add( boardItem );
 
  326                    bulkAddedItems.push_back( boardItem );
 
  334                view->
Add( boardItem );
 
  336            updateComponentClasses( boardItem );
 
  347                itemWrapper.
SetLink( entry.m_copy );
 
  348                entry.m_copy = 
nullptr;   
 
  357                itemsDeselected = 
true;
 
  366            switch( boardItem->
Type() )
 
  369                static_cast<PCB_FIELD*
>( boardItem )->SetVisible( 
false );
 
  395                    view->
Remove( boardItem );
 
  402                            parentFP->Remove( boardItem );
 
  407                        bulkRemovedItems.push_back( boardItem );
 
  416                bulkRemovedItems.push_back( boardItem );
 
  436                itemWrapper.
SetLink( entry.m_copy );
 
  437                entry.m_copy = 
nullptr;   
 
  443                connectivity->MarkItemNetAsDirty( boardItemCopy );
 
  444                connectivity->Update( boardItem );
 
  453            updateComponentClasses( boardItem );
 
  456                view->
Update( boardItem );
 
  458            itemsChanged.push_back( boardItem );
 
  469        entry.m_copy = 
nullptr;
 
  489            connectivity->ClearRatsnest();
 
  490            connectivity->ClearLocalRatsnest();
 
  494            connectivity->RecalculateRatsnest( 
this );
 
  496            connectivity->ClearLocalRatsnest();
 
  504        if( solderMaskDirty )
 
  510        if( updateBoardBoundingBox && view )
 
  519                    view->
Add( outline );
 
  526                                            || cfg->m_Display.m_PadClearance ) )
 
  533        if( !staleTeardropPadsAndVias.empty() || !staleTeardropTracks.empty() )
 
  535            teardropMgr.
UpdateTeardrops( *
this, &staleTeardropPadsAndVias, &staleTeardropTracks );
 
  538            connectivity->RecalculateRatsnest( 
this );
 
  542        for( 
size_t i = originalCount; i < 
m_entries.size(); ++i )
 
  554            wxCHECK2( boardItem, 
continue );
 
  559                itemWrapper.
SetLink( boardItemCopy );
 
  570                    view->
Add( boardItem );
 
  572                    view->
Remove( boardItem );
 
  574                    view->
Update( boardItem );
 
  579    if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
 
  595    if( itemsDeselected )
 
  602        for( 
ZONE* zone : *staleZones )
 
  610    if( selectedModified )
 
  622        if( !itemsDeselected && !autofillZones && !selectedModified )
 
  624            std::vector<MSG_PANEL_ITEM> msg_list;
 
 
  673    std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->
GetConnectivity();
 
  677    auto updateComponentClasses =
 
  687    std::vector<BOARD_ITEM*> bulkAddedItems;
 
  688    std::vector<BOARD_ITEM*> bulkRemovedItems;
 
  689    std::vector<BOARD_ITEM*> itemsChanged;
 
  693        if( !entry.m_item || !entry.m_item->IsBOARD_ITEM() )
 
  697        int          changeType = entry.m_type & 
CHT_TYPE;
 
  698        int          changeFlags = entry.m_type & 
CHT_FLAGS;
 
  707                view->
Remove( boardItem );
 
  712                    parentFP->Remove( boardItem );
 
  717                bulkRemovedItems.push_back( boardItem );
 
  728                view->
Add( boardItem );
 
  738                bulkAddedItems.push_back( boardItem );
 
  741            updateComponentClasses( boardItem );
 
  748                view->
Remove( boardItem );
 
  750            connectivity->Remove( boardItem );
 
  752            wxASSERT( entry.m_copy && entry.m_copy->IsBOARD_ITEM() );
 
  757                view->
Add( boardItem );
 
  759            connectivity->Add( boardItem );
 
  760            itemsChanged.push_back( boardItem );
 
  762            updateComponentClasses( boardItem );
 
  779    if( bulkAddedItems.size() > 0 || bulkRemovedItems.size() > 0 || itemsChanged.size() > 0 )
 
  784        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, 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.
 
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 & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
 
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 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...