Commit 87c9423f authored by Maciej Suminski's avatar Maciej Suminski

PCB_EDIT_FRAME::SetActiveLayer() & GetActiveLayer() made public.

parent 0694f2fa
......@@ -134,22 +134,6 @@ protected:
void createPopUpBlockMenu( wxMenu* menu );
void createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu );
/**
* Function setActiveLayer
* will change the currently active layer to \a aLayer and also
* update the PCB_LAYER_WIDGET.
*/
void setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate = true );
/**
* Function getActiveLayer
* returns the active layer
*/
LAYER_NUM getActiveLayer()
{
return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
}
/**
* Function setHighContrastLayer
* takes care of display settings for the given layer to be displayed in high contrast mode.
......@@ -159,7 +143,7 @@ protected:
/**
* Function syncLayerWidgetLayer
* updates the currently layer "selection" within the PCB_LAYER_WIDGET.
* The currently selected layer is defined by the return value of getActiveLayer().
* The currently selected layer is defined by the return value of GetActiveLayer().
* <p>
* This function cannot be inline without including layer_widget.h in
* here and we do not want to do that.
......@@ -577,6 +561,22 @@ public:
*/
void SetTopLayer( LAYER_NUM aLayer );
/**
* Function SetActiveLayer
* will change the currently active layer to \a aLayer and also
* update the PCB_LAYER_WIDGET.
*/
void SetActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate = true );
/**
* Function GetActiveLayer
* returns the active layer
*/
LAYER_NUM GetActiveLayer()
{
return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
}
/**
* Function IsElementVisible
* tests whether a given element category is visible. Keep this as an
......
......@@ -183,7 +183,7 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
if( IsCopperLayer( layer ) )
{
bool loc_visible = visible;
if( force_active_layer_visible && (layer == myframe->getActiveLayer() ) )
if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) )
loc_visible = true;
cb->SetValue( loc_visible );
......@@ -354,7 +354,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
{
// the layer change from the PCB_LAYER_WIDGET can be denied by returning
// false from this function.
myframe->setActiveLayer( aLayer, false );
myframe->SetActiveLayer( aLayer, false );
if( m_alwaysShowActiveCopperLayer )
OnLayerSelected();
......
......@@ -53,7 +53,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
{
if( g_CurrentTrackList.GetCount() > 0 )
{
LAYER_NUM previous_layer = getActiveLayer();
LAYER_NUM previous_layer = GetActiveLayer();
DBG( g_CurrentTrackList.VerifyListIntegrity(); )
......@@ -86,7 +86,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
// Correct active layer which could change if a via
// has been erased
setActiveLayer( previous_layer );
SetActiveLayer( previous_layer );
UpdateStatusBar();
......
......@@ -228,7 +228,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
// Apply new display options to the GAL canvas (this is faster than recaching)
settings->LoadDisplayOptions( DisplayOpt );
setHighContrastLayer( getActiveLayer() );
setHighContrastLayer( GetActiveLayer() );
m_canvas->Refresh();
break;
......
......@@ -39,7 +39,7 @@ DIALOG_GLOBAL_DELETION::DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent )
void PCB_EDIT_FRAME::InstallPcbGlobalDeleteFrame( const wxPoint& pos )
{
DIALOG_GLOBAL_DELETION dlg( this );
dlg.SetCurrentLayer( getActiveLayer() );
dlg.SetCurrentLayer( GetActiveLayer() );
dlg.ShowModal();
}
......
......@@ -670,11 +670,11 @@ void PCB_EDIT_FRAME::InstallDialogLayerSetup()
if( dlg.ShowModal() == wxID_CANCEL )
return;
wxLogDebug( wxT( "Current layer selected %d." ), getActiveLayer() );
wxLogDebug( wxT( "Current layer selected %d." ), GetActiveLayer() );
// If the current active layer was removed, find the next avaiable layer to set as the
// active layer.
if( !( GetLayerMask( getActiveLayer() ) & GetBoard()->GetEnabledLayers() ) )
if( !( GetLayerMask( GetActiveLayer() ) & GetBoard()->GetEnabledLayers() ) )
{
for( LAYER_NUM i = FIRST_LAYER; i < NB_LAYERS; ++i )
{
......@@ -685,14 +685,14 @@ void PCB_EDIT_FRAME::InstallDialogLayerSetup()
if( GetLayerMask( tmp ) & GetBoard()->GetEnabledLayers() )
{
wxLogDebug( wxT( "Setting current layer to %d." ), getActiveLayer() );
setActiveLayer( tmp, true );
wxLogDebug( wxT( "Setting current layer to %d." ), GetActiveLayer() );
SetActiveLayer( tmp, true );
break;
}
}
}
else
{
setActiveLayer( getActiveLayer(), true );
SetActiveLayer( GetActiveLayer(), true );
}
}
......@@ -251,7 +251,7 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
aDimension = new DIMENSION( GetBoard() );
aDimension->SetFlags( IS_NEW );
aDimension->SetLayer( getActiveLayer() );
aDimension->SetLayer( GetActiveLayer() );
aDimension->SetOrigin( pos );
aDimension->SetEnd( pos );
......
......@@ -406,14 +406,14 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->SetIgnoreMouseEvents( true );
wxPoint dlgPosition;
wxGetMousePosition( &dlgPosition.x, &dlgPosition.y );
LAYER_NUM layer = SelectLayer( getActiveLayer(), ALL_NO_CU_LAYERS,
LAYER_NUM layer = SelectLayer( GetActiveLayer(), ALL_NO_CU_LAYERS,
dlgPosition );
m_canvas->SetIgnoreMouseEvents( false );
m_canvas->MoveCursorToCrossHair();
if( getActiveLayer() != layer )
if( GetActiveLayer() != layer )
{
GetScreen()->m_Route_Layer_TOP = getActiveLayer();
GetScreen()->m_Route_Layer_TOP = GetActiveLayer();
GetScreen()->m_Route_Layer_BOTTOM = layer;
Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
}
......@@ -942,17 +942,17 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_SELECT_LAYER:
itmp = SelectLayer( getActiveLayer() );
itmp = SelectLayer( GetActiveLayer() );
if( itmp >= 0 )
{
// if user changed colors and we are in high contrast mode, then redraw
// because the PAD_SMD pads may change color.
if( DisplayOpt.ContrastModeDisplay && getActiveLayer() != itmp )
if( DisplayOpt.ContrastModeDisplay && GetActiveLayer() != itmp )
{
m_canvas->Refresh();
}
setActiveLayer( itmp );
SetActiveLayer( itmp );
}
m_canvas->MoveCursorToCrossHair();
......@@ -963,19 +963,19 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_SELECT_NO_CU_LAYER:
itmp = SelectLayer( getActiveLayer(), ALL_CU_LAYERS );
itmp = SelectLayer( GetActiveLayer(), ALL_CU_LAYERS );
if( itmp >= 0 )
setActiveLayer( itmp );
SetActiveLayer( itmp );
m_canvas->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_SELECT_CU_LAYER:
itmp = SelectLayer( getActiveLayer(), ALL_NO_CU_LAYERS );
itmp = SelectLayer( GetActiveLayer(), ALL_NO_CU_LAYERS );
if( itmp >= 0 )
setActiveLayer( itmp );
SetActiveLayer( itmp );
break;
......@@ -985,7 +985,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_TOOLBARH_PCB_SELECT_LAYER:
setActiveLayer( m_SelLayerBox->GetLayerSelection() );
SetActiveLayer( m_SelLayerBox->GetLayerSelection() );
if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh( true );
......@@ -1288,7 +1288,7 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
{
LAYER_NUM curLayer = getActiveLayer();
LAYER_NUM curLayer = GetActiveLayer();
// Check if the specified layer matches the present layer
if( layer == curLayer )
......@@ -1330,7 +1330,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
GetScreen()->m_Route_Layer_TOP = curLayer;
GetScreen()->m_Route_Layer_BOTTOM = layer;
setActiveLayer( curLayer );
SetActiveLayer( curLayer );
if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
{
......@@ -1351,7 +1351,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
// and a non-copper layer, or vice-versa?
// ...
setActiveLayer( layer );
SetActiveLayer( layer );
if( DisplayOpt.ContrastModeDisplay )
m_canvas->Refresh();
......
......@@ -246,7 +246,7 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T s
s_large = GetDesignSettings().m_DrawSegmentWidth;
if( getActiveLayer() == EDGE_N )
if( GetActiveLayer() == EDGE_N )
{
s_large = GetDesignSettings().m_EdgeSegmentWidth;
}
......@@ -255,7 +255,7 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T s
{
SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
Segment->SetFlags( IS_NEW );
Segment->SetLayer( getActiveLayer() );
Segment->SetLayer( GetActiveLayer() );
Segment->SetWidth( s_large );
Segment->SetShape( shape );
Segment->SetAngle( 900 );
......
......@@ -51,10 +51,10 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
if( aTrack == NULL )
{
if( getActiveLayer() != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
setActiveLayer( ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP );
if( GetActiveLayer() != ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP )
SetActiveLayer( ((PCB_SCREEN*)GetScreen())->m_Route_Layer_TOP );
else
setActiveLayer(((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM );
SetActiveLayer(((PCB_SCREEN*)GetScreen())->m_Route_Layer_BOTTOM );
UpdateStatusBar();
return true;
......@@ -108,7 +108,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
via->SetLayerPair( LAYER_N_BACK, LAYER_N_FRONT );
via->SetDrill( GetBoard()->GetCurrentViaDrill() );
LAYER_NUM first_layer = getActiveLayer();
LAYER_NUM first_layer = GetActiveLayer();
LAYER_NUM last_layer;
// prepare switch to new active layer:
......@@ -171,7 +171,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
return false;
}
setActiveLayer( last_layer );
SetActiveLayer( last_layer );
TRACK* lastNonVia = g_CurrentTrackSegment;
......@@ -193,7 +193,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
*/
// set the layer to the new value
track->SetLayer( getActiveLayer() );
track->SetLayer( GetActiveLayer() );
/* the start point is the via position and the end point is the cursor
* which also is on the via (will change when moving mouse)
......
......@@ -263,7 +263,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
break;
case HK_SWITCH_LAYER_TO_PREVIOUS:
ll = getActiveLayer();
ll = GetActiveLayer();
if( (ll <= LAYER_N_BACK) || (ll > LAYER_N_FRONT) )
break;
......@@ -279,7 +279,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
break;
case HK_SWITCH_LAYER_TO_NEXT:
ll = getActiveLayer();
ll = GetActiveLayer();
if( (ll < LAYER_N_BACK) || (ll >= LAYER_N_FRONT) )
break;
......@@ -397,7 +397,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
break;
case HK_BACK_SPACE:
if( IsCopperLayer( getActiveLayer() ) )
if( IsCopperLayer( GetActiveLayer() ) )
{
if( !itemCurrentlyEdited )
{
......@@ -622,7 +622,7 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC )
switch( GetToolId() )
{
case ID_TRACK_BUTT:
if( getActiveLayer() > LAYER_N_FRONT )
if( GetActiveLayer() > LAYER_N_FRONT )
return false;
if( ItemFree )
......@@ -983,7 +983,7 @@ bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC )
TRACK * PCB_EDIT_FRAME::OnHotkeyBeginRoute( wxDC* aDC )
{
if( getActiveLayer() > LAYER_N_FRONT )
if( GetActiveLayer() > LAYER_N_FRONT )
return NULL;
bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->GetFlags());
......
......@@ -243,7 +243,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
if( GetToolId() == ID_PCB_ARC_BUTT )
shape = S_ARC;
if( IsCopperLayer( getActiveLayer() ) )
if( IsCopperLayer( GetActiveLayer() ) )
{
DisplayError( this, _( "Graphic not allowed on Copper layers" ) );
break;
......@@ -267,7 +267,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_TRACK_BUTT:
if( !IsCopperLayer( getActiveLayer() ) )
if( !IsCopperLayer( GetActiveLayer() ) )
{
DisplayError( this, _( "Tracks on Copper layers only " ) );
break;
......@@ -325,7 +325,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_PCB_ADD_TEXT_BUTT:
if( IsLayerInList( EDGE_LAYER, getActiveLayer() ) )
if( IsLayerInList( EDGE_LAYER, GetActiveLayer() ) )
{
DisplayError( this,
_( "Texts not allowed on Edge Cut layer" ) );
......@@ -374,7 +374,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_PCB_DIMENSION_BUTT:
if( IsLayerInList( EDGE_LAYER|ALL_CU_LAYERS, getActiveLayer() ) )
if( IsLayerInList( EDGE_LAYER|ALL_CU_LAYERS, GetActiveLayer() ) )
{
DisplayError( this,
_( "Dimension not allowed on Copper or Edge Cut layers" ) );
......
......@@ -842,7 +842,7 @@ void PCB_EDIT_FRAME::SetGridColor(EDA_COLOR_T aColor)
bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void )
{
int copperlayercnt = GetBoard()->GetCopperLayerCount( );
LAYER_NUM currLayer = getActiveLayer();
LAYER_NUM currLayer = GetActiveLayer();
if( !GetDesignSettings().m_MicroViasAllowed )
return false; // Obvious..
......@@ -946,7 +946,7 @@ void PCB_EDIT_FRAME::SetTopLayer( LAYER_NUM aLayer )
}
void PCB_EDIT_FRAME::setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate )
void PCB_EDIT_FRAME::SetActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate )
{
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
......@@ -962,7 +962,7 @@ void PCB_EDIT_FRAME::setActiveLayer( LAYER_NUM aLayer, bool doLayerWidgetUpdate
void PCB_EDIT_FRAME::syncLayerWidgetLayer()
{
m_Layers->SelectLayer( getActiveLayer() );
m_Layers->SelectLayer( GetActiveLayer() );
m_Layers->OnLayerSelected();
}
......
......@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator()
previous_Route_Layer_BOTTOM_color, previous_via_color;
/* get colors, and redraw bitmap button only on changes */
active_layer_color = GetBoard()->GetLayerColor(getActiveLayer());
active_layer_color = GetBoard()->GetLayerColor(GetActiveLayer());
if( previous_active_layer_color != active_layer_color )
{
......
......@@ -96,7 +96,7 @@ void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
void PCB_EDIT_FRAME::OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent )
{
m_SelLayerBox->SetLayerSelection( getActiveLayer() );
m_SelLayerBox->SetLayerSelection( GetActiveLayer() );
}
......
......@@ -515,7 +515,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
if( !GetBoard()->m_CurrentZoneContour )
{
if( GetToolId() == ID_PCB_KEEPOUT_AREA_BUTT &&
getActiveLayer() >= FIRST_NON_COPPER_LAYER )
GetActiveLayer() >= FIRST_NON_COPPER_LAYER )
{
DisplayError( this,
_( "Error: a keepout area is allowed only on copper layers" ) );
......@@ -534,7 +534,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
ZONE_EDIT_T edited;
// Init zone params to reasonable values
zone->SetLayer( getActiveLayer() );
zone->SetLayer( GetActiveLayer() );
// Prompt user for parameters:
m_canvas->SetIgnoreMouseEvents( true );
......@@ -597,7 +597,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
return 0;
// Switch active layer to the selected zone layer
setActiveLayer( zoneInfo.m_CurrentZone_Layer );
SetActiveLayer( zoneInfo.m_CurrentZone_Layer );
SetZoneSettings( zoneInfo );
}
......@@ -607,7 +607,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
// zone (add cutout or similar zone)
zoneInfo.m_CurrentZone_Layer = s_CurrentZone->GetLayer();
setActiveLayer( s_CurrentZone->GetLayer() );
SetActiveLayer( s_CurrentZone->GetLayer() );
zoneInfo << *s_CurrentZone;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment