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
4ac27702
Commit
4ac27702
authored
Jul 09, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code formatting.
parent
77d8b2d8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
130 additions
and
144 deletions
+130
-144
dxf2brd_items.cpp
pcbnew/import_dxf/dxf2brd_items.cpp
+77
-89
dxf2brd_items.h
pcbnew/import_dxf/dxf2brd_items.h
+53
-55
No files found.
pcbnew/import_dxf/dxf2brd_items.cpp
View file @
4ac27702
...
@@ -67,13 +67,13 @@ DXF2BRD_CONVERTER::~DXF2BRD_CONVERTER()
...
@@ -67,13 +67,13 @@ DXF2BRD_CONVERTER::~DXF2BRD_CONVERTER()
// coordinate conversions from dxf to internal units
// coordinate conversions from dxf to internal units
int
DXF2BRD_CONVERTER
::
mapX
(
double
aDxfCoordX
)
int
DXF2BRD_CONVERTER
::
mapX
(
double
aDxfCoordX
)
{
{
return
Millimeter2iu
(
m_xOffset
+
(
aDxfCoordX
*
m_Dfx2mm
)
);
return
Millimeter2iu
(
m_xOffset
+
(
aDxfCoordX
*
m_Dfx2mm
)
);
}
}
int
DXF2BRD_CONVERTER
::
mapY
(
double
aDxfCoordY
)
int
DXF2BRD_CONVERTER
::
mapY
(
double
aDxfCoordY
)
{
{
return
Millimeter2iu
(
m_yOffset
-
(
aDxfCoordY
*
m_Dfx2mm
)
);
return
Millimeter2iu
(
m_yOffset
-
(
aDxfCoordY
*
m_Dfx2mm
)
);
}
}
...
@@ -95,23 +95,22 @@ bool DXF2BRD_CONVERTER::ImportDxfFile( const wxString& aFile, BOARD* aBoard )
...
@@ -95,23 +95,22 @@ bool DXF2BRD_CONVERTER::ImportDxfFile( const wxString& aFile, BOARD* aBoard )
return
success
;
return
success
;
}
}
// Add aItem the the board
// this item is also added to the list of new items
void
DXF2BRD_CONVERTER
::
appendToBoard
(
BOARD_ITEM
*
aItem
)
// (for undo command for instance)
void
DXF2BRD_CONVERTER
::
appendToBoard
(
BOARD_ITEM
*
aItem
)
{
{
m_brd
->
Add
(
aItem
);
m_brd
->
Add
(
aItem
);
m_newItemsList
.
push_back
(
aItem
);
m_newItemsList
.
push_back
(
aItem
);
}
}
/*
/*
* Implementation of the method which handles layers.
* Implementation of the method which handles layers.
*/
*/
void
DXF2BRD_CONVERTER
::
addLayer
(
const
DRW_Layer
&
d
ata
)
void
DXF2BRD_CONVERTER
::
addLayer
(
const
DRW_Layer
&
aD
ata
)
{
{
// Not yet useful in Pcbnew.
// Not yet useful in Pcbnew.
#if 0
#if 0
wxString name = wxString::FromUTF8(
d
ata.name.c_str() );
wxString name = wxString::FromUTF8(
aD
ata.name.c_str() );
wxLogMessage( name );
wxLogMessage( name );
#endif
#endif
}
}
...
@@ -120,25 +119,20 @@ void DXF2BRD_CONVERTER::addLayer( const DRW_Layer& data )
...
@@ -120,25 +119,20 @@ void DXF2BRD_CONVERTER::addLayer( const DRW_Layer& data )
/*
/*
* Import line entities.
* Import line entities.
*/
*/
void
DXF2BRD_CONVERTER
::
addLine
(
const
DRW_Line
&
d
ata
)
void
DXF2BRD_CONVERTER
::
addLine
(
const
DRW_Line
&
aD
ata
)
{
{
DRAWSEGMENT
*
segm
=
new
DRAWSEGMENT
(
m_brd
);
DRAWSEGMENT
*
segm
=
new
DRAWSEGMENT
(
m_brd
);
segm
->
SetLayer
(
ToLAYER_ID
(
m_brdLayer
)
);
segm
->
SetLayer
(
ToLAYER_ID
(
m_brdLayer
)
);
wxPoint
start
(
mapX
(
aData
.
basePoint
.
x
),
mapY
(
aData
.
basePoint
.
y
)
);
wxPoint
start
(
mapX
(
data
.
basePoint
.
x
),
mapY
(
data
.
basePoint
.
y
)
);
segm
->
SetStart
(
start
);
segm
->
SetStart
(
start
);
wxPoint
end
(
mapX
(
aData
.
secPoint
.
x
),
mapY
(
aData
.
secPoint
.
y
)
);
wxPoint
end
(
mapX
(
data
.
secPoint
.
x
),
mapY
(
data
.
secPoint
.
y
)
);
segm
->
SetEnd
(
end
);
segm
->
SetEnd
(
end
);
segm
->
SetWidth
(
mapDim
(
aData
.
thickness
==
0
?
m_defaultThickness
:
aData
.
thickness
)
);
segm
->
SetWidth
(
mapDim
(
data
.
thickness
==
0
?
m_defaultThickness
:
data
.
thickness
)
);
appendToBoard
(
segm
);
appendToBoard
(
segm
);
}
}
void
DXF2BRD_CONVERTER
::
addPolyline
(
const
DRW_Polyline
&
d
ata
)
void
DXF2BRD_CONVERTER
::
addPolyline
(
const
DRW_Polyline
&
aD
ata
)
{
{
// Currently, Pcbnew does not know polylines, for boards.
// Currently, Pcbnew does not know polylines, for boards.
// So we have to convert a polyline to a set of segments.
// So we have to convert a polyline to a set of segments.
...
@@ -146,9 +140,9 @@ void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& data )
...
@@ -146,9 +140,9 @@ void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& data )
wxPoint
startpoint
;
wxPoint
startpoint
;
for
(
unsigned
ii
=
0
;
ii
<
d
ata
.
vertlist
.
size
();
ii
++
)
for
(
unsigned
ii
=
0
;
ii
<
aD
ata
.
vertlist
.
size
();
ii
++
)
{
{
DRW_Vertex
*
vertex
=
d
ata
.
vertlist
[
ii
];
DRW_Vertex
*
vertex
=
aD
ata
.
vertlist
[
ii
];
if
(
ii
==
0
)
if
(
ii
==
0
)
{
{
...
@@ -163,14 +157,14 @@ void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& data )
...
@@ -163,14 +157,14 @@ void DXF2BRD_CONVERTER::addPolyline(const DRW_Polyline& data )
segm
->
SetStart
(
startpoint
);
segm
->
SetStart
(
startpoint
);
wxPoint
endpoint
(
mapX
(
vertex
->
basePoint
.
x
),
mapY
(
vertex
->
basePoint
.
y
)
);
wxPoint
endpoint
(
mapX
(
vertex
->
basePoint
.
x
),
mapY
(
vertex
->
basePoint
.
y
)
);
segm
->
SetEnd
(
endpoint
);
segm
->
SetEnd
(
endpoint
);
segm
->
SetWidth
(
mapDim
(
d
ata
.
thickness
==
0
?
m_defaultThickness
segm
->
SetWidth
(
mapDim
(
aD
ata
.
thickness
==
0
?
m_defaultThickness
:
d
ata
.
thickness
)
);
:
aD
ata
.
thickness
)
);
appendToBoard
(
segm
);
appendToBoard
(
segm
);
startpoint
=
endpoint
;
startpoint
=
endpoint
;
}
}
}
}
void
DXF2BRD_CONVERTER
::
addLWPolyline
(
const
DRW_LWPolyline
&
d
ata
)
void
DXF2BRD_CONVERTER
::
addLWPolyline
(
const
DRW_LWPolyline
&
aD
ata
)
{
{
// Currently, Pcbnew does not know polylines, for boards.
// Currently, Pcbnew does not know polylines, for boards.
// So we have to convert a polyline to a set of segments.
// So we have to convert a polyline to a set of segments.
...
@@ -179,9 +173,9 @@ void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& data )
...
@@ -179,9 +173,9 @@ void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& data )
// the variable width of each vertex (when exists) is not used.
// the variable width of each vertex (when exists) is not used.
wxPoint
startpoint
;
wxPoint
startpoint
;
for
(
unsigned
ii
=
0
;
ii
<
d
ata
.
vertlist
.
size
();
ii
++
)
for
(
unsigned
ii
=
0
;
ii
<
aD
ata
.
vertlist
.
size
();
ii
++
)
{
{
DRW_Vertex2D
*
vertex
=
d
ata
.
vertlist
[
ii
];
DRW_Vertex2D
*
vertex
=
aD
ata
.
vertlist
[
ii
];
if
(
ii
==
0
)
if
(
ii
==
0
)
{
{
...
@@ -196,8 +190,8 @@ void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& data )
...
@@ -196,8 +190,8 @@ void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& data )
segm
->
SetStart
(
startpoint
);
segm
->
SetStart
(
startpoint
);
wxPoint
endpoint
(
mapX
(
vertex
->
x
),
mapY
(
vertex
->
y
)
);
wxPoint
endpoint
(
mapX
(
vertex
->
x
),
mapY
(
vertex
->
y
)
);
segm
->
SetEnd
(
endpoint
);
segm
->
SetEnd
(
endpoint
);
segm
->
SetWidth
(
mapDim
(
d
ata
.
thickness
==
0
?
m_defaultThickness
segm
->
SetWidth
(
mapDim
(
aD
ata
.
thickness
==
0
?
m_defaultThickness
:
d
ata
.
thickness
)
);
:
aD
ata
.
thickness
)
);
appendToBoard
(
segm
);
appendToBoard
(
segm
);
startpoint
=
endpoint
;
startpoint
=
endpoint
;
}
}
...
@@ -206,19 +200,17 @@ void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& data )
...
@@ -206,19 +200,17 @@ void DXF2BRD_CONVERTER::addLWPolyline(const DRW_LWPolyline& data )
/*
/*
* Import Circle entities.
* Import Circle entities.
*/
*/
void
DXF2BRD_CONVERTER
::
addCircle
(
const
DRW_Circle
&
d
ata
)
void
DXF2BRD_CONVERTER
::
addCircle
(
const
DRW_Circle
&
aD
ata
)
{
{
DRAWSEGMENT
*
segm
=
new
DRAWSEGMENT
(
m_brd
);
DRAWSEGMENT
*
segm
=
new
DRAWSEGMENT
(
m_brd
);
segm
->
SetLayer
(
ToLAYER_ID
(
m_brdLayer
)
);
segm
->
SetLayer
(
ToLAYER_ID
(
m_brdLayer
)
);
segm
->
SetShape
(
S_CIRCLE
);
segm
->
SetShape
(
S_CIRCLE
);
wxPoint
center
(
mapX
(
data
.
basePoint
.
x
),
mapY
(
d
ata
.
basePoint
.
y
)
);
wxPoint
center
(
mapX
(
aData
.
basePoint
.
x
),
mapY
(
aD
ata
.
basePoint
.
y
)
);
segm
->
SetCenter
(
center
);
segm
->
SetCenter
(
center
);
wxPoint
circle_start
(
mapX
(
data
.
basePoint
.
x
+
data
.
radious
),
wxPoint
circle_start
(
mapX
(
aData
.
basePoint
.
x
+
aData
.
radious
),
mapY
(
aData
.
basePoint
.
y
)
);
mapY
(
data
.
basePoint
.
y
)
);
segm
->
SetArcStart
(
circle_start
);
segm
->
SetArcStart
(
circle_start
);
segm
->
SetWidth
(
mapDim
(
data
.
thickness
==
0
?
m_defaultThickness
segm
->
SetWidth
(
mapDim
(
aData
.
thickness
==
0
?
m_defaultThickness
:
aData
.
thickness
)
);
:
data
.
thickness
)
);
appendToBoard
(
segm
);
appendToBoard
(
segm
);
}
}
...
@@ -256,25 +248,24 @@ void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )
...
@@ -256,25 +248,24 @@ void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )
segm
->
SetAngle
(
angle
);
segm
->
SetAngle
(
angle
);
segm
->
SetWidth
(
mapDim
(
data
.
thickness
==
0
?
m_defaultThickness
segm
->
SetWidth
(
mapDim
(
data
.
thickness
==
0
?
m_defaultThickness
:
data
.
thickness
)
);
:
data
.
thickness
)
);
appendToBoard
(
segm
);
appendToBoard
(
segm
);
}
}
/**
/**
* Import texts (TEXT).
* Import texts (TEXT).
*/
*/
void
DXF2BRD_CONVERTER
::
addText
(
const
DRW_Text
&
data
)
void
DXF2BRD_CONVERTER
::
addText
(
const
DRW_Text
&
aData
)
{
{
TEXTE_PCB
*
pcb_text
=
new
TEXTE_PCB
(
m_brd
);
TEXTE_PCB
*
pcb_text
=
new
TEXTE_PCB
(
m_brd
);
pcb_text
->
SetLayer
(
ToLAYER_ID
(
m_brdLayer
)
);
pcb_text
->
SetLayer
(
ToLAYER_ID
(
m_brdLayer
)
);
wxPoint
refPoint
(
mapX
(
data
.
basePoint
.
x
),
mapY
(
data
.
basePoint
.
y
)
);
wxPoint
refPoint
(
mapX
(
aData
.
basePoint
.
x
),
mapY
(
aData
.
basePoint
.
y
)
);
wxPoint
secPoint
(
mapX
(
data
.
secPoint
.
x
),
mapY
(
data
.
secPoint
.
y
)
);
wxPoint
secPoint
(
mapX
(
aData
.
secPoint
.
x
),
mapY
(
aData
.
secPoint
.
y
)
);
if
(
data
.
alignV
!=
0
||
data
.
alignH
!=
0
||
data
.
alignH
==
DRW_Text
::
HMiddle
)
if
(
aData
.
alignV
!=
0
||
aData
.
alignH
!=
0
||
aData
.
alignH
==
DRW_Text
::
HMiddle
)
{
{
if
(
data
.
alignH
!=
DRW_Text
::
HAligned
&&
data
.
alignH
!=
DRW_Text
::
HFit
)
if
(
aData
.
alignH
!=
DRW_Text
::
HAligned
&&
aData
.
alignH
!=
DRW_Text
::
HFit
)
{
{
wxPoint
tmp
=
secPoint
;
wxPoint
tmp
=
secPoint
;
secPoint
=
refPoint
;
secPoint
=
refPoint
;
...
@@ -282,7 +273,7 @@ void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
...
@@ -282,7 +273,7 @@ void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
}
}
}
}
switch
(
d
ata
.
alignV
)
switch
(
aD
ata
.
alignV
)
{
{
case
DRW_Text
:
:
VBaseLine
:
case
DRW_Text
:
:
VBaseLine
:
pcb_text
->
SetVertJustify
(
GR_TEXT_VJUSTIFY_BOTTOM
);
pcb_text
->
SetVertJustify
(
GR_TEXT_VJUSTIFY_BOTTOM
);
...
@@ -301,7 +292,7 @@ void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
...
@@ -301,7 +292,7 @@ void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
break
;
break
;
}
}
switch
(
d
ata
.
alignH
)
switch
(
aD
ata
.
alignH
)
{
{
case
DRW_Text
:
:
HLeft
:
case
DRW_Text
:
:
HLeft
:
pcb_text
->
SetHorizJustify
(
GR_TEXT_HJUSTIFY_LEFT
);
pcb_text
->
SetHorizJustify
(
GR_TEXT_HJUSTIFY_LEFT
);
...
@@ -332,13 +323,13 @@ void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
...
@@ -332,13 +323,13 @@ void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
}
}
#if 0
#if 0
wxString sty = wxString::FromUTF8(
d
ata.style.c_str());
wxString sty = wxString::FromUTF8(
aD
ata.style.c_str());
sty=sty.ToLower();
sty=sty.ToLower();
if (
d
ata.textgen==2)
if (
aD
ata.textgen==2)
{
{
// Text dir = left to right;
// Text dir = left to right;
} else if (
d
ata.textgen==4)
} else if (
aD
ata.textgen==4)
{
{
/ Text dir = top to bottom;
/ Text dir = top to bottom;
} else
} else
...
@@ -346,15 +337,14 @@ void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
...
@@ -346,15 +337,14 @@ void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
}
}
#endif
#endif
wxString
text
=
toNativeString
(
wxString
::
FromUTF8
(
d
ata
.
text
.
c_str
()
)
);
wxString
text
=
toNativeString
(
wxString
::
FromUTF8
(
aD
ata
.
text
.
c_str
()
)
);
pcb_text
->
SetTextPosition
(
refPoint
);
pcb_text
->
SetTextPosition
(
refPoint
);
pcb_text
->
SetOrientation
(
d
ata
.
angle
*
10
);
pcb_text
->
SetOrientation
(
aD
ata
.
angle
*
10
);
// The 0.8 factor gives a better height/width ratio with our font
// The 0.8 factor gives a better height/width ratio with our font
pcb_text
->
SetWidth
(
mapDim
(
data
.
height
*
0.8
)
);
pcb_text
->
SetWidth
(
mapDim
(
aData
.
height
*
0.8
)
);
pcb_text
->
SetHeight
(
mapDim
(
data
.
height
)
);
pcb_text
->
SetHeight
(
mapDim
(
aData
.
height
)
);
pcb_text
->
SetThickness
(
mapDim
(
data
.
thickness
==
0
?
m_defaultThickness
pcb_text
->
SetThickness
(
mapDim
(
aData
.
thickness
==
0
?
m_defaultThickness
:
aData
.
thickness
)
);
:
data
.
thickness
)
);
pcb_text
->
SetText
(
text
);
pcb_text
->
SetText
(
text
);
appendToBoard
(
pcb_text
);
appendToBoard
(
pcb_text
);
...
@@ -364,9 +354,9 @@ void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
...
@@ -364,9 +354,9 @@ void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
/**
/**
* Import multi line texts (MTEXT).
* Import multi line texts (MTEXT).
*/
*/
void
DXF2BRD_CONVERTER
::
addMText
(
const
DRW_MText
&
d
ata
)
void
DXF2BRD_CONVERTER
::
addMText
(
const
DRW_MText
&
aD
ata
)
{
{
wxString
text
=
toNativeString
(
wxString
::
FromUTF8
(
d
ata
.
text
.
c_str
()
)
);
wxString
text
=
toNativeString
(
wxString
::
FromUTF8
(
aD
ata
.
text
.
c_str
()
)
);
wxString
attrib
,
tmp
;
wxString
attrib
,
tmp
;
/* Some texts start by '\' and have formating chars (font name, font option...)
/* Some texts start by '\' and have formating chars (font name, font option...)
...
@@ -396,23 +386,21 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& data )
...
@@ -396,23 +386,21 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& data )
TEXTE_PCB
*
pcb_text
=
new
TEXTE_PCB
(
m_brd
);
TEXTE_PCB
*
pcb_text
=
new
TEXTE_PCB
(
m_brd
);
pcb_text
->
SetLayer
(
ToLAYER_ID
(
m_brdLayer
)
);
pcb_text
->
SetLayer
(
ToLAYER_ID
(
m_brdLayer
)
);
wxPoint
textpos
(
mapX
(
aData
.
basePoint
.
x
),
mapY
(
aData
.
basePoint
.
y
)
);
wxPoint
textpos
(
mapX
(
data
.
basePoint
.
x
),
mapY
(
data
.
basePoint
.
y
)
);
pcb_text
->
SetTextPosition
(
textpos
);
pcb_text
->
SetTextPosition
(
textpos
);
pcb_text
->
SetOrientation
(
d
ata
.
angle
*
10
);
pcb_text
->
SetOrientation
(
aD
ata
.
angle
*
10
);
// The 0.8 factor gives a better height/width ratio with our font
// The 0.8 factor gives a better height/width ratio with our font
pcb_text
->
SetWidth
(
mapDim
(
data
.
height
*
0.8
)
);
pcb_text
->
SetWidth
(
mapDim
(
aData
.
height
*
0.8
)
);
pcb_text
->
SetHeight
(
mapDim
(
data
.
height
)
);
pcb_text
->
SetHeight
(
mapDim
(
aData
.
height
)
);
pcb_text
->
SetThickness
(
mapDim
(
data
.
thickness
==
0
?
m_defaultThickness
pcb_text
->
SetThickness
(
mapDim
(
aData
.
thickness
==
0
?
m_defaultThickness
:
aData
.
thickness
)
);
:
data
.
thickness
)
);
pcb_text
->
SetText
(
text
);
pcb_text
->
SetText
(
text
);
// Initialize text justifications:
// Initialize text justifications:
if
(
d
ata
.
textgen
<=
3
)
if
(
aD
ata
.
textgen
<=
3
)
{
{
pcb_text
->
SetVertJustify
(
GR_TEXT_VJUSTIFY_TOP
);
pcb_text
->
SetVertJustify
(
GR_TEXT_VJUSTIFY_TOP
);
}
}
else
if
(
d
ata
.
textgen
<=
6
)
else
if
(
aD
ata
.
textgen
<=
6
)
{
{
pcb_text
->
SetVertJustify
(
GR_TEXT_VJUSTIFY_CENTER
);
pcb_text
->
SetVertJustify
(
GR_TEXT_VJUSTIFY_CENTER
);
}
}
...
@@ -421,11 +409,11 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& data )
...
@@ -421,11 +409,11 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& data )
pcb_text
->
SetVertJustify
(
GR_TEXT_VJUSTIFY_BOTTOM
);
pcb_text
->
SetVertJustify
(
GR_TEXT_VJUSTIFY_BOTTOM
);
}
}
if
(
d
ata
.
textgen
%
3
==
1
)
if
(
aD
ata
.
textgen
%
3
==
1
)
{
{
pcb_text
->
SetHorizJustify
(
GR_TEXT_HJUSTIFY_LEFT
);
pcb_text
->
SetHorizJustify
(
GR_TEXT_HJUSTIFY_LEFT
);
}
}
else
if
(
d
ata
.
textgen
%
3
==
2
)
else
if
(
aD
ata
.
textgen
%
3
==
2
)
{
{
pcb_text
->
SetHorizJustify
(
GR_TEXT_HJUSTIFY_CENTER
);
pcb_text
->
SetHorizJustify
(
GR_TEXT_HJUSTIFY_CENTER
);
}
}
...
@@ -448,7 +436,7 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& data )
...
@@ -448,7 +436,7 @@ void DXF2BRD_CONVERTER::addMText( const DRW_MText& data )
// use ByStyle;
// use ByStyle;
}
}
if(
d
ata.alignV==1 )
if(
aD
ata.alignV==1 )
{
{
// use AtLeast;
// use AtLeast;
}
}
...
@@ -490,24 +478,24 @@ void DXF2BRD_CONVERTER::addHeader( const DRW_Header* data )
...
@@ -490,24 +478,24 @@ void DXF2BRD_CONVERTER::addHeader( const DRW_Header* data )
* - %%%d for a degree sign
* - %%%d for a degree sign
* - %%%p for a plus/minus sign
* - %%%p for a plus/minus sign
*/
*/
wxString
DXF2BRD_CONVERTER
::
toDxfString
(
const
wxString
&
s
tr
)
wxString
DXF2BRD_CONVERTER
::
toDxfString
(
const
wxString
&
aS
tr
)
{
{
wxString
res
;
wxString
res
;
int
j
=
0
;
int
j
=
0
;
for
(
unsigned
i
=
0
;
i
<
s
tr
.
length
();
++
i
)
for
(
unsigned
i
=
0
;
i
<
aS
tr
.
length
();
++
i
)
{
{
int
c
=
s
tr
[
i
];
int
c
=
aS
tr
[
i
];
if
(
c
>
175
||
c
<
11
)
if
(
c
>
175
||
c
<
11
)
{
{
res
.
append
(
s
tr
.
Mid
(
j
,
i
-
j
)
);
res
.
append
(
aS
tr
.
Mid
(
j
,
i
-
j
)
);
j
=
i
;
j
=
i
;
switch
(
c
)
switch
(
c
)
{
{
case
0x0A
:
case
0x0A
:
res
+=
wxT
(
"
\\
P"
);
res
+=
wxT
(
"
\\
P"
);
break
;
break
;
// diameter:
// diameter:
...
@@ -517,17 +505,17 @@ wxString DXF2BRD_CONVERTER::toDxfString( const wxString& str )
...
@@ -517,17 +505,17 @@ wxString DXF2BRD_CONVERTER::toDxfString( const wxString& str )
#else
#else
case
0x2205
:
case
0x2205
:
#endif
#endif
res
+=
wxT
(
"%%C"
);
res
+=
wxT
(
"%%C"
);
break
;
break
;
// degree:
// degree:
case
0x00B0
:
case
0x00B0
:
res
+=
wxT
(
"%%D"
);
res
+=
wxT
(
"%%D"
);
break
;
break
;
// plus/minus
// plus/minus
case
0x00B1
:
case
0x00B1
:
res
+=
wxT
(
"%%P"
);
res
+=
wxT
(
"%%P"
);
break
;
break
;
default
:
default
:
...
@@ -539,7 +527,7 @@ wxString DXF2BRD_CONVERTER::toDxfString( const wxString& str )
...
@@ -539,7 +527,7 @@ wxString DXF2BRD_CONVERTER::toDxfString( const wxString& str )
}
}
}
}
res
.
append
(
s
tr
.
Mid
(
j
)
);
res
.
append
(
aS
tr
.
Mid
(
j
)
);
return
res
;
return
res
;
}
}
...
@@ -547,26 +535,26 @@ wxString DXF2BRD_CONVERTER::toDxfString( const wxString& str )
...
@@ -547,26 +535,26 @@ wxString DXF2BRD_CONVERTER::toDxfString( const wxString& str )
/**
/**
* Converts a DXF encoded string into a native Unicode string.
* Converts a DXF encoded string into a native Unicode string.
*/
*/
wxString
DXF2BRD_CONVERTER
::
toNativeString
(
const
wxString
&
d
ata
)
wxString
DXF2BRD_CONVERTER
::
toNativeString
(
const
wxString
&
aD
ata
)
{
{
wxString
res
;
wxString
res
;
// Ignore font tags:
// Ignore font tags:
int
j
=
0
;
int
j
=
0
;
for
(
unsigned
i
=
0
;
i
<
d
ata
.
length
();
++
i
)
for
(
unsigned
i
=
0
;
i
<
aD
ata
.
length
();
++
i
)
{
{
if
(
d
ata
[
i
]
==
0x7B
)
// is '{' ?
if
(
aD
ata
[
i
]
==
0x7B
)
// is '{' ?
{
{
if
(
data
[
i
+
1
]
==
0x5c
&&
d
ata
[
i
+
2
]
==
0x66
)
// is "\f" ?
if
(
aData
[
i
+
1
]
==
0x5c
&&
aD
ata
[
i
+
2
]
==
0x66
)
// is "\f" ?
{
{
// found font tag, append parsed part
// found font tag, append parsed part
res
.
append
(
d
ata
.
Mid
(
j
,
i
-
j
)
);
res
.
append
(
aD
ata
.
Mid
(
j
,
i
-
j
)
);
// skip to ';'
// skip to ';'
for
(
unsigned
k
=
i
+
3
;
k
<
d
ata
.
length
();
++
k
)
for
(
unsigned
k
=
i
+
3
;
k
<
aD
ata
.
length
();
++
k
)
{
{
if
(
d
ata
[
k
]
==
0x3B
)
if
(
aD
ata
[
k
]
==
0x3B
)
{
{
i
=
j
=
++
k
;
i
=
j
=
++
k
;
break
;
break
;
...
@@ -574,11 +562,11 @@ wxString DXF2BRD_CONVERTER::toNativeString( const wxString& data )
...
@@ -574,11 +562,11 @@ wxString DXF2BRD_CONVERTER::toNativeString( const wxString& data )
}
}
// add to '}'
// add to '}'
for
(
unsigned
k
=
i
;
k
<
d
ata
.
length
();
++
k
)
for
(
unsigned
k
=
i
;
k
<
aD
ata
.
length
();
++
k
)
{
{
if
(
d
ata
[
k
]
==
0x7D
)
if
(
aD
ata
[
k
]
==
0x7D
)
{
{
res
.
append
(
d
ata
.
Mid
(
i
,
k
-
i
)
);
res
.
append
(
aD
ata
.
Mid
(
i
,
k
-
i
)
);
i
=
j
=
++
k
;
i
=
j
=
++
k
;
break
;
break
;
}
}
...
@@ -587,7 +575,7 @@ wxString DXF2BRD_CONVERTER::toNativeString( const wxString& data )
...
@@ -587,7 +575,7 @@ wxString DXF2BRD_CONVERTER::toNativeString( const wxString& data )
}
}
}
}
res
.
append
(
d
ata
.
Mid
(
j
)
);
res
.
append
(
aD
ata
.
Mid
(
j
)
);
#if 1
#if 1
wxRegEx
regexp
;
wxRegEx
regexp
;
...
@@ -621,7 +609,7 @@ wxString DXF2BRD_CONVERTER::toNativeString( const wxString& data )
...
@@ -621,7 +609,7 @@ wxString DXF2BRD_CONVERTER::toNativeString( const wxString& data )
}
}
void
DXF2BRD_CONVERTER
::
addTextStyle
(
const
DRW_Textstyle
&
d
ata
)
void
DXF2BRD_CONVERTER
::
addTextStyle
(
const
DRW_Textstyle
&
aD
ata
)
{
{
// TODO
// TODO
}
}
pcbnew/import_dxf/dxf2brd_items.h
View file @
4ac27702
...
@@ -41,9 +41,8 @@ class BOARD_ITEM;
...
@@ -41,9 +41,8 @@ class BOARD_ITEM;
class
DXF2BRD_CONVERTER
:
public
DRW_Interface
class
DXF2BRD_CONVERTER
:
public
DRW_Interface
{
{
private
:
private
:
std
::
vector
<
BOARD_ITEM
*>
m_newItemsList
;
// The list of new items added
std
::
vector
<
BOARD_ITEM
*>
m_newItemsList
;
// The list of new items added to the board
// to the board
BOARD
*
m_brd
;
BOARD
*
m_brd
;
double
m_xOffset
;
// X coord offset for conversion (in mm)
double
m_xOffset
;
// X coord offset for conversion (in mm)
double
m_yOffset
;
// Y coord offset for conversion (in mm)
double
m_yOffset
;
// Y coord offset for conversion (in mm)
double
m_defaultThickness
;
// default line thickness for conversion (in mm)
double
m_defaultThickness
;
// default line thickness for conversion (in mm)
...
@@ -85,7 +84,7 @@ public:
...
@@ -85,7 +84,7 @@ public:
* @param aFile = the full filename.
* @param aFile = the full filename.
* @param aBoard = where to store the graphical items and text
* @param aBoard = where to store the graphical items and text
*/
*/
bool
ImportDxfFile
(
const
wxString
&
aFile
,
BOARD
*
aBoard
);
bool
ImportDxfFile
(
const
wxString
&
aFile
,
BOARD
*
aBoard
);
/**
/**
* @return the list of new BOARD_ITEM
* @return the list of new BOARD_ITEM
...
@@ -104,65 +103,65 @@ private:
...
@@ -104,65 +103,65 @@ private:
// Add aItem the the board
// Add aItem the the board
// this item is also added to the list of new items
// this item is also added to the list of new items
// (for undo command for instance)
// (for undo command for instance)
void
appendToBoard
(
BOARD_ITEM
*
aItem
);
void
appendToBoard
(
BOARD_ITEM
*
aItem
);
// Methods from DRW_CreationInterface:
// Methods from DRW_CreationInterface:
// They are "call back" fonctions, called when the corresponding object
// They are "call back" fonctions, called when the corresponding object
// is read in dxf file
// is read in dxf file
// Depending of the application, they can do something or not
// Depending of the application, they can do something or not
virtual
void
addHeader
(
const
DRW_Header
*
d
ata
);
virtual
void
addHeader
(
const
DRW_Header
*
aD
ata
);
virtual
void
addLType
(
const
DRW_LType
&
data
)
{}
virtual
void
addLType
(
const
DRW_LType
&
aData
)
{}
virtual
void
addLayer
(
const
DRW_Layer
&
d
ata
);
virtual
void
addLayer
(
const
DRW_Layer
&
aD
ata
);
virtual
void
addDimStyle
(
const
DRW_Dimstyle
&
data
)
{}
virtual
void
addDimStyle
(
const
DRW_Dimstyle
&
aData
)
{}
virtual
void
addBlock
(
const
DRW_Block
&
data
)
{}
virtual
void
addBlock
(
const
DRW_Block
&
aData
)
{}
virtual
void
endBlock
(){}
virtual
void
endBlock
()
{}
virtual
void
addPoint
(
const
DRW_Point
&
data
)
{}
virtual
void
addPoint
(
const
DRW_Point
&
aData
)
{}
virtual
void
addLine
(
const
DRW_Line
&
d
ata
);
virtual
void
addLine
(
const
DRW_Line
&
aD
ata
);
virtual
void
addRay
(
const
DRW_Ray
&
data
)
{}
virtual
void
addRay
(
const
DRW_Ray
&
aData
)
{}
virtual
void
addXline
(
const
DRW_Xline
&
data
)
{}
virtual
void
addXline
(
const
DRW_Xline
&
aData
)
{}
virtual
void
addCircle
(
const
DRW_Circle
&
d
ata
);
virtual
void
addCircle
(
const
DRW_Circle
&
aD
ata
);
virtual
void
addArc
(
const
DRW_Arc
&
d
ata
);
virtual
void
addArc
(
const
DRW_Arc
&
aD
ata
);
virtual
void
addEllipse
(
const
DRW_Ellipse
&
data
)
{}
virtual
void
addEllipse
(
const
DRW_Ellipse
&
aData
)
{}
virtual
void
addLWPolyline
(
const
DRW_LWPolyline
&
d
ata
);
virtual
void
addLWPolyline
(
const
DRW_LWPolyline
&
aD
ata
);
virtual
void
addText
(
const
DRW_Text
&
d
ata
);
virtual
void
addText
(
const
DRW_Text
&
aD
ata
);
virtual
void
addPolyline
(
const
DRW_Polyline
&
d
ata
);
virtual
void
addPolyline
(
const
DRW_Polyline
&
aD
ata
);
virtual
void
addSpline
(
const
DRW_Spline
*
data
)
{}
virtual
void
addSpline
(
const
DRW_Spline
*
aData
)
{}
virtual
void
addKnot
(
const
DRW_Entity
&
)
{}
virtual
void
addKnot
(
const
DRW_Entity
&
)
{}
virtual
void
addInsert
(
const
DRW_Insert
&
d
ata
){}
virtual
void
addInsert
(
const
DRW_Insert
&
aD
ata
){}
virtual
void
addTrace
(
const
DRW_Trace
&
d
ata
){}
virtual
void
addTrace
(
const
DRW_Trace
&
aD
ata
){}
virtual
void
addSolid
(
const
DRW_Solid
&
d
ata
){}
virtual
void
addSolid
(
const
DRW_Solid
&
aD
ata
){}
virtual
void
addMText
(
const
DRW_MText
&
d
ata
);
virtual
void
addMText
(
const
DRW_MText
&
aD
ata
);
virtual
void
addDimAlign
(
const
DRW_DimAligned
*
data
)
{}
virtual
void
addDimAlign
(
const
DRW_DimAligned
*
aData
)
{}
virtual
void
addDimLinear
(
const
DRW_DimLinear
*
data
)
{}
virtual
void
addDimLinear
(
const
DRW_DimLinear
*
aData
)
{}
virtual
void
addDimRadial
(
const
DRW_DimRadial
*
data
)
{}
virtual
void
addDimRadial
(
const
DRW_DimRadial
*
aData
)
{}
virtual
void
addDimDiametric
(
const
DRW_DimDiametric
*
data
)
{}
virtual
void
addDimDiametric
(
const
DRW_DimDiametric
*
aData
)
{}
virtual
void
addDimAngular
(
const
DRW_DimAngular
*
data
)
{}
virtual
void
addDimAngular
(
const
DRW_DimAngular
*
aData
)
{}
virtual
void
addDimAngular3P
(
const
DRW_DimAngular3p
*
data
)
{}
virtual
void
addDimAngular3P
(
const
DRW_DimAngular3p
*
aData
)
{}
virtual
void
addDimOrdinate
(
const
DRW_DimOrdinate
*
data
)
{}
virtual
void
addDimOrdinate
(
const
DRW_DimOrdinate
*
aData
)
{}
virtual
void
addLeader
(
const
DRW_Leader
*
data
)
{}
virtual
void
addLeader
(
const
DRW_Leader
*
aData
)
{}
virtual
void
addHatch
(
const
DRW_Hatch
*
data
)
{}
virtual
void
addHatch
(
const
DRW_Hatch
*
aData
)
{}
virtual
void
addImage
(
const
DRW_Image
*
data
)
{}
virtual
void
addImage
(
const
DRW_Image
*
aData
)
{}
virtual
void
linkImage
(
const
DRW_ImageDef
*
data
)
{}
virtual
void
linkImage
(
const
DRW_ImageDef
*
aData
)
{}
virtual
void
add3dFace
(
const
DRW_3Dface
&
data
)
{}
virtual
void
add3dFace
(
const
DRW_3Dface
&
aData
)
{}
virtual
void
addComment
(
const
char
*
)
{}
virtual
void
addComment
(
const
char
*
)
{}
virtual
void
addVport
(
const
DRW_Vport
&
data
)
{}
virtual
void
addVport
(
const
DRW_Vport
&
aData
)
{}
virtual
void
addTextStyle
(
const
DRW_Textstyle
&
data
);
virtual
void
addTextStyle
(
const
DRW_Textstyle
&
aData
);
virtual
void
addViewport
(
const
DRW_Viewport
&
data
)
{}
virtual
void
addViewport
(
const
DRW_Viewport
&
aData
)
{}
virtual
void
setBlock
(
const
int
handle
)
{}
virtual
void
setBlock
(
const
int
aHandle
)
{}
static
wxString
toDxfString
(
const
wxString
&
str
);
static
wxString
toDxfString
(
const
wxString
&
aStr
);
static
wxString
toNativeString
(
const
wxString
&
data
);
static
wxString
toNativeString
(
const
wxString
&
aData
);
// These functions are not used in Kicad.
// These functions are not used in Kicad.
// But because they are virtual pure in DRW_Interface, they should be defined
// But because they are virtual pure in DRW_Interface, they should be defined
virtual
void
writeTextstyles
()
{}
virtual
void
writeTextstyles
()
{}
virtual
void
writeVports
()
{}
virtual
void
writeVports
()
{}
virtual
void
writeHeader
(
DRW_Header
&
data
)
{}
virtual
void
writeHeader
(
DRW_Header
&
aData
)
{}
virtual
void
writeEntities
()
{}
virtual
void
writeEntities
()
{}
virtual
void
writeLTypes
()
{}
virtual
void
writeLTypes
()
{}
virtual
void
writeLayers
()
{}
virtual
void
writeLayers
()
{}
...
@@ -172,7 +171,6 @@ private:
...
@@ -172,7 +171,6 @@ private:
void
writeLine
();
void
writeLine
();
void
writeMtext
();
void
writeMtext
();
};
};
#endif // FILTERDXFRW_H
#endif // FILTERDXFRW_H
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