KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2022 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 <tools/pcb_tool_base.h>
30#include <pcbnew_settings.h>
31
34class PCB_BASE_FRAME;
35
36
38{
39public:
41 virtual ~CONVERT_TOOL();
42
44 void Reset( RESET_REASON aReason ) override {}
45
47 bool Init() override;
48
52 int CreatePolys( const TOOL_EVENT& aEvent );
53
57 int CreateLines( const TOOL_EVENT& aEvent );
58
62 int SegmentToArc( const TOOL_EVENT& aEvent );
63
67 int OutsetItems( const TOOL_EVENT& aEvent );
68
70 void setTransitions() override;
71
72private:
79 static std::optional<SEG> getStartEndPoints( EDA_ITEM* aItem );
80
91 SHAPE_POLY_SET makePolysFromChainedSegs( const std::deque<EDA_ITEM*>& aItems,
92 CONVERT_STRATEGY aStrategy );
93
100 SHAPE_POLY_SET makePolysFromOpenGraphics( const std::deque<EDA_ITEM*>& aItems, int aGap );
101 SHAPE_POLY_SET makePolysFromClosedGraphics( const std::deque<EDA_ITEM*>& aItems,
102 CONVERT_STRATEGY aStrategy );
103
107 void initUserSettings();
108
109private:
114};
115
116#endif
int CreateLines(const TOOL_EVENT &aEvent)
Convert selected polygon-like object to graphic lines, if possible.
bool Init() override
Init() is called once upon a registration of the tool.
int SegmentToArc(const TOOL_EVENT &aEvent)
Convert selected segment (graphic or track) to an arc of the same type.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Definition: convert_tool.h:44
void initUserSettings()
Initialize the user settings for the tool.
SHAPE_POLY_SET makePolysFromChainedSegs(const std::deque< EDA_ITEM * > &aItems, CONVERT_STRATEGY aStrategy)
Try to make polygons from chained segments in the selected items.
SHAPE_POLY_SET makePolysFromOpenGraphics(const std::deque< EDA_ITEM * > &aItems, int aGap)
Make polygons from graphic shapes and zones.
static std::optional< SEG > getStartEndPoints(EDA_ITEM *aItem)
Retrieve the start and end points for a generic item.
SHAPE_POLY_SET makePolysFromClosedGraphics(const std::deque< EDA_ITEM * > &aItems, CONVERT_STRATEGY aStrategy)
int CreatePolys(const TOOL_EVENT &aEvent)
Convert selected lines to a polygon, if possible.
PCB_SELECTION_TOOL * m_selectionTool
Definition: convert_tool.h:110
virtual ~CONVERT_TOOL()
CONVERT_SETTINGS m_userSettings
Definition: convert_tool.h:113
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
CONDITIONAL_MENU * m_menu
Definition: convert_tool.h:111
PCB_BASE_FRAME * m_frame
Definition: convert_tool.h:112
int OutsetItems(const TOOL_EVENT &aEvent)
Convert selected items to outset versions of themselves.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
The selection tool: currently supports:
Represent a set of closed polygons.
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
Generic, UI-independent tool event.
Definition: tool_event.h:167
CONVERT_STRATEGY