void WinEDA_DrawFrame::Zoom_Automatique(bool move_mouse_cursor) /**************************************************************/ /* Affiche le Schema au meilleur zoom au meilleur centrage pour le dessin de facon a avoir toute la feuille affichee a l'ecran */ { int bestzoom; bestzoom = BestZoom(); m_CurrentScreen->SetZoom(bestzoom); Recadre_Trace(move_mouse_cursor); }
// JEY TODO: Obsolete; replace with ACTIONS::zoomFitScreen void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer ) { BASE_SCREEN* screen = GetScreen(); // Set the best zoom and get center point. // BestZoom() can compute an illegal zoom if the client window size // is small, say because frame is not maximized. So use the clamping form // of SetZoom(): double bestzoom = BestZoom(); screen->SetScalingFactor( bestzoom ); if( !screen->m_Initialized ) SetCrossHairPosition( GetScrollCenterPosition() ); m_toolManager->RunAction( "common.Control.zoomFitScreen", true ); }
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; }
LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, CMP_LIBRARY* aLibrary ) : SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Library Browser" ), wxDefaultPosition, wxDefaultSize, aFrameType==FRAME_SCH_VIEWER ? KICAD_DEFAULT_DRAWFRAME_STYLE : KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT, GetLibViewerFrameName() ) { wxASSERT( aFrameType==FRAME_SCH_VIEWER || aFrameType==FRAME_SCH_VIEWER_MODAL ); if( aFrameType == FRAME_SCH_VIEWER_MODAL ) SetModal( true ); wxAcceleratorTable table( ACCEL_TABLE_CNT, accels ); m_FrameName = GetLibViewerFrameName(); m_configPath = wxT( "LibraryViewer" ); // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( library_browse_xpm ) ); SetIcon( icon ); m_HotkeysZoomAndGridList = s_Viewlib_Hokeys_Descr; m_cmpList = NULL; m_libList = NULL; SetScreen( new SCH_SCREEN() ); GetScreen()->m_Center = true; // Axis origin centered on screen. LoadSettings( config() ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); // Initialize grid id to the default value (50 mils): m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); ReCreateHToolbar(); ReCreateVToolbar(); wxSize size = GetClientSize(); size.y -= m_MsgFrameHeight + 2; wxPoint win_pos( 0, 0 ); if( !aLibrary ) { // Creates the libraries window display m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST, wxPoint( 0, 0 ), wxSize(m_libListWidth, -1), 0, NULL, wxLB_HSCROLL ); } else { m_libraryName = aLibrary->GetName(); m_entryName.Clear(); m_unit = 1; m_convert = 1; m_libListWidth = 0; } // Creates the component window display win_pos.x = m_libListWidth; m_cmpList = new wxListBox( this, ID_LIBVIEW_CMP_LIST, wxPoint( 0, 0 ), wxSize(m_cmpListWidth, -1), 0, NULL, wxLB_HSCROLL ); if( m_libList ) ReCreateListLib(); DisplayLibInfos(); if( m_canvas ) m_canvas->SetAcceleratorTable( table ); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiz; horiz.HorizontalToolbarPane(); EDA_PANEINFO vert; vert.VerticalToolbarPane(); EDA_PANEINFO info; info.InfoToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); // Manage main toolbal m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiz ).Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) ); // Manage the left window (list of libraries) if( m_libList ) m_auimgr.AddPane( m_libList, wxAuiPaneInfo( info ).Name( wxT( "m_libList" ) ). Left().Row( 0 ) ); // Manage the list of components) m_auimgr.AddPane( m_cmpList, wxAuiPaneInfo( info ).Name( wxT( "m_cmpList" ) ). Left().Row( 1 ) ); // Manage the draw panel m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); // Manage the message panel m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) ); /* Now the minimum windows are fixed, set library list * and component list of the previous values from last viewlib use */ if( m_libList ) { m_auimgr.GetPane( m_libList ).MinSize( wxSize( 80, -1) ); m_auimgr.GetPane( m_libList ).BestSize( wxSize(m_libListWidth, -1) ); } m_auimgr.GetPane( m_cmpList ).MinSize( wxSize( 80, -1) ); m_auimgr.GetPane( m_cmpList ).BestSize(wxSize(m_cmpListWidth, -1) ); m_auimgr.Update(); // Now Drawpanel is sized, we can use BestZoom to show the component (if any) #ifdef USE_WX_GRAPHICS_CONTEXT GetScreen()->SetZoom( BestZoom() ); #else Zoom_Automatique( false ); #endif Show( true ); }
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType ) : PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ), wxDefaultPosition, wxDefaultSize, aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT : KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintViewerFrameName() ) { wxASSERT( aFrameType==FRAME_PCB_MODULE_VIEWER || aFrameType==FRAME_PCB_MODULE_VIEWER_MODAL ); if( aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ) SetModal( true ); wxAcceleratorTable table( DIM( accels ), accels ); m_FrameName = GetFootprintViewerFrameName(); m_configPath = wxT( "FootprintViewer" ); m_showAxis = true; // true to draw axis. // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) ); SetIcon( icon ); m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr; m_libList = new wxListBox( this, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL ); m_footprintList = new wxListBox( this, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL ); 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 ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); ReCreateHToolbar(); ReCreateVToolbar(); ReCreateLibraryList(); UpdateTitle(); // If a footprint was previously loaded, reload it if( getCurNickname().size() && getCurFootprintName().size() ) { FPID id; id.SetLibNickname( getCurNickname() ); id.SetFootprintName( getCurFootprintName() ); GetBoard()->Add( loadFootprint( id ) ); } if( m_canvas ) m_canvas->SetAcceleratorTable( table ); m_auimgr.SetManagedWindow( this ); wxSize minsize(100,-1); // Min size of list boxes // Main toolbar is initially docked at the top of the main window and dockable on any side. // The close button is disable because the footprint viewer has no main menu to re-enable it. // The tool bar will only be dockable on the top or bottom of the main frame window. This is // most likely due to the fact that the other windows are not dockable and are preventing the // tool bar from docking on the right and left. wxAuiPaneInfo toolbarPaneInfo; toolbarPaneInfo.Name( wxT( "m_mainToolBar" ) ).ToolbarPane().Top().CloseButton( false ); EDA_PANEINFO info; info.InfoToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); // Manage main toolbar, top pane m_auimgr.AddPane( m_mainToolBar, toolbarPaneInfo ); // Manage the list of libraries, left pane. m_auimgr.AddPane( m_libList, wxAuiPaneInfo( info ).Name( wxT( "m_libList" ) ) .Left().Row( 1 ).MinSize( minsize ) ); // Manage the list of footprints, center pane. m_auimgr.AddPane( m_footprintList, wxAuiPaneInfo( info ).Name( wxT( "m_footprintList" ) ) .Left().Row( 2 ).MinSize( minsize ) ); // Manage the draw panel, right pane. m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); // Manage the message panel, bottom pane. m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom() ); if( !m_perspective.IsEmpty() ) { // Restore last saved sizes, pos and other params // However m_mainToolBar size cannot be set to its last saved size // because the actual size change depending on the way modview was called: // the tool to export the current footprint exist or not. // and the saved size is not always OK // the trick is to get the default toolbar size, and set the size after // calling LoadPerspective wxSize tbsize = m_mainToolBar->GetSize(); m_auimgr.LoadPerspective( m_perspective, false ); m_auimgr.GetPane( m_mainToolBar ).BestSize( tbsize ); } #if 0 // no. // Set min size (overwrite params read in LoadPerspective(), if any) m_auimgr.GetPane( m_libList ).MinSize( minsize ); m_auimgr.GetPane( m_footprintList ).MinSize( minsize ); #endif // after changing something to the aui manager, // call Update()() to reflect the changes m_auimgr.Update(); // Now Drawpanel is sized, we can use BestZoom to show the component (if any) #ifdef USE_WX_GRAPHICS_CONTEXT GetScreen()->SetZoom( BestZoom() ); #else Zoom_Automatique( false ); #endif Show( true ); }
FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType ) : PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT, FOOTPRINT_WIZARD_FRAME_NAME ) { wxASSERT( aFrameType==FRAME_PCB_FOOTPRINT_WIZARD_MODAL ); if( aFrameType == FRAME_PCB_FOOTPRINT_WIZARD_MODAL ) SetModal( true ); wxAcceleratorTable table( ACCEL_TABLE_CNT, accels ); m_FrameName = FOOTPRINT_WIZARD_FRAME_NAME; m_configPath = wxT( "FootprintWizard" ); m_showAxis = true; // true to draw axis. // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) ); SetIcon( icon ); m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr; m_wizardName.Empty(); 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 ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); ReCreateHToolbar(); ReCreateVToolbar(); // Creates the parameter pages list m_pageList = new wxListBox( this, ID_FOOTPRINT_WIZARD_PAGE_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL ); // Creates the The list of parameters for the current parameter page m_parameterGrid = new wxGrid( this, ID_FOOTPRINT_WIZARD_PARAMETER_LIST ); m_parameterGrid->CreateGrid( 1, 3 ); // Columns m_parameterGrid->SetColLabelValue( 0, _( "Parameter" ) ); m_parameterGrid->SetColLabelValue( 1, _( "Value" ) ); m_parameterGrid->SetColLabelValue( 2, _( "Units" ) ); m_parameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); m_parameterGrid->AutoSizeColumns(); ReCreatePageList(); DisplayWizardInfos(); if( m_canvas ) m_canvas->SetAcceleratorTable( table ); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiztb; horiztb.HorizontalToolbarPane(); EDA_PANEINFO info; info.InfoToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); // Manage main toolbal m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiztb ). Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) ); // Manage the left window (list of parameter pages) EDA_PANEINFO paneList; paneList.InfoToolbarPane().Name( wxT( "m_pageList" ) ).Left().Row( 0 ); m_auimgr.AddPane( m_pageList, wxAuiPaneInfo( paneList ) ); // Manage the parameters grid editor for the current parameter page EDA_PANEINFO panePrms; panePrms.InfoToolbarPane().Name( wxT( "m_parameterGrid" ) ).Left().Row( 1 ); m_auimgr.AddPane( m_parameterGrid, wxAuiPaneInfo( panePrms ) ); // Manage the draw panel m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); // Manage the message panel m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(1) ); // Gives a min size and the last saved size to left windows m_auimgr.GetPane( m_pageList ).MinSize( wxSize(60, -1 ) ); m_auimgr.GetPane( m_pageList ).BestSize( wxSize(m_pageListWidth, -1) ); m_auimgr.GetPane( m_parameterGrid ).MinSize( wxSize( 120, -1 ) ); m_auimgr.GetPane( m_parameterGrid ).BestSize( wxSize(m_parameterGridWidth, -1) ); m_auimgr.Update(); // Now Drawpanel is sized, we can use BestZoom to show the component (if any) #ifdef USE_WX_GRAPHICS_CONTEXT GetScreen()->SetZoom( BestZoom() ); #else Zoom_Automatique( false ); #endif Show( true ); this->SelectFootprintWizard(); }
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; }
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType ) : PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ), wxDefaultPosition, wxDefaultSize, aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ? #ifdef __WINDOWS__ KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP : #else KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT : #endif KICAD_DEFAULT_DRAWFRAME_STYLE, FOOTPRINT_VIEWER_FRAME_NAME ) { wxASSERT( aFrameType==FRAME_PCB_MODULE_VIEWER || aFrameType==FRAME_PCB_MODULE_VIEWER_MODAL ); if( aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ) SetModal( true ); m_configFrameName = FOOTPRINT_VIEWER_FRAME_NAME; m_showAxis = true; // true to draw axis. // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) ); SetIcon( icon ); m_hotkeysDescrList = g_Module_Viewer_Hokeys_Descr; m_libList = new wxListBox( this, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL ); m_footprintList = new wxListBox( this, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL ); SetBoard( new BOARD() ); // 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().GetDefault()->SetClearance(0); // 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 ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); // Menu bar is not mandatory: uncomment/comment the next line // to add/remove the menubar ReCreateMenuBar(); ReCreateHToolbar(); ReCreateVToolbar(); ReCreateLibraryList(); UpdateTitle(); PCB_BASE_FRAME* parentFrame = static_cast<PCB_BASE_FRAME*>( Kiway().Player( FRAME_PCB, true ) ); // Create GAL canvas PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, parentFrame->GetGalCanvas()->GetBackend() ); SetGalCanvas( drawPanel ); // Create the manager and dispatcher & route draw panel events to the dispatcher m_toolManager = new TOOL_MANAGER; m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(), drawPanel->GetViewControls(), this ); m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager ); drawPanel->SetEventDispatcher( m_toolDispatcher ); m_toolManager->RegisterTool( new PCBNEW_CONTROL ); m_toolManager->ResetTools( TOOL_BASE::RUN ); // If a footprint was previously loaded, reload it if( getCurNickname().size() && getCurFootprintName().size() ) { FPID id; id.SetLibNickname( getCurNickname() ); id.SetFootprintName( getCurFootprintName() ); GetBoard()->Add( loadFootprint( id ) ); } drawPanel->DisplayBoard( m_Pcb ); updateView(); m_auimgr.SetManagedWindow( this ); wxSize minsize(100,-1); // Min size of list boxes // Main toolbar is initially docked at the top of the main window and dockable on any side. // The close button is disable because the footprint viewer has no main menu to re-enable it. // The tool bar will only be dockable on the top or bottom of the main frame window. This is // most likely due to the fact that the other windows are not dockable and are preventing the // tool bar from docking on the right and left. wxAuiPaneInfo toolbarPaneInfo; toolbarPaneInfo.Name( wxT( "m_mainToolBar" ) ).ToolbarPane().Top().CloseButton( false ); EDA_PANEINFO info; info.InfoToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); // Manage main toolbar, top pane m_auimgr.AddPane( m_mainToolBar, toolbarPaneInfo ); // Manage the list of libraries, left pane. m_auimgr.AddPane( m_libList, wxAuiPaneInfo( info ).Name( wxT( "m_libList" ) ) .Left().Row( 1 ).MinSize( minsize ) ); // Manage the list of footprints, center pane. m_auimgr.AddPane( m_footprintList, wxAuiPaneInfo( info ).Name( wxT( "m_footprintList" ) ) .Left().Row( 2 ).MinSize( minsize ) ); // Manage the draw panel, right pane. m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); m_auimgr.AddPane( (wxWindow*) GetGalCanvas(), wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() ); // Manage the message panel, bottom pane. m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom() ); if( !m_perspective.IsEmpty() ) { // Restore last saved sizes, pos and other params // However m_mainToolBar size cannot be set to its last saved size // because the actual size change depending on the way modview was called: // the tool to export the current footprint exist or not. // and the saved size is not always OK // the trick is to get the default toolbar size, and set the size after // calling LoadPerspective wxSize tbsize = m_mainToolBar->GetSize(); m_auimgr.LoadPerspective( m_perspective, false ); m_auimgr.GetPane( m_mainToolBar ).BestSize( tbsize ); } // after changing something to the aui manager, // call Update()() to reflect the changes m_auimgr.Update(); // Now Drawpanel is sized, we can use BestZoom to show the component (if any) #ifdef USE_WX_GRAPHICS_CONTEXT GetScreen()->SetZoom( BestZoom() ); #else Zoom_Automatique( false ); #endif UseGalCanvas( parentFrame->IsGalCanvasActive() ); if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame { Raise(); // On some window managers, this is needed Show( true ); } } FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME() { if( m_Draw3DFrame ) m_Draw3DFrame->Destroy(); } void FOOTPRINT_VIEWER_FRAME::OnCloseWindow( wxCloseEvent& Event ) { DBG(printf( "%s:\n", __func__ );) if( IsGalCanvasActive() )
SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): SCH_BASE_FRAME( aKiway, aParent, SCHEMATIC_FRAME_TYPE, wxT( "Eeschema" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ), m_item_to_repeat( 0 ) { m_FrameName = SCH_EDIT_FRAME_NAME; m_showAxis = false; // true to show axis m_showBorderAndTitleBlock = true; // true to show sheet references m_CurrentSheet = new SCH_SHEET_PATH(); m_TextFieldSize = DEFAULT_SIZE_TEXT; m_DefaultSchematicFileName = NAMELESS_PROJECT; m_DefaultSchematicFileName += wxT( ".sch" ); m_showAllPins = false; m_previewPosition = wxDefaultPosition; m_previewSize = wxDefaultSize; m_printMonochrome = true; m_printSheetReference = true; m_HotkeysZoomAndGridList = s_Schematic_Hokeys_Descr; m_dlgFindReplace = NULL; m_findReplaceData = new wxFindReplaceData( wxFR_DOWN ); m_undoItem = NULL; m_hasAutoSave = true; SetForceHVLines( true ); SetDefaultLabelSize( DEFAULT_SIZE_TEXT ); CreateScreens(); // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) ); SetIcon( icon ); // Initialize grid id to the default value (50 mils): m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; LoadSettings( config() ); // Ensure m_LastGridSizeId is an offset inside the allowed schematic range if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000 ) m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_1 - ID_POPUP_GRID_LEVEL_1000 ) m_LastGridSizeId = ID_POPUP_GRID_LEVEL_1 - ID_POPUP_GRID_LEVEL_1000; SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); if( m_canvas ) m_canvas->SetEnableBlockCommands( true ); ReCreateMenuBar(); ReCreateHToolbar(); ReCreateVToolbar(); ReCreateOptToolbar(); // Initialize common print setup dialog settings. m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER ); m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM ); m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO ); m_pageSetupData.GetPrintData().SetNoCopies( 1 ); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiz; horiz.HorizontalToolbarPane(); EDA_PANEINFO vert; vert.VerticalToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); 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() ); 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) ); m_auimgr.Update(); // Now Drawpanel is sized, we can use BestZoom to show the component (if any) GetScreen()->SetZoom( BestZoom() ); }
LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, PART_LIB* aLibrary ) : SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Library Browser" ), wxDefaultPosition, wxDefaultSize, aFrameType==FRAME_SCH_VIEWER_MODAL ? #ifdef __WINDOWS__ KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP #else aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP #endif : KICAD_DEFAULT_DRAWFRAME_STYLE, aFrameType == FRAME_SCH_VIEWER_MODAL ? LIB_VIEW_FRAME_NAME_MODAL : LIB_VIEW_FRAME_NAME ) { wxASSERT( aFrameType == FRAME_SCH_VIEWER || aFrameType == FRAME_SCH_VIEWER_MODAL ); if( aFrameType == FRAME_SCH_VIEWER_MODAL ) SetModal( true ); // Force the frame name used in config. the lib viewer frame has a name // depending on aFrameType (needed to identify the frame by wxWidgets), // but only one configuration is preferable. m_configFrameName = LIB_VIEW_FRAME_NAME; // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( library_browse_xpm ) ); SetIcon( icon ); m_hotkeysDescrList = g_Viewlib_Hokeys_Descr; m_cmpList = NULL; m_libList = NULL; m_listPowerCmpOnly = false; SetScreen( new SCH_SCREEN( aKiway ) ); GetScreen()->m_Center = true; // Axis origin centered on screen. LoadSettings( config() ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); // Initialize grid id to the default value (50 mils): m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); // Menu bar is not mandatory: uncomment/comment the next line // to add/remove the menubar ReCreateMenuBar(); ReCreateHToolbar(); ReCreateVToolbar(); if( !aLibrary ) { // Creates the libraries window display m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST, wxPoint( 0, 0 ), wxSize(m_libListWidth, -1), 0, NULL, wxLB_HSCROLL ); } else { m_libraryName = aLibrary->GetName(); m_entryName.Clear(); m_unit = 1; m_convert = 1; m_libListWidth = 0; } // Creates the component window display m_cmpList = new wxListBox( this, ID_LIBVIEW_CMP_LIST, wxPoint( 0, 0 ), wxSize(m_cmpListWidth, -1), 0, NULL, wxLB_HSCROLL ); if( m_libList ) ReCreateListLib(); DisplayLibInfos(); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiz; horiz.HorizontalToolbarPane(); EDA_PANEINFO vert; vert.VerticalToolbarPane(); EDA_PANEINFO info; info.InfoToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); // Manage main toolbal m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiz ).Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) ); // Manage the left window (list of libraries) if( m_libList ) m_auimgr.AddPane( m_libList, wxAuiPaneInfo( info ).Name( wxT( "m_libList" ) ). Left().Row( 0 ) ); // Manage the list of components) m_auimgr.AddPane( m_cmpList, wxAuiPaneInfo( info ).Name( wxT( "m_cmpList" ) ). Left().Row( 1 ) ); // Manage the draw panel m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); // Manage the message panel m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) ); /* Now the minimum windows are fixed, set library list * and component list of the previous values from last viewlib use */ if( m_libList ) { m_auimgr.GetPane( m_libList ).MinSize( wxSize( 80, -1) ); m_auimgr.GetPane( m_libList ).BestSize( wxSize(m_libListWidth, -1) ); } m_auimgr.GetPane( m_cmpList ).MinSize( wxSize( 80, -1) ); m_auimgr.GetPane( m_cmpList ).BestSize(wxSize(m_cmpListWidth, -1) ); m_auimgr.Update(); // Now Drawpanel is sized, we can use BestZoom to show the component (if any) #ifdef USE_WX_GRAPHICS_CONTEXT GetScreen()->SetZoom( BestZoom() ); #else Zoom_Automatique( false ); #endif if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame { Raise(); Show( true ); } }
FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType ) : PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ), wxDefaultPosition, wxDefaultSize, aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | MODAL_MODE_EXTRASTYLE : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP, FOOTPRINT_WIZARD_FRAME_NAME ) { wxASSERT( aFrameType == FRAME_PCB_FOOTPRINT_WIZARD_MODAL ); // This frame is always show modal: SetModal( true ); m_messagesFrame = NULL; // This windows will be created the first time a wizard is loaded m_showAxis = true; // true to draw axis. // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) ); SetIcon( icon ); m_hotkeysDescrList = g_Module_Viewer_Hokeys_Descr; m_wizardName.Empty(); 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: DISPLAY_OPTIONS* disp_opts = (DISPLAY_OPTIONS*) GetDisplayOptions(); disp_opts->m_DisplayPadIsol = false; disp_opts->m_DisplayPadNum = true; GetBoard()->SetElementVisibility( PCB_VISIBLE(NO_CONNECTS_VISIBLE), false ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); ReCreateHToolbar(); ReCreateVToolbar(); // Creates the parameter pages list m_pageList = new wxListBox( this, ID_FOOTPRINT_WIZARD_PAGE_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL ); // Creates the The list of parameters for the current parameter page initParameterGrid(); ReCreatePageList(); DisplayWizardInfos(); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiztb; horiztb.HorizontalToolbarPane(); EDA_PANEINFO info; info.InfoToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); // Manage main toolbal m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiztb ). Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) ); // Manage the left window (list of parameter pages) EDA_PANEINFO paneList; paneList.InfoToolbarPane().Name( wxT( "m_pageList" ) ).Left().Row( 0 ); m_auimgr.AddPane( m_pageList, wxAuiPaneInfo( paneList ) ); // Manage the parameters grid editor for the current parameter page EDA_PANEINFO panePrms; panePrms.InfoToolbarPane().Name( wxT( "m_parameterGrid" ) ).Left().Row( 1 ); m_auimgr.AddPane( m_parameterGrid, wxAuiPaneInfo( panePrms ) ); // Manage the draw panel m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); // Manage the message panel m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(1) ); // Gives a min size and the last saved size to left windows m_auimgr.GetPane( m_pageList ).MinSize( wxSize(60, -1 ) ); m_auimgr.GetPane( m_pageList ).BestSize( wxSize(m_pageListWidth, -1) ); m_auimgr.GetPane( m_parameterGrid ).MinSize( wxSize( 120, -1 ) ); m_auimgr.GetPane( m_parameterGrid ).BestSize( wxSize(m_parameterGridWidth, -1) ); m_auimgr.Update(); // Now Drawpanel is sized, we can use BestZoom to show the component (if any) #ifdef USE_WX_GRAPHICS_CONTEXT GetScreen()->SetZoom( BestZoom() ); #else Zoom_Automatique( false ); #endif // 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 // SelectFootprintWizard(); }