Open file dialog fixes and minor code cleaning.

* Fix a minor problem with wxFileDialog to open a file that no longer
  exists in PCBNew.
* Make GerbView open file behavior the same as PCBNew.
* Remove redundant PCB file wild card definition.
* Add open file refactor task to the todo list.
* Fix some minor code formatting issues.
This commit is contained in:
Wayne Stambaugh 2010-05-17 16:35:46 -04:00
parent 6fba09e1bc
commit 5ce9c9a9d7
21 changed files with 124 additions and 109 deletions

View File

@ -24,7 +24,8 @@ Common
* List auto up and down scrolling.
* Integer/long/double input boxes should handle comma and dot separated values,
not only comma.
* Push file open semantics down to one of the base frame classes ( likely candidate is
WinEDA_BasicFrame ) so that file open behavior is consistent across all applications.
ANYONE:
C2) Write a tool to generate DSNLEXER keyword tables (and enums) as *.cpp and

View File

@ -55,17 +55,17 @@ Ki_PageDescr* g_SheetSizeList[NB_ITEMS + 1] =
* that they cannot be changed. */
const wxString ProjectFileExtension( wxT( "pro" ) );
const wxString SchematicFileExtension( wxT( "sch" ) );
const wxString BoardFileExtension( wxT( "brd" ) );
const wxString NetlistFileExtension( wxT( "net" ) );
const wxString GerberFileExtension( wxT( "pho" ) );
const wxString PcbFileExtension( wxT( "brd" ) );
const wxString PdfFileExtension( wxT( "pdf" ) );
/* Proper wxFileDialog wild card definitions. */
const wxString ProjectFileWildcard( _( "Kicad project files (*.pro)|*.pro" ) );
const wxString BoardFileWildcard( _( "Kicad PCB files (*.brd)|*.brd" ) );
const wxString SchematicFileWildcard( _( "Kicad schematic files (*.sch)|*.sch" ) );
const wxString NetlistFileWildcard( _( "Kicad netlist files (*.net)|*.net" ) );
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
const wxString PcbFileWildcard( _( "Kicad printed circuit board files (*.brd)|*.brd" ) );
const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) );
const wxString AllFilesWildcard( _( "All files (*)|*" ) );

View File

@ -72,7 +72,6 @@ wxArrayString g_LibName_List; // library list to load
DISPLAY_OPTIONS DisplayOpt; /* Display options for board items */
/* PCB file name extension definitions. */
wxString PcbExtBuffer( wxT( "brd" ) );
wxString g_SaveFileName( wxT( "$savepcb" ) );
wxString NetExtBuffer( wxT( "net" ) );
wxString NetCmpExtBuffer( wxT( "cmp" ) );
@ -80,11 +79,7 @@ wxString g_Shapes3DExtBuffer( wxT( "wrl" ) );
const wxString ModuleFileExtension( wxT( "mod" ) );
/* PCB file name wild card definitions. */
const wxString ModuleFileWildcard(
_( "Kicad footprint library files (*.mod)|*.mod" )
);
const wxString PcbFileWildcard(
_( "Printed circuit board files (*.brd)|*.brd" ) );
const wxString ModuleFileWildcard( _( "Kicad footprint library files (*.mod)|*.mod" ) );
int g_CurrentVersionPCB = 1;

View File

