2018-11-13 13:30:56 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-11-13 13:30:56 +00:00
|
|
|
* @author Jon Evans <jon@craftyjon.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CONVERT_TOOL_H_
|
|
|
|
#define CONVERT_TOOL_H_
|
|
|
|
|
2020-10-02 22:42:32 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
2018-11-13 13:30:56 +00:00
|
|
|
#include <tool/tool_interactive.h>
|
|
|
|
|
|
|
|
class CONDITIONAL_MENU;
|
2020-12-16 13:31:32 +00:00
|
|
|
class PCB_SELECTION_TOOL;
|
2018-11-13 13:30:56 +00:00
|
|
|
class PCB_BASE_FRAME;
|
|
|
|
|
|
|
|
|
|
|
|
class CONVERT_TOOL : public TOOL_INTERACTIVE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CONVERT_TOOL();
|
|
|
|
virtual ~CONVERT_TOOL();
|
|
|
|
|
|
|
|
/// @copydoc TOOL_INTERACTIVE::Reset()
|
|
|
|
void Reset( RESET_REASON aReason ) override {}
|
|
|
|
|
|
|
|
/// @copydoc TOOL_INTERACTIVE::Init()
|
|
|
|
bool Init() override;
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Convert selected lines to a polygon, if possible.
|
2018-11-13 13:30:56 +00:00
|
|
|
*/
|
|
|
|
int LinesToPoly( const TOOL_EVENT& aEvent );
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Convert selected polygon-like object to graphic lines, if possible.
|
2018-11-13 13:30:56 +00:00
|
|
|
*/
|
|
|
|
int PolyToLines( const TOOL_EVENT& aEvent );
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Convert selected segment (graphic or track) to an arc of the same type
|
2018-11-13 13:30:56 +00:00
|
|
|
*/
|
|
|
|
int SegmentToArc( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< @copydoc TOOL_INTERACTIVE::setTransitions()
|
2018-11-13 13:30:56 +00:00
|
|
|
void setTransitions() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Retrieve the start and end points for a generic item.
|
|
|
|
*
|
|
|
|
* @param aItem is an item that has a start and end point.
|
|
|
|
* @return a segment from start to end, or NULLOPT if invalid.
|
2018-11-13 13:30:56 +00:00
|
|
|
*/
|
|
|
|
static OPT<SEG> getStartEndPoints( EDA_ITEM* aItem );
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Try to make polygons from segments in the selected items.
|
|
|
|
*
|
2018-11-13 13:30:56 +00:00
|
|
|
* Polygons are formed from chains of lines/arcs. Each set containing two or more lines/arcs
|
2021-01-27 22:15:38 +00:00
|
|
|
* that are connected will be added to the return SHAPE_POLY_SET as an outline. No attempt
|
|
|
|
* is made to guess at holes.
|
|
|
|
*
|
|
|
|
* @param aItems is a list of items to process.
|
|
|
|
* @return a #SHAPE_POLY_SET containing any polygons that were created.
|
2018-11-13 13:30:56 +00:00
|
|
|
*/
|
|
|
|
static SHAPE_POLY_SET makePolysFromSegs( const std::deque<EDA_ITEM*>& aItems );
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Try to make polygons from rectangles.
|
|
|
|
*
|
|
|
|
* @param aItems is a list of rect shapes to process.
|
|
|
|
* @return a #SHAPE_POLY_SET containing any polygons that were created.
|
2018-11-13 13:30:56 +00:00
|
|
|
*/
|
|
|
|
static SHAPE_POLY_SET makePolysFromRects( const std::deque<EDA_ITEM*>& aItems );
|
|
|
|
|
2021-01-06 17:20:54 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Try to make polygons from circles.
|
|
|
|
*
|
|
|
|
* @param aItems is a list of circle shapes to process.
|
|
|
|
* @return a #SHAPE_POLY_SET containing any polygons that were created.
|
2021-01-06 17:20:54 +00:00
|
|
|
*/
|
|
|
|
static SHAPE_POLY_SET makePolysFromCircles( const std::deque<EDA_ITEM*>& aItems );
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
PCB_SELECTION_TOOL* m_selectionTool;
|
|
|
|
CONDITIONAL_MENU* m_menu;
|
|
|
|
PCB_BASE_FRAME* m_frame;
|
2018-11-13 13:30:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|