KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_rule_area.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef SCH_RULE_AREA_H
21#define SCH_RULE_AREA_H
22
23#include <unordered_set>
24#include <utility>
25
26#include <plotters/plotter.h>
27#include <sch_plotter.h>
28#include <sch_screen.h>
29#include <sch_shape.h>
30#include <sch_label.h>
31#include <sch_sheet_path.h>
32#include <sch_view.h>
33
34class SCHEMATIC;
35
37{
38public:
41 m_excludedFromSim( false ),
42 m_excludedFromBOM( false ),
43 m_excludedFromBoard( false ),
44 m_DNP( false )
45 {
47 }
48
49 virtual ~SCH_RULE_AREA();
50
51 wxString GetClass() const override;
52
53 wxString GetFriendlyName() const override;
54
55 EDA_ITEM* Clone() const override;
56
60 void SetExcludedFromSim( bool aExcludeFromSim, const SCH_SHEET_PATH* aInstance = nullptr,
61 const wxString& aVariantName = wxEmptyString ) override
62 {
63 m_excludedFromSim = aExcludeFromSim;
64 }
65
66 bool GetExcludedFromSim( const SCH_SHEET_PATH* aInstance = nullptr,
67 const wxString& aVariantName = wxEmptyString ) const override
68 {
69 return m_excludedFromSim;
70 }
71
72 bool GetExcludedFromSimProp() const { return GetExcludedFromSim(); }
73
74 void SetExcludedFromSimProp( bool aExcludeFromSim ) { SetExcludedFromSim( aExcludeFromSim ); }
75
79 void SetExcludedFromBOM( bool aExcludeFromBOM, const SCH_SHEET_PATH* aInstance = nullptr,
80 const wxString& aVariantName = wxEmptyString ) override
81 {
82 m_excludedFromBOM = aExcludeFromBOM;
83 }
84
85 bool GetExcludedFromBOM( const SCH_SHEET_PATH* aInstance = nullptr,
86 const wxString& aVariantName = wxEmptyString ) const override
87 {
88 return m_excludedFromBOM;
89 }
90
91 bool GetExcludedFromBOMProp() const { return GetExcludedFromBOM(); }
92
93 void SetExcludedFromBOMProp( bool aExcludeFromBOM ) { SetExcludedFromBOM( aExcludeFromBOM ); }
94
98 void SetExcludedFromBoard( bool aExclude, const SCH_SHEET_PATH* aInstance = nullptr,
99 const wxString& aVariantName = wxEmptyString ) override
100 {
101 m_excludedFromBoard = aExclude;
102 }
103
104 bool GetExcludedFromBoard( const SCH_SHEET_PATH* aInstance = nullptr,
105 const wxString& aVariantName = wxEmptyString ) const override
106 {
107 return m_excludedFromBoard;
108 }
109
111 void SetExcludedFromBoardProp( bool aExclude ) { SetExcludedFromBoard( aExclude ); }
112
116 bool GetDNP( const SCH_SHEET_PATH* aInstance = nullptr,
117 const wxString& aVariantName = wxEmptyString ) const override { return m_DNP; }
118 void SetDNP( bool aDNP, const SCH_SHEET_PATH* aInstance = nullptr,
119 const wxString& aVariantName = wxEmptyString ) override { m_DNP = aDNP; }
120
121 bool GetDNPProp() const { return GetDNP(); }
122
123 void SetDNPProp( bool aDNP ) { SetDNP( aDNP ); }
124
125 std::vector<int> ViewGetLayers() const override;
126
127 bool IsFilledForHitTesting() const override
128 {
129 return false;
130 }
131
132 virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override;
133
134 virtual void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
135 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
136
137 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
138
141
145 static std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>>
146 UpdateRuleAreasInScreens( std::unordered_set<SCH_SCREEN*>& screens, KIGFX::SCH_VIEW* view );
147
149 const std::unordered_set<SCH_ITEM*>& GetContainedItems() const;
150
151 const std::unordered_set<KIID>& GetPastContainedItems() const;
152
154 const std::unordered_set<SCH_DIRECTIVE_LABEL*>& GetDirectives() const;
155
159 const std::vector<std::pair<wxString, SCH_ITEM*>> GetResolvedNetclasses( const SCH_SHEET_PATH* aSheetPath ) const;
160
162 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
163
164protected:
166 void addDirective( SCH_DIRECTIVE_LABEL* label );
167
169 void addContainedItem( SCH_ITEM* item );
170
172 void resetCaches();
173
174protected:
178 bool m_DNP;
179
180public:
182 void RemoveItem( SCH_ITEM* aItem );
183
185 void RemoveDirective( SCH_DIRECTIVE_LABEL* aLabel );
186
188 std::unordered_set<SCH_ITEM*> m_items;
189 std::unordered_set<KIID> m_itemIDs;
190
192 std::unordered_set<SCH_DIRECTIVE_LABEL*> m_directives;
193 std::unordered_set<KIID> m_directiveIDs;
194
196 std::unordered_set<KIID> m_prev_items;
197
199 std::unordered_set<KIID> m_prev_directives;
200};
201
202#endif
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
Base plotter engine class.
Definition plotter.h:133
Holds all the data relating to one schematic.
Definition schematic.h:90
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
void SetLayer(SCH_LAYER_ID aLayer)
Definition sch_item.h:339
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:52
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
std::unordered_set< KIID > m_directiveIDs
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the EDA_SHAPE.
const std::unordered_set< SCH_ITEM * > & GetContainedItems() const
Return a set of all items contained within the rule area.
void addContainedItem(SCH_ITEM *item)
Add an item to the list of items which this rule area affects.
std::unordered_set< KIID > m_prev_items
All SCH_ITEM objectss contained or intersecting the rule area in the previous update.
std::unordered_set< KIID > m_prev_directives
All SCH_DIRECTIVE_LABEL objects attached to the rule area border in the previous update.
void RefreshContainedItemsAndDirectives(SCH_SCREEN *screen)
Refresh the list of items which this rule area affects.
void SetExcludedFromBOMProp(bool aExcludeFromBOM)
bool m_DNP
True if symbol is set to 'Do Not Populate'.
void resetCaches()
Reset all item and directive caches, saving the current state first.
const std::unordered_set< SCH_DIRECTIVE_LABEL * > & GetDirectives() const
Return the set of all directive labels attached to the rule area border.
void addDirective(SCH_DIRECTIVE_LABEL *label)
Add a directive label which applies to items within ths rule area.
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
bool GetExcludedFromBoardProp() const
void SetExcludedFromSimProp(bool aExcludeFromSim)
wxString GetFriendlyName() const override
virtual void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
bool IsFilledForHitTesting() const override
std::unordered_set< SCH_DIRECTIVE_LABEL * > m_directives
All SCH_DIRECTIVE_LABEL objects attached to the rule area border. No ownership.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool GetExcludedFromSimProp() const
const std::vector< std::pair< wxString, SCH_ITEM * > > GetResolvedNetclasses(const SCH_SHEET_PATH *aSheetPath) const
Resolve the netclass of this rule area from connected directive labels.
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
void SetDNP(bool aDNP, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
void SetExcludedFromSim(bool aExcludeFromSim, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
static std::vector< std::pair< SCH_RULE_AREA *, SCH_SCREEN * > > UpdateRuleAreasInScreens(std::unordered_set< SCH_SCREEN * > &screens, KIGFX::SCH_VIEW *view)
Update all rule area connectvity / caches in the given sheet paths.
void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
virtual ~SCH_RULE_AREA()
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
std::unordered_set< SCH_ITEM * > m_items
All SCH_ITEM objects currently contained or intersecting the rule area. No ownership.
const std::unordered_set< KIID > & GetPastContainedItems() const
void SetExcludedFromBoardProp(bool aExclude)
std::unordered_set< KIID > m_itemIDs
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
void RemoveDirective(SCH_DIRECTIVE_LABEL *aLabel)
Remove a directive label from this rule area's caches (called when the label is deleted).
bool GetExcludedFromBOMProp() const
bool GetDNPProp() const
wxString GetClass() const override
Return the class name.
void RemoveItem(SCH_ITEM *aItem)
Remove an item from this rule area's caches (called when the item is deleted).
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Get the message panel info for the rule area.
void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from board netlist flag.
void SetDNPProp(bool aDNP)
SCH_SHAPE(SHAPE_T aShape=SHAPE_T::UNDEFINED, SCH_LAYER_ID aLayer=LAYER_NOTES, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, KICAD_T aType=SCH_SHAPE_T)
Definition sch_shape.cpp:40
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SHAPE_T
Definition eda_shape.h:44
FILL_T
Definition eda_shape.h:59
@ NO_FILL
Definition eda_shape.h:60
@ LAYER_RULE_AREAS
Definition layer_ids.h:463
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ SCH_RULE_AREA_T
Definition typeinfo.h:167
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683