KiCad PCB EDA Suite
ZONE_CREATE_HELPER Class Reference

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. More...

#include <zone_create_helper.h>

Inheritance diagram for ZONE_CREATE_HELPER:
POLYGON_GEOM_MANAGER::CLIENT

Classes

struct  PARAMS
 Parameters used to fully describe a zone creation process. More...
 

Public Member Functions

 ZONE_CREATE_HELPER (DRAWING_TOOL &aTool, PARAMS &aParams)
 
virtual ~ZONE_CREATE_HELPER ()
 
ZONEGetZone () const
 
void OnGeometryChange (const POLYGON_GEOM_MANAGER &aMgr) override
 Called when the polygon is complete. More...
 
bool OnFirstPoint (POLYGON_GEOM_MANAGER &aMgr) override
 Called before the first point is added - clients can do initialization here, and can veto the start of the process (e.g. More...
 
void OnComplete (const POLYGON_GEOM_MANAGER &aMgr) override
 
std::unique_ptr< ZONEcreateNewZone (bool aKeepout)
 Prompt the user for new zone settings, and create a new zone with those settings. More...
 
std::unique_ptr< ZONEcreateZoneFromExisting (const ZONE &aSrcZone)
 Create a new zone with the settings from an existing zone. More...
 
void performZoneCutout (ZONE &aZone, const ZONE &aCutout)
 Cut one zone out of another one (i.e. More...
 
void commitZone (std::unique_ptr< ZONE > aZone)
 Commit the current zone-in-progress to the BOARD. More...
 

Private Attributes

DRAWING_TOOLm_tool
 Parameters of the zone to be drawn. More...
 
PARAMSm_params
 The preview item to display. More...
 
KIGFX::PREVIEW::POLYGON_ITEM m_previewItem
 view that show the preview item More...
 
KIGFX::VIEWm_parentView
 The zone-in-progress. More...
 
std::unique_ptr< ZONEm_zone
 

Detailed Description

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.

Definition at line 42 of file zone_create_helper.h.

Constructor & Destructor Documentation

◆ ZONE_CREATE_HELPER()

ZONE_CREATE_HELPER::ZONE_CREATE_HELPER ( DRAWING_TOOL aTool,
PARAMS aParams 
)
Parameters
aToolthe DRAWING_TOOL to provide the zone tool to.
aParamsthe parameters to use to guide the zone creation.

Definition at line 40 of file zone_create_helper.cpp.

40 :
41 m_tool( aTool ),
42 m_params( aParams ),
43 m_parentView( *aTool.getView() )
44{
46}
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
PARAMS & m_params
The preview item to display.
KIGFX::PREVIEW::POLYGON_ITEM m_previewItem
view that show the preview item
KIGFX::VIEW & m_parentView
The zone-in-progress.
DRAWING_TOOL & m_tool
Parameters of the zone to be drawn.

References KIGFX::VIEW::Add(), m_parentView, and m_previewItem.

◆ ~ZONE_CREATE_HELPER()

ZONE_CREATE_HELPER::~ZONE_CREATE_HELPER ( )
virtual

Definition at line 49 of file zone_create_helper.cpp.

50{
51 // remove the preview from the view
54}
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:346
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1512

References m_parentView, m_previewItem, KIGFX::VIEW::Remove(), and KIGFX::VIEW::SetVisible().

Member Function Documentation

◆ commitZone()

void ZONE_CREATE_HELPER::commitZone ( std::unique_ptr< ZONE aZone)

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.

Parameters
aZoneis the drawn zone outline to commit.

Definition at line 191 of file zone_create_helper.cpp.

192{
193 switch ( m_params.m_mode )
194 {
196 // For cutouts, subtract from the source
198 break;
199
200 case ZONE_MODE::ADD:
202 {
203 BOARD_COMMIT commit( &m_tool );
204
205 aZone->HatchBorder();
206
207 commit.Add( aZone.get() );
208 commit.Push( _( "Add a zone" ) );
209
210 m_tool.GetManager()->RunAction( PCB_ACTIONS::selectItem, true, aZone.release() );
211 break;
212 }
213
215 {
216 BOARD_COMMIT commit( &m_tool );
217 BOARD* board = m_tool.getModel<BOARD>();
219 PCB_SHAPE* poly;
220
222 poly = new FP_SHAPE( static_cast<FOOTPRINT*>( m_tool.m_frame->GetModel() ) );
223 else
224 poly = new PCB_SHAPE();
225
226 poly->SetShape( SHAPE_T::POLY );
227
228 if( layer == Edge_Cuts || layer == F_CrtYd || layer == B_CrtYd )
229 poly->SetFilled( false );
230 else
231 poly->SetFilled( true );
232
235 poly->SetLayer( layer );
236 poly->SetPolyShape( *aZone->Outline() );
237
238 commit.Add( poly );
240
241 commit.Push( _( "Add a graphical polygon" ) );
242
243 break;
244 }
245 }
246}
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:198
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:240
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:615
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:281
void SetFilled(bool aFlag)
Definition: eda_shape.h:94
void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition: eda_shape.h:250
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:109
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: pcb_actions.h:62
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: pcb_shape.h:84
bool m_isFootprintEditor
Simple container to manage line stroke parameters.
Definition: stroke_params.h:87
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143
T * getModel() const
Return the model object if it matches the requested type.
Definition: tool_base.h:196
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
void performZoneCutout(ZONE &aZone, const ZONE &aCutout)
Cut one zone out of another one (i.e.
#define _(s)
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ F_CrtYd
Definition: layer_ids.h:117
@ Edge_Cuts
Definition: layer_ids.h:113
@ B_CrtYd
Definition: layer_ids.h:116
@ SIMILAR
Add a new zone with the same settings as an existing one.
@ CUTOUT
Make a cutout to an existing zone.
@ ADD
Add a new zone/keepout with fresh settings.
ZONE_MODE m_mode
Zone settings source (for similar and cutout zones)
ZONE * m_sourceZone
Zone leader mode.
PCB_LAYER_ID m_layer
The zone mode to operate in.

References _, COMMIT::Add(), ADD, B_CrtYd, CUTOUT, Edge_Cuts, F_CrtYd, BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetLineThickness(), TOOL_BASE::GetManager(), TOOL_BASE::getModel(), PCB_BASE_FRAME::GetModel(), GRAPHIC_POLYGON, DRAWING_TOOL::m_frame, PCB_TOOL_BASE::m_isFootprintEditor, ZONE_CREATE_HELPER::PARAMS::m_layer, ZONE_CREATE_HELPER::PARAMS::m_mode, m_params, ZONE_CREATE_HELPER::PARAMS::m_sourceZone, m_tool, performZoneCutout(), POLY, BOARD_COMMIT::Push(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectItem, EDA_SHAPE::SetFilled(), BOARD_ITEM::SetLayer(), EDA_SHAPE::SetPolyShape(), EDA_SHAPE::SetShape(), PCB_SHAPE::SetStroke(), SIMILAR, and SOLID.

Referenced by OnComplete().

◆ createNewZone()

std::unique_ptr< ZONE > ZONE_CREATE_HELPER::createNewZone ( bool  aKeepout)

Prompt the user for new zone settings, and create a new zone with those settings.

Parameters
aKeepoutshould the zone be a keepout
Returns
the new zone, can be null if the user aborted

Definition at line 57 of file zone_create_helper.cpp.

58{
60 BOARD* board = frame->GetBoard();
63 std::set<int> highlightedNets = board->GetHighLightNetCodes();
64
65 // Get the current default settings for zones
66 ZONE_SETTINGS zoneInfo = frame->GetZoneSettings();
67 zoneInfo.m_Layers.reset().set( m_params.m_layer ); // TODO(JE) multilayer defaults?
68 zoneInfo.m_NetcodeSelection = highlightedNets.empty() ? -1 : *highlightedNets.begin();
70
71 // If we don't have a net from highlighting, maybe we can get one from the selection
73
74 if( selectionTool && !selectionTool->GetSelection().Empty()
75 && zoneInfo.m_NetcodeSelection == -1 )
76 {
77 EDA_ITEM* item = *selectionTool->GetSelection().GetItems().begin();
78
79 if( BOARD_CONNECTED_ITEM* bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
80 zoneInfo.m_NetcodeSelection = bci->GetNetCode();
81 }
82
84 {
85 // Get the current default settings for zones
86
87 // Show options dialog
88 int dialogResult;
89
91 dialogResult = InvokeRuleAreaEditor( frame, &zoneInfo );
92 else
93 {
94 // TODO(JE) combine these dialogs?
95 if( ( zoneInfo.m_Layers & LSET::AllCuMask() ).any() )
96 dialogResult = InvokeCopperZonesEditor( frame, &zoneInfo );
97 else
98 dialogResult = InvokeNonCopperZonesEditor( frame, &zoneInfo );
99 }
100
101 if( dialogResult == wxID_CANCEL )
102 return nullptr;
103
104 controls->WarpMouseCursor( controls->GetCursorPosition(), true );
105 }
106
107 // The new zone is a ZONE if created in the board editor and a FP_ZONE if created in the
108 // footprint editor
109 wxASSERT( !m_tool.m_isFootprintEditor || ( parent->Type() == PCB_FOOTPRINT_T ) );
110
111 std::unique_ptr<ZONE> newZone = m_tool.m_isFootprintEditor ?
112 std::make_unique<FP_ZONE>( parent ) :
113 std::make_unique<ZONE>( parent );
114
115 // Apply the selected settings
116 zoneInfo.ExportSetting( *newZone );
117
118 return newZone;
119}
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
Common, abstract interface for edit frames.
const ZONE_SETTINGS & GetZoneSettings() const
BOARD * GetBoard() const
The selection tool: currently supports:
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:109
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:98
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition: tool_base.h:184
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:287
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:70
void SetIsRuleArea(bool aEnable)
int m_NetcodeSelection
Definition: zone_settings.h:95
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
Handle a list of polygons defining a copper zone.
Definition: zone.h:58
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aZoneSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
Definition: bitmap.cpp:64
bool m_keepout
< Should create a keepout zone?
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:88

References LSET::AllCuMask(), SELECTION::Empty(), ZONE_SETTINGS::ExportSetting(), PCB_BASE_FRAME::GetBoard(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getEditFrame(), SELECTION::GetItems(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), PCB_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), TOOL_MANAGER::GetViewControls(), PCB_BASE_FRAME::GetZoneSettings(), GRAPHIC_POLYGON, InvokeCopperZonesEditor(), InvokeNonCopperZonesEditor(), InvokeRuleAreaEditor(), DRAWING_TOOL::m_frame, PCB_TOOL_BASE::m_isFootprintEditor, ZONE_CREATE_HELPER::PARAMS::m_keepout, ZONE_CREATE_HELPER::PARAMS::m_layer, ZONE_SETTINGS::m_Layers, ZONE_CREATE_HELPER::PARAMS::m_mode, ZONE_SETTINGS::m_NetcodeSelection, m_params, m_tool, PCB_FOOTPRINT_T, ZONE_SETTINGS::SetIsRuleArea(), EDA_ITEM::Type(), and KIGFX::VIEW_CONTROLS::WarpMouseCursor().

Referenced by OnFirstPoint().

◆ createZoneFromExisting()

std::unique_ptr< ZONE > ZONE_CREATE_HELPER::createZoneFromExisting ( const ZONE aSrcZone)

Create a new zone with the settings from an existing zone.

Parameters
aSrcZonethe zone to copy settings from
Returns
the new zone

Definition at line 122 of file zone_create_helper.cpp.

123{
124 BOARD* board = m_tool.getModel<BOARD>();
125
126 std::unique_ptr<ZONE> newZone = std::make_unique<ZONE>( board );
127
128 ZONE_SETTINGS zoneSettings;
129 zoneSettings << aSrcZone;
130
131 zoneSettings.ExportSetting( *newZone );
132
133 return newZone;
134}

References ZONE_SETTINGS::ExportSetting(), TOOL_BASE::getModel(), and m_tool.

Referenced by OnFirstPoint().

◆ GetZone()

ZONE * ZONE_CREATE_HELPER::GetZone ( ) const
inline

Definition at line 74 of file zone_create_helper.h.

74{ return m_zone.get(); }
std::unique_ptr< ZONE > m_zone

References m_zone.

Referenced by DRAWING_TOOL::DrawZone().

◆ OnComplete()

void ZONE_CREATE_HELPER::OnComplete ( const POLYGON_GEOM_MANAGER aMgr)
overridevirtual

Implements POLYGON_GEOM_MANAGER::CLIENT.

Definition at line 290 of file zone_create_helper.cpp.

291{
292 auto& finalPoints = aMgr.GetLockedInPoints();
293
294 if( finalPoints.PointCount() < 3 )
295 {
296 // just scrap the zone in progress
297 m_zone = nullptr;
298 }
299 else
300 {
301 // if m_params.m_mode == DRAWING_TOOL::ZONE_MODE::CUTOUT, m_zone
302 // will be merged to the existing zone as a new hole.
303 m_zone->Outline()->NewOutline();
304 auto* outline = m_zone->Outline();
305
306 for( int i = 0; i < finalPoints.PointCount(); ++i )
307 outline->Append( finalPoints.CPoint( i ) );
308
309 // In DEG45 mode, we may have intermediate points in the leader that should be
310 // included as they are shown in the preview. These typically maintain the
311 // 45 constraint
313 {
314 const auto& pts = aMgr.GetLeaderLinePoints();
315 for( int i = 1; i < pts.PointCount(); i++ )
316 outline->Append( pts.CPoint( i ) );
317 }
318
319 outline->Outline( 0 ).SetClosed( true );
320 outline->RemoveNullSegments();
321 outline->Simplify( SHAPE_POLY_SET::PM_FAST );
322
323 // hand the zone over to the committer
324 commitZone( std::move( m_zone ) );
325 m_zone = nullptr;
326 }
327
329}
const SHAPE_LINE_CHAIN & GetLockedInPoints() const
Get the "locked-in" points that describe the polygon itself.
LEADER_MODE GetLeaderMode() const
const SHAPE_LINE_CHAIN & GetLeaderLinePoints() const
Get the points comprising the leader line (the line from the last locked-in point to the current curs...
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
void commitZone(std::unique_ptr< ZONE > aZone)
Commit the current zone-in-progress to the BOARD.

References SHAPE_LINE_CHAIN::Append(), commitZone(), POLYGON_GEOM_MANAGER::DEG45, POLYGON_GEOM_MANAGER::GetLeaderLinePoints(), POLYGON_GEOM_MANAGER::GetLeaderMode(), POLYGON_GEOM_MANAGER::GetLockedInPoints(), m_parentView, m_previewItem, m_zone, SHAPE_POLY_SET::PM_FAST, and KIGFX::VIEW::SetVisible().

◆ OnFirstPoint()

bool ZONE_CREATE_HELPER::OnFirstPoint ( POLYGON_GEOM_MANAGER aMgr)
overridevirtual

Called before the first point is added - clients can do initialization here, and can veto the start of the process (e.g.

if user cancels a dialog)

Returns
false to veto start of new polygon Sent when the polygon geometry changes

Implements POLYGON_GEOM_MANAGER::CLIENT.

Definition at line 249 of file zone_create_helper.cpp.

250{
251 // if we don't have a zone, create one
252 // the user's choice here can affect things like the colour of the preview
253 if( !m_zone )
254 {
257 else
259
260 if( m_zone )
261 {
263
264 // set up properties from zone
265 const auto& settings = *m_parentView.GetPainter()->GetSettings();
266 COLOR4D color = settings.GetColor( nullptr, m_zone->GetFirstLayer() );
267
269 m_previewItem.SetFillColor( color.WithAlpha( 0.2 ) );
270
272
275 }
276 }
277
278 return m_zone != nullptr;
279}
int color
Definition: DXF_plotter.cpp:57
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
void SetFillColor(const COLOR4D &aNewColor)
Set the line width to set before drawing preview.
void SetStrokeColor(const COLOR4D &aNewColor)
Set the fill color to set before drawing preview.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual bool Is45Limited() const
Should the tool use its 45° mode option?
@ DIRECT
Unconstrained point-to-point.
void SetLeaderMode(LEADER_MODE aMode)
Set the leader mode to use when calculating the leader/returner lines.
std::unique_ptr< ZONE > createNewZone(bool aKeepout)
Prompt the user for new zone settings, and create a new zone with those settings.
std::unique_ptr< ZONE > createZoneFromExisting(const ZONE &aSrcZone)
Create a new zone with the settings from an existing zone.
@ WHITE
Definition: color4d.h:48

References color, createNewZone(), createZoneFromExisting(), POLYGON_GEOM_MANAGER::DEG45, POLYGON_GEOM_MANAGER::DIRECT, TOOL_BASE::GetManager(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), PCB_TOOL_BASE::Is45Limited(), ZONE_CREATE_HELPER::PARAMS::m_keepout, m_params, m_parentView, m_previewItem, ZONE_CREATE_HELPER::PARAMS::m_sourceZone, m_tool, m_zone, TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, KIGFX::PREVIEW::SIMPLE_OVERLAY_ITEM::SetFillColor(), POLYGON_GEOM_MANAGER::SetLeaderMode(), KIGFX::PREVIEW::SIMPLE_OVERLAY_ITEM::SetStrokeColor(), KIGFX::VIEW::SetVisible(), and WHITE.

◆ OnGeometryChange()

void ZONE_CREATE_HELPER::OnGeometryChange ( const POLYGON_GEOM_MANAGER aMgr)
overridevirtual

Called when the polygon is complete.

Implements POLYGON_GEOM_MANAGER::CLIENT.

Definition at line 282 of file zone_create_helper.cpp.

283{
284 // send the points to the preview item
287}
void SetPoints(const SHAPE_LINE_CHAIN &aLockedInPts, const SHAPE_LINE_CHAIN &aLeaderPts)
Set the polygon points.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1574
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:49

References KIGFX::GEOMETRY, POLYGON_GEOM_MANAGER::GetLeaderLinePoints(), POLYGON_GEOM_MANAGER::GetLockedInPoints(), m_parentView, m_previewItem, KIGFX::PREVIEW::POLYGON_ITEM::SetPoints(), and KIGFX::VIEW::Update().

Referenced by DRAWING_TOOL::DrawZone().

◆ performZoneCutout()

void ZONE_CREATE_HELPER::performZoneCutout ( ZONE aZone,
const ZONE aCutout 
)

Cut one zone out of another one (i.e.

subtraction) and update the zone..

Parameters
aZonethe zone to removed area from
aCutoutthe area to remove

Definition at line 137 of file zone_create_helper.cpp.

138{
139 BOARD_COMMIT commit( &m_tool );
140 std::vector<ZONE*> newZones;
141
142 // Clear the selection before removing the old zone
143 auto toolMgr = m_tool.GetManager();
144 toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
145
146 SHAPE_POLY_SET originalOutline( *aZone.Outline() );
147 originalOutline.BooleanSubtract( *aCutout.Outline(), SHAPE_POLY_SET::PM_FAST );
148
149 // After substracting the hole, originalOutline can have more than one
150 // main outline.
151 // But a zone can have only one main outline, so create as many zones as
152 // originalOutline contains main outlines:
153 for( int outline = 0; outline < originalOutline.OutlineCount(); outline++ )
154 {
155 auto newZoneOutline = new SHAPE_POLY_SET;
156 newZoneOutline->AddOutline( originalOutline.Outline( outline ) );
157
158 // Add holes (if any) to thez new zone outline:
159 for (int hole = 0; hole < originalOutline.HoleCount( outline ) ; hole++ )
160 newZoneOutline->AddHole( originalOutline.CHole( outline, hole ) );
161
162 auto newZone = new ZONE( aZone );
163 newZone->SetOutline( newZoneOutline );
164 newZone->SetLocalFlags( 1 );
165 newZone->HatchBorder();
166 newZone->UnFill();
167 newZones.push_back( newZone );
168 commit.Add( newZone );
169 }
170
171 commit.Remove( &aZone );
172
173 // TODO Refill zones when KiCad supports auto re-fill
174
175 commit.Push( _( "Add a zone cutout" ) );
176
177 // Select the new zone and set it as the source for the next cutout
178 if( newZones.empty() )
179 {
180 m_params.m_sourceZone = nullptr;
181 }
182 else
183 {
184 m_params.m_sourceZone = newZones[0];
185 toolMgr->RunAction( PCB_ACTIONS::selectItem, true, newZones[0] );
186 }
187
188}
Represent a set of closed polygons.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
SHAPE_POLY_SET * Outline()
Definition: zone.h:327

References _, COMMIT::Add(), SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::BooleanSubtract(), SHAPE_POLY_SET::CHole(), TOOL_BASE::GetManager(), SHAPE_POLY_SET::HoleCount(), m_params, ZONE_CREATE_HELPER::PARAMS::m_sourceZone, m_tool, ZONE::Outline(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::PM_FAST, BOARD_COMMIT::Push(), COMMIT::Remove(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, and PCB_ACTIONS::selectItem.

Referenced by commitZone().

Member Data Documentation

◆ m_params

PARAMS& ZONE_CREATE_HELPER::m_params
private

The preview item to display.

Definition at line 123 of file zone_create_helper.h.

Referenced by commitZone(), createNewZone(), OnFirstPoint(), and performZoneCutout().

◆ m_parentView

KIGFX::VIEW& ZONE_CREATE_HELPER::m_parentView
private

The zone-in-progress.

Definition at line 129 of file zone_create_helper.h.

Referenced by OnComplete(), OnFirstPoint(), OnGeometryChange(), ZONE_CREATE_HELPER(), and ~ZONE_CREATE_HELPER().

◆ m_previewItem

KIGFX::PREVIEW::POLYGON_ITEM ZONE_CREATE_HELPER::m_previewItem
private

view that show the preview item

Definition at line 126 of file zone_create_helper.h.

Referenced by OnComplete(), OnFirstPoint(), OnGeometryChange(), ZONE_CREATE_HELPER(), and ~ZONE_CREATE_HELPER().

◆ m_tool

DRAWING_TOOL& ZONE_CREATE_HELPER::m_tool
private

Parameters of the zone to be drawn.

Definition at line 120 of file zone_create_helper.h.

Referenced by commitZone(), createNewZone(), createZoneFromExisting(), OnFirstPoint(), and performZoneCutout().

◆ m_zone

std::unique_ptr<ZONE> ZONE_CREATE_HELPER::m_zone
private

Definition at line 132 of file zone_create_helper.h.

Referenced by GetZone(), OnComplete(), and OnFirstPoint().


The documentation for this class was generated from the following files: