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 (C) 2017-2021 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>
34
35#include <pad.h>
36#include <footprint.h>
37#include <reporter.h>
38#include <zone_settings.h>
39
41{
42 INSIDE = 0,
44 CLIP
45};
46
48{
49 bool m_copyRouting = true;
50 bool m_copyPlacement = true;
51 bool m_groupItems = false;
54 bool m_keepOldRouting = false;
56 REPEAT_LAYOUT_EDGE_MODE m_edgeMode = REPEAT_LAYOUT_EDGE_MODE::INSIDE;
57};
58
59
60struct RULE_AREA;
61
63{
64 RULE_AREA* m_refArea = nullptr;
65 bool m_isOk = false;
66 bool m_doCopy = false;
67 wxString m_errorMsg;
69};
70
72{
73 RULE_AREA_PLACEMENT_SOURCE_TYPE m_sourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME;
74 ZONE* m_oldArea = nullptr;
75 ZONE* m_area = nullptr;
76 std::set<FOOTPRINT*> m_raFootprints;
77 std::set<FOOTPRINT*> m_components;
78 bool m_existsAlready = false;
79 bool m_generateEnabled = false;
80 wxString m_sheetPath;
81 wxString m_sheetName;
82 wxString m_ruleName;
85};
86
87
89{
90 bool m_generateEnabled = false;
91 wxString m_sheetPath;
92 wxString m_sheetName;
93};
94
95
97{
98 bool m_replaceExisting = false;
99 RULE_AREA* m_refRA = nullptr;
101
102 std::vector<RULE_AREA> m_areas;
103 std::unordered_map<RULE_AREA*, RULE_AREA_COMPAT_DATA> m_compatMap;
104};
105
106
108{
109public:
112
114 int AutogenerateRuleAreas( const TOOL_EVENT& aEvent );
115 int RepeatLayout( const TOOL_EVENT& aEvent, ZONE* aRefZone );
118 int CheckRACompatibility( ZONE *aRefZone );
119
120private:
121 void setTransitions() override;
122 int repeatLayout( const TOOL_EVENT& aEvent );
123
124 wxString stripComponentIndex( wxString aRef ) const;
125 bool identifyComponentsInRuleArea( ZONE* aRuleArea, std::set<FOOTPRINT*>& aComponents );
126 const SHAPE_LINE_CHAIN buildRAOutline( std::set<FOOTPRINT*>& aFootprints, int aMargin );
127 std::set<FOOTPRINT*> queryComponentsInSheet( wxString aSheetName ) const;
128 std::set<FOOTPRINT*>
129 queryComponentsInComponentClass( const wxString& aComponentClassName ) const;
130 RULE_AREA* findRAByName( const wxString& aName );
131 bool resolveConnectionTopology( RULE_AREA* aRefArea, RULE_AREA* aTargetArea,
132 RULE_AREA_COMPAT_DATA& aMatches );
133 bool copyRuleAreaContents( TMATCH::COMPONENT_MATCHES& aMatches, BOARD_COMMIT* aCommit, RULE_AREA* aRefArea,
134 RULE_AREA* aTargetArea, REPEAT_LAYOUT_OPTIONS aOpts, std::unordered_set<BOARD_ITEM*>& aAffectedItems,
135 std::unordered_set<BOARD_ITEM*>& aGroupableItems );
136 int findRoutedConnections( std::set<BOARD_ITEM*>& aOutput,
137 std::shared_ptr<CONNECTIVITY_DATA> aConnectivity,
138 const SHAPE_POLY_SET& aRAPoly, RULE_AREA* aRA, FOOTPRINT* aFp,
139 const REPEAT_LAYOUT_OPTIONS& aOpts ) const;
140
141 bool pruneExistingGroups( COMMIT& aCommit, const std::unordered_set<BOARD_ITEM*>& aItemsToCheck );
142
143 std::unique_ptr<REPORTER> m_reporter;
145};
146
147
148#endif // TOOLS_MULTICHANNEL_TOOL
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition: commit.h:74
int CheckRACompatibility(ZONE *aRefZone)
std::set< FOOTPRINT * > queryComponentsInSheet(wxString aSheetName) const
std::unique_ptr< REPORTER > m_reporter
int findRoutedConnections(std::set< BOARD_ITEM * > &aOutput, std::shared_ptr< CONNECTIVITY_DATA > aConnectivity, const SHAPE_POLY_SET &aRAPoly, RULE_AREA *aRA, FOOTPRINT *aFp, const REPEAT_LAYOUT_OPTIONS &aOpts) const
int repeatLayout(const TOOL_EVENT &aEvent)
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)
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)
wxString stripComponentIndex(wxString aRef) const
std::set< FOOTPRINT * > queryComponentsInComponentClass(const wxString &aComponentClassName) const
RULE_AREA * findRAByName(const wxString &aName)
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)
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:73
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
RULE_AREA * m_refRA
REPEAT_LAYOUT_OPTIONS m_options
std::vector< RULE_AREA > m_areas
TMATCH::COMPONENT_MATCHES m_matchingComponents
VECTOR2I m_center
RULE_AREA_PLACEMENT_SOURCE_TYPE m_sourceType
wxString m_sheetName
wxString m_componentClass
bool m_existsAlready
std::set< FOOTPRINT * > m_raFootprints
ZONE * m_oldArea
std::set< FOOTPRINT * > m_components
wxString m_ruleName
wxString m_sheetPath
bool m_generateEnabled
Class ZONE_SETTINGS used to handle zones parameters in dialogs.
RULE_AREA_PLACEMENT_SOURCE_TYPE
Definition: zone_settings.h:66