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 ) override { m_excludedFromSim = aExcludeFromSim; }
65 bool GetExcludedFromSim() const override { return m_excludedFromSim; }
66
70 void SetExcludedFromBOM( bool aExcludeFromBOM ) override { m_excludedFromBOM = aExcludeFromBOM; }
71 bool GetExcludedFromBOM() const override { return m_excludedFromBOM; }
72
76 void SetExcludedFromBoard( bool aExcludeFromBoard ) override { m_excludedFromBoard = aExcludeFromBoard; }
77 bool GetExcludedFromBoard() const override { return m_excludedFromBoard; }
78
82 bool GetDNP() const override { return m_DNP; }
83 void SetDNP( bool aDNP ) override { m_DNP = aDNP; }
84
85 std::vector<int> ViewGetLayers() const override;
86
87 bool IsFilledForHitTesting() const override
88 {
89 return false;
90 }
91
92 virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override;
93
94 virtual void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
95 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
96
97 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
98
101
105 static std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>>
106 UpdateRuleAreasInScreens( std::unordered_set<SCH_SCREEN*>& screens, KIGFX::SCH_VIEW* view );
107
109 const std::unordered_set<SCH_ITEM*>& GetContainedItems() const;
110
111 const std::unordered_set<KIID>& GetPastContainedItems() const;
112
114 const std::unordered_set<SCH_DIRECTIVE_LABEL*>& GetDirectives() const;
115
119 const std::vector<std::pair<wxString, SCH_ITEM*>> GetResolvedNetclasses() const;
120
122 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
123
124protected:
126 void addDirective( SCH_DIRECTIVE_LABEL* label );
127
129 void addContainedItem( SCH_ITEM* item );
130
132 void resetCaches();
133
134protected:
138 bool m_DNP;
139
141 std::unordered_set<SCH_ITEM*> m_items;
142 std::unordered_set<KIID> m_itemIDs;
143
145 std::unordered_set<SCH_DIRECTIVE_LABEL*> m_directives;
146 std::unordered_set<KIID> m_directiveIDs;
147
149 std::unordered_set<KIID> m_prev_items;
150
152 std::unordered_set<KIID> m_prev_directives;
153};
154
155#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:168
void SetLayer(SCH_LAYER_ID aLayer)
Definition: sch_item.h:314
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.
Definition: sch_rule_area.h:76
void SetExcludedFromSim(bool aExcludeFromSim) override
Set or clear the exclude from simulation flag.
Definition: sch_rule_area.h:64
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 SetDNP(bool aDNP) override
Definition: sch_rule_area.h:83
bool m_excludedFromBOM
bool m_DNP
True if symbol is set to 'Do Not Populate'.
bool GetExcludedFromSim() const override
Definition: sch_rule_area.h:65
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 m_excludedFromSim
bool GetExcludedFromBoard() const override
Definition: sch_rule_area.h:77
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
Definition: sch_rule_area.h:87
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 GetDNP() const override
Set or clear the 'Do Not Populate' flag.
Definition: sch_rule_area.h:82
bool GetExcludedFromBOM() const override
Definition: sch_rule_area.h:71
bool m_excludedFromBoard
void SetExcludedFromBOM(bool aExcludeFromBOM) override
Set or clear the exclude from schematic bill of materials flag.
Definition: sch_rule_area.h:70
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.
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()
Definition: sch_rule_area.h:53
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.
SHAPE_T
Definition: eda_shape.h:43
FILL_T
Definition: eda_shape.h:56
@ LAYER_RULE_AREAS
Definition: layer_ids.h:455
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ SCH_RULE_AREA_T
Definition: typeinfo.h:171