bool FOOTPRINT_EDIT_FRAME::SaveFootprint( MODULE* aModule ) { wxString libraryName = aModule->GetFPID().GetLibNickname(); wxString footprintName = aModule->GetFPID().GetLibItemName(); bool nameChanged = m_footprintNameWhenLoaded != footprintName; if( aModule->GetLink() ) { if( SaveFootprintToBoard( false ) ) { m_footprintNameWhenLoaded = footprintName; return true; } else return false; } else if( libraryName.IsEmpty() || footprintName.IsEmpty() ) { if( SaveFootprintAs( aModule ) ) { m_footprintNameWhenLoaded = footprintName; SyncLibraryTree( true ); return true; } else return false; } FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs(); // Legacy libraries are readable, but modifying legacy format is not allowed // So prompt the user if he try to add/replace a footprint in a legacy lib wxString libfullname = tbl->FindRow( libraryName )->GetFullURI(); if( IO_MGR::GuessPluginTypeFromLibPath( libfullname ) == IO_MGR::LEGACY ) { DisplayInfoMessage( this, INFO_LEGACY_LIB_WARN_EDIT ); return false; } if( nameChanged ) { LIB_ID oldFPID( libraryName, m_footprintNameWhenLoaded ); DeleteModuleFromLibrary( oldFPID, false ); } if( !saveFootprintInLibrary( aModule, libraryName ) ) return false; if( nameChanged ) { m_footprintNameWhenLoaded = footprintName; SyncLibraryTree( true ); } return true; }
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnTestChipName( wxCommandEvent& event ) { wxString partname = chipnameTextCtrl->GetValue(); LIB_PART* entry = Prj().SchLibs()->FindLibPart( partname ); wxString msg; if( entry ) { msg.Printf( _( "Component '%s' found in library '%s'" ), GetChars( partname ), GetChars( entry->GetLibraryName() ) ); wxMessageBox( msg ); return; } msg.Printf( _( "Component '%s' not found in any library" ), GetChars( partname ) ); // Try to find components which have a name "near" the current chip name, // i.e. the same name when the comparison is case insensitive. // Could be helpful for old designs when lower cases and upper case were // equivalent. std::vector<LIB_ALIAS*> candidates; Prj().SchLibs()->FindLibraryNearEntries( candidates, partname ); if( candidates.size() == 0 ) { wxMessageBox( msg ); return; } // Some candidates are found. Show them: msg << wxT("\n") << _( "However, some candidates are found:" ); // add candidate names: for( unsigned ii = 0; ii < candidates.size(); ii++ ) { msg << wxT("\n") << wxString::Format( _( "'%s' found in library '%s'" ), GetChars( candidates[ii]->GetName() ), GetChars( candidates[ii]->GetLibraryName() ) ); } wxMessageBox( msg ); }
void KICAD_MANAGER_FRAME::SetProjectFileName( const wxString& aFullProjectProFileName ) { // ensure file name is absolute: wxFileName fn( aFullProjectProFileName ); if( !fn.IsAbsolute() ) fn.MakeAbsolute(); Prj().SetProjectFullName( fn.GetFullPath() ); }
bool DIALOG_SYMBOL_REMAP::remapSymbolToLibTable( SCH_COMPONENT* aSymbol ) { wxCHECK_MSG( aSymbol != NULL, false, "Null pointer passed to remapSymbolToLibTable." ); wxCHECK_MSG( aSymbol->GetLibId().GetLibNickname().empty(), false, "Cannot remap symbol that is already mapped." ); wxCHECK_MSG( !aSymbol->GetLibId().GetLibItemName().empty(), false, "The symbol LIB_ID name is empty." ); PART_LIBS* libs = Prj().SchLibs(); for( PART_LIBS_BASE::iterator it = libs->begin(); it != libs->end(); ++it ) { // Ignore the cache library. if( it->IsCache() ) continue; LIB_ALIAS* alias = it->FindAlias( aSymbol->GetLibId().GetLibItemName().wx_str() ); // Found in the same library as the old look up method assuming the user didn't // change the libraries or library ordering since the last time the schematic was // loaded. if( alias ) { // Find the same library in the symbol library table using the full path and file name. wxString libFileName = it->GetFullFileName(); const LIB_TABLE_ROW* row = Prj().SchSymbolLibTable()->FindRowByURI( libFileName ); if( row ) { LIB_ID id = aSymbol->GetLibId(); id.SetLibNickname( row->GetNickName() ); // Don't resolve symbol library links now. aSymbol->SetLibId( id, nullptr, nullptr ); return true; } } } return false; }
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& event ) { PROJECT& prj = Prj(); SEARCH_STACK* search = prj.SchSearchS(); wxString mask = wxT( "*" ); wxString docpath = prj.GetRString( PROJECT::DOC_PATH ); if( !docpath ) docpath = search->LastVisitedPath( wxT( "doc" ) ); wxString fullFileName = EDA_FILE_SELECTOR( _( "Doc Files" ), docpath, wxEmptyString, wxEmptyString, mask, this, wxFD_OPEN, true ); if( fullFileName.IsEmpty() ) return; /* If the path is already in the library search paths * list, just add the library name to the list. Otherwise, add * the library name with the full or relative path. * the relative path, when possible is preferable, * because it preserve use of default libraries paths, when the path is a sub path of * these default paths */ wxFileName fn = fullFileName; prj.SetRString( PROJECT::DOC_PATH, fn.GetPath() ); wxString filename = search->FilenameWithRelativePathInSearchList( fullFileName, wxPathOnly( Prj().GetProjectFullName() ) ); // Filenames are always stored in unix like mode, ie separator "\" is stored as "/" // to ensure files are identical under unices and windows #ifdef __WINDOWS__ filename.Replace( wxT( "\\" ), wxT( "/" ) ); #endif m_DocfileCtrl->SetValue( filename ); }
bool PCB_EDIT_FRAME::LoadProjectSettings() { wxLogDebug( wxT( "Loading project '%s' settings." ), GetChars( Prj().GetProjectFullName() ) ); bool rc = Prj().ConfigLoad( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters() ); // Load the page layout decr file, from the filename stored in // BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file // If empty, or not existing, the default descr is loaded WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); wxString pg_fullfilename = WORKSHEET_LAYOUT::MakeFullFileName( BASE_SCREEN::m_PageLayoutDescrFileName, Prj().GetProjectPath() ); pglayout.SetPageLayout( pg_fullfilename ); return rc; }
// Displays the list of available footprints in library name and select a footprint. void DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint( wxCommandEvent& event ) { wxString newname; newname = m_parent->SelectFootprint( m_parent, wxEmptyString, wxEmptyString, wxEmptyString, Prj().PcbFootprintLibs() ); if( newname != wxEmptyString ) m_NewFootprintFPID->SetValue( newname ); }
void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName ) { wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(), "Project folder must exist and be writable to create a new project." ); // Init project filename. This clears all elements from the project object. SetProjectFileName( aProjectFileName.GetFullPath() ); // Copy kicad.pro file from template folder. if( !aProjectFileName.FileExists() ) { wxString srcFileName = sys_search().FindValidPath( "kicad.pro" ); // Create a minimal project (.pro) file if the template project file could not be copied. if( !wxFileName::FileExists( srcFileName ) || !wxCopyFile( srcFileName, aProjectFileName.GetFullPath() ) ) { Prj().ConfigSave( PgmTop().SysSearch(), GeneralGroupName, s_KicadManagerParams ); } } // Ensure a "stub" for a schematic root sheet and a board exist. // It will avoid messages from the schematic editor or the board editor to create a new file // And forces the user to create main files under the right name for the project manager wxFileName fn( aProjectFileName.GetFullPath() ); fn.SetExt( SchematicFileExtension ); // If a <project>.sch file does not exist, create a "stub" file ( minimal schematic file ) if( !fn.FileExists() ) { wxFile file( fn.GetFullPath(), wxFile::write ); if( file.IsOpened() ) file.Write( wxT( "EESchema Schematic File Version 2\n" "EELAYER 25 0\nEELAYER END\n$EndSCHEMATC\n" ) ); // wxFile dtor will close the file } // If a <project>.kicad_pcb or <project>.brd file does not exist, // create a .kicad_pcb "stub" file fn.SetExt( KiCadPcbFileExtension ); wxFileName leg_fn( fn ); leg_fn.SetExt( LegacyPcbFileExtension ); if( !fn.FileExists() && !leg_fn.FileExists() ) { wxFile file( fn.GetFullPath(), wxFile::write ); if( file.IsOpened() ) file.Write( wxT( "(kicad_pcb (version 4) (host kicad \"dummy file\") )\n" ) ); // wxFile dtor will close the file } }
bool SCH_SCREEN::Save( FILE* aFile ) const { // Creates header if( fprintf( aFile, "%s %s %d\n", EESCHEMA_FILE_STAMP, SCHEMATIC_HEAD_STRING, EESCHEMA_VERSION ) < 0 ) return false; BOOST_FOREACH( const PART_LIB& lib, *Prj().SchLibs() ) { if( fprintf( aFile, "LIBS:%s\n", TO_UTF8( lib.GetName() ) ) < 0 ) return false; } // This section is not used, but written for file compatibility if( fprintf( aFile, "EELAYER %d %d\n", LAYERSCH_ID_COUNT, 0 ) < 0 || fprintf( aFile, "EELAYER END\n" ) < 0 ) return false; /* Write page info, ScreenNumber and NumberOfScreen; not very meaningful for * SheetNumber and Sheet Count in a complex hierarchy, but useful in * simple hierarchy and flat hierarchy. Used also to search the root * sheet ( ScreenNumber = 1 ) within the files */ const TITLE_BLOCK& tb = GetTitleBlock(); if( fprintf( aFile, "$Descr %s %d %d%s\n", TO_UTF8( m_paper.GetType() ), m_paper.GetWidthMils(), m_paper.GetHeightMils(), !m_paper.IsCustom() && m_paper.IsPortrait() ? " portrait" : "" ) < 0 || fprintf( aFile, "encoding utf-8\n") < 0 || fprintf( aFile, "Sheet %d %d\n", m_ScreenNumber, m_NumberOfScreens ) < 0 || fprintf( aFile, "Title %s\n", EscapedUTF8( tb.GetTitle() ).c_str() ) < 0 || fprintf( aFile, "Date %s\n", EscapedUTF8( tb.GetDate() ).c_str() ) < 0 || fprintf( aFile, "Rev %s\n", EscapedUTF8( tb.GetRevision() ).c_str() ) < 0 || fprintf( aFile, "Comp %s\n", EscapedUTF8( tb.GetCompany() ).c_str() ) < 0 || fprintf( aFile, "Comment1 %s\n", EscapedUTF8( tb.GetComment1() ).c_str() ) < 0 || fprintf( aFile, "Comment2 %s\n", EscapedUTF8( tb.GetComment2() ).c_str() ) < 0 || fprintf( aFile, "Comment3 %s\n", EscapedUTF8( tb.GetComment3() ).c_str() ) < 0 || fprintf( aFile, "Comment4 %s\n", EscapedUTF8( tb.GetComment4() ).c_str() ) < 0 || fprintf( aFile, "$EndDescr\n" ) < 0 ) return false; for( SCH_ITEM* item = m_drawList.begin(); item; item = item->Next() ) { if( !item->Save( aFile ) ) return false; } if( fprintf( aFile, "$EndSCHEMATC\n" ) < 0 ) return false; return true; }
bool SCH_BASE_FRAME::saveSymbolLibTables( bool aGlobal, bool aProject ) { bool success = true; if( aGlobal ) { try { FILE_OUTPUTFORMATTER sf( SYMBOL_LIB_TABLE::GetGlobalTableFileName() ); SYMBOL_LIB_TABLE::GetGlobalLibTable().Format( &sf, 0 ); } catch( const IO_ERROR& ioe ) { success = false; wxString msg = wxString::Format( _( "Error occurred saving the global symbol library " "table:\n\n%s" ), GetChars( ioe.What().GetData() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } if( aProject && !Prj().GetProjectName().IsEmpty() ) { wxFileName fn( Prj().GetProjectPath(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() ); try { Prj().SchSymbolLibTable()->Save( fn.GetFullPath() ); } catch( const IO_ERROR& ioe ) { success = false; wxString msg = wxString::Format( _( "Error occurred saving project specific " "symbol library table:\n\n%s" ), GetChars( ioe.What() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } } return success; }
LIB_ALIAS* LIB_VIEW_FRAME::getSelectedAlias() const { LIB_ALIAS* alias = NULL; if( !m_libraryName.IsEmpty() && !m_entryName.IsEmpty() ) { alias = Prj().SchSymbolLibTable()->LoadSymbol( m_libraryName, m_entryName ); } return alias; }
LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent, bool aEndPointOnly ) const { SCH_ITEM* item; SCH_COMPONENT* component = NULL; LIB_PIN* pin = NULL; for( item = m_drawList.begin(); item; item = item->Next() ) { if( item->Type() != SCH_COMPONENT_T ) continue; component = (SCH_COMPONENT*) item; if( aEndPointOnly ) { pin = NULL; LIB_PART* part = Prj().SchLibs()->FindLibPart( component->GetPartName() ); if( !part ) continue; for( pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) ) { // Skip items not used for this part. if( component->GetUnit() && pin->GetUnit() && ( pin->GetUnit() != component->GetUnit() ) ) continue; if( component->GetConvert() && pin->GetConvert() && ( pin->GetConvert() != component->GetConvert() ) ) continue; if(component->GetPinPhysicalPosition( pin ) == aPosition ) break; } if( pin ) break; } else { pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T ); if( pin ) break; } } if( pin && aComponent ) *aComponent = component; return pin; }
void PCB_EDIT_FRAME::SaveProjectSettings( bool aAskForSave ) { wxFileName fn = Prj().GetProjectFullName(); if( aAskForSave ) { wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(), ProjectFileWildcard, wxFD_SAVE | wxFD_CHANGE_DIR ); if( dlg.ShowModal() == wxID_CANCEL ) return; fn = dlg.GetPath(); } wxString pro_name = fn.GetFullPath(); Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters(), pro_name ); }
bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName ) { wxLogDebug( wxT( "Loading project '%s' settings." ), GetChars( aProjectFileName ) ); wxFileName fn = aProjectFileName; if( fn.GetExt() != ProjectFileExtension ) fn.SetExt( ProjectFileExtension ); // was: wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false ); Prj().ConfigLoad( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP_PCB, GetProjectFileParameters(), false ); // Dick 5-Feb-2012: I don't agree with this, the BOARD contents should dictate // what is visible or not, even initially. And since PCB_EDIT_FRAME projects settings // have no control over what is visible (see PCB_EDIT_FRAME::GetProjectFileParameters()) // this is recklessly turning on things the user may not want to see. #if 0 /* Reset the items visibility flag when loading a new configuration because it could * create SERIOUS mistakes for the user if board items are not visible after loading * a board. Grid and ratsnest can be left to their previous state. */ bool showGrid = IsElementVisible( GRID_VISIBLE ); bool showRats = IsElementVisible( RATSNEST_VISIBLE ); SetVisibleAlls(); SetElementVisibility( GRID_VISIBLE, showGrid ); SetElementVisibility( RATSNEST_VISIBLE, showRats ); #endif Prj().ElemClear( PROJECT::ELEM_FPTBL ); // Force it to be reloaded on demand. // Load the page layout decr file, from the filename stored in // BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file // If empty, the default descr is loaded WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); pglayout.SetPageLayout( BASE_SCREEN::m_PageLayoutDescrFileName ); return true; }
void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC ) { /* Setup the netlist file name to the last netlist file read, * or the board file name if the last filename is empty or last file not existing. */ wxString netlistName = GetLastNetListRead(); wxFileName fn = netlistName; if( !fn.IsOk() || !fn.FileExists() ) { fn = GetBoard()->GetFileName(); fn.SetExt( NetlistFileExtension ); if( fn.GetName().IsEmpty() ) netlistName.Clear(); else netlistName = fn.GetFullPath(); } DIALOG_NETLIST dlg( this, DC, netlistName ); dlg.ShowModal(); // Save project settings if needed. // Project settings are saved in the corresponding <board name>.pro file bool configChanged = !GetLastNetListRead().IsEmpty() && ( netlistName != GetLastNetListRead() ); if( configChanged && !GetBoard()->GetFileName().IsEmpty() && IsOK( NULL, _( "The project configuration has changed. Do you want to save it?" ) ) ) { fn = Prj().AbsolutePath( GetBoard()->GetFileName() ); fn.SetExt( ProjectFileExtension ); wxString pro_name = fn.GetFullPath(); Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_PCB, GetProjectFileParameters(), pro_name ); } }
PART_LIB* SCH_BASE_FRAME::SelectLibraryFromList() { PROJECT& prj = Prj(); if( PART_LIBS* libs = prj.SchLibs() ) { if( !libs->GetLibraryCount() ) { DisplayError( this, _( "No component libraries are loaded." ) ); return NULL; } wxArrayString headers; headers.Add( wxT( "Library" ) ); wxArrayString libNamesList = libs->GetLibraryNames(); std::vector<wxArrayString> itemsToDisplay; // Conversion from wxArrayString to vector of ArrayString for( unsigned i = 0; i < libNamesList.GetCount(); i++ ) { wxArrayString item; item.Add( libNamesList[i] ); itemsToDisplay.push_back( item ); } wxString old_lib_name = prj.GetRString( PROJECT::SCH_LIB_SELECT ); EDA_LIST_DIALOG dlg( this, _( "Select Library" ), headers, itemsToDisplay, old_lib_name ); if( dlg.ShowModal() != wxID_OK ) return NULL; wxString libname = dlg.GetTextSelection(); if( !libname ) return NULL; PART_LIB* lib = libs->FindLibrary( libname ); if( lib ) prj.SetRString( PROJECT::SCH_LIB_SELECT, libname ); return lib; } return NULL; }
void LIB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) { const std::string& payload = mail.GetPayload(); switch( mail.Command() ) { case MAIL_LIB_EDIT: if( !payload.empty() ) { wxString libFileName( payload ); wxString libNickname; wxString msg; SYMBOL_LIB_TABLE* libTable = Prj().SchSymbolLibTable(); const LIB_TABLE_ROW* libTableRow = libTable->FindRowByURI( libFileName ); if( !libTableRow ) { msg.Printf( _( "The current configuration does not include the symbol library\n" "\"%s\".\nUse Manage Symbol Libraries to edit the configuration." ), libFileName ); DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg ); break; } libNickname = libTableRow->GetNickName(); if( !libTable->HasLibrary( libNickname, true ) ) { msg.Printf( _( "The library with the nickname \"%s\" is not enabled\n" "in the current configuration. Use Manage Symbol Libraries to\n" "edit the configuration." ), libNickname ); DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg ); break; } SetCurLib( libNickname ); if( m_treePane ) { LIB_ID id( libNickname, wxEmptyString ); m_treePane->GetLibTree()->ExpandLibId( id ); m_treePane->GetLibTree()->CenterLibId( id ); } } break; default: ; } }
void LIB_VIEW_FRAME::DisplayLibInfos() { PART_LIBS* libs = Prj().SchLibs(); if( libs ) { PART_LIB* lib = libs->FindLibrary( m_libraryName ); wxString title = wxString::Format( "Library Browser \u2014 %s", lib ? lib->GetFullFileName() : "no library selected" ); SetTitle( title ); } }
bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName ) { wxLogDebug( wxT( "Loading project '%s' settings." ), GetChars( aProjectFileName ) ); wxFileName fn = aProjectFileName; if( fn.GetExt() != ProjectFileExtension ) fn.SetExt( ProjectFileExtension ); // was: wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false ); Prj().ConfigLoad( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP_PCB, GetProjectFileParameters(), false ); Prj().ElemClear( PROJECT::ELEM_FPTBL ); // Force it to be reloaded on demand. // Load the page layout decr file, from the filename stored in // BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file // If empty, the default descr is loaded WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); pglayout.SetPageLayout( BASE_SCREEN::m_PageLayoutDescrFileName ); return true; }
void FOOTPRINT_EDIT_FRAME::updateTitle() { wxString title = _( "Footprint Editor" ); LIB_ID fpid = GetLoadedFPID(); bool writable = true; if( IsCurrentFPFromBoard() ) { title += wxString::Format( wxT( " \u2014 %s [from %s.%s]" ), GetBoard()->m_Modules->GetReference(), Prj().GetProjectName(), PcbFileExtension ); } else if( fpid.IsValid() ) { try { writable = Prj().PcbFootprintLibs()->IsFootprintLibWritable( fpid.GetLibNickname() ); } catch( const IO_ERROR& ) { // best efforts... } // Note: don't used GetLoadedFPID(); footprint name may have been edited title += wxString::Format( wxT( " \u2014 %s %s" ), FROM_UTF8( GetBoard()->m_Modules->GetFPID().Format().c_str() ), writable ? wxString( wxEmptyString ) : _( "[Read Only]" ) ); } else if( !fpid.GetLibItemName().empty() ) { // Note: don't used GetLoadedFPID(); footprint name may have been edited title += wxString::Format( wxT( " \u2014 %s %s" ), FROM_UTF8( GetBoard()->m_Modules->GetFPID().GetLibItemName().c_str() ), _( "[Unsaved]" ) ); } SetTitle( title ); }
DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* aParent ) : DIALOG_CONFIG_EQUFILES_BASE( aParent ) { m_Parent = aParent; m_Config = Pgm().CommonSettings(); PROJECT& prj = Prj(); SetTitle( wxString::Format( _( "Project file: '%s'" ), GetChars( prj.GetProjectFullName() ) ) ); Init( ); GetSizer()->SetSizeHints( this ); Center(); }
/* * TODO: Copy of DIALOG_PLOT::OnOutputDirectoryBrowseClicked in dialog_plot.cpp, maybe merge to a common method. */ void DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { // Build the absolute path of current output plot directory // to preselect it when opening the dialog. wxFileName fn( m_outputDirectoryName->GetValue() ); wxString path = Prj().AbsolutePath( m_outputDirectoryName->GetValue() ); wxDirDialog dirDialog( this, _( "Select Output Directory" ), path ); if( dirDialog.ShowModal() == wxID_CANCEL ) { return; } wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() ); wxMessageDialog dialog( this, _( "Use a relative path? " ), _( "Plot Output Directory" ), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT ); // relative directory selected if( dialog.ShowModal() == wxID_YES ) { wxString plotFilePath = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." ) + PS_PLOTTER::GetDefaultFileExtension(); plotFilePath = Prj().AbsolutePath(plotFilePath); plotFilePath = wxPathOnly( plotFilePath ); if( !dirName.MakeRelativeTo( plotFilePath ) ) wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ), _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); } m_outputDirectoryName->SetValue( dirName.GetFullPath() ); }
void DIALOG_EESCHEMA_CONFIG::OnCancelClick( wxCommandEvent& event ) { SEARCH_STACK& lib_search = Prj().SchSearchS(); // Recreate the user lib path if( m_LibPathChanged ) { for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ ) lib_search.RemovePaths( m_listUserPaths->GetString(ii) ); lib_search.AddPaths( m_Parent->GetUserLibraryPath(), 1 ); } EndModal( wxID_CANCEL ); }
void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& ) { wxFileName fn = m_brdEditor->GetBoard()->GetFileName(); fn.SetExt( ReportFileExtension ); wxString prj_path = Prj().GetProjectPath(); wxFileDialog dlg( this, _( "Save DRC Report File" ), prj_path, fn.GetFullName(), ReportFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) return; m_CreateRptCtrl->SetValue( true ); m_RptFilenameCtrl->SetValue( dlg.GetPath() ); }
void FOOTPRINT_EDIT_FRAME::retainLastFootprint() { PCB_IO pcb_io; MODULE* module = GetBoard()->m_Modules; if( module ) { pcb_io.Format( module ); wxString pretty = FROM_UTF8( pcb_io.GetStringOutput( true ).c_str() ); // save the footprint in the RSTRING facility. Prj().SetRString( PROJECT::PCB_FOOTPRINT, pretty ); } }
const wxString FOOTPRINT_EDIT_FRAME::getLibPath() { try { const wxString& nickname = GetCurrentLib(); const FP_LIB_TABLE::ROW* row = Prj().PcbFootprintLibs()->FindRow( nickname ); return row->GetFullURI( true ); } catch( const IO_ERROR& ioe ) { return wxEmptyString; } }
void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) { LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryAlias( m_entryName, m_libraryName ); if( !entry ) return; LIB_PART* part = entry->GetPart(); if( !part ) return; wxString msg; wxString tmp; m_canvas->DrawBackGround( DC ); if( !entry->IsRoot() ) { // Temporarily change the name field text to reflect the alias name. msg = entry->GetName(); tmp = part->GetName(); part->SetName( msg ); if( m_unit < 1 ) m_unit = 1; if( m_convert < 1 ) m_convert = 1; } else msg = _( "None" ); part->Draw( m_canvas, DC, wxPoint( 0, 0 ), m_unit, m_convert, GR_DEFAULT_DRAWMODE ); // Redraw the cursor m_canvas->DrawCrossHair( DC ); if( !tmp.IsEmpty() ) part->SetName( tmp ); ClearMsgPanel(); AppendMsgPanel( _( "Part" ), part->GetName(), BLUE, 6 ); AppendMsgPanel( _( "Alias" ), msg, RED, 6 ); AppendMsgPanel( _( "Description" ), entry->GetDescription(), CYAN, 6 ); AppendMsgPanel( _( "Key words" ), entry->GetKeyWords(), DARKDARKGRAY ); }
bool LIB_VIEW_FRAME::ReCreateListCmp() { if( m_cmpList == NULL ) return false; wxArrayString aliasNames; try { Prj().SchSymbolLibTable()->EnumerateSymbolLib( m_libraryName, aliasNames, m_listPowerCmpOnly ); } catch( const IO_ERROR& ) {} // ignore, it is handled below m_cmpList->Clear(); if( aliasNames.IsEmpty() ) { m_libraryName = wxEmptyString; m_entryName = wxEmptyString; m_convert = 1; m_unit = 1; return true; } m_cmpList->Append( aliasNames ); int index = m_cmpList->FindString( m_entryName ); bool changed = false; if( index == wxNOT_FOUND ) { // Select the first library entry when the previous entry name does not exist in // the current library. m_convert = 1; m_unit = 1; index = 0; changed = true; m_entryName = wxEmptyString; } m_cmpList->SetSelection( index, true ); wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_CMP_LIST ); ProcessEvent( evt ); return changed; }
bool PCB_EDIT_FRAME::doAutoSave() { wxFileName tmpFileName; if( GetBoard()->GetFileName().IsEmpty() ) { tmpFileName = wxFileName( wxStandardPaths::Get().GetDocumentsDir(), wxT( "noname" ), KiCadPcbFileExtension ); GetBoard()->SetFileName( tmpFileName.GetFullPath() ); } else { tmpFileName = Prj().AbsolutePath( GetBoard()->GetFileName() ); } wxFileName autoSaveFileName = tmpFileName; // Auto save file name is the board file name prepended with autosaveFilePrefix string. autoSaveFileName.SetName( GetAutoSaveFilePrefix() + autoSaveFileName.GetName() ); if( !autoSaveFileName.IsOk() ) return false; // If the board file path is not writable, try writing to a platform specific temp file // path. If that path isn't writabe, give up. if( !autoSaveFileName.IsDirWritable() ) { autoSaveFileName.SetPath( wxFileName::GetTempDir() ); if( !autoSaveFileName.IsOk() || !autoSaveFileName.IsDirWritable() ) return false; } wxLogTrace( traceAutoSave, "Creating auto save file <" + autoSaveFileName.GetFullPath() + ">" ); if( SavePcbFile( autoSaveFileName.GetFullPath(), NO_BACKUP_FILE ) ) { GetScreen()->SetModify(); GetBoard()->SetFileName( tmpFileName.GetFullPath() ); UpdateTitle(); m_autoSaveState = false; return true; } GetBoard()->SetFileName( tmpFileName.GetFullPath() ); return false; }
DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR() { m_page = m_NoteBook->GetSelection(); for( unsigned ii = 0; ii < m_Shapes3D_list.size(); ii++ ) delete m_Shapes3D_list[ii]; m_Shapes3D_list.clear(); // free the memory used by all models, otherwise models which were // browsed but not used would consume memory Prj().Get3DCacheManager()->FlushCache( false ); delete m_ReferenceCopy; delete m_ValueCopy; }