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 (C) 2024 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:
44 SCH_SHAPE( SHAPE_T::POLY, LAYER_RULE_AREAS, 0 /* line width */, FILL_T::NO_FILL,
46 {
48 }
49
50 virtual ~SCH_RULE_AREA() {}
51
52 wxString GetClass() const override;
53
54 wxString GetFriendlyName() const override;
55
56 EDA_ITEM* Clone() const override;
57
58 void ViewGetLayers( int aLayers[], int& aCount ) const override;
59
60 virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override;
61
62 virtual void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
63 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
64
65 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
66
68 void ResetCaches( KIGFX::SCH_VIEW* view );
69
72 SCH_SCREEN* screen, KIGFX::SCH_VIEW* view,
73 std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>>& forceUpdateRuleAreas );
74
76 std::unordered_set<SCH_ITEM*> GetPastAndPresentContainedItems() const;
77
80 static std::vector<std::pair<SCH_RULE_AREA*, SCH_SCREEN*>>
81 UpdateRuleAreasInScreens( std::unordered_set<SCH_SCREEN*>& screens, KIGFX::SCH_VIEW* view );
82
84 const std::unordered_set<SCH_ITEM*>& GetContainedItems() const;
85
87 const std::unordered_set<SCH_DIRECTIVE_LABEL*> GetDirectives() const;
88
91 const std::vector<std::pair<wxString, SCH_ITEM*>> GetResolvedNetclasses() const;
92
95
97 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
98
99protected:
102
104 void clearDirectives( KIGFX::SCH_VIEW* view );
105
107 void addContainedItem( SCH_ITEM* item );
108
110 void clearContainedItems();
111
113 std::unordered_set<SCH_ITEM*> m_items;
114
116 std::unordered_set<SCH_DIRECTIVE_LABEL*> m_directives;
117
119 std::unordered_set<SCH_ITEM*> m_prev_items;
120
122 std::unordered_set<SCH_DIRECTIVE_LABEL*> m_prev_directives;
123};
124
125#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:88
Base plotter engine class.
Definition: plotter.h:104
Holds all the data relating to one schematic.
Definition: schematic.h:75
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:174
void SetLayer(SCH_LAYER_ID aLayer)
Definition: sch_item.h:290
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
Returns a set of all items contained within the rule area.
void ResetDirectivesAndItems(KIGFX::SCH_VIEW *view)
Clears and resets items and directives attached to this rule area.
void ResetCaches(KIGFX::SCH_VIEW *view)
Resets all item and directive caches, saving the current state first.
void addContainedItem(SCH_ITEM *item)
@briefs Adds an item to the list of items which this rule area affects
const std::unordered_set< SCH_DIRECTIVE_LABEL * > GetDirectives() const
Returns the set of all directive labels attached to the rule area border.
void addDirective(SCH_DIRECTIVE_LABEL *label, KIGFX::SCH_VIEW *view)
Adds a directive label which applies to items within ths rule area.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
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.
std::unordered_set< SCH_DIRECTIVE_LABEL * > m_directives
All SCH_DIRECTIVE_LABELs attached to the rule area border.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
std::unordered_set< SCH_ITEM * > m_prev_items
All SCH_ITEMs contained or intersecting the rule area in the previous update.
void RefreshContainedItemsAndDirectives(SCH_SCREEN *screen, KIGFX::SCH_VIEW *view, std::vector< std::pair< SCH_RULE_AREA *, SCH_SCREEN * > > &forceUpdateRuleAreas)
Refreshes the list of items which this rule area affects.
std::unordered_set< SCH_DIRECTIVE_LABEL * > m_prev_directives
All SCH_DIRECTIVE_LABELs attached to the rule area border in the previous update.
std::unordered_set< SCH_ITEM * > GetPastAndPresentContainedItems() const
Fetches all items which were, or are, within the rule area.
static std::vector< std::pair< SCH_RULE_AREA *, SCH_SCREEN * > > UpdateRuleAreasInScreens(std::unordered_set< SCH_SCREEN * > &screens, KIGFX::SCH_VIEW *view)
Updates all rule area connectvity / caches in the given sheet paths.
std::unordered_set< SCH_ITEM * > m_items
All SCH_ITEMs currently contained or intersecting the rule area.
const std::vector< std::pair< wxString, SCH_ITEM * > > GetResolvedNetclasses() const
Resolves the netclass of this rule area from connected directive labels.
virtual ~SCH_RULE_AREA()
Definition: sch_rule_area.h:50
void clearContainedItems()
Clears the list of items which this rule area affects.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
void clearDirectives(KIGFX::SCH_VIEW *view)
Clears the list of directives.
wxString GetClass() const override
Return the class name.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Gets the message panel info for the rule area.
SHAPE_T
Definition: eda_shape.h:42
FILL_T
Definition: eda_shape.h:55
@ LAYER_RULE_AREAS
Definition: layer_ids.h:369
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ SCH_RULE_AREA_T
Definition: typeinfo.h:170