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
dea9dd23
Commit
dea9dd23
authored
Jun 13, 2013
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better error reporting and parsing of bad legacy footprint libs
parent
64f8e0b8
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
54 deletions
+89
-54
dialog_annotate.cpp
eeschema/dialogs/dialog_annotate.cpp
+1
-1
reporter.h
include/reporter.h
+2
-2
dialog_template_selector.h
kicad/dialogs/dialog_template_selector.h
+10
-6
project_template.h
kicad/project_template.h
+1
-1
legacy_plugin.cpp
pcbnew/legacy_plugin.cpp
+74
-43
legacy_plugin.h
pcbnew/legacy_plugin.h
+1
-1
No files found.
eeschema/dialogs/dialog_annotate.cpp
View file @
dea9dd23
/**
* @file
annotate_dialog
.cpp
* @file
dialog_annotate
.cpp
* @brief Annotation dialog functions.
*/
...
...
include/reporter.h
View file @
dea9dd23
...
...
@@ -44,8 +44,8 @@ class wxTextCtrl;
* The purpose of the REPORTER object is to offer a way for a procedural function
* to report multiple errors without having to:
* <ul>
* <li>
a)
know too much about the caller's UI, i.e. wx. </li>
* <li>
b)
stop after the first error </li>
* <li> know too much about the caller's UI, i.e. wx. </li>
* <li> stop after the first error </li>
* </ul>
*/
class
REPORTER
...
...
kicad/dialogs/dialog_template_selector.h
View file @
dea9dd23
...
...
@@ -25,17 +25,18 @@
#ifndef PROJECT_TEMPLATE_SELECTOR_H
#define PROJECT_TEMPLATE_SELECTOR_H
#include
"dialogs/dialog_template_selector_base.h"
#include
<dialogs/dialog_template_selector_base.h>
#include "project_template.h"
class
TEMPLATE_WIDGET
:
public
TEMPLATE_WIDGET_BASE
{
protected
:
wxDialog
*
dialog
;
wxWindow
*
parent
;
wxPanel
*
panel
;
bool
selected
;
PROJECT_TEMPLATE
*
templ
;
void
OnKillFocus
(
wxFocusEvent
&
event
);
...
...
@@ -56,6 +57,7 @@ public:
bool
IsSelected
();
};
class
TEMPLATE_SELECTION_PANEL
:
public
TEMPLATE_SELECTION_PANEL_BASE
{
protected
:
...
...
@@ -65,6 +67,7 @@ protected:
public
:
/**
* @param aParent The window creating the dialog
* @param aPath the path
*/
TEMPLATE_SELECTION_PANEL
(
wxWindow
*
aParent
,
const
wxString
&
aPath
);
~
TEMPLATE_SELECTION_PANEL
();
...
...
@@ -72,6 +75,7 @@ public:
const
wxString
&
GetPath
()
{
return
m_templatesPath
;
}
};
class
DIALOG_TEMPLATE_SELECTOR
:
public
DIALOG_TEMPLATE_SELECTOR_BASE
{
protected
:
...
...
kicad/project_template.h
View file @
dea9dd23
...
...
@@ -59,7 +59,7 @@
~~~~~~~~~~~~~~
/info.html - Contains html formatted information about the template which is used by the
user to determine if the template is what they are after. The
<title>
tag
user to determine if the template is what they are after. The
<title>
tag
determines the actual name of the template that is exposed to the user for
template selection. Using html to format this document means that images can
be in-lined without having to invent a new scheme. Only HTML supported by
...
...
pcbnew/legacy_plugin.cpp
View file @
dea9dd23
...
...
@@ -276,8 +276,9 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend )
if
(
TESTLINE
(
"$MODULE"
)
)
{
MODULE
*
m
=
LoadMODULE
();
m_board
->
Add
(
m
,
ADD_APPEND
);
auto_ptr
<
MODULE
>
module
(
new
MODULE
(
m_board
)
);
LoadMODULE
(
module
.
get
()
);
m_board
->
Add
(
module
.
release
(),
ADD_APPEND
);
}
else
if
(
TESTLINE
(
"$DRAWSEGMENT"
)
)
...
...
@@ -918,9 +919,8 @@ void LEGACY_PLUGIN::loadSETUP()
}
MODULE
*
LEGACY_PLUGIN
::
LoadMODULE
(
)
void
LEGACY_PLUGIN
::
LoadMODULE
(
MODULE
*
aModule
)
{
auto_ptr
<
MODULE
>
module
(
new
MODULE
(
m_board
)
);
char
*
line
;
while
(
(
line
=
READLINE
(
m_reader
)
)
!=
NULL
)
...
...
@@ -929,14 +929,14 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
// most frequently encountered ones at the top
if
(
TESTSUBSTR
(
"D"
)
)
// read a drawing item, e.g. "DS"
if
(
TESTSUBSTR
(
"D"
)
&&
strchr
(
"SCAP"
,
line
[
1
]
)
)
// read a drawing item, e.g. "DS"
{
loadMODULE_EDGE
(
module
.
get
()
);
loadMODULE_EDGE
(
aModule
);
}
else
if
(
TESTLINE
(
"$PAD"
)
)
{
loadPAD
(
module
.
get
()
);
loadPAD
(
aModule
);
}
// Read a footprint text description (ref, value, or drawing)
...
...
@@ -951,17 +951,17 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
switch
(
tnum
)
{
case
TEXTE_MODULE
:
:
TEXT_is_REFERENCE
:
textm
=
&
m
odule
->
Reference
();
textm
=
&
aM
odule
->
Reference
();
break
;
case
TEXTE_MODULE
:
:
TEXT_is_VALUE
:
textm
=
&
m
odule
->
Value
();
textm
=
&
aM
odule
->
Value
();
break
;
default
:
// text is a drawing
textm
=
new
TEXTE_MODULE
(
module
.
get
()
);
m
odule
->
GraphicalItems
().
PushBack
(
textm
);
textm
=
new
TEXTE_MODULE
(
aModule
);
aM
odule
->
GraphicalItems
().
PushBack
(
textm
);
}
loadMODULE_TEXT
(
textm
);
...
...
@@ -986,29 +986,29 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
// data is now a two character long string
// Note: some old files do not have this field
if
(
data
&&
data
[
0
]
==
'F'
)
m
odule
->
SetLocked
(
true
);
aM
odule
->
SetLocked
(
true
);
if
(
data
&&
data
[
1
]
==
'P'
)
m
odule
->
SetIsPlaced
(
true
);
aM
odule
->
SetIsPlaced
(
true
);
m
odule
->
SetPosition
(
wxPoint
(
pos_x
,
pos_y
)
);
m
odule
->
SetLayer
(
layer
);
m
odule
->
SetOrientation
(
orient
);
m
odule
->
SetTimeStamp
(
timestamp
);
m
odule
->
SetLastEditTime
(
edittime
);
aM
odule
->
SetPosition
(
wxPoint
(
pos_x
,
pos_y
)
);
aM
odule
->
SetLayer
(
layer
);
aM
odule
->
SetOrientation
(
orient
);
aM
odule
->
SetTimeStamp
(
timestamp
);
aM
odule
->
SetLastEditTime
(
edittime
);
}
else
if
(
TESTLINE
(
"Li"
)
)
// Library name of footprint
{
// There can be whitespace in the footprint name on some old libraries.
// Grab everything after "Li" up to end of line:
m
odule
->
SetLibRef
(
FROM_UTF8
(
StrPurge
(
line
+
SZ
(
"Li"
)
)
)
);
// aM
odule->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) );
}
else
if
(
TESTLINE
(
"Sc"
)
)
// timestamp
{
time_t
timestamp
=
hexParse
(
line
+
SZ
(
"Sc"
)
);
m
odule
->
SetTimeStamp
(
timestamp
);
aM
odule
->
SetTimeStamp
(
timestamp
);
}
else
if
(
TESTLINE
(
"Op"
)
)
// (Op)tions for auto placement
...
...
@@ -1020,7 +1020,7 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
if
(
cntRot180
>
10
)
cntRot180
=
10
;
m
odule
->
SetPlacementCost180
(
cntRot180
);
aM
odule
->
SetPlacementCost180
(
cntRot180
);
int
cntRot90
=
itmp1
&
0x0F
;
if
(
cntRot90
>
10
)
...
...
@@ -1030,7 +1030,7 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
if
(
itmp1
>
10
)
itmp1
=
0
;
m
odule
->
SetPlacementCost90
(
(
itmp1
<<
4
)
|
cntRot90
);
aM
odule
->
SetPlacementCost90
(
(
itmp1
<<
4
)
|
cntRot90
);
}
else
if
(
TESTLINE
(
"At"
)
)
// (At)tributes of module
...
...
@@ -1045,30 +1045,31 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
if
(
strstr
(
data
,
"VIRTUAL"
)
)
attrs
|=
MOD_VIRTUAL
;
m
odule
->
SetAttributes
(
attrs
);
aM
odule
->
SetAttributes
(
attrs
);
}
else
if
(
TESTLINE
(
"AR"
)
)
// Alternate Reference
{
// e.g. "AR /47BA2624/45525076"
data
=
strtok
(
line
+
SZ
(
"AR"
),
delims
);
module
->
SetPath
(
FROM_UTF8
(
data
)
);
if
(
data
)
aModule
->
SetPath
(
FROM_UTF8
(
data
)
);
}
else
if
(
TESTLINE
(
"$SHAPE3D"
)
)
{
load3D
(
module
.
get
()
);
load3D
(
aModule
);
}
else
if
(
TESTLINE
(
"Cd"
)
)
{
// e.g. "Cd Double rangee de contacts 2 x 4 pins\r\n"
m
odule
->
SetDescription
(
FROM_UTF8
(
StrPurge
(
line
+
SZ
(
"Cd"
)
)
)
);
aM
odule
->
SetDescription
(
FROM_UTF8
(
StrPurge
(
line
+
SZ
(
"Cd"
)
)
)
);
}
else
if
(
TESTLINE
(
"Kw"
)
)
// Key words
{
m
odule
->
SetKeywords
(
FROM_UTF8
(
StrPurge
(
line
+
SZ
(
"Kw"
)
)
)
);
aM
odule
->
SetKeywords
(
FROM_UTF8
(
StrPurge
(
line
+
SZ
(
"Kw"
)
)
)
);
}
else
if
(
TESTLINE
(
".SolderPasteRatio"
)
)
...
...
@@ -1082,54 +1083,58 @@ MODULE* LEGACY_PLUGIN::LoadMODULE()
tmp
=
-
0.50
;
if
(
tmp
>
0.0
)
tmp
=
0.0
;
m
odule
->
SetLocalSolderPasteMarginRatio
(
tmp
);
aM
odule
->
SetLocalSolderPasteMarginRatio
(
tmp
);
}
else
if
(
TESTLINE
(
".SolderPaste"
)
)
{
BIU
tmp
=
biuParse
(
line
+
SZ
(
".SolderPaste"
)
);
m
odule
->
SetLocalSolderPasteMargin
(
tmp
);
aM
odule
->
SetLocalSolderPasteMargin
(
tmp
);
}
else
if
(
TESTLINE
(
".SolderMask"
)
)
{
BIU
tmp
=
biuParse
(
line
+
SZ
(
".SolderMask"
)
);
m
odule
->
SetLocalSolderMaskMargin
(
tmp
);
aM
odule
->
SetLocalSolderMaskMargin
(
tmp
);
}
else
if
(
TESTLINE
(
".LocalClearance"
)
)
{
BIU
tmp
=
biuParse
(
line
+
SZ
(
".LocalClearance"
)
);
m
odule
->
SetLocalClearance
(
tmp
);
aM
odule
->
SetLocalClearance
(
tmp
);
}
else
if
(
TESTLINE
(
".ZoneConnection"
)
)
{
int
tmp
=
intParse
(
line
+
SZ
(
".ZoneConnection"
)
);
m
odule
->
SetZoneConnection
(
(
ZoneConnection
)
tmp
);
aM
odule
->
SetZoneConnection
(
(
ZoneConnection
)
tmp
);
}
else
if
(
TESTLINE
(
".ThermalWidth"
)
)
{
BIU
tmp
=
biuParse
(
line
+
SZ
(
".ThermalWidth"
)
);
m
odule
->
SetThermalWidth
(
tmp
);
aM
odule
->
SetThermalWidth
(
tmp
);
}
else
if
(
TESTLINE
(
".ThermalGap"
)
)
{
BIU
tmp
=
biuParse
(
line
+
SZ
(
".ThermalGap"
)
);
m
odule
->
SetThermalGap
(
tmp
);
aM
odule
->
SetThermalGap
(
tmp
);
}
else
if
(
TESTLINE
(
"$EndMODULE"
)
)
{
m
odule
->
CalculateBoundingBox
();
aM
odule
->
CalculateBoundingBox
();
return
module
.
release
()
;
// preferred exit
return
;
// preferred exit
}
}
THROW_IO_ERROR
(
"Missing '$EndMODULE'"
);
wxString
msg
=
wxString
::
Format
(
wxT
(
"Missing '$EndMODULE' for MODULE '%s'"
),
GetChars
(
aModule
->
GetLibRef
()
)
);
THROW_IO_ERROR
(
msg
);
}
...
...
@@ -1175,8 +1180,12 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule )
case
'O'
:
padshape
=
PAD_OVAL
;
break
;
case
'T'
:
padshape
=
PAD_TRAPEZOID
;
break
;
default
:
m_error
.
Printf
(
_
(
"Unknown padshape '%s' on line:%d"
),
FROM_UTF8
(
line
).
GetData
(),
m_reader
->
LineNumber
()
);
m_error
.
Printf
(
_
(
"Unknown padshape '%c=0x%02x' on line:%d of module:'%s'"
),
(
unsigned
char
)
padshape
,
(
unsigned
char
)
padshape
,
m_reader
->
LineNumber
(),
GetChars
(
aModule
->
GetLibRef
()
)
);
THROW_IO_ERROR
(
m_error
);
}
...
...
@@ -1372,8 +1381,12 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
case
'A'
:
shape
=
S_ARC
;
break
;
case
'P'
:
shape
=
S_POLYGON
;
break
;
default
:
m_error
.
Printf
(
wxT
(
"Unknown EDGE_MODULE type '%s' line %d"
),
FROM_UTF8
(
line
).
GetData
(),
m_reader
->
LineNumber
()
);
m_error
.
Printf
(
wxT
(
"Unknown EDGE_MODULE type:'%c=0x%02x' on line:%d of module:'%s'"
),
(
unsigned
char
)
line
[
1
],
(
unsigned
char
)
line
[
1
],
m_reader
->
LineNumber
(),
GetChars
(
aModule
->
GetLibRef
()
)
);
THROW_IO_ERROR
(
m_error
);
}
...
...
@@ -4036,9 +4049,27 @@ void FPL_CACHE::LoadModules( LINE_READER* aReader )
// test first for the $MODULE, even before reading because of INDEX bug.
if
(
TESTLINE
(
"$MODULE"
)
)
{
MODULE
*
m
=
m_owner
->
LoadMODULE
();
auto_ptr
<
MODULE
>
module
(
new
MODULE
(
m_owner
->
m_board
)
);
std
::
string
footprintName
=
StrPurge
(
line
+
SZ
(
"$MODULE"
)
);
// set the footprint name first thing, so exceptions can use name.
module
->
SetLibRef
(
FROM_UTF8
(
footprintName
.
c_str
()
)
);
#if 0 && defined( DEBUG )
printf( "%s\n", footprintName.c_str() );
if( footprintName == "QFN40" )
{
int breakhere = 1;
(void) breakhere;
}
#endif
m_owner
->
LoadMODULE
(
module
.
get
()
);
MODULE
*
m
=
module
.
release
();
// exceptions after this are not expected.
std
::
string
footprintName
=
TO_UTF8
(
m
->
GetLibRef
(
)
);
wxASSERT
(
footprintName
==
TO_UTF8
(
m
->
GetLibRef
()
)
);
/*
...
...
pcbnew/legacy_plugin.h
View file @
dea9dd23
...
...
@@ -106,7 +106,7 @@ public:
void
SetReader
(
LINE_READER
*
aReader
)
{
m_reader
=
aReader
;
}
void
SetFilePtr
(
FILE
*
aFile
)
{
m_fp
=
aFile
;
}
MODULE
*
LoadMODULE
(
);
void
LoadMODULE
(
MODULE
*
aModule
);
void
SaveMODULE
(
const
MODULE
*
aModule
)
const
;
void
SaveModule3D
(
const
MODULE
*
aModule
)
const
;
void
SaveBOARD
(
const
BOARD
*
aBoard
)
const
;
...
...
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