tool_pcb.cpp 28 KB
Newer Older
1 2 3
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
4 5 6 7
 * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
 * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you may find one here:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * or you may search the http://www.gnu.org website for the version 2 license,
 * or you may write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

27 28 29 30
/**
 * @file tool_pcb.cpp
 * @brief PCB editor tool bars
 */
31

32
#include <fctsys.h>
33
#include <kiface_i.h>
34 35 36 37 38
#include <help_common_strings.h>
#include <dialog_helpers.h>
#include <class_layer_box_selector.h>
#include <colors_selection.h>
#include <wxPcbStruct.h>
39

40
#include <class_board.h>
41

42 43 44
#include <pcbnew.h>
#include <pcbnew_id.h>
#include <hotkeys.h>
45
#include <class_pcb_layer_box_selector.h>
46

47
#include <wx/wupdlock.h>
48

49 50

#ifdef __UNIX__
51
#define LISTBOX_WIDTH 150
52
#else
53
#define LISTBOX_WIDTH 130
54 55
#endif

dickelbeck's avatar
dickelbeck committed
56 57
#define SEL_LAYER_HELP _( \
        "Show active layer selections\nand select layer pair for route and place via" )
58

59

60
/* Data to build the layer pair indicator button */
61
static wxBitmap*  LayerPairBitmap = NULL;
dickelbeck's avatar
dickelbeck committed
62

