KiCad PCB EDA Suite
zone_create_helper.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) 2017-2021 Kicad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef TOOLS_ZONE_CREATE_HELPER__H_
25 #define TOOLS_ZONE_CREATE_HELPER__H_
26 
29 
30 #include <tools/drawing_tool.h>
31 
32 namespace KIGFX
33 {
34 class VIEW;
35 }
36 
43 {
44 public:
48  struct PARAMS
49  {
51  bool m_keepout;
52 
55 
58 
61 
64  };
65 
70  ZONE_CREATE_HELPER( DRAWING_TOOL& aTool, PARAMS& aParams );
71 
72  virtual ~ZONE_CREATE_HELPER();
73 
74  ZONE* GetZone() const { return m_zone.get(); }
75 
76  /*
77  * Interface for receiving #POLYGON_GEOM_MANAGER update
78  */
79  void OnGeometryChange( const POLYGON_GEOM_MANAGER& aMgr ) override;
80 
81  bool OnFirstPoint( POLYGON_GEOM_MANAGER& aMgr ) override;
82 
83  void OnComplete( const POLYGON_GEOM_MANAGER& aMgr ) override;
84 
91  std::unique_ptr<ZONE> createNewZone( bool aKeepout );
92 
99  std::unique_ptr<ZONE> createZoneFromExisting( const ZONE& aSrcZone );
100 
107  void performZoneCutout( ZONE& aZone, const ZONE& aCutout );
108 
117  void commitZone( std::unique_ptr<ZONE> aZone );
118 
119 private:
121 
124 
127 
130 
132  std::unique_ptr<ZONE> m_zone;
133 };
134 
135 #endif // TOOLS_ZONE_CREATE_HELPER__H_
void OnComplete(const POLYGON_GEOM_MANAGER &aMgr) override
LEADER_MODE
The kind of the leader line.
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:191
ZONE * m_sourceZone
Zone leader mode.
ZONE_CREATE_HELPER(DRAWING_TOOL &aTool, PARAMS &aParams)
DRAWING_TOOL & m_tool
Parameters of the zone to be drawn.
PCB_LAYER_ID m_layer
The zone mode to operate in.
KIGFX::PREVIEW::POLYGON_ITEM m_previewItem
view that show the preview item
Parameters used to fully describe a zone creation process.
PCB_LAYER_ID
A quick note on layer IDs:
"Listener" interface for a class that wants to be updated about polygon geometry changes
Tool responsible for drawing graphical elements like lines, arcs, circles, etc.
Definition: drawing_tool.h:50
KIGFX::VIEW & m_parentView
The zone-in-progress.
bool OnFirstPoint(POLYGON_GEOM_MANAGER &aMgr) override
Called before the first point is added - clients can do initialization here, and can veto the start o...
void commitZone(std::unique_ptr< ZONE > aZone)
Commit the current zone-in-progress to the BOARD.
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
void performZoneCutout(ZONE &aZone, const ZONE &aCutout)
Cut one zone out of another one (i.e.
ZONE_MODE
Definition: pcb_actions.h:33
PARAMS & m_params
The preview item to display.
void OnGeometryChange(const POLYGON_GEOM_MANAGER &aMgr) override
Called when the polygon is complete.
std::unique_ptr< ZONE > createZoneFromExisting(const ZONE &aSrcZone)
Create a new zone with the settings from an existing zone.
A preview item which shows an in-progress polygon, which can be used for zone outlines,...
Definition: polygon_item.h:44
std::unique_ptr< ZONE > m_zone
An adjunct helper to the DRAWING_TOOL interactive tool, which handles incoming geometry changes from ...
ZONE * GetZone() const
std::unique_ptr< ZONE > createNewZone(bool aKeepout)
Prompt the user for new zone settings, and create a new zone with those settings.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
POLYGON_GEOM_MANAGER::LEADER_MODE m_leaderMode
bool m_keepout
< Should create a keepout zone?
Class that handles the drawing of a polygon, including management of last corner deletion and drawing...
ZONE_MODE m_mode
Zone settings source (for similar and cutout zones)