2017-02-26 17:45:52 +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) 2017-2021 Kicad Developers, see AUTHORS.txt for contributors.
|
2017-02-26 17:45:52 +00:00
|
|
|
*
|
|
|
|
* 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 TOOLS_ZONE_CREATE_HELPER__H_
|
|
|
|
#define TOOLS_ZONE_CREATE_HELPER__H_
|
|
|
|
|
|
|
|
#include <preview_items/polygon_geom_manager.h>
|
|
|
|
#include <preview_items/polygon_item.h>
|
|
|
|
|
|
|
|
#include <tools/drawing_tool.h>
|
|
|
|
|
|
|
|
namespace KIGFX
|
|
|
|
{
|
|
|
|
class VIEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* An adjunct helper to the DRAWING_TOOL interactive tool, which handles incoming geometry
|
|
|
|
* changes from a #POLYGON_GEOM_MANAGER and translates that into a ZONE based on given
|
|
|
|
* parameters.
|
2017-02-26 17:45:52 +00:00
|
|
|
*/
|
|
|
|
class ZONE_CREATE_HELPER : public POLYGON_GEOM_MANAGER::CLIENT
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Parameters used to fully describe a zone creation process
|
|
|
|
*/
|
|
|
|
struct PARAMS
|
|
|
|
{
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Should create a keepout zone?
|
2017-02-26 17:45:52 +00:00
|
|
|
bool m_keepout;
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Layer to begin drawing
|
2018-10-03 12:57:02 +00:00
|
|
|
PCB_LAYER_ID m_layer;
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< The zone mode to operate in
|
2019-06-24 15:27:05 +00:00
|
|
|
ZONE_MODE m_mode;
|
2017-02-26 17:45:52 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Zone settings source (for similar and cutout zones)
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE* m_sourceZone;
|
2019-10-20 16:27:44 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Zone leader mode
|
2019-10-20 16:27:44 +00:00
|
|
|
POLYGON_GEOM_MANAGER::LEADER_MODE m_leaderMode;
|
2017-02-26 17:45:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aTool the #DRAWING_TOOL to provide the zone tool to.
|
|
|
|
* @param aParams the parameters to use to guide the zone creation.
|
2017-02-26 17:45:52 +00:00
|
|
|
*/
|
2019-01-23 14:39:08 +00:00
|
|
|
ZONE_CREATE_HELPER( DRAWING_TOOL& aTool, PARAMS& aParams );
|
2017-02-26 17:45:52 +00:00
|
|
|
|
2020-02-05 22:19:14 +00:00
|
|
|
virtual ~ZONE_CREATE_HELPER();
|
2017-02-26 17:45:52 +00:00
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
ZONE* GetZone() const { return m_zone.get(); }
|
2020-09-17 21:29:40 +00:00
|
|
|
|
2017-02-26 17:45:52 +00:00
|
|
|
/*
|
2021-01-27 22:15:38 +00:00
|
|
|
* Interface for receiving #POLYGON_GEOM_MANAGER update
|
2017-02-26 17:45:52 +00:00
|
|
|
*/
|
|
|
|
void OnGeometryChange( const POLYGON_GEOM_MANAGER& aMgr ) override;
|
|
|
|
|
2018-02-20 14:51:40 +00:00
|
|
|
bool OnFirstPoint( POLYGON_GEOM_MANAGER& aMgr ) override;
|
2017-02-26 17:45:52 +00:00
|
|
|
|
|
|
|
void OnComplete( const POLYGON_GEOM_MANAGER& aMgr ) override;
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Prompt the user for new zone settings, and create a new zone with those settings.
|
2017-02-26 17:45:52 +00:00
|
|
|
*
|
|
|
|
* @param aKeepout should the zone be a keepout
|
|
|
|
* @return the new zone, can be null if the user aborted
|
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
std::unique_ptr<ZONE> createNewZone( bool aKeepout );
|
2017-02-26 17:45:52 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Create a new zone with the settings from an existing zone.
|
2017-02-26 17:45:52 +00:00
|
|
|
*
|
|
|
|
* @param aSrcZone the zone to copy settings from
|
|
|
|
* @return the new zone
|
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
std::unique_ptr<ZONE> createZoneFromExisting( const ZONE& aSrcZone );
|
2017-02-26 17:45:52 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Cut one zone out of another one (i.e. subtraction) and update the zone..
|
2017-02-26 17:45:52 +00:00
|
|
|
*
|
2018-05-25 14:56:04 +00:00
|
|
|
* @param aZone the zone to removed area from
|
2017-02-26 17:45:52 +00:00
|
|
|
* @param aCutout the area to remove
|
|
|
|
*/
|
2021-03-06 09:27:41 +00:00
|
|
|
void performZoneCutout( ZONE& aZone, const ZONE& aCutout );
|
2017-02-26 17:45:52 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Commit the current zone-in-progress to the BOARD.
|
|
|
|
*
|
|
|
|
* This might be adding a new zone, or modifying an existing zone with a cutout, depending
|
|
|
|
* on parameters.
|
2017-02-26 17:45:52 +00:00
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aZone is the drawn zone outline to commit.
|
2017-02-26 17:45:52 +00:00
|
|
|
*/
|
2020-11-11 23:05:59 +00:00
|
|
|
void commitZone( std::unique_ptr<ZONE> aZone );
|
2017-02-26 17:45:52 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DRAWING_TOOL& m_tool;
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Parameters of the zone to be drawn
|
2019-01-23 14:39:08 +00:00
|
|
|
PARAMS& m_params;
|
2017-02-26 17:45:52 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< The preview item to display
|
2017-02-26 17:45:52 +00:00
|
|
|
KIGFX::PREVIEW::POLYGON_ITEM m_previewItem;
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< view that show the preview item
|
2017-02-26 17:45:52 +00:00
|
|
|
KIGFX::VIEW& m_parentView;
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< The zone-in-progress
|
2020-11-11 23:05:59 +00:00
|
|
|
std::unique_ptr<ZONE> m_zone;
|
2017-02-26 17:45:52 +00:00
|
|
|
};
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
#endif // TOOLS_ZONE_CREATE_HELPER__H_
|