63 64 65
#define BM_LAYERICON_SIZE 24
static const char s_BitmapLayerIcon[BM_LAYERICON_SIZE][BM_LAYERICON_SIZE] =
{
dickelbeck's avatar
dickelbeck committed
66
    // 0 = draw pixel with active layer color
67
    // 1 = draw pixel with top layer color (top/bottom layer used inautoroute and place via)
dickelbeck's avatar
dickelbeck committed
68 69
    // 2 = draw pixel with bottom layer color
    // 3 = draw pixel with via color
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 1, 1, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0 },
    { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 0, 1, 1, 1, 1, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
    { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
    { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 1, 1, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
92
};
dickelbeck's avatar
dickelbeck committed
93 94


95
/* Draw the icon for the "Select layer pair" bitmap tool
dickelbeck's avatar
dickelbeck committed
96
 */
97
void PCB_EDIT_FRAME::PrepareLayerIndicator()
98
{
dickelbeck's avatar
dickelbeck committed
99
    int        ii, jj;
100
    EDA_COLOR_T active_layer_color, Route_Layer_TOP_color,
dickelbeck's avatar
dickelbeck committed
101 102
               Route_Layer_BOTTOM_color, via_color;
    bool       change = false;
103
    bool first_call = LayerPairBitmap == NULL;
dickelbeck's avatar
dickelbeck committed
104 105 106 107 108

    static int previous_active_layer_color, previous_Route_Layer_TOP_color,
               previous_Route_Layer_BOTTOM_color, previous_via_color;

    /* get colors, and redraw bitmap button only on changes */
109
    active_layer_color = GetBoard()->GetLayerColor(GetActiveLayer());
110

dickelbeck's avatar
dickelbeck committed
111 112 113
    if( previous_active_layer_color != active_layer_color )
    {
        previous_active_layer_color = active_layer_color;
114
        change = true;
dickelbeck's avatar
dickelbeck committed
115
    }
116

117 118
    Route_Layer_TOP_color =
        g_ColorsSettings.GetLayerColor( ( ( PCB_SCREEN* ) GetScreen() )->m_Route_Layer_TOP );
119

dickelbeck's avatar
dickelbeck committed
120 121 122
    if( previous_Route_Layer_TOP_color != Route_Layer_TOP_color )
    {
        previous_Route_Layer_TOP_color = Route_Layer_TOP_color;
123
        change = true;
dickelbeck's avatar
dickelbeck committed
124
    }
125

126 127
    Route_Layer_BOTTOM_color =
        g_ColorsSettings.GetLayerColor( ( (PCB_SCREEN*) GetScreen() )->m_Route_Layer_BOTTOM );
128

dickelbeck's avatar
dickelbeck committed
129 130 131
    if( previous_Route_Layer_BOTTOM_color != Route_Layer_BOTTOM_color )
    {
        previous_Route_Layer_BOTTOM_color = Route_Layer_BOTTOM_color;
132
        change = true;
dickelbeck's avatar
dickelbeck committed
133
    }
134

135
    int via_type = GetDesignSettings().m_CurrentViaType;
136
    via_color = GetBoard()->GetVisibleElementColor(VIAS_VISIBLE+via_type);
137

dickelbeck's avatar
dickelbeck committed
138 139 140
    if( previous_via_color != via_color )
    {
        previous_via_color = via_color;
141
        change = true;
dickelbeck's avatar
dickelbeck committed
142 143 144 145 146
    }

    if( !change && (LayerPairBitmap != NULL) )
        return;

147
    /* Create the bitmap and its Memory DC, if not already made */
dickelbeck's avatar
dickelbeck committed
148 149
    if( LayerPairBitmap == NULL )
    {
150
        LayerPairBitmap = new wxBitmap( 24, 24 );
dickelbeck's avatar
dickelbeck committed
151 152
    }

153 154
    /* Draw the icon, with colors according to the active layer and layer
     * pairs for via command (change layer)
dickelbeck's avatar
dickelbeck committed
155 156 157 158
     */
    wxMemoryDC iconDC;
    iconDC.SelectObject( *LayerPairBitmap );
    wxPen      pen;
159
    int buttonColor = -1;
160

161
    for( ii = 0; ii < BM_LAYERICON_SIZE; ii++ )
dickelbeck's avatar
dickelbeck committed
162
    {
163
        for( jj = 0; jj < BM_LAYERICON_SIZE; jj++ )
dickelbeck's avatar
dickelbeck committed
164
        {
165
            if( s_BitmapLayerIcon[ii][jj] != buttonColor )
dickelbeck's avatar
dickelbeck committed
166
            {
167
                switch( s_BitmapLayerIcon[ii][jj] )
dickelbeck's avatar
dickelbeck committed
168 169 170
                {
                default:
                case 0:
171
                    pen.SetColour( MakeColour( active_layer_color ) );
dickelbeck's avatar
dickelbeck committed
172 173 174
                    break;

                case 1:
175
                    pen.SetColour( MakeColour( Route_Layer_TOP_color) );
dickelbeck's avatar
dickelbeck committed
176 177 178
                    break;

                case 2:
179
                    pen.SetColour( MakeColour( Route_Layer_BOTTOM_color ) );
dickelbeck's avatar
dickelbeck committed
180 181 182
                    break;

                case 3:
183
                    pen.SetColour( MakeColour( via_color ) );
dickelbeck's avatar
dickelbeck committed
184 185 186
                    break;
                }

187
                buttonColor = s_BitmapLayerIcon[ii][jj];
dickelbeck's avatar
dickelbeck committed
188 189
                iconDC.SetPen( pen );
            }
190

dickelbeck's avatar
dickelbeck committed
191 192 193 194 195 196 197 198
            iconDC.DrawPoint( jj, ii );
        }
    }

    /* Deselect the Tool Bitmap from DC,
     *  in order to delete the MemoryDC safely without deleting the bitmap */
    iconDC.SelectObject( wxNullBitmap );

199
    if( m_mainToolBar && ! first_call )
dickelbeck's avatar
dickelbeck committed
200
    {
201 202
        m_mainToolBar->SetToolBitmap( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, *LayerPairBitmap );
        m_mainToolBar->Refresh();
dickelbeck's avatar
dickelbeck committed
203
    }
204 205 206
}


207
/* Creates or updates the main horizontal toolbar for the board editor
208
*/
209
void PCB_EDIT_FRAME::ReCreateHToolbar()
210
{
211
    wxString msg;
dickelbeck's avatar
dickelbeck committed
212

213
    if( m_mainToolBar )
dickelbeck's avatar
dickelbeck committed
214 215
        return;

216
    wxWindowUpdateLocker dummy( this );
dickelbeck's avatar
dickelbeck committed
217

218 219
    m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
                                      wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
220

dickelbeck's avatar
dickelbeck committed
221
    // Set up toolbar
222 223 224 225 226 227 228 229
    if( Kiface().IsSingle() )
    {
        m_mainToolBar->AddTool( ID_NEW_BOARD, wxEmptyString, KiBitmap( new_pcb_xpm ),
                                _( "New board" ) );
        m_mainToolBar->AddTool( ID_LOAD_FILE, wxEmptyString, KiBitmap( open_brd_file_xpm ),
                                _( "Open existing board" ) );
    }

230 231
    m_mainToolBar->AddTool( ID_SAVE_BOARD, wxEmptyString, KiBitmap( save_xpm ),
                            _( "Save board" ) );
dickelbeck's avatar
dickelbeck committed
232

233 234 235
    m_mainToolBar->AddSeparator();
    m_mainToolBar->AddTool( ID_SHEET_SET, wxEmptyString, KiBitmap( sheetset_xpm ),
                            _( "Page settings for paper size and texts" ) );
dickelbeck's avatar
dickelbeck committed
236

237
    m_mainToolBar->AddSeparator();
238
    m_mainToolBar->AddTool( ID_OPEN_MODULE_EDITOR, wxEmptyString,
239
                            KiBitmap( module_editor_xpm ),
240
                            _( "Open module editor" ) );
dickelbeck's avatar
dickelbeck committed
241

242 243
    m_mainToolBar->AddTool( ID_OPEN_MODULE_VIEWER, wxEmptyString,
                            KiBitmap( modview_icon_xpm ),
244
                            _( "Open module viewer" ) );
245

246
    m_mainToolBar->AddSeparator();
247
    msg = AddHotkeyName( HELP_UNDO, g_Board_Editor_Hokeys_Descr, HK_UNDO, IS_COMMENT );
248
    m_mainToolBar->AddTool( wxID_UNDO, wxEmptyString, KiBitmap( undo_xpm ), HELP_UNDO );
249
    msg = AddHotkeyName( HELP_REDO, g_Board_Editor_Hokeys_Descr, HK_REDO, IS_COMMENT );
250
    m_mainToolBar->AddTool( wxID_REDO, wxEmptyString, KiBitmap( redo_xpm ), HELP_REDO );
dickelbeck's avatar
dickelbeck committed
251

252 253 254 255 256
    m_mainToolBar->AddSeparator();
    m_mainToolBar->AddTool( wxID_PRINT, wxEmptyString, KiBitmap( print_button_xpm ),
                            _( "Print board" ) );
    m_mainToolBar->AddTool( ID_GEN_PLOT, wxEmptyString, KiBitmap( plot_xpm ),
                            _( "Plot (HPGL, PostScript, or GERBER format)" ) );
dickelbeck's avatar
dickelbeck committed
257

258
    m_mainToolBar->AddSeparator();
259
    msg = AddHotkeyName( HELP_ZOOM_IN, g_Board_Editor_Hokeys_Descr, HK_ZOOM_IN, IS_COMMENT );
260
    m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ), msg );
261

262
    msg = AddHotkeyName( HELP_ZOOM_OUT, g_Board_Editor_Hokeys_Descr, HK_ZOOM_OUT, IS_COMMENT );
263
    m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ), msg );
