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 void Serialize( google::protobuf::Any& aContainer ) const override;
52 bool Deserialize( const google::protobuf::Any& aContainer ) override;
53
54 wxString GetClass() const override;
55
56 wxString GetFriendlyName() const override;
57
58 EDA_ITEM* Clone() const override;
59
63 void SetExcludedFromSim( bool aExcludeFromSim, const SCH_SHEET_PATH* aInstance = nullptr,
64 const wxString& aVariantName = wxEmptyString ) override
65 {
66 m_excludedFromSim = aExcludeFromSim;
67 }
68
69 bool GetExcludedFromSim( const SCH_SHEET_PATH* aInstance = nullptr,
70 const wxString& aVariantName = wxEmptyString ) const override
71 {
72 return m_excludedFromSim;
73 }
74
75 bool GetExcludedFromSimProp() const { return GetExcludedFromSim(); }
76
77 void SetExcludedFromSimProp( bool aExcludeFromSim ) { SetExcludedFromSim( aExcludeFromSim ); }
78
82 void SetExcludedFromBOM( bool aExcludeFromBOM, const SCH_SHEET_PATH* aInstance = nullptr,
83 const wxString& aVariantName = wxEmptyString ) override
84 {
85 m_excludedFromBOM = aExcludeFromBOM;
86 }
87
88 bool GetExcludedFromBOM( const SCH_SHEET_PATH* aInstance = nullptr,
89 const wxString& aVariantName = wxEmptyString ) const override
90 {
91 return m_excludedFromBOM;
92 }
93
94 bool GetExcludedFromBOMProp() const { return GetExcludedFromBOM(); }
95
96 void SetExcludedFromBOMProp( bool aExcludeFromBOM ) { SetExcludedFromBOM( aExcludeFromBOM ); }
97
101 void SetExcludedFromBoard( bool aExclude, const SCH_SHEET_PATH* aInstance = nullptr,
102 const wxString& aVariantName = wxEmptyString ) override
103 {
104 m_excludedFromBoard = aExclude;
105 }
106
107 bool GetExcludedFromBoard( const SCH_SHEET_PATH* aInstance = nullptr,
108 const wxString& aVariantName = wxEmptyString ) const override
109 {
110 return m_excludedFromBoard;
111 }
112
114 void SetExcludedFromBoardProp( bool aExclude ) { SetExcludedFromBoard( aExclude ); }
115
119 bool GetDNP( const SCH_SHEET_PATH* aInstance = nullptr,
120 const wxString& aVariantName = wxEmptyString ) const override { return m_DNP; }
121 void SetDNP( bool aDNP, const SCH_SHEET_PATH* aInstance = nullptr,
122 const wxString& aVariantName = wxEmptyString ) override { m_DNP = aDNP; }
123
124 bool GetDNPProp() const { return GetDNP(); }
125
126 void SetDNPProp( bool aDNP ) { SetDNP( aDNP ); }
127
128 std::vector<int> ViewGetLayers() const override;
129
130 bool IsFilledForHitTesting() const override
131 {
132 return false;
133 }
134
135 virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override;
136
137 virtual void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
138 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
139
140 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
141
144
148 static std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>>
149 UpdateRuleAreasInScreens( std::unordered_set<SCH_SCREEN*>& screens, KIGFX::SCH_VIEW* view );
150
152 const std::unordered_set<SCH_ITEM*>& GetContainedItems() const;
153
154 const std::unordered_set<KIID>& GetPastContainedItems() const;
155
157 const std::unordered_set<SCH_DIRECTIVE_LABEL*>& GetDirectives() const;
158
162 const std::vector<std::pair<wxString, SCH_ITEM*>> GetResolvedNetclasses( const SCH_SHEET_PATH* aSheetPath ) const;
163
168 {
169 return !m_directives.empty() && !m_DNP && !m_excludedFromSim && !m_excludedFromBOM
171 }
172
174 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
175
176protected:
178 void addDirective( SCH_DIRECTIVE_LABEL* label );
179
181 void addContainedItem( SCH_ITEM* item );
182
184 void resetCaches();
185
186protected:
190 bool m_DNP;
191
192public:
194 void RemoveItem( SCH_ITEM* aItem );
195
197 void RemoveDirective( SCH_DIRECTIVE_LABEL* aLabel );
198
200 std::unordered_set<SCH_ITEM*> m_items;
201 std::unordered_set<KIID> m_itemIDs;
202
204 std::unordered_set<SCH_DIRECTIVE_LABEL*> m_directives;
205 std::unordered_set<KIID> m_directiveIDs;
206
208 std::unordered_set<KIID> m_prev_items;
209
211 std::unordered_set<KIID> m_prev_directives;
212};
213
214#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:98
Base plotter engine class.
Definition plotter.h:136
Holds all the data relating to one schematic.
Definition schematic.h:148
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:165
void SetLayer(SCH_LAYER_ID aLayer)
Definition sch_item.h:346
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)
bool IsDirectiveLabelOnlyArea() const
Return true when the rule area exists only as a container for attached directive labels.
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.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
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:41
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
FILL_T
Definition eda_fill.h:29
@ NO_FILL
Definition eda_fill.h:30
SHAPE_T
Definition eda_shape.h:54
@ LAYER_RULE_AREAS
Definition layer_ids.h:487
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ SCH_RULE_AREA_T
Definition typeinfo.h:166
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683