Add similar zone tool in GAL

This action launches the normal interactive zone tool, but re-uses the
settings from an existing zone, based on a flag passed to the main zone
function.
This commit is contained in:
John Beard 2017-02-06 15:37:13 +08:00 committed by Maciej Suminski
parent abe83b54ae
commit 728349ea12
5 changed files with 30 additions and 0 deletions

View File

@ -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 );

View File

@ -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;

View File

@ -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() );

View File

@ -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

View File

@ -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() );