Commit ca4a3651 authored by jean-pierre charras's avatar jean-pierre charras

Gerbview, layer manager: add option (popup menu) to always keep layers not...

Gerbview, layer manager: add option (popup menu) to always keep layers not visible but the active layer, even when the active layer is changed.
Pcbnew: fix swig warning for operator EDA_COLOR_T::++  (changed to function EDA_COLOR_T:: NextColor)
parent 74a57d4e
......@@ -203,7 +203,7 @@ bool DXF_PLOTTER::StartPlot()
{ "YELLOW4", 2 }
};
for( EDA_COLOR_T i = BLACK; i < NBCOLORS; ++i )
for( EDA_COLOR_T i = BLACK; i < NBCOLORS; i = NextColor(i) )
{
fprintf( outputFile,
" 0\n"
......
/*
/**
* @file confirm.cpp
* utilities to display some error, warning and info short messges
* @brief utilities to display some error, warning and info short messges
*/
#include <fctsys.h>
......
......@@ -1502,7 +1502,7 @@ EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
EDA_COLOR_T ColorByName( const wxChar *aName )
{
// look for a match in the palette itself
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; ++trying )
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
if( 0 == wxStricmp( aName, g_ColorRefs[trying].m_Name ) )
return trying;
......@@ -1535,7 +1535,7 @@ EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
*/
int nearest_distance = 255 * 255 * 3 + 1; // Can't beat this
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; ++trying )
for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
{
const StructColors &c = g_ColorRefs[trying];
int distance = (r - c.m_Red) * (r - c.m_Red) +
......
......@@ -55,6 +55,8 @@ GERBER_LAYER_WIDGET::GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFo
LAYER_WIDGET( aParent, aFocusOwner, aPointSize ),
myframe( aParent )
{
m_alwaysShowActiveLayer = false;
ReFillRender();
// Update default tabs labels for GerbView
......@@ -67,7 +69,8 @@ GERBER_LAYER_WIDGET::GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFo
// since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
// and not m_LayerScrolledWindow->Connect()
Connect( ID_SHOW_ALL_COPPERS, ID_SHOW_NO_COPPERS_BUT_ACTIVE, wxEVT_COMMAND_MENU_SELECTED,
Connect( ID_SHOW_ALL_LAYERS, ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( GERBER_LAYER_WIDGET::onPopupSelection ), NULL, this );
// install the right click handler into each control at end of ReFill()
......@@ -144,13 +147,16 @@ void GERBER_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
// menu text is capitalized:
// http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_COPPERS,
menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_LAYERS,
_("Show All Layers") ) );
menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_COPPERS_BUT_ACTIVE,
menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_LAYERS_BUT_ACTIVE,
_( "Hide All Layers But Active" ) ) );
menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_COPPERS,
menu.Append( new wxMenuItem( &menu, ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE,
_( "Always Hide All Layers But Active" ) ) );
menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_LAYERS,
_( "Hide All Layers" ) ) );
PopupMenu( &menu );
......@@ -162,24 +168,32 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
{
int rowCount;
int menuId = event.GetId();
bool visible = (menuId == ID_SHOW_ALL_COPPERS) ? true : false;;
bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false;;
LAYER_MSK visibleLayers = NO_LAYERS;
bool force_active_layer_visible;
m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
force_active_layer_visible = ( menuId == ID_SHOW_NO_LAYERS_BUT_ACTIVE ||
menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
switch( menuId )
{
case ID_SHOW_ALL_COPPERS:
case ID_SHOW_NO_COPPERS:
case ID_SHOW_NO_COPPERS_BUT_ACTIVE:
case ID_SHOW_ALL_LAYERS:
case ID_SHOW_NO_LAYERS:
case ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE:
case ID_SHOW_NO_LAYERS_BUT_ACTIVE:
rowCount = GetLayerRowCount();
for( int row=0; row < rowCount; ++row )
{
wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 );
LAYER_NUM layer = getDecodedId( cb->GetId() );
bool loc_visible = visible;
if( (menuId == ID_SHOW_NO_COPPERS_BUT_ACTIVE ) &&
(row == m_CurrentRow ) )
if( force_active_layer_visible && (layer == myframe->getActiveLayer() ) )
loc_visible = true;
wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 );
cb->SetValue( loc_visible );
if( loc_visible )
visibleLayers |= GetLayerMask( row );
else
......@@ -192,6 +206,18 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
}
}
bool GERBER_LAYER_WIDGET::OnLayerSelected()
{
if( !m_alwaysShowActiveLayer )
return false;
// postprocess after an active layer selection
// ensure active layer visible
wxCommandEvent event;
event.SetId( ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
onPopupSelection( event );
return true;
}
void GERBER_LAYER_WIDGET::ReFill()
......@@ -227,7 +253,10 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
myframe->syncLayerBox();
if( layer != myframe->getActiveLayer( ) )
{
if( ! OnLayerSelected() )
myframe->GetCanvas()->Refresh();
}
return true;
}
......
......@@ -42,11 +42,14 @@
class GERBER_LAYER_WIDGET : public LAYER_WIDGET
{
GERBVIEW_FRAME* myframe;
bool m_alwaysShowActiveLayer; // If true: Only shows the current active layer
// even if it is changed
// popup menu ids.
#define ID_SHOW_ALL_COPPERS wxID_HIGHEST
#define ID_SHOW_NO_COPPERS (wxID_HIGHEST+1)
#define ID_SHOW_NO_COPPERS_BUT_ACTIVE (wxID_HIGHEST+2)
#define ID_SHOW_ALL_LAYERS wxID_HIGHEST
#define ID_SHOW_NO_LAYERS (wxID_HIGHEST+1)
#define ID_SHOW_NO_LAYERS_BUT_ACTIVE (wxID_HIGHEST+2)
#define ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE (wxID_HIGHEST+3)
/**
* Function OnRightDownLayers
......@@ -101,6 +104,18 @@ public:
void SetLayersManagerTabsText( );
//-----</implement LAYER_WIDGET abstract callback functions>----------
/**
* Function OnLayerSelected
* ensure the active layer is visible, and other layers not visible
* when m_alwaysShowActiveLayer is true
* Otherwise do nothing.
* @return true m_alwaysShowActiveLayer is true and the canvas is refreshed,
* and false if do nothing
*/
bool OnLayerSelected(); // postprocess after an active layer selection
// ensure active layer visible if
// m_alwaysShowActiveCopperLayer is true;
/**
* Function UpdateLayerIcons
* Update the layer manager icons (layers only)
......
......@@ -240,7 +240,10 @@ void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
setActiveLayer( event.GetSelection() );
if( layer != getActiveLayer() )
{
if( m_LayersManager->OnLayerSelected() )
m_canvas->Refresh();
}
}
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
......@@ -87,7 +87,8 @@ void GERBVIEW_FRAME::ReCreateHToolbar( void )
m_mainToolBar->AddSeparator();
m_SelLayerBox = new GBR_LAYER_BOX_SELECTOR( m_mainToolBar, ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,
m_SelLayerBox = new GBR_LAYER_BOX_SELECTOR( m_mainToolBar,
ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER,
wxDefaultPosition, wxSize( 150, -1 ), 0,NULL);
m_SelLayerBox->Resync();
......
......@@ -55,7 +55,7 @@ inline EDA_COLOR_T ColorFromInt( int aColor )
return static_cast<EDA_COLOR_T>( aColor );
}
inline EDA_COLOR_T operator++( EDA_COLOR_T& aColor )
inline EDA_COLOR_T NextColor( EDA_COLOR_T& aColor )
{
// We have to accept NBCOLORS for loop termination conditions
wxASSERT( aColor >= UNSPECIFIED_COLOR && aColor <= NBCOLORS );
......@@ -63,7 +63,6 @@ inline EDA_COLOR_T operator++( EDA_COLOR_T& aColor )
return aColor;
}
/// Return only the plain color part
inline EDA_COLOR_T ColorGetBase( EDA_COLOR_T aColor)
{
......
......@@ -32,7 +32,7 @@
#include <vector>
#include <class_base_screen.h>
#include <eeschema/general.h>
#include <general.h>
using namespace std;
......
......@@ -91,7 +91,8 @@ PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_EDIT_FRAME* aParent, wxWindow* aFocusOwn
// since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
// and not m_LayerScrolledWindow->Connect()
Connect( ID_SHOW_ALL_COPPERS, ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE, wxEVT_COMMAND_MENU_SELECTED,
Connect( ID_SHOW_ALL_COPPERS, ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
// install the right click handler into each control at end of ReFill()
......@@ -143,16 +144,17 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
bool visible;
bool force_active_layer_visible;
visible = menuId == ID_SHOW_ALL_COPPERS;
m_alwaysShowActiveCopperLayer = ( menuId == ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE );
force_active_layer_visible = ( menuId == ID_SHOW_NO_COPPERS_BUT_ACTIVE ||
menuId == ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE );
switch( menuId )
{
case ID_SHOW_ALL_COPPERS:
case ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE:
case ID_SHOW_NO_COPPERS_BUT_ACTIVE:
case ID_SHOW_NO_COPPERS:
visible = menuId == ID_SHOW_ALL_COPPERS;
m_alwaysShowActiveCopperLayer = ( menuId == ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE );
force_active_layer_visible = ( menuId == ID_SHOW_NO_COPPERS_BUT_ACTIVE ||
menuId == ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE );
// Search the last copper layer row index:
int lastCu = -1;
rowCount = GetLayerRowCount();
......@@ -353,16 +355,18 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
return true;
}
void PCB_LAYER_WIDGET::OnLayerSelected()
bool PCB_LAYER_WIDGET::OnLayerSelected()
{
if( !m_alwaysShowActiveCopperLayer )
return;
return false;
// postprocess after an active layer selection
// ensure active layer visible
wxCommandEvent event;
event.SetId( ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE );
onPopupSelection( event );
return true;
}
......
......@@ -89,7 +89,15 @@ public:
void OnRenderEnable( int aId, bool isEnabled );
//-----</implement LAYER_WIDGET abstract callback functions>----------
void OnLayerSelected(); // postprocess after an active layer selection
/**
* Function OnLayerSelected
* ensure the active layer is visible, and other layers not visible
* when m_alwaysShowActiveLayer is true
* Otherwise do nothing.
* @return true m_alwaysShowActiveLayer is true and the canvas is refreshed,
* and false if do nothing
*/
bool OnLayerSelected(); // postprocess after an active layer selection
// ensure active layer visible if
// m_alwaysShowActiveCopperLayer is true;
......
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