Simplified code for switching layers in GAL view. Tools are notified of layer change event.
This commit is contained in:
parent
c0a96141df
commit
db0d708300
|
@ -828,7 +828,10 @@ void PCB_EDIT_FRAME::SetActiveLayer( LAYER_ID aLayer )
|
||||||
syncLayerWidgetLayer();
|
syncLayerWidgetLayer();
|
||||||
|
|
||||||
if( IsGalCanvasActive() )
|
if( IsGalCanvasActive() )
|
||||||
|
{
|
||||||
|
m_toolManager->RunAction( COMMON_ACTIONS::layerChanged ); // notify other tools
|
||||||
GetGalCanvas()->Refresh();
|
GetGalCanvas()->Refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -222,6 +222,10 @@ TOOL_ACTION COMMON_ACTIONS::layerAlphaDec( "pcbnew.Control.layerAlphaDec",
|
||||||
AS_GLOBAL, '{',
|
AS_GLOBAL, '{',
|
||||||
"", "" );
|
"", "" );
|
||||||
|
|
||||||
|
TOOL_ACTION COMMON_ACTIONS::layerChanged( "pcbnew.Control.layerChanged",
|
||||||
|
AS_GLOBAL, 0,
|
||||||
|
"", "", AF_NOTIFY );
|
||||||
|
|
||||||
|
|
||||||
// Grid control
|
// Grid control
|
||||||
TOOL_ACTION COMMON_ACTIONS::gridFast1( "pcbnew.Control.gridFast1",
|
TOOL_ACTION COMMON_ACTIONS::gridFast1( "pcbnew.Control.gridFast1",
|
||||||
|
|
|
@ -157,6 +157,8 @@ public:
|
||||||
static TOOL_ACTION layerAlphaInc;
|
static TOOL_ACTION layerAlphaInc;
|
||||||
static TOOL_ACTION layerAlphaDec;
|
static TOOL_ACTION layerAlphaDec;
|
||||||
|
|
||||||
|
static TOOL_ACTION layerChanged; // notification
|
||||||
|
|
||||||
// Grid control
|
// Grid control
|
||||||
static TOOL_ACTION gridFast1;
|
static TOOL_ACTION gridFast1;
|
||||||
static TOOL_ACTION gridFast2;
|
static TOOL_ACTION gridFast2;
|
||||||
|
|
|
@ -889,7 +889,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
|
||||||
|
|
||||||
if( aStartingPoint )
|
if( aStartingPoint )
|
||||||
{
|
{
|
||||||
LAYER_NUM layer = m_frame->GetScreen()->m_Active_Layer;
|
LAYER_ID layer = m_frame->GetScreen()->m_Active_Layer;
|
||||||
|
|
||||||
// Init the new item attributes
|
// Init the new item attributes
|
||||||
aGraphic->SetShape( (STROKE_T) aShape );
|
aGraphic->SetShape( (STROKE_T) aShape );
|
||||||
|
|
|
@ -576,14 +576,9 @@ int MODULE_TOOLS::ModuleEdgeOutlines( TOOL_EVENT& aEvent )
|
||||||
KIGFX::PCB_RENDER_SETTINGS* settings =
|
KIGFX::PCB_RENDER_SETTINGS* settings =
|
||||||
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
||||||
|
|
||||||
const LAYER_NUM layers[] = { ADHESIVE_N_FRONT, ADHESIVE_N_BACK,\
|
const LAYER_ID layers[] = { F_Adhes, B_Adhes, F_Paste, B_Paste,
|
||||||
SOLDERPASTE_N_FRONT, SOLDERPASTE_N_BACK,\
|
F_SilkS, B_SilkS, F_Mask, B_Mask,
|
||||||
SILKSCREEN_N_FRONT, SILKSCREEN_N_BACK,\
|
Dwgs_User, Cmts_User, Eco1_User, Eco2_User, Edge_Cuts };
|
||||||
SOLDERMASK_N_FRONT, SOLDERMASK_N_BACK,\
|
|
||||||
DRAW_N,\
|
|
||||||
COMMENT_N,\
|
|
||||||
ECO1_N, ECO2_N,\
|
|
||||||
EDGE_N };
|
|
||||||
|
|
||||||
bool enable = !settings->GetSketchMode( layers[0] );
|
bool enable = !settings->GetSketchMode( layers[0] );
|
||||||
|
|
||||||
|
|
|
@ -279,79 +279,25 @@ int PCBNEW_CONTROL::HighContrastDec( TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
|
|
||||||
// Layer control
|
// Layer control
|
||||||
int PCBNEW_CONTROL::LayerTop( TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::LayerSwitch( TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
if( aEvent.IsAction( &COMMON_ACTIONS::layerTop ) )
|
||||||
m_frame->SwitchLayer( NULL, F_Cu );
|
m_frame->SwitchLayer( NULL, F_Cu );
|
||||||
m_frame->GetGalCanvas()->SetFocus();
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner1 ) )
|
||||||
setTransitions();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::LayerInner1( TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
m_frame->SwitchLayer( NULL, In1_Cu );
|
m_frame->SwitchLayer( NULL, In1_Cu );
|
||||||
m_frame->GetGalCanvas()->SetFocus();
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner2 ) )
|
||||||
setTransitions();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::LayerInner2( TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
m_frame->SwitchLayer( NULL, In2_Cu );
|
m_frame->SwitchLayer( NULL, In2_Cu );
|
||||||
m_frame->GetGalCanvas()->SetFocus();
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner3 ) )
|
||||||
setTransitions();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::LayerInner3( TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
m_frame->SwitchLayer( NULL, In3_Cu );
|
m_frame->SwitchLayer( NULL, In3_Cu );
|
||||||
m_frame->GetGalCanvas()->SetFocus();
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner4 ) )
|
||||||
setTransitions();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::LayerInner4( TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
m_frame->SwitchLayer( NULL, In4_Cu );
|
m_frame->SwitchLayer( NULL, In4_Cu );
|
||||||
m_frame->GetGalCanvas()->SetFocus();
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner5 ) )
|
||||||
setTransitions();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::LayerInner5( TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
m_frame->SwitchLayer( NULL, In5_Cu );
|
m_frame->SwitchLayer( NULL, In5_Cu );
|
||||||
m_frame->GetGalCanvas()->SetFocus();
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerInner6 ) )
|
||||||
setTransitions();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::LayerInner6( TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
m_frame->SwitchLayer( NULL, In6_Cu );
|
m_frame->SwitchLayer( NULL, In6_Cu );
|
||||||
m_frame->GetGalCanvas()->SetFocus();
|
else if( aEvent.IsAction( &COMMON_ACTIONS::layerBottom ) )
|
||||||
setTransitions();
|
m_frame->SwitchLayer( NULL, B_Cu );
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::LayerBottom( TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
m_frame->SetActiveLayer( B_Cu );
|
|
||||||
m_frame->GetGalCanvas()->SetFocus();
|
m_frame->GetGalCanvas()->SetFocus();
|
||||||
setTransitions();
|
setTransitions();
|
||||||
|
|
||||||
|
@ -364,15 +310,17 @@ int PCBNEW_CONTROL::LayerNext( TOOL_EVENT& aEvent )
|
||||||
PCB_BASE_FRAME* editFrame = m_frame;
|
PCB_BASE_FRAME* editFrame = m_frame;
|
||||||
LAYER_NUM layer = editFrame->GetActiveLayer();
|
LAYER_NUM layer = editFrame->GetActiveLayer();
|
||||||
|
|
||||||
if( layer < F_Cu || layer >= B_Cu )
|
if( layer < F_Cu || layer > B_Cu )
|
||||||
{
|
{
|
||||||
setTransitions();
|
setTransitions();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( getModel<BOARD>()->GetCopperLayerCount() < 2 ) // Single layer
|
int layerCount = getModel<BOARD>()->GetCopperLayerCount();
|
||||||
|
|
||||||
|
if( layer == layerCount - 2 || layerCount < 2 )
|
||||||
layer = B_Cu;
|
layer = B_Cu;
|
||||||
else if( layer >= getModel<BOARD>()->GetCopperLayerCount() - 2 )
|
else if( layer == B_Cu )
|
||||||
layer = F_Cu;
|
layer = F_Cu;
|
||||||
else
|
else
|
||||||
++layer;
|
++layer;
|
||||||
|
@ -390,16 +338,18 @@ int PCBNEW_CONTROL::LayerPrev( TOOL_EVENT& aEvent )
|
||||||
PCB_BASE_FRAME* editFrame = m_frame;
|
PCB_BASE_FRAME* editFrame = m_frame;
|
||||||
LAYER_NUM layer = editFrame->GetActiveLayer();
|
LAYER_NUM layer = editFrame->GetActiveLayer();
|
||||||
|
|
||||||
if( layer <= F_Cu || layer > B_Cu )
|
if( layer < F_Cu || layer > B_Cu )
|
||||||
{
|
{
|
||||||
setTransitions();
|
setTransitions();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( getModel<BOARD>()->GetCopperLayerCount() < 2 ) // Single layer
|
int layerCount = getModel<BOARD>()->GetCopperLayerCount();
|
||||||
|
|
||||||
|
if( layer == F_Cu || layerCount < 2 )
|
||||||
layer = B_Cu;
|
layer = B_Cu;
|
||||||
else if( layer == B_Cu )
|
else if( layer == B_Cu )
|
||||||
layer = std::max( int( F_Cu ), getModel<BOARD>()->GetCopperLayerCount() - 2 );
|
layer = layerCount - 2;
|
||||||
else
|
else
|
||||||
--layer;
|
--layer;
|
||||||
|
|
||||||
|
@ -617,14 +567,14 @@ void PCBNEW_CONTROL::setTransitions()
|
||||||
Go( &PCBNEW_CONTROL::HighContrastDec, COMMON_ACTIONS::highContrastDec.MakeEvent() );
|
Go( &PCBNEW_CONTROL::HighContrastDec, COMMON_ACTIONS::highContrastDec.MakeEvent() );
|
||||||
|
|
||||||
// Layer control
|
// Layer control
|
||||||
Go( &PCBNEW_CONTROL::LayerTop, COMMON_ACTIONS::layerTop.MakeEvent() );
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerTop.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::LayerInner1, COMMON_ACTIONS::layerInner1.MakeEvent() );
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner1.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::LayerInner2, COMMON_ACTIONS::layerInner2.MakeEvent() );
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner2.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::LayerInner3, COMMON_ACTIONS::layerInner3.MakeEvent() );
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner3.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::LayerInner4, COMMON_ACTIONS::layerInner4.MakeEvent() );
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner4.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::LayerInner5, COMMON_ACTIONS::layerInner5.MakeEvent() );
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner5.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::LayerInner6, COMMON_ACTIONS::layerInner6.MakeEvent() );
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerInner6.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::LayerBottom, COMMON_ACTIONS::layerBottom.MakeEvent() );
|
Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerBottom.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::LayerNext, COMMON_ACTIONS::layerNext.MakeEvent() );
|
Go( &PCBNEW_CONTROL::LayerNext, COMMON_ACTIONS::layerNext.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::LayerPrev, COMMON_ACTIONS::layerPrev.MakeEvent() );
|
Go( &PCBNEW_CONTROL::LayerPrev, COMMON_ACTIONS::layerPrev.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::LayerAlphaInc, COMMON_ACTIONS::layerAlphaInc.MakeEvent() );
|
Go( &PCBNEW_CONTROL::LayerAlphaInc, COMMON_ACTIONS::layerAlphaInc.MakeEvent() );
|
||||||
|
|
|
@ -62,14 +62,7 @@ public:
|
||||||
int HighContrastDec( TOOL_EVENT& aEvent );
|
int HighContrastDec( TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
// Layer control
|
// Layer control
|
||||||
int LayerTop( TOOL_EVENT& aEvent );
|
int LayerSwitch( TOOL_EVENT& aEvent );
|
||||||
int LayerInner1( TOOL_EVENT& aEvent );
|
|
||||||
int LayerInner2( TOOL_EVENT& aEvent );
|
|
||||||
int LayerInner3( TOOL_EVENT& aEvent );
|
|
||||||
int LayerInner4( TOOL_EVENT& aEvent );
|
|
||||||
int LayerInner5( TOOL_EVENT& aEvent );
|
|
||||||
int LayerInner6( TOOL_EVENT& aEvent );
|
|
||||||
int LayerBottom( TOOL_EVENT& aEvent );
|
|
||||||
int LayerNext( TOOL_EVENT& aEvent );
|
int LayerNext( TOOL_EVENT& aEvent );
|
||||||
int LayerPrev( TOOL_EVENT& aEvent );
|
int LayerPrev( TOOL_EVENT& aEvent );
|
||||||
int LayerAlphaInc( TOOL_EVENT& aEvent );
|
int LayerAlphaInc( TOOL_EVENT& aEvent );
|
||||||
|
|
|
@ -303,7 +303,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
|
||||||
{
|
{
|
||||||
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
|
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
|
||||||
{
|
{
|
||||||
if( !item->IsOnLayer( GetLayer() ) && !item->IsOnLayer( EDGE_N ) )
|
if( !item->IsOnLayer( GetLayer() ) && !item->IsOnLayer( Edge_Cuts ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( item->Type() != PCB_MODULE_EDGE_T )
|
if( item->Type() != PCB_MODULE_EDGE_T )
|
||||||
|
|
Loading…
Reference in New Issue