@ -281,8 +281,7 @@ void WinEDA_CvpcbFrame::OnCloseWindow( wxCloseEvent& Event )
m_modified = false;
else if( diag == 0 )
{
if( !IsOK( this,
_( "Problem when saving files, exit anyway ?" ) ) )
if( !IsOK( this, _( "Problem when saving files, exit anyway ?" ) ) )
{
Event.Veto();
return;
@ -346,7 +345,8 @@ void WinEDA_CvpcbFrame::ToFirstNA( wxCommandEvent& event )
if( selection < 0 )
selection = 0;
BOOST_FOREACH( COMPONENT & component, m_components ) {
BOOST_FOREACH( COMPONENT & component, m_components )
{
if( component.m_Module.IsEmpty() && ii > selection )
{
m_ListCmp->SetSelection( ii );
@ -444,10 +444,8 @@ void WinEDA_CvpcbFrame::LoadNetList( wxCommandEvent& event )
}
else
{
newFileName = wxFileName( wxGetCwd(), _( "unnamed" ), wxT( "net" ) );
wxFileDialog dlg( this, _( "Open Net List" ), newFileName.GetPath(),
newFileName.GetFullName(), NetlistFileWildcard,
wxFileDialog dlg( this, _( "Open Net List" ), wxGetCwd(),
wxEmptyString, NetlistFileWildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
if( dlg.ShowModal() == wxID_CANCEL )

View File

@ -176,7 +176,7 @@ bool WinEDA_App::OnInit()
wxSetWorkingDirectory( filename.GetPath() );
if( frame->DrawPanel
&& frame->LoadOneEEProject( filename.GetFullPath(), false ) <= 0 )
&& frame->LoadOneEEProject( filename.GetFullPath(), false ) )
frame->DrawPanel->Refresh( true );
}
else

View File

@ -50,7 +50,7 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event )
* Schematic root file and its subhierarchies, the configuration and the libs
* which are not already loaded)
*/
int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNew )
bool WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNew )
{
SCH_SCREEN* screen;
wxString FullFileName, msg;
@ -67,7 +67,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
if( screen )
{
if( !IsOK( this, _( "Clear schematic hierarchy?" ) ) )
return FALSE;
return false;
if( g_RootSheet->m_AssociatedScreen->m_FileName != m_DefaultSchematicFileName )
SetLastProject( g_RootSheet->m_AssociatedScreen->m_FileName );
}
@ -80,7 +80,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() == wxID_CANCEL )
return 0;
return false;
FullFileName = dlg.GetPath();
}
@ -127,7 +127,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
Zoom_Automatique( TRUE );
SetSheetNumberAndCount();
DrawPanel->Refresh();
return 1;
return true;
}
// Reloading configuration.
@ -143,13 +143,6 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
// Delete old caches.
CMP_LIBRARY::RemoveCacheLibrary();
if( IsNew )
{
if( DrawPanel )
DrawPanel->Refresh( true );
return 1;
}
/* Loading the project library cache
* until apr 2009 the lib is named <root_name>.cache.lib
* and after (due to code change): <root_name>-cache.lib
@ -158,7 +151,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
bool use_oldcachename = false;
wxString cachename = fn.GetName() + wxT("-cache");
wxString cachename = fn.GetName() + wxT( "-cache" );
fn.SetName( cachename );
fn.SetExt( CompLibFileExtension );
@ -185,7 +178,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
msg += wxT( " OK" );
if ( use_oldcachename ) // set the new name
{
fn.SetName(cachename);
fn.SetName( cachename );
fn.SetExt( CompLibFileExtension );
LibCache->SetFileName( fn );
}
@ -212,9 +205,9 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
{
Zoom_Automatique( FALSE );
msg.Printf( _( "File <%s> not found." ),
g_RootSheet->m_AssociatedScreen->m_FileName.GetData() );
GetChars( g_RootSheet->m_AssociatedScreen->m_FileName ) );
DisplayInfoMessage( this, msg, 0 );
return -1;
return false;
}
// load the project.
@ -222,7 +215,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
bool diag = g_RootSheet->Load( this );
/* Redraw base screen (ROOT) if necessary. */
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
Zoom_Automatique( FALSE );
SetSheetNumberAndCount();
DrawPanel->Refresh( true );
@ -250,7 +243,7 @@ void WinEDA_SchematicFrame::SaveProject()
/* Archive components in current directory. */
fn = g_RootSheet->GetFileName();
wxString cachename = fn.GetName() + wxT("-cache");
wxString cachename = fn.GetName() + wxT( "-cache" );
fn.SetName( cachename );
fn.SetExt( CompLibFileExtension );
LibArchive( this, fn.GetFullPath() );

View File

