KiCad PCB EDA Suite
|
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>
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 () |
ZONE * | GetZone () const |
void | OnGeometryChange (const POLYGON_GEOM_MANAGER &aMgr) override |
Called when the polygon is complete. | |
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. | |
void | OnComplete (const POLYGON_GEOM_MANAGER &aMgr) override |
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. | |
void | performZoneCutout (ZONE &aZone, const ZONE &aCutout) |
Cut one zone out of another one (i.e. | |
void | commitZone (std::unique_ptr< ZONE > aZone) |
Commit the current zone-in-progress to the BOARD. | |
Private Member Functions | |
void | setUniquePriority (ZONE_SETTINGS &aZoneInfo) |
Choose a new priority for @aZoneInfo. | |
Private Attributes | |
DRAWING_TOOL & | m_tool |
Parameters of the zone to be drawn. | |
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. | |
std::unique_ptr< ZONE > | m_zone |
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.
ZONE_CREATE_HELPER::ZONE_CREATE_HELPER | ( | DRAWING_TOOL & | aTool, |
PARAMS & | aParams | ||
) |
aTool | the DRAWING_TOOL to provide the zone tool to. |
aParams | the parameters to use to guide the zone creation. |
Definition at line 38 of file zone_create_helper.cpp.
References KIGFX::VIEW::Add(), m_parentView, and m_previewItem.
|
virtual |
Definition at line 47 of file zone_create_helper.cpp.
References m_parentView, m_previewItem, KIGFX::VIEW::Remove(), and KIGFX::VIEW::SetVisible().
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.
aZone | is the drawn zone outline to commit. |
Definition at line 213 of file zone_create_helper.cpp.
References _, COMMIT::Add(), B_CrtYd, Edge_Cuts, F_CrtYd, BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetLineThickness(), TOOL_BASE::GetManager(), TOOL_BASE::getModel(), PCB_BASE_FRAME::GetModel(), DRAWING_TOOL::m_frame, ZONE_CREATE_HELPER::PARAMS::m_layer, ZONE_CREATE_HELPER::PARAMS::m_mode, m_params, ZONE_CREATE_HELPER::PARAMS::m_sourceZone, m_tool, performZoneCutout(), BOARD_COMMIT::Push(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectItem, EDA_SHAPE::SetFilled(), PCB_SHAPE::SetLayer(), EDA_SHAPE::SetPolyShape(), EDA_SHAPE::SetShape(), and PCB_SHAPE::SetStroke().
Referenced by OnComplete().
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.
aKeepout | should the zone be a keepout |
Definition at line 87 of file zone_create_helper.cpp.
References LSET::AllCuMask(), PCB_TOOL_BASE::board(), SELECTION::Empty(), ZONE_SETTINGS::ExportSetting(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), 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(), 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, BASE_SET::reset(), BASE_SET::set(), EDA_DRAW_PANEL_GAL::SetFocus(), ZONE_SETTINGS::SetIsRuleArea(), setUniquePriority(), EDA_ITEM::Type(), and KIGFX::VIEW_CONTROLS::WarpMouseCursor().
Referenced by OnFirstPoint().
Create a new zone with the settings from an existing zone.
aSrcZone | the zone to copy settings from |
Definition at line 149 of file zone_create_helper.cpp.
References ZONE_SETTINGS::ExportSetting(), TOOL_BASE::getModel(), and m_tool.
Referenced by OnFirstPoint().
|
inline |
Definition at line 74 of file zone_create_helper.h.
References m_zone.
Referenced by DRAWING_TOOL::DrawZone().
|
overridevirtual |
Implements POLYGON_GEOM_MANAGER::CLIENT.
Definition at line 310 of file zone_create_helper.cpp.
References SHAPE_LINE_CHAIN::Append(), commitZone(), SHAPE_LINE_CHAIN::CPoint(), POLYGON_GEOM_MANAGER::DEG45, POLYGON_GEOM_MANAGER::GetLeaderLinePoints(), POLYGON_GEOM_MANAGER::GetLeaderMode(), POLYGON_GEOM_MANAGER::GetLockedInPoints(), POLYGON_GEOM_MANAGER::GetLoopLinePoints(), SEG::LineDistance(), m_parentView, m_previewItem, m_zone, SHAPE_LINE_CHAIN::PointCount(), SHAPE_LINE_CHAIN::Remove(), SHAPE_LINE_CHAIN::SetClosed(), KIGFX::VIEW::SetVisible(), and SHAPE_LINE_CHAIN::Simplify().
|
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)
Implements POLYGON_GEOM_MANAGER::CLIENT.
Definition at line 261 of file zone_create_helper.cpp.
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(), and KIGFX::VIEW::SetVisible().
|
overridevirtual |
Called when the polygon is complete.
Implements POLYGON_GEOM_MANAGER::CLIENT.
Definition at line 293 of file zone_create_helper.cpp.
References KIGFX::GEOMETRY, POLYGON_GEOM_MANAGER::GetLeaderLinePoints(), POLYGON_GEOM_MANAGER::GetLockedInPoints(), POLYGON_GEOM_MANAGER::GetLoopLinePoints(), POLYGON_GEOM_MANAGER::IsPolygonInProgress(), m_parentView, m_previewItem, m_zone, KIGFX::PREVIEW::POLYGON_ITEM::SetPoints(), KIGFX::VIEW::SetVisible(), and KIGFX::VIEW::Update().
Referenced by DRAWING_TOOL::DrawZone().
Cut one zone out of another one (i.e.
subtraction) and update the zone..
aZone | the zone to removed area from |
aCutout | the area to remove |
Definition at line 164 of file zone_create_helper.cpp.
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().
|
private |
Choose a new priority for @aZoneInfo.
This will be the lowest unused zone priority number
aZoneInfo | ZONE_SETTINGS to apply the new priority number to |
Definition at line 55 of file zone_create_helper.cpp.
References LSET::AllCuMask(), PCB_BASE_FRAME::GetBoard(), TOOL_BASE::getEditFrame(), m_tool, and ZONE_SETTINGS::m_ZonePriority.
Referenced by createNewZone().
|
private |
The preview item to display.
Definition at line 130 of file zone_create_helper.h.
Referenced by commitZone(), createNewZone(), OnFirstPoint(), and performZoneCutout().
|
private |
The zone-in-progress.
Definition at line 136 of file zone_create_helper.h.
Referenced by OnComplete(), OnFirstPoint(), OnGeometryChange(), ZONE_CREATE_HELPER(), and ~ZONE_CREATE_HELPER().
|
private |
view that show the preview item
Definition at line 133 of file zone_create_helper.h.
Referenced by OnComplete(), OnFirstPoint(), OnGeometryChange(), ZONE_CREATE_HELPER(), and ~ZONE_CREATE_HELPER().
|
private |
Parameters of the zone to be drawn.
Definition at line 127 of file zone_create_helper.h.
Referenced by commitZone(), createNewZone(), createZoneFromExisting(), OnFirstPoint(), performZoneCutout(), and setUniquePriority().
|
private |
Definition at line 139 of file zone_create_helper.h.
Referenced by GetZone(), OnComplete(), OnFirstPoint(), and OnGeometryChange().