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;
39
41{
42 bool m_copyRouting = true;
44 bool m_copyPlacement = true;
45 bool m_copyOtherItems = true;
46 bool m_groupItems = false;
49};
50
51struct RULE_AREA;
52
54{
55 bool m_isOk = false;
56 bool m_doCopy = false;
57 wxString m_errorMsg;
59 std::vector<wxString> m_mismatchReasons;
61 std::unordered_set<BOARD_ITEM*> m_affectedItems;
63 std::unordered_set<BOARD_ITEM*> m_groupableItems;
64};
65
67{
69 ZONE* m_oldZone = nullptr;
70 ZONE* m_zone = nullptr;
71 std::set<FOOTPRINT*> m_components;
72 std::unordered_set<EDA_ITEM*> m_designBlockItems;
73 PCB_GROUP* m_group = nullptr;
74 bool m_existsAlready = false;
75 bool m_generateEnabled = false;
76 wxString m_sheetPath;
77 wxString m_sheetName;
78 wxString m_ruleName;
80 wxString m_groupName;
82};
83
84
86{
87 bool m_replaceExisting = false;
88 RULE_AREA* m_refRA = nullptr;
90
91 std::vector<RULE_AREA> m_areas;
92 std::unordered_map<RULE_AREA*, RULE_AREA_COMPAT_DATA> m_compatMap;
93};
94
95
97{
98public:
101
102 int RepeatLayout( const TOOL_EVENT& aEvent, ZONE* aRefZone );
103 int RepeatLayout( const TOOL_EVENT& aEvent, RULE_AREA& aRefArea, RULE_AREA& aTargetArea,
104 REPEAT_LAYOUT_OPTIONS& aOptions, BOARD_COMMIT* aExternalCommit = nullptr,
105 wxString* aErrorOut = nullptr );
106 int AutogenerateRuleAreas( const TOOL_EVENT& aEvent );
107
108 void UpdatePickedPoint( const std::optional<VECTOR2I>& aPoint ) override {};
109 void UpdatePickedItem( const EDA_ITEM* aItem ) override;
110
111 void ShowMismatchDetails( wxWindow* aParent, const wxString& aSummary,
112 const std::vector<wxString>& aReasons ) const;
113
115
118 int CheckRACompatibility( ZONE* aRefZone );
119
120private:
121 void setTransitions() override;
122 int repeatLayout( const TOOL_EVENT& aEvent );
123
124 wxString stripComponentIndex( const wxString& aRef ) const;
125
126 bool findComponentsInRuleArea( RULE_AREA* aRuleArea, std::set<FOOTPRINT*>& aComponents );
127 bool findOtherItemsInRuleArea( RULE_AREA* aRuleArea, std::set<BOARD_ITEM*>& aItems );
128 int findRoutingInRuleArea( RULE_AREA* aRuleArea, std::set<BOARD_CONNECTED_ITEM*>& aOutput,
129 std::shared_ptr<CONNECTIVITY_DATA> aConnectivity, const SHAPE_POLY_SET& aRAPoly,
130 const REPEAT_LAYOUT_OPTIONS& aOpts ) const;
131 bool copyRuleAreaContents( RULE_AREA* aRefArea, RULE_AREA* aTargetArea,
132 BOARD_COMMIT* aCommit, REPEAT_LAYOUT_OPTIONS aOpts,
133 RULE_AREA_COMPAT_DATA& aCompatData );
134
135 const SHAPE_LINE_CHAIN buildRAOutline( std::set<FOOTPRINT*>& aFootprints, int aMargin );
136 const SHAPE_LINE_CHAIN buildRAOutline( const std::set<BOARD_ITEM*>& aItems, int aMargin );
137
138 std::set<FOOTPRINT*> queryComponentsInSheet( wxString aSheetName ) const;
139 std::set<FOOTPRINT*> queryComponentsInComponentClass( const wxString& aComponentClassName ) const;
140 std::set<FOOTPRINT*> queryComponentsInGroup( const wxString& aGroupName ) const;
141 std::set<BOARD_ITEM*> queryBoardItemsInGroup( const wxString& aGroupName ) const;
142
143 RULE_AREA* findRAByName( const wxString& aName );
144 bool resolveConnectionTopology( RULE_AREA* aRefArea, RULE_AREA* aTargetArea,
145 RULE_AREA_COMPAT_DATA& aMatches,
146 const TMATCH::ISOMORPHISM_PARAMS& aParams = {} );
147 void fixupNet( BOARD_CONNECTED_ITEM* aRef, BOARD_CONNECTED_ITEM* aTarget,
148 TMATCH::COMPONENT_MATCHES& aComponentMatches );
149 bool pruneExistingGroups( COMMIT& aCommit, const std::unordered_set<BOARD_ITEM*>& aItemsToCheck );
150
151 std::unique_ptr<REPORTER> m_reporter;
153};
154
155
156#endif // TOOLS_MULTICHANNEL_TOOL
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
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
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