KiCad PCB EDA Suite
Loading...
Searching...
No Matches
multichannel_tool.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 TOOLS_MULTICHANNEL_TOOL_H
25#define TOOLS_MULTICHANNEL_TOOL_H
26
27#include <vector>
28#include <set>
29#include <unordered_map>
30#include <unordered_set>
31
32#include <tools/pcb_tool_base.h>
35
36#include <pad.h>
37#include <footprint.h>
38#include <reporter.h>
39#include <zone_settings.h>
40
42{
43 INSIDE = 0,
45 CLIP
46};
47
49{
50 bool m_copyRouting = true;
52 bool m_copyPlacement = true;
53 bool m_copyOtherItems = true;
54 bool m_groupItems = false;
57 bool m_keepOldRouting = false;
60 REPEAT_LAYOUT_EDGE_MODE m_edgeMode = REPEAT_LAYOUT_EDGE_MODE::INSIDE;
61};
62
63
64struct RULE_AREA;
65
67{
68 RULE_AREA* m_refArea = nullptr;
69 bool m_isOk = false;
70 bool m_doCopy = false;
71 wxString m_errorMsg;
73 std::unordered_set<BOARD_ITEM*> m_affectedItems;
74 std::unordered_set<BOARD_ITEM*> m_groupableItems;
75};
76
78{
79 PLACEMENT_SOURCE_T m_sourceType = PLACEMENT_SOURCE_T::SHEETNAME;
80 ZONE* m_oldArea = nullptr;
81 ZONE* m_area = nullptr;
82 std::set<FOOTPRINT*> m_raFootprints;
83 std::set<FOOTPRINT*> m_components;
84 bool m_existsAlready = false;
85 bool m_generateEnabled = false;
86 wxString m_sheetPath;
87 wxString m_sheetName;
88 wxString m_ruleName;
91 wxString m_groupName;
93};
94
95
97{
98 bool m_generateEnabled = false;
99 wxString m_sheetPath;
100 wxString m_sheetName;
101};
102
103
105{
106 bool m_replaceExisting = false;
107 RULE_AREA* m_refRA = nullptr;
109
110 std::vector<RULE_AREA> m_areas;
111 std::unordered_map<RULE_AREA*, RULE_AREA_COMPAT_DATA> m_compatMap;
112};
113
114
116{
117public:
120
121 void UpdatePickedPoint( const std::optional<VECTOR2I>& aPoint ) override {};
122 void UpdatePickedItem( const EDA_ITEM* aItem ) override;
123
125 int AutogenerateRuleAreas( const TOOL_EVENT& aEvent );
126 int RepeatLayout( const TOOL_EVENT& aEvent, ZONE* aRefZone );
129 int CheckRACompatibility( ZONE *aRefZone );
130
131private:
132 void setTransitions() override;
133 int repeatLayout( const TOOL_EVENT& aEvent );
134
135 wxString stripComponentIndex( const wxString& aRef ) const;
136 bool identifyComponentsInRuleArea( ZONE* aRuleArea, std::set<FOOTPRINT*>& aComponents );
137 bool findOtherItemsInRuleArea( ZONE* aRuleArea, std::set<BOARD_ITEM*>& aItems );
138 const SHAPE_LINE_CHAIN buildRAOutline( std::set<FOOTPRINT*>& aFootprints, int aMargin );
139 std::set<FOOTPRINT*> queryComponentsInSheet( wxString aSheetName ) const;
140 std::set<FOOTPRINT*>
141 queryComponentsInComponentClass( const wxString& aComponentClassName ) const;
142 std::set<FOOTPRINT*> queryComponentsInGroup( const wxString& aGroupName ) const;
143 RULE_AREA* findRAByName( const wxString& aName );
144 bool resolveConnectionTopology( RULE_AREA* aRefArea, RULE_AREA* aTargetArea,
145 RULE_AREA_COMPAT_DATA& aMatches );
146 bool copyRuleAreaContents( TMATCH::COMPONENT_MATCHES& aMatches, BOARD_COMMIT* aCommit, RULE_AREA* aRefArea,
147 RULE_AREA* aTargetArea, REPEAT_LAYOUT_OPTIONS aOpts, std::unordered_set<BOARD_ITEM*>& aAffectedItems,
148 std::unordered_set<BOARD_ITEM*>& aGroupableItems );
149 int findRouting( std::set<BOARD_CONNECTED_ITEM*>& aOutput, std::shared_ptr<CONNECTIVITY_DATA> aConnectivity,
150 const SHAPE_POLY_SET& aRAPoly, RULE_AREA* aRA,
151 const REPEAT_LAYOUT_OPTIONS& aOpts ) const;
153 TMATCH::COMPONENT_MATCHES& aComponentMatches );
154
155 bool pruneExistingGroups( COMMIT& aCommit, const std::unordered_set<BOARD_ITEM*>& aItemsToCheck );
156
157 std::unique_ptr<REPORTER> m_reporter;
159};
160
161
162#endif // TOOLS_MULTICHANNEL_TOOL
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition: commit.h:73
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:97
Definition: kiid.h:49
int CheckRACompatibility(ZONE *aRefZone)
std::set< FOOTPRINT * > queryComponentsInSheet(wxString aSheetName) const
std::unique_ptr< REPORTER > m_reporter
int repeatLayout(const TOOL_EVENT &aEvent)
void UpdatePickedItem(const EDA_ITEM *aItem) override
int findRouting(std::set< BOARD_CONNECTED_ITEM * > &aOutput, std::shared_ptr< CONNECTIVITY_DATA > aConnectivity, const SHAPE_POLY_SET &aRAPoly, RULE_AREA *aRA, const REPEAT_LAYOUT_OPTIONS &aOpts) const
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
const SHAPE_LINE_CHAIN buildRAOutline(std::set< FOOTPRINT * > &aFootprints, int aMargin)
RULE_AREAS_DATA * GetData()
wxString stripComponentIndex(const wxString &aRef) const
bool resolveConnectionTopology(RULE_AREA *aRefArea, RULE_AREA *aTargetArea, RULE_AREA_COMPAT_DATA &aMatches)
RULE_AREAS_DATA m_areas
bool pruneExistingGroups(COMMIT &aCommit, const std::unordered_set< BOARD_ITEM * > &aItemsToCheck)
int RepeatLayout(const TOOL_EVENT &aEvent, ZONE *aRefZone)
int AutogenerateRuleAreas(const TOOL_EVENT &aEvent)
bool identifyComponentsInRuleArea(ZONE *aRuleArea, std::set< FOOTPRINT * > &aComponents)
void fixupNet(BOARD_CONNECTED_ITEM *aRef, BOARD_CONNECTED_ITEM *aTarget, TMATCH::COMPONENT_MATCHES &aComponentMatches)
Attempts to make sure copied items are assigned the right net.
std::set< FOOTPRINT * > queryComponentsInComponentClass(const wxString &aComponentClassName) const
void UpdatePickedPoint(const std::optional< VECTOR2I > &aPoint) override
RULE_AREA * findRAByName(const wxString &aName)
std::set< FOOTPRINT * > queryComponentsInGroup(const wxString &aGroupName) const
bool copyRuleAreaContents(TMATCH::COMPONENT_MATCHES &aMatches, BOARD_COMMIT *aCommit, RULE_AREA *aRefArea, RULE_AREA *aTargetArea, REPEAT_LAYOUT_OPTIONS aOpts, std::unordered_set< BOARD_ITEM * > &aAffectedItems, std::unordered_set< BOARD_ITEM * > &aGroupableItems)
bool findOtherItemsInRuleArea(ZONE *aRuleArea, std::set< BOARD_ITEM * > &aItems)
Interface class for something that receives picked points or items from this tool.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
Generic, UI-independent tool event.
Definition: tool_event.h:168
Handle a list of polygons defining a copper zone.
Definition: zone.h:74
REPEAT_LAYOUT_EDGE_MODE
std::map< FOOTPRINT *, FOOTPRINT * > COMPONENT_MATCHES
Definition: topo_match.h:149
wxString m_sheetName
wxString m_sheetPath
bool m_generateEnabled
REPEAT_LAYOUT_EDGE_MODE m_edgeMode
std::unordered_map< RULE_AREA *, RULE_AREA_COMPAT_DATA > m_compatMap
REPEAT_LAYOUT_OPTIONS m_options
std::vector< RULE_AREA > m_areas
std::unordered_set< BOARD_ITEM * > m_affectedItems
TMATCH::COMPONENT_MATCHES m_matchingComponents
std::unordered_set< BOARD_ITEM * > m_groupableItems
VECTOR2I m_center
wxString m_sheetName
PLACEMENT_SOURCE_T m_sourceType
wxString m_componentClass
bool m_existsAlready
std::set< FOOTPRINT * > m_raFootprints
ZONE * m_oldArea
std::set< FOOTPRINT * > m_components
wxString m_ruleName
wxString m_groupName
wxString m_sheetPath
bool m_generateEnabled
Class ZONE_SETTINGS used to handle zones parameters in dialogs.
PLACEMENT_SOURCE_T
Definition: zone_settings.h:75