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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef SCH_RULE_AREA_H
25#define SCH_RULE_AREA_H
26
27#include <unordered_set>
28#include <utility>
29
30#include <plotters/plotter.h>
31#include <sch_plotter.h>
32#include <sch_screen.h>
33#include <sch_shape.h>
34#include <sch_label.h>
35#include <sch_sheet_path.h>
36#include <sch_view.h>
37
38class SCHEMATIC;
39
41{
42public:
45 m_excludedFromSim( false ),
46 m_excludedFromBOM( false ),
47 m_excludedFromBoard( false ),
48 m_DNP( false )
49 {
51 }
52
53 virtual ~SCH_RULE_AREA();
54
55 wxString GetClass() const override;
56
57 wxString GetFriendlyName() const override;
58
59 EDA_ITEM* Clone() const override;
60
64 void SetExcludedFromSim( bool aExcludeFromSim, const SCH_SHEET_PATH* aInstance = nullptr,
65 const wxString& aVariantName = wxEmptyString ) override
66 {
67 m_excludedFromSim = aExcludeFromSim;
68 }
69
70 bool GetExcludedFromSim( const SCH_SHEET_PATH* aInstance = nullptr,
71 const wxString& aVariantName = wxEmptyString ) const override
72 {
73 return m_excludedFromSim;
74 }
75
76 bool GetExcludedFromSimProp() const { return GetExcludedFromSim(); }
77
78 void SetExcludedFromSimProp( bool aExcludeFromSim ) { SetExcludedFromSim( aExcludeFromSim ); }
79
83 void SetExcludedFromBOM( bool aExcludeFromBOM, const SCH_SHEET_PATH* aInstance = nullptr,
84 const wxString& aVariantName = wxEmptyString ) override
85 {
86 m_excludedFromBOM = aExcludeFromBOM;
87 }
88
89 bool GetExcludedFromBOM( const SCH_SHEET_PATH* aInstance = nullptr,
90 const wxString& aVariantName = wxEmptyString ) const override
91 {
92 return m_excludedFromBOM;
93 }
94
95 bool GetExcludedFromBOMProp() const { return GetExcludedFromBOM(); }
96
97 void SetExcludedFromBOMProp( bool aExcludeFromBOM ) { SetExcludedFromBOM( aExcludeFromBOM ); }
98
102 void SetExcludedFromBoard( bool aExclude, const SCH_SHEET_PATH* aInstance = nullptr,
103 const wxString& aVariantName = wxEmptyString ) override
104 {
105 m_excludedFromBoard = aExclude;
106 }
107
108 bool GetExcludedFromBoard( const SCH_SHEET_PATH* aInstance = nullptr,
109 const wxString& aVariantName = wxEmptyString ) const override
110 {
111 return m_excludedFromBoard;
112 }
113
115 void SetExcludedFromBoardProp( bool aExclude ) { SetExcludedFromBoard( aExclude ); }
116
120 bool GetDNP( const SCH_SHEET_PATH* aInstance = nullptr,
121 const wxString& aVariantName = wxEmptyString ) const override { return m_DNP; }
122 void SetDNP( bool aDNP, const SCH_SHEET_PATH* aInstance = nullptr,
123 const wxString& aVariantName = wxEmptyString ) override { m_DNP = aDNP; }
124
125 bool GetDNPProp() const { return GetDNP(); }
126
127 void SetDNPProp( bool aDNP ) { SetDNP( aDNP ); }
128
129 std::vector<int> ViewGetLayers() const override;
130
131 bool IsFilledForHitTesting() const override
132 {
133 return false;
134 }
135
136 virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override;
137
138 virtual void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
139 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
140
141 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
142
145
149 static std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>>
150 UpdateRuleAreasInScreens( std::unordered_set<SCH_SCREEN*>& screens, KIGFX::SCH_VIEW* view );
151
153 const std::unordered_set<SCH_ITEM*>& GetContainedItems() const;
154
155 const std::unordered_set<KIID>& GetPastContainedItems() const;
156
158 const std::unordered_set<SCH_DIRECTIVE_LABEL*>& GetDirectives() const;
159
163 const std::vector<std::pair<wxString, SCH_ITEM*>> GetResolvedNetclasses( const SCH_SHEET_PATH* aSheetPath ) const;
164
166 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
167
168protected:
170 void addDirective( SCH_DIRECTIVE_LABEL* label );
171
173 void addContainedItem( SCH_ITEM* item );
174
176 void resetCaches();
177
178protected:
182 bool m_DNP;
183
184public:
186 void RemoveItem( SCH_ITEM* aItem );
187
189 void RemoveDirective( SCH_DIRECTIVE_LABEL* aLabel );
190
192 std::unordered_set<SCH_ITEM*> m_items;
193 std::unordered_set<KIID> m_itemIDs;
194
196 std::unordered_set<SCH_DIRECTIVE_LABEL*> m_directives;
197 std::unordered_set<KIID> m_directiveIDs;
198
200 std::unordered_set<KIID> m_prev_items;
201
203 std::unordered_set<KIID> m_prev_directives;
204};
205
206#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:100
Base plotter engine class.
Definition plotter.h:136
Holds all the data relating to one schematic.
Definition schematic.h:89
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:168
void SetLayer(SCH_LAYER_ID aLayer)
Definition sch_item.h:345
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:56
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:45
FILL_T
Definition eda_shape.h:58
@ NO_FILL
Definition eda_shape.h:59
@ LAYER_RULE_AREAS
Definition layer_ids.h:467
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ SCH_RULE_AREA_T
Definition typeinfo.h:171
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687