2009-09-27 11:00:21 +00:00
|
|
|
/****************************************************************
|
2009-11-20 14:55:20 +00:00
|
|
|
* toolbars_update_user_interface.cpp
|
|
|
|
****************************************************************/
|
2009-10-03 17:57:57 +00:00
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
/*
|
2009-10-03 17:57:57 +00:00
|
|
|
* function to update toolbars UI after changing parameters
|
|
|
|
*/
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "appl_wxstruct.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "wxPcbStruct.h"
|
|
|
|
#include "bitmaps.h"
|
|
|
|
#include "pcbnew_id.h"
|
|
|
|
#include "drc_stuff.h"
|
|
|
|
#include "3d_viewer.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
/* helper to convert an integer value to a string, using mils or mm
|
|
|
|
* according to g_UnitMetric value
|
|
|
|
*/
|
2009-10-03 17:57:57 +00:00
|
|
|
static wxString ReturnStringValue( int aValue )
|
2009-09-27 11:00:21 +00:00
|
|
|
{
|
2009-10-03 17:57:57 +00:00
|
|
|
wxString text;
|
|
|
|
const wxChar* format;
|
|
|
|
double value = To_User_Unit( g_UnitMetric, aValue, PCB_INTERNAL_UNIT );
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
if( g_UnitMetric == INCHES )
|
|
|
|
{
|
|
|
|
format = wxT( " %.1f" );
|
|
|
|
value *= 1000;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
format = wxT( " %.3f" );
|
|
|
|
text.Printf( format, value );
|
|
|
|
if( g_UnitMetric == INCHES )
|
2009-10-03 17:57:57 +00:00
|
|
|
text += _( " mils" );
|
2009-09-27 11:00:21 +00:00
|
|
|
else
|
2009-10-03 17:57:57 +00:00
|
|
|
text += _( " mm" );
|
2009-09-27 11:00:21 +00:00
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2009-10-03 17:57:57 +00:00
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
/**
|
|
|
|
* Function AuxiliaryToolBar_DesignRules_Update_UI
|
|
|
|
* update the displayed values: track widths, via sizes, clearance, Netclass name
|
|
|
|
* used when a netclass is selected
|
|
|
|
*/
|
2009-10-03 17:57:57 +00:00
|
|
|
void WinEDA_PcbFrame::AuxiliaryToolBar_DesignRules_Update_UI()
|
2009-09-27 11:00:21 +00:00
|
|
|
{
|
|
|
|
wxString nclname = GetBoard()->m_CurrentNetClassName;
|
2009-10-03 17:57:57 +00:00
|
|
|
wxString msg = _( "NetClass: " ) + nclname;
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
m_NetClassSelectedBox->Clear();
|
|
|
|
m_NetClassSelectedBox->AppendText( msg );
|
|
|
|
|
|
|
|
NETCLASS* netclass = GetBoard()->m_NetClasses.Find( nclname );
|
|
|
|
|
|
|
|
if( m_ClearanceBox )
|
|
|
|
{
|
2009-10-03 17:57:57 +00:00
|
|
|
wxString msg = _( "Clearance" ) + ReturnStringValue( netclass->GetClearance() );
|
2009-09-27 11:00:21 +00:00
|
|
|
m_ClearanceBox->Clear();
|
|
|
|
m_ClearanceBox->AppendText( msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-03 17:57:57 +00:00
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
/**
|
|
|
|
* Function AuxiliaryToolBar_Update_UI
|
|
|
|
* update the displayed values on auxiliary horizontal toolbar
|
|
|
|
* (track width, via sizes, clearance ...
|
2009-10-01 16:46:13 +00:00
|
|
|
* Display format for track and via lists
|
|
|
|
* first item = current selected class value
|
|
|
|
* next items (if any) = ordered list of sizes (extra sizes).
|
|
|
|
* So the current selected class value can be same as an other extra value
|
2009-09-27 11:00:21 +00:00
|
|
|
*/
|
2009-10-03 17:57:57 +00:00
|
|
|
void WinEDA_PcbFrame::AuxiliaryToolBar_Update_UI()
|
2009-09-27 11:00:21 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2009-10-01 16:46:13 +00:00
|
|
|
|
2009-10-03 17:57:57 +00:00
|
|
|
AuxiliaryToolBar_DesignRules_Update_UI();
|
|
|
|
|
|
|
|
m_AuxiliaryToolBar->ToggleTool( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH,
|
2010-01-31 20:01:46 +00:00
|
|
|
GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth );
|
2009-10-01 16:46:13 +00:00
|
|
|
|
|
|
|
if( m_SelTrackWidthBox && m_TrackAndViasSizesList_Changed )
|
2009-09-27 11:00:21 +00:00
|
|
|
{
|
|
|
|
m_SelTrackWidthBox->Clear();
|
2009-10-06 13:19:40 +00:00
|
|
|
for( unsigned ii = 0; ii < GetBoard()->m_TrackWidthList.size(); ii++ )
|
2009-09-27 11:00:21 +00:00
|
|
|
{
|
2009-10-06 13:19:40 +00:00
|
|
|
msg = _( "Track" ) + ReturnStringValue( GetBoard()->m_TrackWidthList[ii] );
|
2009-10-03 17:57:57 +00:00
|
|
|
if( ii == 0 )
|
|
|
|
msg << _( " *" );
|
2009-09-27 11:00:21 +00:00
|
|
|
m_SelTrackWidthBox->Append( msg );
|
|
|
|
}
|
|
|
|
}
|
2009-10-06 13:19:40 +00:00
|
|
|
if( GetBoard()->m_TrackWidthSelector >= GetBoard()->m_TrackWidthList.size() )
|
2009-10-03 17:18:08 +00:00
|
|
|
GetBoard()->m_TrackWidthSelector = 0;
|
|
|
|
m_SelTrackWidthBox->SetSelection( GetBoard()->m_TrackWidthSelector );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2009-10-01 16:46:13 +00:00
|
|
|
if( m_SelViaSizeBox && m_TrackAndViasSizesList_Changed )
|
2009-09-27 11:00:21 +00:00
|
|
|
{
|
|
|
|
m_SelViaSizeBox->Clear();
|
2009-10-30 17:58:15 +00:00
|
|
|
for( unsigned ii = 0; ii < GetBoard()->m_ViasDimensionsList.size(); ii++ )
|
2009-09-27 11:00:21 +00:00
|
|
|
{
|
2009-10-30 17:58:15 +00:00
|
|
|
msg = _( "Via" );
|
|
|
|
msg << ReturnStringValue( GetBoard()->m_ViasDimensionsList[ii].m_Diameter );
|
|
|
|
|
|
|
|
if( GetBoard()->m_ViasDimensionsList[ii].m_Drill )
|
|
|
|
msg << wxT("/") << ReturnStringValue( GetBoard()->m_ViasDimensionsList[ii].m_Drill );
|
|
|
|
|
2009-10-03 17:57:57 +00:00
|
|
|
if( ii == 0 )
|
|
|
|
msg << _( " *" );
|
2009-09-27 11:00:21 +00:00
|
|
|
m_SelViaSizeBox->Append( msg );
|
|
|
|
}
|
|
|
|
}
|
2009-10-30 17:58:15 +00:00
|
|
|
if( GetBoard()->m_ViaSizeSelector >= GetBoard()->m_ViasDimensionsList.size() )
|
2009-10-03 17:18:08 +00:00
|
|
|
GetBoard()->m_ViaSizeSelector = 0;
|
|
|
|
m_SelViaSizeBox->SetSelection( GetBoard()->m_ViaSizeSelector );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
if( m_SelZoomBox )
|
|
|
|
{
|
|
|
|
bool not_found = true;
|
2009-09-28 16:14:45 +00:00
|
|
|
for( unsigned jj = 0; jj < GetScreen()->m_ZoomList.GetCount(); jj++ )
|
2009-09-27 11:00:21 +00:00
|
|
|
{
|
|
|
|
if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[jj] )
|
|
|
|
{
|
|
|
|
m_SelZoomBox->SetSelection( jj + 1 );
|
|
|
|
not_found = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-10-03 17:57:57 +00:00
|
|
|
|
|
|
|
if( not_found )
|
2009-09-27 11:00:21 +00:00
|
|
|
m_SelZoomBox->SetSelection( -1 );
|
|
|
|
}
|
|
|
|
|
2009-10-01 16:46:13 +00:00
|
|
|
if( m_SelGridBox )
|
2009-11-07 14:36:54 +00:00
|
|
|
m_SelGridBox->SetSelection( m_LastGridSizeId );
|
2009-10-01 16:46:13 +00:00
|
|
|
|
|
|
|
m_TrackAndViasSizesList_Changed = false;
|
2010-04-17 10:45:00 +00:00
|
|
|
|
|
|
|
m_AuxiliaryToolBar->Refresh();
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-11-20 14:55:20 +00:00
|
|
|
* Enable or disable the toolbar's controls, depending on the current
|
|
|
|
* state.
|
|
|
|
*
|
|
|
|
* @todo: All of this should be perform in appropriate wxUpdateUIEvent
|
|
|
|
* handles. This is not how it how updating user interface controls
|
|
|
|
* is handle in wxWidgets.
|
2009-09-27 11:00:21 +00:00
|
|
|
*/
|
2009-11-20 14:55:20 +00:00
|
|
|
void WinEDA_PcbFrame::SetToolbars()
|
2009-09-27 11:00:21 +00:00
|
|
|
{
|
|
|
|
bool state;
|
|
|
|
|
|
|
|
if( m_ID_current_state == ID_TRACK_BUTT )
|
|
|
|
{
|
|
|
|
if( Drc_On )
|
|
|
|
DrawPanel->SetCursor( wxCursor( wxCURSOR_PENCIL ) );
|
|
|
|
else
|
|
|
|
DrawPanel->SetCursor( wxCursor( wxCURSOR_QUESTION_ARROW ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( m_HToolBar == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_HToolBar->EnableTool( ID_SAVE_BOARD, GetScreen()->IsModify() );
|
|
|
|
|
|
|
|
state = GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE;
|
|
|
|
m_HToolBar->EnableTool( wxID_CUT, state );
|
|
|
|
m_HToolBar->EnableTool( wxID_COPY, state );
|
|
|
|
|
|
|
|
m_HToolBar->EnableTool( wxID_PASTE, false );
|
|
|
|
|
|
|
|
state = GetScreen()->GetUndoCommandCount() > 0;
|
2010-01-19 20:43:44 +00:00
|
|
|
m_HToolBar->EnableTool( wxID_UNDO, state );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
state = GetScreen()->GetRedoCommandCount() > 0;
|
2010-01-19 20:43:44 +00:00
|
|
|
m_HToolBar->EnableTool( wxID_REDO, state );
|
2010-04-17 10:45:00 +00:00
|
|
|
m_HToolBar->Refresh();
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
if( m_OptionsToolBar )
|
|
|
|
{
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_DRC_OFF,
|
|
|
|
!Drc_On );
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_DRC_OFF,
|
2009-11-20 14:55:20 +00:00
|
|
|
Drc_On ?
|
|
|
|
_( "Disable design rule checking" ) :
|
|
|
|
_( "Enable design rule checking" ) );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM,
|
|
|
|
g_UnitMetric == MILLIMETRE ? TRUE : false );
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
|
|
|
|
g_UnitMetric == INCHES ? TRUE : false );
|
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD,
|
|
|
|
DisplayOpt.DisplayPolarCood );
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD,
|
2009-11-20 14:55:20 +00:00
|
|
|
DisplayOpt.DisplayPolarCood ?
|
|
|
|
_( "Display rectangular coordinates" ) :
|
|
|
|
_( "Display polar coordinates" ) );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2010-02-01 21:23:27 +00:00
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, IsGridVisible( ) );
|
2009-09-27 11:00:21 +00:00
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID,
|
2010-02-01 21:23:27 +00:00
|
|
|
IsGridVisible( ) ?
|
2009-11-20 14:55:20 +00:00
|
|
|
_( "Hide grid" ) :
|
|
|
|
_( "Show grid" ) );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
|
|
|
|
m_CursorShape );
|
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_RATSNEST,
|
2010-01-29 20:36:12 +00:00
|
|
|
GetBoard()->IsElementVisible(RATSNEST_VISIBLE) );
|
2009-09-27 11:00:21 +00:00
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_RATSNEST,
|
2010-01-29 20:36:12 +00:00
|
|
|
GetBoard()->IsElementVisible(RATSNEST_VISIBLE) ?
|
2009-11-20 14:55:20 +00:00
|
|
|
_( "Hide board ratsnest" ) :
|
|
|
|
_( "Show board ratsnest" ) );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST,
|
|
|
|
g_Show_Module_Ratsnest );
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST,
|
2009-11-20 14:55:20 +00:00
|
|
|
g_Show_Module_Ratsnest ?
|
|
|
|
_( "Hide module ratsnest" ) :
|
|
|
|
_( "Show module ratsnest" ) );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_AUTO_DEL_TRACK,
|
|
|
|
g_AutoDeleteOldTrack );
|
|
|
|
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_AUTO_DEL_TRACK,
|
2009-11-20 14:55:20 +00:00
|
|
|
g_AutoDeleteOldTrack ?
|
|
|
|
_( "Disable auto delete old track" ) :
|
|
|
|
_( "Enable auto delete old track" ) );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
|
|
|
!m_DisplayPadFill );
|
|
|
|
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
2009-11-20 14:55:20 +00:00
|
|
|
m_DisplayPadFill ?
|
|
|
|
_( "Show pads in outline mode" ) :
|
|
|
|
_( "Show pads in fill mode" ) );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2009-09-29 04:44:35 +00:00
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
|
|
|
|
!m_DisplayViaFill );
|
|
|
|
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
|
2009-11-20 14:55:20 +00:00
|
|
|
m_DisplayViaFill ?
|
|
|
|
_( "Show vias in outline mode" ) :
|
|
|
|
_( "Show vias in fill mode" ) );
|
2009-09-29 04:44:35 +00:00
|
|
|
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
|
|
|
|
!m_DisplayPcbTrackFill );
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
|
2009-11-20 14:55:20 +00:00
|
|
|
m_DisplayPcbTrackFill ?
|
|
|
|
_( "Show tracks in outline mode" ) :
|
|
|
|
_( "Show tracks in fill mode" ) );
|
2009-09-27 11:00:21 +00:00
|
|
|
|
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
|
|
|
|
DisplayOpt.ContrastModeDisplay );
|
|
|
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
|
2009-11-20 14:55:20 +00:00
|
|
|
DisplayOpt.ContrastModeDisplay ?
|
|
|
|
_( "Normal contrast display mode" ) :
|
|
|
|
_( "High contrast display mode" ) );
|
2009-10-10 01:25:53 +00:00
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1,
|
|
|
|
m_auimgr.GetPane(wxT("m_AuxVToolBar")).IsShown() );
|
2010-04-17 10:45:00 +00:00
|
|
|
m_OptionsToolBar->Refresh();
|
2009-09-27 11:00:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_AuxiliaryToolBar )
|
2009-10-03 17:57:57 +00:00
|
|
|
AuxiliaryToolBar_Update_UI();
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2010-01-24 02:05:07 +00:00
|
|
|
syncLayerBox();
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
PrepareLayerIndicator();
|
|
|
|
DisplayUnitsMsg();
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2009-11-02 22:24:55 +00:00
|
|
|
if(m_auimgr.GetManagedWindow())
|
|
|
|
m_auimgr.Update();
|
2009-09-27 11:00:21 +00:00
|
|
|
}
|