@ -702,7 +702,7 @@ void WinEDA_SchematicFrame::OnOpenPcbnew( wxCommandEvent& event )
if( fn.IsOk() )
{
fn.SetExt( BoardFileExtension );
fn.SetExt( PcbFileExtension );
wxString filename = QuoteFullPath( fn );

View File

@ -39,9 +39,12 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
switch( id )
{
case wxID_FILE:
{
wxString fileName = GetScreen()->m_FileName;
Erase_Current_Layer( false );
LoadOneGerberFile( wxEmptyString, 0 );
LoadOneGerberFile( fileName, true );
break;
}
case ID_MENU_INC_LAYER_AND_APPEND_FILE:
case ID_INC_LAYER_AND_APPEND_FILE:
@ -51,18 +54,23 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
{
setActiveLayer(origLayer+1);
if( !LoadOneGerberFile( wxEmptyString, 0 ) )
if( !LoadOneGerberFile( wxEmptyString ) )
setActiveLayer(origLayer);
SetToolbars();
}
else
wxMessageBox(_("Cannot increment layer number: max count reached") );
{
wxString msg;
msg.Printf( _( "GerbView only supports a maximum of %d layers. You must first \
delete an existing layer to load any new layers." ), NB_LAYERS );
wxMessageBox( msg );
}
}
break;
case ID_APPEND_FILE:
LoadOneGerberFile( wxEmptyString, 0 );
LoadOneGerberFile( wxEmptyString );
break;
case ID_NEW_BOARD:
@ -94,25 +102,15 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
}
/*
* Load a PCB file.
*
* Returns:
* 0 if file not read (cancellation of order ...)
* 1 if OK
*/
bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName,
int mode )
bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& aFullFileName, bool aOpenFileDialog )
{
wxString filetypes;
wxFileName filename = FullFileName;
wxFileName filename = aFullFileName;
ActiveScreen = GetScreen();
if( !filename.IsOk() )
if( !filename.IsOk() || aOpenFileDialog )
{
wxString current_path = filename.GetPath();
/* Standard gerber filetypes
* (See http://en.wikipedia.org/wiki/Gerber_File)
* the .pho extension is the default used in Pcbnew
@ -139,9 +137,11 @@ bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName,
/* All filetypes */
filetypes += AllFilesWildcard;
/* Get current path if emtpy */
if( current_path.IsEmpty() )
current_path = wxGetCwd();
/* Use the current working directory if the file name path does not exist. */
wxString current_path = wxGetCwd();
if( filename.DirExists() )
current_path = filename.GetPath();
wxFileDialog dlg( this,
_( "Open Gerber File" ),

View File

@ -310,18 +310,18 @@ void WinEDA_GerberFrame::SetToolbars()
g_DisplayPolygonsModeSketch == 0 ? 0 : 1 );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_DCODES,
IsElementVisible( DCODES_VISIBLE) );
IsElementVisible( DCODES_VISIBLE ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
m_show_layer_manager_tools );
if( m_show_layer_manager_tools )
GetMenuBar()->SetLabel(ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
_("Hide &Layers Manager" ) );
GetMenuBar()->SetLabel( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
_("Hide &Layers Manager" ) );
else
GetMenuBar()->SetLabel(ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
_("Show &Layers Manager" ) );
GetMenuBar()->SetLabel( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
_("Show &Layers Manager" ) );
}
}
DisplayUnitsMsg();
@ -369,8 +369,8 @@ void WinEDA_GerberFrame::LoadSettings()
}
long tmp;
config->Read( GerbviewShowDCodes, &tmp, 1);
SetElementVisibility( DCODES_VISIBLE, tmp);
config->Read( GerbviewShowDCodes, &tmp, 1 );
SetElementVisibility( DCODES_VISIBLE, tmp );
}
/**************************************/
@ -399,7 +399,7 @@ void WinEDA_GerberFrame::SaveSettings()
}
}
config->Write( GerbviewShowPageSizeOption, pageSize_opt );
config->Write( GerbviewShowDCodes, IsElementVisible( DCODES_VISIBLE) );
config->Write( GerbviewShowDCodes, IsElementVisible( DCODES_VISIBLE ) );
}
@ -420,7 +420,7 @@ void WinEDA_GerberFrame::ReFillLayerWidget()
else
m_LayersManager->SetSize( bestz );
syncLayerWidget( );
syncLayerWidget();
}
/** Function IsGridVisible() , virtual
@ -428,7 +428,7 @@ void WinEDA_GerberFrame::ReFillLayerWidget()
*/
bool WinEDA_GerberFrame::IsGridVisible()
{
return IsElementVisible(GERBER_GRID_VISIBLE);
return IsElementVisible( GERBER_GRID_VISIBLE );
}
/** Function SetGridVisibility() , virtual
@ -494,8 +494,8 @@ void WinEDA_GerberFrame::syncLayerBox()
void WinEDA_GerberFrame::SetLanguage( wxCommandEvent& event )
{
WinEDA_DrawFrame::SetLanguage( event );
m_LayersManager->SetLayersManagerTabsText( );
wxAuiPaneInfo& pane_info = m_auimgr.GetPane(m_LayersManager);
m_LayersManager->SetLayersManagerTabsText();
wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_LayersManager );
pane_info.Caption( _( "Visibles" ) );
m_auimgr.Update();

View File

@ -61,14 +61,15 @@ IMPLEMENT_APP( WinEDA_App )
/* MacOSX: Needed for file association
* http://wiki.wxwidgets.org/WxMac-specific_topics
*/
void WinEDA_App::MacOpenFile(const wxString &fileName) {
wxFileName filename = fileName;
void WinEDA_App::MacOpenFile(const wxString &fileName)
{
wxFileName filename = fileName;
WinEDA_GerberFrame * frame = ((WinEDA_GerberFrame*)GetTopWindow());
if(!filename.FileExists())
if( !filename.FileExists() )
return;
frame->LoadOneGerberFile( fileName, FALSE );
frame->LoadOneGerberFile( fileName );
}
@ -106,8 +107,8 @@ bool WinEDA_App::OnInit()
*/
frame = new WinEDA_GerberFrame( NULL, wxT( "GerbView" ),
wxPoint( 0, 0 ),
wxSize( 600, 400 ) );
wxPoint( 0, 0 ),
wxSize( 600, 400 ) );
/* Gerbview mainframe title */
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );
@ -142,7 +143,7 @@ bool WinEDA_App::OnInit()
if( fn.FileExists() )
{
( (PCB_SCREEN*) frame->GetScreen() )->m_Active_Layer = ii - 1;
frame->LoadOneGerberFile( fn.GetFullPath(), FALSE );
frame->LoadOneGerberFile( fn.GetFullPath() );
}
}
}