264

265 266 267
    msg = AddHotkeyName( HELP_ZOOM_REDRAW, g_Board_Editor_Hokeys_Descr, HK_ZOOM_REDRAW,
                         IS_COMMENT );
    m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiBitmap( zoom_redraw_xpm ), msg );
268

269
    msg = AddHotkeyName( HELP_ZOOM_FIT, g_Board_Editor_Hokeys_Descr, HK_ZOOM_AUTO, IS_COMMENT );
270
    m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ), msg );
dickelbeck's avatar
dickelbeck committed
271

272
    m_mainToolBar->AddSeparator();
273
    msg = AddHotkeyName( HELP_FIND, g_Board_Editor_Hokeys_Descr, HK_FIND_ITEM, IS_COMMENT );
274
    m_mainToolBar->AddTool( ID_FIND_ITEMS, wxEmptyString, KiBitmap( find_xpm ), msg );
dickelbeck's avatar
dickelbeck committed
275

276 277 278 279 280
    m_mainToolBar->AddSeparator();
    m_mainToolBar->AddTool( ID_GET_NETLIST, wxEmptyString, KiBitmap( netlist_xpm ),
                            _( "Read netlist" ) );
    m_mainToolBar->AddTool( ID_DRC_CONTROL, wxEmptyString, KiBitmap( erc_xpm ),
                            _( "Perform design rules check" ) );
