Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
b68fa7cd
Commit
b68fa7cd
authored
May 29, 2012
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generalize the BOARD loading process PCB_EDIT_FRAME::LoadOnePcbFile() to use any supported PLUGIN
parent
ad86e50a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
37 deletions
+61
-37
wildcards_and_files_ext.cpp
common/wildcards_and_files_ext.cpp
+1
-0
wildcards_and_files_ext.h
include/wildcards_and_files_ext.h
+1
-0
files.cpp
pcbnew/files.cpp
+59
-37
No files found.
common/wildcards_and_files_ext.cpp
View file @
b68fa7cd
...
...
@@ -55,6 +55,7 @@ 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
LegacyPcbFileWildcard
(
_
(
"KiCad printed circuit board files (*.brd)|*.brd"
)
);
const
wxString
EaglePcbFileWildcard
(
_
(
"Eagle printed circuit board files (*.brd)|*.brd"
)
);
const
wxString
PcbFileWildcard
(
_
(
"KiCad s-expr printed circuit board files (*.kicad_pcb)|*.kicad_pcb"
)
);
const
wxString
FootprintLibFileWildcard
(
_
(
"KiCad footprint library file (*.mod)|*.mod"
)
);
const
wxString
PdfFileWildcard
(
_
(
"Portable document format files (*.pdf)|*.pdf"
)
);
...
...
include/wildcards_and_files_ext.h
View file @
b68fa7cd
...
...
@@ -63,6 +63,7 @@ extern const wxString NetlistFileWildcard;
extern
const
wxString
GerberFileWildcard
;
extern
const
wxString
LegacyPcbFileWildcard
;
extern
const
wxString
PcbFileWildcard
;
extern
const
wxString
EaglePcbFileWildcard
;
extern
const
wxString
PdfFileWildcard
;
extern
const
wxString
MacrosFileWildcard
;
extern
const
wxString
AllFilesWildcard
;
...
...
pcbnew/files.cpp
View file @
b68fa7cd
...
...
@@ -90,39 +90,39 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
case
ID_MENU_READ_LAST_SAVED_VERSION_BOARD
:
case
ID_MENU_RECOVER_BOARD
:
{
wxFileName
fn
;
if
(
id
==
ID_MENU_RECOVER_BOARD
)
{
fn
=
wxFileName
(
wxEmptyString
,
saveFileName
,
PcbFileExtension
);
}
else
{
fn
=
GetScreen
()
->
GetFileName
();
fn
.
SetExt
(
pcbBackupFileExtension
);
}
wxFileName
fn
;
if
(
!
fn
.
FileExists
()
)
{
msg
=
_
(
"Recovery file "
)
+
fn
.
GetFullPath
()
+
_
(
" not found."
);
DisplayInfoMessage
(
this
,
msg
);
break
;
}
else
{
msg
=
_
(
"OK to load recovery file "
)
+
fn
.
GetFullPath
();
if
(
id
==
ID_MENU_RECOVER_BOARD
)
{
fn
=
wxFileName
(
wxEmptyString
,
saveFileName
,
PcbFileExtension
);
}
else
{
fn
=
GetScreen
()
->
GetFileName
();
fn
.
SetExt
(
pcbBackupFileExtension
);
}
if
(
!
IsOK
(
this
,
msg
)
)
if
(
!
fn
.
FileExists
()
)
{
msg
=
_
(
"Recovery file "
)
+
fn
.
GetFullPath
()
+
_
(
" not found."
);
DisplayInfoMessage
(
this
,
msg
);
break
;
}
}
else
{
msg
=
_
(
"OK to load recovery file "
)
+
fn
.
GetFullPath
();
LoadOnePcbFile
(
fn
.
GetFullPath
(),
false
);
fn
.
SetExt
(
PcbFileExtension
);
GetScreen
()
->
SetFileName
(
fn
.
GetFullPath
()
);
UpdateTitle
();
if
(
!
IsOK
(
this
,
msg
)
)
break
;
}
LoadOnePcbFile
(
fn
.
GetFullPath
(),
false
);
fn
.
SetExt
(
PcbFileExtension
);
GetScreen
()
->
SetFileName
(
fn
.
GetFullPath
()
);
UpdateTitle
();
}
break
;
}
case
ID_APPEND_FILE
:
LoadOnePcbFile
(
wxEmptyString
,
true
);
...
...
@@ -154,8 +154,6 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
bool
PCB_EDIT_FRAME
::
LoadOnePcbFile
(
const
wxString
&
aFileName
,
bool
aAppend
,
bool
aForceFileDialog
)
{
wxString
msg
;
if
(
GetScreen
()
->
IsModify
()
&&
!
aAppend
)
{
if
(
!
IsOK
(
this
,
_
(
"The current board has been modified. Do you wish to discard \
...
...
@@ -170,12 +168,32 @@ the changes?" ) ) )
GetBoard
()
->
m_Status_Pcb
=
0
;
}
wxFileName
fileName
=
aFileName
;
wxFileName
fileName
=
aFileName
;
IO_MGR
::
PCB_FILE_T
pluginType
=
IO_MGR
::
LEGACY
;
static
const
struct
{
const
wxString
&
filter
;
IO_MGR
::
PCB_FILE_T
pluginType
;
}
loaders
[]
=
{
{
LegacyPcbFileWildcard
,
IO_MGR
::
LEGACY
},
{
PcbFileWildcard
,
IO_MGR
::
KICAD
},
{
EaglePcbFileWildcard
,
IO_MGR
::
EAGLE
},
};
if
(
!
fileName
.
IsOk
()
||
!
fileName
.
FileExists
()
||
aForceFileDialog
)
{
wxString
name
;
wxString
path
=
wxGetCwd
();
wxString
fileFilters
;
for
(
unsigned
i
=
0
;
i
<
DIM
(
loaders
);
++
i
)
{
if
(
i
>
0
)
fileFilters
+=
wxChar
(
'|'
);
fileFilters
+=
loaders
[
i
].
filter
;
}
if
(
aForceFileDialog
&&
fileName
.
FileExists
()
)
{
...
...
@@ -183,7 +201,7 @@ the changes?" ) ) )
name
=
fileName
.
GetFullName
();
}
wxFileDialog
dlg
(
this
,
_
(
"Open Board File"
),
path
,
name
,
LegacyPcbFileWildcard
,
wxFileDialog
dlg
(
this
,
_
(
"Open Board File"
),
path
,
name
,
fileFilters
,
wxFD_OPEN
|
wxFD_FILE_MUST_EXIST
);
if
(
dlg
.
ShowModal
()
==
wxID_CANCEL
)
...
...
@@ -191,10 +209,15 @@ the changes?" ) ) )
fileName
=
dlg
.
GetPath
();
i
f
(
!
fileName
.
HasExt
()
)
fileName
.
SetExt
(
PcbFileExtension
)
;
i
nt
chosenFilter
=
dlg
.
GetFilterIndex
();
pluginType
=
loaders
[
chosenFilter
].
pluginType
;
}
PLUGIN
::
RELEASER
pi
(
IO_MGR
::
PluginFind
(
pluginType
)
);
if
(
!
fileName
.
HasExt
()
)
fileName
.
SetExt
(
pi
->
GetFileExtension
()
);
if
(
!
aAppend
)
Clear_Pcb
(
false
);
// pass false since we prompted above for a modified board
...
...
@@ -224,13 +247,12 @@ the changes?" ) ) )
try
{
// load or append either:
loadedBoard
=
IO_MGR
::
Load
(
IO_MGR
::
LEGACY
,
GetScreen
()
->
GetFileName
(),
aAppend
?
GetBoard
()
:
NULL
,
NULL
);
loadedBoard
=
pi
->
Load
(
GetScreen
()
->
GetFileName
(),
aAppend
?
GetBoard
()
:
NULL
,
NULL
);
if
(
!
aAppend
)
{
if
(
loadedBoard
->
GetFileFormatVersionAtLoad
()
<
LEGACY_BOARD_FILE_VERSION
)
if
(
pluginType
==
IO_MGR
::
LEGACY
&&
loadedBoard
->
GetFileFormatVersionAtLoad
()
<
LEGACY_BOARD_FILE_VERSION
)
{
DisplayInfoMessage
(
this
,
_
(
"This file was created by an older \
version of Pcbnew. It will be stored in the new file format when you save \
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment