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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef TOOLS_MULTICHANNEL_TOOL_H
21#define TOOLS_MULTICHANNEL_TOOL_H
22
23#include <vector>
24#include <set>
25#include <unordered_map>
26#include <unordered_set>
27
28#include <tools/pcb_tool_base.h>
31
32#include <reporter.h>
33#include <zone_settings.h>
34
35class wxWindow;
36class EDA_ITEM;
37class FOOTPRINT;
38class PCB_GROUP;
39class NETINFO_ITEM;
40
42{
43 bool m_copyRouting = true;
45 bool m_copyPlacement = true;
46 bool m_copyOtherItems = true;
47 bool m_groupItems = false;
50};
51
52struct RULE_AREA;
53
55{
56 bool m_isOk = false;
57 bool m_doCopy = false;
58 wxString m_errorMsg;
60 std::vector<wxString> m_mismatchReasons;
62 std::unordered_set<BOARD_ITEM*> m_affectedItems;
64 std::unordered_set<BOARD_ITEM*> m_groupableItems;
65};
66
68{
70 ZONE* m_oldZone = nullptr;
71 ZONE* m_zone = nullptr;
72 std::set<FOOTPRINT*> m_components;
73 std::unordered_set<EDA_ITEM*> m_designBlockItems;
74 PCB_GROUP* m_group = nullptr;
75 bool m_existsAlready = false;
76 bool m_generateEnabled = false;
77 wxString m_sheetPath;
78 wxString m_sheetName;
79 wxString m_ruleName;
81 wxString m_groupName;
83};
84
85
87{
88 bool m_replaceExisting = false;
89 RULE_AREA* m_refRA = nullptr;
91
92 std::vector<RULE_AREA> m_areas;
93 std::unordered_map<RULE_AREA*, RULE_AREA_COMPAT_DATA> m_compatMap;
94};
95
96
98{
99public:
102
103 int RepeatLayout( const TOOL_EVENT& aEvent, ZONE* aRefZone );
104 int RepeatLayout( const TOOL_EVENT& aEvent, RULE_AREA& aRefArea, RULE_AREA& aTargetArea,
105 REPEAT_LAYOUT_OPTIONS& aOptions, BOARD_COMMIT* aExternalCommit = nullptr,
106 wxString* aErrorOut = nullptr );
107 int AutogenerateRuleAreas( const TOOL_EVENT& aEvent );
108
109 void UpdatePickedPoint( const std::optional<VECTOR2I>& aPoint ) override {};
110 void UpdatePickedItem( const EDA_ITEM* aItem ) override;
111
112 void ShowMismatchDetails( wxWindow* aParent, const wxString& aSummary,
113 const std::vector<wxString>& aReasons ) const;
114
116
119 int CheckRACompatibility( ZONE* aRefZone );
120
127 static std::vector<NETINFO_ITEM*> IsolateDesignBlockAutoNets( BOARD* aBoard,
128 const std::set<FOOTPRINT*>& aFootprints,
129 const std::unordered_set<EDA_ITEM*>& aItems );
130
131private:
132 void setTransitions() override;
133 int repeatLayout( const TOOL_EVENT& aEvent );
134
135 wxString stripComponentIndex( const wxString& aRef ) const;
136
137 bool findComponentsInRuleArea( RULE_AREA* aRuleArea, std::set<FOOTPRINT*>& aComponents );
138 bool findOtherItemsInRuleArea( RULE_AREA* aRuleArea, std::set<BOARD_ITEM*>& aItems );
139 int findRoutingInRuleArea( RULE_AREA* aRuleArea, std::set<BOARD_CONNECTED_ITEM*>& aOutput,
140 std::shared_ptr<CONNECTIVITY_DATA> aConnectivity, const SHAPE_POLY_SET& aRAPoly,
141 const REPEAT_LAYOUT_OPTIONS& aOpts ) const;
142 bool copyRuleAreaContents( RULE_AREA* aRefArea, RULE_AREA* aTargetArea,
143 BOARD_COMMIT* aCommit, REPEAT_LAYOUT_OPTIONS aOpts,
144 RULE_AREA_COMPAT_DATA& aCompatData );
145
146 const SHAPE_LINE_CHAIN buildRAOutline( std::set<FOOTPRINT*>& aFootprints, int aMargin );
147 const SHAPE_LINE_CHAIN buildRAOutline( const std::set<BOARD_ITEM*>& aItems, int aMargin );
148
149 std::set<FOOTPRINT*> queryComponentsInSheet( wxString aSheetName ) const;
150 std::set<FOOTPRINT*> queryComponentsInComponentClass( const wxString& aComponentClassName ) const;
151 std::set<FOOTPRINT*> queryComponentsInGroup( const wxString& aGroupName ) const;
152 std::set<BOARD_ITEM*> queryBoardItemsInGroup( const wxString& aGroupName ) const;
153
154 RULE_AREA* findRAByName( const wxString& aName );
155 bool resolveConnectionTopology( RULE_AREA* aRefArea, RULE_AREA* aTargetArea,
156 RULE_AREA_COMPAT_DATA& aMatches,
157 const TMATCH::ISOMORPHISM_PARAMS& aParams = {} );
158 void fixupNet( BOARD_CONNECTED_ITEM* aRef, BOARD_CONNECTED_ITEM* aTarget,
159 TMATCH::COMPONENT_MATCHES& aComponentMatches );
160 bool pruneExistingGroups( COMMIT& aCommit, const std::unordered_set<BOARD_ITEM*>& aItemsToCheck );
161
162 std::unique_ptr<REPORTER> m_reporter;
164};
165
166
167#endif // TOOLS_MULTICHANNEL_TOOL
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:373
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
int CheckRACompatibility(ZONE *aRefZone)
std::set< FOOTPRINT * > queryComponentsInSheet(wxString aSheetName) const
bool findOtherItemsInRuleArea(RULE_AREA *aRuleArea, std::set< BOARD_ITEM * > &aItems)
std::unique_ptr< REPORTER > m_reporter
int repeatLayout(const TOOL_EVENT &aEvent)
bool findComponentsInRuleArea(RULE_AREA *aRuleArea, std::set< FOOTPRINT * > &aComponents)
void UpdatePickedItem(const EDA_ITEM *aItem) override
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()
bool resolveConnectionTopology(RULE_AREA *aRefArea, RULE_AREA *aTargetArea, RULE_AREA_COMPAT_DATA &aMatches, const TMATCH::ISOMORPHISM_PARAMS &aParams={})
int findRoutingInRuleArea(RULE_AREA *aRuleArea, std::set< BOARD_CONNECTED_ITEM * > &aOutput, std::shared_ptr< CONNECTIVITY_DATA > aConnectivity, const SHAPE_POLY_SET &aRAPoly, const REPEAT_LAYOUT_OPTIONS &aOpts) const
wxString stripComponentIndex(const wxString &aRef) const
static std::vector< NETINFO_ITEM * > IsolateDesignBlockAutoNets(BOARD *aBoard, const std::set< FOOTPRINT * > &aFootprints, const std::unordered_set< EDA_ITEM * > &aItems)
Remap auto-generated nets (Net-(...), unconnected-...) of a design block that was appended for layout...
RULE_AREAS_DATA m_areas
bool pruneExistingGroups(COMMIT &aCommit, const std::unordered_set< BOARD_ITEM * > &aItemsToCheck)
void ShowMismatchDetails(wxWindow *aParent, const wxString &aSummary, const std::vector< wxString > &aReasons) const
int RepeatLayout(const TOOL_EVENT &aEvent, ZONE *aRefZone)
int AutogenerateRuleAreas(const TOOL_EVENT &aEvent)
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.
bool copyRuleAreaContents(RULE_AREA *aRefArea, RULE_AREA *aTargetArea, BOARD_COMMIT *aCommit, REPEAT_LAYOUT_OPTIONS aOpts, RULE_AREA_COMPAT_DATA &aCompatData)
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
std::set< BOARD_ITEM * > queryBoardItemsInGroup(const wxString &aGroupName) const
Handle the data for a net.
Definition netinfo.h:46
A set of BOARD_ITEMs (i.e., without duplicates).
Definition pcb_group.h:49
Interface class for something that receives picked points or items from this tool.
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
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:167
Handle a list of polygons defining a copper zone.
Definition zone.h:70
std::map< FOOTPRINT *, FOOTPRINT * > COMPONENT_MATCHES
Definition topo_match.h:180
std::unordered_map< RULE_AREA *, RULE_AREA_COMPAT_DATA > m_compatMap
REPEAT_LAYOUT_OPTIONS m_options
std::vector< RULE_AREA > m_areas
std::vector< wxString > m_mismatchReasons
std::unordered_set< BOARD_ITEM * > m_affectedItems
Filled in by copyRuleAreaContents with items that were affected by the copy operation.
TMATCH::COMPONENT_MATCHES m_matchingComponents
std::unordered_set< BOARD_ITEM * > m_groupableItems
Filled in by copyRuleAreaContents with affected items that can be grouped together.
VECTOR2I m_center
std::unordered_set< EDA_ITEM * > m_designBlockItems
wxString m_sheetName
PLACEMENT_SOURCE_T m_sourceType
wxString m_componentClass
std::set< FOOTPRINT * > m_components
wxString m_ruleName
PCB_GROUP * m_group
wxString m_groupName
wxString m_sheetPath
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
Class ZONE_SETTINGS used to handle zones parameters in dialogs.
PLACEMENT_SOURCE_T