pcbnew: More about work on color selection and items visibility
This commit is contained in:
parent
560970da29
commit
cf7ad0f503
|
@ -4,6 +4,12 @@ KiCad ChangeLog 2010
|
|||
Please add newer entries at the top, list the date and your name with
|
||||
email address.
|
||||
|
||||
2010-Jan-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
||||
================================================================================
|
||||
++ pcbnew:
|
||||
More about work on color selection and items visibility
|
||||
work in progress
|
||||
|
||||
2010-Jan-29 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
||||
================================================================================
|
||||
++ All:
|
||||
|
@ -17,7 +23,7 @@ email address.
|
|||
Now a test is made, and if there are problems relative to floats
|
||||
(write/read conversion error),
|
||||
use the C convention (always a point as separator)
|
||||
|
||||
|
||||
++ eeschema:
|
||||
Removed metrics grid values, that cannot be handled in schematic.
|
||||
(because 2 items are seen as connected if they have the same coordinates
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
/****************************************************/
|
||||
#include "fctsys.h"
|
||||
#include "colors.h"
|
||||
#include "macros.h"
|
||||
|
||||
#include "class_colors_design_settings.h"
|
||||
|
||||
|
@ -64,10 +65,10 @@ static const int default_items_color[LAYERSCOLORSBUFFERSIZE] =
|
|||
|
||||
COLORS_DESIGN_SETTINGS:: COLORS_DESIGN_SETTINGS()
|
||||
{
|
||||
for( unsigned ii = 0; ii < LAYERSCOLORSBUFFERSIZE; ii++ )
|
||||
for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
|
||||
m_LayersColors[ii] = default_layer_color[ii];
|
||||
|
||||
for( unsigned ii = 0; ii < ITEMSCOLORSBUFFERSIZE; ii++ )
|
||||
for( unsigned ii = 0; ii < DIM(m_ItemsColors); ii++ )
|
||||
m_ItemsColors[ii] = default_items_color[ii];
|
||||
}
|
||||
|
||||
|
@ -79,7 +80,7 @@ COLORS_DESIGN_SETTINGS:: COLORS_DESIGN_SETTINGS()
|
|||
*/
|
||||
int COLORS_DESIGN_SETTINGS::GetLayerColor( int aLayer )
|
||||
{
|
||||
if( (unsigned) aLayer < LAYERSCOLORSBUFFERSIZE )
|
||||
if( (unsigned) aLayer < DIM(m_LayersColors) )
|
||||
{
|
||||
return m_LayersColors[aLayer];
|
||||
}
|
||||
|
@ -94,7 +95,7 @@ int COLORS_DESIGN_SETTINGS::GetLayerColor( int aLayer )
|
|||
*/
|
||||
void COLORS_DESIGN_SETTINGS:: SetLayerColor( int aLayer, int aColor )
|
||||
{
|
||||
if( (unsigned) aLayer < LAYERSCOLORSBUFFERSIZE )
|
||||
if( (unsigned) aLayer < DIM(m_LayersColors) )
|
||||
{
|
||||
m_LayersColors[aLayer] = aColor;
|
||||
}
|
||||
|
@ -108,7 +109,7 @@ void COLORS_DESIGN_SETTINGS:: SetLayerColor( int aLayer, int aColor )
|
|||
*/
|
||||
int COLORS_DESIGN_SETTINGS:: GetItemColor( int aItemIdx )
|
||||
{
|
||||
if( (unsigned) aItemIdx < ITEMSCOLORSBUFFERSIZE )
|
||||
if( (unsigned) aItemIdx < DIM(m_ItemsColors) )
|
||||
{
|
||||
return m_ItemsColors[aItemIdx];
|
||||
}
|
||||
|
@ -123,7 +124,7 @@ int COLORS_DESIGN_SETTINGS:: GetItemColor( int aItemIdx )
|
|||
*/
|
||||
void COLORS_DESIGN_SETTINGS:: SetItemColor( int aItemIdx, int aColor )
|
||||
{
|
||||
if( (unsigned) aItemIdx < ITEMSCOLORSBUFFERSIZE )
|
||||
if( (unsigned) aItemIdx < DIM(m_ItemsColors) )
|
||||
{
|
||||
m_ItemsColors[aItemIdx] = aColor;
|
||||
}
|
||||
|
|
|
@ -96,8 +96,11 @@ protected:
|
|||
* <p>
|
||||
* This function cannot be inline without including layer_widget.h in
|
||||
* here and we do not want to do that.
|
||||
* @param aRenderOnly: true to update render only, false (default) for full update
|
||||
* if aRenderOnly = true, the page displayed by the layer manager is not changed
|
||||
* if aRenderOnly = false, the page displayed after update is the layers list
|
||||
*/
|
||||
void syncLayerWidget();
|
||||
void syncLayerWidget(bool aRenderOnly = false);
|
||||
|
||||
/**
|
||||
* Function syncLayerBox
|
||||
|
|
|
@ -390,7 +390,27 @@ void BOARD::SetVisibleLayers( int aLayerMask )
|
|||
|
||||
void BOARD::SetVisibleElements( int aMask )
|
||||
{
|
||||
m_BoardSettings->SetVisibleElements( aMask );
|
||||
/* Call SetElementVisibility for each item,
|
||||
* to ensure specific calculations that can be needed by some items
|
||||
*/
|
||||
for( int ii = 0; ii < PCB_VISIBLE(END_PCB_VISIBLE_LIST); ii++ )
|
||||
{
|
||||
int item_mask = 1 << ii;
|
||||
SetElementVisibility( ii, aMask & item_mask );
|
||||
}
|
||||
}
|
||||
|
||||
// these are not tidy, since there are PCB_VISIBLEs that are not stored in the bitmap.
|
||||
void BOARD::SetVisibleAlls( )
|
||||
{
|
||||
SetVisibleLayers( FULL_LAYERS );
|
||||
/* Call SetElementVisibility for each item,
|
||||
* to ensure specific calculations that can be needed by some items
|
||||
*/
|
||||
for( int ii = 0; ii < PCB_VISIBLE(END_PCB_VISIBLE_LIST); ii++ )
|
||||
{
|
||||
SetElementVisibility( ii, true );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -420,11 +440,29 @@ void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled )
|
|||
{
|
||||
switch( aPCB_VISIBLE )
|
||||
{
|
||||
/*
|
||||
case GRID_VISIBLE:
|
||||
myframe->m_Draw_Grid = isEnabled;
|
||||
m_PcbFrame->m_Draw_Grid = isEnabled;
|
||||
m_BoardSettings->SetElementVisibility( aPCB_VISIBLE, isEnabled );
|
||||
break;
|
||||
*/
|
||||
|
||||
|
||||
case RATSNEST_VISIBLE:
|
||||
m_BoardSettings->SetElementVisibility( aPCB_VISIBLE, isEnabled );
|
||||
// we must clear or set the CH_VISIBLE flags to hide/show ratsnet
|
||||
// because we have a tool to show hide ratsnest relative to a pad or a module
|
||||
// so the hide/show option is a per item selection
|
||||
if( IsElementVisible(RATSNEST_VISIBLE) )
|
||||
{
|
||||
for( unsigned ii = 0; ii < GetRatsnestsCount(); ii++ )
|
||||
m_FullRatsnest[ii].m_Status |= CH_VISIBLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( unsigned ii = 0; ii < GetRatsnestsCount(); ii++ )
|
||||
m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
m_BoardSettings->SetElementVisibility( aPCB_VISIBLE, isEnabled );
|
||||
|
@ -478,20 +516,6 @@ void BOARD::SetVisibleElementColor( int aPCB_VISIBLE, int aColor )
|
|||
g_ColorsSettings.SetItemColor( aPCB_VISIBLE, aColor );
|
||||
break;
|
||||
case RATSNEST_VISIBLE:
|
||||
// we must clear or set the CH_VISIBLE flags to hide/show ratsnet
|
||||
// because we have atool to show hide ratsnest relative to a pad or a module
|
||||
// so the hide/show option is a per item selection
|
||||
if( IsElementVisible(RATSNEST_VISIBLE) )
|
||||
{
|
||||
for( unsigned ii = 0; ii < GetRatsnestsCount(); ii++ )
|
||||
m_FullRatsnest[ii].m_Status |= CH_VISIBLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( unsigned ii = 0; ii < GetRatsnestsCount(); ii++ )
|
||||
m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE;
|
||||
}
|
||||
|
||||
g_ColorsSettings.SetItemColor( aPCB_VISIBLE, aColor );
|
||||
break;
|
||||
|
||||
|
|
|
@ -304,6 +304,13 @@ public:
|
|||
*/
|
||||
void SetVisibleElements( int aMask );
|
||||
|
||||
/**
|
||||
* Function SetVisibleAlls
|
||||
* changes the bit-mask of visible element categories and layers
|
||||
* @see enum PCB_VISIBLE
|
||||
*/
|
||||
void SetVisibleAlls( );
|
||||
|
||||
/**
|
||||
* Function IsElementVisible
|
||||
* tests whether a given element category is visible. Keep this as an
|
||||
|
|
|
@ -150,26 +150,29 @@ void WinEDA_ModuleEditFrame::InstallOptionsFrame( const wxPoint& pos )
|
|||
void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
|
||||
{
|
||||
int id = event.GetId();
|
||||
|
||||
bool state = m_OptionsToolBar->GetToolState( id );
|
||||
|
||||
switch( id )
|
||||
{
|
||||
case ID_TB_OPTIONS_DRC_OFF:
|
||||
Drc_On = m_OptionsToolBar->GetToolState( id ) ? FALSE : true;
|
||||
Drc_On = state ? FALSE : true;
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_GRID:
|
||||
m_Draw_Grid = m_OptionsToolBar->GetToolState( id );
|
||||
GetBoard()->SetElementVisibility(GRID_VISIBLE, state);
|
||||
syncLayerWidget( true );
|
||||
DrawPanel->Refresh();
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_RATSNEST:
|
||||
GetBoard()->SetElementVisibility(RATSNEST_VISIBLE, m_OptionsToolBar->GetToolState( id ));
|
||||
GetBoard()->SetElementVisibility(RATSNEST_VISIBLE, state);
|
||||
syncLayerWidget( true );
|
||||
DrawPanel->Refresh( );
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_MODULE_RATSNEST:
|
||||
g_Show_Module_Ratsnest = m_OptionsToolBar->GetToolState( id );
|
||||
g_Show_Module_Ratsnest = state; // TODO: use the visibility list
|
||||
syncLayerWidget( true );
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SELECT_UNIT_MM:
|
||||
|
@ -186,16 +189,16 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
|
||||
case ID_TB_OPTIONS_SHOW_POLAR_COORD:
|
||||
Affiche_Message( wxEmptyString );
|
||||
DisplayOpt.DisplayPolarCood = m_OptionsToolBar->GetToolState( id );
|
||||
DisplayOpt.DisplayPolarCood = state;
|
||||
UpdateStatusBar();
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SELECT_CURSOR:
|
||||
m_CursorShape = m_OptionsToolBar->GetToolState( id );
|
||||
m_CursorShape = state;
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_AUTO_DEL_TRACK:
|
||||
g_AutoDeleteOldTrack = m_OptionsToolBar->GetToolState( id );
|
||||
g_AutoDeleteOldTrack = state;
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_ZONES:
|
||||
|
@ -214,7 +217,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_PADS_SKETCH:
|
||||
if( m_OptionsToolBar->GetToolState( id ) )
|
||||
if( state )
|
||||
{
|
||||
m_DisplayPadFill = DisplayOpt.DisplayPadFill = false;
|
||||
}
|
||||
|
@ -226,7 +229,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
|
||||
if( m_OptionsToolBar->GetToolState( id ) )
|
||||
if( state )
|
||||
{
|
||||
m_DisplayViaFill = DisplayOpt.DisplayViaFill = false;
|
||||
}
|
||||
|
@ -238,19 +241,17 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
|
||||
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill =
|
||||
!m_OptionsToolBar->GetToolState( id );
|
||||
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill = !state;
|
||||
DrawPanel->Refresh();
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE:
|
||||
DisplayOpt.ContrastModeDisplay =
|
||||
m_OptionsToolBar->GetToolState( id );
|
||||
DisplayOpt.ContrastModeDisplay = state;
|
||||
DrawPanel->Refresh();
|
||||
break;
|
||||
|
||||
case ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1:
|
||||
m_show_microwave_tools = m_OptionsToolBar->GetToolState( id );
|
||||
m_show_microwave_tools = state;
|
||||
#if !defined(KICAD_AUIMANAGER)
|
||||
// show auxiliary Vertical toolbar (Microwave tool)
|
||||
m_AuxVToolBar->Show(m_show_microwave_tools);
|
||||
|
@ -267,7 +268,7 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
|
|||
case ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR:
|
||||
#if defined(KICAD_AUIMANAGER)
|
||||
// show auxiliary Vertical layers and visibility manager toolbar
|
||||
m_show_layer_manager_tools = m_OptionsToolBar->GetToolState( id );
|
||||
m_show_layer_manager_tools = state;
|
||||
m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools );
|
||||
m_auimgr.Update();
|
||||
if( m_show_layer_manager_tools )
|
||||
|
|
|
@ -259,6 +259,7 @@ this file again."));
|
|||
|
||||
ReCreateLayerBox( NULL );
|
||||
AuxiliaryToolBar_Update_UI();
|
||||
syncLayerWidget( );
|
||||
|
||||
// Display the loaded board:
|
||||
Zoom_Automatique( false );
|
||||
|
|
|
@ -85,6 +85,9 @@ public:
|
|||
PCB_LAYER_WIDGET( WinEDA_PcbFrame* aParent, wxWindow* aFocusOwner, int aPointSize = 10 );
|
||||
|
||||
void ReFill();
|
||||
// Update Show/hide checkbox state in render page
|
||||
// must be called when a Show/hide option is changed outside the layer manager
|
||||
void RenderSynchronize( );
|
||||
|
||||
//-----<implement LAYER_WIDGET abstract callback functions>-----------
|
||||
void OnLayerColorChange( int aLayer, int aColor );
|
||||
|
@ -315,6 +318,33 @@ void PCB_LAYER_WIDGET::ReFill()
|
|||
// m_Layers->Thaw();
|
||||
}
|
||||
|
||||
// Update the checkboxes state of each row of the render.
|
||||
void PCB_LAYER_WIDGET::RenderSynchronize( )
|
||||
{
|
||||
BOARD* brd = myframe->GetBoard();
|
||||
wxSizerItemList& sizerslist = m_RenderFlexGridSizer->GetChildren();
|
||||
|
||||
for( unsigned ii=0; ii< PCB_VISIBLE(END_PCB_VISIBLE_LIST); ++ii )
|
||||
{
|
||||
unsigned idx = ii * m_RenderFlexGridSizer->GetCols();
|
||||
// idx points the first size of a m_RenderFlexGridSizer row
|
||||
// the checkbox to update is managed by the second sizer
|
||||
idx = idx + 1;
|
||||
if( idx >= sizerslist.size() )
|
||||
break; // Should not occur
|
||||
|
||||
// Get the sizer that manages the check box to update
|
||||
wxSizerItem * sizer = sizerslist[idx];
|
||||
// Get the checkbox and update its state.
|
||||
wxCheckBox* cb = (wxCheckBox*)sizer->GetWindow();
|
||||
if( cb )
|
||||
{
|
||||
// Calculate the visible item id
|
||||
int id = getDecodedId(cb->GetId());
|
||||
cb->SetValue(brd->IsElementVisible(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----<LAYER_WIDGET callbacks>-------------------------------------------
|
||||
|
||||
|
@ -330,6 +360,9 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer )
|
|||
// false from this function.
|
||||
myframe->setActiveLayer( aLayer, false );
|
||||
myframe->syncLayerBox();
|
||||
if(DisplayOpt.ContrastModeDisplay)
|
||||
myframe->DrawPanel->Refresh();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -362,14 +395,11 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
|
|||
|
||||
/* @todo:
|
||||
|
||||
1) move:
|
||||
move:
|
||||
|
||||
RATSNEST_VISIBLE,
|
||||
GRID_VISIBLE, ? maybe not this one
|
||||
into m_VisibleElements and get rid of globals.
|
||||
|
||||
2) Add IsElementVisible() & SetVisibleElement() to class BOARD
|
||||
*/
|
||||
*/
|
||||
|
||||
switch( aId )
|
||||
{
|
||||
|
@ -378,7 +408,7 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
|
|||
case GRID_VISIBLE:
|
||||
// @todo, make read/write accessors for grid control so the write accessor can fire updates to
|
||||
// grid state listeners. I think the grid state should be kept in the BOARD.
|
||||
myframe->m_Draw_Grid = isEnabled;
|
||||
brd->SetElementVisibility( aId, isEnabled ); // set visibilty flag also in list, and myframe->m_Draw_Grid
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -643,6 +673,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
|
|||
|
||||
if( DrawPanel )
|
||||
DrawPanel->m_Block_Enable = true;
|
||||
|
||||
ReCreateMenuBar();
|
||||
ReCreateHToolbar();
|
||||
ReCreateAuxiliaryToolbar();
|
||||
|
@ -718,8 +749,8 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
|
|||
m_AuxVToolBar->Show(m_show_microwave_tools);
|
||||
#endif
|
||||
|
||||
SetToolbars();
|
||||
ReFillLayerWidget(); // this is near end because contents establish size
|
||||
|
||||
syncLayerWidget();
|
||||
}
|
||||
|
||||
|
@ -845,6 +876,10 @@ void WinEDA_PcbFrame::LoadSettings()
|
|||
config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption );
|
||||
config->Read( SHOW_MICROWAVE_TOOLS, &m_show_microwave_tools );
|
||||
config->Read( SHOW_LAYER_MANAGER_TOOLS, &m_show_layer_manager_tools );
|
||||
|
||||
// Copy grid visibility (set by LoadSetting() in visibility items list:
|
||||
GetBoard()->SetElementVisibility(GRID_VISIBLE, m_Draw_Grid);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -870,8 +905,10 @@ void WinEDA_PcbFrame::SaveSettings()
|
|||
}
|
||||
|
||||
|
||||
void WinEDA_PcbFrame::syncLayerWidget()
|
||||
void WinEDA_PcbFrame::syncLayerWidget( bool aRenderOnly)
|
||||
{
|
||||
m_Layers->SelectLayer( getActiveLayer() );
|
||||
if( ! aRenderOnly )
|
||||
m_Layers->SelectLayer( getActiveLayer() );
|
||||
m_Layers->RenderSynchronize( );
|
||||
}
|
||||
|
||||
|
|
|
@ -191,9 +191,14 @@ bool WinEDA_PcbFrame::Read_Config( const wxString& projectFileName )
|
|||
|
||||
/* Reset the items visibility flag when loading a new config
|
||||
* Because it could creates SERIOUS mistakes for the user,
|
||||
* if some items are not visible after loading a board...
|
||||
* if board items are not visible after loading a board...
|
||||
* Grid and ratsnest can be left to their previous state
|
||||
*/
|
||||
GetBoard()->m_BoardSettings->SetVisibleAlls( );
|
||||
bool showGrid = GetBoard()->IsElementVisible(GRID_VISIBLE);
|
||||
bool showRats = GetBoard()->IsElementVisible(RATSNEST_VISIBLE);
|
||||
GetBoard()->SetVisibleAlls( );
|
||||
GetBoard()->SetElementVisibility(GRID_VISIBLE, showGrid);
|
||||
GetBoard()->SetElementVisibility(RATSNEST_VISIBLE, showRats);
|
||||
|
||||
DisplayOpt.DisplayPadNoConn = true;
|
||||
return TRUE;
|
||||
|
|
|
@ -203,10 +203,9 @@ void WinEDA_PcbFrame::SetToolbars()
|
|||
_( "Display rectangular coordinates" ) :
|
||||
_( "Display polar coordinates" ) );
|
||||
|
||||
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID,
|
||||
m_Draw_Grid );
|
||||
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, GetBoard()->IsElementVisible(GRID_VISIBLE) );
|
||||
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID,
|
||||
m_Draw_Grid ?
|
||||
GetBoard()->IsElementVisible(GRID_VISIBLE) ?
|
||||
_( "Hide grid" ) :
|
||||
_( "Show grid" ) );
|
||||
|
||||
|
|
Loading…
Reference in New Issue