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 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 
44 {
45 public:
46 
50  struct PARAMS
51  {
53  bool m_keepout;
54 
57 
60  };
61 
66  ZONE_CREATE_HELPER( DRAWING_TOOL& aTool, const PARAMS& aParams );
67 
69 
70  /*
71  * Interface for receiving POLYGON_GEOM_MANAGER update
72  */
73 
74  void OnGeometryChange( const POLYGON_GEOM_MANAGER& aMgr ) override;
75 
76  bool OnFirstPoint() override;
77 
78  void OnComplete( const POLYGON_GEOM_MANAGER& aMgr ) override;
79 
89  std::unique_ptr<ZONE_CONTAINER> createNewZone( bool aKeepout );
90 
99  std::unique_ptr<ZONE_CONTAINER> createZoneFromExisting( const ZONE_CONTAINER& aSrcZone );
100 
110  void performZoneCutout( ZONE_CONTAINER& aExistingZone, ZONE_CONTAINER& aCutout );
111 
119  void commitZone( std::unique_ptr<ZONE_CONTAINER> aZone );
120 
121 private:
122 
124 
126  const PARAMS& m_params;
127 
130 
133 
135  std::unique_ptr<ZONE_CONTAINER> m_zone;
136 };
137 
138 #endif /* __DRAWING_TOOL_H */
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
std::unique_ptr< ZONE_CONTAINER > createZoneFromExisting(const ZONE_CONTAINER &aSrcZone)
Function createZoneFromExisting.
void OnComplete(const POLYGON_GEOM_MANAGER &aMgr) override
Called when the polygon is complete
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
void commitZone(std::unique_ptr< ZONE_CONTAINER > aZone)
Commit the current zone-in-progress to the BOARD.
std::unique_ptr< ZONE_CONTAINER > m_zone
The zone-in-progress
KIGFX::PREVIEW::POLYGON_ITEM m_previewItem
The preview item to display
Parameters used to fully describe a zone creation process.
void performZoneCutout(ZONE_CONTAINER &aExistingZone, ZONE_CONTAINER &aCutout)
Function performZoneCutout()
"Listener" interface for a class that wants to be updated about polygon geometry changes ...
Class DRAWING_TOOL.
Definition: drawing_tool.h:49
ZONE_CONTAINER * m_sourceZone
Zone settings source (for similar and cutout zones)
KIGFX::VIEW & m_parentView
view that show the preview item
DRAWING_TOOL::ZONE_MODE m_mode
The zone mode to operate in
ZONE_CREATE_HELPER(DRAWING_TOOL &aTool, const PARAMS &aParams)
const PARAMS & m_params
Parameters of the zone to be drawn
void OnGeometryChange(const POLYGON_GEOM_MANAGER &aMgr) override
Sent when the polygon geometry changes
std::unique_ptr< ZONE_CONTAINER > createNewZone(bool aKeepout)
Function createNewZone()
Class POLYGON_ITEM.
Definition: polygon_item.h:46
This class is an adjuct helper to the DRAWING_TOOL interactive tool, which handles incoming geometry ...
bool OnFirstPoint() override
Called before the first point is added - clients can do initialisation here, and can veto the start o...
Class VIEW.
Definition: view.h:58
bool m_keepout
Should create a keepout zone?
Class that handles the drawing of a polygon, including management of last corner deletion and drawing...