1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/****************************************************************
* toolbars_update_user_interface.cpp
****************************************************************/
/*
* function to update toolbars UI after changing parameters
*/
#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"
#include "class_board_design_settings.h"
/* helper to convert an integer value to a string, using mils or mm
* according to g_UserUnit value
*/
static wxString ReturnStringValue( int aValue )
{
wxString text;
const wxChar* format;
double value = To_User_Unit( g_UserUnit, aValue, PCB_INTERNAL_UNIT );
if( g_UserUnit == INCHES )
{
format = wxT( " %.1f" );
value *= 1000;
}
else
format = wxT( " %.3f" );
text.Printf( format, value );
if( g_UserUnit == INCHES )
text += _( " mils" );
else
text += _( " mm" );
return text;
}
/**
* Function AuxiliaryToolBar_DesignRules_Update_UI
* update the displayed values: track widths, via sizes, clearance, Netclass name
* used when a netclass is selected
*/
void WinEDA_PcbFrame::AuxiliaryToolBar_DesignRules_Update_UI()
{
wxString nclname = GetBoard()->m_CurrentNetClassName;
wxString msg = _( "NetClass: " ) + nclname;
m_NetClassSelectedBox->Clear();
m_NetClassSelectedBox->AppendText( msg );
NETCLASS* netclass = GetBoard()->m_NetClasses.Find( nclname );
if( m_ClearanceBox )
{
wxString msg = _( "Clearance" ) + ReturnStringValue( netclass->GetClearance() );
m_ClearanceBox->Clear();
m_ClearanceBox->AppendText( msg );
}
}
/**
* Function AuxiliaryToolBar_Update_UI
* update the displayed values on auxiliary horizontal toolbar
* (track width, via sizes, clearance ...
* 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
*/
void WinEDA_PcbFrame::AuxiliaryToolBar_Update_UI()
{
wxString msg;
AuxiliaryToolBar_DesignRules_Update_UI();
m_AuxiliaryToolBar->ToggleTool( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH,
GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth );
if( m_SelTrackWidthBox && m_TrackAndViasSizesList_Changed )
{
m_SelTrackWidthBox->Clear();
for( unsigned ii = 0; ii < GetBoard()->m_TrackWidthList.size(); ii++ )
{
msg = _( "Track" ) + ReturnStringValue( GetBoard()->m_TrackWidthList[ii] );
if( ii == 0 )
msg << _( " *" );
m_SelTrackWidthBox->Append( msg );
}
}
if( GetBoard()->m_TrackWidthSelector >= GetBoard()->m_TrackWidthList.size() )
GetBoard()->m_TrackWidthSelector = 0;
m_SelTrackWidthBox->SetSelection( GetBoard()->m_TrackWidthSelector );
if( m_SelViaSizeBox && m_TrackAndViasSizesList_Changed )
{
m_SelViaSizeBox->Clear();
for( unsigned ii = 0; ii < GetBoard()->m_ViasDimensionsList.size(); ii++ )
{
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 );
if( ii == 0 )
msg << _( " *" );
m_SelViaSizeBox->Append( msg );
}
}
if( GetBoard()->m_ViaSizeSelector >= GetBoard()->m_ViasDimensionsList.size() )
GetBoard()->m_ViaSizeSelector = 0;
m_SelViaSizeBox->SetSelection( GetBoard()->m_ViaSizeSelector );
if( m_SelZoomBox )
{
bool not_found = true;
for( unsigned jj = 0; jj < GetScreen()->m_ZoomList.GetCount(); jj++ )
{
if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[jj] )
{
m_SelZoomBox->SetSelection( jj + 1 );
not_found = false;
break;
}
}
if( not_found )
m_SelZoomBox->SetSelection( -1 );
}
if( m_SelGridBox )
m_SelGridBox->SetSelection( m_LastGridSizeId );
m_TrackAndViasSizesList_Changed = false;
m_AuxiliaryToolBar->Refresh();
}
/*
* 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.
*/
void WinEDA_PcbFrame::SetToolbars()
{
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;
m_HToolBar->EnableTool( wxID_UNDO, state );
state = GetScreen()->GetRedoCommandCount() > 0;
m_HToolBar->EnableTool( wxID_REDO, state );
m_HToolBar->Refresh();
if( m_OptionsToolBar )
{
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_DRC_OFF,
!Drc_On );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_DRC_OFF,
Drc_On ?
_( "Disable design rule checking" ) :
_( "Enable design rule checking" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UserUnit == MILLIMETRES );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UserUnit == INCHES );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD,
DisplayOpt.DisplayPolarCood );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_POLAR_COORD,
DisplayOpt.DisplayPolarCood ?
_( "Display rectangular coordinates" ) :
_( "Display polar coordinates" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, IsGridVisible( ) );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID,
IsGridVisible( ) ?
_( "Hide grid" ) :
_( "Show grid" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
m_CursorShape );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_RATSNEST,
GetBoard()->IsElementVisible(RATSNEST_VISIBLE) );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_RATSNEST,
GetBoard()->IsElementVisible(RATSNEST_VISIBLE) ?
_( "Hide board ratsnest" ) :
_( "Show board ratsnest" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST,
g_Show_Module_Ratsnest );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST,
g_Show_Module_Ratsnest ?
_( "Hide module ratsnest" ) :
_( "Show module ratsnest" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_AUTO_DEL_TRACK,
g_AutoDeleteOldTrack );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_AUTO_DEL_TRACK,
g_AutoDeleteOldTrack ?
_( "Disable auto delete old track" ) :
_( "Enable auto delete old track" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
!m_DisplayPadFill );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
m_DisplayPadFill ?
_( "Show pads in outline mode" ) :
_( "Show pads in fill mode" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
!m_DisplayViaFill );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
m_DisplayViaFill ?
_( "Show vias in outline mode" ) :
_( "Show vias in fill mode" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
!m_DisplayPcbTrackFill );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
m_DisplayPcbTrackFill ?
_( "Show tracks in outline mode" ) :
_( "Show tracks in fill mode" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
DisplayOpt.ContrastModeDisplay );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
DisplayOpt.ContrastModeDisplay ?
_( "Normal contrast display mode" ) :
_( "High contrast display mode" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1,
m_auimgr.GetPane(wxT("m_AuxVToolBar")).IsShown() );
m_OptionsToolBar->Refresh();
}
if( m_AuxiliaryToolBar )
AuxiliaryToolBar_Update_UI();
syncLayerBox();
PrepareLayerIndicator();
DisplayUnitsMsg();
}