KiCad PCB EDA Suite
convert_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) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
5  * @author Jon Evans <[email protected]>
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 CONVERT_TOOL_H_
26 #define CONVERT_TOOL_H_
27 
29 #include <tool/tool_interactive.h>
30 
31 class CONDITIONAL_MENU;
32 class PCB_SELECTION_TOOL;
33 class PCB_BASE_FRAME;
34 
35 
37 {
38 public:
39  CONVERT_TOOL();
40  virtual ~CONVERT_TOOL();
41 
43  void Reset( RESET_REASON aReason ) override {}
44 
46  bool Init() override;
47 
51  int CreatePolys( const TOOL_EVENT& aEvent );
52 
56  int CreateLines( const TOOL_EVENT& aEvent );
57 
61  int SegmentToArc( const TOOL_EVENT& aEvent );
62 
64  void setTransitions() override;
65 
66 private:
73  static OPT<SEG> getStartEndPoints( EDA_ITEM* aItem, int* aWidth );
74 
85  static SHAPE_POLY_SET makePolysFromSegs( const std::deque<EDA_ITEM*>& aItems );
86 
93  static SHAPE_POLY_SET makePolysFromRects( const std::deque<EDA_ITEM*>& aItems );
94 
101  static SHAPE_POLY_SET makePolysFromCircles( const std::deque<EDA_ITEM*>& aItems );
102 
107  static SHAPE_POLY_SET extractPolygons( const std::deque<EDA_ITEM*>& aItems );
108 
112 };
113 
114 #endif
static OPT< SEG > getStartEndPoints(EDA_ITEM *aItem, int *aWidth)
Retrieve the start and end points for a generic item.
static SHAPE_POLY_SET makePolysFromCircles(const std::deque< EDA_ITEM * > &aItems)
Try to make polygons from circles.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Definition: convert_tool.h:43
PCB_SELECTION_TOOL * m_selectionTool
Definition: convert_tool.h:109
static SHAPE_POLY_SET makePolysFromRects(const std::deque< EDA_ITEM * > &aItems)
Try to make polygons from rectangles.
int CreatePolys(const TOOL_EVENT &aEvent)
Convert selected lines to a polygon, if possible.
virtual ~CONVERT_TOOL()
Represent a set of closed polygons.
Generic, UI-independent tool event.
Definition: tool_event.h:152
PCB_BASE_FRAME * m_frame
Definition: convert_tool.h:111
CONDITIONAL_MENU * m_menu
Definition: convert_tool.h:110
bool Init() override
Init() is called once upon a registration of the tool.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:77
boost::optional< T > OPT
Definition: optional.h:7
int CreateLines(const TOOL_EVENT &aEvent)
Convert selected polygon-like object to graphic lines, if possible.
static SHAPE_POLY_SET makePolysFromSegs(const std::deque< EDA_ITEM * > &aItems)
Try to make polygons from segments in the selected items.
static SHAPE_POLY_SET extractPolygons(const std::deque< EDA_ITEM * > &aItems)
For any polygon shapes (zones, keepouts, graphic polys) in aItems, extracts the polygon outlines into...
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
int SegmentToArc(const TOOL_EVENT &aEvent)
Convert selected segment (graphic or track) to an arc of the same type.