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
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
94 void SetExcludedFromBoard( bool aExcludeFromBoard ) override { m_excludedFromBoard = aExcludeFromBoard; }
95 bool GetExcludedFromBoard() const override { return m_excludedFromBoard; }
96
100 bool GetDNP( const SCH_SHEET_PATH* aInstance = nullptr,
101 const wxString& aVariantName = wxEmptyString ) const override { return m_DNP; }
102 void SetDNP( bool aDNP, const SCH_SHEET_PATH* aInstance = nullptr,
103 const wxString& aVariantName = wxEmptyString ) override { m_DNP = aDNP; }
104
105 std::vector<int> ViewGetLayers() const override;
106
107 bool IsFilledForHitTesting() const override
108 {
109 return false;
110 }
111
112 virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override;
113
114 virtual void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
115 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
116
117 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
118
121
125 static std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>>
126 UpdateRuleAreasInScreens( std::unordered_set<SCH_SCREEN*>& screens, KIGFX::SCH_VIEW* view );
127
129 const std::unordered_set<SCH_ITEM*>& GetContainedItems() const;
130
131 const std::unordered_set<KIID>& GetPastContainedItems() const;
132
134 const std::unordered_set<SCH_DIRECTIVE_LABEL*>& GetDirectives() const;
135
139 const std::vector<std::pair<wxString, SCH_ITEM*>> GetResolvedNetclasses() const;
140
142 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
143
144protected:
146 void addDirective( SCH_DIRECTIVE_LABEL* label );
147
149 void addContainedItem( SCH_ITEM* item );
150
152 void resetCaches();
153
154protected:
158 bool m_DNP;
159
161 std::unordered_set<SCH_ITEM*> m_items;
162 std::unordered_set<KIID> m_itemIDs;
163
165 std::unordered_set<SCH_DIRECTIVE_LABEL*> m_directives;
166 std::unordered_set<KIID> m_directiveIDs;
167
169 std::unordered_set<KIID> m_prev_items;
170
172 std::unordered_set<KIID> m_prev_directives;
173};
174
175#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:121
Holds all the data relating to one schematic.
Definition schematic.h:88
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
void SetLayer(SCH_LAYER_ID aLayer)
Definition sch_item.h:322
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 SetExcludedFromBoard(bool aExcludeFromBoard) override
Set or clear exclude from board netlist flag.
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.
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.
bool GetExcludedFromBoard() const override
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)
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 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.
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::vector< std::pair< wxString, SCH_ITEM * > > GetResolvedNetclasses() const
Resolve the netclass of this rule area from connected directive labels.
virtual ~SCH_RULE_AREA()
const std::unordered_set< KIID > & GetPastContainedItems() const
std::unordered_set< KIID > m_itemIDs
wxString GetClass() const override
Return the class name.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Get the message panel info for the rule area.
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:38
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:43
FILL_T
Definition eda_shape.h:56
@ NO_FILL
Definition eda_shape.h:57
@ LAYER_RULE_AREAS
Definition layer_ids.h:465
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ SCH_RULE_AREA_T
Definition typeinfo.h:174
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695