dickelbeck's avatar
dickelbeck committed
281

282
    m_mainToolBar->AddSeparator();
283

284
    if( m_SelLayerBox == NULL )
285
    {
286
        m_SelLayerBox = new PCB_LAYER_BOX_SELECTOR( m_mainToolBar, ID_TOOLBARH_PCB_SELECT_LAYER );
287 288
        m_SelLayerBox->SetBoardFrame( this );
    }
Dick Hollenbeck's avatar
Dick Hollenbeck committed
289

290
    ReCreateLayerBox( false );
291
    m_mainToolBar->AddControl( m_SelLayerBox );
292

293 294
    PrepareLayerIndicator();    // Initialize the bitmap with current
                                // active layer colors for the next tool
295 296
    m_mainToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, wxEmptyString,
                            *LayerPairBitmap, SEL_LAYER_HELP );
dickelbeck's avatar
dickelbeck committed
297

298 299 300 301 302 303
    m_mainToolBar->AddSeparator();
    m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_MODULE, wxEmptyString, KiBitmap( mode_module_xpm ),
                            _( "Mode footprint: manual and automatic move and place modules" ),
                            wxITEM_CHECK );
    m_mainToolBar->AddTool( ID_TOOLBARH_PCB_MODE_TRACKS, wxEmptyString, KiBitmap( mode_track_xpm ),
                            _( "Mode track: autorouting" ), wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
304

dickelbeck's avatar
dickelbeck committed
305
    // Fast call to FreeROUTE Web Bases router
306 307 308 309
    m_mainToolBar->AddSeparator();
    m_mainToolBar->AddTool( ID_TOOLBARH_PCB_FREEROUTE_ACCESS, wxEmptyString,
                            KiBitmap( web_support_xpm ),
                            _( "Fast access to the Web Based FreeROUTE advanced router" ) );
dickelbeck's avatar
dickelbeck committed
310

311 312
    // Access to the scripting console
#ifdef KICAD_SCRIPTING_WXPYTHON
313 314
    m_mainToolBar->AddSeparator();

315
    m_mainToolBar->AddTool( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, wxEmptyString,
316
                            KiBitmap( py_script_xpm ),
317 318
                            _( "Show/Hide the Python Scripting console" ),
                            wxITEM_CHECK );
319
#endif
320

321
    // after adding the buttons to the toolbar, must call Realize() to reflect the changes
322
    m_mainToolBar->Realize();
323 324
}

dickelbeck's avatar
dickelbeck committed
325

326
void PCB_EDIT_FRAME::ReCreateOptToolbar()
327
{
328
    if( m_optionsToolBar )
dickelbeck's avatar
dickelbeck committed
329 330
        return;

331
    wxWindowUpdateLocker dummy( this );
332

333 334
    m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
                                         wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
dickelbeck's avatar
dickelbeck committed
335

336
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_DRC_OFF, wxEmptyString, KiBitmap( drc_off_xpm ),
337
                               _( "Enable design rule checking" ), wxITEM_CHECK );
338
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, KiBitmap( grid_xpm ),
339
                               _( "Hide grid" ), wxITEM_CHECK );
340
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
341
                               KiBitmap( polar_coord_xpm ),
342
                               _( "Display polar coordinates" ), wxITEM_CHECK );
343
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
344
                               KiBitmap( unit_inch_xpm ),
345
                               _( "Units in inches" ), wxITEM_CHECK );
346
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
347
                               KiBitmap( unit_mm_xpm ),
348
                               _( "Units in millimeters" ), wxITEM_CHECK );
349
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
350
                               KiBitmap( cursor_shape_xpm ),
351
                               _( "Change cursor shape" ), wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
352

353 354
    m_optionsToolBar->AddSeparator();
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_RATSNEST, wxEmptyString,
355
                               KiBitmap( general_ratsnest_xpm ),
