KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_line_wire_bus_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) 2019 CERN
5 * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef SCH_LINE_WIRE_BUS_TOOL_H
26#define SCH_LINE_WIRE_BUS_TOOL_H
27
28#include <wx/string.h>
29#include <string>
30#include <vector>
31
32#include <math/vector2d.h>
33#include <sch_edit_frame.h>
34#include <sch_line.h>
35
36#include <ee_tool_base.h>
37
38class TOOL_EVENT;
39
41class SCH_LABEL;
42class SCH_EDIT_FRAME;
44
45
48{
50 bool flipX;
51 bool flipY;
53
55 wxString net_name;
56
59};
60
61
63{
67};
68
73class SCH_LINE_WIRE_BUS_TOOL : public EE_TOOL_BASE<SCH_EDIT_FRAME>
74{
75public:
78
80 bool Init() override;
81
82 int DrawSegments( const TOOL_EVENT& aEvent );
83 int UnfoldBus( const TOOL_EVENT& aEvent );
84
85 // SELECTION_CONDITIONs:
86 static bool IsDrawingLineWireOrBus( const SELECTION& aSelection );
87
91 int AddJunctionsIfNeeded( SCH_COMMIT* aCommit, EE_SELECTION* aSelection );
92
96 int TrimOverLappingWires( SCH_COMMIT* aCommit, EE_SELECTION* aSelection );
97
98private:
99 int doDrawSegments( const TOOL_EVENT& aTool, int aType, bool aQuitOnDraw );
100
101 SCH_LINE* startSegments( int aType, const VECTOR2D& aPos, SCH_LINE* aSegment = nullptr );
102
103 SCH_LINE* doUnfoldBus( const wxString& aNet, const VECTOR2I& aPos = VECTOR2I( 0, 0 ) );
104
105 void finishSegments();
106
111 void simplifyWireList();
112
114 void setTransitions() override;
115
122 const SCH_SHEET_PIN* getSheetPin( const VECTOR2I& aPosition );
123
135 void computeBreakPoint( const std::pair<SCH_LINE*, SCH_LINE*>& aSegments, VECTOR2I& aPosition,
136 LINE_MODE mode, bool posture );
137
138private:
139 bool m_inDrawingTool; // Reentrancy guard
140
142 std::vector<SCH_LINE*> m_wires; // Lines being drawn
143};
144
145#endif /* SCH_LINE_WIRE_BUS_TOOL_H */
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:48
Class for a wire to bus entry.
Schematic editor (Eeschema) main window.
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.)
void computeBreakPoint(const std::pair< SCH_LINE *, SCH_LINE * > &aSegments, VECTOR2I &aPosition, LINE_MODE mode, bool posture)
Compute the middle coordinate for 2 segments from the start point to aPosition with the segments kept...
int DrawSegments(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int AddJunctionsIfNeeded(SCH_COMMIT *aCommit, EE_SELECTION *aSelection)
Handle the addition of junctions to a selection of objects.
int UnfoldBus(const TOOL_EVENT &aEvent)
int doDrawSegments(const TOOL_EVENT &aTool, int aType, bool aQuitOnDraw)
bool Init() override
Init() is called once upon a registration of the tool.
const SCH_SHEET_PIN * getSheetPin(const VECTOR2I &aPosition)
Search for a sheet pin at a location.
std::vector< SCH_LINE * > m_wires
int TrimOverLappingWires(SCH_COMMIT *aCommit, EE_SELECTION *aSelection)
Logic to remove wires when overlapping correct items.
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
SCH_LINE * doUnfoldBus(const wxString &aNet, const VECTOR2I &aPos=VECTOR2I(0, 0))
SCH_LINE * startSegments(int aType, const VECTOR2D &aPos, SCH_LINE *aSegment=nullptr)
void simplifyWireList()
Iterate over the wire list and removes the null segments and overlapping segments to create a simplif...
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
Generic, UI-independent tool event.
Definition: tool_event.h:167
LINE_MODE
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:353
Collection of data related to the bus unfolding tool.
bool label_placed
True if user has placed the net label.
wxString net_name
Net label for the unfolding operation.
bool flipY
True if the bus entry should be flipped in the y-axis.
SCH_BUS_WIRE_ENTRY * entry
bool flipX
True if the bus entry should be flipped in the x-axis.
VECTOR2I origin
Origin (on the bus) of the unfold.
bool in_progress
True if bus unfold operation is running.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588