void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard() { DIALOG_FOOTPRINT_WIZARD_LIST* selectWizard = new DIALOG_FOOTPRINT_WIZARD_LIST( this ); if( selectWizard->ShowModal() != wxID_OK ) return; FOOTPRINT_WIZARD* footprintWizard = selectWizard->GetWizard(); if( footprintWizard ) { m_wizardName = footprintWizard->GetName(); m_wizardDescription = footprintWizard->GetDescription(); } else { m_wizardName = wxT( "" ); m_wizardDescription = wxT( "" ); } ReloadFootprint(); Zoom_Automatique( false ); DisplayWizardInfos(); ReCreatePageList(); ReCreateParameterList(); }
void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() { if( m_pageList == NULL ) 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(); m_canvas->Refresh(); }
void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event ) { int ii = m_pageList->GetSelection(); if( ii < 0 ) return; ReCreateParameterList(); m_canvas->Refresh(); DisplayWizardInfos(); }
/** * Function SelectCurrentFootprint * Selects the current footprint name and display it */ void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) { int page = m_pageList->GetSelection(); FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); if( !footprintWizard ) return; if( page<0 ) return; int n = m_parameterGrid->GetNumberRows(); wxArrayString arr; wxArrayString ptList = footprintWizard->GetParameterTypes( page ); for( int i = 0; i<n; i++ ) { wxString value = m_parameterGrid->GetCellValue( i, 1 ); // if this parameter is expected to be an internal // unit convert it back from the user format if( ptList[i]==wxT( "IU" ) ) { LOCALE_IO toggle; double dValue; value.ToDouble( &dValue ); // convert from mils to inches where it's needed if( g_UserUnit==INCHES ) dValue = dValue / 1000.0; dValue = From_User_Unit( g_UserUnit, dValue ); value.Printf( wxT( "%f" ), dValue ); } // If our locale is set to use , for decimal point, just change it // to be scripting compatible arr.Add( value ); } wxString res = footprintWizard->SetParameterValues( page, arr ); ReloadFootprint(); DisplayWizardInfos(); }
void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event ) { EDA_DRAW_FRAME::OnActivate( event ); // Ensure we do not have old selection: if( !m_FrameIsActive ) return; bool footprintWizardsChanged = false; if( footprintWizardsChanged ) { // If we are here, the library list has changed, rebuild it ReCreatePageList(); DisplayWizardInfos(); } }
void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event ) { EDA_DRAW_FRAME::OnActivate( event ); // Ensure we do not have old selection: if( !event.GetActive() ) return; #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 }
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(); }
void FOOTPRINT_WIZARD_FRAME::ParametersUpdated( wxGridEvent& event ) { int page = m_pageList->GetSelection(); FOOTPRINT_WIZARD* footprintWizard = GetMyWizard(); if( !footprintWizard ) return; if( page < 0 ) return; wxArrayString prmValues = footprintWizard->GetParameterValues( page ); wxArrayString ptList = footprintWizard->GetParameterTypes( page ); bool has_changed = false; int count = m_parameterGrid->GetNumberRows(); // Skip extra event, useless if( event.GetString() == m_parameterGrid->GetCellValue( event.GetRow(), m_columnPrmValue ) ) return; for( int prm_id = 0; prm_id < count; ++prm_id ) { wxString value = m_parameterGrid->GetCellValue( prm_id, m_columnPrmValue ); // if this parameter is expected to be an internal // unit convert it back from the user format if( ptList[prm_id]==wxT( "IU" ) ) { // If our locale is set to use, for decimal point, just change it // to be scripting compatible LOCALE_IO toggle; double dValue; value.ToDouble( &dValue ); // convert from mils to inches where it's needed if( g_UserUnit==INCHES ) dValue = dValue / 1000.0; dValue = From_User_Unit( g_UserUnit, dValue ); // Internal units are int. Print them as int. value.Printf( "%d", KiROUND( dValue ) ); if( prmValues[prm_id].EndsWith(".0") ) { prmValues[prm_id].RemoveLast(); prmValues[prm_id].RemoveLast(); } } if( prmValues[prm_id] != value ) { has_changed = true; prmValues[prm_id] = value; } } if( has_changed ) { wxString res = footprintWizard->SetParameterValues( page, prmValues ); if( !res.IsEmpty() ) wxMessageBox( res ); ReloadFootprint(); DisplayWizardInfos(); } }
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(); }