View File

@ -286,7 +286,18 @@ public:
void Files_io( wxCommandEvent& event );
void OnFileHistory( wxCommandEvent& event );
bool LoadOneGerberFile( const wxString& FileName, int mode );
/**
* Load a photoplot (Gerber) file.
*
* @param aFileName - File name with full path to open or empty string to open a new
* file.
* @param aOpenFileDialog - Set to true to display the open file dialog even if
* aFileName is valid.
*
* @return - True if file was opened successfully.
*/
bool LoadOneGerberFile( const wxString& aFileName, bool aOpenFileDialog = false );
int ReadGerberFile( FILE* File, bool Append );
bool Read_GERBER_File( const wxString& GERBER_FullFileName,
const wxString& D_Code_FullFileName );

View File

@ -160,9 +160,9 @@ extern bool g_ShowPageLimits; // TRUE to display the page limits
/* File name extension definitions. */
extern const wxString ProjectFileExtension;
extern const wxString SchematicFileExtension;
extern const wxString BoardFileExtension;
extern const wxString NetlistFileExtension;
extern const wxString GerberFileExtension;
extern const wxString PcbFileExtension;
extern const wxString PdfFileExtension;
extern const wxString ProjectFileWildcard;
@ -170,6 +170,7 @@ extern const wxString SchematicFileWildcard;
extern const wxString BoardFileWildcard;
extern const wxString NetlistFileWildcard;
extern const wxString GerberFileWildcard;
extern const wxString PcbFileWildcard;
extern const wxString PdfFileWildcard;
extern const wxString AllFilesWildcard;

