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 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;
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 bool m_existsAlready = false;
74 bool m_generateEnabled = false;
75 wxString m_sheetPath;
76 wxString m_sheetName;
77 wxString m_ruleName;
79 wxString m_groupName;
81};
82
83
85{
86 bool m_replaceExisting = false;
87 RULE_AREA* m_refRA = nullptr;
89
90 std::vector<RULE_AREA> m_areas;
91 std::unordered_map<RULE_AREA*, RULE_AREA_COMPAT_DATA> m_compatMap;
92};
93
94
96{
97public:
100
101 int RepeatLayout( const TOOL_EVENT& aEvent, ZONE* aRefZone );
102 int RepeatLayout( const TOOL_EVENT& aEvent, RULE_AREA& aRefArea, RULE_AREA& aTargetArea );
103 int AutogenerateRuleAreas( const TOOL_EVENT& aEvent );
104
105 void UpdatePickedPoint( const std::optional<VECTOR2I>& aPoint ) override {};
106 void UpdatePickedItem( const EDA_ITEM* aItem ) override;
107
109
112 int CheckRACompatibility( ZONE* aRefZone );
113
114private:
115 void setTransitions() override;
116 int repeatLayout( const TOOL_EVENT& aEvent );
117
118 wxString stripComponentIndex( const wxString& aRef ) const;
119
120 bool findComponentsInRuleArea( RULE_AREA* aRuleArea, std::set<FOOTPRINT*>& aComponents );
121 bool findOtherItemsInRuleArea( RULE_AREA* aRuleArea, std::set<BOARD_ITEM*>& aItems );
122 int findRoutingInRuleArea( RULE_AREA* aRuleArea, std::set<BOARD_CONNECTED_ITEM*>& aOutput,
123 std::shared_ptr<CONNECTIVITY_DATA> aConnectivity, const SHAPE_POLY_SET& aRAPoly,
124 const REPEAT_LAYOUT_OPTIONS& aOpts ) const;
125 bool copyRuleAreaContents( RULE_AREA* aRefArea, RULE_AREA* aTargetArea,
126 BOARD_COMMIT* aCommit, REPEAT_LAYOUT_OPTIONS aOpts,
127 RULE_AREA_COMPAT_DATA& aCompatData );
128
129 const SHAPE_LINE_CHAIN buildRAOutline( std::set<FOOTPRINT*>& aFootprints, int aMargin );
130
131 std::set<FOOTPRINT*> queryComponentsInSheet( wxString aSheetName ) const;
132 std::set<FOOTPRINT*> queryComponentsInComponentClass( const wxString& aComponentClassName ) const;
133 std::set<FOOTPRINT*> queryComponentsInGroup( const wxString& aGroupName ) const;
134
135 RULE_AREA* findRAByName( const wxString& aName );
136 bool resolveConnectionTopology( RULE_AREA* aRefArea, RULE_AREA* aTargetArea,
137 RULE_AREA_COMPAT_DATA& aMatches );
139 TMATCH::COMPONENT_MATCHES& aComponentMatches );
140 bool pruneExistingGroups( COMMIT& aCommit, const std::unordered_set<BOARD_ITEM*>& aItemsToCheck );
141
142 std::unique_ptr<REPORTER> m_reporter;
144};
145
146
147#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:72
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
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()
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
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)
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
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:171
Handle a list of polygons defining a copper zone.
Definition zone.h:74
std::map< FOOTPRINT *, FOOTPRINT * > COMPONENT_MATCHES
Definition topo_match.h:149
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
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
wxString m_groupName
wxString m_sheetPath
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
Class ZONE_SETTINGS used to handle zones parameters in dialogs.
PLACEMENT_SOURCE_T