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
443534e7
Commit
443534e7
authored
Oct 08, 2010
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Plain Diff
Gerbview: fixed a serious bug when reading GERBER files with no trailing zeros
parents
562f26dd
69b3bfd4
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
33 deletions
+70
-33
gr_basic.cpp
common/gr_basic.cpp
+4
-4
aperture-circle-flash-with_hole.gbr
...iew/gerber_test_files/aperture-circle-flash-with_hole.gbr
+1
-1
gerberframe.cpp
gerbview/gerberframe.cpp
+13
-7
rs274d.cpp
gerbview/rs274d.cpp
+16
-17
rs274x.cpp
gerbview/rs274x.cpp
+32
-2
gr_basic.h
include/gr_basic.h
+4
-2
No files found.
common/gr_basic.cpp
View file @
443534e7
...
...
@@ -555,7 +555,7 @@ void GRResetPenAndBrush( wxDC* DC )
* Function GRSetColorPen
* sets a pen style, width, color, and alpha into the given device context.
*/
void
GRSetColorPen
(
wxDC
*
DC
,
int
Color
,
int
width
,
int
style
)
void
GRSetColorPen
(
wxDC
*
DC
,
int
Color
,
int
width
,
wxPenStyle
style
)
{
if
(
width
<
0
)
width
=
0
;
...
...
@@ -733,7 +733,7 @@ void GRSDashedLine( EDA_Rect* ClipBox,
GRLastMoveToX
=
x2
;
GRLastMoveToY
=
y2
;
s_DC_lastcolor
=
-
1
;
GRSetColorPen
(
DC
,
Color
,
width
,
wxSHORT_DASH
);
GRSetColorPen
(
DC
,
Color
,
width
,
wx
PENSTYLE_
SHORT_DASH
);
GRSLine
(
ClipBox
,
DC
,
x1
,
y1
,
x2
,
y2
,
width
,
Color
);
s_DC_lastcolor
=
-
1
;
GRSetColorPen
(
DC
,
Color
,
width
);
...
...
@@ -748,7 +748,7 @@ void GRSDashedLineTo( EDA_Rect* ClipBox,
int
Color
)
{
s_DC_lastcolor
=
-
1
;
GRSetColorPen
(
DC
,
Color
,
width
,
wxSHORT_DASH
);
GRSetColorPen
(
DC
,
Color
,
width
,
wx
PENSTYLE_
SHORT_DASH
);
GRSLine
(
ClipBox
,
DC
,
GRLastMoveToX
,
GRLastMoveToY
,
x2
,
y2
,
width
,
Color
);
s_DC_lastcolor
=
-
1
;
GRSetColorPen
(
DC
,
Color
,
width
);
...
...
@@ -846,7 +846,7 @@ void GRSMixedLine( EDA_Rect* ClipBox,
int
width
,
int
Color
)
{
GRSetColorPen
(
DC
,
Color
,
width
,
wxDOT_DASH
);
GRSetColorPen
(
DC
,
Color
,
width
,
wx
PENSTYLE_
DOT_DASH
);
GRSLine
(
ClipBox
,
DC
,
x1
,
y1
,
x2
,
y2
,
width
,
Color
);
GRSetColorPen
(
DC
,
Color
,
width
);
}
...
...
gerbview/gerber_test_files/aperture-circle-flash-with_hole.gbr
View file @
443534e7
...
...
@@ -21,7 +21,7 @@ X0Y00100D03*
G04 Two, with round holes, slightly overlapping, centered at 0.1,0.1 *
G54D11*
X
00100Y000
90D03*
X
100Y
90D03*
X00100Y00110D03*
M02*
gerbview/gerberframe.cpp
View file @
443534e7
...
...
@@ -482,8 +482,10 @@ void WinEDA_GerberFrame::Liste_D_Codes( )
/** function UpdateTitleAndInfo
* displays the short filename (if exists) of the selected layer
* on the caption of the main gerbview window
*
and the name of the layer
(found in the gerber file: LN <name> command)
*
displays image name and the last layer name
(found in the gerber file: LN <name> command)
* in the status bar
* Note layer name can change when reading a gerber file, and the layer name is the last found.
* So, show the layer name is not very useful, and can be seen as a debug feature.
*/
void
WinEDA_GerberFrame
::
UpdateTitleAndInfo
()
{
...
...
@@ -493,24 +495,28 @@ void WinEDA_GerberFrame::UpdateTitleAndInfo()
if
(
gerber
==
NULL
)
{
text
=
wxGetApp
().
GetAppName
()
+
wxT
(
" "
)
+
GetBuildVersion
();
SetTitle
(
text
);
SetStatusText
(
wxEmptyString
,
0
);
m_TextInfo
->
Clear
();
SetTitle
(
text
);
return
;
}
text
=
_
(
"File:"
);
text
<<
wxT
(
" "
)
<<
gerber
->
m_FileName
;
SetTitle
(
text
);
// Display Image Name and Layer Name (from the current gerber data):
text
.
Printf
(
_
(
"Image name:
\"
%s
\"
Layer name
\"
%s
\"
"
),
GetChars
(
gerber
->
m_ImageName
),
GetChars
(
gerber
->
m_LayerName
)
);
SetStatusText
(
text
,
0
);
// Display data format like fmt in X3.4Y3.4
or fmt mm X2.3 Y3.5
text
.
Printf
(
wxT
(
"fmt
%s X%d.%d Y%d.%d
"
),
// Display data format like fmt in X3.4Y3.4
no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
text
.
Printf
(
wxT
(
"fmt
: %s X%d.%d Y%d.%d no %cZ
"
),
gerber
->
m_GerbMetric
?
wxT
(
"mm"
)
:
wxT
(
"in"
),
gerber
->
m_FmtLen
.
x
-
gerber
->
m_FmtScale
.
x
,
gerber
->
m_FmtScale
.
x
,
gerber
->
m_FmtLen
.
y
-
gerber
->
m_FmtScale
.
y
,
gerber
->
m_FmtScale
.
y
);
gerber
->
m_FmtLen
.
y
-
gerber
->
m_FmtScale
.
y
,
gerber
->
m_FmtScale
.
y
,
gerber
->
m_NoTrailingZeros
?
'T'
:
'L'
);
m_TextInfo
->
SetValue
(
text
);
}
...
...
gerbview/rs274d.cpp
View file @
443534e7
...
...
@@ -453,7 +453,7 @@ static void fillArcPOLY( BOARD* aPcb, GERBER_DRAW_ITEM* aGbrItem,
wxPoint
GERBER
::
ReadXYCoord
(
char
*&
Text
)
{
wxPoint
pos
=
m_CurrentPos
;
int
type_coord
=
0
,
current_coord
,
nb
char
;
int
type_coord
=
0
,
current_coord
,
nb
digits
;
bool
is_float
=
false
;
char
*
text
;
char
line
[
256
];
...
...
@@ -475,14 +475,15 @@ wxPoint GERBER::ReadXYCoord( char*& Text )
type_coord
=
*
Text
;
Text
++
;
text
=
line
;
nb
char
=
0
;
nb
digits
=
0
;
while
(
IsNumber
(
*
Text
)
)
{
if
(
*
Text
==
'.'
)
is_float
=
true
;
*
(
text
++
)
=
*
(
Text
++
);
// count digits only (sign and decimal point are not counted)
if
(
(
*
Text
>=
'0'
)
&&
(
*
Text
<=
'9'
)
)
nbchar
++
;
nbdigits
++
;
*
(
text
++
)
=
*
(
Text
++
);
}
*
text
=
0
;
...
...
@@ -495,24 +496,21 @@ wxPoint GERBER::ReadXYCoord( char*& Text )
}
else
{
int
fmt_scale
=
(
type_coord
==
'X'
)
?
m_FmtScale
.
x
:
m_FmtScale
.
y
;
int
fmt_scale
=
(
type_coord
==
'X'
)
?
m_FmtScale
.
x
:
m_FmtScale
.
y
;
if
(
m_NoTrailingZeros
)
{
int
min_digit
=
(
type_coord
==
'X'
)
?
m_FmtLen
.
x
:
m_FmtLen
.
y
;
while
(
nb
char
<
min_digit
)
while
(
nb
digits
<
min_digit
)
{
*
(
text
++
)
=
'0'
;
nb
char
++
;
nb
digits
++
;
}
*
text
=
0
;
}
current_coord
=
atoi
(
line
);
double
real_scale
=
1.0
;
if
(
fmt_scale
<
0
||
fmt_scale
>
9
)
fmt_scale
=
4
;
double
scale_list
[
10
]
=
{
10000.0
,
1000.0
,
100.0
,
10.0
,
...
...
@@ -557,7 +555,7 @@ wxPoint GERBER::ReadIJCoord( char*& Text )
{
wxPoint
pos
(
0
,
0
);
int
type_coord
=
0
,
current_coord
,
nb
char
;
int
type_coord
=
0
,
current_coord
,
nb
digits
;
bool
is_float
=
false
;
char
*
text
;
char
line
[
256
];
...
...
@@ -573,14 +571,15 @@ wxPoint GERBER::ReadIJCoord( char*& Text )
type_coord
=
*
Text
;
Text
++
;
text
=
line
;
nb
char
=
0
;
nb
digits
=
0
;
while
(
IsNumber
(
*
Text
)
)
{
if
(
*
Text
==
'.'
)
is_float
=
true
;
*
(
text
++
)
=
*
(
Text
++
);
// count digits only (sign and decimal point are not counted)
if
(
(
*
Text
>=
'0'
)
&&
(
*
Text
<=
'9'
)
)
nbchar
++
;
nbdigits
++
;
*
(
text
++
)
=
*
(
Text
++
);
}
*
text
=
0
;
...
...
@@ -599,10 +598,10 @@ wxPoint GERBER::ReadIJCoord( char*& Text )
{
int
min_digit
=
(
type_coord
==
'I'
)
?
m_FmtLen
.
x
:
m_FmtLen
.
y
;
while
(
nb
char
<
min_digit
)
while
(
nb
digits
<
min_digit
)
{
*
(
text
++
)
=
'0'
;
nb
char
++
;
nb
digits
++
;
}
*
text
=
0
;
...
...
gerbview/rs274x.cpp
View file @
443534e7
...
...
@@ -225,11 +225,20 @@ bool GERBER::ExecuteRS274XCommand( int command,
// number of digits after the decimal point
m_FmtScale
.
x
=
*
text
-
'0'
;
m_FmtLen
.
x
=
ctmp
+
m_FmtScale
.
x
;
// m_FmtScale is 0 to 9
if
(
m_FmtScale
.
x
<
0
)
m_FmtScale
.
x
=
0
;
if
(
m_FmtScale
.
x
>
9
)
m_FmtScale
.
x
=
9
;
}
else
{
m_FmtScale
.
y
=
*
text
-
'0'
;
m_FmtLen
.
y
=
ctmp
+
m_FmtScale
.
y
;
if
(
m_FmtScale
.
y
<
0
)
m_FmtScale
.
y
=
0
;
if
(
m_FmtScale
.
y
>
9
)
m_FmtScale
.
y
=
9
;
}
text
++
;
}
...
...
@@ -285,6 +294,29 @@ bool GERBER::ExecuteRS274XCommand( int command,
break
;
case
SCALE_FACTOR
:
m_LayerScale
.
x
=
m_LayerScale
.
y
=
1.0
;
while
(
*
text
!=
'*'
)
{
switch
(
*
text
)
{
case
'A'
:
// A axis scale
text
++
;
m_LayerScale
.
x
=
ReadDouble
(
text
);
break
;
case
'B'
:
// B axis scale
text
++
;
m_LayerScale
.
y
=
ReadDouble
(
text
);
break
;
}
}
if
(
m_LayerScale
.
x
!=
1.0
||
m_LayerScale
.
y
!=
1.0
)
{
msg
.
Printf
(
_
(
"RS274X: FS command: Gerbview uses 1.0 only scale factor"
)
);
ReportMessage
(
msg
);
}
break
;
case
IMAGE_JUSTIFY
:
case
IMAGE_ROTATION
:
case
IMAGE_OFFSET
:
...
...
@@ -292,11 +324,9 @@ bool GERBER::ExecuteRS274XCommand( int command,
case
KNOCKOUT
:
case
STEP_AND_REPEAT
:
case
ROTATE
:
{
msg
.
Printf
(
_
(
"RS274X: Command
\"
%c%c
\"
ignored by Gerbview"
),
(
command
>>
8
)
&
0xFF
,
command
&
0xFF
);
ReportMessage
(
msg
);
}
break
;
case
IMAGE_NAME
:
...
...
include/gr_basic.h
View file @
443534e7
...
...
@@ -27,6 +27,8 @@ class EDA_Rect;
//wxWidgets 2.8 compatibility
#if !wxCHECK_VERSION(2,9,0)
#define wxPENSTYLE_SOLID wxSOLID
#define wxPENSTYLE_SHORT_DASH wxSHORT_DASH
#define wxPENSTYLE_DOT_DASH wxDOT_DASH
typedef
int
wxPenStyle
;
#endif
...
...
@@ -51,7 +53,7 @@ class WinEDA_DrawPanel;
void
GRSetDrawMode
(
wxDC
*
DC
,
int
mode
);
int
GRGetDrawMode
(
wxDC
*
DC
);
void
GRResetPenAndBrush
(
wxDC
*
DC
);
void
GRSetColorPen
(
wxDC
*
DC
,
int
Color
,
int
width
=
1
,
int
stype
=
wx
SOLID
);
void
GRSetColorPen
(
wxDC
*
DC
,
int
Color
,
int
width
=
1
,
wxPenStyle
stype
=
wxPENSTYLE_
SOLID
);
void
GRSetBrush
(
wxDC
*
DC
,
int
Color
,
int
fill
=
0
);
/** function GRForceBlackPen
...
...
@@ -191,7 +193,7 @@ void GRRect( EDA_Rect* ClipBox, wxDC* DC,const EDA_Rect& aRect, int Color );
void
GRRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
);
void
GRRectPs
(
EDA_Rect
*
aClipBox
,
wxDC
*
aDC
,
const
EDA_Rect
&
aRect
,
int
aWidth
,
int
aColor
,
int
aStyle
=
wx
SOLID
);
int
aWidth
,
int
aColor
,
wxPenStyle
aStyle
=
wxPENSTYLE_
SOLID
);
void
GRSFilledRect
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
int
width
,
int
Color
,
int
BgColor
);
...
...
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