View File

@ -23,14 +23,12 @@ extern int g_TabAllCopperLayerMask[NB_COPPER_LAYERS];
extern wxArrayString g_LibName_List; // library list to load
extern DISPLAY_OPTIONS DisplayOpt;
extern wxString PcbExtBuffer;
extern wxString g_SaveFileName;
extern wxString NetExtBuffer;
extern wxString NetCmpExtBuffer;
extern const wxString ModuleFileExtension;
extern const wxString ModuleFileWildcard;
extern const wxString PcbFileWildcard;
extern wxString g_ViaType_Name[4];

View File

@ -270,7 +270,7 @@ public:
// read and save files
void Save_File( wxCommandEvent& event );
void SaveProject();
int LoadOneEEProject( const wxString& FileName, bool IsNew );
bool LoadOneEEProject( const wxString& FileName, bool IsNew );
bool LoadOneEEFile( SCH_SCREEN* screen,
const wxString& FullFileName );
bool ReadInputStuffFile();

View File

@ -495,7 +495,20 @@ public:
void OnFileHistory( wxCommandEvent& event );
void Files_io( wxCommandEvent& event );
bool LoadOnePcbFile( const wxString& FileName, bool Append );
/**
* Load a Kicad board (.brd) file.
*
* @param aFileName - File name including path. If empty, a file dialog will
* be displayed.
* @param aAppend - Append board file aFileName to the currently loaded file if true.
* @param aForceFileDialog - Display the file open dialog even if aFullFileName is
* valid if true.
*
* @return False if file load fails or is cancelled by the user, otherwise true.
*/
bool LoadOnePcbFile( const wxString& aFileName, bool aAppend,
bool aForceFileDialog = false );
/**

View File

@ -176,7 +176,7 @@ void WinEDA_MainFrame::OnRunPcbNew( wxCommandEvent& event )
{
wxFileName fn( m_ProjectFileName );
fn.SetExt( BoardFileExtension );
fn.SetExt( PcbFileExtension );
ExecuteFile( this, PCBNEW_EXE, QuoteFullPath( fn ) );
}

View File

@ -46,7 +46,7 @@ void WinEDA_MainFrame::CreateNewProject( const wxString PrjFullFileName )
/* Init pcb board filename */
m_BoardFileName = wxFileName( newProjectName.GetName(),
BoardFileExtension ).GetFullName();
PcbFileExtension ).GetFullName();
/* Init project filename */
m_ProjectFileName = newProjectName;

View File

@ -425,7 +425,7 @@ wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type )
break;
case TREE_PCB:
ext = BoardFileExtension;
ext = PcbFileExtension;
break;
case TREE_GERBER:
@ -468,7 +468,7 @@ wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type )
break;
case TREE_PCB:
ext = BoardFileWildcard;
ext = PcbFileWildcard;
break;
case TREE_GERBER:
@ -704,7 +704,7 @@ void TREE_PROJECT_FRAME::ReCreateTreePrj()
if( !fn.FileExists() )
AddFile( fn.GetFullName(), m_root );
fn.SetExt( BoardFileExtension );
fn.SetExt( PcbFileExtension );
if( !fn.FileExists( ) )
AddFile( fn.GetFullName(), m_root );

View File

