diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp index 05bf2cb97d..36915b82c1 100644 --- a/pcbnew/tools/common_actions.cpp +++ b/pcbnew/tools/common_actions.cpp @@ -194,6 +194,11 @@ TOOL_ACTION COMMON_ACTIONS::drawZoneCutout( "pcbnew.InteractiveDrawing.zoneCutou _( "Add a Zone Cutout" ), _( "Add a cutout area of an existing zone" ), add_zone_cutout_xpm, AF_ACTIVATE ); +TOOL_ACTION COMMON_ACTIONS::drawSimilarZone( "pcbnew.InteractiveDrawing.similarZone", + AS_GLOBAL, 0, + _( "Add a Similar Zone" ), _( "Add a zone with the same settings as an existing zone" ), + add_zone_xpm, AF_ACTIVATE ); + TOOL_ACTION COMMON_ACTIONS::placeDXF( "pcbnew.InteractiveDrawing.placeDXF", AS_GLOBAL, 0, "Place DXF", "", NULL, AF_ACTIVATE ); diff --git a/pcbnew/tools/common_actions.h b/pcbnew/tools/common_actions.h index d4eaedbb03..f5172f748f 100644 --- a/pcbnew/tools/common_actions.h +++ b/pcbnew/tools/common_actions.h @@ -129,6 +129,9 @@ public: /// Activation of the drawing tool (drawing a ZONE cutout) static TOOL_ACTION drawZoneCutout; + /// Activation of the drawing tool (drawing a similar ZONE to another one) + static TOOL_ACTION drawSimilarZone; + /// Activation of the drawing tool (placing a TARGET) static TOOL_ACTION placeTarget; diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 5a31d3d085..4fc8ce498d 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -567,6 +567,15 @@ int DRAWING_TOOL::DrawZoneCutout( const TOOL_EVENT& aEvent ) } +int DRAWING_TOOL::DrawSimilarZone( const TOOL_EVENT& aEvent ) +{ + SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE ); + m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add similar zone" ) ); + + return drawZone( false, ZONE_MODE::SIMILAR ); +} + + int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent ) { if( !m_frame->GetModel() ) @@ -1504,6 +1513,7 @@ void DRAWING_TOOL::SetTransitions() Go( &DRAWING_TOOL::DrawZone, COMMON_ACTIONS::drawZone.MakeEvent() ); Go( &DRAWING_TOOL::DrawKeepout, COMMON_ACTIONS::drawKeepout.MakeEvent() ); Go( &DRAWING_TOOL::DrawZoneCutout, COMMON_ACTIONS::drawZoneCutout.MakeEvent() ); + Go( &DRAWING_TOOL::DrawSimilarZone, COMMON_ACTIONS::drawSimilarZone.MakeEvent() ); Go( &DRAWING_TOOL::PlaceText, COMMON_ACTIONS::placeText.MakeEvent() ); Go( &DRAWING_TOOL::PlaceDXF, COMMON_ACTIONS::placeDXF.MakeEvent() ); Go( &DRAWING_TOOL::SetAnchor, COMMON_ACTIONS::setAnchor.MakeEvent() ); diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index 287acae9d0..7cf7ce44b5 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -152,6 +152,15 @@ public: */ int DrawZoneCutout( const TOOL_EVENT& aEvent ); + /** + * Function DrawSimilarZone() + * Starts interactively drawing a zone with same settings as + * an existing zone. + * The normal zone interactive tool is used, but the zone settings + * dialog is not shown at the start. + */ + int DrawSimilarZone( const TOOL_EVENT& aEvent ); + /** * Function PlaceDXF() * Places a drawing imported from a DXF file in module editor. @@ -173,6 +182,7 @@ private: { ADD, ///< Add a new zone/keepout with fresh settings CUTOUT, ///< Make a cutout to an existing zone + SIMILAR ///< Add a new zone with the same settings as an existing one }; ///> Shows the context menu for the drawing tool diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 5591de1c27..9dc4310967 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -75,6 +75,7 @@ public: Add( COMMON_ACTIONS::zoneMerge ); Add( COMMON_ACTIONS::zoneDuplicate ); Add( COMMON_ACTIONS::drawZoneCutout ); + Add( COMMON_ACTIONS::drawSimilarZone ); } protected: @@ -95,6 +96,7 @@ private: Enable( getMenuId( COMMON_ACTIONS::zoneDuplicate), singleZoneActionsEnabled ); Enable( getMenuId( COMMON_ACTIONS::drawZoneCutout), singleZoneActionsEnabled ); + Enable( getMenuId( COMMON_ACTIONS::drawSimilarZone), singleZoneActionsEnabled ); // enable zone actions that ably to a specific set of zones (as opposed to all of them) bool nonGlobalActionsEnabled = ( SELECTION_CONDITIONS::MoreThan( 0 ) )( selTool->GetSelection() );