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 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
|
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012-2015 Miguel Angel Ajo Pelayo <miguelangel@nbee.es>
* Copyright (C) 2012-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright The 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
* 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
*/
#include <kiface_base.h>
#include <pcb_draw_panel_gal.h>
#include <pcb_edit_frame.h>
#include <3d_viewer/eda_3d_viewer_frame.h>
#include <widgets/msgpanel.h>
#include <bitmaps.h>
#include <grid_tricks.h>
#include <board.h>
#include <footprint_edit_frame.h>
#include <footprint_editor_settings.h>
#include <pcbnew_id.h>
#include <pcbnew_settings.h>
#include "footprint_wizard_frame.h"
#include <wx/listbox.h>
#include <wx/statline.h>
#include <wx/tokenzr.h>
#include <wx/numformatter.h>
#include <wildcards_and_files_ext.h>
#include <base_units.h>
#include <pgm_base.h>
#include <settings/color_settings.h>
#include <settings/settings_manager.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/action_toolbar.h>
#include <tool/common_tools.h>
#include "tools/pcb_selection_tool.h"
#include "tools/pcb_control.h"
#include "tools/pcb_actions.h"
#include <python/scripting/pcb_scripting_tool.h>
BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, PCB_BASE_EDIT_FRAME )
// Window events
EVT_SIZE( FOOTPRINT_WIZARD_FRAME::OnSize )
EVT_ACTIVATE( FOOTPRINT_WIZARD_FRAME::OnActivate )
// Toolbar events
EVT_TOOL( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard )
EVT_TOOL( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, FOOTPRINT_WIZARD_FRAME::DefaultParameters )
EVT_TOOL( ID_FOOTPRINT_WIZARD_NEXT, FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS, FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE, FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )
// listbox events
EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList )
EVT_GRID_CMD_CELL_CHANGED( ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
FOOTPRINT_WIZARD_FRAME::ParametersUpdated )
END_EVENT_TABLE()
// Note: our FOOTPRINT_WIZARD_FRAME is always modal.
FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent,
FRAME_T aFrameType ) :
PCB_BASE_EDIT_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
wxDefaultPosition, wxDefaultSize,
aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT
: KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
FOOTPRINT_WIZARD_FRAME_NAME ),
m_wizardListShown( false )
{
wxASSERT( aFrameType == FRAME_FOOTPRINT_WIZARD );
// This frame is always show modal:
SetModal( true );
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( BITMAPS::module_wizard ) );
SetIcon( icon );
m_wizardName.Empty();
// Create the GAL canvas.
// Must be created before calling LoadSettings() that needs a valid GAL canvas
PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
m_frameSize,
GetGalDisplayOptions(),
EDA_DRAW_PANEL_GAL::GAL_FALLBACK );
SetCanvas( gal_drawPanel );
SetBoard( new BOARD() );
// Ensure all layers and items are visible:
GetBoard()->SetVisibleAlls();
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
GetScreen()->m_Center = true; // Center coordinate origins on screen.
LoadSettings( config() );
SetSize( m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
// Set some display options here, because the FOOTPRINT_WIZARD_FRAME
// does not have a config menu to do that:
// the footprint wizard frame has no config menu. so use some settings
// from the caller, or force some options:
PCB_BASE_FRAME* caller = dynamic_cast<PCB_BASE_FRAME*>( aParent );
if( caller )
SetUserUnits( caller->GetUserUnits() );
// In viewer, the default net clearance is not known (it depends on the actual board).
// So we do not show the default clearance, by setting it to 0
// The footprint or pad specific clearance will be shown
GetBoard()->GetDesignSettings().m_NetSettings->GetDefaultNetclass()->SetClearance( 0 );
// Create the manager and dispatcher & route draw panel events to the dispatcher
m_toolManager = new TOOL_MANAGER;
m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
gal_drawPanel->GetViewControls(), config(), this );
m_actions = new PCB_ACTIONS();
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
m_toolManager->RegisterTool( new PCB_CONTROL );
m_toolManager->RegisterTool( new PCB_SELECTION_TOOL ); // for std context menus (zoom & grid)
m_toolManager->RegisterTool( new SCRIPTING_TOOL );
m_toolManager->RegisterTool( new COMMON_TOOLS );
m_toolManager->InitTools();
// Run the control tool, it is supposed to be always active
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
// Create the toolbars
ReCreateHToolbar();
ReCreateVToolbar();
// Create the parameters panel
m_parametersPanel = new wxPanel( this, wxID_ANY );
m_pageList = new wxListBox( m_parametersPanel, ID_FOOTPRINT_WIZARD_PAGE_LIST,
wxDefaultPosition, wxDefaultSize, 0, nullptr,
wxLB_HSCROLL | wxNO_BORDER );
auto divider = new wxStaticLine( m_parametersPanel, wxID_ANY,
wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
m_parameterGrid = new WX_GRID( m_parametersPanel, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
initParameterGrid();
m_parameterGrid->PushEventHandler( new GRID_TRICKS( m_parameterGrid ) );
ReCreatePageList();
wxBoxSizer* parametersSizer = new wxBoxSizer( wxHORIZONTAL );
parametersSizer->Add( m_pageList, 0, wxEXPAND, 5 );
parametersSizer->Add( divider, 0, wxEXPAND, 5 );
parametersSizer->Add( m_parameterGrid, 1, wxEXPAND, 5 );
m_parametersPanel->SetSizer( parametersSizer );
m_parametersPanel->Layout();
// Create the build message box
m_buildMessageBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_READONLY | wxNO_BORDER );
DisplayWizardInfos();
m_auimgr.SetManagedWindow( this );
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6)
.BestSize( -1, m_msgFrameHeight ) );
m_auimgr.AddPane( m_parametersPanel, EDA_PANE().Palette().Name( "Params" ).Left().Position(0)
.Caption( _( "Parameters" ) ).MinSize( 360, 180 ) );
m_auimgr.AddPane( m_buildMessageBox, EDA_PANE().Palette().Name( "Output" ).Left().Position(1)
.CaptionVisible( false ).MinSize( 360, -1 ) );
m_auimgr.AddPane( GetCanvas(), wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
auto& galOpts = GetGalDisplayOptions();
galOpts.m_fullscreenCursor = true;
galOpts.m_forceDisplayCursor = true;
galOpts.m_axesEnabled = true;
ActivateGalCanvas();
updateView();
SetActiveLayer( F_Cu );
GetToolManager()->PostAction( ACTIONS::zoomFitScreen );
// Do not Run a dialog here: on some Window Managers, it creates issues.
// Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
// It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
// Event Loop Manager, and stop the one created by the dialog.
// It does not happen on all W.M., perhaps due to the way the order events are called
// See the call in onActivate instead
}
FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
{
// Delete the GRID_TRICKS.
m_parameterGrid->PopEventHandler( true );
GetCanvas()->StopDrawing();
// Be sure any event cannot be fired after frame deletion:
GetCanvas()->SetEvtHandlerEnabled( false );
// Be sure a active tool (if exists) is deactivated:
if( m_toolManager )
m_toolManager->DeactivateTool();
EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame )
draw3DFrame->Destroy();
// Now this frame can be deleted
}
void FOOTPRINT_WIZARD_FRAME::doCloseWindow()
{
SaveSettings( config() );
if( IsModal() )
{
// Only dismiss a modal frame once, so that the return values set by
// the prior DismissModal() are not bashed for ShowModal().
if( !IsDismissed() )
DismissModal( false );
}
}
void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent )
{
DismissModal( true );
Close();
}
void FOOTPRINT_WIZARD_FRAME::OnGridSize( wxSizeEvent& aSizeEvent )
{
// Resize the parameter columns
ResizeParamColumns();
aSizeEvent.Skip();
}
void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
{
if( m_auimgr.GetManagedWindow() )
m_auimgr.Update();
SizeEv.Skip();
}
COLOR_SETTINGS* FOOTPRINT_WIZARD_FRAME::GetColorSettings( bool aForceRefresh ) const
{
wxString currentTheme = GetFootprintEditorSettings()->m_ColorTheme;
return Pgm().GetSettingsManager().GetColorSettings( currentTheme );
}
void FOOTPRINT_WIZARD_FRAME::updateView()
{
GetCanvas()->UpdateColors();
GetCanvas()->DisplayBoard( GetBoard() );
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
m_toolManager->RunAction( ACTIONS::zoomFitScreen );
UpdateMsgPanel();
}
void FOOTPRINT_WIZARD_FRAME::UpdateMsgPanel()
{
BOARD_ITEM* footprint = GetBoard()->GetFirstFootprint();
if( footprint )
{
std::vector<MSG_PANEL_ITEM> items;
footprint->GetMsgPanelInfo( this, items );
SetMsgPanel( items );
}
else
{
ClearMsgPanel();
}
}
void FOOTPRINT_WIZARD_FRAME::initParameterGrid()
{
m_parameterGridPage = -1;
// Prepare the grid where parameters are displayed
m_parameterGrid->CreateGrid( 0, 3 );
m_parameterGrid->SetColLabelValue( WIZ_COL_NAME, _( "Parameter" ) );
m_parameterGrid->SetColLabelValue( WIZ_COL_VALUE, _( "Value" ) );
m_parameterGrid->SetColLabelValue( WIZ_COL_UNITS, _( "Units" ) );
m_parameterGrid->SetColLabelSize( 22 );
m_parameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
m_parameterGrid->AutoSizeColumns();
m_parameterGrid->AutoSizeRows();
m_parameterGrid->SetRowLabelSize( 0 );
m_parameterGrid->DisableDragGridSize();
m_parameterGrid->DisableDragColSize();
m_parameterGrid->Connect( wxEVT_SIZE,
wxSizeEventHandler( FOOTPRINT_WIZARD_FRAME::OnGridSize ),
nullptr, this );
}
void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
{
if( m_pageList == nullptr )
return;
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
if( !footprintWizard )
return;
m_pageList->Clear();
int max_page = footprintWizard->GetNumParameterPages();
for( int i = 0; i < max_page; i++ )
{
wxString name = footprintWizard->GetParameterPageName( i );
m_pageList->Append( name );
}
m_pageList->SetSelection( 0, true );
ReCreateParameterList();
ReCreateHToolbar();
DisplayWizardInfos();
GetCanvas()->Refresh();
}
void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
{
if( m_parameterGrid == nullptr )
return;
FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
if( footprintWizard == nullptr )
return;
m_parameterGrid->Freeze();
m_parameterGrid->ClearGrid();
m_parameterGridPage = m_pageList->GetSelection();
if( m_parameterGridPage < 0 ) // Should not happen
return;
// Get the list of names, values, types, hints and designators
wxArrayString designatorsList = footprintWizard->GetParameterDesignators( m_parameterGridPage );
wxArrayString namesList = footprintWizard->GetParameterNames( m_parameterGridPage );
wxArrayString valuesList = footprintWizard->GetParameterValues( m_parameterGridPage );
wxArrayString typesList = footprintWizard->GetParameterTypes( m_parameterGridPage );
wxArrayString hintsList = footprintWizard->GetParameterHints( m_parameterGridPage );
// Dimension the wxGrid
m_parameterGrid->ClearRows();
m_parameterGrid->AppendRows( namesList.size() );
wxString designator, name, value, units, hint;
for( unsigned int i = 0; i < namesList.size(); i++ )
{
designator = designatorsList[i];
name = namesList[i];
value = valuesList[i];
units = typesList[i];
hint = hintsList[i];
m_parameterGrid->SetRowLabelValue( i, designator );
// Set the 'Name'
m_parameterGrid->SetCellValue( i, WIZ_COL_NAME, name );
m_parameterGrid->SetReadOnly( i, WIZ_COL_NAME );
// Boolean parameters are displayed using a checkbox
if( units == WIZARD_PARAM_UNITS_BOOL )
{
// Set to ReadOnly as we delegate interactivity to GRID_TRICKS
m_parameterGrid->SetReadOnly( i, WIZ_COL_VALUE );
m_parameterGrid->SetCellRenderer( i, WIZ_COL_VALUE, new wxGridCellBoolRenderer );
}
// Parameters that can be selected from a list of multiple options
else if( units.Contains( wxT( "," ) ) ) // Indicates list of available options
{
wxStringTokenizer tokenizer( units, wxT( "," ) );
wxArrayString options;
while( tokenizer.HasMoreTokens() )
{
options.Add( tokenizer.GetNextToken() );
}
m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE,
new wxGridCellChoiceEditor( options ) );
units = wxT( "" );
}
else if( units == WIZARD_PARAM_UNITS_INTEGER ) // Integer parameters
{
m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellNumberEditor );
}
else if( ( units == WIZARD_PARAM_UNITS_MM ) ||
( units == WIZARD_PARAM_UNITS_MILS ) ||
( units == WIZARD_PARAM_UNITS_FLOAT ) ||
( units == WIZARD_PARAM_UNITS_RADIANS ) ||
( units == WIZARD_PARAM_UNITS_DEGREES ) ||
( units == WIZARD_PARAM_UNITS_PERCENT ) )
{
// Non-integer numerical parameters
m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellFloatEditor );
// Convert separators to the locale-specific character
value.Replace( ",", wxNumberFormatter::GetDecimalSeparator() );
value.Replace( ".", wxNumberFormatter::GetDecimalSeparator() );
}
// Set the 'Units'
m_parameterGrid->SetCellValue( i, WIZ_COL_UNITS, units );
m_parameterGrid->SetReadOnly( i, WIZ_COL_UNITS );
// Set the 'Value'
m_parameterGrid->SetCellValue( i, WIZ_COL_VALUE, value );
}
ResizeParamColumns();
m_parameterGrid->Thaw();
}
void FOOTPRINT_WIZARD_FRAME::ResizeParamColumns()
{
// Parameter grid is not yet configured
if( ( m_parameterGrid == nullptr ) || ( m_parameterGrid->GetNumberCols() == 0 ) )
return;
// first auto-size the columns to ensure enough space around text
m_parameterGrid->AutoSizeColumns();
// Auto-size the value column
int width = m_parameterGrid->GetClientSize().GetWidth() -
m_parameterGrid->GetRowLabelSize() -
m_parameterGrid->GetColSize( WIZ_COL_NAME ) -
m_parameterGrid->GetColSize( WIZ_COL_UNITS );
if( width > m_parameterGrid->GetColMinimalAcceptableWidth() )
{
m_parameterGrid->SetColSize( WIZ_COL_VALUE, width );
}
}
void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
{
if( m_pageList->GetSelection() >= 0 )
{
ReCreateParameterList();
GetCanvas()->Refresh();
DisplayWizardInfos();
}
}
void FOOTPRINT_WIZARD_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
{
PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
wxCHECK( cfg, /*void*/ );
PCB_BASE_FRAME::LoadSettings( cfg );
m_auiPerspective = cfg->m_FootprintViewer.perspective;
}
void FOOTPRINT_WIZARD_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{
PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
wxCHECK( cfg, /*void*/ );
PCB_BASE_FRAME::SaveSettings( cfg );
cfg->m_FootprintViewer.perspective = m_auimgr.SavePerspective().ToStdString();
}
WINDOW_SETTINGS* FOOTPRINT_WIZARD_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
{
auto cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
wxASSERT( cfg );
return cfg ? &cfg->m_FootprintWizard : nullptr;
}
void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event )
{
// Ensure we do not have old selection:
if( !event.GetActive() )
return;
if( !m_wizardListShown )
{
m_wizardListShown = true;
wxPostEvent( this, wxCommandEvent( wxEVT_TOOL, ID_FOOTPRINT_WIZARD_SELECT_WIZARD ) );
}
#if 0
// Currently, we do not have a way to see if a Python wizard has changed,
// therefore the lists of parameters and option has to be rebuilt
// This code could be enabled when this way exists
bool footprintWizardsChanged = false;
if( footprintWizardsChanged )
{
// If we are here, the library list has changed, rebuild it
ReCreatePageList();
DisplayWizardInfos();
}
#endif
}
void FOOTPRINT_WIZARD_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
{
wxString frm3Dtitle;
frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), m_wizardName );
PCB_BASE_FRAME::Update3DView( aMarkDirty, aRefresh, &frm3Dtitle );
}
void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
{
if( m_mainToolBar )
{
m_mainToolBar->ClearToolbar();
}
else
{
m_mainToolBar = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
m_mainToolBar->SetAuiManager( &m_auimgr );
}
// Set up toolbar
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, wxEmptyString,
KiBitmap( BITMAPS::module_wizard ),
_( "Select wizard script to run" ) );
m_mainToolBar->AddScaledSeparator( this );
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, wxEmptyString,
KiBitmap( BITMAPS::reload ),
_( "Reset wizard parameters to default") );
m_mainToolBar->AddScaledSeparator( this );
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_PREVIOUS, wxEmptyString,
KiBitmap( BITMAPS::lib_previous ),
_( "Select previous parameters page" ) );
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_NEXT, wxEmptyString,
KiBitmap( BITMAPS::lib_next ),
_( "Select next parameters page" ) );
#if 0 // Currently: the 3D viewer is not useful
m_mainToolBar->AddScaledSeparator( this );
m_mainToolBar->Add( ACTIONS::show3DViewer );
#endif
m_mainToolBar->AddScaledSeparator( this );
m_mainToolBar->Add( ACTIONS::zoomRedraw );
m_mainToolBar->Add( ACTIONS::zoomInCenter );
m_mainToolBar->Add( ACTIONS::zoomOutCenter );
m_mainToolBar->Add( ACTIONS::zoomFitScreen );
// The footprint wizard always can export the current footprint
m_mainToolBar->AddScaledSeparator( this );
m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_DONE,
wxEmptyString, KiBitmap( BITMAPS::export_footprint_names ),
_( "Export footprint to editor" ) );
// after adding the buttons to the toolbar, must call Realize() to
// reflect the changes
m_mainToolBar->Realize();
}
BOARD_ITEM_CONTAINER* FOOTPRINT_WIZARD_FRAME::GetModel() const
{
return GetBoard()->GetFirstFootprint();
}
void FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar()
{
// Currently, there is no vertical toolbar
}
void FOOTPRINT_WIZARD_FRAME::PythonPluginsReload()
{
// Reload the Python plugins
// Because the board editor has also a plugin python menu,
// call the PCB_EDIT_FRAME RunAction() if the board editor is running
// Otherwise run the current RunAction().
PCB_EDIT_FRAME* pcbframe = static_cast<PCB_EDIT_FRAME*>( Kiway().Player( FRAME_PCB_EDITOR, false ) );
if( pcbframe )
pcbframe->GetToolManager()->RunAction( ACTIONS::pluginsReload );
else
GetToolManager()->RunAction( ACTIONS::pluginsReload );
}
|