bool GERBVIEW_FRAME::LoadZipArchiveFile( const wxString& aFullFileName ) { #define ZipFileExtension "zip" wxFileName filename = aFullFileName; wxString currentPath; if( !filename.IsOk() ) { // Use the current working directory if the file name path does not exist. if( filename.DirExists() ) currentPath = filename.GetPath(); else currentPath = m_mruPath; wxFileDialog dlg( this, _( "Open Zip File" ), currentPath, filename.GetFullName(), ZipFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) return false; filename = dlg.GetPath(); currentPath = wxGetCwd(); m_mruPath = currentPath; } else { currentPath = filename.GetPath(); m_mruPath = currentPath; } wxString msg; WX_STRING_REPORTER reporter( &msg ); if( filename.IsOk() ) unarchiveFiles( filename.GetFullPath(), &reporter ); Zoom_Automatique( false ); // Synchronize layers tools with actual active layer: ReFillLayerWidget(); SetActiveLayer( GetActiveLayer() ); m_LayersManager->UpdateLayerIcons(); syncLayerBox(); if( !msg.IsEmpty() ) { wxSafeYield(); // Allows slice of time to redraw the screen // to refresh widgets, before displaying messages HTML_MESSAGE_BOX mbox( this, _( "Messages" ) ); mbox.ListSet( msg ); mbox.ShowModal(); } return true; }
bool GERBVIEW_FRAME::Clear_DrawLayers( bool query ) { if( GetGerberLayout() == NULL ) return false; if( query && GetScreen()->IsModify() ) { if( !IsOK( this, _( "Current data will be lost?" ) ) ) return false; } if( auto canvas = GetGalCanvas() ) { canvas->GetView()->Clear(); } GetImagesList()->DeleteAllImages(); GetGerberLayout()->SetBoundingBox( EDA_RECT() ); SetActiveLayer( 0 ); ReFillLayerWidget(); syncLayerBox(); return true; }
/* File commands. */ void GERBVIEW_FRAME::Files_io( wxCommandEvent& event ) { int id = event.GetId(); switch( id ) { case wxID_FILE: Erase_Current_DrawLayer( false ); LoadGerberFiles( wxEmptyString ); break; case ID_GERBVIEW_ERASE_ALL: Clear_DrawLayers( false ); Zoom_Automatique( false ); m_canvas->Refresh(); ClearMsgPanel(); ReFillLayerWidget(); break; case ID_GERBVIEW_LOAD_DRILL_FILE: LoadExcellonFiles( wxEmptyString ); m_canvas->Refresh(); break; default: wxFAIL_MSG( wxT( "File_io: unexpected command id" ) ); break; } }
/** * Function Clear_Pcb * delete all and reinitialize the current board * @param aQuery = true to prompt user for confirmation, false to initialize silently */ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery ) { if( GetBoard() == NULL ) return false; if( aQuery ) { if( GetBoard()->m_Drawings || GetBoard()->m_Modules || GetBoard()->m_Track || GetBoard()->m_Zone ) { if( !IsOK( this, _( "Current Board will be lost and this operation cannot be undone. Continue ?" ) ) ) return false; } } // Clear undo and redo lists because we want a full deletion GetScreen()->ClearUndoRedoList(); /* Items visibility flags will be set becuse a new board will be created. * Grid and ratsnest can be left to their previous state */ bool showGrid = IsElementVisible( GRID_VISIBLE ); bool showRats = IsElementVisible( RATSNEST_VISIBLE ); // delete the old BOARD and create a new BOARD so that the default // layer names are put into the BOARD. SetBoard( new BOARD() ); SetElementVisibility( GRID_VISIBLE, showGrid ); SetElementVisibility( RATSNEST_VISIBLE, showRats ); SetCurItem( NULL ); // clear filename, to avoid overwriting an old file GetScreen()->GetFileName().Empty(); // preserve grid size accross call to InitDataPoints() // wxRealPoint gridsize = GetScreen()->GetGridSize(); GetScreen()->InitDataPoints( GetPageSizeIU() ); // GetScreen()->SetGrid( gridsize ); GetBoard()->ResetHighLight(); // Enable all layers (SetCopperLayerCount() will adjust the copper layers enabled) GetBoard()->SetEnabledLayers( ALL_LAYERS ); // Default copper layers count set to 2: double layer board GetBoard()->SetCopperLayerCount( 2 ); // Update display: GetBoard()->SetVisibleLayers( ALL_LAYERS ); ReFillLayerWidget(); Zoom_Automatique( false ); return true; }
/** * Function SetLanguage * called on a language menu selection * Update Layer manager title and tabs texts */ void GERBVIEW_FRAME::SetLanguage( wxCommandEvent& event ) { EDA_DRAW_FRAME::SetLanguage( event ); m_LayersManager->SetLayersManagerTabsText(); wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager ); pane_info.Caption( _( "Visibles" ) ); m_auimgr.Update(); ReFillLayerWidget(); }
void GERBVIEW_FRAME::ShowChangedLanguage() { // call my base class EDA_DRAW_FRAME::ShowChangedLanguage(); m_LayersManager->SetLayersManagerTabsText(); wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager ); pane_info.Caption( _( "Visibles" ) ); m_auimgr.Update(); ReFillLayerWidget(); }
void PCB_EDIT_FRAME::SetLanguage( wxCommandEvent& event ) { EDA_DRAW_FRAME::SetLanguage( event ); m_Layers->SetLayersManagerTabsText(); wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_Layers ); pane_info.Caption( _( "Visibles" ) ); m_auimgr.Update(); ReFillLayerWidget(); FOOTPRINT_EDIT_FRAME * moduleEditFrame = FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor(); if( moduleEditFrame ) moduleEditFrame->EDA_DRAW_FRAME::SetLanguage( event ); }
void PCB_EDIT_FRAME::ShowChangedLanguage() { // call my base class PCB_BASE_FRAME::ShowChangedLanguage(); m_Layers->SetLayersManagerTabsText(); wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_Layers ); pane_info.Caption( _( "Visibles" ) ); m_auimgr.Update(); ReFillLayerWidget(); }
void GERBVIEW_FRAME::Erase_Current_DrawLayer( bool query ) { int layer = GetActiveLayer(); wxString msg; msg.Printf( _( "Clear layer %d?" ), layer + 1 ); if( query && !IsOK( this, msg ) ) return; SetCurItem( NULL ); GetImagesList()->DeleteImage( layer ); ReFillLayerWidget(); syncLayerBox(); m_canvas->Refresh(); }
void FOOTPRINT_EDIT_FRAME::UpdateUserInterface() { // Update the layer manager and other widgets from the board setup // (layer and items visibility, colors ...) // Update the layer manager m_Layers->Freeze(); ReFillLayerWidget(); m_Layers->ReFillRender(); // update the layer widget to match board visibility states. m_Layers->SyncLayerVisibilities(); static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb ); m_Layers->SelectLayer( GetActiveLayer() ); m_Layers->OnLayerSelected(); m_Layers->Thaw(); }
GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME ) { m_colorsSettings = &g_ColorsSettings; m_gerberLayout = NULL; m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1 // when the screen shows a 1:1 image // obviously depends on the monitor, // but this is an acceptable value PAGE_INFO pageInfo( wxT( "GERBER" ) ); SetPageSettings( pageInfo ); m_show_layer_manager_tools = true; m_showAxis = true; // true to show X and Y axis on screen m_showBorderAndTitleBlock = false; // true for reference drawings. m_HotkeysZoomAndGridList = GerbviewHokeysDescr; m_SelLayerBox = NULL; m_DCodeSelector = NULL; m_displayMode = 0; m_drillFileHistory.SetBaseId( ID_GERBVIEW_DRILL_FILE1 ); if( m_canvas ) m_canvas->SetEnableBlockCommands( true ); // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) ); SetIcon( icon ); SetLayout( new GBR_LAYOUT() ); SetVisibleLayers( -1 ); // All draw layers visible. SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) ); // Create the PCB_LAYER_WIDGET *after* SetLayout(): wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); int pointSize = font.GetPointSize(); int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); if( screenHeight <= 900 ) pointSize = (pointSize * 8) / 10; m_LayersManager = new GERBER_LAYER_WIDGET( this, m_canvas, pointSize ); // LoadSettings() *after* creating m_LayersManager, because LoadSettings() // initialize parameters in m_LayersManager LoadSettings( config() ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); if( m_LastGridSizeId < 0 ) m_LastGridSizeId = 0; if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000 ) m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000; GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); ReCreateMenuBar(); ReCreateHToolbar(); ReCreateOptToolbar(); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiz; horiz.HorizontalToolbarPane(); EDA_PANEINFO vert; vert.VerticalToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template. // the Layers Manager is floatable, but initially docked at far right EDA_PANEINFO lyrs; lyrs.LayersToolbarPane(); lyrs.MinSize( m_LayersManager->GetBestSize() ); lyrs.BestSize( m_LayersManager->GetBestSize() ); lyrs.Caption( _( "Visibles" ) ); lyrs.TopDockable( false ).BottomDockable( false ); if( m_mainToolBar ) m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) ); if( m_drawToolBar ) m_auimgr.AddPane( m_drawToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right().Row( 1 ) ); m_auimgr.AddPane( m_LayersManager, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 0 ) ); if( m_optionsToolBar ) m_auimgr.AddPane( m_optionsToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() ); if( m_canvas ) m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); if( m_messagePanel ) m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer( 10 ) ); ReFillLayerWidget(); // this is near end because contents establish size m_LayersManager->ReFillRender(); // Update colors in Render after the config is read m_auimgr.Update(); setActiveLayer( 0, true ); Zoom_Automatique( false ); // Gives a default zoom value }
void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) { int id = event.GetId(); wxFileName fn; switch( id ) { case ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG: m_show_layer_manager_tools = ! m_show_layer_manager_tools; m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools ); m_auimgr.Update(); GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG, m_show_layer_manager_tools ? _("Hide &Layers Manager" ) : _("Show &Layers Manager" )); break; case ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR: m_show_microwave_tools = ! m_show_microwave_tools; m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools ); m_auimgr.Update(); GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_MUWAVE_TOOLBAR, m_show_microwave_tools ? _( "Hide Microwave Toolbar" ): _( "Show Microwave Toolbar" )); break; case ID_PCB_LAYERS_SETUP: if( InvokeLayerSetup( this, GetBoard() ) ) { LAYER_ID cur_layer = GetActiveLayer(); // If after showing the dialog the user has removed the active layer, // then select a new active layer (front copper layer). if( !GetBoard()->GetEnabledLayers()[ cur_layer ] ) cur_layer = F_Cu; SetActiveLayer( cur_layer ); OnModify(); ReCreateLayerBox(); ReFillLayerWidget(); if( IsGalCanvasActive() ) static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( GetBoard() ); } break; case ID_PCB_LIB_WIZARD: case ID_PCB_LIB_TABLE_EDIT: { bool tableChanged = false; int r = 0; if( id == ID_PCB_LIB_TABLE_EDIT ) r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() ); else r = InvokeFootprintWizard( this, &GFootprintTable, Prj().PcbFootprintLibs() ); if( r & 1 ) { try { FILE_OUTPUTFORMATTER sf( FP_LIB_TABLE::GetGlobalTableFileName() ); GFootprintTable.Format( &sf, 0 ); tableChanged = true; } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error occurred saving the global footprint library " "table:\n\n%s" ), GetChars( ioe.errorText.GetData() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } // If no board file is defined, do not save the project specific library table. It // is kept in memory and created in the path when the new board is saved. if( (r & 2) && !GetBoard()->GetFileName().IsEmpty() ) { wxString tblName = Prj().FootprintLibTblName(); try { Prj().PcbFootprintLibs()->Save( tblName ); tableChanged = true; } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error occurred saving project specific footprint library " "table:\n\n%s" ), GetChars( ioe.errorText ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } FOOTPRINT_VIEWER_FRAME* viewer; if( tableChanged && (viewer = (FOOTPRINT_VIEWER_FRAME*)Kiway().Player( FRAME_PCB_MODULE_VIEWER, false )) != NULL ) { viewer->ReCreateLibraryList(); } } break; case ID_PCB_3DSHAPELIB_WIZARD: #ifdef BUILD_GITHUB_PLUGIN Invoke3DShapeLibsDownloaderWizard( this ); #endif break; case ID_PCB_MASK_CLEARANCE: { DIALOG_PADS_MASK_CLEARANCE dlg( this ); if( dlg.ShowModal() == 1 && IsGalCanvasActive() ) { for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() ) module->ViewUpdate(); GetGalCanvas()->Refresh(); } } break; case wxID_PREFERENCES: { DIALOG_GENERALOPTIONS dlg( this ); dlg.ShowModal(); } break; case ID_PCB_PAD_SETUP: InstallPadOptionsFrame( NULL ); break; case ID_CONFIG_SAVE: SaveProjectSettings( true ); break; case ID_CONFIG_READ: { fn = GetBoard()->GetFileName(); fn.SetExt( ProjectFileExtension ); wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), fn.GetFullName(), ProjectFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) break; if( !wxFileExists( dlg.GetPath() ) ) { wxString msg = wxString::Format( _( "File %s not found" ), GetChars( dlg.GetPath() ) ); DisplayError( this, msg ); break; } wxString pro_file = dlg.GetPath(); Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters(), pro_file ); } break; // Hotkey IDs case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG: ExportHotkeyConfigToFile( g_Board_Editor_Hokeys_Descr, wxT( "pcbnew" ) ); break; case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG: ImportHotkeyConfigFromFile( g_Board_Editor_Hokeys_Descr, wxT( "pcbnew" ) ); break; case ID_PREFERENCES_HOTKEY_SHOW_EDITOR: InstallHotkeyFrame( this, g_Board_Editor_Hokeys_Descr ); break; case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display current hotkey list for Pcbnew. DisplayHotkeyList( this, g_Board_Editor_Hokeys_Descr ); break; default: DisplayError( this, wxT( "PCB_EDIT_FRAME::Process_Config error" ) ); } }
bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ) { // This is for python: if( aFileSet.size() != 1 ) { UTF8 msg = StrPrintf( "Pcbnew:%s() takes only a single filename", __func__ ); DisplayError( this, msg ); return false; } wxString fullFileName( aFileSet[0] ); // We insist on caller sending us an absolute path, if it does not, we say it's a bug. wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "bug in single_top.cpp or project manager." ) ); if( !LockFile( fullFileName ) ) { wxString msg = wxString::Format( _( "PCB file '%s' is already open." ), GetChars( fullFileName ) ); DisplayError( this, msg ); return false; } if( GetScreen()->IsModify() ) { int response = YesNoCancelDialog( this, _( "The current board has been modified. Do you wish to save the changes?" ), wxEmptyString, _( "Save and Load" ), _( "Load Without Saving" ) ); if( response == wxID_CANCEL ) return false; else if( response == wxID_YES ) SavePcbFile( GetBoard()->GetFileName(), CREATE_BACKUP_FILE ); else { // response == wxID_NO, fall thru } } wxFileName pro = fullFileName; pro.SetExt( ProjectFileExtension ); bool is_new = !wxFileName::IsFileReadable( fullFileName ); // If its a non-existent schematic and caller thinks it exists if( is_new && !( aCtl & KICTL_CREATE ) ) { // notify user that fullFileName does not exist, ask if user wants to create it. wxString ask = wxString::Format( _( "Board '%s' does not exist. Do you wish to create it?" ), GetChars( fullFileName ) ); if( !IsOK( this, ask ) ) return false; } Clear_Pcb( false ); // pass false since we prompted above for a modified board IO_MGR::PCB_FILE_T pluginType = plugin_type( fullFileName, aCtl ); bool converted = pluginType != IO_MGR::LEGACY && pluginType != IO_MGR::KICAD; if( !converted ) { // PROJECT::SetProjectFullName() is an impactful function. It should only be // called under carefully considered circumstances. // The calling code should know not to ask me here to change projects unless // it knows what consequences that will have on other KIFACEs running and using // this same PROJECT. It can be very harmful if that calling code is stupid. Prj().SetProjectFullName( pro.GetFullPath() ); // load project settings before BOARD LoadProjectSettings(); } if( is_new ) { OnModify(); } else { BOARD* loadedBoard = 0; // it will be set to non-NULL if loaded OK PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) ); try { PROPERTIES props; char xbuf[30]; char ybuf[30]; // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet. sprintf( xbuf, "%d", GetPageSizeIU().x ); sprintf( ybuf, "%d", GetPageSizeIU().y ); props["page_width"] = xbuf; props["page_height"] = ybuf; #if USE_INSTRUMENTATION // measure the time to load a BOARD. unsigned startTime = GetRunningMicroSecs(); #endif loadedBoard = pi->Load( fullFileName, NULL, &props ); #if USE_INSTRUMENTATION unsigned stopTime = GetRunningMicroSecs(); printf( "PLUGIN::Load(): %u usecs\n", stopTime - startTime ); #endif } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.errorText ) ); DisplayError( this, msg ); return false; } SetBoard( loadedBoard ); // we should not ask PLUGINs to do these items: loadedBoard->BuildListOfNets(); loadedBoard->SynchronizeNetsAndNetClasses(); SetStatusText( wxEmptyString ); BestZoom(); // update the layer names in the listbox ReCreateLayerBox( false ); GetScreen()->ClrModify(); { wxFileName fn = fullFileName; CheckForAutoSaveFile( fullFileName, fn.GetExt() ); } if( pluginType == IO_MGR::LEGACY && loadedBoard->GetFileFormatVersionAtLoad() < LEGACY_BOARD_FILE_VERSION ) { DisplayInfoMessage( this, _( "This file was created by an older version of Pcbnew.\n" "It will be stored in the new file format when you save this file again." ) ); } } { wxFileName fn = fullFileName; if( converted ) fn.SetExt( PcbFileExtension ); wxString fname = fn.GetFullPath(); fname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); GetBoard()->SetFileName( fname ); } UpdateTitle(); if( !converted ) UpdateFileHistory( GetBoard()->GetFileName() ); // Rebuild the new pad list (for drc and ratsnet control ...) GetBoard()->m_Status_Pcb = 0; // Update info shown by the horizontal toolbars SetCurrentNetClass( NETCLASS::Default ); ReFillLayerWidget(); ReCreateLayerBox(); // upate the layer widget to match board visibility states, both layers and render columns. syncLayerVisibilities(); syncLayerWidgetLayer(); syncRenderStates(); // Update the tracks / vias available sizes list: ReCreateAuxiliaryToolbar(); // Update the RATSNEST items, which were not loaded at the time // BOARD::SetVisibleElements() was called from within any PLUGIN. // See case RATSNEST_VISIBLE: in BOARD::SetElementVisibility() GetBoard()->SetVisibleElements( GetBoard()->GetVisibleElements() ); // Display the loaded board: Zoom_Automatique( false ); // Compile ratsnest and displays net info { wxBusyCursor dummy; // Displays an Hourglass while building connectivity Compile_Ratsnest( NULL, true ); GetBoard()->GetRatsnest()->ProcessBoard(); } SetMsgPanel( GetBoard() ); // Refresh the 3D view, if any if( m_Draw3DFrame ) m_Draw3DFrame->NewDisplay(); #if 0 && defined(DEBUG) // Output the board object tree to stdout, but please run from command prompt: GetBoard()->Show( 0, std::cout ); #endif // from EDA_APPL which was first loaded BOARD only: { /* For an obscure reason the focus is lost after loading a board file * when starting up the process. * (seems due to the recreation of the layer manager after loading the file) * Give focus to main window and Drawpanel * must be done for these 2 windows (for an obscure reason ...) * Linux specific * This is more a workaround than a fix. */ SetFocus(); GetCanvas()->SetFocus(); } return true; }
bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) { wxString filetypes; wxArrayString filenamesList; wxFileName filename = aFullFileName; wxString currentPath; if( !filename.IsOk() ) { filetypes = DrillFileWildcard(); filetypes << wxT( "|" ); /* All filetypes */ filetypes += wxGetTranslation( AllFilesWildcard ); /* Use the current working directory if the file name path does not exist. */ if( filename.DirExists() ) currentPath = filename.GetPath(); else currentPath = m_mruPath; wxFileDialog dlg( this, _( "Open Drill File" ), currentPath, filename.GetFullName(), filetypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) return false; dlg.GetPaths( filenamesList ); currentPath = wxGetCwd(); m_mruPath = currentPath; } else { filenamesList.Add( aFullFileName ); currentPath = filename.GetPath(); m_mruPath = currentPath; } // Read Excellon drill files: each file is loaded on a new GerbView layer bool success = true; int layer = GetActiveLayer(); // Manage errors when loading files wxString msg; WX_STRING_REPORTER reporter( &msg ); for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) { filename = filenamesList[ii]; if( !filename.IsAbsolute() ) filename.SetPath( currentPath ); m_lastFileName = filename.GetFullPath(); SetActiveLayer( layer, false ); if( Read_EXCELLON_File( filename.GetFullPath() ) ) { // Update the list of recent drill files. UpdateFileHistory( filename.GetFullPath(), &m_drillFileHistory ); layer = getNextAvailableLayer( layer ); if( layer == NO_AVAILABLE_LAYERS && ii < filenamesList.GetCount()-1 ) { success = false; reporter.Report( MSG_NO_MORE_LAYER, REPORTER::RPT_ERROR ); // Report the name of not loaded files: ii += 1; while( ii < filenamesList.GetCount() ) { filename = filenamesList[ii++]; wxString txt; txt.Printf( MSG_NOT_LOADED, GetChars( filename.GetFullName() ) ); reporter.Report( txt, REPORTER::RPT_ERROR ); } break; } SetActiveLayer( layer, false ); } } if( !success ) { HTML_MESSAGE_BOX mbox( this, _( "Errors" ) ); mbox.ListSet( msg ); mbox.ShowModal(); } Zoom_Automatique( false ); // Synchronize layers tools with actual active layer: ReFillLayerWidget(); SetActiveLayer( GetActiveLayer() ); m_LayersManager->UpdateLayerIcons(); syncLayerBox(); return success; }
bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) { wxString filetypes; wxArrayString filenamesList; wxFileName filename = aFullFileName; wxString currentPath; if( !filename.IsOk() ) { /* Standard gerber filetypes * (See http://en.wikipedia.org/wiki/Gerber_File) * the .gbr (.pho in legacy files) extension is the default used in Pcbnew * However there are a lot of other extensions used for gerber files * Because the first letter is usually g, we accept g* as extension * (Mainly internal copper layers do not have specific extension, * and filenames are like *.g1, *.g2 *.gb1 ...). * Now (2014) Ucamco (the company which manages the Gerber format) encourages * use of .gbr only and the Gerber X2 file format. */ filetypes = _( "Gerber files (.g* .lgr .pho)" ); filetypes << wxT("|"); filetypes += wxT("*.g*;*.G*;*.pho;*.PHO" ); filetypes << wxT("|"); /* Special gerber filetypes */ filetypes += _( "Top layer (*.GTL)|*.GTL;*.gtl|" ); filetypes += _( "Bottom layer (*.GBL)|*.GBL;*.gbl|" ); filetypes += _( "Bottom solder resist (*.GBS)|*.GBS;*.gbs|" ); filetypes += _( "Top solder resist (*.GTS)|*.GTS;*.gts|" ); filetypes += _( "Bottom overlay (*.GBO)|*.GBO;*.gbo|" ); filetypes += _( "Top overlay (*.GTO)|*.GTO;*.gto|" ); filetypes += _( "Bottom paste (*.GBP)|*.GBP;*.gbp|" ); filetypes += _( "Top paste (*.GTP)|*.GTP;*.gtp|" ); filetypes += _( "Keep-out layer (*.GKO)|*.GKO;*.gko|" ); filetypes += _( "Mechanical layers (*.GMx)|*.GM1;*.gm1;*.GM2;*.gm2;*.GM3;*.gm3|" ); filetypes += _( "Top Pad Master (*.GPT)|*.GPT;*.gpt|" ); filetypes += _( "Bottom Pad Master (*.GPB)|*.GPB;*.gpb|" ); // All filetypes filetypes += AllFilesWildcard; // Use the current working directory if the file name path does not exist. if( filename.DirExists() ) currentPath = filename.GetPath(); else { currentPath = m_mruPath; // On wxWidgets 3.1 (bug?) the path in wxFileDialog is ignored when // finishing by the dir separator. Remove it if any: if( currentPath.EndsWith( '\\' ) || currentPath.EndsWith( '/' ) ) currentPath.RemoveLast(); } wxFileDialog dlg( this, _( "Open Gerber File" ), currentPath, filename.GetFullName(), filetypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) return false; dlg.GetPaths( filenamesList ); // @todo Take a closer look at the CWD switching here. The current working directory // gets changed by wxFileDialog because the wxFD_CHANGE_DIR flag is set. Is this the // appropriate behavior? The current working directory is not returned to the previous // value so this may be an issue elsewhere. currentPath = wxGetCwd(); m_mruPath = currentPath; } else { filenamesList.Add( aFullFileName ); currentPath = filename.GetPath(); m_mruPath = currentPath; } // Set the busy cursor wxBusyCursor wait; // Read gerber files: each file is loaded on a new GerbView layer bool success = true; int layer = GetActiveLayer(); // Manage errors when loading files wxString msg; WX_STRING_REPORTER reporter( &msg ); for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) { filename = filenamesList[ii]; if( !filename.IsAbsolute() ) filename.SetPath( currentPath ); m_lastFileName = filename.GetFullPath(); SetActiveLayer( layer, false ); if( Read_GERBER_File( filename.GetFullPath() ) ) { UpdateFileHistory( m_lastFileName ); layer = getNextAvailableLayer( layer ); if( layer == NO_AVAILABLE_LAYERS && ii < filenamesList.GetCount()-1 ) { success = false; reporter.Report( MSG_NO_MORE_LAYER, REPORTER::RPT_ERROR ); // Report the name of not loaded files: ii += 1; while( ii < filenamesList.GetCount() ) { filename = filenamesList[ii++]; wxString txt; txt.Printf( MSG_NOT_LOADED, GetChars( filename.GetFullName() ) ); reporter.Report( txt, REPORTER::RPT_ERROR ); } break; } SetActiveLayer( layer, false ); } } if( !success ) { HTML_MESSAGE_BOX mbox( this, _( "Errors" ) ); mbox.ListSet( msg ); mbox.ShowModal(); } Zoom_Automatique( false ); // Synchronize layers tools with actual active layer: ReFillLayerWidget(); SetActiveLayer( GetActiveLayer() ); m_LayersManager->UpdateLayerIcons(); syncLayerBox(); return success; }
bool PCB_EDIT_FRAME::AppendBoardFile( const wxString& aFullFileName, int aCtl ) { IO_MGR::PCB_FILE_T pluginType = plugin_type( aFullFileName, aCtl ); PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) ); // keep trace of existing items, in order to know what are the new items // (for undo command for instance) // Tracks are inserted, not append, so mark existing tracks to know what are // the new tracks for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() ) track->SetFlags( FLAG0 ); // Other items are append to the item list, so keep trace to the // last existing item is enough MODULE* module = GetBoard()->m_Modules.GetLast(); BOARD_ITEM* drawing = GetBoard()->m_Drawings.GetLast(); int zonescount = GetBoard()->GetAreaCount(); // Keep also the count of copper layers, because we can happen boards // with different copper layers counts, // and the enabled layers int initialCopperLayerCount = GetBoard()->GetCopperLayerCount(); LSET initialEnabledLayers = GetBoard()->GetEnabledLayers(); try { PROPERTIES props; char xbuf[30]; char ybuf[30]; // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet. sprintf( xbuf, "%d", GetPageSizeIU().x ); sprintf( ybuf, "%d", GetPageSizeIU().y ); props["page_width"] = xbuf; props["page_height"] = ybuf; GetDesignSettings().m_NetClasses.Clear(); pi->Load( aFullFileName, GetBoard(), &props ); } catch( const IO_ERROR& ioe ) { for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() ) track->ClearFlags( FLAG0 ); wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ) ); DisplayError( this, msg ); return false; } // Now prepare a block move command to place the new items, and // prepare the undo command. BLOCK_SELECTOR& blockmove = GetScreen()->m_BlockLocate; HandleBlockBegin( NULL, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0) ); PICKED_ITEMS_LIST& blockitemsList = blockmove.GetItems(); PICKED_ITEMS_LIST undoListPicker; ITEM_PICKER picker( NULL, UR_NEW ); EDA_RECT bbox; // the new items bounding box, for block move bool bboxInit = true; // true until the bounding box is initialized for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() ) { if( track->GetFlags() & FLAG0 ) { track->ClearFlags( FLAG0 ); continue; } track->SetFlags( IS_MOVED ); picker.SetItem( track ); undoListPicker.PushItem( picker ); blockitemsList.PushItem( picker ); if( bboxInit ) bbox = track->GetBoundingBox(); else bbox.Merge( track->GetBoundingBox() ); bboxInit = false; } if( module ) module = module->Next(); else module = GetBoard()->m_Modules; for( ; module; module = module->Next() ) { module->SetFlags( IS_MOVED ); picker.SetItem( module ); undoListPicker.PushItem( picker ); blockitemsList.PushItem( picker ); if( bboxInit ) bbox = module->GetBoundingBox(); else bbox.Merge( module->GetBoundingBox() ); bboxInit = false; } if( drawing ) drawing = drawing->Next(); else drawing = GetBoard()->m_Drawings; for( ; drawing; drawing = drawing->Next() ) { drawing->SetFlags( IS_MOVED ); picker.SetItem( drawing ); undoListPicker.PushItem( picker ); blockitemsList.PushItem( picker ); if( bboxInit ) bbox = drawing->GetBoundingBox(); else bbox.Merge( drawing->GetBoundingBox() ); bboxInit = false; } for( ZONE_CONTAINER* zone = GetBoard()->GetArea( zonescount ); zone; zone = GetBoard()->GetArea( zonescount ) ) { zone->SetFlags( IS_MOVED ); picker.SetItem( zone ); undoListPicker.PushItem( picker ); blockitemsList.PushItem( picker ); zonescount++; if( bboxInit ) bbox = zone->GetBoundingBox(); else bbox.Merge( zone->GetBoundingBox() ); bboxInit = false; } SaveCopyInUndoList( undoListPicker, UR_NEW ); // we should not ask PLUGINs to do these items: int copperLayerCount = GetBoard()->GetCopperLayerCount(); if( copperLayerCount > initialCopperLayerCount ) GetBoard()->SetCopperLayerCount( copperLayerCount ); // Enable all used layers, and make them visible: LSET enabledLayers = GetBoard()->GetEnabledLayers(); enabledLayers |= initialEnabledLayers; GetBoard()->SetEnabledLayers( enabledLayers ); GetBoard()->SetVisibleLayers( enabledLayers ); ReCreateLayerBox(); ReFillLayerWidget(); if( IsGalCanvasActive() ) static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( GetBoard() ); GetBoard()->BuildListOfNets(); GetBoard()->SynchronizeNetsAndNetClasses(); SetStatusText( wxEmptyString ); BestZoom(); // Finish block move command: wxPoint cpos = GetNearestGridPosition( bbox.Centre() ); blockmove.SetOrigin( bbox.GetOrigin() ); blockmove.SetSize( bbox.GetSize() ); blockmove.SetLastCursorPosition( cpos ); HandleBlockEnd( NULL ); return true; }
PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB, wxT( "Pcbnew" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PCB_EDIT_FRAME_NAME ) { m_showBorderAndTitleBlock = true; // true to display sheet references m_showAxis = false; // true to display X and Y axis m_showOriginAxis = true; m_showGridAxis = true; m_SelTrackWidthBox = NULL; m_SelViaSizeBox = NULL; m_SelLayerBox = NULL; m_show_microwave_tools = false; m_show_layer_manager_tools = true; m_hotkeysDescrList = g_Board_Editor_Hokeys_Descr; m_hasAutoSave = true; m_RecordingMacros = -1; m_microWaveToolBar = NULL; m_rotationAngle = 900; for ( int i = 0; i < 10; i++ ) m_Macros[i].m_Record.clear(); // Create GAL canvas EDA_DRAW_PANEL_GAL* galCanvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ); SetGalCanvas( galCanvas ); SetBoard( new BOARD() ); // Create the PCB_LAYER_WIDGET *after* SetBoard(): wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); int pointSize = font.GetPointSize(); int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); // printf( "pointSize:%d 80%%:%d\n", pointSize, (pointSize*8)/10 ); if( screenHeight <= 900 ) pointSize = (pointSize * 8) / 10; m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), pointSize ); m_drc = new DRC( this ); // these 2 objects point to each other wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) ); SetIcon( icon ); // LoadSettings() *after* creating m_LayersManager, because LoadSettings() // initialize parameters in m_LayersManager LoadSettings( config() ); SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) ); GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax ); // PCB drawings start in the upper left corner. GetScreen()->m_Center = false; SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); if( m_canvas ) m_canvas->SetEnableBlockCommands( true ); ReCreateMenuBar(); ReCreateHToolbar(); ReCreateAuxiliaryToolbar(); ReCreateVToolbar(); ReCreateOptToolbar(); ReCreateMicrowaveVToolbar(); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiz; horiz.HorizontalToolbarPane(); EDA_PANEINFO vert; vert.VerticalToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template. // LAYER_WIDGET is floatable, but initially docked at far right EDA_PANEINFO lyrs; lyrs.LayersToolbarPane(); lyrs.MinSize( m_Layers->GetBestSize() ); // updated in ReFillLayerWidget lyrs.BestSize( m_Layers->GetBestSize() ); lyrs.Caption( _( "Visibles" ) ); lyrs.TopDockable( false ).BottomDockable( false ); if( m_mainToolBar ) // The main horizontal toolbar { m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) ); } if( m_auxiliaryToolBar ) // the auxiliary horizontal toolbar, that shows track and via sizes, zoom ...) { m_auimgr.AddPane( m_auxiliaryToolBar, wxAuiPaneInfo( horiz ).Name( wxT( "m_auxiliaryToolBar" ) ).Top().Row( 1 ) ); } if( m_microWaveToolBar ) // The auxiliary vertical right toolbar (currently microwave tools) m_auimgr.AddPane( m_microWaveToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_microWaveToolBar" ) ). Right().Layer( 1 ).Position(1).Hide() ); if( m_drawToolBar ) // The main right vertical toolbar m_auimgr.AddPane( m_drawToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Layer( 2 ) ); // Add the layer manager ( most right side of pcbframe ) m_auimgr.AddPane( m_Layers, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 3 ) ); if( m_optionsToolBar ) // The left vertical toolbar (fast acces display options of Pcbnew) { m_auimgr.AddPane( m_optionsToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left().Layer(1) ); m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools ); m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools ); } if( m_canvas ) m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); if( GetGalCanvas() ) m_auimgr.AddPane( (wxWindow*) GetGalCanvas(), wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() ); if( m_messagePanel ) m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) ); ReFillLayerWidget(); // this is near end because contents establish size m_Layers->ReFillRender(); // Update colors in Render after the config is read syncLayerWidgetLayer(); m_auimgr.Update(); setupTools(); Zoom_Automatique( false ); EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = LoadCanvasTypeSetting(); if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ) { if( GetGalCanvas()->SwitchBackend( canvasType ) ) UseGalCanvas( true ); } enableGALSpecificMenus(); }
PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : PCB_BASE_FRAME( parent, PCB_FRAME_TYPE, title, pos, size, style, PCB_EDIT_FRAME_NAME ) { m_FrameName = PCB_EDIT_FRAME_NAME; m_showBorderAndTitleBlock = true; // true to display sheet references m_showAxis = false; // true to display X and Y axis m_showOriginAxis = true; m_showGridAxis = true; m_SelTrackWidthBox = NULL; m_SelViaSizeBox = NULL; m_SelLayerBox = NULL; m_show_microwave_tools = false; m_show_layer_manager_tools = true; m_HotkeysZoomAndGridList = g_Board_Editor_Hokeys_Descr; m_hasAutoSave = true; m_RecordingMacros = -1; m_microWaveToolBar = NULL; m_useCmpFileForFpNames = true; m_footprintLibTable = NULL; m_globalFootprintTable = NULL; m_rotationAngle = 900; #ifdef KICAD_SCRIPTING_WXPYTHON m_pythonPanel = NULL; #endif for ( int i = 0; i < 10; i++ ) m_Macros[i].m_Record.clear(); SetBoard( new BOARD() ); if( GetGalCanvas() ) { ViewReloadBoard( m_Pcb ); // update the tool manager with the new board and its view. if( m_toolManager ) m_toolManager->SetEnvironment( m_Pcb, GetGalCanvas()->GetView(), GetGalCanvas()->GetViewControls(), this ); } // Create the PCB_LAYER_WIDGET *after* SetBoard(): wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); int pointSize = font.GetPointSize(); int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); // printf( "pointSize:%d 80%%:%d\n", pointSize, (pointSize*8)/10 ); if( screenHeight <= 900 ) pointSize = (pointSize * 8) / 10; m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), pointSize ); m_drc = new DRC( this ); // these 2 objects point to each other wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) ); SetIcon( icon ); SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) ); // PCB drawings start in the upper left corner. GetScreen()->m_Center = false; // LoadSettings() *after* creating m_LayersManager, because LoadSettings() // initialize parameters in m_LayersManager LoadSettings(); // Be sure options are updated m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill; m_DisplayPadFill = DisplayOpt.DisplayPadFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill; m_DisplayPadNum = DisplayOpt.DisplayPadNum; m_DisplayModEdge = DisplayOpt.DisplayModEdge; m_DisplayModText = DisplayOpt.DisplayModText; SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); if( m_canvas ) m_canvas->SetEnableBlockCommands( true ); ReCreateMenuBar(); ReCreateHToolbar(); ReCreateAuxiliaryToolbar(); ReCreateVToolbar(); ReCreateOptToolbar(); ReCreateMicrowaveVToolbar(); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiz; horiz.HorizontalToolbarPane(); EDA_PANEINFO vert; vert.VerticalToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template. // LAYER_WIDGET is floatable, but initially docked at far right EDA_PANEINFO lyrs; lyrs.LayersToolbarPane(); lyrs.MinSize( m_Layers->GetBestSize() ); // updated in ReFillLayerWidget lyrs.BestSize( m_Layers->GetBestSize() ); lyrs.Caption( _( "Visibles" ) ); if( m_mainToolBar ) // The main horizontal toolbar { m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) ); } if( m_auxiliaryToolBar ) // the auxiliary horizontal toolbar, that shows track and via sizes, zoom ...) { m_auimgr.AddPane( m_auxiliaryToolBar, wxAuiPaneInfo( horiz ).Name( wxT( "m_auxiliaryToolBar" ) ).Top().Row( 1 ) ); } if( m_microWaveToolBar ) // The auxiliary vertical right toolbar (currently microwave tools) m_auimgr.AddPane( m_microWaveToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_microWaveToolBar" ) ).Right().Layer( 1 ).Position(1).Hide() ); if( m_drawToolBar ) // The main right vertical toolbar m_auimgr.AddPane( m_drawToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_VToolBar" ) ).Right().Layer( 2 ) ); // Add the layer manager ( most right side of pcbframe ) m_auimgr.AddPane( m_Layers, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 3 ) ); if( m_optionsToolBar ) // The left vertical toolbar (fast acces display options of Pcbnew) { m_auimgr.AddPane( m_optionsToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left().Layer(1) ); m_auimgr.GetPane( wxT( "m_LayersManagerToolBar" ) ).Show( m_show_layer_manager_tools ); m_auimgr.GetPane( wxT( "m_microWaveToolBar" ) ).Show( m_show_microwave_tools ); } if( m_canvas ) m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); if( GetGalCanvas() ) m_auimgr.AddPane( (wxWindow*) GetGalCanvas(), wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() ); if( m_messagePanel ) m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) ); #ifdef KICAD_SCRIPTING_WXPYTHON // Add the scripting panel EDA_PANEINFO pythonAuiInfo; pythonAuiInfo.ScriptingToolbarPane(); pythonAuiInfo.Caption( wxT( "Python Scripting" ) ); pythonAuiInfo.MinSize( wxSize( 200, 100 ) ); pythonAuiInfo.BestSize( wxSize( GetClientSize().x/2, 200 ) ); pythonAuiInfo.Hide(); m_pythonPanel = CreatePythonShellWindow( this ); m_auimgr.AddPane( m_pythonPanel, pythonAuiInfo.Name( wxT( "PythonPanel" ) ).Bottom().Layer(9) ); m_pythonPanelHidden = true; #endif ReFillLayerWidget(); // this is near end because contents establish size m_Layers->ReFillRender(); // Update colors in Render after the config is read syncLayerWidgetLayer(); m_auimgr.Update(); if( m_globalFootprintTable == NULL ) { try { m_globalFootprintTable = new FP_LIB_TABLE(); if( !FP_LIB_TABLE::LoadGlobalTable( *m_globalFootprintTable ) ) { DisplayInfoMessage( this, wxT( "You have run Pcbnew for the first time using the " "new footprint library table method for finding " "footprints. Pcbnew has either copied the default " "table or created an empty table in your home " "folder. You must first configure the library " "table to include all footprint libraries not " "included with KiCad. See the \"Footprint Library " "Table\" section of the CvPcb documentation for " "more information." ) ); } } catch( IO_ERROR ioe ) { wxString msg; msg.Printf( _( "An error occurred attempting to load the global footprint library " "table:\n\n%s" ), GetChars( ioe.errorText ) ); DisplayError( this, msg ); } } setupTools(); }
GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* aParent, const wxString& aTitle, const wxPoint& aPosition, const wxSize& aSize, long aStyle ) : EDA_DRAW_FRAME( aParent, GERBER_FRAME_TYPE, aTitle, aPosition, aSize, aStyle, GERBVIEW_FRAME_NAME ) { m_colorsSettings = &g_ColorsSettings; m_gerberLayout = NULL; m_FrameName = GERBVIEW_FRAME_NAME; m_show_layer_manager_tools = true; m_showAxis = true; // true to show X and Y axis on screen m_showBorderAndTitleBlock = false; // true for reference drawings. m_HotkeysZoomAndGridList = s_Gerbview_Hokeys_Descr; m_SelLayerBox = NULL; m_DCodeSelector = NULL; m_displayMode = 0; m_drillFileHistory.SetBaseId( ID_GERBVIEW_DRILL_FILE1 ); if( m_canvas ) m_canvas->SetEnableBlockCommands( true ); // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) ); SetIcon( icon ); SetLayout( new GBR_LAYOUT() ); SetVisibleLayers( FULL_LAYERS ); // All 32 layers visible. SetScreen( new GBR_SCREEN( GetGerberLayout()->GetPageSettings().GetSizeIU() ) ); // Create the PCB_LAYER_WIDGET *after* SetLayout(): wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); int pointSize = font.GetPointSize(); int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); if( screenHeight <= 900 ) pointSize = (pointSize * 8) / 10; m_LayersManager = new GERBER_LAYER_WIDGET( this, m_canvas, pointSize ); // LoadSettings() *after* creating m_LayersManager, because LoadSettings() // initialize parameters in m_LayersManager LoadSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); if( m_LastGridSizeId < 0 ) m_LastGridSizeId = 0; if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000 ) m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000; GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); ReCreateMenuBar(); ReCreateHToolbar(); ReCreateOptToolbar(); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiz; horiz.HorizontalToolbarPane(); EDA_PANEINFO vert; vert.VerticalToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); EDA_PANEINFO lyrs; lyrs.LayersToolbarPane(); lyrs.MinSize( m_LayersManager->GetBestSize() ); lyrs.BestSize( m_LayersManager->GetBestSize() ); lyrs.Caption( _( "Visibles" ) ); if( m_mainToolBar ) m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) ); if( m_drawToolBar ) m_auimgr.AddPane( m_drawToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right().Row( 1 ) ); m_auimgr.AddPane( m_LayersManager, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 0 ) ); if( m_optionsToolBar ) m_auimgr.AddPane( m_optionsToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() ); if( m_canvas ) m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); if( m_messagePanel ) m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer( 10 ) ); ReFillLayerWidget(); // this is near end because contents establish size m_LayersManager->ReFillRender(); // Update colors in Render after the config is read m_auimgr.Update(); }
bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) { wxString filetypes; wxArrayString filenamesList; wxFileName filename = aFullFileName; wxString currentPath; if( !filename.IsOk() ) { /* Standard gerber filetypes * (See http://en.wikipedia.org/wiki/Gerber_File) * the .gbr (.pho in legacy files) extension is the default used in Pcbnew * However there are a lot of other extensions used for gerber files * Because the first letter is usually g, we accept g* as extension * (Mainly internal copper layers do not have specific extension, * and filenames are like *.g1, *.g2 *.gb1 ...). * Now (2014) Ucamco (the company which manager the Gerber format) encourage * use of .gbr only and the Gerber X2 file format. */ filetypes = _( "Gerber files (.g* .lgr .pho)" ); filetypes << wxT("|"); filetypes += wxT("*.g*;*.G*;*.pho;*.PHO" ); filetypes << wxT("|"); /* Special gerber filetypes */ filetypes += _( "Top layer (*.GTL)|*.GTL;*.gtl|" ); filetypes += _( "Bottom layer (*.GBL)|*.GBL;*.gbl|" ); filetypes += _( "Bottom solder resist (*.GBS)|*.GBS;*.gbs|" ); filetypes += _( "Top solder resist (*.GTS)|*.GTS;*.gts|" ); filetypes += _( "Bottom overlay (*.GBO)|*.GBO;*.gbo|" ); filetypes += _( "Top overlay (*.GTO)|*.GTO;*.gto|" ); filetypes += _( "Bottom paste (*.GBP)|*.GBP;*.gbp|" ); filetypes += _( "Top paste (*.GTP)|*.GTP;*.gtp|" ); filetypes += _( "Keep-out layer (*.GKO)|*.GKO;*.gko|" ); filetypes += _( "Mechanical layers (*.GMx)|*.GM1;*.gm1;*.GM2;*.gm2;*.GM3;*.gm3|" ); filetypes += _( "Top Pad Master (*.GPT)|*.GPT;*.gpt|" ); filetypes += _( "Bottom Pad Master (*.GPB)|*.GPB;*.gpb|" ); /* All filetypes */ filetypes += AllFilesWildcard; /* Use the current working directory if the file name path does not exist. */ if( filename.DirExists() ) currentPath = filename.GetPath(); else currentPath = m_mruPath; wxFileDialog dlg( this, _( "Open Gerber File" ), currentPath, filename.GetFullName(), filetypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) return false; dlg.GetPaths( filenamesList ); // @todo Take a closer look at the CWD switching here. The current working directory // gets changed by wxFileDialog because the wxFD_CHANGE_DIR flag is set. Is this the // appropriate behavior? The current working directory is not returned to the previous // value so this may be an issue elsewhere. currentPath = wxGetCwd(); m_mruPath = currentPath; } else { wxFileName filename = aFullFileName; filenamesList.Add( aFullFileName ); currentPath = filename.GetPath(); m_mruPath = currentPath; } // Read gerber files: each file is loaded on a new GerbView layer int layer = getActiveLayer(); for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) { wxFileName filename = filenamesList[ii]; if( !filename.IsAbsolute() ) filename.SetPath( currentPath ); m_lastFileName = filename.GetFullPath(); setActiveLayer( layer, false ); if( Read_GERBER_File( filename.GetFullPath(), filename.GetFullPath() ) ) { UpdateFileHistory( m_lastFileName ); layer = getNextAvailableLayer( layer ); if( layer == NO_AVAILABLE_LAYERS ) { wxString msg = wxT( "No more empty available layers.\n" "The remaining gerber files will not be loaded." ); wxMessageBox( msg ); break; } setActiveLayer( layer, false ); } } Zoom_Automatique( false ); // Synchronize layers tools with actual active layer: ReFillLayerWidget(); setActiveLayer( getActiveLayer() ); m_LayersManager->UpdateLayerIcons(); syncLayerBox(); return true; }
bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) { wxString filetypes; wxArrayString filenamesList; wxFileName filename = aFullFileName; wxString currentPath; if( !filename.IsOk() ) { filetypes = wxGetTranslation( DrillFileWildcard ); filetypes << wxT("|"); /* All filetypes */ filetypes += wxGetTranslation( AllFilesWildcard ); /* Use the current working directory if the file name path does not exist. */ if( filename.DirExists() ) currentPath = filename.GetPath(); else currentPath = m_mruPath; wxFileDialog dlg( this, _( "Open Drill File" ), currentPath, filename.GetFullName(), filetypes, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) return false; dlg.GetPaths( filenamesList ); currentPath = wxGetCwd(); m_mruPath = currentPath; } else { wxFileName filename = aFullFileName; filenamesList.Add( aFullFileName ); currentPath = filename.GetPath(); m_mruPath = currentPath; } // Read gerber files: each file is loaded on a new GerbView layer int layer = getActiveLayer(); for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ ) { wxFileName filename = filenamesList[ii]; if( !filename.IsAbsolute() ) filename.SetPath( currentPath ); m_lastFileName = filename.GetFullPath(); setActiveLayer( layer, false ); if( Read_EXCELLON_File( filename.GetFullPath() ) ) { // Update the list of recent drill files. UpdateFileHistory( filename.GetFullPath(), &m_drillFileHistory ); layer = getNextAvailableLayer( layer ); if( layer == NO_AVAILABLE_LAYERS ) { wxString msg = wxT( "No more empty available layers.\n" "The remaining gerber files will not be loaded." ); wxMessageBox( msg ); break; } setActiveLayer( layer, false ); } } Zoom_Automatique( false ); // Synchronize layers tools with actual active layer: ReFillLayerWidget(); setActiveLayer( getActiveLayer() ); m_LayersManager->UpdateLayerIcons(); syncLayerBox(); return true; }