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
5748b791
Commit
5748b791
authored
Aug 06, 2007
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added some conditional DEBUG code for showing the pcb object tree in simple XML format
parent
02a2268f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
2636 additions
and
2326 deletions
+2636
-2326
base_struct.cpp
common/base_struct.cpp
+45
-4
base_struct.h
include/base_struct.h
+27
-0
pcbstruct.h
include/pcbstruct.h
+16
-3
class_board.cpp
pcbnew/class_board.cpp
+33
-0
class_module.cpp
pcbnew/class_module.cpp
+1053
-951
class_module.h
pcbnew/class_module.h
+84
-71
files.cpp
pcbnew/files.cpp
+315
-303
ioascii.cpp
pcbnew/ioascii.cpp
+1063
-994
No files found.
common/base_struct.cpp
View file @
5748b791
...
...
@@ -18,8 +18,7 @@
// DrawStructureType names for error messages only:
static
wxString
DrawStructureTypeName
[
MAX_STRUCT_TYPE_ID
+
1
]
=
{
static
wxString
DrawStructureTypeName
[
MAX_STRUCT_TYPE_ID
+
1
]
=
{
wxT
(
"Not init"
),
wxT
(
"Pcb"
),
...
...
@@ -168,10 +167,9 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
*/
{
}
#endif
/*********************************************/
wxString
EDA_BaseStruct
::
ReturnClassName
(
void
)
/*********************************************/
...
...
@@ -191,6 +189,48 @@ wxString EDA_BaseStruct::ReturnClassName( void )
}
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void
EDA_BaseStruct
::
Show
(
int
nestLevel
,
std
::
ostream
&
os
)
{
// for now, make it look like XML:
NestedSpace
(
nestLevel
,
os
)
<<
'<'
<<
ReturnClassName
().
mb_str
()
<<
">
\n
"
;
EDA_BaseStruct
*
kid
=
m_Son
;
for
(
;
kid
;
kid
=
kid
->
Pnext
)
{
kid
->
Show
(
nestLevel
+
1
,
os
);
}
NestedSpace
(
nestLevel
,
os
)
<<
"</"
<<
ReturnClassName
().
mb_str
()
<<
">
\n
"
;
}
/**
* Function NestedSpace
* outputs nested space for pretty indenting.
* @param nestLevel The nest count
* @param os The ostream&, where to output
* @return std::ostream& - for continuation.
**/
std
::
ostream
&
EDA_BaseStruct
::
NestedSpace
(
int
nestLevel
,
std
::
ostream
&
os
)
{
for
(
int
i
=
0
;
i
<
nestLevel
;
++
i
)
os
<<
' '
;
// number of spaces here controls indent per nest level
return
os
;
}
#endif
/**********************************************************************************************/
EDA_BaseLineStruct
::
EDA_BaseLineStruct
(
EDA_BaseStruct
*
StructFather
,
DrawStructureType
idtype
)
:
EDA_BaseStruct
(
StructFather
,
idtype
)
...
...
@@ -721,3 +761,4 @@ void DrawPickedStruct::DeleteWrapperList( void )
delete
wrapp_struct
;
}
}
include/base_struct.h
View file @
5748b791
...
...
@@ -6,6 +6,11 @@
#define BASE_STRUCT_H
#if defined(DEBUG)
#include <iostream> // needed for Show()
#endif
/* Id for class identification, at run time */
enum
DrawStructureType
{
TYPE_NOT_INIT
=
0
,
...
...
@@ -123,8 +128,30 @@ public:
const
wxPoint
&
offset
,
int
draw_mode
,
int
Color
=
-
1
);
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
virtual
void
Show
(
int
nestLevel
,
std
::
ostream
&
os
);
/**
* Function NestedSpace
* outputs nested space for pretty indenting.
* @param nestLevel The nest count
* @param os The ostream&, where to output
* @return std::ostream& - for continuation.
**/
static
std
::
ostream
&
NestedSpace
(
int
nestLevel
,
std
::
ostream
&
os
);
#endif
};
// Text justify:
// Values -1,0,1 are used in computations, do not change them
typedef
enum
{
...
...
include/pcbstruct.h
View file @
5748b791
...
...
@@ -176,15 +176,16 @@ public:
EDA_BoardDesignSettings
(
void
);
};
// Values for m_DisplayViaMode member:
enum
DisplayViaMode
{
VIA_HOLE_NOT_SHOW
=
0
,
VIA_SPECIAL_HOLE_SHOW
,
ALL_VIA_HOLE_SHOW
,
OPT_VIA_HOLE_END
};
class
BOARD
:
public
EDA_BaseStruct
{
public
:
...
...
@@ -212,7 +213,7 @@ public:
CHEVELU
*
m_Ratsnest
;
// pointeur liste des chevelus
CHEVELU
*
m_LocalRatsnest
;
// pointeur liste des chevelus d'un module
EDGE_ZONE
*
m_CurrentLimitZone
;
/* pointeur sur la liste des segments
EDGE_ZONE
*
m_CurrentLimitZone
;
/* pointeur sur la liste des segments
* de delimitation de la zone en cours de trace */
BOARD
(
EDA_BaseStruct
*
StructFather
,
WinEDA_BasePcbFrame
*
frame
);
...
...
@@ -230,6 +231,18 @@ public:
// Calcul du rectangle d'encadrement:
bool
ComputeBoundaryBox
(
void
);
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
virtual
void
Show
(
int
nestLevel
,
std
::
ostream
&
os
);
#endif
};
...
...
pcbnew/class_board.cpp
View file @
5748b791
...
...
@@ -254,3 +254,36 @@ bool BOARD::ComputeBoundaryBox( void )
return
Has_Items
;
}
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void
BOARD
::
Show
(
int
nestLevel
,
std
::
ostream
&
os
)
{
// for now, make it look like XML:
NestedSpace
(
nestLevel
,
os
)
<<
'<'
<<
ReturnClassName
().
mb_str
()
<<
">
\n
"
;
// specialization of the output:
EDA_BaseStruct
*
p
=
m_Modules
;
for
(
;
p
;
p
=
p
->
Pnext
)
p
->
Show
(
nestLevel
+
1
,
os
);
p
=
m_Drawings
;
for
(
;
p
;
p
=
p
->
Pnext
)
p
->
Show
(
nestLevel
+
1
,
os
);
EDA_BaseStruct
*
kid
=
m_Son
;
for
(
;
kid
;
kid
=
kid
->
Pnext
)
{
kid
->
Show
(
nestLevel
+
1
,
os
);
}
NestedSpace
(
nestLevel
,
os
)
<<
"</"
<<
ReturnClassName
().
mb_str
()
<<
">
\n
"
;
}
#endif
pcbnew/class_module.cpp
View file @
5748b791
/****************************************************/
/* class_module.cpp : fonctions de la classe MODULE */
/****************************************************/
/****************************************************/
/* class_module.cpp : fonctions de la classe MODULE */
/****************************************************/
#include "fctsys.h"
#include "gr_basic.h"
...
...
@@ -26,38 +26,39 @@
#define MAX_WIDTH 10000 // Epaisseur (en 1/10000 ") max raisonnable des traits, textes...
/*********************************************************************************/
void
MODULE
::
DrawAncre
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
dim_ancre
,
int
draw_mode
)
void
MODULE
::
DrawAncre
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
dim_ancre
,
int
draw_mode
)
/*********************************************************************************/
/* trace de l'ancre (croix verticale)
(doit etre fait apres les pads,
car le trace du trou efface tout donc peut etre l'ancre */
*
(doit etre fait apres les pads,
*
car le trace du trou efface tout donc peut etre l'ancre */
{
int
zoom
=
panel
->
GetZoom
();
int
anchor_size
=
dim_ancre
*
zoom
;
int
zoom
=
panel
->
GetZoom
();
int
anchor_size
=
dim_ancre
*
zoom
;
GRSetDrawMode
(
DC
,
draw_mode
);
GRSetDrawMode
(
DC
,
draw_mode
);
if
(
(
g_AnchorColor
&
ITEM_NOT_SHOW
)
==
0
)
if
(
(
g_AnchorColor
&
ITEM_NOT_SHOW
)
==
0
)
{
GRLine
(
&
panel
->
m_ClipBox
,
DC
,
GRLine
(
&
panel
->
m_ClipBox
,
DC
,
m_Pos
.
x
-
offset
.
x
-
anchor_size
,
m_Pos
.
y
-
offset
.
y
,
m_Pos
.
x
-
offset
.
x
+
anchor_size
,
m_Pos
.
y
-
offset
.
y
,
0
,
g_AnchorColor
);
GRLine
(
&
panel
->
m_ClipBox
,
DC
,
m_Pos
.
x
-
offset
.
x
,
m_Pos
.
y
-
offset
.
y
-
anchor_size
,
m_Pos
.
x
-
offset
.
x
,
m_Pos
.
y
-
offset
.
y
+
anchor_size
,
0
,
g_AnchorColor
);
m_Pos
.
x
-
offset
.
x
+
anchor_size
,
m_Pos
.
y
-
offset
.
y
,
0
,
g_AnchorColor
);
GRLine
(
&
panel
->
m_ClipBox
,
DC
,
m_Pos
.
x
-
offset
.
x
,
m_Pos
.
y
-
offset
.
y
-
anchor_size
,
m_Pos
.
x
-
offset
.
x
,
m_Pos
.
y
-
offset
.
y
+
anchor_size
,
0
,
g_AnchorColor
);
}
}
/*************************************************/
/* Class MODULE : description d'un composant pcb */
/*************************************************/
/*************************************************/
/* Class MODULE : description d'un composant pcb */
/*************************************************/
/* Constructeur de la classe MODULE */
MODULE
::
MODULE
(
BOARD
*
parent
)
:
EDA_BaseStruct
(
parent
,
TYPEMODULE
)
MODULE
::
MODULE
(
BOARD
*
parent
)
:
EDA_BaseStruct
(
parent
,
TYPEMODULE
)
{
m_Pads
=
NULL
;
m_Drawings
=
NULL
;
...
...
@@ -70,62 +71,65 @@ MODULE::MODULE(BOARD * parent): EDA_BaseStruct( parent, TYPEMODULE)
m_CntRot90
=
m_CntRot180
=
0
;
m_Surface
=
0
;
m_Link
=
0
;
m_LastEdit_Time
=
time
(
NULL
);
m_Reference
=
new
TEXTE_MODULE
(
this
,
TEXT_is_REFERENCE
);
m_LastEdit_Time
=
time
(
NULL
);
m_Reference
=
new
TEXTE_MODULE
(
this
,
TEXT_is_REFERENCE
);
m_Reference
->
Pback
=
this
;
m_Value
=
new
TEXTE_MODULE
(
this
,
TEXT_is_VALUE
);
m_Value
=
new
TEXTE_MODULE
(
this
,
TEXT_is_VALUE
);
m_Value
->
Pback
=
this
;
m_3D_Drawings
=
new
Struct3D_Master
(
this
);
m_3D_Drawings
=
new
Struct3D_Master
(
this
);
}
/* Destructeur */
MODULE
::~
MODULE
(
void
)
/* Destructeur */
MODULE
::~
MODULE
(
void
)
{
D_PAD
*
Pad
;
EDA_BaseStruct
*
Struct
,
*
NextStruct
;
D_PAD
*
Pad
;
EDA_BaseStruct
*
Struct
,
*
NextStruct
;
delete
m_Reference
;
delete
m_Value
;
for
(
Struct
=
m_3D_Drawings
;
Struct
!=
NULL
;
Struct
=
NextStruct
)
for
(
Struct
=
m_3D_Drawings
;
Struct
!=
NULL
;
Struct
=
NextStruct
)
{
NextStruct
=
Struct
->
Pnext
;
delete
Struct
;
}
/* effacement des pads */
for
(
Pad
=
m_Pads
;
Pad
!=
NULL
;
Pad
=
(
D_PAD
*
)
NextStruct
)
for
(
Pad
=
m_Pads
;
Pad
!=
NULL
;
Pad
=
(
D_PAD
*
)
NextStruct
)
{
NextStruct
=
Pad
->
Pnext
;
delete
Pad
;
}
/* effacement des elements de trace */
for
(
Struct
=
m_Drawings
;
Struct
!=
NULL
;
Struct
=
NextStruct
)
for
(
Struct
=
m_Drawings
;
Struct
!=
NULL
;
Struct
=
NextStruct
)
{
NextStruct
=
Struct
->
Pnext
;
switch
(
(
Struct
->
m_StructType
)
)
{
case
TYPEEDGEMODULE
:
delete
(
EDGE_MODULE
*
)
Struct
;
delete
(
EDGE_MODULE
*
)
Struct
;
break
;
case
TYPETEXTEMODULE
:
delete
(
TEXTE_MODULE
*
)
Struct
;
delete
(
TEXTE_MODULE
*
)
Struct
;
break
;
default
:
DisplayError
(
NULL
,
wxT
(
"Warn: ItemType not handled in delete MODULE"
)
);
DisplayError
(
NULL
,
wxT
(
"Warn: ItemType not handled in delete MODULE"
)
);
NextStruct
=
NULL
;
break
;
}
}
}
/*********************************/
void
MODULE
::
Copy
(
MODULE
*
Module
)
void
MODULE
::
Copy
(
MODULE
*
Module
)
/*********************************/
{
D_PAD
*
pad
,
*
lastpad
;
D_PAD
*
pad
,
*
lastpad
;
m_Pos
=
Module
->
m_Pos
;
m_Layer
=
Module
->
m_Layer
;
...
...
@@ -140,20 +144,20 @@ D_PAD * pad,* lastpad;
m_TimeStamp
=
GetTimeStamp
();
/* Copy des structures auxiliaires: Reference et value */
m_Reference
->
Copy
(
Module
->
m_Reference
);
m_Value
->
Copy
(
Module
->
m_Value
);
m_Reference
->
Copy
(
Module
->
m_Reference
);
m_Value
->
Copy
(
Module
->
m_Value
);
/* Copie des structures auxiliaires: Pads */
lastpad
=
NULL
;
pad
=
Module
->
m_Pads
;
for
(
;
pad
!=
NULL
;
pad
=
(
D_PAD
*
)
pad
->
Pnext
)
for
(
;
pad
!=
NULL
;
pad
=
(
D_PAD
*
)
pad
->
Pnext
)
{
D_PAD
*
newpad
=
new
D_PAD
(
this
);
newpad
->
Copy
(
pad
);
D_PAD
*
newpad
=
new
D_PAD
(
this
);
newpad
->
Copy
(
pad
);
if
(
m_Pads
==
NULL
)
if
(
m_Pads
==
NULL
)
{
newpad
->
Pback
=
this
;
m_Pads
=
(
D_PAD
*
)
newpad
;
m_Pads
=
(
D_PAD
*
)
newpad
;
}
else
{
...
...
@@ -165,27 +169,31 @@ D_PAD * pad,* lastpad;
/* Copy des structures auxiliaires: Drawings */
EDA_BaseStruct
*
OldStruct
=
(
EDA_BaseStruct
*
)
Module
->
m_Drawings
;
EDA_BaseStruct
*
NewStruct
,
*
LastStruct
=
NULL
;
for
(
;
OldStruct
;
OldStruct
=
OldStruct
->
Pnext
)
EDA_BaseStruct
*
NewStruct
,
*
LastStruct
=
NULL
;
for
(
;
OldStruct
;
OldStruct
=
OldStruct
->
Pnext
)
{
NewStruct
=
NULL
;
switch
(
OldStruct
->
m_StructType
)
switch
(
OldStruct
->
m_StructType
)
{
case
TYPETEXTEMODULE
:
NewStruct
=
new
TEXTE_MODULE
(
this
);
((
TEXTE_MODULE
*
)
NewStruct
)
->
Copy
((
TEXTE_MODULE
*
)
OldStruct
);
(
(
TEXTE_MODULE
*
)
NewStruct
)
->
Copy
(
(
TEXTE_MODULE
*
)
OldStruct
);
break
;
case
TYPEEDGEMODULE
:
NewStruct
=
new
EDGE_MODULE
(
this
);
((
EDGE_MODULE
*
)
NewStruct
)
->
Copy
((
EDGE_MODULE
*
)
OldStruct
);
(
(
EDGE_MODULE
*
)
NewStruct
)
->
Copy
(
(
EDGE_MODULE
*
)
OldStruct
);
break
;
default
:
DisplayError
(
NULL
,
wxT
(
"Internal Err: CopyModule: type indefini"
)
);
DisplayError
(
NULL
,
wxT
(
"Internal Err: CopyModule: type indefini"
)
);
break
;
}
if
(
NewStruct
==
NULL
)
break
;
if
(
m_Drawings
==
NULL
)
if
(
NewStruct
==
NULL
)
break
;
if
(
m_Drawings
==
NULL
)
{
NewStruct
->
Pback
=
this
;
m_Drawings
=
NewStruct
;
...
...
@@ -199,14 +207,14 @@ D_PAD * pad,* lastpad;
}
/* Copy des elements complementaires Drawings 3D */
m_3D_Drawings
->
Copy
(
Module
->
m_3D_Drawings
);
Struct3D_Master
*
Struct3D
,
*
NewStruct3D
,
*
CurrStruct3D
;
Struct3D
=
(
Struct3D_Master
*
)
Module
->
m_3D_Drawings
->
Pnext
;
m_3D_Drawings
->
Copy
(
Module
->
m_3D_Drawings
);
Struct3D_Master
*
Struct3D
,
*
NewStruct3D
,
*
CurrStruct3D
;
Struct3D
=
(
Struct3D_Master
*
)
Module
->
m_3D_Drawings
->
Pnext
;
CurrStruct3D
=
m_3D_Drawings
;
for
(
;
Struct3D
!=
NULL
;
Struct3D
=
(
Struct3D_Master
*
)
Struct3D
->
Pnext
)
for
(
;
Struct3D
!=
NULL
;
Struct3D
=
(
Struct3D_Master
*
)
Struct3D
->
Pnext
)
{
NewStruct3D
=
new
Struct3D_Master
(
this
);
NewStruct3D
->
Copy
(
Struct3D
);
NewStruct3D
=
new
Struct3D_Master
(
this
);
NewStruct3D
->
Copy
(
Struct3D
);
CurrStruct3D
->
Pnext
=
NewStruct3D
;
NewStruct3D
->
Pback
=
CurrStruct3D
;
CurrStruct3D
=
NewStruct3D
;
...
...
@@ -215,221 +223,234 @@ Struct3D_Master * Struct3D, *NewStruct3D, *CurrStruct3D;
/* Copie des elements complementaires */
m_Doc
=
Module
->
m_Doc
;
m_KeyWord
=
Module
->
m_KeyWord
;
}
/* supprime du chainage la structure Struct
les structures arrieres et avant sont chainees directement
*
les structures arrieres et avant sont chainees directement
*/
void
MODULE
::
UnLink
(
void
)
{
/* Modification du chainage arriere */
if
(
Pback
)
{
if
(
Pback
->
m_StructType
!=
TYPEPCB
)
if
(
Pback
->
m_StructType
!=
TYPEPCB
)
{
Pback
->
Pnext
=
Pnext
;
}
else
/* Le chainage arriere pointe sur la structure "Pere" */
{
if
(
GetState
(
DELETED
)
)
// A REVOIR car Pback = NULL si place en undelete
if
(
GetState
(
DELETED
)
)
// A REVOIR car Pback = NULL si place en undelete
{
if
(
g_UnDeleteStack
)
g_UnDeleteStack
[
g_UnDeleteStackPtr
-
1
]
=
Pnext
;
if
(
g_UnDeleteStack
)
g_UnDeleteStack
[
g_UnDeleteStackPtr
-
1
]
=
Pnext
;
}
else
((
BOARD
*
)
Pback
)
->
m_Modules
=
(
MODULE
*
)
Pnext
;
else
(
(
BOARD
*
)
Pback
)
->
m_Modules
=
(
MODULE
*
)
Pnext
;
}
}
/* Modification du chainage avant */
if
(
Pnext
)
Pnext
->
Pback
=
Pback
;
if
(
Pnext
)
Pnext
->
Pback
=
Pback
;
Pnext
=
Pback
=
NULL
;
}
/**********************************************************/
void
MODULE
::
Draw
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
draw_mode
)
void
MODULE
::
Draw
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
draw_mode
)
/**********************************************************/
/* Dessin d'une empreinte sur l'ecran actif:
Entree :
Module: pointeur sur le module
ox, oy = offset de trace
draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND)
Utilise par ailleur:
Description des parametres de l'empreinte calcules par caract() ;
*/
*
Entree :
*
Module: pointeur sur le module
*
ox, oy = offset de trace
*
draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND)
*
Utilise par ailleur:
*
Description des parametres de l'empreinte calcules par caract() ;
*/
{
D_PAD
*
pt_pad
;
EDA_BaseStruct
*
PtStruct
;
TEXTE_MODULE
*
PtTexte
;
D_PAD
*
pt_pad
;
EDA_BaseStruct
*
PtStruct
;
TEXTE_MODULE
*
PtTexte
;
/* trace des pastilles */
pt_pad
=
m_Pads
;
for
(
;
pt_pad
!=
NULL
;
pt_pad
=
(
D_PAD
*
)
pt_pad
->
Pnext
)
{
if
(
pt_pad
->
m_Flags
&
IS_MOVED
)
continue
;
pt_pad
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
if
(
pt_pad
->
m_Flags
&
IS_MOVED
)
continue
;
pt_pad
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
}
/* Impression de l'ancre du module */
DrawAncre
(
panel
,
DC
,
offset
,
DIM_ANCRE_MODULE
,
draw_mode
)
;
DrawAncre
(
panel
,
DC
,
offset
,
DIM_ANCRE_MODULE
,
draw_mode
)
;
/* impression des graphismes */
if
(
!
(
m_Reference
->
m_Flags
&
IS_MOVED
)
)
m_Reference
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
if
(
!
(
m_Value
->
m_Flags
&
IS_MOVED
)
)
m_Value
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
if
(
!
(
m_Reference
->
m_Flags
&
IS_MOVED
)
)
m_Reference
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
if
(
!
(
m_Value
->
m_Flags
&
IS_MOVED
)
)
m_Value
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
PtStruct
=
m_Drawings
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
{
if
(
PtStruct
->
m_Flags
&
IS_MOVED
)
continue
;
if
(
PtStruct
->
m_Flags
&
IS_MOVED
)
continue
;
switch
(
PtStruct
->
m_StructType
)
{
case
TYPETEXTEMODULE
:
PtTexte
=
(
TEXTE_MODULE
*
)
PtStruct
;
PtTexte
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
PtTexte
=
(
TEXTE_MODULE
*
)
PtStruct
;
PtTexte
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
break
;
case
TYPEEDGEMODULE
:
((
EDGE_MODULE
*
)
PtStruct
)
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
(
(
EDGE_MODULE
*
)
PtStruct
)
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
break
;
default
:
break
;
default
:
break
;
}
}
}
/**************************************************************/
void
MODULE
::
DrawEdgesOnly
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
draw_mode
)
void
MODULE
::
DrawEdgesOnly
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
draw_mode
)
/**************************************************************/
{
EDA_BaseStruct
*
PtStruct
;
EDA_BaseStruct
*
PtStruct
;
/* impression des graphismes */
PtStruct
=
m_Drawings
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
{
switch
(
PtStruct
->
m_StructType
)
{
case
TYPEEDGEMODULE
:
((
EDGE_MODULE
*
)
PtStruct
)
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
(
(
EDGE_MODULE
*
)
PtStruct
)
->
Draw
(
panel
,
DC
,
offset
,
draw_mode
);
break
;
default
:
break
;
default
:
break
;
}
}
}
/*************************************/
int
MODULE
::
WriteDescr
(
FILE
*
File
)
int
MODULE
::
WriteDescr
(
FILE
*
File
)
/*************************************/
/* Sauvegarde de la description d'un MODULE
*/
*/
{
char
StringStat
[
20
];
TEXTE_MODULE
*
PtText
;
EDGE_MODULE
*
PtEdge
;
D_PAD
*
ptpad
;
EDA_BaseStruct
*
PtStruct
;
int
ii
,
NbLigne
=
0
;
wxString
msg
;
char
StringStat
[
20
];
TEXTE_MODULE
*
PtText
;
EDGE_MODULE
*
PtEdge
;
D_PAD
*
ptpad
;
EDA_BaseStruct
*
PtStruct
;
int
ii
,
NbLigne
=
0
;
wxString
msg
;
if
(
GetState
(
DELETED
)
)
return
(
NbLigne
);
if
(
GetState
(
DELETED
)
)
return
NbLigne
;
/* Generation du fichier module: */
fprintf
(
File
,
"$MODULE %s
\n
"
,
CONV_TO_UTF8
(
m_LibRef
)
);
fprintf
(
File
,
"$MODULE %s
\n
"
,
CONV_TO_UTF8
(
m_LibRef
)
);
NbLigne
++
;
/* Generation des coord et caracteristiques */
memset
(
StringStat
,
0
,
sizeof
(
StringStat
)
);
if
(
m_ModuleStatus
&
MODULE_is_LOCKED
)
memset
(
StringStat
,
0
,
sizeof
(
StringStat
)
);
if
(
m_ModuleStatus
&
MODULE_is_LOCKED
)
StringStat
[
0
]
=
'F'
;
else
StringStat
[
0
]
=
'~'
;
if
(
m_ModuleStatus
&
MODULE_is_PLACED
)
else
StringStat
[
0
]
=
'~'
;
if
(
m_ModuleStatus
&
MODULE_is_PLACED
)
StringStat
[
1
]
=
'P'
;
else
StringStat
[
1
]
=
'~'
;
else
StringStat
[
1
]
=
'~'
;
fprintf
(
File
,
"Po %d %d %d %d %8.8lX %8.8lX %s
\n
"
,
fprintf
(
File
,
"Po %d %d %d %d %8.8lX %8.8lX %s
\n
"
,
m_Pos
.
x
,
m_Pos
.
y
,
m_Orient
,
m_Layer
,
m_LastEdit_Time
,
m_TimeStamp
,
StringStat
);
m_Orient
,
m_Layer
,
m_LastEdit_Time
,
m_TimeStamp
,
StringStat
);
NbLigne
++
;
fprintf
(
File
,
"Li %s
\n
"
,
CONV_TO_UTF8
(
m_LibRef
)
);
fprintf
(
File
,
"Li %s
\n
"
,
CONV_TO_UTF8
(
m_LibRef
)
);
NbLigne
++
;
if
(
!
m_Doc
.
IsEmpty
()
)
if
(
!
m_Doc
.
IsEmpty
()
)
{
fprintf
(
File
,
"Cd %s
\n
"
,
CONV_TO_UTF8
(
m_Doc
)
);
fprintf
(
File
,
"Cd %s
\n
"
,
CONV_TO_UTF8
(
m_Doc
)
);
NbLigne
++
;
}
if
(
!
m_KeyWord
.
IsEmpty
()
)
if
(
!
m_KeyWord
.
IsEmpty
()
)
{
fprintf
(
File
,
"Kw %s
\n
"
,
CONV_TO_UTF8
(
m_KeyWord
)
);
fprintf
(
File
,
"Kw %s
\n
"
,
CONV_TO_UTF8
(
m_KeyWord
)
);
NbLigne
++
;
}
fprintf
(
File
,
"Sc %8.8lX
\n
"
,
m_TimeStamp
);
fprintf
(
File
,
"Sc %8.8lX
\n
"
,
m_TimeStamp
);
NbLigne
++
;
fprintf
(
File
,
"Op %X %X 0
\n
"
,
m_CntRot90
,
m_CntRot180
);
fprintf
(
File
,
"Op %X %X 0
\n
"
,
m_CntRot90
,
m_CntRot180
);
NbLigne
++
;
/* Attributs du module */
if
(
m_Attributs
!=
MOD_DEFAULT
)
{
fprintf
(
File
,
"At "
);
if
(
m_Attributs
&
MOD_CMS
)
fprintf
(
File
,
"SMD "
);
if
(
m_Attributs
&
MOD_VIRTUAL
)
fprintf
(
File
,
"VIRTUAL "
);
fprintf
(
File
,
"
\n
"
);
fprintf
(
File
,
"At "
);
if
(
m_Attributs
&
MOD_CMS
)
fprintf
(
File
,
"SMD "
);
if
(
m_Attributs
&
MOD_VIRTUAL
)
fprintf
(
File
,
"VIRTUAL "
);
fprintf
(
File
,
"
\n
"
);
}
/* Texte Reference du module */
fprintf
(
File
,
"T%d %d %d %d %d %d %d %c %c %d
\"
%.16s
\"\n
"
,
fprintf
(
File
,
"T%d %d %d %d %d %d %d %c %c %d
\"
%.16s
\"\n
"
,
m_Reference
->
m_Type
,
m_Reference
->
m_Pos0
.
x
,
m_Reference
->
m_Pos0
.
y
,
m_Reference
->
m_Size
.
y
,
m_Reference
->
m_Size
.
x
,
m_Reference
->
m_Size
.
y
,
m_Reference
->
m_Size
.
x
,
m_Reference
->
m_Orient
+
m_Orient
,
m_Reference
->
m_Width
,
m_Reference
->
m_Miroir
?
'N'
:
'M'
,
m_Reference
->
m_NoShow
?
'I'
:
'V'
,
m_Reference
->
m_Layer
,
CONV_TO_UTF8
(
m_Reference
->
m_Text
)
);
CONV_TO_UTF8
(
m_Reference
->
m_Text
)
);
NbLigne
++
;
/* Texte Value du module */
fprintf
(
File
,
"T%d %d %d %d %d %d %d %c %c %d
\"
%.16s
\"\n
"
,
fprintf
(
File
,
"T%d %d %d %d %d %d %d %c %c %d
\"
%.16s
\"\n
"
,
m_Value
->
m_Type
,
m_Value
->
m_Pos0
.
x
,
m_Value
->
m_Pos0
.
y
,
m_Value
->
m_Size
.
y
,
m_Value
->
m_Size
.
x
,
m_Value
->
m_Size
.
y
,
m_Value
->
m_Size
.
x
,
m_Value
->
m_Orient
+
m_Orient
,
m_Value
->
m_Width
,
m_Value
->
m_Miroir
?
'N'
:
'M'
,
m_Value
->
m_NoShow
?
'I'
:
'V'
,
m_Value
->
m_Layer
,
CONV_TO_UTF8
(
m_Value
->
m_Text
)
);
CONV_TO_UTF8
(
m_Value
->
m_Text
)
);
NbLigne
++
;
/* Generation des elements Drawing modules */
PtStruct
=
m_Drawings
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
{
switch
(
PtStruct
->
m_StructType
)
switch
(
PtStruct
->
m_StructType
)
{
case
TYPETEXTEMODULE
:
PtText
=
((
TEXTE_MODULE
*
)
PtStruct
);
fprintf
(
File
,
"T%d %d %d %d %d %d %d %c %c %d
\"
%s
\"\n
"
,
PtText
=
(
(
TEXTE_MODULE
*
)
PtStruct
);
fprintf
(
File
,
"T%d %d %d %d %d %d %d %c %c %d
\"
%s
\"\n
"
,
PtText
->
m_Type
,
PtText
->
m_Pos0
.
x
,
PtText
->
m_Pos0
.
y
,
PtText
->
m_Size
.
y
,
PtText
->
m_Size
.
x
,
PtText
->
m_Size
.
y
,
PtText
->
m_Size
.
x
,
PtText
->
m_Orient
+
m_Orient
,
PtText
->
m_Width
,
PtText
->
m_Miroir
?
'N'
:
'M'
,
PtText
->
m_NoShow
?
'I'
:
'V'
,
PtText
->
m_Layer
,
CONV_TO_UTF8
(
PtText
->
m_Text
)
);
PtText
->
m_Layer
,
CONV_TO_UTF8
(
PtText
->
m_Text
)
);
NbLigne
++
;
break
;
...
...
@@ -439,237 +460,261 @@ wxString msg;
break
;
default
:
msg
.
Printf
(
wxT
(
"Type (%d) Draw Module inconnu"
),
PtStruct
->
m_StructType
);
DisplayError
(
NULL
,
msg
);
msg
.
Printf
(
wxT
(
"Type (%d) Draw Module inconnu"
),
PtStruct
->
m_StructType
);
DisplayError
(
NULL
,
msg
);
break
;
}
/* Fin switch gestion des Items draw */
}
/* Fin switch gestion des Items draw */
}
/* Generation de la liste des pads */
ptpad
=
m_Pads
;
for
(
;
ptpad
!=
NULL
;
ptpad
=
(
D_PAD
*
)
ptpad
->
Pnext
)
for
(
;
ptpad
!=
NULL
;
ptpad
=
(
D_PAD
*
)
ptpad
->
Pnext
)
{
ii
=
ptpad
->
WriteDescr
(
File
);
ii
=
ptpad
->
WriteDescr
(
File
);
NbLigne
+=
ii
;
}
/* Generation des informations de trac
3D */
/* Generation des informations de trac�
3D */
Write_3D_Descr
(
File
);
/* Fin de description: */
fprintf
(
File
,
"$EndMODULE %s
\n
"
,
CONV_TO_UTF8
(
m_LibRef
)
);
fprintf
(
File
,
"$EndMODULE %s
\n
"
,
CONV_TO_UTF8
(
m_LibRef
)
);
NbLigne
++
;
return
(
NbLigne
)
;
return
NbLigne
;
}
/***************************************/
int
MODULE
::
Write_3D_Descr
(
FILE
*
File
)
int
MODULE
::
Write_3D_Descr
(
FILE
*
File
)
/***************************************/
/* Sauvegarde de la description 3D du MODULE
*/
*/
{
char
buf
[
512
];
Struct3D_Master
*
Struct3D
=
m_3D_Drawings
;
char
buf
[
512
];
Struct3D_Master
*
Struct3D
=
m_3D_Drawings
;
for
(
;
Struct3D
!=
NULL
;
Struct3D
=
(
Struct3D_Master
*
)
Struct3D
->
Pnext
)
for
(
;
Struct3D
!=
NULL
;
Struct3D
=
(
Struct3D_Master
*
)
Struct3D
->
Pnext
)
{
if
(
!
Struct3D
->
m_Shape3DName
.
IsEmpty
()
)
if
(
!
Struct3D
->
m_Shape3DName
.
IsEmpty
()
)
{
fprintf
(
File
,
"$SHAPE3D
\n
"
);
fprintf
(
File
,
"$SHAPE3D
\n
"
);
fprintf
(
File
,
"Na
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
Struct3D
->
m_Shape3DName
)
);
fprintf
(
File
,
"Na
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
Struct3D
->
m_Shape3DName
)
);
sprintf
(
buf
,
"Sc %lf %lf %lf
\n
"
,
sprintf
(
buf
,
"Sc %lf %lf %lf
\n
"
,
Struct3D
->
m_MatScale
.
x
,
Struct3D
->
m_MatScale
.
y
,
Struct3D
->
m_MatScale
.
z
);
fprintf
(
File
,
to_point
(
buf
)
);
Struct3D
->
m_MatScale
.
z
);
fprintf
(
File
,
to_point
(
buf
)
);
sprintf
(
buf
,
"Of %lf %lf %lf
\n
"
,
sprintf
(
buf
,
"Of %lf %lf %lf
\n
"
,
Struct3D
->
m_MatPosition
.
x
,
Struct3D
->
m_MatPosition
.
y
,
Struct3D
->
m_MatPosition
.
z
);
fprintf
(
File
,
to_point
(
buf
)
);
Struct3D
->
m_MatPosition
.
z
);
fprintf
(
File
,
to_point
(
buf
)
);
sprintf
(
buf
,
"Ro %lf %lf %lf
\n
"
,
sprintf
(
buf
,
"Ro %lf %lf %lf
\n
"
,
Struct3D
->
m_MatRotation
.
x
,
Struct3D
->
m_MatRotation
.
y
,
Struct3D
->
m_MatRotation
.
z
);
fprintf
(
File
,
to_point
(
buf
)
);
Struct3D
->
m_MatRotation
.
z
);
fprintf
(
File
,
to_point
(
buf
)
);
fprintf
(
File
,
"$EndSHAPE3D
\n
"
);
fprintf
(
File
,
"$EndSHAPE3D
\n
"
);
}
}
return
0
;
}
/****************************************************/
int
MODULE
::
Read_3D_Descr
(
FILE
*
File
,
int
*
LineNum
)
int
MODULE
::
Read_3D_Descr
(
FILE
*
File
,
int
*
LineNum
)
/****************************************************/
/* Lecture de la description d'un MODULE (format Ascii)
la 1ere ligne de descr ($MODULE) est supposee etre deja lue
retourne 0 si OK
*/
*
la 1ere ligne de descr ($MODULE) est supposee etre deja lue
*
retourne 0 si OK
*/
{
char
Line
[
1024
];
char
*
text
=
Line
+
3
;
Struct3D_Master
*
Struct3D
=
m_3D_Drawings
;
char
Line
[
1024
];
char
*
text
=
Line
+
3
;
Struct3D_Master
*
Struct3D
=
m_3D_Drawings
;
if
(
!
Struct3D
->
m_Shape3DName
.
IsEmpty
()
)
if
(
!
Struct3D
->
m_Shape3DName
.
IsEmpty
()
)
{
Struct3D_Master
*
NewStruct3D
;
while
(
Struct3D
->
Pnext
)
Struct3D
=
(
Struct3D_Master
*
)
Struct3D
->
Pnext
;
Struct3D
->
Pnext
=
NewStruct3D
=
new
Struct3D_Master
(
this
);
Struct3D_Master
*
NewStruct3D
;
while
(
Struct3D
->
Pnext
)
Struct3D
=
(
Struct3D_Master
*
)
Struct3D
->
Pnext
;
Struct3D
->
Pnext
=
NewStruct3D
=
new
Struct3D_Master
(
this
);
NewStruct3D
->
Pback
=
Struct3D
;
Struct3D
=
NewStruct3D
;
}
while
(
GetLine
(
File
,
Line
,
LineNum
,
sizeof
(
Line
)
-
1
)
!=
NULL
)
while
(
GetLine
(
File
,
Line
,
LineNum
,
sizeof
(
Line
)
-
1
)
!=
NULL
)
{
switch
(
Line
[
0
]
)
{
case
'$'
:
// Fin de description
if
(
Line
[
1
]
==
'E'
)
return
0
;
if
(
Line
[
1
]
==
'E'
)
return
0
;
return
1
;
case
'N'
:
// Shape File Name
{
char
buf
[
512
];
ReadDelimitedText
(
buf
,
text
,
512
);
Struct3D
->
m_Shape3DName
=
CONV_FROM_UTF8
(
buf
);
ReadDelimitedText
(
buf
,
text
,
512
);
Struct3D
->
m_Shape3DName
=
CONV_FROM_UTF8
(
buf
);
break
;
}
case
'S'
:
// Scale
sscanf
(
text
,
"%lf %lf %lf
\n
"
,
sscanf
(
text
,
"%lf %lf %lf
\n
"
,
&
Struct3D
->
m_MatScale
.
x
,
&
Struct3D
->
m_MatScale
.
y
,
&
Struct3D
->
m_MatScale
.
z
);
&
Struct3D
->
m_MatScale
.
z
);
break
;
case
'O'
:
// Offset
sscanf
(
text
,
"%lf %lf %lf
\n
"
,
sscanf
(
text
,
"%lf %lf %lf
\n
"
,
&
Struct3D
->
m_MatPosition
.
x
,
&
Struct3D
->
m_MatPosition
.
y
,
&
Struct3D
->
m_MatPosition
.
z
);
&
Struct3D
->
m_MatPosition
.
z
);
break
;
case
'R'
:
// Rotation
sscanf
(
text
,
"%lf %lf %lf
\n
"
,
sscanf
(
text
,
"%lf %lf %lf
\n
"
,
&
Struct3D
->
m_MatRotation
.
x
,
&
Struct3D
->
m_MatRotation
.
y
,
&
Struct3D
->
m_MatRotation
.
z
);
&
Struct3D
->
m_MatRotation
.
z
);
break
;
default
:
break
;
}
}
return
1
;
}
/**************************************************/
int
MODULE
::
ReadDescr
(
FILE
*
File
,
int
*
LineNum
)
int
MODULE
::
ReadDescr
(
FILE
*
File
,
int
*
LineNum
)
/**************************************************/
/* Lecture de la description d'un MODULE (format Ascii)
la 1ere ligne de descr ($MODULE) est supposee etre deja lue
retourne 0 si OK
*/
*
la 1ere ligne de descr ($MODULE) est supposee etre deja lue
*
retourne 0 si OK
*/
{
D_PAD
*
LastPad
=
NULL
,
*
ptpad
;
EDA_BaseStruct
*
LastModStruct
=
NULL
;
EDGE_MODULE
*
DrawSegm
;
TEXTE_MODULE
*
DrawText
;
char
Line
[
256
],
BufLine
[
256
],
BufCar1
[
128
],
BufCar2
[
128
],
*
PtLine
;
int
itmp1
,
itmp2
;
while
(
GetLine
(
File
,
Line
,
LineNum
,
sizeof
(
Line
)
-
1
)
!=
NULL
)
D_PAD
*
LastPad
=
NULL
,
*
ptpad
;
EDA_BaseStruct
*
LastModStruct
=
NULL
;
EDGE_MODULE
*
DrawSegm
;
TEXTE_MODULE
*
DrawText
;
char
Line
[
256
],
BufLine
[
256
],
BufCar1
[
128
],
BufCar2
[
128
],
*
PtLine
;
int
itmp1
,
itmp2
;
while
(
GetLine
(
File
,
Line
,
LineNum
,
sizeof
(
Line
)
-
1
)
!=
NULL
)
{
if
(
Line
[
0
]
==
'$'
)
{
if
(
Line
[
1
]
==
'E'
)
break
;
if
(
Line
[
1
]
==
'E'
)
break
;
if
(
Line
[
1
]
==
'P'
)
{
ptpad
=
new
D_PAD
(
this
);
ptpad
->
ReadDescr
(
File
,
LineNum
);
ptpad
=
new
D_PAD
(
this
);
ptpad
->
ReadDescr
(
File
,
LineNum
);
RotatePoint
(
&
ptpad
->
m_Pos
.
x
,
&
ptpad
->
m_Pos
.
y
,
m_Orient
);
ptpad
->
m_Pos
.
x
+=
m_Pos
.
x
;
ptpad
->
m_Pos
.
y
+=
m_Pos
.
y
;
if
(
LastPad
==
NULL
)
if
(
LastPad
==
NULL
)
{
ptpad
->
Pback
=
(
EDA_BaseStruct
*
)
this
;
ptpad
->
Pback
=
(
EDA_BaseStruct
*
)
this
;
m_Pads
=
ptpad
;
}
else
{
ptpad
->
Pback
=
(
EDA_BaseStruct
*
)
LastPad
;
LastPad
->
Pnext
=
(
EDA_BaseStruct
*
)
ptpad
;
ptpad
->
Pback
=
(
EDA_BaseStruct
*
)
LastPad
;
LastPad
->
Pnext
=
(
EDA_BaseStruct
*
)
ptpad
;
}
LastPad
=
ptpad
;
continue
;
}
if
(
Line
[
1
]
==
'S'
)
Read_3D_Descr
(
File
,
LineNum
);
if
(
Line
[
1
]
==
'S'
)
Read_3D_Descr
(
File
,
LineNum
);
}
if
(
strlen
(
Line
)
<
4
)
continue
;
PtLine
=
Line
+
3
;
/* Pointe 1er code utile de la ligne */
if
(
strlen
(
Line
)
<
4
)
continue
;
PtLine
=
Line
+
3
;
/* Pointe 1er code utile de la ligne */
switch
(
Line
[
0
]
)
{
case
'P'
:
memset
(
BufCar1
,
0
,
sizeof
(
BufCar1
)
);
sscanf
(
PtLine
,
"%d %d %d %d %lX %lX %s"
,
memset
(
BufCar1
,
0
,
sizeof
(
BufCar1
)
);
sscanf
(
PtLine
,
"%d %d %d %d %lX %lX %s"
,
&
m_Pos
.
x
,
&
m_Pos
.
y
,
&
m_Orient
,
&
m_Layer
,
&
m_LastEdit_Time
,
&
m_TimeStamp
,
BufCar1
);
&
m_Orient
,
&
m_Layer
,
&
m_LastEdit_Time
,
&
m_TimeStamp
,
BufCar1
);
m_ModuleStatus
=
0
;
if
(
BufCar1
[
0
]
==
'F'
)
m_ModuleStatus
|=
MODULE_is_LOCKED
;
if
(
BufCar1
[
1
]
==
'P'
)
m_ModuleStatus
|=
MODULE_is_PLACED
;
if
(
BufCar1
[
0
]
==
'F'
)
m_ModuleStatus
|=
MODULE_is_LOCKED
;
if
(
BufCar1
[
1
]
==
'P'
)
m_ModuleStatus
|=
MODULE_is_PLACED
;
break
;
case
'L'
:
/* Li = Lecture du nom librairie du module */
*
BufLine
=
0
;
sscanf
(
PtLine
,
" %s"
,
BufLine
);
m_LibRef
=
CONV_FROM_UTF8
(
BufLine
);
sscanf
(
PtLine
,
" %s"
,
BufLine
);
m_LibRef
=
CONV_FROM_UTF8
(
BufLine
);
break
;
case
'S'
:
sscanf
(
PtLine
,
" %lX"
,
&
m_TimeStamp
);
sscanf
(
PtLine
,
" %lX"
,
&
m_TimeStamp
);
break
;
case
'O'
:
/* (Op)tions de placement auto */
itmp1
=
itmp2
=
0
;
sscanf
(
PtLine
,
" %X %X"
,
&
itmp1
,
&
itmp2
);
sscanf
(
PtLine
,
" %X %X"
,
&
itmp1
,
&
itmp2
);
m_CntRot180
=
itmp2
&
0x0F
;
if
(
m_CntRot180
>
10
)
m_CntRot180
=
10
;
if
(
m_CntRot180
>
10
)
m_CntRot180
=
10
;
m_CntRot90
=
itmp1
&
0x0F
;
if
(
m_CntRot90
>
10
)
m_CntRot90
=
0
;
if
(
m_CntRot90
>
10
)
m_CntRot90
=
0
;
itmp1
=
(
itmp1
>>
4
)
&
0x0F
;
if
(
itmp1
>
10
)
itmp1
=
0
;
if
(
itmp1
>
10
)
itmp1
=
0
;
m_CntRot90
|=
itmp1
<<
4
;
break
;
case
'A'
:
/* At = (At)tributs du module */
if
(
strstr
(
PtLine
,
"SMD"
)
)
m_Attributs
|=
MOD_CMS
;
if
(
strstr
(
PtLine
,
"VIRTUAL"
)
)
m_Attributs
|=
MOD_VIRTUAL
;
if
(
strstr
(
PtLine
,
"SMD"
)
)
m_Attributs
|=
MOD_CMS
;
if
(
strstr
(
PtLine
,
"VIRTUAL"
)
)
m_Attributs
|=
MOD_VIRTUAL
;
break
;
case
'T'
:
/* lecture des textes modules */
sscanf
(
Line
+
1
,
"%d"
,
&
itmp1
);
if
(
itmp1
==
TEXT_is_REFERENCE
)
sscanf
(
Line
+
1
,
"%d"
,
&
itmp1
);
if
(
itmp1
==
TEXT_is_REFERENCE
)
DrawText
=
m_Reference
;
else
if
(
itmp1
==
TEXT_is_VALUE
)
else
if
(
itmp1
==
TEXT_is_VALUE
)
DrawText
=
m_Value
;
else
/* text is a drawing */
{
DrawText
=
new
TEXTE_MODULE
(
this
);
if
(
LastModStruct
==
NULL
)
{
DrawText
=
new
TEXTE_MODULE
(
this
);
if
(
LastModStruct
==
NULL
)
{
DrawText
->
Pback
=
this
;
m_Drawings
=
(
EDA_BaseStruct
*
)
DrawText
;
...
...
@@ -682,37 +727,46 @@ int itmp1, itmp2;
LastModStruct
=
(
EDA_BaseStruct
*
)
DrawText
;
}
sscanf
(
Line
+
1
,
"%d %d %d %d %d %d %d %s %s %d"
,
sscanf
(
Line
+
1
,
"%d %d %d %d %d %d %d %s %s %d"
,
&
itmp1
,
&
DrawText
->
m_Pos0
.
x
,
&
DrawText
->
m_Pos0
.
y
,
&
DrawText
->
m_Size
.
y
,
&
DrawText
->
m_Size
.
x
,
&
DrawText
->
m_Orient
,
&
DrawText
->
m_Width
,
BufCar1
,
BufCar2
,
&
DrawText
->
m_Layer
);
BufCar1
,
BufCar2
,
&
DrawText
->
m_Layer
);
DrawText
->
m_Type
=
itmp1
;
DrawText
->
m_Orient
-=
m_Orient
;
// m_Orient texte relative au module
if
(
BufCar1
[
0
]
==
'M'
)
DrawText
->
m_Miroir
=
0
;
else
DrawText
->
m_Miroir
=
1
;
if
(
BufCar2
[
0
]
==
'I'
)
DrawText
->
m_NoShow
=
1
;
else
DrawText
->
m_NoShow
=
0
;
if
(
BufCar1
[
0
]
==
'M'
)
DrawText
->
m_Miroir
=
0
;
else
DrawText
->
m_Miroir
=
1
;
if
(
BufCar2
[
0
]
==
'I'
)
DrawText
->
m_NoShow
=
1
;
else
DrawText
->
m_NoShow
=
0
;
if
(
m_Layer
==
CUIVRE_N
)
DrawText
->
m_Layer
=
SILKSCREEN_N_CU
;
if
(
m_Layer
==
CMP_N
)
DrawText
->
m_Layer
=
SILKSCREEN_N_CMP
;
if
(
m_Layer
==
CUIVRE_N
)
DrawText
->
m_Layer
=
SILKSCREEN_N_CU
;
if
(
m_Layer
==
CMP_N
)
DrawText
->
m_Layer
=
SILKSCREEN_N_CMP
;
/* calcul de la position vraie */
DrawText
->
SetDrawCoord
();
/* Lecture de la chaine "text" */
ReadDelimitedText
(
BufLine
,
Line
,
sizeof
(
BufLine
)
);
DrawText
->
m_Text
=
CONV_FROM_UTF8
(
BufLine
);
ReadDelimitedText
(
BufLine
,
Line
,
sizeof
(
BufLine
)
);
DrawText
->
m_Text
=
CONV_FROM_UTF8
(
BufLine
);
// Controle d'epaisseur raisonnable:
if
(
DrawText
->
m_Width
<=
1
)
DrawText
->
m_Width
=
1
;
if
(
DrawText
->
m_Width
>
MAX_WIDTH
)
DrawText
->
m_Width
=
MAX_WIDTH
;
if
(
DrawText
->
m_Width
<=
1
)
DrawText
->
m_Width
=
1
;
if
(
DrawText
->
m_Width
>
MAX_WIDTH
)
DrawText
->
m_Width
=
MAX_WIDTH
;
break
;
case
'D'
:
/* lecture du contour */
DrawSegm
=
new
EDGE_MODULE
(
this
);
DrawSegm
=
new
EDGE_MODULE
(
this
);
if
(
LastModStruct
==
NULL
)
if
(
LastModStruct
==
NULL
)
{
DrawSegm
->
Pback
=
this
;
m_Drawings
=
DrawSegm
;
...
...
@@ -724,72 +778,76 @@ int itmp1, itmp2;
}
LastModStruct
=
DrawSegm
;
DrawSegm
->
ReadDescr
(
Line
,
File
,
LineNum
);
DrawSegm
->
ReadDescr
(
Line
,
File
,
LineNum
);
DrawSegm
->
SetDrawCoord
();
break
;
case
'C'
:
/* Lecture de la doc */
m_Doc
=
CONV_FROM_UTF8
(
StrPurge
(
PtLine
)
);
m_Doc
=
CONV_FROM_UTF8
(
StrPurge
(
PtLine
)
);
break
;
case
'K'
:
/* Lecture de la liste des mots cle */
m_KeyWord
=
CONV_FROM_UTF8
(
StrPurge
(
PtLine
)
);
m_KeyWord
=
CONV_FROM_UTF8
(
StrPurge
(
PtLine
)
);
break
;
default
:
break
;
}
}
/* Recalcul de l'encadrement */
Set_Rectangle_Encadrement
();
return
(
0
)
;
return
0
;
}
/****************************************************/
void
MODULE
::
SetPosition
(
const
wxPoint
&
newpos
)
void
MODULE
::
SetPosition
(
const
wxPoint
&
newpos
)
/****************************************************/
// replace le module en position newpos
{
int
deltaX
=
newpos
.
x
-
m_Pos
.
x
;
int
deltaY
=
newpos
.
y
-
m_Pos
.
y
;
int
deltaX
=
newpos
.
x
-
m_Pos
.
x
;
int
deltaY
=
newpos
.
y
-
m_Pos
.
y
;
/* deplacement de l'ancre */
m_Pos
.
x
+=
deltaX
;
m_Pos
.
y
+=
deltaY
;
m_Pos
.
x
+=
deltaX
;
m_Pos
.
y
+=
deltaY
;
/* deplacement de la reference */
m_Reference
->
m_Pos
.
x
+=
deltaX
;
m_Reference
->
m_Pos
.
y
+=
deltaY
;
m_Reference
->
m_Pos
.
x
+=
deltaX
;
m_Reference
->
m_Pos
.
y
+=
deltaY
;
/* deplacement de la Valeur */
m_Value
->
m_Pos
.
x
+=
deltaX
;
m_Value
->
m_Pos
.
y
+=
deltaY
;
m_Value
->
m_Pos
.
x
+=
deltaX
;
m_Value
->
m_Pos
.
y
+=
deltaY
;
/* deplacement des pastilles */
D_PAD
*
pad
=
m_Pads
;
for
(
;
pad
!=
NULL
;
pad
=
(
D_PAD
*
)
pad
->
Pnext
)
D_PAD
*
pad
=
m_Pads
;
for
(
;
pad
!=
NULL
;
pad
=
(
D_PAD
*
)
pad
->
Pnext
)
{
pad
->
m_Pos
.
x
+=
deltaX
;
pad
->
m_Pos
.
y
+=
deltaY
;
pad
->
m_Pos
.
x
+=
deltaX
;
pad
->
m_Pos
.
y
+=
deltaY
;
}
/* deplacement des dessins de l'empreinte : */
EDA_BaseStruct
*
PtStruct
=
m_Drawings
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
EDA_BaseStruct
*
PtStruct
=
m_Drawings
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
{
switch
(
PtStruct
->
m_StructType
)
switch
(
PtStruct
->
m_StructType
)
{
case
TYPEEDGEMODULE
:
{
EDGE_MODULE
*
pt_edgmod
=
(
EDGE_MODULE
*
)
PtStruct
;
EDGE_MODULE
*
pt_edgmod
=
(
EDGE_MODULE
*
)
PtStruct
;
pt_edgmod
->
SetDrawCoord
();
break
;
}
case
TYPETEXTEMODULE
:
{
TEXTE_MODULE
*
pt_texte
=
(
TEXTE_MODULE
*
)
PtStruct
;
pt_texte
->
m_Pos
.
x
+=
deltaX
;
pt_texte
->
m_Pos
.
y
+=
deltaY
;
TEXTE_MODULE
*
pt_texte
=
(
TEXTE_MODULE
*
)
PtStruct
;
pt_texte
->
m_Pos
.
x
+=
deltaX
;
pt_texte
->
m_Pos
.
y
+=
deltaY
;
break
;
}
default
:
DisplayError
(
NULL
,
wxT
(
"Type Draw Indefini"
));
break
;
default
:
DisplayError
(
NULL
,
wxT
(
"Type Draw Indefini"
)
);
break
;
}
}
...
...
@@ -797,29 +855,29 @@ int deltaY = newpos.y - m_Pos.y;
}
/*********************************************/
void
MODULE
::
SetOrientation
(
int
newangle
)
void
MODULE
::
SetOrientation
(
int
newangle
)
/*********************************************/
/* Tourne de newangle (en 0.1 degres) le module
*/
*/
{
int
px
,
py
;
int
px
,
py
;
newangle
-=
m_Orient
;
// = delta de rotation
m_Orient
+=
newangle
;
NORMALIZE_ANGLE_POS
(
m_Orient
);
NORMALIZE_ANGLE_POS
(
m_Orient
);
/* deplacement et rotation des pastilles */
D_PAD
*
pad
=
m_Pads
;
for
(
;
pad
!=
NULL
;
pad
=
(
D_PAD
*
)
pad
->
Pnext
)
D_PAD
*
pad
=
m_Pads
;
for
(
;
pad
!=
NULL
;
pad
=
(
D_PAD
*
)
pad
->
Pnext
)
{
px
=
pad
->
m_Pos0
.
x
;
py
=
pad
->
m_Pos0
.
y
;
pad
->
m_Orient
+=
newangle
;
/* change m_Orientation */
NORMALIZE_ANGLE_POS
(
pad
->
m_Orient
);
pad
->
m_Orient
+=
newangle
;
/* change m_Orientation */
NORMALIZE_ANGLE_POS
(
pad
->
m_Orient
);
RotatePoint
(
&
px
,
&
py
,
(
int
)
m_Orient
);
pad
->
m_Pos
.
x
=
m_Pos
.
x
+
px
;
...
...
@@ -831,18 +889,18 @@ int px ,py;
m_Value
->
SetDrawCoord
();
/* deplacement des contours et textes de l'empreinte : */
EDA_BaseStruct
*
PtStruct
=
m_Drawings
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
EDA_BaseStruct
*
PtStruct
=
m_Drawings
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
{
if
(
PtStruct
->
m_StructType
==
TYPEEDGEMODULE
)
{
EDGE_MODULE
*
pt_edgmod
=
(
EDGE_MODULE
*
)
PtStruct
;
EDGE_MODULE
*
pt_edgmod
=
(
EDGE_MODULE
*
)
PtStruct
;
pt_edgmod
->
SetDrawCoord
();
}
if
(
PtStruct
->
m_StructType
==
TYPETEXTEMODULE
)
{
/* deplacement des inscriptions : */
TEXTE_MODULE
*
pt_texte
=
(
TEXTE_MODULE
*
)
PtStruct
;
TEXTE_MODULE
*
pt_texte
=
(
TEXTE_MODULE
*
)
PtStruct
;
pt_texte
->
SetDrawCoord
();
}
}
...
...
@@ -851,23 +909,25 @@ int px ,py;
Set_Rectangle_Encadrement
();
}
/************************************************/
void
MODULE
::
Set_Rectangle_Encadrement
(
void
)
void
MODULE
::
Set_Rectangle_Encadrement
(
void
)
/************************************************/
/* Mise a jour du rectangle d'encadrement du module
Entree : pointeur sur module
Le rectangle d'encadrement est le rectangle comprenant les contours et les
pads.
Le rectangle est calcule:
pour orient 0
en coord relatives / position ancre
*/
*
Entree : pointeur sur module
*
Le rectangle d'encadrement est le rectangle comprenant les contours et les
*
pads.
*
Le rectangle est calcule:
*
pour orient 0
*
en coord relatives / position ancre
*/
{
EDGE_MODULE
*
pt_edge_mod
;
D_PAD
*
pad
;
int
width
;
int
cx
,
cy
,
uxf
,
uyf
,
rayon
;
int
xmax
,
ymax
;
EDGE_MODULE
*
pt_edge_mod
;
D_PAD
*
pad
;
int
width
;
int
cx
,
cy
,
uxf
,
uyf
,
rayon
;
int
xmax
,
ymax
;
/* Init des pointeurs */
...
...
@@ -878,195 +938,237 @@ int xmax, ymax;
m_BoundaryBox
.
m_Pos
.
y
=
-
500
;
ymax
=
500
;
/* Contours: Recherche des coord min et max et mise a jour du cadre */
for
(
;
pt_edge_mod
!=
NULL
;
pt_edge_mod
=
(
EDGE_MODULE
*
)
pt_edge_mod
->
Pnext
)
for
(
;
pt_edge_mod
!=
NULL
;
pt_edge_mod
=
(
EDGE_MODULE
*
)
pt_edge_mod
->
Pnext
)
{
if
(
pt_edge_mod
->
m_StructType
!=
TYPEEDGEMODULE
)
continue
;
if
(
pt_edge_mod
->
m_StructType
!=
TYPEEDGEMODULE
)
continue
;
width
=
pt_edge_mod
->
m_Width
/
2
;
switch
(
pt_edge_mod
->
m_Shape
)
switch
(
pt_edge_mod
->
m_Shape
)
{
case
S_ARC
:
case
S_CIRCLE
:
{
cx
=
pt_edge_mod
->
m_Start0
.
x
;
cy
=
pt_edge_mod
->
m_Start0
.
y
;
// centre
uxf
=
pt_edge_mod
->
m_End0
.
x
;
uyf
=
pt_edge_mod
->
m_End0
.
y
;
rayon
=
(
int
)
hypot
((
double
)(
cx
-
uxf
),(
double
)
(
cy
-
uyf
)
);
cx
=
pt_edge_mod
->
m_Start0
.
x
;
cy
=
pt_edge_mod
->
m_Start0
.
y
;
// centre
uxf
=
pt_edge_mod
->
m_End0
.
x
;
uyf
=
pt_edge_mod
->
m_End0
.
y
;
rayon
=
(
int
)
hypot
(
(
double
)
(
cx
-
uxf
),
(
double
)
(
cy
-
uyf
)
);
rayon
+=
width
;
m_BoundaryBox
.
m_Pos
.
x
=
min
(
m_BoundaryBox
.
m_Pos
.
x
,
cx
-
rayon
);
m_BoundaryBox
.
m_Pos
.
y
=
min
(
m_BoundaryBox
.
m_Pos
.
y
,
cy
-
rayon
);
xmax
=
max
(
xmax
,
cx
+
rayon
);
ymax
=
max
(
ymax
,
cy
+
rayon
);
m_BoundaryBox
.
m_Pos
.
x
=
min
(
m_BoundaryBox
.
m_Pos
.
x
,
cx
-
rayon
);
m_BoundaryBox
.
m_Pos
.
y
=
min
(
m_BoundaryBox
.
m_Pos
.
y
,
cy
-
rayon
);
xmax
=
max
(
xmax
,
cx
+
rayon
);
ymax
=
max
(
ymax
,
cy
+
rayon
);
break
;
}
default
:
m_BoundaryBox
.
m_Pos
.
x
=
min
(
m_BoundaryBox
.
m_Pos
.
x
,
pt_edge_mod
->
m_Start0
.
x
-
width
);
m_BoundaryBox
.
m_Pos
.
x
=
min
(
m_BoundaryBox
.
m_Pos
.
x
,
pt_edge_mod
->
m_End0
.
x
-
width
);
m_BoundaryBox
.
m_Pos
.
y
=
min
(
m_BoundaryBox
.
m_Pos
.
y
,
pt_edge_mod
->
m_Start0
.
y
-
width
);
m_BoundaryBox
.
m_Pos
.
y
=
min
(
m_BoundaryBox
.
m_Pos
.
y
,
pt_edge_mod
->
m_End0
.
y
-
width
);
xmax
=
max
(
xmax
,
pt_edge_mod
->
m_Start0
.
x
+
width
);
xmax
=
max
(
xmax
,
pt_edge_mod
->
m_End0
.
x
+
width
);
ymax
=
max
(
ymax
,
pt_edge_mod
->
m_Start0
.
y
+
width
);
ymax
=
max
(
ymax
,
pt_edge_mod
->
m_End0
.
y
+
width
);
m_BoundaryBox
.
m_Pos
.
x
=
min
(
m_BoundaryBox
.
m_Pos
.
x
,
pt_edge_mod
->
m_Start0
.
x
-
width
);
m_BoundaryBox
.
m_Pos
.
x
=
min
(
m_BoundaryBox
.
m_Pos
.
x
,
pt_edge_mod
->
m_End0
.
x
-
width
);
m_BoundaryBox
.
m_Pos
.
y
=
min
(
m_BoundaryBox
.
m_Pos
.
y
,
pt_edge_mod
->
m_Start0
.
y
-
width
);
m_BoundaryBox
.
m_Pos
.
y
=
min
(
m_BoundaryBox
.
m_Pos
.
y
,
pt_edge_mod
->
m_End0
.
y
-
width
);
xmax
=
max
(
xmax
,
pt_edge_mod
->
m_Start0
.
x
+
width
);
xmax
=
max
(
xmax
,
pt_edge_mod
->
m_End0
.
x
+
width
);
ymax
=
max
(
ymax
,
pt_edge_mod
->
m_Start0
.
y
+
width
);
ymax
=
max
(
ymax
,
pt_edge_mod
->
m_End0
.
y
+
width
);
break
;
}
}
/* Pads: Recherche des coord min et max et mise a jour du cadre */
for
(
pad
=
m_Pads
;
pad
!=
NULL
;
pad
=
(
D_PAD
*
)
pad
->
Pnext
)
for
(
pad
=
m_Pads
;
pad
!=
NULL
;
pad
=
(
D_PAD
*
)
pad
->
Pnext
)
{
rayon
=
pad
->
m_Rayon
;
cx
=
pad
->
m_Pos0
.
x
;
cy
=
pad
->
m_Pos0
.
y
;
m_BoundaryBox
.
m_Pos
.
x
=
min
(
m_BoundaryBox
.
m_Pos
.
x
,
cx
-
rayon
);
m_BoundaryBox
.
m_Pos
.
y
=
min
(
m_BoundaryBox
.
m_Pos
.
y
,
cy
-
rayon
);
xmax
=
max
(
xmax
,
cx
+
rayon
);
ymax
=
max
(
ymax
,
cy
+
rayon
);
m_BoundaryBox
.
m_Pos
.
x
=
min
(
m_BoundaryBox
.
m_Pos
.
x
,
cx
-
rayon
);
m_BoundaryBox
.
m_Pos
.
y
=
min
(
m_BoundaryBox
.
m_Pos
.
y
,
cy
-
rayon
);
xmax
=
max
(
xmax
,
cx
+
rayon
);
ymax
=
max
(
ymax
,
cy
+
rayon
);
}
m_BoundaryBox
.
SetWidth
(
xmax
-
m_BoundaryBox
.
m_Pos
.
x
);
m_BoundaryBox
.
SetHeight
(
ymax
-
m_BoundaryBox
.
m_Pos
.
y
);
m_BoundaryBox
.
SetWidth
(
xmax
-
m_BoundaryBox
.
m_Pos
.
x
);
m_BoundaryBox
.
SetHeight
(
ymax
-
m_BoundaryBox
.
m_Pos
.
y
);
}
/****************************************/
void
MODULE
::
SetRectangleExinscrit
(
void
)
void
MODULE
::
SetRectangleExinscrit
(
void
)
/****************************************/
/* Analogue a MODULE::Set_Rectangle_Encadrement() mais en coord reelles:
Mise a jour du rectangle d'encadrement reel du module c.a.d en coord PCB
Entree : pointeur sur module
Le rectangle d'encadrement est le rectangle comprenant les contours et les
pads.
Met egalement a jour la surface (.m_Surface) du module.
*/
*
Mise a jour du rectangle d'encadrement reel du module c.a.d en coord PCB
*
Entree : pointeur sur module
*
Le rectangle d'encadrement est le rectangle comprenant les contours et les
*
pads.
*
Met egalement a jour la surface (.m_Surface) du module.
*/
{
EDGE_MODULE
*
EdgeMod
;
D_PAD
*
Pad
;
int
width
;
int
cx
,
cy
,
uxf
,
uyf
,
rayon
;
int
xmax
,
ymax
;
EDGE_MODULE
*
EdgeMod
;
D_PAD
*
Pad
;
int
width
;
int
cx
,
cy
,
uxf
,
uyf
,
rayon
;
int
xmax
,
ymax
;
m_RealBoundaryBox
.
m_Pos
.
x
=
xmax
=
m_Pos
.
x
;
m_RealBoundaryBox
.
m_Pos
.
y
=
ymax
=
m_Pos
.
y
;
/* Contours: Recherche des coord min et max et mise a jour du cadre */
EdgeMod
=
(
EDGE_MODULE
*
)
m_Drawings
;
for
(
;
EdgeMod
!=
NULL
;
EdgeMod
=
(
EDGE_MODULE
*
)
EdgeMod
->
Pnext
)
EdgeMod
=
(
EDGE_MODULE
*
)
m_Drawings
;
for
(
;
EdgeMod
!=
NULL
;
EdgeMod
=
(
EDGE_MODULE
*
)
EdgeMod
->
Pnext
)
{
if
(
EdgeMod
->
m_StructType
!=
TYPEEDGEMODULE
)
continue
;
if
(
EdgeMod
->
m_StructType
!=
TYPEEDGEMODULE
)
continue
;
width
=
EdgeMod
->
m_Width
/
2
;
switch
(
EdgeMod
->
m_Shape
)
switch
(
EdgeMod
->
m_Shape
)
{
case
S_ARC
:
case
S_CIRCLE
:
{
cx
=
EdgeMod
->
m_Start
.
x
;
cy
=
EdgeMod
->
m_Start
.
y
;
// centre
uxf
=
EdgeMod
->
m_End
.
x
;
uyf
=
EdgeMod
->
m_End
.
y
;
rayon
=
(
int
)
hypot
((
double
)(
cx
-
uxf
),(
double
)
(
cy
-
uyf
)
);
cx
=
EdgeMod
->
m_Start
.
x
;
cy
=
EdgeMod
->
m_Start
.
y
;
// centre
uxf
=
EdgeMod
->
m_End
.
x
;
uyf
=
EdgeMod
->
m_End
.
y
;
rayon
=
(
int
)
hypot
(
(
double
)
(
cx
-
uxf
),
(
double
)
(
cy
-
uyf
)
);
rayon
+=
width
;
m_RealBoundaryBox
.
m_Pos
.
x
=
min
(
m_RealBoundaryBox
.
m_Pos
.
x
,
cx
-
rayon
);
m_RealBoundaryBox
.
m_Pos
.
y
=
min
(
m_RealBoundaryBox
.
m_Pos
.
y
,
cy
-
rayon
);
xmax
=
max
(
xmax
,
cx
+
rayon
);
ymax
=
max
(
ymax
,
cy
+
rayon
);
m_RealBoundaryBox
.
m_Pos
.
x
=
min
(
m_RealBoundaryBox
.
m_Pos
.
x
,
cx
-
rayon
);
m_RealBoundaryBox
.
m_Pos
.
y
=
min
(
m_RealBoundaryBox
.
m_Pos
.
y
,
cy
-
rayon
);
xmax
=
max
(
xmax
,
cx
+
rayon
);
ymax
=
max
(
ymax
,
cy
+
rayon
);
break
;
}
default
:
m_RealBoundaryBox
.
m_Pos
.
x
=
min
(
m_RealBoundaryBox
.
m_Pos
.
x
,
EdgeMod
->
m_Start
.
x
-
width
);
m_RealBoundaryBox
.
m_Pos
.
x
=
min
(
m_RealBoundaryBox
.
m_Pos
.
x
,
EdgeMod
->
m_End
.
x
-
width
);
m_RealBoundaryBox
.
m_Pos
.
y
=
min
(
m_RealBoundaryBox
.
m_Pos
.
y
,
EdgeMod
->
m_Start
.
y
-
width
);
m_RealBoundaryBox
.
m_Pos
.
y
=
min
(
m_RealBoundaryBox
.
m_Pos
.
y
,
EdgeMod
->
m_End
.
y
-
width
);
xmax
=
max
(
xmax
,
EdgeMod
->
m_Start
.
x
+
width
);
xmax
=
max
(
xmax
,
EdgeMod
->
m_End
.
x
+
width
);
ymax
=
max
(
ymax
,
EdgeMod
->
m_Start
.
y
+
width
);
ymax
=
max
(
ymax
,
EdgeMod
->
m_End
.
y
+
width
);
m_RealBoundaryBox
.
m_Pos
.
x
=
min
(
m_RealBoundaryBox
.
m_Pos
.
x
,
EdgeMod
->
m_Start
.
x
-
width
);
m_RealBoundaryBox
.
m_Pos
.
x
=
min
(
m_RealBoundaryBox
.
m_Pos
.
x
,
EdgeMod
->
m_End
.
x
-
width
);
m_RealBoundaryBox
.
m_Pos
.
y
=
min
(
m_RealBoundaryBox
.
m_Pos
.
y
,
EdgeMod
->
m_Start
.
y
-
width
);
m_RealBoundaryBox
.
m_Pos
.
y
=
min
(
m_RealBoundaryBox
.
m_Pos
.
y
,
EdgeMod
->
m_End
.
y
-
width
);
xmax
=
max
(
xmax
,
EdgeMod
->
m_Start
.
x
+
width
);
xmax
=
max
(
xmax
,
EdgeMod
->
m_End
.
x
+
width
);
ymax
=
max
(
ymax
,
EdgeMod
->
m_Start
.
y
+
width
);
ymax
=
max
(
ymax
,
EdgeMod
->
m_End
.
y
+
width
);
break
;
}
}
/* Pads: Recherche des coord min et max et mise a jour du cadre */
for
(
Pad
=
m_Pads
;
Pad
!=
NULL
;
Pad
=
(
D_PAD
*
)
Pad
->
Pnext
)
for
(
Pad
=
m_Pads
;
Pad
!=
NULL
;
Pad
=
(
D_PAD
*
)
Pad
->
Pnext
)
{
rayon
=
Pad
->
m_Rayon
;
cx
=
Pad
->
m_Pos
.
x
;
cy
=
Pad
->
m_Pos
.
y
;
m_RealBoundaryBox
.
m_Pos
.
x
=
min
(
m_RealBoundaryBox
.
m_Pos
.
x
,
cx
-
rayon
);
m_RealBoundaryBox
.
m_Pos
.
y
=
min
(
m_RealBoundaryBox
.
m_Pos
.
y
,
cy
-
rayon
);
xmax
=
max
(
xmax
,
cx
+
rayon
);
ymax
=
max
(
ymax
,
cy
+
rayon
);
}
m_RealBoundaryBox
.
SetWidth
(
xmax
-
m_RealBoundaryBox
.
m_Pos
.
x
);
m_RealBoundaryBox
.
SetHeight
(
ymax
-
m_RealBoundaryBox
.
m_Pos
.
y
);
m_Surface
=
ABS
((
float
)
m_RealBoundaryBox
.
GetWidth
()
*
m_RealBoundaryBox
.
GetHeight
());
m_RealBoundaryBox
.
m_Pos
.
x
=
min
(
m_RealBoundaryBox
.
m_Pos
.
x
,
cx
-
rayon
);
m_RealBoundaryBox
.
m_Pos
.
y
=
min
(
m_RealBoundaryBox
.
m_Pos
.
y
,
cy
-
rayon
);
xmax
=
max
(
xmax
,
cx
+
rayon
);
ymax
=
max
(
ymax
,
cy
+
rayon
);
}
m_RealBoundaryBox
.
SetWidth
(
xmax
-
m_RealBoundaryBox
.
m_Pos
.
x
);
m_RealBoundaryBox
.
SetHeight
(
ymax
-
m_RealBoundaryBox
.
m_Pos
.
y
);
m_Surface
=
ABS
(
(
float
)
m_RealBoundaryBox
.
GetWidth
()
*
m_RealBoundaryBox
.
GetHeight
()
);
}
/*******************************************************/
void
MODULE
::
Display_Infos
(
WinEDA_BasePcbFrame
*
frame
)
void
MODULE
::
Display_Infos
(
WinEDA_BasePcbFrame
*
frame
)
/*******************************************************/
{
int
nbpad
;
char
bufcar
[
512
],
Line
[
512
];
int
pos
;
bool
flag
=
FALSE
;
wxString
msg
;
frame
->
MsgPanel
->
EraseMsgBox
()
;
/* Effacement de la zone message */
if
(
frame
->
m_Ident
!=
PCB_FRAME
)
flag
=
TRUE
;
int
nbpad
;
char
bufcar
[
512
],
Line
[
512
];
int
pos
;
bool
flag
=
FALSE
;
wxString
msg
;
frame
->
MsgPanel
->
EraseMsgBox
();
/* Effacement de la zone message */
if
(
frame
->
m_Ident
!=
PCB_FRAME
)
flag
=
TRUE
;
pos
=
1
;
Affiche_1_Parametre
(
frame
,
pos
,
m_Reference
->
m_Text
,
m_Value
->
m_Text
,
DARKCYAN
);
Affiche_1_Parametre
(
frame
,
pos
,
m_Reference
->
m_Text
,
m_Value
->
m_Text
,
DARKCYAN
);
/* Affiche signature temporelle ou date de modif (en edition de modules) */
pos
+=
14
;
if
(
flag
)
// Affichage date de modification (utile en Module Editor)
{
strcpy
(
Line
,
ctime
(
&
m_LastEdit_Time
)
);
strtok
(
Line
,
"
\n\r
"
);
strcpy
(
bufcar
,
strtok
(
NULL
,
"
\n\r
"
)
);
strcat
(
bufcar
,
" "
);
strcat
(
bufcar
,
strtok
(
NULL
,
"
\n\r
"
)
);
strcat
(
bufcar
,
", "
);
strtok
(
NULL
,
"
\n\r
"
);
strcat
(
bufcar
,
strtok
(
NULL
,
"
\n\r
"
)
);
msg
=
CONV_FROM_UTF8
(
bufcar
);
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Last Change"
),
msg
,
BROWN
);
if
(
flag
)
// Affichage date de modification (utile en Module Editor)
{
strcpy
(
Line
,
ctime
(
&
m_LastEdit_Time
)
);
strtok
(
Line
,
"
\n\r
"
);
strcpy
(
bufcar
,
strtok
(
NULL
,
"
\n\r
"
)
);
strcat
(
bufcar
,
" "
);
strcat
(
bufcar
,
strtok
(
NULL
,
"
\n\r
"
)
);
strcat
(
bufcar
,
", "
);
strtok
(
NULL
,
"
\n\r
"
);
strcat
(
bufcar
,
strtok
(
NULL
,
"
\n\r
"
)
);
msg
=
CONV_FROM_UTF8
(
bufcar
);
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Last Change"
),
msg
,
BROWN
);
pos
+=
4
;
}
else
{
msg
.
Printf
(
wxT
(
"%8.8lX"
),
m_TimeStamp
);
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"TimeStamp"
),
msg
,
BROWN
);
msg
.
Printf
(
wxT
(
"%8.8lX"
),
m_TimeStamp
);
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"TimeStamp"
),
msg
,
BROWN
);
}
pos
+=
6
;
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Layer"
),
ReturnPcbLayerName
(
m_Layer
),
RED
)
;
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Layer"
),
ReturnPcbLayerName
(
m_Layer
),
RED
)
;
pos
+=
6
;
EDA_BaseStruct
*
PtStruct
=
m_Pads
;
EDA_BaseStruct
*
PtStruct
=
m_Pads
;
nbpad
=
0
;
while
(
PtStruct
)
{
nbpad
++
;
PtStruct
=
PtStruct
->
Pnext
;
}
msg
.
Printf
(
wxT
(
"%d"
),
nbpad
);
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Pads"
),
msg
,
BLUE
);
while
(
PtStruct
)
{
nbpad
++
;
PtStruct
=
PtStruct
->
Pnext
;
}
msg
.
Printf
(
wxT
(
"%d"
),
nbpad
);
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Pads"
),
msg
,
BLUE
);
pos
+=
4
;
msg
=
wxT
(
".."
);
if
(
m_ModuleStatus
&
MODULE_is_LOCKED
)
msg
[
0
]
=
'F'
;
if
(
m_ModuleStatus
&
MODULE_is_PLACED
)
msg
[
1
]
=
'P'
;
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Stat"
),
msg
,
MAGENTA
);
msg
=
wxT
(
".."
);
if
(
m_ModuleStatus
&
MODULE_is_LOCKED
)
msg
[
0
]
=
'F'
;
if
(
m_ModuleStatus
&
MODULE_is_PLACED
)
msg
[
1
]
=
'P'
;
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Stat"
),
msg
,
MAGENTA
);
pos
+=
4
;
msg
.
Printf
(
wxT
(
"%.1f"
),(
float
)
m_Orient
/
10
);
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Orient"
),
msg
,
BROWN
);
msg
.
Printf
(
wxT
(
"%.1f"
),
(
float
)
m_Orient
/
10
);
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Orient"
),
msg
,
BROWN
);
pos
+=
5
;
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Module"
),
m_LibRef
,
BLUE
);
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"Module"
),
m_LibRef
,
BLUE
);
pos
+=
9
;
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"3D-Shape"
),
m_3D_Drawings
->
m_Shape3DName
,
RED
);
Affiche_1_Parametre
(
frame
,
pos
,
_
(
"3D-Shape"
),
m_3D_Drawings
->
m_Shape3DName
,
RED
);
pos
+=
14
;
wxString
doc
=
_
(
"Doc: "
)
+
m_Doc
;
wxString
keyword
=
_
(
"KeyW: "
)
+
m_KeyWord
;
Affiche_1_Parametre
(
frame
,
pos
,
doc
,
keyword
,
BLACK
);
wxString
doc
=
_
(
"Doc: "
)
+
m_Doc
;
wxString
keyword
=
_
(
"KeyW: "
)
+
m_KeyWord
;
Affiche_1_Parametre
(
frame
,
pos
,
doc
,
keyword
,
BLACK
);
}
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
void
MODULE
::
Show
(
int
nestLevel
,
std
::
ostream
&
os
)
{
// for now, make it look like XML, expand on this later.
NestedSpace
(
nestLevel
,
os
)
<<
'<'
<<
ReturnClassName
().
mb_str
()
<<
" ref=
\"
"
<<
m_Reference
->
m_Text
.
mb_str
()
<<
"
\"
value=
\"
"
<<
m_Value
->
m_Text
.
mb_str
()
<<
"
\"
>
\n
"
;
EDA_BaseStruct
*
p
=
m_Drawings
;
for
(
;
p
;
p
=
p
->
Pnext
)
p
->
Show
(
nestLevel
+
1
,
os
);
EDA_BaseStruct
*
kid
=
m_Son
;
for
(
;
kid
;
kid
=
kid
->
Pnext
)
{
kid
->
Show
(
nestLevel
+
1
,
os
);
}
NestedSpace
(
nestLevel
,
os
)
<<
"</"
<<
ReturnClassName
().
mb_str
()
<<
">
\n
"
;
}
#endif
pcbnew/class_module.h
View file @
5748b791
/*******************************************************/
/* class_module.h : module description (excepted pads) */
/*******************************************************/
/*******************************************************/
/* class_module.h : module description (excepted pads) */
/*******************************************************/
class
Pcb3D_GLCanvas
;
class
Struct3D_Master
;
/************************************/
/* Modules (footprints) description */
/* pad are in class_pad.xx */
/************************************/
/************************************/
/* Modules (footprints) description */
/* pad are in class_pad.xx */
/************************************/
/* Format des modules:
Description generale
Description segments contour
Description textes
Description pastilles
*/
*
Description generale
*
Description segments contour
*
Description textes
*
Description pastilles
*/
/* Flags :*/
...
...
@@ -24,9 +24,10 @@ enum Mod_Attribut /* Attributs d'un module */
{
MOD_DEFAULT
=
0
,
/* Type default */
MOD_CMS
=
1
,
/* Pour module apparaissant dans les
fichiers de placement automatique (principalement modules CMS */
*
fichiers de placement automatique (principalement modules CMS */
MOD_VIRTUAL
=
2
/* Module virtuel constitue par un dessin sur circuit
(connecteur, trou de percage..) */
* (connecteur, trou de percage..) */
};
/* flags for autoplace and autoroute (.m_ModuleStatus member) */
...
...
@@ -34,24 +35,24 @@ enum Mod_Attribut /* Attributs d'un module */
#define MODULE_is_PLACED 0x02
/* In autoplace: module automatically placed */
#define MODULE_to_PLACE 0x04
/* In autoplace: module waiting for autoplace */
class
MODULE
:
public
EDA_BaseStruct
class
MODULE
:
public
EDA_BaseStruct
{
public
:
int
m_Layer
;
// layer number
wxPoint
m_Pos
;
// Real coord on board
D_PAD
*
m_Pads
;
/* Pad list (linked list) */
EDA_BaseStruct
*
m_Drawings
;
/* Graphic items list (linked list) */
Struct3D_Master
*
m_3D_Drawings
;
/* Pointeur sur la liste des elements de trace 3D*/
TEXTE_MODULE
*
m_Reference
;
// texte reference du composant (U34, R18..)
TEXTE_MODULE
*
m_Value
;
// texte valeur du composant (74LS00, 22K..)
D_PAD
*
m_Pads
;
/* Pad list (linked list) */
EDA_BaseStruct
*
m_Drawings
;
/* Graphic items list (linked list) */
Struct3D_Master
*
m_3D_Drawings
;
/* Pointeur sur la liste des elements de trace 3D*/
TEXTE_MODULE
*
m_Reference
;
// texte reference du composant (U34, R18..)
TEXTE_MODULE
*
m_Value
;
// texte valeur du composant (74LS00, 22K..)
wxString
m_LibRef
;
/* nom du module en librairie */
int
m_Attributs
;
/* Flags bits a bit ( voir enum Mod_Attribut ) */
int
m_Orient
;
/* orientation en 1/10 degres */
int
flag
;
/* flag utilise en trace rastnest et routage auto */
int
m_Orient
;
/* orientation en 1/10 degres */
int
flag
;
/* flag utilise en trace rastnest et routage auto */
int
m_ModuleStatus
;
/* For autoplace: flags (LOCKED, AUTOPLACED) */
EDA_Rect
m_BoundaryBox
;
/* position/taille du cadre de reperage (coord locales)*/
EDA_Rect
m_RealBoundaryBox
;
/* position/taille du module (coord relles) */
EDA_Rect
m_RealBoundaryBox
;
/* position/taille du module (coord relles) */
int
m_PadNum
;
// Nombre total de pads
int
m_AltPadNum
;
// en placement auto Nombre de pads actifs pour
// les calculs
...
...
@@ -67,23 +68,24 @@ public:
wxString
m_KeyWord
;
// Liste des mots cles relatifs au module
public
:
MODULE
(
BOARD
*
parent
);
MODULE
(
MODULE
*
module
);
~
MODULE
(
void
);
MODULE
(
BOARD
*
parent
);
MODULE
(
MODULE
*
module
);
~
MODULE
(
void
);
void
Copy
(
MODULE
*
Module
);
// Copy structure
MODULE
*
Next
(
void
)
{
return
(
MODULE
*
)
Pnext
;
}
void
Copy
(
MODULE
*
Module
);
// Copy structure
void
Set_Rectangle_Encadrement
(
void
);
/* mise a jour du rect d'encadrement
en coord locales (orient 0 et origine = pos module) */
MODULE
*
Next
(
void
)
{
return
(
MODULE
*
)
Pnext
;
}
void
SetRectangleExinscrit
(
void
);
/* mise a jour du rect d'encadrement
et de la surface en coord reelles */
void
Set_Rectangle_Encadrement
(
void
);
/* mise a jour du rect d'encadrement
* en coord locales (orient 0 et origine = pos module) */
void
SetRectangleExinscrit
(
void
);
/* mise a jour du rect d'encadrement
* et de la surface en coord reelles */
// deplacements
void
SetPosition
(
const
wxPoint
&
newpos
);
void
SetOrientation
(
int
newangle
);
void
SetPosition
(
const
wxPoint
&
newpos
);
void
SetOrientation
(
int
newangle
);
/* supprime du chainage la structure Struct */
void
UnLink
(
void
);
...
...
@@ -114,21 +116,32 @@ public:
/* Readind and writing data on files */
int
WriteDescr
(
FILE
*
File
);
int
Write_3D_Descr
(
FILE
*
File
);
int
ReadDescr
(
FILE
*
File
,
int
*
LineNum
=
NULL
);
int
Read_3D_Descr
(
FILE
*
File
,
int
*
LineNum
=
NULL
);
int
WriteDescr
(
FILE
*
File
);
int
Write_3D_Descr
(
FILE
*
File
);
int
ReadDescr
(
FILE
*
File
,
int
*
LineNum
=
NULL
);
int
Read_3D_Descr
(
FILE
*
File
,
int
*
LineNum
=
NULL
);
/* drawing functions */
void
Draw
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
draw_mode
);
void
Draw3D
(
Pcb3D_GLCanvas
*
glcanvas
);
void
DrawEdgesOnly
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
draw_mode
);
void
DrawAncre
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
dim_ancre
,
int
draw_mode
);
void
Draw
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
draw_mode
);
void
Draw3D
(
Pcb3D_GLCanvas
*
glcanvas
);
void
DrawEdgesOnly
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
draw_mode
);
void
DrawAncre
(
WinEDA_DrawPanel
*
panel
,
wxDC
*
DC
,
const
wxPoint
&
offset
,
int
dim_ancre
,
int
draw_mode
);
/* miscellaneous */
void
Display_Infos
(
WinEDA_BasePcbFrame
*
frame
);
};
void
Display_Infos
(
WinEDA_BasePcbFrame
*
frame
);
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.
* @param nestLevel An aid to prettier tree indenting, and is the level
* of nesting of this object within the overall tree.
* @param os The ostream& to output to.
*/
virtual
void
Show
(
int
nestLevel
,
std
::
ostream
&
os
);
#endif
};
pcbnew/files.cpp
View file @
5748b791
/***************************************************/
/* Files.cpp: Lecture / Sauvegarde des fichiers PCB */
/***************************************************/
/***************************************************/
/* Files.cpp: Lecture / Sauvegarde des fichiers PCB */
/***************************************************/
#include "fctsys.h"
...
...
@@ -11,30 +11,31 @@
/****************************************************/
void
WinEDA_PcbFrame
::
Files_io
(
wxCommandEvent
&
event
)
void
WinEDA_PcbFrame
::
Files_io
(
wxCommandEvent
&
event
)
/****************************************************/
/* Gestion generale des commandes de lecture de fichiers
*/
*/
{
int
id
=
event
.
GetId
();
wxClientDC
dc
(
DrawPanel
);
wxString
msg
;
int
id
=
event
.
GetId
();
wxClientDC
dc
(
DrawPanel
);
wxString
msg
;
DrawPanel
->
PrepareGraphicContext
(
&
dc
);
DrawPanel
->
PrepareGraphicContext
(
&
dc
);
// Arret des commandes en cours
if
(
DrawPanel
->
ManageCurseur
&&
DrawPanel
->
ForceCloseManageCurseur
)
{
DrawPanel
->
ForceCloseManageCurseur
(
DrawPanel
,
&
dc
);
DrawPanel
->
ForceCloseManageCurseur
(
DrawPanel
,
&
dc
);
}
SetToolID
(
0
,
wxCURSOR_ARROW
,
wxEmptyString
);
SetToolID
(
0
,
wxCURSOR_ARROW
,
wxEmptyString
);
switch
(
id
)
switch
(
id
)
{
case
ID_MENU_LOAD_FILE
:
case
ID_LOAD_FILE
:
Clear_Pcb
(
&
dc
,
TRUE
);
LoadOnePcbFile
(
wxEmptyString
,
&
dc
,
FALSE
);
Clear_Pcb
(
&
dc
,
TRUE
);
LoadOnePcbFile
(
wxEmptyString
,
&
dc
,
FALSE
);
ReCreateAuxiliaryToolbar
();
break
;
...
...
@@ -42,45 +43,46 @@ wxString msg;
case
ID_MENU_RECOVER_BOARD
:
{
wxString
filename
,
oldfilename
=
GetScreen
()
->
m_FileName
;
if
(
id
==
ID_MENU_RECOVER_BOARD
)
if
(
id
==
ID_MENU_RECOVER_BOARD
)
{
filename
=
g_SaveFileName
+
PcbExtBuffer
;
}
else
{
filename
=
oldfilename
;
ChangeFileNameExt
(
filename
,
wxT
(
".000"
)
);
ChangeFileNameExt
(
filename
,
wxT
(
".000"
)
);
}
if
(
!
wxFileExists
(
filename
)
)
if
(
!
wxFileExists
(
filename
)
)
{
msg
=
_
(
"Recovery file "
)
+
filename
+
_
(
" not found"
);
DisplayInfo
(
this
,
msg
);
msg
=
_
(
"Recovery file "
)
+
filename
+
_
(
" not found"
);
DisplayInfo
(
this
,
msg
);
break
;
}
else
{
msg
=
_
(
"Ok to load Recovery file "
)
+
filename
;
if
(
!
IsOK
(
this
,
msg
)
)
break
;
msg
=
_
(
"Ok to load Recovery file "
)
+
filename
;
if
(
!
IsOK
(
this
,
msg
)
)
break
;
}
Clear_Pcb
(
&
dc
,
TRUE
);
LoadOnePcbFile
(
filename
,
&
dc
,
FALSE
);
Clear_Pcb
(
&
dc
,
TRUE
);
LoadOnePcbFile
(
filename
,
&
dc
,
FALSE
);
GetScreen
()
->
m_FileName
=
oldfilename
;
SetTitle
(
GetScreen
()
->
m_FileName
);
SetTitle
(
GetScreen
()
->
m_FileName
);
ReCreateAuxiliaryToolbar
();
}
break
;
case
ID_MENU_APPEND_FILE
:
case
ID_APPEND_FILE
:
LoadOnePcbFile
(
wxEmptyString
,
&
dc
,
TRUE
);
LoadOnePcbFile
(
wxEmptyString
,
&
dc
,
TRUE
);
break
;
case
ID_MENU_NEW_BOARD
:
case
ID_NEW_BOARD
:
Clear_Pcb
(
&
dc
,
TRUE
);
GetScreen
()
->
m_FileName
.
Printf
(
wxT
(
"%s%cnoname%s"
),
wxGetCwd
().
GetData
(),
DIR_SEP
,
PcbExtBuffer
.
GetData
()
);
SetTitle
(
GetScreen
()
->
m_FileName
);
Clear_Pcb
(
&
dc
,
TRUE
);
GetScreen
()
->
m_FileName
.
Printf
(
wxT
(
"%s%cnoname%s"
),
wxGetCwd
().
GetData
(),
DIR_SEP
,
PcbExtBuffer
.
GetData
()
);
SetTitle
(
GetScreen
()
->
m_FileName
);
break
;
case
ID_LOAD_FILE_1
:
...
...
@@ -93,53 +95,53 @@ wxString msg;
case
ID_LOAD_FILE_8
:
case
ID_LOAD_FILE_9
:
case
ID_LOAD_FILE_10
:
Clear_Pcb
(
&
dc
,
TRUE
);
wxSetWorkingDirectory
(
wxPathOnly
(
GetLastProject
(
id
-
ID_LOAD_FILE_1
))
);
LoadOnePcbFile
(
GetLastProject
(
id
-
ID_LOAD_FILE_1
).
GetData
(),
&
dc
,
FALSE
);
Clear_Pcb
(
&
dc
,
TRUE
);
wxSetWorkingDirectory
(
wxPathOnly
(
GetLastProject
(
id
-
ID_LOAD_FILE_1
)
)
);
LoadOnePcbFile
(
GetLastProject
(
id
-
ID_LOAD_FILE_1
).
GetData
(),
&
dc
,
FALSE
);
ReCreateAuxiliaryToolbar
();
break
;
case
ID_SAVE_BOARD
:
case
ID_MENU_SAVE_BOARD
:
SavePcbFile
(
GetScreen
()
->
m_FileName
);
SavePcbFile
(
GetScreen
()
->
m_FileName
);
break
;
case
ID_MENU_SAVE_BOARD_AS
:
SavePcbFile
(
wxEmptyString
);
SavePcbFile
(
wxEmptyString
);
break
;
case
ID_PCB_GEN_CMP_FILE
:
RecreateCmpFileFromBoard
();
break
;
default
:
DisplayError
(
this
,
wxT
(
"File_io Internal Error"
)
);
break
;
default
:
DisplayError
(
this
,
wxT
(
"File_io Internal Error"
)
);
break
;
}
}
/*****************************************************************************************/
int
WinEDA_PcbFrame
::
LoadOnePcbFile
(
const
wxString
&
FullFileName
,
wxDC
*
DC
,
bool
Append
)
int
WinEDA_PcbFrame
::
LoadOnePcbFile
(
const
wxString
&
FullFileName
,
wxDC
*
DC
,
bool
Append
)
/******************************************************************************************/
/*
Lecture d'un fichier PCB, le nom etant dans PcbNameBuffer.s
retourne:
0 si fichier non lu ( annulation de commande ... )
1 si OK
*/
*
Lecture d'un fichier PCB, le nom etant dans PcbNameBuffer.s
*
retourne:
*
0 si fichier non lu ( annulation de commande ... )
*
1 si OK
*/
{
int
ii
;
FILE
*
source
;
wxString
msg
;
int
ii
;
FILE
*
source
;
wxString
msg
;
ActiveScreen
=
GetScreen
();
if
(
GetScreen
()
->
IsModify
()
&&
!
Append
)
{
if
(
!
IsOK
(
this
,
_
(
"Board Modified: Continue ?"
))
)
return
(
0
)
;
if
(
!
IsOK
(
this
,
_
(
"Board Modified: Continue ?"
)
)
)
return
0
;
}
m_SelTrackWidthBox_Changed
=
TRUE
;
...
...
@@ -152,11 +154,11 @@ wxString msg;
m_Pcb
->
m_Status_Pcb
=
0
;
}
if
(
FullFileName
==
wxEmptyString
)
if
(
FullFileName
==
wxEmptyString
)
{
msg
=
wxT
(
"*"
)
+
PcbExtBuffer
;
msg
=
wxT
(
"*"
)
+
PcbExtBuffer
;
wxString
FileName
=
EDA_FileSelector
(
_
(
"Board files:"
),
EDA_FileSelector
(
_
(
"Board files:"
),
wxEmptyString
,
/* Chemin par defaut */
GetScreen
()
->
m_FileName
,
/* nom fichier par defaut */
PcbExtBuffer
,
/* extension par defaut */
...
...
@@ -165,90 +167,98 @@ wxString msg;
wxFD_OPEN
,
FALSE
);
if
(
FileName
==
wxEmptyString
)
return
FALSE
;
if
(
FileName
==
wxEmptyString
)
return
FALSE
;
GetScreen
()
->
m_FileName
=
FileName
;
}
else
GetScreen
()
->
m_FileName
=
FullFileName
;
else
GetScreen
()
->
m_FileName
=
FullFileName
;
/////////////////////////
/* Lecture Fichier PCB */
/////////////////////////
source
=
wxFopen
(
GetScreen
()
->
m_FileName
,
wxT
(
"rt"
)
);
if
(
source
==
NULL
)
source
=
wxFopen
(
GetScreen
()
->
m_FileName
,
wxT
(
"rt"
)
);
if
(
source
==
NULL
)
{
msg
.
Printf
(
_
(
"File <%s> not found"
),
GetScreen
()
->
m_FileName
.
GetData
())
;
DisplayError
(
this
,
msg
)
;
return
(
0
)
;
msg
.
Printf
(
_
(
"File <%s> not found"
),
GetScreen
()
->
m_FileName
.
GetData
()
)
;
DisplayError
(
this
,
msg
)
;
return
0
;
}
/* Lecture de l'entete et TEST si PCB format ASCII */
GetLine
(
source
,
cbuf
,
&
ii
);
if
(
strncmp
(
cbuf
,
"PCBNEW-BOARD"
,
12
)
!=
0
)
GetLine
(
source
,
cbuf
,
&
ii
);
if
(
strncmp
(
cbuf
,
"PCBNEW-BOARD"
,
12
)
!=
0
)
{
fclose
(
source
);
DisplayError
(
this
,
wxT
(
"Unknown file type"
)
);
return
(
0
)
;
fclose
(
source
);
DisplayError
(
this
,
wxT
(
"Unknown file type"
)
);
return
0
;
}
SetTitle
(
GetScreen
()
->
m_FileName
);
SetLastProject
(
GetScreen
()
->
m_FileName
);
SetTitle
(
GetScreen
()
->
m_FileName
);
SetLastProject
(
GetScreen
()
->
m_FileName
);
// Rechargement de la configuration:
wxSetWorkingDirectory
(
wxPathOnly
(
GetScreen
()
->
m_FileName
)
);
if
(
Append
)
ReadPcbFile
(
DC
,
source
,
TRUE
);
wxSetWorkingDirectory
(
wxPathOnly
(
GetScreen
()
->
m_FileName
)
);
if
(
Append
)
ReadPcbFile
(
DC
,
source
,
TRUE
);
else
{
Read_Config
(
GetScreen
()
->
m_FileName
);
Read_Config
(
GetScreen
()
->
m_FileName
);
// Mise a jour du toolbar d'options
m_DisplayPcbTrackFill
=
DisplayOpt
.
DisplayPcbTrackFill
;
m_DisplayModText
=
DisplayOpt
.
DisplayModText
;
m_DisplayModText
=
DisplayOpt
.
DisplayModText
;
m_DisplayModEdge
=
DisplayOpt
.
DisplayModEdge
;
m_DisplayPadFill
=
DisplayOpt
.
DisplayPadFill
;
ReadPcbFile
(
DC
,
source
,
FALSE
);
ReadPcbFile
(
DC
,
source
,
FALSE
);
}
fclose
(
source
);
fclose
(
source
);
GetScreen
()
->
ClrModify
();
if
(
Append
)
{
GetScreen
()
->
SetModify
();
GetScreen
()
->
m_FileName
.
Printf
(
wxT
(
"%s%cnoname%s"
),
wxGetCwd
().
GetData
(),
DIR_SEP
,
PcbExtBuffer
.
GetData
()
);
GetScreen
()
->
m_FileName
.
Printf
(
wxT
(
"%s%cnoname%s"
),
wxGetCwd
().
GetData
(),
DIR_SEP
,
PcbExtBuffer
.
GetData
()
);
}
/* liste des pads recalculee avec Affichage des messages d'erreur */
build_liste_pads
();
Affiche_Infos_Status_Pcb
(
this
);
Affiche_Infos_Status_Pcb
(
this
);
g_SaveTime
=
time
(
NULL
);
return
(
1
);
}
g_SaveTime
=
time
(
NULL
);
#if defined(DEBUG)
// output the board object tree to stdout:
m_Pcb
->
Show
(
0
,
std
::
cout
);
#endif
return
1
;
}
/***********************************************************/
bool
WinEDA_PcbFrame
::
SavePcbFile
(
const
wxString
&
FileName
)
bool
WinEDA_PcbFrame
::
SavePcbFile
(
const
wxString
&
FileName
)
/************************************************************/
/* Sauvegarde du fichier PCB en format ASCII
*/
*/
{
wxString
old_name
,
FullFileName
,
msg
;
bool
saveok
=
TRUE
;
FILE
*
dest
;
wxString
old_name
,
FullFileName
,
msg
;
bool
saveok
=
TRUE
;
FILE
*
dest
;
if
(
FileName
==
wxEmptyString
)
{
msg
=
wxT
(
"*"
)
+
PcbExtBuffer
;
FullFileName
=
EDA_FileSelector
(
_
(
"Board files:"
),
msg
=
wxT
(
"*"
)
+
PcbExtBuffer
;
FullFileName
=
EDA_FileSelector
(
_
(
"Board files:"
),
wxEmptyString
,
/* Chemin par defaut */
GetScreen
()
->
m_FileName
,
/* nom fichier par defaut */
PcbExtBuffer
,
/* extension par defaut */
...
...
@@ -257,57 +267,58 @@ FILE * dest;
wxFD_SAVE
,
FALSE
);
if
(
FullFileName
==
wxEmptyString
)
return
FALSE
;
if
(
FullFileName
==
wxEmptyString
)
return
FALSE
;
GetScreen
()
->
m_FileName
=
FullFileName
;
}
else
GetScreen
()
->
m_FileName
=
FileName
;
else
GetScreen
()
->
m_FileName
=
FileName
;
/* mise a jour date si modifications */
if
(
GetScreen
()
->
IsModify
()
)
if
(
GetScreen
()
->
IsModify
()
)
{
GetScreen
()
->
m_Date
=
GenDate
();
}
/* Calcul du nom du fichier a creer */
FullFileName
=
MakeFileName
(
wxEmptyString
,
GetScreen
()
->
m_FileName
,
PcbExtBuffer
);
FullFileName
=
MakeFileName
(
wxEmptyString
,
GetScreen
()
->
m_FileName
,
PcbExtBuffer
);
/* Calcul du nom du fichier de sauvegarde */
old_name
=
FullFileName
;
ChangeFileNameExt
(
old_name
,
wxT
(
".000"
)
);
ChangeFileNameExt
(
old_name
,
wxT
(
".000"
)
);
/* Changement du nom de l'ancien fichier s'il existe */
if
(
wxFileExists
(
FullFileName
)
)
if
(
wxFileExists
(
FullFileName
)
)
{
/* conversion en *.000 de l'ancien fichier */
wxRemoveFile
(
old_name
);
/* S'il y a une ancienne sauvegarde */
if
(
!
wxRenameFile
(
FullFileName
,
old_name
)
)
wxRemoveFile
(
old_name
);
/* S'il y a une ancienne sauvegarde */
if
(
!
wxRenameFile
(
FullFileName
,
old_name
)
)
{
msg
=
_
(
"Warning: unable to create bakfile "
)
+
old_name
;
DisplayError
(
this
,
msg
,
15
)
;
msg
=
_
(
"Warning: unable to create bakfile "
)
+
old_name
;
DisplayError
(
this
,
msg
,
15
)
;
saveok
=
FALSE
;
}
}
else
{
old_name
=
wxEmptyString
;
saveok
=
FALSE
;
}
/* Sauvegarde de l'ancien fichier */
dest
=
wxFopen
(
FullFileName
,
wxT
(
"wt"
)
);
if
(
dest
==
0
)
dest
=
wxFopen
(
FullFileName
,
wxT
(
"wt"
)
);
if
(
dest
==
0
)
{
msg
=
_
(
"Unable to create "
)
+
FullFileName
;
DisplayError
(
this
,
msg
)
;
msg
=
_
(
"Unable to create "
)
+
FullFileName
;
DisplayError
(
this
,
msg
)
;
saveok
=
FALSE
;
}
if
(
dest
)
{
GetScreen
()
->
m_FileName
=
FullFileName
;
SetTitle
(
GetScreen
()
->
m_FileName
);
SavePcbFormatAscii
(
dest
);
fclose
(
dest
)
;
SetTitle
(
GetScreen
()
->
m_FileName
);
SavePcbFormatAscii
(
dest
);
fclose
(
dest
)
;
}
/* Affichage des fichiers crees: */
...
...
@@ -315,17 +326,18 @@ FILE * dest;
if
(
saveok
)
{
msg
=
_
(
"Backup file: "
)
+
old_name
;
Affiche_1_Parametre
(
this
,
1
,
msg
,
wxEmptyString
,
CYAN
);
msg
=
_
(
"Backup file: "
)
+
old_name
;
Affiche_1_Parametre
(
this
,
1
,
msg
,
wxEmptyString
,
CYAN
);
}
if
(
dest
)
msg
=
_
(
"Write Board file: "
);
else
msg
=
_
(
"Failed to create "
);
if
(
dest
)
msg
=
_
(
"Write Board file: "
);
else
msg
=
_
(
"Failed to create "
);
msg
+=
FullFileName
;
Affiche_1_Parametre
(
this
,
1
,
wxEmptyString
,
msg
,
CYAN
);
g_SaveTime
=
time
(
NULL
);
/* Reset delai pour sauvegarde automatique */
Affiche_1_Parametre
(
this
,
1
,
wxEmptyString
,
msg
,
CYAN
);
g_SaveTime
=
time
(
NULL
);
/* Reset delai pour sauvegarde automatique */
GetScreen
()
->
ClrModify
();
return
TRUE
;
}
pcbnew/ioascii.cpp
View file @
5748b791
...
...
@@ -3,7 +3,7 @@
/* Fichier common a PCBNEW et CVPCB */
/********************************************************************/
/* ioascii.cpp */
/* ioascii.cpp */
#include "fctsys.h"
#include "gr_basic.h"
...
...
@@ -24,783 +24,835 @@
/* Format des structures de sauvegarde type ASCII :
Structure PAD:
Structure PAD:
$PAD
Sh "name" forme dimv dimH dV dH orient :forme generale dV, dH = delta dimensions
Dr diam, dV dH :drill : diametre offsets de percage
At type S/N layers : type standard,cms,conn,hole,meca.,
$PAD
Sh "name" forme dimv dimH dV dH orient :forme generale dV, dH = delta dimensions
Dr diam, dV dH :drill : diametre offsets de percage
At type S/N layers : type standard,cms,conn,hole,meca.,
Stack/Normal,
Hexadecimal 32 bits: occupation des couches
Nm net_code netname
Po posrefX posrefy : position refX,Y (= position orient 0 / ancre)
$EndPAD
Nm net_code netname
Po posrefX posrefy : position refX,Y (= position orient 0 / ancre)
$EndPAD
******
**
Structure module ***********
****** Structure module ***********
$MODULE namelib
Po ax ay orient layer masquelayer m_TimeCode
$MODULE namelib
Po ax ay orient layer masquelayer m_TimeCode
ax ay = coord ancre (position module)
orient = orient en 0.1 degre
layer = numero de couche
masquelayer = couche pour serigraphie
m_TimeCode a usage interne (groupements)
Li <namelib>
Li <namelib>
Cd <text> Description du composant (Composant Doc)
Kw <text> Liste des mots cle
Cd <text> Description du composant (Composant Doc)
Kw <text> Liste des mots cle
Sc schematimestamp de reference schematique
Sc schematimestamp de reference schematique
Op rot90 rot180 Options de placement auto (cout rot 90, 180 )
Op rot90 rot180 Options de placement auto (cout rot 90, 180 )
rot90 est sur 2x4 bits:
lsb = cout rot 90, msb = cout rot -90;
Tn px py dimv dimh orient epaisseur miroir visible "texte"
Tn px py dimv dimh orient epaisseur miroir visible "texte"
n = type (0 = ref, 1 = val, > 1 =qcq
Textes POS x,y / ancre et orient module 0
dimv dimh orient
epaisseur miroir (Normal/miroir)
visible V/I
DS ox oy fx fy w
DS ox oy fx fy w
edge: segment coord ox,oy a fx,fy, relatives
a l'ancre et orient 0
epaisseur w
DC ox oy fx fy w descr cercle (centre, 1 point, epaisseur)
$PAD
$EndPAD section pads s'il y en a
$EndMODULE
DC ox oy fx fy w descr cercle (centre, 1 point, epaisseur)
$PAD
$EndPAD section pads s'il y en a
$EndMODULE
*/
extern
Ki_PageDescr
*
SheetList
[];
extern
Ki_PageDescr
*
SheetList
[];
/* Variables locales, utilisees pour la lecture des fichiers PCB */
int
NbDraw
,
NbTrack
,
NbZone
,
NbMod
,
NbNets
;
int
NbDraw
,
NbTrack
,
NbZone
,
NbMod
,
NbNets
;
/**********************************************************************/
int
WinEDA_BasePcbFrame
::
ReadListeSegmentDescr
(
wxDC
*
DC
,
FILE
*
File
,
TRACK
*
PtSegm
,
int
StructType
,
int
*
LineNum
,
int
NumSegm
)
int
WinEDA_BasePcbFrame
::
ReadListeSegmentDescr
(
wxDC
*
DC
,
FILE
*
File
,
TRACK
*
PtSegm
,
int
StructType
,
int
*
LineNum
,
int
NumSegm
)
/**********************************************************************/
/* Lecture de la description d'une liste de segments (Tracks, zones)
Retourne:
si ok nombre d'items lus.
si pas de fin de block ($..) - nombre.
*/
*
Retourne:
*
si ok nombre d'items lus.
*
si pas de fin de block ($..) - nombre.
*/
{
int
shape
,
width
,
layer
,
type
,
flags
,
net_code
;
int
ii
=
0
,
PerCent
,
Pas
;
char
Line
[
256
];
TRACK
*
NewTrack
;
int
shape
,
width
,
layer
,
type
,
flags
,
net_code
;
int
ii
=
0
,
PerCent
,
Pas
;
char
Line
[
256
];
TRACK
*
NewTrack
;
PerCent
=
0
;
Pas
=
NumSegm
/
99
;
#ifdef PCBNEW
switch
(
StructType
)
switch
(
StructType
)
{
case
TYPETRACK
:
case
TYPEVIA
:
DisplayActivity
(
PerCent
,
wxT
(
"Tracks:"
)
);
DisplayActivity
(
PerCent
,
wxT
(
"Tracks:"
)
);
break
;
case
TYPEZONE
:
DisplayActivity
(
PerCent
,
wxT
(
"Zones:"
)
);
DisplayActivity
(
PerCent
,
wxT
(
"Zones:"
)
);
break
;
}
#endif
while
(
GetLine
(
File
,
Line
,
LineNum
)
)
while
(
GetLine
(
File
,
Line
,
LineNum
)
)
{
if
(
Line
[
0
]
==
'$'
)
if
(
Line
[
0
]
==
'$'
)
{
return
(
ii
);
/* fin de liste OK */
return
ii
;
/* fin de liste OK */
}
switch
(
StructType
)
switch
(
StructType
)
{
default
:
case
TYPETRACK
:
NewTrack
=
new
TRACK
(
m_Pcb
);
case
TYPETRACK
:
NewTrack
=
new
TRACK
(
m_Pcb
);
break
;
case
TYPEVIA
:
NewTrack
=
new
SEGVIA
(
m_Pcb
);
case
TYPEVIA
:
NewTrack
=
new
SEGVIA
(
m_Pcb
);
break
;
case
TYPEZONE
:
NewTrack
=
new
SEGZONE
(
m_Pcb
);
case
TYPEZONE
:
NewTrack
=
new
SEGZONE
(
m_Pcb
);
break
;
}
NewTrack
->
Insert
(
m_Pcb
,
PtSegm
);
PtSegm
=
NewTrack
;
int
arg_count
=
sscanf
(
Line
+
2
,
" %d %d %d %d %d %d %d"
,
&
shape
,
NewTrack
->
Insert
(
m_Pcb
,
PtSegm
);
PtSegm
=
NewTrack
;
int
arg_count
=
sscanf
(
Line
+
2
,
" %d %d %d %d %d %d %d"
,
&
shape
,
&
PtSegm
->
m_Start
.
x
,
&
PtSegm
->
m_Start
.
y
,
&
PtSegm
->
m_End
.
x
,
&
PtSegm
->
m_End
.
y
,
&
width
,
&
PtSegm
->
m_Drill
);
&
PtSegm
->
m_Drill
);
PtSegm
->
m_Width
=
width
;
PtSegm
->
m_Shape
=
shape
;
if
(
arg_count
<
7
)
PtSegm
->
m_Drill
=
-
1
;
if
(
arg_count
<
7
)
PtSegm
->
m_Drill
=
-
1
;
if
(
GetLine
(
File
,
Line
,
LineNum
)
==
NULL
)
break
;
if
(
Line
[
0
]
==
'$'
)
break
;
if
(
GetLine
(
File
,
Line
,
LineNum
)
==
NULL
)
break
;
if
(
Line
[
0
]
==
'$'
)
break
;
sscanf
(
Line
+
2
,
" %d %d %d %lX %X"
,
&
layer
,
&
type
,
&
net_code
,
&
PtSegm
->
m_TimeStamp
,
&
flags
);
if
(
type
==
1
)
PtSegm
->
m_StructType
=
TYPEVIA
;
sscanf
(
Line
+
2
,
" %d %d %d %lX %X"
,
&
layer
,
&
type
,
&
net_code
,
&
PtSegm
->
m_TimeStamp
,
&
flags
);
if
(
type
==
1
)
PtSegm
->
m_StructType
=
TYPEVIA
;
PtSegm
->
m_Layer
=
layer
;
PtSegm
->
m_NetCode
=
net_code
;
PtSegm
->
SetState
(
flags
,
ON
);
PtSegm
->
m_NetCode
=
net_code
;
PtSegm
->
SetState
(
flags
,
ON
);
#ifdef PCBNEW
PtSegm
->
Draw
(
DrawPanel
,
DC
,
GR_OR
);
PtSegm
->
Draw
(
DrawPanel
,
DC
,
GR_OR
);
#endif
ii
++
;
if
(
(
Pas
&&
(
ii
%
Pas
)
==
0
)
)
{
PerCent
++
;
PerCent
++
;
#ifdef PCBNEW
switch
(
StructType
)
switch
(
StructType
)
{
case
TYPETRACK
:
case
TYPEVIA
:
DisplayActivity
(
PerCent
,
wxT
(
"Tracks:"
)
);
DisplayActivity
(
PerCent
,
wxT
(
"Tracks:"
)
);
break
;
case
TYPEZONE
:
DisplayActivity
(
PerCent
,
wxT
(
"Zones:"
)
);
DisplayActivity
(
PerCent
,
wxT
(
"Zones:"
)
);
break
;
}
#endif
}
}
DisplayError
(
this
,
_
(
"Error: Unexpected end of file !"
)
);
return
(
-
ii
);
}
DisplayError
(
this
,
_
(
"Error: Unexpected end of file !"
)
);
return
-
ii
;
}
/**********************************************************************************/
int
WinEDA_BasePcbFrame
::
ReadGeneralDescrPcb
(
wxDC
*
DC
,
FILE
*
File
,
int
*
LineNum
)
int
WinEDA_BasePcbFrame
::
ReadGeneralDescrPcb
(
wxDC
*
DC
,
FILE
*
File
,
int
*
LineNum
)
/**********************************************************************************/
{
char
Line
[
1024
],
*
data
;
BASE_SCREEN
*
screen
=
m_CurrentScreen
;
char
Line
[
1024
],
*
data
;
BASE_SCREEN
*
screen
=
m_CurrentScreen
;
while
(
GetLine
(
File
,
Line
,
LineNum
)
!=
NULL
)
while
(
GetLine
(
File
,
Line
,
LineNum
)
!=
NULL
)
{
data
=
strtok
(
Line
,
" =
\n\r
"
);
if
(
strnicmp
(
data
,
"$EndGENERAL"
,
10
)
==
0
)
break
;
data
=
strtok
(
Line
,
" =
\n\r
"
);
if
(
strnicmp
(
data
,
"$EndGENERAL"
,
10
)
==
0
)
break
;
if
(
strncmp
(
data
,
"Ly"
,
2
)
==
0
)
// Old format for Layer count
if
(
strncmp
(
data
,
"Ly"
,
2
)
==
0
)
// Old format for Layer count
{
int
Masque_Layer
=
1
,
ii
;
data
=
strtok
(
NULL
,
" =
\n\r
"
);
sscanf
(
data
,
"%X"
,
&
Masque_Layer
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
sscanf
(
data
,
"%X"
,
&
Masque_Layer
);
// Setup layer count
m_Pcb
->
m_BoardSettings
->
m_CopperLayerCount
=
0
;
for
(
ii
=
0
;
ii
<
NB_COPPER_LAYERS
;
ii
++
)
for
(
ii
=
0
;
ii
<
NB_COPPER_LAYERS
;
ii
++
)
{
if
(
Masque_Layer
&
1
)
m_Pcb
->
m_BoardSettings
->
m_CopperLayerCount
++
;
if
(
Masque_Layer
&
1
)
m_Pcb
->
m_BoardSettings
->
m_CopperLayerCount
++
;
Masque_Layer
>>=
1
;
}
continue
;
}
if
(
strnicmp
(
data
,
"Links"
,
5
)
==
0
)
if
(
strnicmp
(
data
,
"Links"
,
5
)
==
0
)
{
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_NbLinks
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_NbLinks
=
atoi
(
data
);
continue
;
}
if
(
strnicmp
(
data
,
"NoConn"
,
6
)
==
0
)
if
(
strnicmp
(
data
,
"NoConn"
,
6
)
==
0
)
{
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_NbNoconnect
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_NbNoconnect
=
atoi
(
data
);
continue
;
}
if
(
strnicmp
(
data
,
"Di"
,
2
)
==
0
)
if
(
strnicmp
(
data
,
"Di"
,
2
)
==
0
)
{
int
ii
,
jj
,
bestzoom
;
wxSize
pcbsize
,
screensize
;
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_BoundaryBox
.
SetX
(
atoi
(
data
)
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_BoundaryBox
.
SetY
(
atoi
(
data
)
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_BoundaryBox
.
SetWidth
(
atoi
(
data
)
-
m_Pcb
->
m_BoundaryBox
.
GetX
()
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_BoundaryBox
.
SetHeight
(
atoi
(
data
)
-
m_Pcb
->
m_BoundaryBox
.
GetY
()
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_BoundaryBox
.
SetX
(
atoi
(
data
)
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_BoundaryBox
.
SetY
(
atoi
(
data
)
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_BoundaryBox
.
SetWidth
(
atoi
(
data
)
-
m_Pcb
->
m_BoundaryBox
.
GetX
()
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
m_Pcb
->
m_BoundaryBox
.
SetHeight
(
atoi
(
data
)
-
m_Pcb
->
m_BoundaryBox
.
GetY
()
);
/* calcul du zoom optimal */
pcbsize
=
m_Pcb
->
m_BoundaryBox
.
GetSize
();
screensize
=
DrawPanel
->
GetClientSize
();
ii
=
pcbsize
.
x
/
screensize
.
x
;
jj
=
pcbsize
.
y
/
screensize
.
y
;
bestzoom
=
max
(
ii
,
jj
);
ii
=
pcbsize
.
x
/
screensize
.
x
;
jj
=
pcbsize
.
y
/
screensize
.
y
;
bestzoom
=
max
(
ii
,
jj
);
screen
->
m_Curseur
=
m_Pcb
->
m_BoundaryBox
.
Centre
();
screen
->
SetZoom
(
bestzoom
);
// la position des tracs a chang: mise a jour dans le DC courant
screen
->
SetZoom
(
bestzoom
);
// la position des trac� a chang� mise a jour dans le DC courant
wxPoint
org
;
DrawPanel
->
GetViewStart
(
&
org
.
x
,
&
org
.
y
);
DrawPanel
->
GetScrollPixelsPerUnit
(
&
ii
,
&
jj
);
DrawPanel
->
GetViewStart
(
&
org
.
x
,
&
org
.
y
);
DrawPanel
->
GetScrollPixelsPerUnit
(
&
ii
,
&
jj
);
org
.
x
*=
ii
;
org
.
y
*=
jj
;
#ifdef WX_ZOOM
DC
->
SetUserScale
(
1.0
/
(
double
)
screen
->
GetZoom
(),
1.0
/
screen
->
GetZoom
()
);
DC
->
SetUserScale
(
1.0
/
(
double
)
screen
->
GetZoom
(),
1.0
/
screen
->
GetZoom
()
);
org
.
x
*=
screen
->
GetZoom
();
org
.
y
*=
screen
->
GetZoom
();
DC
->
SetDeviceOrigin
(
-
org
.
x
,
-
org
.
y
);
DC
->
SetDeviceOrigin
(
-
org
.
x
,
-
org
.
y
);
#endif
DrawPanel
->
SetBoundaryBox
();
Recadre_Trace
(
TRUE
);
Recadre_Trace
(
TRUE
);
continue
;
}
/* Lecture du nombre de segments type DRAW , TRACT, ZONE */
if
(
stricmp
(
data
,
"Ndraw"
)
==
0
)
if
(
stricmp
(
data
,
"Ndraw"
)
==
0
)
{
data
=
strtok
(
NULL
,
" =
\n\r
"
);
NbDraw
=
atoi
(
data
);;
data
=
strtok
(
NULL
,
" =
\n\r
"
);
NbDraw
=
atoi
(
data
);;
continue
;
}
if
(
stricmp
(
data
,
"Ntrack"
)
==
0
)
if
(
stricmp
(
data
,
"Ntrack"
)
==
0
)
{
data
=
strtok
(
NULL
,
" =
\n\r
"
);
NbTrack
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
NbTrack
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
data
,
"Nzone"
)
==
0
)
if
(
stricmp
(
data
,
"Nzone"
)
==
0
)
{
data
=
strtok
(
NULL
,
" =
\n\r
"
);
NbZone
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
NbZone
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
data
,
"Nmodule"
)
==
0
)
if
(
stricmp
(
data
,
"Nmodule"
)
==
0
)
{
data
=
strtok
(
NULL
,
" =
\n\r
"
);
NbMod
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
NbMod
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
data
,
"Nnets"
)
==
0
)
if
(
stricmp
(
data
,
"Nnets"
)
==
0
)
{
data
=
strtok
(
NULL
,
" =
\n\r
"
);
NbNets
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
NbNets
=
atoi
(
data
);
continue
;
}
}
return
(
1
);
return
1
;
}
/*************************************************************/
int
WinEDA_BasePcbFrame
::
ReadSetup
(
FILE
*
File
,
int
*
LineNum
)
int
WinEDA_BasePcbFrame
::
ReadSetup
(
FILE
*
File
,
int
*
LineNum
)
/*************************************************************/
{
char
Line
[
1024
],
*
data
;
char
Line
[
1024
],
*
data
;
while
(
GetLine
(
File
,
Line
,
LineNum
)
!=
NULL
)
while
(
GetLine
(
File
,
Line
,
LineNum
)
!=
NULL
)
{
strtok
(
Line
,
" =
\n\r
"
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
strtok
(
Line
,
" =
\n\r
"
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
if
(
stricmp
(
Line
,
"$EndSETUP"
)
==
0
)
if
(
stricmp
(
Line
,
"$EndSETUP"
)
==
0
)
{
return
0
;
}
if
(
stricmp
(
Line
,
"AuxiliaryAxisOrg"
)
==
0
)
if
(
stricmp
(
Line
,
"AuxiliaryAxisOrg"
)
==
0
)
{
int
gx
=
0
,
gy
=
0
;
gx
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
if
(
data
)
gy
=
atoi
(
data
);
int
gx
=
0
,
gy
=
0
;
gx
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
if
(
data
)
gy
=
atoi
(
data
);
m_Auxiliary_Axis_Position
.
x
=
gx
;
m_Auxiliary_Axis_Position
.
y
=
gy
;
continue
;
}
#ifdef PCBNEW
if
(
stricmp
(
Line
,
"Layers"
)
==
0
)
if
(
stricmp
(
Line
,
"Layers"
)
==
0
)
{
int
tmp
;
sscanf
(
data
,
"%d"
,
&
tmp
);
sscanf
(
data
,
"%d"
,
&
tmp
);
m_Pcb
->
m_BoardSettings
->
m_CopperLayerCount
=
tmp
;
continue
;
}
if
(
stricmp
(
Line
,
"TrackWidth"
)
==
0
)
if
(
stricmp
(
Line
,
"TrackWidth"
)
==
0
)
{
g_DesignSettings
.
m_CurrentTrackWidth
=
atoi
(
data
);
AddHistory
(
g_DesignSettings
.
m_CurrentTrackWidth
,
TYPETRACK
);
g_DesignSettings
.
m_CurrentTrackWidth
=
atoi
(
data
);
AddHistory
(
g_DesignSettings
.
m_CurrentTrackWidth
,
TYPETRACK
);
continue
;
}
if
(
stricmp
(
Line
,
"TrackWidthHistory"
)
==
0
)
if
(
stricmp
(
Line
,
"TrackWidthHistory"
)
==
0
)
{
int
tmp
=
atoi
(
data
);
AddHistory
(
tmp
,
TYPETRACK
);
int
tmp
=
atoi
(
data
);
AddHistory
(
tmp
,
TYPETRACK
);
continue
;
}
if
(
stricmp
(
Line
,
"TrackClearence"
)
==
0
)
if
(
stricmp
(
Line
,
"TrackClearence"
)
==
0
)
{
g_DesignSettings
.
m_TrackClearence
=
atoi
(
data
);
g_DesignSettings
.
m_TrackClearence
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"ZoneClearence"
)
==
0
)
if
(
stricmp
(
Line
,
"ZoneClearence"
)
==
0
)
{
g_DesignSettings
.
m_ZoneClearence
=
atoi
(
data
);
g_DesignSettings
.
m_ZoneClearence
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"GridSize"
)
==
0
)
if
(
stricmp
(
Line
,
"GridSize"
)
==
0
)
{
wxSize
Grid
;
Grid
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
if
(
data
)
Grid
.
y
=
atoi
(
data
);
else
Grid
.
y
=
Grid
.
x
;
GetScreen
()
->
SetGrid
(
Grid
);
Grid
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
if
(
data
)
Grid
.
y
=
atoi
(
data
);
else
Grid
.
y
=
Grid
.
x
;
GetScreen
()
->
SetGrid
(
Grid
);
continue
;
}
if
(
stricmp
(
Line
,
"ZoneGridSize"
)
==
0
)
if
(
stricmp
(
Line
,
"ZoneGridSize"
)
==
0
)
{
g_GridRoutingSize
=
atoi
(
data
);
g_GridRoutingSize
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"UserGridSize"
)
==
0
)
if
(
stricmp
(
Line
,
"UserGridSize"
)
==
0
)
{
wxString
msg
;
if
(
data
)
if
(
data
)
{
msg
=
CONV_FROM_UTF8
(
data
);
msg
.
ToDouble
(
&
g_UserGrid
.
x
);
msg
=
CONV_FROM_UTF8
(
data
);
msg
.
ToDouble
(
&
g_UserGrid
.
x
);
}
else
continue
;
data
=
strtok
(
NULL
,
" =
\n\r
"
);
if
(
data
)
else
continue
;
data
=
strtok
(
NULL
,
" =
\n\r
"
);
if
(
data
)
{
msg
=
CONV_FROM_UTF8
(
data
);
msg
.
ToDouble
(
&
g_UserGrid
.
y
);
msg
=
CONV_FROM_UTF8
(
data
);
msg
.
ToDouble
(
&
g_UserGrid
.
y
);
}
else
g_UserGrid
.
y
=
g_UserGrid
.
x
;
else
g_UserGrid
.
y
=
g_UserGrid
.
x
;
GetScreen
()
->
m_UserGrid
=
g_UserGrid
;
data
=
strtok
(
NULL
,
" =
\n\r
"
);
if
(
data
)
data
=
strtok
(
NULL
,
" =
\n\r
"
);
if
(
data
)
{
if
(
stricmp
(
data
,
"mm"
)
==
0
)
if
(
stricmp
(
data
,
"mm"
)
==
0
)
g_UserGrid_Unit
=
MILLIMETRE
;
else
g_UserGrid_Unit
=
INCHES
;
else
g_UserGrid_Unit
=
INCHES
;
GetScreen
()
->
m_UserGridUnit
=
g_UserGrid_Unit
;
}
continue
;
}
if
(
stricmp
(
Line
,
"DrawSegmWidth"
)
==
0
)
if
(
stricmp
(
Line
,
"DrawSegmWidth"
)
==
0
)
{
g_DesignSettings
.
m_DrawSegmentWidth
=
atoi
(
data
);
g_DesignSettings
.
m_DrawSegmentWidth
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"EdgeSegmWidth"
)
==
0
)
if
(
stricmp
(
Line
,
"EdgeSegmWidth"
)
==
0
)
{
g_DesignSettings
.
m_EdgeSegmentWidth
=
atoi
(
data
);
g_DesignSettings
.
m_EdgeSegmentWidth
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"ViaSize"
)
==
0
)
if
(
stricmp
(
Line
,
"ViaSize"
)
==
0
)
{
g_DesignSettings
.
m_CurrentViaSize
=
atoi
(
data
);
AddHistory
(
g_DesignSettings
.
m_CurrentViaSize
,
TYPEVIA
);
g_DesignSettings
.
m_CurrentViaSize
=
atoi
(
data
);
AddHistory
(
g_DesignSettings
.
m_CurrentViaSize
,
TYPEVIA
);
continue
;
}
if
(
stricmp
(
Line
,
"ViaSizeHistory"
)
==
0
)
if
(
stricmp
(
Line
,
"ViaSizeHistory"
)
==
0
)
{
int
tmp
=
atoi
(
data
);
AddHistory
(
tmp
,
TYPEVIA
);
int
tmp
=
atoi
(
data
);
AddHistory
(
tmp
,
TYPEVIA
);
continue
;
}
if
(
stricmp
(
Line
,
"ViaDrill"
)
==
0
)
if
(
stricmp
(
Line
,
"ViaDrill"
)
==
0
)
{
g_DesignSettings
.
m_ViaDrill
=
atoi
(
data
);
g_DesignSettings
.
m_ViaDrill
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"TextPcbWidth"
)
==
0
)
if
(
stricmp
(
Line
,
"TextPcbWidth"
)
==
0
)
{
g_DesignSettings
.
m_PcbTextWidth
=
atoi
(
data
);
g_DesignSettings
.
m_PcbTextWidth
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"TextPcbSize"
)
==
0
)
if
(
stricmp
(
Line
,
"TextPcbSize"
)
==
0
)
{
g_DesignSettings
.
m_PcbTextSize
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
g_DesignSettings
.
m_PcbTextSize
.
y
=
atoi
(
data
);
g_DesignSettings
.
m_PcbTextSize
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
g_DesignSettings
.
m_PcbTextSize
.
y
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"EdgeModWidth"
)
==
0
)
if
(
stricmp
(
Line
,
"EdgeModWidth"
)
==
0
)
{
ModuleSegmentWidth
=
atoi
(
data
);
ModuleSegmentWidth
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"TextModWidth"
)
==
0
)
if
(
stricmp
(
Line
,
"TextModWidth"
)
==
0
)
{
ModuleTextWidth
=
atoi
(
data
);
ModuleTextWidth
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"TextModSize"
)
==
0
)
if
(
stricmp
(
Line
,
"TextModSize"
)
==
0
)
{
ModuleTextSize
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
ModuleTextSize
.
y
=
atoi
(
data
);
ModuleTextSize
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
ModuleTextSize
.
y
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"PadSize"
)
==
0
)
if
(
stricmp
(
Line
,
"PadSize"
)
==
0
)
{
g_Pad_Master
.
m_Size
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
g_Pad_Master
.
m_Size
.
y
=
atoi
(
data
);
g_Pad_Master
.
m_Size
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
g_Pad_Master
.
m_Size
.
y
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"PadDrill"
)
==
0
)
if
(
stricmp
(
Line
,
"PadDrill"
)
==
0
)
{
g_Pad_Master
.
m_Drill
.
x
=
atoi
(
data
);
g_Pad_Master
.
m_Drill
.
x
=
atoi
(
data
);
g_Pad_Master
.
m_Drill
.
y
=
g_Pad_Master
.
m_Drill
.
x
;
continue
;
}
if
(
stricmp
(
Line
,
"PadDeltaSize"
)
==
0
)
if
(
stricmp
(
Line
,
"PadDeltaSize"
)
==
0
)
{
g_Pad_Master
.
m_DeltaSize
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
g_Pad_Master
.
m_DeltaSize
.
y
=
atoi
(
data
);
g_Pad_Master
.
m_DeltaSize
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
g_Pad_Master
.
m_DeltaSize
.
y
=
atoi
(
data
);
continue
;
}
if
(
stricmp
(
Line
,
"PadShapeOffset"
)
==
0
)
if
(
stricmp
(
Line
,
"PadShapeOffset"
)
==
0
)
{
g_Pad_Master
.
m_Offset
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
g_Pad_Master
.
m_Offset
.
y
=
atoi
(
data
);
g_Pad_Master
.
m_Offset
.
x
=
atoi
(
data
);
data
=
strtok
(
NULL
,
" =
\n\r
"
);
g_Pad_Master
.
m_Offset
.
y
=
atoi
(
data
);
continue
;
}
#endif
}
return
(
1
);
return
1
;
}
#ifdef PCBNEW
/***************************************************************/
static
int
WriteSetup
(
FILE
*
File
,
WinEDA_BasePcbFrame
*
frame
)
static
int
WriteSetup
(
FILE
*
File
,
WinEDA_BasePcbFrame
*
frame
)
/***************************************************************/
{
char
text
[
1024
];
int
ii
,
jj
;
char
text
[
1024
];
int
ii
,
jj
;
fprintf
(
File
,
"$SETUP
\n
"
);
sprintf
(
text
,
"InternalUnit %f INCH
\n
"
,
1.0
/
PCB_INTERNAL_UNIT
);
fprintf
(
File
,
text
);
fprintf
(
File
,
"$SETUP
\n
"
);
sprintf
(
text
,
"InternalUnit %f INCH
\n
"
,
1.0
/
PCB_INTERNAL_UNIT
);
fprintf
(
File
,
text
);
if
(
frame
->
GetScreen
()
->
m_UserGridIsON
)
ii
=
jj
=
-
1
;
if
(
frame
->
GetScreen
()
->
m_UserGridIsON
)
ii
=
jj
=
-
1
;
else
{
ii
=
frame
->
GetScreen
()
->
GetGrid
().
x
;
jj
=
frame
->
GetScreen
()
->
GetGrid
().
y
;
}
sprintf
(
text
,
"GridSize %d %d
\n
"
,
ii
,
jj
);
fprintf
(
File
,
text
);
sprintf
(
text
,
"GridSize %d %d
\n
"
,
ii
,
jj
);
fprintf
(
File
,
text
);
sprintf
(
text
,
"UserGridSize %lf %lf %s
\n
"
,
sprintf
(
text
,
"UserGridSize %lf %lf %s
\n
"
,
frame
->
GetScreen
()
->
m_UserGrid
.
x
,
frame
->
GetScreen
()
->
m_UserGrid
.
y
,
(
g_UserGrid_Unit
==
0
)
?
"INCH"
:
"mm"
);
fprintf
(
File
,
text
);
fprintf
(
File
,
"ZoneGridSize %d
\n
"
,
g_GridRoutingSize
);
fprintf
(
File
,
"Layers %d
\n
"
,
g_DesignSettings
.
m_CopperLayerCount
);
fprintf
(
File
,
"TrackWidth %d
\n
"
,
g_DesignSettings
.
m_CurrentTrackWidth
);
for
(
ii
=
0
;
ii
<
HIST0RY_NUMBER
;
ii
++
)
{
if
(
g_DesignSettings
.
m_TrackWidhtHistory
[
ii
]
==
0
)
break
;
fprintf
(
File
,
"TrackWidthHistory %d
\n
"
,
g_DesignSettings
.
m_TrackWidhtHistory
[
ii
]);
}
fprintf
(
File
,
"TrackClearence %d
\n
"
,
g_DesignSettings
.
m_TrackClearence
);
fprintf
(
File
,
"ZoneClearence %d
\n
"
,
g_DesignSettings
.
m_ZoneClearence
);
fprintf
(
File
,
"DrawSegmWidth %d
\n
"
,
g_DesignSettings
.
m_DrawSegmentWidth
);
fprintf
(
File
,
"EdgeSegmWidth %d
\n
"
,
g_DesignSettings
.
m_EdgeSegmentWidth
);
fprintf
(
File
,
"ViaSize %d
\n
"
,
g_DesignSettings
.
m_CurrentViaSize
);
fprintf
(
File
,
"ViaDrill %d
\n
"
,
g_DesignSettings
.
m_ViaDrill
);
for
(
ii
=
0
;
ii
<
HIST0RY_NUMBER
;
ii
++
)
{
if
(
g_DesignSettings
.
m_ViaSizeHistory
[
ii
]
==
0
)
break
;
fprintf
(
File
,
"ViaSizeHistory %d
\n
"
,
g_DesignSettings
.
m_ViaSizeHistory
[
ii
]);
}
fprintf
(
File
,
"TextPcbWidth %d
\n
"
,
g_DesignSettings
.
m_PcbTextWidth
);
fprintf
(
File
,
"TextPcbSize %d %d
\n
"
,
g_DesignSettings
.
m_PcbTextSize
.
x
,
g_DesignSettings
.
m_PcbTextSize
.
y
);
fprintf
(
File
,
"EdgeModWidth %d
\n
"
,
ModuleSegmentWidth
);
fprintf
(
File
,
"TextModSize %d %d
\n
"
,
ModuleTextSize
.
x
,
ModuleTextSize
.
y
);
fprintf
(
File
,
"TextModWidth %d
\n
"
,
ModuleTextWidth
);
fprintf
(
File
,
"PadSize %d %d
\n
"
,
g_Pad_Master
.
m_Size
.
x
,
g_Pad_Master
.
m_Size
.
y
);
fprintf
(
File
,
"PadDrill %d
\n
"
,
g_Pad_Master
.
m_Drill
.
x
);
(
g_UserGrid_Unit
==
0
)
?
"INCH"
:
"mm"
);
fprintf
(
File
,
text
);
fprintf
(
File
,
"ZoneGridSize %d
\n
"
,
g_GridRoutingSize
);
fprintf
(
File
,
"Layers %d
\n
"
,
g_DesignSettings
.
m_CopperLayerCount
);
fprintf
(
File
,
"TrackWidth %d
\n
"
,
g_DesignSettings
.
m_CurrentTrackWidth
);
for
(
ii
=
0
;
ii
<
HIST0RY_NUMBER
;
ii
++
)
{
if
(
g_DesignSettings
.
m_TrackWidhtHistory
[
ii
]
==
0
)
break
;
fprintf
(
File
,
"TrackWidthHistory %d
\n
"
,
g_DesignSettings
.
m_TrackWidhtHistory
[
ii
]
);
}
fprintf
(
File
,
"TrackClearence %d
\n
"
,
g_DesignSettings
.
m_TrackClearence
);
fprintf
(
File
,
"ZoneClearence %d
\n
"
,
g_DesignSettings
.
m_ZoneClearence
);
fprintf
(
File
,
"DrawSegmWidth %d
\n
"
,
g_DesignSettings
.
m_DrawSegmentWidth
);
fprintf
(
File
,
"EdgeSegmWidth %d
\n
"
,
g_DesignSettings
.
m_EdgeSegmentWidth
);
fprintf
(
File
,
"ViaSize %d
\n
"
,
g_DesignSettings
.
m_CurrentViaSize
);
fprintf
(
File
,
"ViaDrill %d
\n
"
,
g_DesignSettings
.
m_ViaDrill
);
for
(
ii
=
0
;
ii
<
HIST0RY_NUMBER
;
ii
++
)
{
if
(
g_DesignSettings
.
m_ViaSizeHistory
[
ii
]
==
0
)
break
;
fprintf
(
File
,
"ViaSizeHistory %d
\n
"
,
g_DesignSettings
.
m_ViaSizeHistory
[
ii
]
);
}
fprintf
(
File
,
"TextPcbWidth %d
\n
"
,
g_DesignSettings
.
m_PcbTextWidth
);
fprintf
(
File
,
"TextPcbSize %d %d
\n
"
,
g_DesignSettings
.
m_PcbTextSize
.
x
,
g_DesignSettings
.
m_PcbTextSize
.
y
);
fprintf
(
File
,
"EdgeModWidth %d
\n
"
,
ModuleSegmentWidth
);
fprintf
(
File
,
"TextModSize %d %d
\n
"
,
ModuleTextSize
.
x
,
ModuleTextSize
.
y
);
fprintf
(
File
,
"TextModWidth %d
\n
"
,
ModuleTextWidth
);
fprintf
(
File
,
"PadSize %d %d
\n
"
,
g_Pad_Master
.
m_Size
.
x
,
g_Pad_Master
.
m_Size
.
y
);
fprintf
(
File
,
"PadDrill %d
\n
"
,
g_Pad_Master
.
m_Drill
.
x
);
// fprintf(File, "PadDeltaSize %d %d\n", Pad_DeltaSize.x, Pad_DeltaSize.y);
// fprintf(File, "PadDrillOffset %d %d\n", Pad_OffsetSize.x, Pad_OffsetSize.y);
fprintf
(
File
,
"AuxiliaryAxisOrg %d %d
\n
"
,
frame
->
m_Auxiliary_Axis_Position
.
x
,
frame
->
m_Auxiliary_Axis_Position
.
y
);
fprintf
(
File
,
"$EndSETUP
\n\n
"
);
return
(
1
)
;
fprintf
(
File
,
"AuxiliaryAxisOrg %d %d
\n
"
,
frame
->
m_Auxiliary_Axis_Position
.
x
,
frame
->
m_Auxiliary_Axis_Position
.
y
);
fprintf
(
File
,
"$EndSETUP
\n\n
"
);
return
1
;
}
#endif
/******************************************************/
bool
WinEDA_PcbFrame
::
WriteGeneralDescrPcb
(
FILE
*
File
)
bool
WinEDA_PcbFrame
::
WriteGeneralDescrPcb
(
FILE
*
File
)
/******************************************************/
{
EDA_BaseStruct
*
PtStruct
=
m_Pcb
->
m_Modules
;
int
NbModules
,
NbDrawItem
,
NbLayers
;
EDA_BaseStruct
*
PtStruct
=
m_Pcb
->
m_Modules
;
int
NbModules
,
NbDrawItem
,
NbLayers
;
/* Calcul du nombre des modules */
for
(
NbModules
=
0
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
NbModules
++
;
for
(
NbModules
=
0
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
NbModules
++
;
/* generation du masque des couches autorisees */
NbLayers
=
m_Pcb
->
m_BoardSettings
->
m_CopperLayerCount
;
fprintf
(
File
,
"$GENERAL
\n
"
);
fprintf
(
File
,
"LayerCount %d
\n
"
,
NbLayers
);
fprintf
(
File
,
"$GENERAL
\n
"
);
fprintf
(
File
,
"LayerCount %d
\n
"
,
NbLayers
);
// Write old format for Layer count (for compatibility with old versions of pcbnew
fprintf
(
File
,
"Ly %8X
\n
"
,
g_TabAllCopperLayerMask
[
NbLayers
-
1
]
|
ALL_NO_CU_LAYERS
);
// For compatibility with old version of pcbnew
fprintf
(
File
,
"Links %d
\n
"
,
m_Pcb
->
m_NbLinks
);
fprintf
(
File
,
"NoConn %d
\n
"
,
m_Pcb
->
m_NbNoconnect
);
fprintf
(
File
,
"Ly %8X
\n
"
,
g_TabAllCopperLayerMask
[
NbLayers
-
1
]
|
ALL_NO_CU_LAYERS
);
// For compatibility with old version of pcbnew
fprintf
(
File
,
"Links %d
\n
"
,
m_Pcb
->
m_NbLinks
);
fprintf
(
File
,
"NoConn %d
\n
"
,
m_Pcb
->
m_NbNoconnect
);
/* Generation des coord du rectangle d'encadrement */
m_Pcb
->
ComputeBoundaryBox
();
fprintf
(
File
,
"Di %d %d %d %d
\n
"
,
fprintf
(
File
,
"Di %d %d %d %d
\n
"
,
m_Pcb
->
m_BoundaryBox
.
GetX
(),
m_Pcb
->
m_BoundaryBox
.
GetY
(),
m_Pcb
->
m_BoundaryBox
.
GetRight
(),
m_Pcb
->
m_BoundaryBox
.
GetBottom
()
);
m_Pcb
->
m_BoundaryBox
.
GetBottom
()
);
/* Generation du nombre de segments type DRAW , TRACT ZONE */
PtStruct
=
m_Pcb
->
m_Drawings
;
NbDrawItem
=
0
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
NbDrawItem
++
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
NbDrawItem
++
;
fprintf
(
File
,
"Ndraw %d
\n
"
,
NbDrawItem
);
fprintf
(
File
,
"Ntrack %d
\n
"
,
m_Pcb
->
GetNumSegmTrack
()
);
fprintf
(
File
,
"Nzone %d
\n
"
,
m_Pcb
->
GetNumSegmZone
()
);
fprintf
(
File
,
"Ndraw %d
\n
"
,
NbDrawItem
);
fprintf
(
File
,
"Ntrack %d
\n
"
,
m_Pcb
->
GetNumSegmTrack
()
);
fprintf
(
File
,
"Nzone %d
\n
"
,
m_Pcb
->
GetNumSegmZone
()
);
fprintf
(
File
,
"Nmodule %d
\n
"
,
NbModules
);
fprintf
(
File
,
"Nnets %d
\n
"
,
m_Pcb
->
m_NbNets
);
fprintf
(
File
,
"Nmodule %d
\n
"
,
NbModules
);
fprintf
(
File
,
"Nnets %d
\n
"
,
m_Pcb
->
m_NbNets
);
fprintf
(
File
,
"$EndGENERAL
\n\n
"
);
fprintf
(
File
,
"$EndGENERAL
\n\n
"
);
return
TRUE
;
}
/******************************************************/
bool
WriteSheetDescr
(
BASE_SCREEN
*
screen
,
FILE
*
File
)
bool
WriteSheetDescr
(
BASE_SCREEN
*
screen
,
FILE
*
File
)
/******************************************************/
{
/* Sauvegarde des dimensions de la feuille de dessin, des textes du cartouche.. */
Ki_PageDescr
*
sheet
=
screen
->
m_CurrentSheet
;
fprintf
(
File
,
"$SHEETDESCR
\n
"
);
fprintf
(
File
,
"Sheet %s %d %d
\n
"
,
CONV_TO_UTF8
(
sheet
->
m_Name
),
sheet
->
m_Size
.
x
,
sheet
->
m_Size
.
y
);
fprintf
(
File
,
"Title
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Title
)
);
fprintf
(
File
,
"Date
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Date
)
);
fprintf
(
File
,
"Rev
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Revision
)
);
fprintf
(
File
,
"Comp
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Company
)
);
fprintf
(
File
,
"Comment1
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Commentaire1
)
);
fprintf
(
File
,
"Comment2
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Commentaire2
)
);
fprintf
(
File
,
"Comment3
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Commentaire3
)
);
fprintf
(
File
,
"Comment4
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Commentaire4
)
);
fprintf
(
File
,
"$EndSHEETDESCR
\n\n
"
);
Ki_PageDescr
*
sheet
=
screen
->
m_CurrentSheet
;
fprintf
(
File
,
"$SHEETDESCR
\n
"
);
fprintf
(
File
,
"Sheet %s %d %d
\n
"
,
CONV_TO_UTF8
(
sheet
->
m_Name
),
sheet
->
m_Size
.
x
,
sheet
->
m_Size
.
y
);
fprintf
(
File
,
"Title
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Title
)
);
fprintf
(
File
,
"Date
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Date
)
);
fprintf
(
File
,
"Rev
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Revision
)
);
fprintf
(
File
,
"Comp
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Company
)
);
fprintf
(
File
,
"Comment1
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Commentaire1
)
);
fprintf
(
File
,
"Comment2
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Commentaire2
)
);
fprintf
(
File
,
"Comment3
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Commentaire3
)
);
fprintf
(
File
,
"Comment4
\"
%s
\"\n
"
,
CONV_TO_UTF8
(
screen
->
m_Commentaire4
)
);
fprintf
(
File
,
"$EndSHEETDESCR
\n\n
"
);
return
TRUE
;
}
/***************************************************************************/
static
bool
ReadSheetDescr
(
BASE_SCREEN
*
screen
,
FILE
*
File
,
int
*
LineNum
)
static
bool
ReadSheetDescr
(
BASE_SCREEN
*
screen
,
FILE
*
File
,
int
*
LineNum
)
/***************************************************************************/
{
char
Line
[
1024
],
buf
[
1024
],
*
text
;
char
Line
[
1024
],
buf
[
1024
],
*
text
;
/* Recheche suite et fin de descr */
while
(
GetLine
(
File
,
Line
,
LineNum
)
!=
NULL
)
while
(
GetLine
(
File
,
Line
,
LineNum
)
!=
NULL
)
{
if
(
strnicmp
(
Line
,
"$End"
,
4
)
==
0
)
return
TRUE
;
if
(
strnicmp
(
Line
,
"$End"
,
4
)
==
0
)
return
TRUE
;
if
(
strnicmp
(
Line
,
"Sheet"
,
4
)
==
0
)
if
(
strnicmp
(
Line
,
"Sheet"
,
4
)
==
0
)
{
text
=
strtok
(
Line
,
"
\t\n\r
"
);
text
=
strtok
(
NULL
,
"
\t\n\r
"
);
Ki_PageDescr
*
sheet
=
SheetList
[
0
];
text
=
strtok
(
Line
,
"
\t\n\r
"
);
text
=
strtok
(
NULL
,
"
\t\n\r
"
);
Ki_PageDescr
*
sheet
=
SheetList
[
0
];
int
ii
;
for
(
ii
=
0
;
sheet
!=
NULL
;
ii
++
,
sheet
=
SheetList
[
ii
]
)
for
(
ii
=
0
;
sheet
!=
NULL
;
ii
++
,
sheet
=
SheetList
[
ii
]
)
{
if
(
stricmp
(
CONV_TO_UTF8
(
sheet
->
m_Name
),
text
)
==
0
)
if
(
stricmp
(
CONV_TO_UTF8
(
sheet
->
m_Name
),
text
)
==
0
)
{
screen
->
m_CurrentSheet
=
sheet
;
if
(
sheet
==
&
g_Sheet_user
)
if
(
sheet
==
&
g_Sheet_user
)
{
text
=
strtok
(
NULL
,
"
\t\n\r
"
);
if
(
text
)
sheet
->
m_Size
.
x
=
atoi
(
text
);
text
=
strtok
(
NULL
,
"
\t\n\r
"
);
if
(
text
)
sheet
->
m_Size
.
y
=
atoi
(
text
);
text
=
strtok
(
NULL
,
"
\t\n\r
"
);
if
(
text
)
sheet
->
m_Size
.
x
=
atoi
(
text
);
text
=
strtok
(
NULL
,
"
\t\n\r
"
);
if
(
text
)
sheet
->
m_Size
.
y
=
atoi
(
text
);
}
break
;
}
}
continue
;
}
if
(
strnicmp
(
Line
,
"Title"
,
2
)
==
0
)
if
(
strnicmp
(
Line
,
"Title"
,
2
)
==
0
)
{
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Title
=
CONV_FROM_UTF8
(
buf
);
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Title
=
CONV_FROM_UTF8
(
buf
);
continue
;
}
if
(
strnicmp
(
Line
,
"Date"
,
2
)
==
0
)
if
(
strnicmp
(
Line
,
"Date"
,
2
)
==
0
)
{
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Date
=
CONV_FROM_UTF8
(
buf
);
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Date
=
CONV_FROM_UTF8
(
buf
);
continue
;
}
if
(
strnicmp
(
Line
,
"Rev"
,
2
)
==
0
)
if
(
strnicmp
(
Line
,
"Rev"
,
2
)
==
0
)
{
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Revision
=
CONV_FROM_UTF8
(
buf
);
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Revision
=
CONV_FROM_UTF8
(
buf
);
continue
;
}
if
(
strnicmp
(
Line
,
"Comp"
,
4
)
==
0
)
if
(
strnicmp
(
Line
,
"Comp"
,
4
)
==
0
)
{
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Company
=
CONV_FROM_UTF8
(
buf
);
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Company
=
CONV_FROM_UTF8
(
buf
);
continue
;
}
if
(
strnicmp
(
Line
,
"Comment1"
,
8
)
==
0
)
if
(
strnicmp
(
Line
,
"Comment1"
,
8
)
==
0
)
{
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Commentaire1
=
CONV_FROM_UTF8
(
buf
);
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Commentaire1
=
CONV_FROM_UTF8
(
buf
);
continue
;
}
if
(
strnicmp
(
Line
,
"Comment2"
,
8
)
==
0
)
if
(
strnicmp
(
Line
,
"Comment2"
,
8
)
==
0
)
{
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Commentaire2
=
CONV_FROM_UTF8
(
buf
);
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Commentaire2
=
CONV_FROM_UTF8
(
buf
);
continue
;
}
if
(
strnicmp
(
Line
,
"Comment3"
,
8
)
==
0
)
if
(
strnicmp
(
Line
,
"Comment3"
,
8
)
==
0
)
{
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Commentaire3
=
CONV_FROM_UTF8
(
buf
);
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Commentaire3
=
CONV_FROM_UTF8
(
buf
);
continue
;
}
if
(
strnicmp
(
Line
,
"Comment4"
,
8
)
==
0
)
if
(
strnicmp
(
Line
,
"Comment4"
,
8
)
==
0
)
{
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Commentaire4
=
CONV_FROM_UTF8
(
buf
);
ReadDelimitedText
(
buf
,
Line
,
256
);
screen
->
m_Commentaire4
=
CONV_FROM_UTF8
(
buf
);
continue
;
}
}
return
(
FALSE
);
return
FALSE
;
}
/********************************************************************/
int
WinEDA_PcbFrame
::
ReadPcbFile
(
wxDC
*
DC
,
FILE
*
File
,
bool
Append
)
int
WinEDA_PcbFrame
::
ReadPcbFile
(
wxDC
*
DC
,
FILE
*
File
,
bool
Append
)
/********************************************************************/
/* Lit un fichier PCB .brd
Si Append == 0: l'ancien pcb en memoire est supprime
Sinon il y a ajout des elements
*/
*
Si Append == 0: l'ancien pcb en memoire est supprime
*
Sinon il y a ajout des elements
*/
{
char
Line
[
1024
];
int
LineNum
=
0
;
int
nbsegm
,
nbmod
;
EDA_BaseStruct
*
LastStructPcb
=
NULL
,
*
StructPcb
;
MODULE
*
LastModule
=
NULL
,
*
Module
;
EQUIPOT
*
LastEquipot
=
NULL
,
*
Equipot
;
char
Line
[
1024
];
int
LineNum
=
0
;
int
nbsegm
,
nbmod
;
EDA_BaseStruct
*
LastStructPcb
=
NULL
,
*
StructPcb
;
MODULE
*
LastModule
=
NULL
,
*
Module
;
EQUIPOT
*
LastEquipot
=
NULL
,
*
Equipot
;
wxBusyCursor
dummy
;
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale
(
LC_NUMERIC
,
"C"
);
setlocale
(
LC_NUMERIC
,
"C"
);
NbDraw
=
NbTrack
=
NbZone
=
NbMod
=
NbNets
=
-
1
;
m_Pcb
->
m_NbNets
=
0
;
m_Pcb
->
m_Status_Pcb
=
0
;
nbmod
=
0
;
if
(
Append
)
if
(
Append
)
{
LastModule
=
m_Pcb
->
m_Modules
;
for
(
;
LastModule
!=
NULL
;
LastModule
=
(
MODULE
*
)
LastModule
->
Pnext
)
{
if
(
LastModule
->
Pnext
==
NULL
)
break
;
if
(
LastModule
->
Pnext
==
NULL
)
break
;
}
LastStructPcb
=
m_Pcb
->
m_Drawings
;
for
(
;
LastStructPcb
!=
NULL
;
LastStructPcb
=
LastStructPcb
->
Pnext
)
{
if
(
LastStructPcb
->
Pnext
==
NULL
)
break
;
if
(
LastStructPcb
->
Pnext
==
NULL
)
break
;
}
LastEquipot
=
m_Pcb
->
m_Equipots
;
for
(
;
LastEquipot
!=
NULL
;
LastEquipot
=
(
EQUIPOT
*
)
LastEquipot
->
Pnext
)
for
(
;
LastEquipot
!=
NULL
;
LastEquipot
=
(
EQUIPOT
*
)
LastEquipot
->
Pnext
)
{
if
(
LastEquipot
->
Pnext
==
NULL
)
break
;
if
(
LastEquipot
->
Pnext
==
NULL
)
break
;
}
}
while
(
GetLine
(
File
,
Line
,
&
LineNum
)
!=
NULL
)
while
(
GetLine
(
File
,
Line
,
&
LineNum
)
!=
NULL
)
{
if
(
strnicmp
(
Line
,
"$EndPCB"
,
6
)
==
0
)
break
;
if
(
strnicmp
(
Line
,
"$EndPCB"
,
6
)
==
0
)
break
;
if
(
strnicmp
(
Line
,
"$GENERAL"
,
8
)
==
0
)
if
(
strnicmp
(
Line
,
"$GENERAL"
,
8
)
==
0
)
{
ReadGeneralDescrPcb
(
DC
,
File
,
&
LineNum
);
ReadGeneralDescrPcb
(
DC
,
File
,
&
LineNum
);
continue
;
}
if
(
strnicmp
(
Line
,
"$SHEETDESCR"
,
11
)
==
0
)
if
(
strnicmp
(
Line
,
"$SHEETDESCR"
,
11
)
==
0
)
{
ReadSheetDescr
(
m_CurrentScreen
,
File
,
&
LineNum
);
ReadSheetDescr
(
m_CurrentScreen
,
File
,
&
LineNum
);
continue
;
}
if
(
strnicmp
(
Line
,
"$SETUP"
,
6
)
==
0
)
if
(
strnicmp
(
Line
,
"$SETUP"
,
6
)
==
0
)
{
if
(
!
Append
)
if
(
!
Append
)
{
ReadSetup
(
File
,
&
LineNum
);
ReadSetup
(
File
,
&
LineNum
);
}
else
{
while
(
GetLine
(
File
,
Line
,
&
LineNum
)
!=
NULL
)
if
(
strnicmp
(
Line
,
"$EndSETUP"
,
6
)
==
0
)
break
;
while
(
GetLine
(
File
,
Line
,
&
LineNum
)
!=
NULL
)
if
(
strnicmp
(
Line
,
"$EndSETUP"
,
6
)
==
0
)
break
;
}
continue
;
}
if
(
strnicmp
(
Line
,
"$EQUIPOT"
,
7
)
==
0
)
if
(
strnicmp
(
Line
,
"$EQUIPOT"
,
7
)
==
0
)
{
Equipot
=
new
EQUIPOT
(
m_Pcb
);
Equipot
->
ReadEquipotDescr
(
File
,
&
LineNum
);
Equipot
=
new
EQUIPOT
(
m_Pcb
);
Equipot
->
ReadEquipotDescr
(
File
,
&
LineNum
);
if
(
LastEquipot
==
NULL
)
{
m_Pcb
->
m_Equipots
=
Equipot
;
...
...
@@ -815,14 +867,17 @@ EQUIPOT * LastEquipot = NULL, * Equipot;
m_Pcb
->
m_NbNets
++
;
continue
;
}
if
(
strnicmp
(
Line
,
"$MODULE"
,
7
)
==
0
)
if
(
strnicmp
(
Line
,
"$MODULE"
,
7
)
==
0
)
{
float
Pas
;
Pas
=
100.0
;
if
(
NbMod
>
1
)
Pas
/=
NbMod
;
Pas
=
100.0
;
if
(
NbMod
>
1
)
Pas
/=
NbMod
;
Module
=
new
MODULE
(
m_Pcb
);
if
(
Module
==
NULL
)
continue
;
Module
->
ReadDescr
(
File
,
&
LineNum
);
Module
=
new
MODULE
(
m_Pcb
);
if
(
Module
==
NULL
)
continue
;
Module
->
ReadDescr
(
File
,
&
LineNum
);
if
(
LastModule
==
NULL
)
{
...
...
@@ -837,17 +892,17 @@ EQUIPOT * LastEquipot = NULL, * Equipot;
LastModule
=
Module
;
nbmod
++
;
#ifdef PCBNEW
DisplayActivity
((
int
)(
Pas
*
nbmod
),
wxT
(
"Modules:"
)
);
DisplayActivity
(
(
int
)
(
Pas
*
nbmod
),
wxT
(
"Modules:"
)
);
#endif
Module
->
Draw
(
DrawPanel
,
DC
,
wxPoint
(
0
,
0
),
GR_OR
);
Module
->
Draw
(
DrawPanel
,
DC
,
wxPoint
(
0
,
0
),
GR_OR
);
continue
;
}
if
(
strnicmp
(
Line
,
"$TEXTPCB"
,
8
)
==
0
)
if
(
strnicmp
(
Line
,
"$TEXTPCB"
,
8
)
==
0
)
{
TEXTE_PCB
*
pcbtxt
=
new
TEXTE_PCB
(
m_Pcb
);
TEXTE_PCB
*
pcbtxt
=
new
TEXTE_PCB
(
m_Pcb
);
StructPcb
=
(
EDA_BaseStruct
*
)
pcbtxt
;
pcbtxt
->
ReadTextePcbDescr
(
File
,
&
LineNum
);
pcbtxt
->
ReadTextePcbDescr
(
File
,
&
LineNum
);
if
(
LastStructPcb
==
NULL
)
{
m_Pcb
->
m_Drawings
=
StructPcb
;
...
...
@@ -860,15 +915,15 @@ EQUIPOT * LastEquipot = NULL, * Equipot;
}
LastStructPcb
=
StructPcb
;
#ifdef PCBNEW
((
TEXTE_PCB
*
)
StructPcb
)
->
Draw
(
DrawPanel
,
DC
,
wxPoint
(
0
,
0
),
GR_OR
);
(
(
TEXTE_PCB
*
)
StructPcb
)
->
Draw
(
DrawPanel
,
DC
,
wxPoint
(
0
,
0
),
GR_OR
);
#endif
continue
;
}
if
(
strnicmp
(
Line
,
"$DRAWSEGMENT"
,
10
)
==
0
)
if
(
strnicmp
(
Line
,
"$DRAWSEGMENT"
,
10
)
==
0
)
{
DRAWSEGMENT
*
DrawSegm
=
new
DRAWSEGMENT
(
m_Pcb
);
DrawSegm
->
ReadDrawSegmentDescr
(
File
,
&
LineNum
);
DRAWSEGMENT
*
DrawSegm
=
new
DRAWSEGMENT
(
m_Pcb
);
DrawSegm
->
ReadDrawSegmentDescr
(
File
,
&
LineNum
);
if
(
LastStructPcb
==
NULL
)
{
m_Pcb
->
m_Drawings
=
DrawSegm
;
...
...
@@ -881,16 +936,16 @@ EQUIPOT * LastEquipot = NULL, * Equipot;
}
LastStructPcb
=
DrawSegm
;
#ifdef PCBNEW
Trace_DrawSegmentPcb
(
DrawPanel
,
DC
,
DrawSegm
,
GR_OR
);
Trace_DrawSegmentPcb
(
DrawPanel
,
DC
,
DrawSegm
,
GR_OR
);
#endif
continue
;
}
if
(
strnicmp
(
Line
,
"$COTATION"
,
9
)
==
0
)
if
(
strnicmp
(
Line
,
"$COTATION"
,
9
)
==
0
)
{
COTATION
*
Cotation
=
new
COTATION
(
m_Pcb
);
Cotation
->
ReadCotationDescr
(
File
,
&
LineNum
);
COTATION
*
Cotation
=
new
COTATION
(
m_Pcb
);
Cotation
->
ReadCotationDescr
(
File
,
&
LineNum
);
if
(
LastStructPcb
==
NULL
)
{
m_Pcb
->
m_Drawings
=
Cotation
;
...
...
@@ -903,15 +958,15 @@ EQUIPOT * LastEquipot = NULL, * Equipot;
}
LastStructPcb
=
Cotation
;
#ifdef PCBNEW
Cotation
->
Draw
(
DrawPanel
,
DC
,
wxPoint
(
0
,
0
),
GR_OR
);
Cotation
->
Draw
(
DrawPanel
,
DC
,
wxPoint
(
0
,
0
),
GR_OR
);
#endif
continue
;
}
if
(
strnicmp
(
Line
,
"$MIREPCB"
,
8
)
==
0
)
if
(
strnicmp
(
Line
,
"$MIREPCB"
,
8
)
==
0
)
{
MIREPCB
*
Mire
=
new
MIREPCB
(
m_Pcb
);
Mire
->
ReadMirePcbDescr
(
File
,
&
LineNum
);
MIREPCB
*
Mire
=
new
MIREPCB
(
m_Pcb
);
Mire
->
ReadMirePcbDescr
(
File
,
&
LineNum
);
if
(
LastStructPcb
==
NULL
)
{
...
...
@@ -925,193 +980,207 @@ EQUIPOT * LastEquipot = NULL, * Equipot;
}
LastStructPcb
=
Mire
;
#ifdef PCBNEW
Mire
->
Draw
(
DrawPanel
,
DC
,
wxPoint
(
0
,
0
),
GR_OR
);
Mire
->
Draw
(
DrawPanel
,
DC
,
wxPoint
(
0
,
0
),
GR_OR
);
#endif
continue
;
}
if
(
strnicmp
(
Line
,
"$TRACK"
,
6
)
==
0
)
if
(
strnicmp
(
Line
,
"$TRACK"
,
6
)
==
0
)
{
TRACK
*
StartTrack
=
m_Pcb
->
m_Track
;
TRACK
*
StartTrack
=
m_Pcb
->
m_Track
;
nbsegm
=
0
;
if
(
Append
)
{
for
(
;
StartTrack
!=
NULL
;
StartTrack
=
(
TRACK
*
)
StartTrack
->
Pnext
)
for
(
;
StartTrack
!=
NULL
;
StartTrack
=
(
TRACK
*
)
StartTrack
->
Pnext
)
{
if
(
StartTrack
->
Pnext
==
NULL
)
break
;
if
(
StartTrack
->
Pnext
==
NULL
)
break
;
}
}
#ifdef PCBNEW
int
ii
=
ReadListeSegmentDescr
(
DC
,
File
,
StartTrack
,
TYPETRACK
,
&
LineNum
,
NbTrack
);
int
ii
=
ReadListeSegmentDescr
(
DC
,
File
,
StartTrack
,
TYPETRACK
,
&
LineNum
,
NbTrack
);
m_Pcb
->
m_NbSegmTrack
+=
ii
;
#endif
continue
;
}
if
(
strnicmp
(
Line
,
"$ZONE"
,
5
)
==
0
)
if
(
strnicmp
(
Line
,
"$ZONE"
,
5
)
==
0
)
{
TRACK
*
StartZone
=
m_Pcb
->
m_Zone
;
TRACK
*
StartZone
=
m_Pcb
->
m_Zone
;
if
(
Append
)
{
for
(
;
StartZone
!=
NULL
;
StartZone
=
(
TRACK
*
)
StartZone
->
Pnext
)
for
(
;
StartZone
!=
NULL
;
StartZone
=
(
TRACK
*
)
StartZone
->
Pnext
)
{
if
(
StartZone
->
Pnext
==
NULL
)
break
;
if
(
StartZone
->
Pnext
==
NULL
)
break
;
}
}
#ifdef PCBNEW
int
ii
=
ReadListeSegmentDescr
(
DC
,
File
,
StartZone
,
TYPEZONE
,
&
LineNum
,
NbZone
);
int
ii
=
ReadListeSegmentDescr
(
DC
,
File
,
StartZone
,
TYPEZONE
,
&
LineNum
,
NbZone
);
m_Pcb
->
m_NbSegmZone
+=
ii
;
#endif
continue
;
}
}
setlocale
(
LC_NUMERIC
,
""
);
// revert to the current locale
setlocale
(
LC_NUMERIC
,
""
);
// revert to the current locale
Affiche_Message
(
wxEmptyString
);
Affiche_Message
(
wxEmptyString
);
#ifdef PCBNEW
Compile_Ratsnest
(
DC
,
TRUE
);
Compile_Ratsnest
(
DC
,
TRUE
);
#endif
return
(
1
)
;
return
1
;
}
#ifdef PCBNEW
/***************************************************/
int
WinEDA_PcbFrame
::
SavePcbFormatAscii
(
FILE
*
File
)
int
WinEDA_PcbFrame
::
SavePcbFormatAscii
(
FILE
*
File
)
/****************************************************/
/* Routine de sauvegarde du PCB courant sous format ASCII
retourne
1 si OK
0 si sauvegarde non faite
*/
*
retourne
*
1 si OK
*
0 si sauvegarde non faite
*/
{
int
ii
,
NbModules
,
nseg
;
float
Pas
;
char
Line
[
256
];
EQUIPOT
*
Equipot
;
TRACK
*
PtSegm
;
EDA_BaseStruct
*
PtStruct
;
MODULE
*
Module
;
int
ii
,
NbModules
,
nseg
;
float
Pas
;
char
Line
[
256
];
EQUIPOT
*
Equipot
;
TRACK
*
PtSegm
;
EDA_BaseStruct
*
PtStruct
;
MODULE
*
Module
;
wxBeginBusyCursor
();
m_Pcb
->
m_Status_Pcb
&=
~
CONNEXION_OK
;
/* Calcul du nombre des modules */
PtStruct
=
(
EDA_BaseStruct
*
)
m_Pcb
->
m_Modules
;
PtStruct
=
(
EDA_BaseStruct
*
)
m_Pcb
->
m_Modules
;
NbModules
=
0
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
NbModules
++
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
NbModules
++
;
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
setlocale
(
LC_NUMERIC
,
"C"
);
setlocale
(
LC_NUMERIC
,
"C"
);
/* Ecriture de l'entete PCB : */
fprintf
(
File
,
"PCBNEW-BOARD Version %d date %s
\n\n
"
,
g_CurrentVersionPCB
,
DateAndTime
(
Line
)
);
fprintf
(
File
,
"PCBNEW-BOARD Version %d date %s
\n\n
"
,
g_CurrentVersionPCB
,
DateAndTime
(
Line
)
);
WriteGeneralDescrPcb
(
File
);
WriteSheetDescr
(
m_CurrentScreen
,
File
);
WriteSetup
(
File
,
this
);
WriteGeneralDescrPcb
(
File
);
WriteSheetDescr
(
m_CurrentScreen
,
File
);
WriteSetup
(
File
,
this
);
/* Ecriture des donnes utiles du pcb */
Equipot
=
m_Pcb
->
m_Equipots
;
Pas
=
100.0
;
if
(
m_Pcb
->
m_NbNets
)
Pas
/=
m_Pcb
->
m_NbNets
;
for
(
ii
=
0
;
Equipot
!=
NULL
;
ii
++
,
Equipot
=
(
EQUIPOT
*
)
Equipot
->
Pnext
)
Pas
=
100.0
;
if
(
m_Pcb
->
m_NbNets
)
Pas
/=
m_Pcb
->
m_NbNets
;
for
(
ii
=
0
;
Equipot
!=
NULL
;
ii
++
,
Equipot
=
(
EQUIPOT
*
)
Equipot
->
Pnext
)
{
Equipot
->
WriteEquipotDescr
(
File
);
DisplayActivity
((
int
)(
Pas
*
ii
),
wxT
(
"Equipot:"
)
);
Equipot
->
WriteEquipotDescr
(
File
);
DisplayActivity
(
(
int
)
(
Pas
*
ii
),
wxT
(
"Equipot:"
)
);
}
Pas
=
100.0
;
if
(
NbModules
)
Pas
/=
NbModules
;
Pas
=
100.0
;
if
(
NbModules
)
Pas
/=
NbModules
;
Module
=
m_Pcb
->
m_Modules
;
for
(
ii
=
1
;
Module
!=
NULL
;
Module
=
Module
->
Next
(),
ii
++
)
for
(
ii
=
1
;
Module
!=
NULL
;
Module
=
Module
->
Next
(),
ii
++
)
{
Module
->
WriteDescr
(
File
);
DisplayActivity
((
int
)(
ii
*
Pas
)
,
wxT
(
"Modules:"
)
);
Module
->
WriteDescr
(
File
);
DisplayActivity
(
(
int
)
(
ii
*
Pas
),
wxT
(
"Modules:"
)
);
}
/* sortie des inscriptions du PCB: */
PtStruct
=
m_Pcb
->
m_Drawings
;
for
(
;
PtStruct
!=
NULL
;
PtStruct
=
PtStruct
->
Pnext
)
{
switch
(
PtStruct
->
m_StructType
)
switch
(
PtStruct
->
m_StructType
)
{
case
TYPETEXTE
:
((
TEXTE_PCB
*
)
PtStruct
)
->
WriteTextePcbDescr
(
File
)
;
(
(
TEXTE_PCB
*
)
PtStruct
)
->
WriteTextePcbDescr
(
File
)
;
break
;
case
TYPEDRAWSEGMENT
:
((
DRAWSEGMENT
*
)
PtStruct
)
->
WriteDrawSegmentDescr
(
File
);
(
(
DRAWSEGMENT
*
)
PtStruct
)
->
WriteDrawSegmentDescr
(
File
);
break
;
case
TYPEMIRE
:
((
MIREPCB
*
)
PtStruct
)
->
WriteMirePcbDescr
(
File
);
(
(
MIREPCB
*
)
PtStruct
)
->
WriteMirePcbDescr
(
File
);
break
;
case
TYPECOTATION
:
((
COTATION
*
)
PtStruct
)
->
WriteCotationDescr
(
File
);
(
(
COTATION
*
)
PtStruct
)
->
WriteCotationDescr
(
File
);
break
;
case
TYPEMARQUEUR
:
/* sauvegarde inutile */
break
;
default
:
DisplayError
(
this
,
wxT
(
"Unknown Draw Type"
)
);
DisplayError
(
this
,
wxT
(
"Unknown Draw Type"
)
);
break
;
}
}
Pas
=
100.0
;
if
(
m_Pcb
->
m_NbSegmTrack
)
Pas
/=
(
m_Pcb
->
m_NbSegmTrack
);
fprintf
(
File
,
"$TRACK
\n
"
);
if
(
m_Pcb
->
m_NbSegmTrack
)
Pas
/=
(
m_Pcb
->
m_NbSegmTrack
);
fprintf
(
File
,
"$TRACK
\n
"
);
PtSegm
=
m_Pcb
->
m_Track
;
DisplayActivity
(
0
,
wxT
(
"Tracks:"
));
for
(
nseg
=
0
,
ii
=
0
;
PtSegm
!=
NULL
;
ii
++
,
PtSegm
=
(
TRACK
*
)
PtSegm
->
Pnext
)
DisplayActivity
(
0
,
wxT
(
"Tracks:"
)
);
for
(
nseg
=
0
,
ii
=
0
;
PtSegm
!=
NULL
;
ii
++
,
PtSegm
=
(
TRACK
*
)
PtSegm
->
Pnext
)
{
((
TRACK
*
)
PtSegm
)
->
WriteTrackDescr
(
File
);
if
(
nseg
!=
(
int
)
(
ii
*
Pas
)
)
(
(
TRACK
*
)
PtSegm
)
->
WriteTrackDescr
(
File
);
if
(
nseg
!=
(
int
)
(
ii
*
Pas
)
)
{
nseg
=
(
int
)
(
ii
*
Pas
);
DisplayActivity
(
nseg
,
wxT
(
"Tracks:"
)
);
nseg
=
(
int
)
(
ii
*
Pas
);
DisplayActivity
(
nseg
,
wxT
(
"Tracks:"
)
);
}
}
fprintf
(
File
,
"$EndTRACK
\n
"
);
fprintf
(
File
,
"$ZONE
\n
"
);
fprintf
(
File
,
"$EndTRACK
\n
"
);
fprintf
(
File
,
"$ZONE
\n
"
);
PtSegm
=
(
TRACK
*
)
m_Pcb
->
m_Zone
;
ii
=
m_Pcb
->
m_NbSegmZone
;
Pas
=
100.0
;
if
(
ii
)
Pas
/=
ii
;
Pas
=
100.0
;
if
(
ii
)
Pas
/=
ii
;
PtSegm
=
m_Pcb
->
m_Zone
;
DisplayActivity
(
0
,
wxT
(
"Zones:"
));
for
(
nseg
=
0
,
ii
=
0
;
PtSegm
!=
NULL
;
ii
++
,
PtSegm
=
(
TRACK
*
)
PtSegm
->
Pnext
)
DisplayActivity
(
0
,
wxT
(
"Zones:"
)
);
for
(
nseg
=
0
,
ii
=
0
;
PtSegm
!=
NULL
;
ii
++
,
PtSegm
=
(
TRACK
*
)
PtSegm
->
Pnext
)
{
((
TRACK
*
)
PtSegm
)
->
WriteTrackDescr
(
File
);
if
(
nseg
!=
(
int
)
(
ii
*
Pas
)
)
(
(
TRACK
*
)
PtSegm
)
->
WriteTrackDescr
(
File
);
if
(
nseg
!=
(
int
)
(
ii
*
Pas
)
)
{
nseg
=
(
int
)
(
ii
*
Pas
);
DisplayActivity
(
nseg
,
wxT
(
"Zones:"
)
);
nseg
=
(
int
)
(
ii
*
Pas
);
DisplayActivity
(
nseg
,
wxT
(
"Zones:"
)
);
}
}
fprintf
(
File
,
"$EndZONE
\n
"
);
fprintf
(
File
,
"$EndBOARD
\n
"
);
fprintf
(
File
,
"$EndZONE
\n
"
);
fprintf
(
File
,
"$EndBOARD
\n
"
);
setlocale
(
LC_NUMERIC
,
""
);
// revert to the current locale
setlocale
(
LC_NUMERIC
,
""
);
// revert to the current locale
wxEndBusyCursor
();
Affiche_Message
(
wxEmptyString
);
Affiche_Message
(
wxEmptyString
);
return
1
;
}
#endif
#endif
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