356
                               _( "Show board ratsnest" ), wxITEM_CHECK );
357
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_RATSNEST, wxEmptyString,
358
                               KiBitmap( local_ratsnest_xpm ),
359
                               _( "Show module ratsnest when moving" ),
360
                               wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
361

362 363
    m_optionsToolBar->AddSeparator();
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_AUTO_DEL_TRACK, wxEmptyString,
364
                               KiBitmap( auto_delete_track_xpm ),
365 366
                               _( "Enable automatic track deletion" ),
                               wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
367

368
    m_optionsToolBar->AddSeparator();
369 370 371 372 373 374 375 376
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES, wxEmptyString, KiBitmap( show_zone_xpm ),
                               _( "Show filled areas in zones" ), wxITEM_CHECK );
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES_DISABLE, wxEmptyString,
                               KiBitmap( show_zone_disable_xpm ),
                               _( "Do not show filled areas in zones" ) , wxITEM_CHECK );
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY, wxEmptyString,
                               KiBitmap( show_zone_outline_only_xpm ),
                               _( "Show outlines of filled areas only in zones" ), wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
377

378 379
    m_optionsToolBar->AddSeparator();
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
380
                               KiBitmap( pad_sketch_xpm ),
381
                               _( "Show pads in outline mode" ), wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
382

383
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, wxEmptyString,
384
                               KiBitmap( via_sketch_xpm ),
385
                               _( "Show vias in outline mode" ), wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
386

387
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString,
388
                               KiBitmap( showtrack_xpm ),
389 390
                               _( "Show tracks in outline mode" ),
                               wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
391

392
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE, wxEmptyString,
393
                               KiBitmap( palette_xpm ),
394
                               _( "Enable high contrast display mode" ),
395
                               wxITEM_CHECK );
396

charras's avatar
charras committed
397
    // Tools to show/hide toolbars:
398 399
    m_optionsToolBar->AddSeparator();
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
400
                               wxEmptyString,
401
                               KiBitmap( layers_manager_xpm ),
402 403
                               HELP_SHOW_HIDE_LAYERMANAGER,
                               wxITEM_CHECK );
404
    m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE,
405
                               wxEmptyString,
406
                               KiBitmap( mw_toolbar_xpm ),
407
                               HELP_SHOW_HIDE_MICROWAVE_TOOLS,
dickelbeck's avatar
dickelbeck committed
408
                               wxITEM_CHECK );
409

410

411 412
    m_optionsToolBar->AddSeparator();
    m_optionsToolBar->Realize();
413 414 415 416
}


/* Create the main vertical right toolbar, showing usual tools
dickelbeck's avatar
dickelbeck committed
417
 */