@ -244,7 +244,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( (CurrentTime - g_SaveTime) > g_TimeOut )
{
wxString tmpFileName = GetScreen()->m_FileName;
wxFileName fn = wxFileName( wxEmptyString, g_SaveFileName, PcbExtBuffer );
wxFileName fn = wxFileName( wxEmptyString, g_SaveFileName, PcbFileExtension );
bool flgmodify = GetScreen()->IsModify();
SavePcbFile( fn.GetFullPath() );

View File

@ -47,7 +47,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
switch( id )
{
case ID_LOAD_FILE:
LoadOnePcbFile( wxEmptyString, false );
LoadOnePcbFile( GetScreen()->m_FileName, false, true );
ReCreateAuxiliaryToolbar();
break;
@ -58,7 +58,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
if( id == ID_MENU_RECOVER_BOARD )
{
fn = wxFileName( wxEmptyString, g_SaveFileName, PcbExtBuffer );
fn = wxFileName( wxEmptyString, g_SaveFileName, PcbFileExtension );
}
else
{
@ -80,7 +80,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
}
LoadOnePcbFile( fn.GetFullPath(), false );
fn.SetExt( PcbExtBuffer );
fn.SetExt( PcbFileExtension );
GetScreen()->m_FileName = fn.GetFullPath();
SetTitle( GetScreen()->m_FileName );
ReCreateAuxiliaryToolbar();
@ -95,7 +95,7 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
Clear_Pcb( true );
GetScreen()->m_FileName.Printf( wxT( "%s%cnoname%s" ),
GetChars( wxGetCwd() ), DIR_SEP,
GetChars( PcbExtBuffer ) );
GetChars( PcbFileExtension ) );
SetTitle( GetScreen()->m_FileName );
ReCreateLayerBox( NULL );
break;
@ -114,12 +114,8 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event )
}
/**
* Read a board file
* @param FullFileName = file name. If empty, a file name will be asked
* @return 0 if fails or abort, 1 if OK
*/
bool WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, bool Append )
bool WinEDA_PcbFrame::LoadOnePcbFile( const wxString& aFileName, bool Append,
bool aForceFileDialog )
{
int ii;
FILE* source;
@ -144,27 +140,35 @@ the changes?" ) ) )
GetBoard()->m_Status_Pcb = 0;
}
wxString fileName;
wxFileName fileName = aFileName;
if( FullFileName == wxEmptyString )
if( !fileName.IsOk() || !fileName.FileExists() || aForceFileDialog )
{
wxFileName fn = GetScreen()->m_FileName;
wxString name;
wxString path = wxGetCwd();
wxFileDialog dlg( this, _( "Open Board File" ), wxEmptyString, fn.GetFullName(),
PcbFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( aForceFileDialog && fileName.FileExists() )
{
path = fileName.GetPath();
name = fileName.GetFullName();
}
wxFileDialog dlg( this, _( "Open Board File" ), path, name, PcbFileWildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() == wxID_CANCEL )
return false;
fileName = dlg.GetPath();
if( !fileName.HasExt() )
fileName.SetExt( PcbFileExtension );
}
else
fileName = FullFileName;
if( !Append )
Clear_Pcb( false ); // pass false since we prompted above for a modified board
GetScreen()->m_FileName = fileName;
GetScreen()->m_FileName = fileName.GetFullPath();
/* Start read PCB file
*/
@ -229,7 +233,7 @@ this file again." ) );
if ( ! new_filename.EndsWith( wxT( "-append" ) ) )
new_filename += wxT( "-append" );
new_filename += wxT( "." ) + PcbExtBuffer;
new_filename += wxT( "." ) + PcbFileExtension;
OnModify();
GetScreen()->m_FileName = new_filename;
@ -310,7 +314,7 @@ bool WinEDA_PcbFrame::SavePcbFile( const wxString& FileName )
if( FileName == wxEmptyString )
{
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString,
GetScreen()->m_FileName, BoardFileWildcard,
GetScreen()->m_FileName, PcbFileWildcard,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL )

View File

@ -120,11 +120,11 @@ bool WinEDA_App::OnInit()
{
fn = argv[1];
if( fn.GetExt() != BoardFileExtension )
if( fn.GetExt() != PcbFileExtension )
{
wxLogDebug( wxT( "PcbNew file <%s> has the wrong extension. \
Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
fn.SetExt( BoardFileExtension );
fn.SetExt( PcbFileExtension );
}
if( fn.IsOk() && fn.DirExists() )