void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent ) { bool tableChanged = false; int r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() ); if( r & 1 ) { wxString fileName = FP_LIB_TABLE::GetGlobalTableFileName(); try { GFootprintTable.Save( fileName ); tableChanged = true; } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error occurred saving the global footprint library table:\n'%s'\n%s" ), GetChars( fileName ), GetChars( ioe.errorText ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } if( r & 2 ) { wxString fileName = Prj().FootprintLibTblName(); try { Prj().PcbFootprintLibs()->Save( fileName ); tableChanged = true; } catch( const IO_ERROR& ioe ) { wxString msg = wxString::Format( _( "Error occurred saving the project footprint library table:\n'%s'\n%s" ), GetChars( fileName ), GetChars( ioe.errorText ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } if( tableChanged ) { wxBusyCursor dummy; BuildLIBRARY_LISTBOX(); m_FootprintsList.ReadFootprintFiles( Prj().PcbFootprintLibs() ); } }
CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) : KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, wxT( "CvPCB" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME ) { m_compListBox = NULL; m_footprintListBox = NULL; m_libListBox = NULL; m_mainToolBar = NULL; m_modified = false; m_isEESchemaNetlist = false; m_KeepCvpcbOpen = false; m_undefinedComponentCnt = 0; m_skipComponentSelect = false; m_NetlistFileExtension = wxT( "net" ); /* Name of the document footprint list * usually located in share/modules/footprints_doc * this is of the responsibility to users to create this file * if they want to have a list of footprints */ m_DocModulesFileName = DEFAULT_FOOTPRINTS_LIST_FILENAME; // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) ); SetIcon( icon ); SetAutoLayout( true ); LoadSettings( config() ); if( m_FrameSize.x < FRAME_MIN_SIZE_X ) m_FrameSize.x = FRAME_MIN_SIZE_X; if( m_FrameSize.y < FRAME_MIN_SIZE_Y ) m_FrameSize.y = FRAME_MIN_SIZE_Y; // Set minimal frame width and height SetSizeHints( FRAME_MIN_SIZE_X, FRAME_MIN_SIZE_Y, -1, -1, -1, -1 ); // Frame size and position SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); // create the status bar static const int dims[3] = { -1, -1, 250 }; CreateStatusBar( 3 ); SetStatusWidths( 3, dims ); ReCreateMenuBar(); ReCreateHToolbar(); // Create list of available modules and components of the schematic BuildCmpListBox(); BuildFOOTPRINTS_LISTBOX(); BuildLIBRARY_LISTBOX(); m_auimgr.SetManagedWindow( this ); UpdateTitle(); EDA_PANEINFO horiz; horiz.HorizontalToolbarPane(); EDA_PANEINFO info; info.InfoToolbarPane(); if( m_mainToolBar ) m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top() ); if( m_compListBox ) m_auimgr.AddPane( m_compListBox, wxAuiPaneInfo( horiz ).Name( wxT( "m_compListBox" ) ).CentrePane() ); if( m_libListBox) m_auimgr.AddPane( m_libListBox, wxAuiPaneInfo( info ).Name( wxT( "m_libListBox" ) ). Left().BestSize( (int) ( m_FrameSize.x * 0.20 ), m_FrameSize.y ) ); if( m_footprintListBox ) m_auimgr.AddPane( m_footprintListBox, wxAuiPaneInfo( info ).Name( wxT( "m_footprintListBox" ) ). Right().BestSize( (int) ( m_FrameSize.x * 0.30 ), m_FrameSize.y ) ); m_auimgr.Update(); }
bool CVPCB_MAINFRAME::ReadNetListAndFpFiles( const std::string& aNetlist ) { wxString msg; bool hasMissingNicks = false; ReadSchematicNetlist( aNetlist ); if( m_compListBox == NULL ) return false; LoadProjectFile(); wxSafeYield(); LoadFootprintFiles(); BuildFOOTPRINTS_LISTBOX(); BuildLIBRARY_LISTBOX(); m_compListBox->Clear(); if( m_netlist.AnyFootprintsLinked() ) { for( unsigned i = 0; i < m_netlist.GetCount(); i++ ) { COMPONENT* component = m_netlist.GetComponent( i ); if( component->GetFPID().empty() ) continue; if( component->GetFPID().IsLegacy() ) hasMissingNicks = true; } } // Check if footprint links were generated before the footprint library table was implemented. if( hasMissingNicks ) { msg = _( "Some of the assigned footprints are legacy entries (are missing lib nicknames). " "Would you like CvPcb to attempt to convert them to the new required LIB_ID format? " "(If you answer no, then these assignments will be cleared out and you will " "have to re-assign these footprints yourself.)" ); if( IsOK( this, msg ) ) { msg.Clear(); try { for( unsigned i = 0; i < m_netlist.GetCount(); i++ ) { COMPONENT* component = m_netlist.GetComponent( i ); if( component->GetFPID().IsLegacy() ) { // get this first here, it's possibly obsoleted if we get it too soon. FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs( Kiway() ); int guess = guessNickname( tbl, (LIB_ID*) &component->GetFPID() ); switch( guess ) { case 0: DBG(printf("%s: guessed OK ref:%s fpid:%s\n", __func__, TO_UTF8( component->GetReference() ), component->GetFPID().Format().c_str() );) m_modified = true; break; case 1: msg += wxString::Format( _( "Component \"%s\" footprint \"%s\" was <b>not found</b> in any library.\n" ), GetChars( component->GetReference() ), GetChars( component->GetFPID().GetLibItemName() ) ); break; case 2: msg += wxString::Format( _( "Component \"%s\" footprint \"%s\" was found in <b>multiple</b> libraries.\n" ), GetChars( component->GetReference() ), GetChars( component->GetFPID().GetLibItemName() ) ); break; } } } }
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles() { COMPONENT* component; wxString msg; bool isLegacy = true; ReadSchematicNetlist(); if( m_ListCmp == NULL ) return false; LoadProjectFile( m_NetlistFileName.GetFullPath() ); LoadFootprintFiles(); BuildFOOTPRINTS_LISTBOX(); BuildLIBRARY_LISTBOX(); m_ListCmp->Clear(); m_undefinedComponentCnt = 0; if( m_netlist.AnyFootprintsLinked() ) { for( unsigned i = 0; i < m_netlist.GetCount(); i++ ) { component = m_netlist.GetComponent( i ); if( component->GetFPID().empty() ) continue; if( isLegacy ) { if( !component->GetFPID().IsLegacy() ) isLegacy = false; } } } else { isLegacy = false; // None of the components have footprints assigned. } wxString missingLibs; // Check if footprint links were generated before the footprint library table was implemented. if( isLegacy ) { if( m_footprintLibTable->MissingLegacyLibs( m_ModuleLibNames, &missingLibs ) ) { msg = wxT( "The following legacy libraries are defined in the project file " "were not found in the footprint library table:\n\n" ) + missingLibs; msg += wxT( "\nDo you want to update the footprint library table before " "attempting to update the assigned footprints?" ); if( IsOK( this, msg ) ) { wxCommandEvent cmd; OnEditFootprintLibraryTable( cmd ); } } msg = wxT( "Some or all of the assigned footprints contain legacy entries. Would you " "like CvPcb to attempt to convert them to the new footprint library table " "format?" ); if( IsOK( this, msg ) ) { msg.Clear(); WX_STRING_REPORTER reporter( &msg ); if( !m_footprintLibTable->ConvertFromLegacy( m_netlist, m_ModuleLibNames, &reporter ) ) { HTML_MESSAGE_BOX dlg( this, wxEmptyString ); dlg.MessageSet( wxT( "The following errors occurred attempt to convert the " "footprint assignments:\n\n" ) ); dlg.ListSet( msg ); dlg.MessageSet( wxT( "\nYou will need to reassign them manually if you want them " "to be updated correctly the next time you import the " "netlist in Pcbnew." ) ); dlg.ShowModal(); } m_modified = true; } else { // Clear the legacy footprint assignments. for( unsigned i = 0; i < m_netlist.GetCount(); i++ ) { FPID emptyFPID; component = m_netlist.GetComponent( i ); component->SetFPID( emptyFPID ); m_modified = true; } } } for( unsigned i = 0; i < m_netlist.GetCount(); i++ ) { component = m_netlist.GetComponent( i ); msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1, GetChars( component->GetReference() ), GetChars( component->GetValue() ), GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ); m_ListCmp->AppendLine( msg ); if( component->GetFPID().empty() ) { m_undefinedComponentCnt += 1; continue; } } if( !m_netlist.IsEmpty() ) m_ListCmp->SetSelection( 0, true ); DisplayStatus(); UpdateTitle(); UpdateFileHistory( m_NetlistFileName.GetFullPath() ); return true; }
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles() { wxString msg; bool hasMissingNicks = false; FP_LIB_TABLE* tbl = FootprintLibs(); ReadSchematicNetlist(); if( m_ListCmp == NULL ) return false; LoadProjectFile( m_NetlistFileName.GetFullPath() ); LoadFootprintFiles(); BuildFOOTPRINTS_LISTBOX(); BuildLIBRARY_LISTBOX(); m_ListCmp->Clear(); m_undefinedComponentCnt = 0; if( m_netlist.AnyFootprintsLinked() ) { for( unsigned i = 0; i < m_netlist.GetCount(); i++ ) { COMPONENT* component = m_netlist.GetComponent( i ); if( component->GetFPID().empty() ) continue; if( component->GetFPID().IsLegacy() ) hasMissingNicks = true; } } // Check if footprint links were generated before the footprint library table was implemented. if( hasMissingNicks ) { msg = wxT( "Some of the assigned footprints are legacy entries (are missing lib nicknames). " "Would you like CvPcb to attempt to convert them to the new required FPID format? " "(If you answer no, then these assignments will be cleared out and you will " "have to re-assign these footprints yourself.)" ); if( IsOK( this, msg ) ) { msg.Clear(); try { for( unsigned i = 0; i < m_netlist.GetCount(); i++ ) { COMPONENT* component = m_netlist.GetComponent( i ); if( component->GetFPID().IsLegacy() ) { int guess = guessNickname( tbl, (FPID*) &component->GetFPID() ); switch( guess ) { case 0: DBG(printf("%s: guessed OK ref:%s fpid:%s\n", __func__, TO_UTF8( component->GetReference() ), component->GetFPID().Format().c_str() );) m_modified = true; break; case 1: msg += wxString::Format( _( "Component '%s' footprint '%s' was <b>not found</b> in any library.\n" ), GetChars( component->GetReference() ), GetChars( component->GetFPID().GetFootprintName() ) ); break; case 2: msg += wxString::Format( _( "Component '%s' footprint '%s' was found in <b>multiple</b> libraries.\n" ), GetChars( component->GetReference() ), GetChars( component->GetFPID().GetFootprintName() ) ); break; } } } }