418
void PCB_EDIT_FRAME::ReCreateVToolbar()
419
{
420
    if( m_drawToolBar )
dickelbeck's avatar
dickelbeck committed
421
        return;
422

423
    wxWindowUpdateLocker dummy( this );
424

425 426
    m_drawToolBar = new wxAuiToolBar( this, ID_V_TOOLBAR, wxDefaultPosition, wxDefaultSize,
                                      wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
427

dickelbeck's avatar
dickelbeck committed
428
    // Set up toolbar
429 430 431
    m_drawToolBar->AddTool( ID_NO_TOOL_SELECTED, wxEmptyString, KiBitmap( cursor_xpm ),
                            wxEmptyString, wxITEM_CHECK );
    m_drawToolBar->AddSeparator();
432

433 434
    m_drawToolBar->AddTool( ID_PCB_HIGHLIGHT_BUTT, wxEmptyString, KiBitmap( net_highlight_xpm ),
                            _( "Highlight net" ), wxITEM_CHECK );
435

436 437 438
    m_drawToolBar->AddTool( ID_PCB_SHOW_1_RATSNEST_BUTT, wxEmptyString,
                            KiBitmap( tool_ratsnest_xpm ),
                            _( "Display local ratsnest" ), wxITEM_CHECK );
439

440 441 442
    m_drawToolBar->AddSeparator();
    m_drawToolBar->AddTool( ID_PCB_MODULE_BUTT, wxEmptyString, KiBitmap( module_xpm ),
                            _( "Add modules" ), wxITEM_CHECK );
443

444 445
    m_drawToolBar->AddTool( ID_TRACK_BUTT, wxEmptyString, KiBitmap( add_tracks_xpm ),
                            _( "Add tracks and vias" ), wxITEM_CHECK );
446

447 448
    m_drawToolBar->AddTool( ID_PCB_ZONES_BUTT, wxEmptyString, KiBitmap( add_zone_xpm ),
                            _( "Add filled zones" ), wxITEM_CHECK );
449

450 451 452 453
    m_drawToolBar->AddTool( ID_PCB_KEEPOUT_AREA_BUTT, wxEmptyString,
                            KiBitmap( add_keepout_area_xpm ),
                            _( "Add keepout areas" ), wxITEM_CHECK );

454 455 456
    m_drawToolBar->AddSeparator();
    m_drawToolBar->AddTool( ID_PCB_ADD_LINE_BUTT, wxEmptyString, KiBitmap( add_dashed_line_xpm ),
                            _( "Add graphic line or polygon" ), wxITEM_CHECK );
457

458 459
    m_drawToolBar->AddTool( ID_PCB_CIRCLE_BUTT, wxEmptyString, KiBitmap( add_circle_xpm ),
                            _( "Add graphic circle" ), wxITEM_CHECK );
460

461 462
    m_drawToolBar->AddTool( ID_PCB_ARC_BUTT, wxEmptyString, KiBitmap( add_arc_xpm ),
                            _( "Add graphic arc" ), wxITEM_CHECK );
463

464 465
    m_drawToolBar->AddTool( ID_PCB_ADD_TEXT_BUTT, wxEmptyString, KiBitmap( add_text_xpm ),
                            _( "Add text on copper layers or graphic text" ), wxITEM_CHECK );
466

467 468 469
    m_drawToolBar->AddSeparator();
    m_drawToolBar->AddTool( ID_PCB_DIMENSION_BUTT, wxEmptyString, KiBitmap( add_dimension_xpm ),
                            _( "Add dimension" ), wxITEM_CHECK );
470

471 472
    m_drawToolBar->AddTool( ID_PCB_MIRE_BUTT, wxEmptyString, KiBitmap( add_mires_xpm ),
                            _( "Add layer alignment target" ), wxITEM_CHECK );
473

474
    m_drawToolBar->AddSeparator();
475
    m_drawToolBar->AddTool( ID_PCB_DELETE_ITEM_BUTT, wxEmptyString, KiBitmap( delete_xpm ),
476
                            _( "Delete items" ), wxITEM_CHECK );
477

478 479 480 481 482
    m_drawToolBar->AddSeparator();
    m_drawToolBar->AddTool( ID_PCB_PLACE_OFFSET_COORD_BUTT, wxEmptyString,
                            KiBitmap( pcb_offset_xpm ),
                            _( "Place the origin point for drill and place files" ),
                            wxITEM_CHECK );
483

484 485 486 487
    m_drawToolBar->AddTool( ID_PCB_PLACE_GRID_COORD_BUTT, wxEmptyString,
                            KiBitmap( grid_select_axis_xpm ),
                            _( "Set the origin point for the grid" ),
                            wxITEM_CHECK );
488

489
    m_drawToolBar->Realize();
490 491 492
}


493
/* Create the auxiliary vertical right toolbar, showing tools for microwave applications
dickelbeck's avatar
dickelbeck committed
494
 */
495
void PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar()
496
{
497
    if( m_microWaveToolBar )
dickelbeck's avatar
dickelbeck committed
498 499
        return;

500 501
    wxWindowUpdateLocker dummy(this);

502 503 504
    m_microWaveToolBar = new wxAuiToolBar( this, ID_MICROWAVE_V_TOOLBAR, wxDefaultPosition,
                                           wxDefaultSize,
                                           wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_VERTICAL );
dickelbeck's avatar
dickelbeck committed
505 506

    // Set up toolbar
507 508
    m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_SELF_CMD, wxEmptyString,
                                 KiBitmap( mw_add_line_xpm ),
509
                                 _( "Create line of specified length for microwave applications" ),
510
                                 wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
511

512 513
    m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_GAP_CMD, wxEmptyString,
                                 KiBitmap( mw_add_gap_xpm ),
514
                                 _( "Create gap of specified length for microwave applications" ),
515
                                 wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
516

517
    m_microWaveToolBar->AddSeparator();
dickelbeck's avatar
dickelbeck committed
518

519 520
    m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_CMD, wxEmptyString,
                                 KiBitmap( mw_add_stub_xpm ),
521
                                 _( "Create stub of specified length for microwave applications" ),
522
                                 wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
523

524 525
    m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, wxEmptyString,
                                 KiBitmap( mw_add_stub_arc_xpm ),
526
                                 _( "Create stub (arc) of specified length for microwave applications" ),
527
                                 wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
528

529 530
    m_microWaveToolBar->AddTool( ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD, wxEmptyString,
                                 KiBitmap( mw_add_shape_xpm ),
531
                                 _( "Create a polynomial shape for microwave applications" ),
532
                                 wxITEM_CHECK );
dickelbeck's avatar
dickelbeck committed
533

534
    m_microWaveToolBar->Realize();
535 536
}

dickelbeck's avatar
dickelbeck committed
537

charras's avatar
charras committed
538
/* Creates auxiliary horizontal toolbar
539 540 541 542
 * displays:
 * existing track width choice
 * selection for auto track width
 * existing via size choice
charras's avatar
charras committed
543
 * Current strategy (to choose the track and via sizes)
544 545
 * grid size choice
 * zoom level choice
dickelbeck's avatar
dickelbeck committed
546
 */
547
void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar()
548
{
dickelbeck's avatar
dickelbeck committed
549 550
    wxString msg;

551
    wxWindowUpdateLocker dummy( this );
552

553
    if( m_auxiliaryToolBar )
554 555
        return;

556 557
    m_auxiliaryToolBar = new wxAuiToolBar( this, ID_AUX_TOOLBAR, wxDefaultPosition, wxDefaultSize,
                                           wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_HORZ_LAYOUT );
558 559 560 561

    /* Set up toolbar items */

    // Creates box to display and choose tracks widths:
562
    m_SelTrackWidthBox = new wxComboBox( m_auxiliaryToolBar,
563 564 565 566 567
                                         ID_AUX_TOOLBAR_PCB_TRACK_WIDTH,
                                         wxEmptyString,
                                         wxPoint( -1, -1 ),
                                         wxSize( LISTBOX_WIDTH, -1 ),
                                         0, NULL, wxCB_READONLY );
568 569
    m_auxiliaryToolBar->AddControl( m_SelTrackWidthBox );
    m_auxiliaryToolBar->AddSeparator();
570 571

    // Creates box to display and choose vias diameters:
572
    m_SelViaSizeBox = new wxComboBox( m_auxiliaryToolBar,
573 574 575 576 577
                                      ID_AUX_TOOLBAR_PCB_VIA_SIZE,
                                      wxEmptyString,
                                      wxPoint( -1, -1 ),
                                      wxSize( (LISTBOX_WIDTH*12)/10, -1 ),
                                      0, NULL, wxCB_READONLY );
578 579
    m_auxiliaryToolBar->AddControl( m_SelViaSizeBox );
    m_auxiliaryToolBar->AddSeparator();
580 581

    // Creates box to display and choose strategy to handle tracks an vias sizes:
582
    m_auxiliaryToolBar->AddTool( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH,
583
                                 wxEmptyString,
584
                                 KiBitmap( auto_track_width_xpm ),
585
                                 _( "Auto track width: when starting on \
586
an existing track use its width\notherwise, use current width setting" ),
587 588 589
                                 wxITEM_CHECK );

    // Add the box to display and select the current grid size:
590 591 592 593 594 595 596 597
    m_auxiliaryToolBar->AddSeparator();
    m_gridSelectBox = new wxComboBox( m_auxiliaryToolBar,
                                      ID_ON_GRID_SELECT,
                                      wxEmptyString,
                                      wxPoint( -1, -1 ),
                                      wxSize( LISTBOX_WIDTH, -1 ),
                                      0, NULL, wxCB_READONLY );
    m_auxiliaryToolBar->AddControl( m_gridSelectBox );
598 599

    //  Add the box to display and select the current Zoom
600 601 602 603 604 605 606 607
    m_auxiliaryToolBar->AddSeparator();
    m_zoomSelectBox = new wxComboBox( m_auxiliaryToolBar,
                                      ID_ON_ZOOM_SELECT,
                                      wxEmptyString,
                                      wxPoint( -1, -1 ),
                                      wxSize( LISTBOX_WIDTH, -1 ),
                                      0, NULL, wxCB_READONLY );
    m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
dickelbeck's avatar
dickelbeck committed
608

609 610 611 612
    updateZoomSelectBox();
    updateGridSelectBox();
    updateTraceWidthSelectBox();
    updateViaSizeSelectBox();
dickelbeck's avatar
dickelbeck committed
613

614
    // after adding the buttons to the toolbar, must call Realize()
615 616
    m_auxiliaryToolBar->Realize();
    m_auxiliaryToolBar->AddSeparator();
617 618 619
}


620
void PCB_EDIT_FRAME::updateTraceWidthSelectBox()
621 622 623 624 625 626 627 628
{
    if( m_SelTrackWidthBox == NULL )
        return;

    wxString msg;

    m_SelTrackWidthBox->Clear();

629
    for( unsigned ii = 0; ii < GetDesignSettings().m_TrackWidthList.size(); ii++ )
630
    {
631
        msg = _( "Track " ) + CoordinateToString( GetDesignSettings().m_TrackWidthList[ii], true );
632

633 634
        if( ii == 0 )
            msg << _( " *" );
635

636
        m_SelTrackWidthBox->Append( msg );
637
    }
638

639 640
    if( GetDesignSettings().GetTrackWidthIndex() >= GetDesignSettings().m_TrackWidthList.size() )
        GetDesignSettings().SetTrackWidthIndex( 0 );
641

642
    m_SelTrackWidthBox->SetSelection( GetDesignSettings().GetTrackWidthIndex() );
643 644
}

dickelbeck's avatar
dickelbeck committed
645

646
void PCB_EDIT_FRAME::updateViaSizeSelectBox()
647 648 649 650 651 652 653 654
{
    if( m_SelViaSizeBox == NULL )
        return;

    wxString msg;

    m_SelViaSizeBox->Clear();

655
    for( unsigned ii = 0; ii < GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
dickelbeck's avatar
dickelbeck committed
656
    {
657
        msg = _( "Via " );
658
        msg << CoordinateToString( GetDesignSettings().m_ViasDimensionsList[ii].m_Diameter, true );
659

660
        if( GetDesignSettings().m_ViasDimensionsList[ii].m_Drill )
661
            msg  << wxT("/ ")
662
                 << CoordinateToString( GetDesignSettings().m_ViasDimensionsList[ii].m_Drill, true );
663

664 665
        if( ii == 0 )
            msg << _( " *" );
666

667
        m_SelViaSizeBox->Append( msg );
dickelbeck's avatar
dickelbeck committed
668
    }
669

670 671
    if( GetDesignSettings().GetViaSizeIndex() >= GetDesignSettings().m_ViasDimensionsList.size() )
        GetDesignSettings().SetViaSizeIndex( 0 );
672

673
    m_SelViaSizeBox->SetSelection( GetDesignSettings().GetViaSizeIndex() );
674
}
dickelbeck's avatar
dickelbeck committed
675

676

677
void PCB_EDIT_FRAME::ReCreateLayerBox( bool aForceResizeToolbar )
678
{
679 680
    if( m_SelLayerBox == NULL || m_mainToolBar == NULL )
        return;
681

682
    m_SelLayerBox->SetToolTip( _( "+/- to switch" ) );
683
    m_SelLayerBox->m_hotkeys = g_Board_Editor_Hokeys_Descr;
684
    m_SelLayerBox->Resync();
dickelbeck's avatar
dickelbeck committed
685

686 687 688 689 690 691
    if( aForceResizeToolbar )
    {
        // the layer box can have its size changed
        // Update the aui manager, to take in account the new size
        m_auimgr.Update();
    }
692
}