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
0a2ed094
Commit
0a2ed094
authored
17 years ago
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
see todays change_log.txt
parent
eb660b7c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1441 additions
and
1229 deletions
+1441
-1229
annotate.cpp
eeschema/annotate.cpp
+39
-26
component_class.cpp
eeschema/component_class.cpp
+14
-14
eelibs_draw_components.cpp
eeschema/eelibs_draw_components.cpp
+16
-3
fieldedi.cpp
eeschema/fieldedi.cpp
+0
-1118
fieldedi.cpp.notused
eeschema/fieldedi.cpp.notused
+1230
-0
netlist.cpp
eeschema/netlist.cpp
+131
-63
netlist.h
eeschema/netlist.h
+11
-5
No files found.
eeschema/annotate.cpp
View file @
0a2ed094
...
...
@@ -9,7 +9,7 @@
/* fonctions exportees */
int
ListeComposants
(
CmpListStruct
*
BaseListeCmp
,
SCH_SCREEN
*
screen
,
int
NumSheet
);
int
AnnotTriComposant
(
CmpListStruct
*
Objet1
,
CmpListStruct
*
Objet
2
);
int
AnnotTriComposant
(
const
void
*
o1
,
const
void
*
o
2
);
void
BreakReference
(
CmpListStruct
*
BaseListeCmp
,
int
NbOfCmp
);
/* fonctions locales */
...
...
@@ -236,8 +236,7 @@ int ListeComposants( CmpListStruct* BaseListeCmp, SCH_SCREEN* screen, int NumShe
EDA_LibComponentStruct
*
Entry
;
DrawList
=
screen
->
EEDrawList
;
while
(
DrawList
)
for
(
;
DrawList
;
DrawList
=
DrawList
->
Pnext
)
{
switch
(
DrawList
->
Type
()
)
{
...
...
@@ -253,20 +252,25 @@ int ListeComposants( CmpListStruct* BaseListeCmp, SCH_SCREEN* screen, int NumShe
Entry
=
FindLibPart
(
DrawLibItem
->
m_ChipName
.
GetData
(),
wxEmptyString
,
FIND_ROOT
);
if
(
Entry
==
NULL
)
break
;
if
(
BaseListeCmp
==
NULL
)
/* Items counting only */
{
NbrCmp
++
;
break
;
NbrCmp
++
;
break
;
}
BaseListeCmp
[
NbrCmp
].
m_Cmp
=
DrawLibItem
;
BaseListeCmp
[
NbrCmp
].
m_NbParts
=
Entry
->
m_UnitCount
;
BaseListeCmp
[
NbrCmp
].
m_Unit
=
DrawLibItem
->
m_Multi
;
BaseListeCmp
[
NbrCmp
].
m_PartsLocked
=
Entry
->
m_UnitSelectionLocked
;
BaseListeCmp
[
NbrCmp
].
m_Sheet
=
NumSheet
;
BaseListeCmp
[
NbrCmp
].
m_IsNew
=
FALSE
;
BaseListeCmp
[
NbrCmp
].
m_Pos
=
DrawLibItem
->
m_Pos
;
BaseListeCmp
[
NbrCmp
].
m_TimeStamp
=
DrawLibItem
->
m_TimeStamp
;
BaseListeCmp
[
NbrCmp
].
m_Pos
=
DrawLibItem
->
m_Pos
;
BaseListeCmp
[
NbrCmp
].
m_TimeStamp
=
DrawLibItem
->
m_TimeStamp
;
if
(
DrawLibItem
->
m_Field
[
REFERENCE
].
m_Text
.
IsEmpty
()
)
DrawLibItem
->
m_Field
[
REFERENCE
].
m_Text
=
wxT
(
"DefRef?"
);
strncpy
(
BaseListeCmp
[
NbrCmp
].
m_TextRef
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
REFERENCE
].
m_Text
),
32
);
...
...
@@ -274,6 +278,7 @@ int ListeComposants( CmpListStruct* BaseListeCmp, SCH_SCREEN* screen, int NumShe
if
(
DrawLibItem
->
m_Field
[
VALUE
].
m_Text
.
IsEmpty
()
)
DrawLibItem
->
m_Field
[
VALUE
].
m_Text
=
wxT
(
"~"
);
strncpy
(
BaseListeCmp
[
NbrCmp
].
m_TextValue
,
CONV_TO_UTF8
(
DrawLibItem
->
m_Field
[
VALUE
].
m_Text
),
32
);
NbrCmp
++
;
...
...
@@ -291,8 +296,6 @@ int ListeComposants( CmpListStruct* BaseListeCmp, SCH_SCREEN* screen, int NumShe
default
:
break
;
}
DrawList
=
DrawList
->
Pnext
;
}
return
NbrCmp
;
...
...
@@ -300,7 +303,7 @@ int ListeComposants( CmpListStruct* BaseListeCmp, SCH_SCREEN* screen, int NumShe
/*****************************************************************/
int
AnnotTriComposant
(
CmpListStruct
*
Objet1
,
CmpListStruct
*
Objet
2
)
int
AnnotTriComposant
(
const
void
*
o1
,
const
void
*
o
2
)
/****************************************************************/
/* function used par qsort() for sorting the list
...
...
@@ -312,9 +315,11 @@ int AnnotTriComposant( CmpListStruct* Objet1, CmpListStruct* Objet2 )
* if same sheet, by time stamp
**/
{
int
ii
;
CmpListStruct
*
Objet1
=
(
CmpListStruct
*
)
o1
;
CmpListStruct
*
Objet2
=
(
CmpListStruct
*
)
o2
;
ii
=
strnicmp
(
Objet1
->
m_TextRef
,
Objet2
->
m_TextRef
,
32
);
int
ii
=
strnicmp
(
Objet1
->
m_TextRef
,
Objet2
->
m_TextRef
,
32
);
if
(
SortByPosition
==
TRUE
)
{
if
(
ii
==
0
)
...
...
@@ -401,7 +406,8 @@ void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp )
BaseListeCmp
[
ii
].
m_IsNew
=
TRUE
;
if
(
!
BaseListeCmp
[
ii
].
m_PartsLocked
)
BaseListeCmp
[
ii
].
m_Unit
=
0x7FFFFFFF
;
Text
[
ll
]
=
0
;
continue
;
Text
[
ll
]
=
0
;
continue
;
}
if
(
isdigit
(
Text
[
ll
]
)
==
0
)
...
...
@@ -646,7 +652,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
/* 2eme passe : Remplissage du tableau des caracteristiques */
if
(
OneSheetOnly
==
0
)
{
ii
=
0
;
screen
=
ScreenSch
;
ii
=
0
;
screen
=
ScreenSch
;
for
(
screen
=
ScreenList
.
GetFirst
();
screen
!=
NULL
;
screen
=
ScreenList
.
GetNext
()
)
{
ii
+=
ListeComposants
(
ListeCmp
+
ii
,
screen
,
NumSheet
);
...
...
@@ -658,9 +665,7 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
ListeComposants
(
ListeCmp
,
screen
,
NumSheet
);
}
qsort
(
ListeCmp
,
NbOfCmp
,
sizeof
(
CmpListStruct
),
(
int
(
*
)
(
const
void
*
,
const
void
*
)
)
AnnotTriComposant
);
qsort
(
ListeCmp
,
NbOfCmp
,
sizeof
(
CmpListStruct
),
AnnotTriComposant
);
/* Separation des Numeros de la reference: IC1 -> IC, et 1 dans .m_NumRef */
BreakReference
(
ListeCmp
,
NbOfCmp
);
...
...
@@ -669,13 +674,16 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
error
=
0
;
for
(
ii
=
0
;
ii
<
NbOfCmp
-
1
;
ii
++
)
{
msg
.
Empty
();
Buff
.
Empty
();
msg
.
Empty
();
Buff
.
Empty
();
if
(
ListeCmp
[
ii
].
m_IsNew
)
{
if
(
ListeCmp
[
ii
].
m_NumRef
>=
0
)
Buff
<<
ListeCmp
[
ii
].
m_NumRef
;
else
Buff
=
wxT
(
"?"
);
cmpref
=
CONV_FROM_UTF8
(
ListeCmp
[
ii
].
m_TextRef
);
msg
.
Printf
(
_
(
"item not annotated: %s%s"
),
cmpref
.
GetData
(),
Buff
.
GetData
()
);
...
...
@@ -685,7 +693,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
msg
<<
Buff
;
}
DisplayError
(
NULL
,
msg
);
error
++
;
break
;
error
++
;
break
;
}
if
(
MAX
(
ListeCmp
[
ii
].
m_NbParts
,
1
)
<
ListeCmp
[
ii
].
m_Unit
)
// Annotate error
...
...
@@ -702,24 +711,27 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
ListeCmp
[
ii
].
m_Unit
,
ListeCmp
[
ii
].
m_NbParts
);
msg
<<
Buff
;
DisplayError
(
frame
,
msg
);
error
++
;
break
;
error
++
;
break
;
}
}
if
(
error
)
return
error
;
/
* comptage des elements doubls (si tous sont annots) */
/
/ count the duplicated elements (if all are annotated)
for
(
ii
=
0
;
(
ii
<
NbOfCmp
-
1
)
&&
(
error
<
4
);
ii
++
)
{
msg
.
Empty
();
Buff
.
Empty
();
msg
.
Empty
();
Buff
.
Empty
();
if
(
(
stricmp
(
ListeCmp
[
ii
].
m_TextRef
,
ListeCmp
[
ii
+
1
].
m_TextRef
)
!=
0
)
||
(
ListeCmp
[
ii
].
m_NumRef
!=
ListeCmp
[
ii
+
1
].
m_NumRef
)
)
continue
;
/* Meme reference trouve */
/* Il y a erreur si meme unite */
if
(
ListeCmp
[
ii
].
m_Unit
==
ListeCmp
[
ii
+
1
].
m_Unit
)
if
(
ListeCmp
[
ii
].
m_Unit
==
ListeCmp
[
ii
+
1
].
m_Unit
)
{
if
(
ListeCmp
[
ii
].
m_NumRef
>=
0
)
Buff
<<
ListeCmp
[
ii
].
m_NumRef
;
...
...
@@ -736,7 +748,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
msg
<<
Buff
;
}
DisplayError
(
frame
,
msg
);
error
++
;
continue
;
error
++
;
continue
;
}
/* Il y a erreur si unites differentes mais nombre de parts differentes
...
...
@@ -771,9 +784,9 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
nextcmpvalue
=
CONV_FROM_UTF8
(
ListeCmp
[
ii
+
1
].
m_TextValue
);
msg
.
Printf
(
_
(
"Diff values for %s%d%c (%s) and %s%d%c (%s)"
),
cmpref
.
GetData
(),
ListeCmp
[
ii
].
m_NumRef
,
ListeCmp
[
ii
].
m_Unit
+
'A'
-
1
,
cmpvalue
.
GetData
(),
nextcmpref
.
GetData
(
),
ListeCmp
[
ii
+
1
].
m_NumRef
,
ListeCmp
[
ii
+
1
].
m_Unit
+
'A'
-
1
,
cmpvalue
.
GetData
(),
nextcmpref
.
GetData
(),
ListeCmp
[
ii
+
1
].
m_NumRef
,
ListeCmp
[
ii
+
1
].
m_Unit
+
'A'
-
1
,
nextcmpvalue
.
GetData
()
);
DisplayError
(
frame
,
msg
);
...
...
This diff is collapsed.
Click to expand it.
eeschema/component_class.cpp
View file @
0a2ed094
...
...
@@ -49,21 +49,21 @@ const wxString& ReturnDefaultFieldName( int aFieldNdx )
* for I18n
*/
{
// avoid unnecessarily copying wxStrings.
// avoid unnecessarily copying wxStrings
at runtime
.
static
const
wxString
FieldDefaultNameList
[]
=
{
_
(
"Ref"
),
/* Reference of part, i.e. "IC21" */
_
(
"Value"
),
/* Value of part, i.e. "3.3K" */
_
(
"Footprint"
),
/* Footprint, used by cvpcb or pcbnew, i.e. "16DIP300" */
_
(
"Sheet"
),
/* for components which are a schematic file, schematic file name, i.e. "cnt16.sch" */
_
(
"Field1"
),
/* User fields (1 to n) have an editable name*/
_
(
"Field2"
),
_
(
"Field3"
),
_
(
"Field4"
),
_
(
"Field5"
),
_
(
"Field6"
),
_
(
"Field7"
),
_
(
"Field8"
),
wxT
(
"badFieldNdx!"
)
// error, and "sentinel" value
_
(
"Ref"
),
/* Reference of part, i.e. "IC21" */
_
(
"Value"
),
/* Value of part, i.e. "3.3K" */
_
(
"Footprint"
),
/* Footprint, used by cvpcb or pcbnew, i.e. "16DIP300" */
_
(
"Sheet"
),
/* for components which are a schematic file, schematic file name, i.e. "cnt16.sch" */
wxString
(
_
(
"Field"
))
+
wxT
(
"1"
),
wxString
(
_
(
"Field"
))
+
wxT
(
"2"
),
wxString
(
_
(
"Field"
))
+
wxT
(
"3"
),
wxString
(
_
(
"Field"
))
+
wxT
(
"4"
),
wxString
(
_
(
"Field"
))
+
wxT
(
"5"
),
wxString
(
_
(
"Field"
))
+
wxT
(
"6"
),
wxString
(
_
(
"Field"
))
+
wxT
(
"7"
),
wxString
(
_
(
"Field"
))
+
wxT
(
"8"
),
wxT
(
"badFieldNdx!"
)
// error, and "sentinel" value
};
if
(
(
unsigned
)
aFieldNdx
>
FIELD8
)
// catches < 0 also
...
...
This diff is collapsed.
Click to expand it.
eeschema/eelibs_draw_components.cpp
View file @
0a2ed094
...
...
@@ -348,7 +348,7 @@ EDA_LibComponentStruct* FindLibPart( const wxChar* Name, const wxString& LibName
{
EDA_LibComponentStruct
*
Entry
;
static
EDA_LibComponentStruct
DummyEntry
(
wxEmptyString
);
/* Used only to call PQFind. */
static
EDA_LibComponentStruct
DummyEntry
(
wxEmptyString
);
/* Used only to call PQFind. */
LibraryStruct
*
Lib
=
g_LibraryList
;
...
...
@@ -357,24 +357,30 @@ EDA_LibComponentStruct* FindLibPart( const wxChar* Name, const wxString& LibName
PQCompFunc
(
(
PQCompFuncType
)
LibraryEntryCompare
);
Entry
=
NULL
;
FindLibName
.
Empty
();
Entry
=
NULL
;
FindLibName
.
Empty
();
while
(
Lib
)
{
if
(
!
LibName
.
IsEmpty
()
)
{
if
(
Lib
->
m_Name
!=
LibName
)
{
Lib
=
Lib
->
m_Pnext
;
continue
;
Lib
=
Lib
->
m_Pnext
;
continue
;
}
}
if
(
Lib
==
NULL
)
break
;
Entry
=
(
EDA_LibComponentStruct
*
)
PQFind
(
Lib
->
m_Entries
,
&
DummyEntry
);
if
(
Entry
!=
NULL
)
{
FindLibName
=
Lib
->
m_Name
;
break
;
}
Lib
=
Lib
->
m_Pnext
;
}
...
...
@@ -425,11 +431,13 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
/* Elimination des elements non relatifs a l'unite */
if
(
Multi
&&
DEntry
->
m_Unit
&&
(
DEntry
->
m_Unit
!=
Multi
)
)
continue
;
if
(
convert
&&
DEntry
->
m_Convert
&&
(
DEntry
->
m_Convert
!=
convert
)
)
continue
;
if
(
DEntry
->
m_Flags
&
IS_MOVED
)
continue
;
// Element en deplacement non trace
SetHightColor
=
(
DEntry
->
m_Selected
&
IS_SELECTED
)
?
HIGHT_LIGHT_FLAG
:
0
;
LineWidth
=
MAX
(
DEntry
->
m_Width
,
g_DrawMinimunLineWidth
);
...
...
@@ -494,10 +502,12 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
{
LibDrawCircle
*
Circle
=
(
LibDrawCircle
*
)
DEntry
;
CharColor
=
GETCOLOR
(
LAYER_DEVICE
);
x1
=
Pos
.
x
+
TransMat
[
0
][
0
]
*
Circle
->
m_Pos
.
x
+
TransMat
[
0
][
1
]
*
Circle
->
m_Pos
.
y
;
y1
=
Pos
.
y
+
TransMat
[
1
][
0
]
*
Circle
->
m_Pos
.
x
+
TransMat
[
1
][
1
]
*
Circle
->
m_Pos
.
y
;
fill_option
=
Circle
->
m_Fill
&
(
~
g_PrintFillMask
);
if
(
Color
<
0
)
{
...
...
@@ -526,10 +536,12 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
/* The text orientation may need to be flipped if the
* transformation matrix cuases xy axes to be flipped. */
t1
=
(
TransMat
[
0
][
0
]
!=
0
)
^
(
Text
->
m_Horiz
!=
0
);
x1
=
Pos
.
x
+
TransMat
[
0
][
0
]
*
Text
->
m_Pos
.
x
+
TransMat
[
0
][
1
]
*
Text
->
m_Pos
.
y
;
y1
=
Pos
.
y
+
TransMat
[
1
][
0
]
*
Text
->
m_Pos
.
x
+
TransMat
[
1
][
1
]
*
Text
->
m_Pos
.
y
;
DrawGraphicText
(
panel
,
DC
,
wxPoint
(
x1
,
y1
),
CharColor
,
Text
->
m_Text
,
t1
?
TEXT_ORIENT_HORIZ
:
TEXT_ORIENT_VERT
,
Text
->
m_Size
,
...
...
@@ -579,6 +591,7 @@ void DrawLibPartAux( WinEDA_DrawPanel* panel, wxDC* DC,
&&
!
g_ShowAllPins
)
break
;
}
/* Calcul de l'orientation reelle de la Pin */
orient
=
Pin
->
ReturnPinDrawOrient
(
TransMat
);
...
...
This diff is collapsed.
Click to expand it.
eeschema/fieldedi.cpp
deleted
100644 → 0
View file @
eb660b7c
/*********************************************************************/
/* EESchema - edition des librairies: Edition des champs ( Fields ) */
/*********************************************************************/
/* Fichier fieldedi.cpp */
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "wx/spinctrl.h"
static
char
*
PanelText
[]
=
{
"Ref"
,
/* Champ Reference of part, i.e. "IC21" */
"Name"
,
/* Champ Value of part, i.e. "3.3K" */
"Fld1"
,
"Fld2"
,
"Fld3"
,
"Fld4"
,
"Fld5"
,
"Fld6"
,
"Fld7"
,
"Fld8"
,
"Pcb"
,
/* Champ Name Module PCB, i.e. "16DIP300" */
"Sheet"
/* Champ Name Schema component, i.e. "cnt16.sch" */
};
/* Routines locales */
static
void
MoveField
(
wxDC
*
DC
,
int
flag
);
static
char
*
PrefixText
(
LibraryEntryStruct
*
LibEntry
,
int
Unit
);
/* Variables locales */
extern
int
CurrentUnit
;
static
wxPoint
StartCursor
;
/* Classe de la frame des proprits d'un composant en librairie */
enum
id_libedit
{
ID_LIBEDIT_NOTEBOOK
=
3200
,
ID_PANEL_BASIC
,
ID_PANEL_ALIAS
,
ID_PANEL_REFERENCE
,
ID_PANEL_VALUE
,
ID_PANEL_FIELD1
,
ID_PANEL_FIELD2
,
ID_PANEL_FIELD3
,
ID_PANEL_FIELD4
,
ID_PANEL_FIELD5
,
ID_PANEL_FIELD6
,
ID_PANEL_FIELD7
,
ID_PANEL_FIELD8
,
ID_PANEL_MODULEPCB
,
ID_PANEL_SUBSCHEMATIC
,
ID_CLOSE_PART_PROPERTIES
,
ID_ACCEPT_PART_PROPERTIES
,
ID_ADD_ALIAS
,
ID_DELETE_ONE_ALIAS
,
ID_DELETE_ALL_ALIAS
};
/************************************/
/* class WinEDA_PartPropertiesFrame */
/************************************/
class
WinEDA_PartPropertiesFrame
:
public
wxDialog
{
private
:
WinEDA_LibeditFrame
*
m_Parent
;
wxNotebook
*
m_NoteBook
;
wxListBox
*
PartAliasList
;
wxPanel
*
PanelBasic
;
wxPanel
*
PanelAlias
;
wxPanel
*
PanelDoc
;
wxPanel
*
PanelField
[
NUMBER_OF_FIELDS
];
wxCheckBox
*
AsConvertButt
;
wxCheckBox
*
ShowFieldText
[
NUMBER_OF_FIELDS
];
wxCheckBox
*
VorientFieldText
[
NUMBER_OF_FIELDS
];
wxCheckBox
*
ShowPinNumButt
;
wxCheckBox
*
ShowPinNameButt
;
wxCheckBox
*
PinsNameInsideButt
;
wxSpinCtrl
*
SelNumberOfUnits
;
wxSpinCtrl
*
m_SetSkew
;
WinEDA_GraphicTextCtrl
*
FieldTextCtrl
[
NUMBER_OF_FIELDS
];
WinEDA_PositionCtrl
*
FieldPosition
[
NUMBER_OF_FIELDS
];
int
FieldFlags
[
NUMBER_OF_FIELDS
];
int
FieldOrient
[
NUMBER_OF_FIELDS
];
WinEDA_EnterText
*
NewDoc
;
WinEDA_EnterText
*
NewDocfile
;
WinEDA_EnterText
*
NewKeywords
;
ListOfAliasStruct
*
AliasListCopy
;
public
:
// Constructor and destructor
WinEDA_PartPropertiesFrame
(
WinEDA_LibeditFrame
*
parent
,
wxPoint
&
pos
);
~
WinEDA_PartPropertiesFrame
()
{
if
(
AliasListCopy
)
AliasListCopy
->
FreeList
();
};
private
:
void
PartPropertiesAccept
(
wxCommandEvent
&
event
);
void
DeleteAllAliasOfPart
();
void
DeleteAliasOfPart
();
void
AddAliasOfPart
();
bool
ChangeNbUnitsPerPackage
(
int
newUnit
);
bool
SetUnsetConvert
();
DECLARE_EVENT_TABLE
()
};
BEGIN_EVENT_TABLE
(
WinEDA_PartPropertiesFrame
,
wxDialog
)
EVT_BUTTON
(
ID_ACCEPT_PART_PROPERTIES
,
WinEDA_PartPropertiesFrame
::
PartPropertiesAccept
)
EVT_BUTTON
(
ID_CLOSE_PART_PROPERTIES
,
WinEDA_PartPropertiesFrame
::
Close
)
EVT_BUTTON
(
ID_ADD_ALIAS
,
WinEDA_PartPropertiesFrame
::
AddAliasOfPart
)
EVT_BUTTON
(
ID_DELETE_ONE_ALIAS
,
WinEDA_PartPropertiesFrame
::
DeleteAliasOfPart
)
EVT_BUTTON
(
ID_DELETE_ALL_ALIAS
,
WinEDA_PartPropertiesFrame
::
DeleteAllAliasOfPart
)
END_EVENT_TABLE
()
void
InstallLibeditFrame
(
WinEDA_LibeditFrame
*
parent
,
wxPoint
&
pos
)
{
WinEDA_PartPropertiesFrame
*
frame
=
new
WinEDA_PartPropertiesFrame
(
parent
,
pos
);
frame
->
ShowModal
();
frame
->
Destroy
();
}
WinEDA_PartPropertiesFrame
::
WinEDA_PartPropertiesFrame
(
WinEDA_LibeditFrame
*
parent
,
wxPoint
&
framepos
)
:
wxDialog
(
parent
,
-
1
,
_
(
"Componant properties"
),
framepos
,
wxSize
(
320
,
300
),
wxDEFAULT_DIALOG_STYLE
|
FLOAT_ON_PARENT
)
{
wxPoint
pos
;
wxLayoutConstraints
*
c
;
m_Parent
=
parent
;
SetAutoLayout
(
TRUE
);
Doc
[
0
]
=
0
;
Docfile
[
0
]
=
0
;
Keywords
[
0
]
=
0
;
AliasListCopy
=
NULL
;
for
(
int
ii
=
0
;
ii
<
NUMBER_OF_FIELDS
;
ii
++
)
{
FieldFlags
[
ii
]
=
0
;
}
if
(
CurrentLibEntry
)
{
if
(
ListAlias
)
AliasListCopy
=
ListAlias
->
DupList
();
if
(
CurrentLibEntry
->
Doc
)
strncpy
(
Doc
,
CurrentLibEntry
->
Doc
,
256
);
if
(
CurrentLibEntry
->
KeyWord
)
strncpy
(
Keywords
,
CurrentLibEntry
->
KeyWord
,
256
);
if
(
CurrentLibEntry
->
DocFile
)
strncpy
(
Docfile
,
CurrentLibEntry
->
DocFile
,
256
);
FieldFlags
[
REFERENCE
]
=
CurrentLibEntry
->
m_Prefix
.
m_Attributs
;
FieldOrient
[
REFERENCE
]
=
CurrentLibEntry
->
m_Prefix
.
m_Orient
;
FieldFlags
[
VALUE
]
=
CurrentLibEntry
->
m_Name
.
m_Attributs
;
FieldOrient
[
VALUE
]
=
CurrentLibEntry
->
m_Name
.
m_Orient
;
LibDrawField
*
Field
=
CurrentLibEntry
->
Fields
;
while
(
Field
)
{
FieldFlags
[
Field
->
m_FieldId
]
=
Field
->
m_Attributs
;
FieldOrient
[
Field
->
m_FieldId
]
=
Field
->
m_Orient
;
Field
=
(
LibDrawField
*
)
Field
->
Pnext
;
}
}
m_NoteBook
=
new
wxNotebook
(
this
,
ID_LIBEDIT_NOTEBOOK
);
c
=
new
wxLayoutConstraints
;
c
->
left
.
SameAs
(
this
,
wxLeft
,
4
);
c
->
right
.
SameAs
(
this
,
wxRight
,
4
);
c
->
top
.
SameAs
(
this
,
wxTop
,
4
);
c
->
bottom
.
SameAs
(
this
,
wxBottom
,
40
);
m_NoteBook
->
SetConstraints
(
c
);
m_NoteBook
->
SetAutoLayout
(
TRUE
);
/* Creation des boutons de commande */
pos
.
x
=
80
;
pos
.
y
=
240
;
wxButton
*
Button
=
new
wxButton
(
this
,
ID_CLOSE_PART_PROPERTIES
,
_
(
"Close"
),
pos
);
c
=
new
wxLayoutConstraints
;
c
->
left
.
SameAs
(
this
,
wxLeft
,
20
);
c
->
height
.
AsIs
();
c
->
width
.
AsIs
();
c
->
bottom
.
SameAs
(
this
,
wxBottom
,
5
);
Button
->
SetConstraints
(
c
);
pos
.
x
+=
Button
->
GetDefaultSize
().
x
+
10
;
Button
=
new
wxButton
(
this
,
ID_ACCEPT_PART_PROPERTIES
,
_
(
"Ok"
),
pos
);
c
=
new
wxLayoutConstraints
;
c
->
right
.
SameAs
(
this
,
wxRight
,
20
);
c
->
height
.
AsIs
();
c
->
width
.
AsIs
();
c
->
bottom
.
SameAs
(
this
,
wxBottom
,
5
);
Button
->
SetConstraints
(
c
);
// Add panel Basic
PanelBasic
=
new
wxPanel
(
m_NoteBook
,
ID_PANEL_BASIC
);
c
=
new
wxLayoutConstraints
;
c
->
left
.
SameAs
(
m_NoteBook
,
wxLeft
);
c
->
right
.
SameAs
(
m_NoteBook
,
wxRight
);
c
->
bottom
.
SameAs
(
m_NoteBook
,
wxBottom
);
PanelBasic
->
SetConstraints
(
c
);
m_NoteBook
->
AddPage
(
PanelBasic
,
_
(
"Options"
),
TRUE
);
pos
.
x
=
5
;
pos
.
y
=
25
;
new
wxStaticBox
(
PanelBasic
,
-
1
,
_
(
" General : "
),
pos
,
wxSize
(
150
,
120
));
pos
.
x
=
10
;
pos
.
y
+=
22
;
AsConvertButt
=
new
wxCheckBox
(
PanelBasic
,
-
1
,
_
(
"As Convert"
),
pos
);
if
(
g_AsDeMorgan
)
AsConvertButt
->
SetValue
(
TRUE
);
pos
.
y
+=
20
;
ShowPinNumButt
=
new
wxCheckBox
(
PanelBasic
,
-
1
,
_
(
"Show Pin Num"
),
pos
);
if
(
CurrentLibEntry
)
{
if
(
CurrentLibEntry
->
DrawPinNum
)
ShowPinNumButt
->
SetValue
(
TRUE
);
}
else
ShowPinNumButt
->
SetValue
(
TRUE
);
pos
.
y
+=
20
;
ShowPinNameButt
=
new
wxCheckBox
(
PanelBasic
,
-
1
,
_
(
"Show Pin Name"
),
pos
);
if
(
CurrentLibEntry
)
{
if
(
CurrentLibEntry
->
DrawPinName
)
ShowPinNameButt
->
SetValue
(
TRUE
);
}
else
ShowPinNameButt
->
SetValue
(
TRUE
);
pos
.
y
+=
20
;
PinsNameInsideButt
=
new
wxCheckBox
(
PanelBasic
,
-
1
,
_
(
"Pin Name Inside"
),
pos
);
if
(
CurrentLibEntry
)
{
if
(
CurrentLibEntry
->
TextInside
)
PinsNameInsideButt
->
SetValue
(
TRUE
);
}
else
PinsNameInsideButt
->
SetValue
(
TRUE
);
pos
.
y
+=
40
;
new
wxStaticText
(
PanelBasic
,
-
1
,
_
(
"Number of Units:"
),
pos
);
pos
.
y
+=
15
;
wxString
number
;
if
(
CurrentLibEntry
)
number
.
Printf
(
"%d"
,
CurrentLibEntry
->
NumOfUnits
);
else
number
=
"1"
;
SelNumberOfUnits
=
new
wxSpinCtrl
(
PanelBasic
,
-
1
,
number
,
pos
,
wxDefaultSize
,
wxSP_ARROW_KEYS
|
wxSP_WRAP
,
1
,
16
);
pos
.
y
-=
15
;
pos
.
x
+=
140
;
new
wxStaticText
(
PanelBasic
,
-
1
,
_
(
"Skew:"
),
pos
);
pos
.
y
+=
15
;
if
(
CurrentLibEntry
&&
CurrentLibEntry
->
TextInside
)
number
.
Printf
(
"%d"
,
CurrentLibEntry
->
TextInside
);
else
number
=
"40"
;
m_SetSkew
=
new
wxSpinCtrl
(
PanelBasic
,
-
1
,
number
,
pos
,
wxDefaultSize
,
wxSP_ARROW_KEYS
|
wxSP_WRAP
,
1
,
100
);
// Add Panel Documentation
PanelDoc
=
new
wxPanel
(
m_NoteBook
,
-
1
);
c
=
new
wxLayoutConstraints
;
c
->
left
.
SameAs
(
m_NoteBook
,
wxLeft
);
c
->
right
.
SameAs
(
m_NoteBook
,
wxRight
);
c
->
bottom
.
SameAs
(
m_NoteBook
,
wxBottom
);
PanelDoc
->
SetConstraints
(
c
);
m_NoteBook
->
AddPage
(
PanelDoc
,
_
(
"Doc"
),
FALSE
);
pos
.
x
=
5
;
pos
.
y
=
40
;
NewDoc
=
new
WinEDA_EnterText
(
PanelDoc
,
_
(
"Doc:"
),
Doc
,
pos
,
wxSize
(
285
,
-
1
)
);
pos
.
y
+=
50
;
NewKeywoed
=
new
WinEDA_EnterText
(
PanelDoc
,
_
(
"Keywords:"
),
Keywords
,
pos
,
wxSize
(
285
,
-
1
)
);
pos
.
y
+=
50
;
NewDocFile
=
new
WinEDA_EnterText
(
PanelDoc
,
_
(
"DocFileName:"
),
Docfile
,
pos
,
wxSize
(
285
,
-
1
)
);
// Add Panel Alias List
PanelAlias
=
new
wxPanel
(
m_NoteBook
,
-
1
);
c
=
new
wxLayoutConstraints
;
c
->
left
.
SameAs
(
m_NoteBook
,
wxLeft
);
c
->
right
.
SameAs
(
m_NoteBook
,
wxRight
);
c
->
bottom
.
SameAs
(
m_NoteBook
,
wxBottom
);
PanelAlias
->
SetConstraints
(
c
);
m_NoteBook
->
AddPage
(
PanelAlias
,
_
(
"Alias"
),
FALSE
);
pos
.
x
=
200
;
pos
.
y
=
70
;
new
wxButton
(
PanelAlias
,
ID_ADD_ALIAS
,
_
(
"Add"
),
pos
);
pos
.
y
+=
Button
->
GetDefaultSize
().
y
+
10
;
new
wxButton
(
PanelAlias
,
ID_DELETE_ONE_ALIAS
,
_
(
"Delete"
),
pos
);
pos
.
y
+=
Button
->
GetDefaultSize
().
y
+
10
;
new
wxButton
(
PanelAlias
,
ID_DELETE_ALL_ALIAS
,
_
(
"Delete All"
),
pos
);
pos
.
x
=
5
;
pos
.
y
=
30
;
PartAliasList
=
new
wxListBox
(
PanelAlias
,
-
1
,
pos
,
wxSize
(
160
,
170
),
0
,
NULL
,
wxLB_ALWAYS_SB
|
wxLB_SINGLE
);
wxStaticText
*
Msg
=
new
wxStaticText
(
PanelAlias
,
-
1
,
_
(
"Alias"
),
wxPoint
(
pos
.
x
,
pos
.
y
-
20
)
);
Msg
->
SetForegroundColour
(
wxColour
(
200
,
0
,
0
)
);
/* lecture des alias */
ListOfAliasStruct
*
Alias
=
AliasListCopy
;
while
(
Alias
)
{
PartAliasList
->
Append
(
Alias
->
m_Name
.
m_Text
);
Alias
=
Alias
->
Next
;
}
// Add panel Fields
for
(
int
ii
=
0
;
ii
<
NUMBER_OF_FIELDS
;
ii
++
)
{
PanelField
[
ii
]
=
new
wxPanel
(
m_NoteBook
,
ID_PANEL_REFERENCE
+
ii
);
c
=
new
wxLayoutConstraints
;
c
->
left
.
SameAs
(
m_NoteBook
,
wxLeft
);
c
->
right
.
SameAs
(
m_NoteBook
,
wxRight
);
c
->
bottom
.
SameAs
(
m_NoteBook
,
wxBottom
);
PanelField
[
ii
]
->
SetConstraints
(
c
);
m_NoteBook
->
AddPage
(
PanelField
[
ii
],
PanelText
[
ii
],
FALSE
);
pos
.
x
=
10
;
pos
.
y
=
20
;
ShowFieldText
[
ii
]
=
new
wxCheckBox
(
PanelField
[
ii
],
-
1
,
_
(
"Show Text"
),
pos
);
if
(
(
FieldFlags
[
ii
]
&
TEXT_NO_VISIBLE
)
==
0
)
ShowFieldText
[
ii
]
->
SetValue
(
TRUE
);
pos
.
x
+=
150
;
VorientFieldText
[
ii
]
=
new
wxCheckBox
(
PanelField
[
ii
],
-
1
,
_
(
"Vertical"
),
pos
);
if
(
FieldOrient
[
ii
]
)
VorientFieldText
[
ii
]
->
SetValue
(
TRUE
);
pos
.
x
=
10
;
pos
.
y
+=
50
;
wxPoint
txtpos
;
switch
(
ii
)
{
case
REFERENCE
:
if
(
CurrentLibEntry
)
txtpos
=
CurrentLibEntry
->
m_Prefix
.
m_Pos
;
else
txtpos
=
wxPoint
(
0
,
0
);
FieldTextCtrl
[
ii
]
=
new
WinEDA_GraphicTextCtrl
(
PanelField
[
ii
],
PanelText
[
ii
],
CurrentLibEntry
?
CurrentLibEntry
->
m_Prefix
.
m_Text
:
(
char
*
)
"U"
,
CurrentLibEntry
?
CurrentLibEntry
->
m_Prefix
.
m_Size
:
50
,
UnitMetric
,
pos
,
200
,
TRUE
);
FieldPosition
[
ii
]
=
new
WinEDA_PositionCtrl
(
PanelField
[
ii
],
txtpos
,
UnitMetric
,
wxPoint
(
pos
.
x
+
150
,
pos
.
y
+
32
)
);
break
;
case
VALUE
:
if
(
CurrentLibEntry
)
txtpos
=
CurrentLibEntry
->
m_Name
.
m_Pos
;
else
txtpos
=
wxPoint
(
0
,
0
);
FieldTextCtrl
[
ii
]
=
new
WinEDA_GraphicTextCtrl
(
PanelField
[
ii
],
PanelText
[
ii
],
CurrentLibEntry
?
CurrentLibEntry
->
m_Name
.
m_Text
:
NULL
,
CurrentLibEntry
?
CurrentLibEntry
->
m_Name
.
m_Size
:
50
,
UnitMetric
,
pos
,
200
,
TRUE
);
FieldPosition
[
ii
]
=
new
WinEDA_PositionCtrl
(
PanelField
[
ii
],
txtpos
,
UnitMetric
,
wxPoint
(
pos
.
x
+
150
,
pos
.
y
+
32
)
);
break
;
default
:
int
fsize
;
char
*
ftext
;
wxPoint
fpos
;
fsize
=
50
;
ftext
=
NULL
;
LibDrawField
*
Field
=
NULL
;
fpos
=
wxPoint
(
0
,
0
);
//recherche du Field de FieldId correspondant, s'il existe
if
(
CurrentLibEntry
)
{
Field
=
CurrentLibEntry
->
Fields
;
while
(
Field
)
{
if
(
Field
->
m_FieldId
==
ii
)
{
fsize
=
Field
->
m_Size
;
ftext
=
Field
->
m_Text
;
fpos
=
Field
->
m_Pos
;
break
;
}
Field
=
(
LibDrawField
*
)
Field
->
Pnext
;
}
}
FieldTextCtrl
[
ii
]
=
new
WinEDA_GraphicTextCtrl
(
PanelField
[
ii
],
PanelText
[
ii
],
ftext
,
fsize
,
UnitMetric
,
pos
,
200
,
TRUE
);
FieldPosition
[
ii
]
=
new
WinEDA_PositionCtrl
(
PanelField
[
ii
],
fpos
,
UnitMetric
,
wxPoint
(
pos
.
x
+
150
,
pos
.
y
+
32
)
);
break
;
}
}
SetModal
(
TRUE
);
}
/***************************************************************************/
/* WinEDA_PartPropertiesFrame::PartPropertiesAccept(wxCommandEvent& event) */
/***************************************************************************/
/* Met a jour les differents parametres pour le composant en cours d'dition
*/
void
WinEDA_PartPropertiesFrame
::
PartPropertiesAccept
(
wxCommandEvent
&
event
)
{
bool
recreateTB
=
FALSE
;
if
(
CurrentLibEntry
==
NULL
)
{
Close
();
return
;
}
m_Parent
->
CurrentScreen
->
SetModify
();
m_Parent
->
CurrentScreen
->
SetRefreshReq
();
if
(
ListAlias
)
ListAlias
->
FreeList
();
if
(
AliasListCopy
)
ListAlias
=
AliasListCopy
->
DupList
();
if
(
CurrentLibEntry
->
Doc
&&
strcmp
(
Doc
,
CurrentLibEntry
->
Doc
)
)
{
free
(
CurrentLibEntry
->
Doc
);
CurrentLibEntry
->
Doc
=
NULL
;
}
if
(
strlen
(
Doc
)
)
CurrentLibEntry
->
Doc
=
strdup
(
Doc
);
if
(
CurrentLibEntry
->
KeyWord
&&
strcmp
(
Keywords
,
CurrentLibEntry
->
KeyWord
)
)
{
free
(
CurrentLibEntry
->
KeyWord
);
CurrentLibEntry
->
KeyWord
=
NULL
;
}
if
(
strlen
(
Keywords
)
)
CurrentLibEntry
->
KeyWord
=
strdup
(
Keywords
);
if
(
CurrentLibEntry
->
DocFile
&&
strcmp
(
Docfile
,
CurrentLibEntry
->
DocFile
)
)
{
free
(
CurrentLibEntry
->
DocFile
);
CurrentLibEntry
->
DocFile
=
NULL
;
}
if
(
strlen
(
Docfile
)
)
CurrentLibEntry
->
DocFile
=
strdup
(
Docfile
);
CurrentLibEntry
->
m_Prefix
.
SetText
(
(
char
*
)
FieldTextCtrl
[
REFERENCE
]
->
GetText
()
);
CurrentLibEntry
->
m_Name
.
SetText
(
(
char
*
)
FieldTextCtrl
[
VALUE
]
->
GetText
()
);
CurrentLibEntry
->
m_Prefix
.
m_Size
=
FieldTextCtrl
[
REFERENCE
]
->
GetTextSize
();
CurrentLibEntry
->
m_Name
.
m_Size
=
FieldTextCtrl
[
VALUE
]
->
GetTextSize
();
CurrentLibEntry
->
m_Prefix
.
m_Pos
=
FieldPosition
[
REFERENCE
]
->
GetCoord
();
CurrentLibEntry
->
m_Name
.
m_Pos
=
FieldPosition
[
VALUE
]
->
GetCoord
();
CurrentLibEntry
->
m_Prefix
.
m_Orient
=
VorientFieldText
[
REFERENCE
]
->
GetValue
()
?
1
:
0
;
CurrentLibEntry
->
m_Name
.
m_Orient
=
VorientFieldText
[
VALUE
]
->
GetValue
()
?
1
:
0
;
if
(
ShowFieldText
[
REFERENCE
]
->
GetValue
()
)
CurrentLibEntry
->
m_Prefix
.
m_Attributs
&=
~
TEXT_NO_VISIBLE
;
else
CurrentLibEntry
->
m_Prefix
.
m_Attributs
|=
TEXT_NO_VISIBLE
;
if
(
ShowFieldText
[
VALUE
]
->
GetValue
()
)
CurrentLibEntry
->
m_Name
.
m_Attributs
&=
~
TEXT_NO_VISIBLE
;
else
CurrentLibEntry
->
m_Name
.
m_Attributs
|=
TEXT_NO_VISIBLE
;
for
(
int
ii
=
FIELD1
;
ii
<
NUMBER_OF_FIELDS
;
ii
++
)
{
LibDrawField
*
Field
=
CurrentLibEntry
->
Fields
;
LibDrawField
*
NextField
,
*
previousField
=
NULL
;
while
(
Field
)
{
NextField
=
(
LibDrawField
*
)
Field
->
Pnext
;
if
(
Field
->
m_FieldId
==
ii
)
{
Field
->
SetText
((
char
*
)
FieldTextCtrl
[
ii
]
->
GetText
());
Field
->
m_Size
=
FieldTextCtrl
[
ii
]
->
GetTextSize
();
if
(
ShowFieldText
[
ii
]
->
GetValue
()
)
Field
->
m_Attributs
&=
~
TEXT_NO_VISIBLE
;
else
Field
->
m_Attributs
|=
TEXT_NO_VISIBLE
;
Field
->
m_Orient
=
VorientFieldText
[
ii
]
->
GetValue
()
?
1
:
0
;
Field
->
m_Pos
=
FieldPosition
[
Field
->
m_FieldId
]
->
GetCoord
();
if
(
Field
->
m_Text
==
NULL
)
{
delete
Field
;
if
(
previousField
)
previousField
->
Pnext
=
NextField
;
else
CurrentLibEntry
->
Fields
=
NextField
;
}
break
;
}
previousField
=
Field
;
Field
=
NextField
;
}
if
(
(
Field
==
NULL
)
&&
strlen
(
FieldTextCtrl
[
ii
]
->
GetText
())
)
{
// N'existe pas: a creer
Field
=
new
LibDrawField
(
ii
);
Field
->
SetText
((
char
*
)
FieldTextCtrl
[
ii
]
->
GetText
());
Field
->
m_Size
=
FieldTextCtrl
[
ii
]
->
GetTextSize
();
Field
->
Pnext
=
CurrentLibEntry
->
Fields
;
if
(
ShowFieldText
[
Field
->
m_FieldId
]
->
GetValue
()
)
Field
->
m_Attributs
&=
~
TEXT_NO_VISIBLE
;
else
Field
->
m_Attributs
|=
TEXT_NO_VISIBLE
;
Field
->
m_Orient
=
VorientFieldText
[
Field
->
m_FieldId
]
->
GetValue
()
?
1
:
0
;
Field
->
m_Pos
=
FieldPosition
[
Field
->
m_FieldId
]
->
GetCoord
();
CurrentLibEntry
->
Fields
=
Field
;
}
}
int
ii
=
SelNumberOfUnits
->
GetValue
();
if
(
ChangeNbUnitsPerPackage
(
ii
)
)
recreateTB
=
TRUE
;
if
(
AsConvertButt
->
GetValue
()
)
{
if
(
!
g_AsDeMorgan
)
{
g_AsDeMorgan
=
1
;
if
(
SetUnsetConvert
()
)
recreateTB
=
TRUE
;
}
}
else
{
if
(
g_AsDeMorgan
)
{
g_AsDeMorgan
=
0
;
if
(
SetUnsetConvert
()
)
recreateTB
=
TRUE
;
}
}
CurrentLibEntry
->
DrawPinNum
=
ShowPinNumButt
->
GetValue
()
?
1
:
0
;
CurrentLibEntry
->
DrawPinName
=
ShowPinNameButt
->
GetValue
()
?
1
:
0
;
if
(
PinsNameInsideButt
->
GetValue
()
==
FALSE
)
CurrentLibEntry
->
TextInside
=
0
;
else
CurrentLibEntry
->
TextInside
=
m_SetSkew
->
GetValue
();
if
(
recreateTB
)
m_Parent
->
ReCreateHToolbar
();
Close
();
}
/***************************************************************/
/* void WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart() */
/***************************************************************/
void
WinEDA_PartPropertiesFrame
::
DeleteAllAliasOfPart
()
{
if
(
CurrentLibEntry
&&
AliasListCopy
)
{
if
(
confirmation
(
_
(
"Ok to Delete Alias LIST"
))
==
YES
)
{
if
(
AliasListCopy
)
AliasListCopy
->
FreeList
();
AliasListCopy
=
NULL
;
PartAliasList
->
Clear
();
}
}
}
/*********************************************************/
/* void WinEDA_PartPropertiesFrame::AddAliasOfPart() */
/*********************************************************/
void
WinEDA_PartPropertiesFrame
::
AddAliasOfPart
()
{
char
Line
[
LINE_LEN
];
int
llen
;
ListOfAliasStruct
*
NewAlias
;
if
(
CurrentLibEntry
==
NULL
)
return
;
*
Line
=
0
;
if
(
Get_Message
(
_
(
"Alias:"
),
Line
,
this
)
!=
0
)
return
;
ChangeSpaces
(
Line
,
'_'
);
llen
=
strlen
(
Line
)
+
1
;
NewAlias
=
LocateAlias
(
AliasListCopy
,
Line
);
if
(
NewAlias
)
{
DisplayError
(
_
(
"Already in use"
),
10
);
return
;
}
NewAlias
=
new
ListOfAliasStruct
(
Line
);
NewAlias
->
Next
=
AliasListCopy
;
AliasListCopy
=
NewAlias
;
/* affichage des alias */
PartAliasList
->
Clear
();
ListOfAliasStruct
*
Alias
=
AliasListCopy
;
while
(
Alias
)
{
PartAliasList
->
Append
(
Alias
->
m_Name
.
m_Text
);
Alias
=
Alias
->
Next
;
}
}
/********************************/
/* void DeleteAliasOfPart() */
/********************************/
void
WinEDA_PartPropertiesFrame
::
DeleteAliasOfPart
()
{
ListOfAliasStruct
*
Alias
;
wxString
aliasname
;
if
(
CurrentLibEntry
==
NULL
)
return
;
if
(
AliasListCopy
==
NULL
)
return
;
aliasname
=
PartAliasList
->
GetStringSelection
();
if
(
aliasname
==
""
)
return
;
Alias
=
AliasListCopy
;
ListOfAliasStruct
*
Previous
=
NULL
;
while
(
Alias
)
{
if
(
stricmp
(
aliasname
.
GetData
(),
Alias
->
m_Name
.
m_Text
)
==
0
)
{
if
(
Previous
)
Previous
->
Next
=
Alias
->
Next
;
else
AliasListCopy
=
Alias
->
Next
;
delete
Alias
;
break
;
}
Previous
=
Alias
;
Alias
=
Alias
->
Next
;
}
/* affichage des alias */
PartAliasList
->
Clear
();
Alias
=
AliasListCopy
;
while
(
Alias
)
{
PartAliasList
->
Append
(
Alias
->
m_Name
.
m_Text
);
Alias
=
Alias
->
Next
;
}
}
/************************************************************/
static
void
ExitMoveField
(
WinEDA_DrawFrame
*
frame
,
wxDC
*
DC
)
/************************************************************/
{
frame
->
CurrentScreen
->
ManageCurseur
=
NULL
;
frame
->
CurrentScreen
->
ForceCloseManageCurseur
=
NULL
;
if
(
CurrentDrawItem
==
NULL
)
return
;
wxPoint
curpos
;
curpos
=
frame
->
CurrentScreen
->
Curseur
;
frame
->
CurrentScreen
->
Curseur
=
StartCursor
;
MoveField
(
DC
,
1
);
frame
->
CurrentScreen
->
Curseur
=
curpos
;
CurrentDrawItem
->
m_Flags
=
0
;
CurrentDrawItem
=
NULL
;
}
/*********************************************/
/* static void StartMoveField(COMMAND * Cmd) */
/*********************************************/
/* Initialise le deplacement d'un champ ( ref ou Name) */
void
WinEDA_LibeditFrame
::
StartMoveField
(
wxDC
*
DC
,
LibDrawField
*
field
)
{
if
(
(
CurrentLibEntry
==
NULL
)
||
(
field
==
NULL
)
)
return
;
CurrentDrawItem
=
field
;
CurrentDrawItem
->
m_Flags
|=
IS_MOVED
;
CurrentScreen
->
ManageCurseur
=
MoveField
;
CurrentScreen
->
ForceCloseManageCurseur
=
ExitMoveField
;
CurrentScreen
->
ManageCurseur
(
DC
,
1
);
StartCursor
=
CurrentScreen
->
Curseur
;
}
/*****************************************************************/
/* Routine d'affichage du texte 'Field' en cours de deplacement. */
/* Routine normalement attachee au curseur */
/*****************************************************************/
static
void
MoveField
(
wxDC
*
DC
,
int
flag
)
{
int
color
;
LibDrawField
*
Field
=
(
LibDrawField
*
)
CurrentDrawItem
;
if
(
(
CurrentLibEntry
==
NULL
)
||
(
Field
==
NULL
)
)
return
;
GRSetDrawMode
(
DC
,
XOR_MODE
);
switch
(
Field
->
m_FieldId
)
{
case
VALUE
:
color
=
ReturnLayerColor
(
LAYER_VALUEPART
);
break
;
case
REFERENCE
:
color
=
ReturnLayerColor
(
LAYER_REFERENCEPART
);
break
;
default
:
color
=
ReturnLayerColor
(
LAYER_FIELDS
);
break
;
}
if
(
Field
->
m_Attributs
&
TEXT_NO_VISIBLE
)
color
=
DARKGRAY
;
if
(
flag
>=
0
)
Gr_E_texte
(
DC
,
Field
->
m_Pos
.
x
,
-
Field
->
m_Pos
.
y
,
color
,
Field
->
m_Text
,
Field
->
m_Orient
,
Field
->
m_Size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
);
Field
->
m_Pos
.
x
=
ActiveScreen
->
Curseur
.
x
;
Field
->
m_Pos
.
y
=
-
ActiveScreen
->
Curseur
.
y
;
Gr_E_texte
(
DC
,
Field
->
m_Pos
.
x
,
-
Field
->
m_Pos
.
y
,
color
,
Field
->
m_Text
,
Field
->
m_Orient
,
Field
->
m_Size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
);
}
/********************************/
/* static void PlaceField() */
/********************************/
void
WinEDA_LibeditFrame
::
PlaceField
(
wxDC
*
DC
,
LibDrawField
*
Field
)
{
int
color
;
if
(
Field
==
NULL
)
return
;
GRSetDrawMode
(
DC
,
GR_DEFAULT_DRAWMODE
);
switch
(
Field
->
m_FieldId
)
{
case
REFERENCE
:
color
=
ReturnLayerColor
(
LAYER_REFERENCEPART
);
break
;
case
VALUE
:
color
=
ReturnLayerColor
(
LAYER_VALUEPART
);
break
;
default
:
color
=
ReturnLayerColor
(
LAYER_FIELDS
);
break
;
}
if
(
Field
->
m_Attributs
&
TEXT_NO_VISIBLE
)
color
=
DARKGRAY
;
Gr_E_texte
(
DC
,
Field
->
m_Pos
.
x
,
-
Field
->
m_Pos
.
y
,
color
,
Field
->
m_Text
,
Field
->
m_Orient
,
Field
->
m_Size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
);
Field
->
m_Flags
=
0
;
CurrentScreen
->
SetModify
();
CurrentScreen
->
ManageCurseur
=
NULL
;
CurrentScreen
->
ForceCloseManageCurseur
=
NULL
;
CurrentDrawItem
=
NULL
;
}
/****************************************/
/* static void EditField(COMMAND * Cmd) */
/****************************************/
void
WinEDA_LibeditFrame
::
EditField
(
wxDC
*
DC
,
LibDrawField
*
Field
)
{
char
Text
[
LINE_LEN
];
int
color
;
wxClientDC
dc
(
DrawPanel
);
if
(
Field
==
NULL
)
return
;
switch
(
Field
->
m_FieldId
)
{
case
REFERENCE
:
color
=
ReturnLayerColor
(
LAYER_REFERENCEPART
);
break
;
case
VALUE
:
color
=
ReturnLayerColor
(
LAYER_VALUEPART
);
break
;
default
:
color
=
ReturnLayerColor
(
LAYER_FIELDS
);
break
;
}
*
Text
=
0
;
if
(
Field
->
m_Attributs
&
TEXT_NO_VISIBLE
)
color
=
DARKGRAY
;
if
(
Field
->
m_Text
)
strcpy
(
Text
,
Field
->
m_Text
);
Get_Message
(
_
(
"Text: "
),
Text
,
this
);
ChangeSpaces
(
Text
,
'_'
);
GRSetDrawMode
(
&
dc
,
XOR_MODE
);
Gr_E_texte
(
DC
,
Field
->
m_Pos
.
x
,
-
Field
->
m_Pos
.
y
,
color
,
Field
->
m_Text
,
Field
->
m_Orient
,
Field
->
m_Size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
);
Field
->
SetText
(
Text
);
if
(
Field
->
m_Flags
==
0
)
GRSetDrawMode
(
&
dc
,
GR_DEFAULT_DRAWMODE
);
Gr_E_texte
(
DC
,
Field
->
m_Pos
.
x
,
-
Field
->
m_Pos
.
y
,
color
,
Field
->
m_Text
,
Field
->
m_Orient
,
Field
->
m_Size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
);
CurrentScreen
->
SetModify
();
}
/*******************************************************************/
void
WinEDA_LibeditFrame
::
RotateField
(
wxDC
*
DC
,
LibDrawField
*
Field
)
/*******************************************************************/
/*
Routine de modification de l'orientation ( Horiz ou Vert. ) du champ.
si un champ est en cours d'edition, modif de celui ci.
sinon Modif du champ pointe par la souris
*/
{
int
color
;
if
(
Field
==
NULL
)
return
;
CurrentScreen
->
SetModify
();
switch
(
Field
->
m_FieldId
)
{
case
REFERENCE
:
color
=
ReturnLayerColor
(
LAYER_REFERENCEPART
);
break
;
case
VALUE
:
color
=
ReturnLayerColor
(
LAYER_VALUEPART
);
break
;
default
:
color
=
ReturnLayerColor
(
LAYER_FIELDS
);
break
;
}
if
(
Field
->
m_Attributs
&
TEXT_NO_VISIBLE
)
color
=
DARKGRAY
;
GRSetDrawMode
(
DC
,
XOR_MODE
);
Gr_E_texte
(
DC
,
Field
->
m_Pos
.
x
,
-
Field
->
m_Pos
.
y
,
color
,
Field
->
m_Text
,
Field
->
m_Orient
,
Field
->
m_Size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
);
if
(
Field
->
m_Orient
)
Field
->
m_Orient
=
0
;
else
Field
->
m_Orient
=
1
;
if
(
Field
->
m_Flags
==
0
)
GRSetDrawMode
(
DC
,
GR_DEFAULT_DRAWMODE
);
Gr_E_texte
(
DC
,
Field
->
m_Pos
.
x
,
-
Field
->
m_Pos
.
y
,
color
,
Field
->
m_Text
,
Field
->
m_Orient
,
Field
->
m_Size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
);
}
/********************************************************/
/* static int LocateField(LibraryEntryStruct *LibEntry) */
/********************************************************/
/* Localise le champ (ref ou name) pointe par la souris
retourne:
< 0: Pas de champ
0: Ref
1: Name(s)
> 2 = Num Field
*/
LibDrawField
*
WinEDA_LibeditFrame
::
LocateField
(
LibraryEntryStruct
*
LibEntry
)
{
int
x0
,
y0
,
x1
,
y1
;
/* Rectangle d'encadrement des textes a localiser */
int
dx
,
dy
;
/* Dimensions du texte */
LibDrawField
*
Field
;
/* Localisation du Nom */
x0
=
LibEntry
->
m_Name
.
m_Pos
.
x
;
y0
=
-
LibEntry
->
m_Name
.
m_Pos
.
y
;
dx
=
LibEntry
->
m_Name
.
m_Size
*
strlen
(
LibEntry
->
m_Name
.
m_Text
),
dy
=
LibEntry
->
m_Name
.
m_Size
;
if
(
LibEntry
->
m_Name
.
m_Orient
)
EXCHG
(
dx
,
dy
);
x0
-=
dx
/
2
;
y0
-=
dy
/
2
;
x1
=
x0
+
dx
;
y1
=
y0
+
dy
;
if
(
(
CurrentScreen
->
Curseur
.
x
>=
x0
)
&&
(
CurrentScreen
->
Curseur
.
x
<=
x1
)
&&
(
CurrentScreen
->
Curseur
.
y
>=
y0
)
&&
(
CurrentScreen
->
Curseur
.
y
<=
y1
)
)
return
&
LibEntry
->
m_Name
;
/* Localisation du Prefix */
x0
=
LibEntry
->
m_Prefix
.
m_Pos
.
x
;
y0
=
-
LibEntry
->
m_Prefix
.
m_Pos
.
y
;
dx
=
LibEntry
->
m_Prefix
.
m_Size
*
strlen
(
LibEntry
->
m_Prefix
.
m_Text
),
dy
=
LibEntry
->
m_Prefix
.
m_Size
;
if
(
LibEntry
->
m_Prefix
.
m_Orient
)
EXCHG
(
dx
,
dy
);
x0
-=
dx
/
2
;
y0
-=
dy
/
2
;
x1
=
x0
+
dx
;
y1
=
y0
+
dy
;
if
(
(
CurrentScreen
->
Curseur
.
x
>=
x0
)
&&
(
CurrentScreen
->
Curseur
.
x
<=
x1
)
&&
(
CurrentScreen
->
Curseur
.
y
>=
y0
)
&&
(
CurrentScreen
->
Curseur
.
y
<=
y1
)
)
return
&
LibEntry
->
m_Prefix
;
/* Localisation des autres fields */
for
(
Field
=
LibEntry
->
Fields
;
Field
!=
NULL
;
Field
=
(
LibDrawField
*
)
Field
->
Pnext
)
{
if
(
Field
->
m_Text
==
NULL
)
continue
;
x0
=
Field
->
m_Pos
.
x
;
y0
=
-
Field
->
m_Pos
.
y
;
dx
=
Field
->
m_Size
*
strlen
(
Field
->
m_Text
),
dy
=
Field
->
m_Size
;
if
(
Field
->
m_Orient
)
EXCHG
(
dx
,
dy
);
x0
-=
dx
/
2
;
y0
-=
dy
/
2
;
x1
=
x0
+
dx
;
y1
=
y0
+
dy
;
if
(
(
CurrentScreen
->
Curseur
.
x
>=
x0
)
&&
(
CurrentScreen
->
Curseur
.
x
<=
x1
)
&&
(
CurrentScreen
->
Curseur
.
y
>=
y0
)
&&
(
CurrentScreen
->
Curseur
.
y
<=
y1
)
)
return
(
Field
);
}
return
NULL
;
}
/*********************************************************************/
/* static char * PrefixText(LibraryEntryStruct * LibEntry, int Unit) */
/*********************************************************************/
/* Calcule l'affichage complet du prefixe ( texte + '?' + ident unit )
Retourne un pointeur sur le nouveau texte (allocation statique)
*/
static
char
*
PrefixText
(
LibraryEntryStruct
*
LibEntry
,
int
Unit
)
{
static
char
Text
[
LINE_LEN
];
if
(
LibEntry
->
NumOfUnits
>
1
)
sprintf
(
Text
,
"%s?%c"
,
LibEntry
->
m_Prefix
.
m_Text
,
Unit
+
'A'
-
1
);
else
sprintf
(
Text
,
"%s?"
,
LibEntry
->
m_Prefix
.
m_Text
);
return
(
Text
);
}
/*****************************************************************/
/* void WinEDA_PartPropertiesFrame::ChangeNbUnitsPerPackagevoid) */
/*****************************************************************/
/* Routine de modification du nombre d'unites par package pour le
composant courant;
*/
bool
WinEDA_PartPropertiesFrame
::
ChangeNbUnitsPerPackage
(
int
MaxUnit
)
{
int
OldNumUnits
,
ii
,
FlagDel
=
-
1
;
LibEDA_BaseStruct
*
DrawItem
,
*
NextDrawItem
;
if
(
CurrentLibEntry
==
NULL
)
return
FALSE
;
/* Si pas de changement: termine */
if
(
CurrentLibEntry
->
NumOfUnits
==
MaxUnit
)
return
FALSE
;
OldNumUnits
=
CurrentLibEntry
->
NumOfUnits
;
if
(
OldNumUnits
<
1
)
OldNumUnits
=
1
;
CurrentLibEntry
->
NumOfUnits
=
MaxUnit
;
/* Traitement des unites enlevees ou rajoutees */
if
(
OldNumUnits
>
CurrentLibEntry
->
NumOfUnits
)
{
DrawItem
=
CurrentLibEntry
->
Drawings
;
for
(
;
DrawItem
!=
NULL
;
DrawItem
=
NextDrawItem
)
{
NextDrawItem
=
DrawItem
->
Pnext
;
if
(
DrawItem
->
m_Unit
>
MaxUnit
)
/* Item a effacer */
{
if
(
FlagDel
<
0
)
{
if
(
confirmation
(
_
(
"Delete units"
))
==
YES
)
{
/* Si part selectee n'existe plus: selection 1ere unit */
if
(
CurrentUnit
>
MaxUnit
)
CurrentUnit
=
1
;
FlagDel
=
1
;
}
else
{
FlagDel
=
0
;
MaxUnit
=
OldNumUnits
;
CurrentLibEntry
->
NumOfUnits
=
MaxUnit
;
return
FALSE
;
}
}
DeleteOneLibraryDrawStruct
(
NULL
,
CurrentLibEntry
,
DrawItem
,
0
);
}
}
return
TRUE
;
}
if
(
OldNumUnits
<
CurrentLibEntry
->
NumOfUnits
)
{
DrawItem
=
CurrentLibEntry
->
Drawings
;
for
(
;
DrawItem
!=
NULL
;
DrawItem
=
DrawItem
->
Pnext
)
{
/* Duplication des items pour autres elements */
if
(
DrawItem
->
m_Unit
==
1
)
{
for
(
ii
=
OldNumUnits
+
1
;
ii
<=
MaxUnit
;
ii
++
)
{
NextDrawItem
=
CopyDrawEntryStruct
(
DrawItem
);
NextDrawItem
->
Pnext
=
CurrentLibEntry
->
Drawings
;
CurrentLibEntry
->
Drawings
=
NextDrawItem
;
NextDrawItem
->
m_Unit
=
ii
;
}
}
}
}
return
TRUE
;
}
/**********************************************************/
/* void WinEDA_PartPropertiesFrame::SetUnsetConvert() */
/**********************************************************/
/* cre ou efface (selon option AsConvert) les lments
de la reprsentation convertie d'un composant
*/
bool
WinEDA_PartPropertiesFrame
::
SetUnsetConvert
()
{
int
FlagDel
=
0
;
LibEDA_BaseStruct
*
DrawItem
=
NULL
,
*
NextDrawItem
;
if
(
g_AsDeMorgan
)
/* Representation convertie a creer */
{
/* Traitement des elements a ajouter ( pins seulement ) */
if
(
CurrentLibEntry
)
DrawItem
=
CurrentLibEntry
->
Drawings
;
for
(
;
DrawItem
!=
NULL
;
DrawItem
=
DrawItem
->
Pnext
)
{
/* Duplication des items pour autres elements */
if
(
DrawItem
->
Type
()
!=
PIN_DRAW_TYPE
)
continue
;
if
(
DrawItem
->
m_Convert
==
1
)
{
if
(
FlagDel
==
0
)
{
if
(
confirmation
(
_
(
"Create pins for Convert items"
))
==
YES
)
FlagDel
=
1
;
else
{
if
(
confirmation
(
_
(
"Part as
\"
De Morgan
\"
anymore"
))
==
YES
)
return
TRUE
;
g_AsDeMorgan
=
0
;
return
FALSE
;
}
}
NextDrawItem
=
CopyDrawEntryStruct
(
DrawItem
);
NextDrawItem
->
Pnext
=
CurrentLibEntry
->
Drawings
;
CurrentLibEntry
->
Drawings
=
NextDrawItem
;
NextDrawItem
->
m_Convert
=
2
;
}
}
}
else
/* Representation convertie a supprimer */
{
/* Traitement des elements supprimer */
if
(
CurrentLibEntry
)
DrawItem
=
CurrentLibEntry
->
Drawings
;
for
(
;
DrawItem
!=
NULL
;
DrawItem
=
NextDrawItem
)
{
NextDrawItem
=
DrawItem
->
Pnext
;
if
(
DrawItem
->
m_Convert
>
1
)
/* Item a effacer */
{
if
(
FlagDel
==
0
)
{
if
(
confirmation
(
_
(
"Delete Convert items"
))
==
YES
)
{
CurrentConvert
=
1
;
FlagDel
=
1
;
}
else
{
g_AsDeMorgan
=
1
;
return
FALSE
;
}
}
ActiveScreen
->
SetModify
();
DeleteOneLibraryDrawStruct
(
NULL
,
CurrentLibEntry
,
DrawItem
,
0
);
}
}
}
return
TRUE
;
}
This diff is collapsed.
Click to expand it.
eeschema/fieldedi.cpp.notused
0 → 100644
View file @
0a2ed094
/*********************************************************************/
/* EESchema - edition des librairies: Edition des champs ( Fields ) */
/*********************************************************************/
/* Fichier fieldedi.cpp */
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
#include "protos.h"
#include "wx/spinctrl.h"
static char* PanelText[] =
{
"Ref", /* Champ Reference of part, i.e. "IC21" */
"Name", /* Champ Value of part, i.e. "3.3K" */
"Fld1",
"Fld2",
"Fld3",
"Fld4",
"Fld5",
"Fld6",
"Fld7",
"Fld8",
"Pcb", /* Champ Name Module PCB, i.e. "16DIP300" */
"Sheet" /* Champ Name Schema component, i.e. "cnt16.sch" */
};
/* Routines locales */
static void MoveField( wxDC* DC, int flag );
static char* PrefixText( LibraryEntryStruct* LibEntry, int Unit );
/* Variables locales */
extern int CurrentUnit;
static wxPoint StartCursor;
/* Classe de la frame des proprits d'un composant en librairie */
enum id_libedit {
ID_LIBEDIT_NOTEBOOK = 3200,
ID_PANEL_BASIC,
ID_PANEL_ALIAS,
ID_PANEL_REFERENCE,
ID_PANEL_VALUE,
ID_PANEL_FIELD1,
ID_PANEL_FIELD2,
ID_PANEL_FIELD3,
ID_PANEL_FIELD4,
ID_PANEL_FIELD5,
ID_PANEL_FIELD6,
ID_PANEL_FIELD7,
ID_PANEL_FIELD8,
ID_PANEL_MODULEPCB,
ID_PANEL_SUBSCHEMATIC,
ID_CLOSE_PART_PROPERTIES,
ID_ACCEPT_PART_PROPERTIES,
ID_ADD_ALIAS,
ID_DELETE_ONE_ALIAS,
ID_DELETE_ALL_ALIAS
};
/************************************/
/* class WinEDA_PartPropertiesFrame */
/************************************/
class WinEDA_PartPropertiesFrame : public wxDialog
{
private:
WinEDA_LibeditFrame* m_Parent;
wxNotebook* m_NoteBook;
wxListBox* PartAliasList;
wxPanel* PanelBasic;
wxPanel* PanelAlias;
wxPanel* PanelDoc;
wxPanel* PanelField[NUMBER_OF_FIELDS];
wxCheckBox* AsConvertButt;
wxCheckBox* ShowFieldText[NUMBER_OF_FIELDS];
wxCheckBox* VorientFieldText[NUMBER_OF_FIELDS];
wxCheckBox* ShowPinNumButt;
wxCheckBox* ShowPinNameButt;
wxCheckBox* PinsNameInsideButt;
wxSpinCtrl* SelNumberOfUnits;
wxSpinCtrl* m_SetSkew;
WinEDA_GraphicTextCtrl* FieldTextCtrl[NUMBER_OF_FIELDS];
WinEDA_PositionCtrl* FieldPosition[NUMBER_OF_FIELDS];
int FieldFlags[NUMBER_OF_FIELDS];
int FieldOrient[NUMBER_OF_FIELDS];
WinEDA_EnterText* NewDoc;
WinEDA_EnterText* NewDocfile;
WinEDA_EnterText* NewKeywords;
ListOfAliasStruct* AliasListCopy;
public:
// Constructor and destructor
WinEDA_PartPropertiesFrame( WinEDA_LibeditFrame * parent, wxPoint & pos );
~WinEDA_PartPropertiesFrame()
{
if( AliasListCopy )
AliasListCopy->FreeList();
};
private:
void PartPropertiesAccept( wxCommandEvent& event );
void DeleteAllAliasOfPart();
void DeleteAliasOfPart();
void AddAliasOfPart();
bool ChangeNbUnitsPerPackage( int newUnit );
bool SetUnsetConvert();
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE( WinEDA_PartPropertiesFrame, wxDialog )
EVT_BUTTON( ID_ACCEPT_PART_PROPERTIES, WinEDA_PartPropertiesFrame::PartPropertiesAccept )
EVT_BUTTON( ID_CLOSE_PART_PROPERTIES, WinEDA_PartPropertiesFrame::Close )
EVT_BUTTON( ID_ADD_ALIAS, WinEDA_PartPropertiesFrame::AddAliasOfPart )
EVT_BUTTON( ID_DELETE_ONE_ALIAS, WinEDA_PartPropertiesFrame::DeleteAliasOfPart )
EVT_BUTTON( ID_DELETE_ALL_ALIAS, WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart )
END_EVENT_TABLE()
void InstallLibeditFrame( WinEDA_LibeditFrame* parent, wxPoint& pos )
{
WinEDA_PartPropertiesFrame* frame = new WinEDA_PartPropertiesFrame( parent, pos );
frame->ShowModal(); frame->Destroy();
}
WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame( WinEDA_LibeditFrame* parent,
wxPoint& framepos ) :
wxDialog( parent, -1, _( "Componant properties" ), framepos, wxSize( 320, 300 ),
wxDEFAULT_DIALOG_STYLE | FLOAT_ON_PARENT )
{
wxPoint pos;
wxLayoutConstraints* c;
m_Parent = parent;
SetAutoLayout( TRUE );
Doc[0] = 0; Docfile[0] = 0; Keywords[0] = 0;
AliasListCopy = NULL;
for( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
{
FieldFlags[ii] = 0;
}
if( CurrentLibEntry )
{
if( ListAlias )
AliasListCopy = ListAlias->DupList();
if( CurrentLibEntry->Doc )
strncpy( Doc, CurrentLibEntry->Doc, 256 );
if( CurrentLibEntry->KeyWord )
strncpy( Keywords, CurrentLibEntry->KeyWord, 256 );
if( CurrentLibEntry->DocFile )
strncpy( Docfile, CurrentLibEntry->DocFile, 256 );
FieldFlags[REFERENCE] = CurrentLibEntry->m_Prefix.m_Attributs;
FieldOrient[REFERENCE] = CurrentLibEntry->m_Prefix.m_Orient;
FieldFlags[VALUE] = CurrentLibEntry->m_Name.m_Attributs;
FieldOrient[VALUE] = CurrentLibEntry->m_Name.m_Orient;
LibDrawField* Field = CurrentLibEntry->Fields;
while( Field )
{
FieldFlags[Field->m_FieldId] = Field->m_Attributs;
FieldOrient[Field->m_FieldId] = Field->m_Orient;
Field = (LibDrawField*) Field->Pnext;
}
}
m_NoteBook = new wxNotebook( this, ID_LIBEDIT_NOTEBOOK );
c = new wxLayoutConstraints;
c->left.SameAs( this, wxLeft, 4 );
c->right.SameAs( this, wxRight, 4 );
c->top.SameAs( this, wxTop, 4 );
c->bottom.SameAs( this, wxBottom, 40 );
m_NoteBook->SetConstraints( c );
m_NoteBook->SetAutoLayout( TRUE );
/* Creation des boutons de commande */
pos.x = 80; pos.y = 240;
wxButton* Button = new wxButton( this, ID_CLOSE_PART_PROPERTIES,
_( "Close" ), pos );
c = new wxLayoutConstraints;
c->left.SameAs( this, wxLeft, 20 );
c->height.AsIs();
c->width.AsIs();
c->bottom.SameAs( this, wxBottom, 5 );
Button->SetConstraints( c );
pos.x += Button->GetDefaultSize().x + 10;
Button = new wxButton( this, ID_ACCEPT_PART_PROPERTIES,
_( "Ok" ), pos );
c = new wxLayoutConstraints;
c->right.SameAs( this, wxRight, 20 );
c->height.AsIs();
c->width.AsIs();
c->bottom.SameAs( this, wxBottom, 5 );
Button->SetConstraints( c );
// Add panel Basic
PanelBasic = new wxPanel( m_NoteBook, ID_PANEL_BASIC );
c = new wxLayoutConstraints;
c->left.SameAs( m_NoteBook, wxLeft );
c->right.SameAs( m_NoteBook, wxRight );
c->bottom.SameAs( m_NoteBook, wxBottom );
PanelBasic->SetConstraints( c );
m_NoteBook->AddPage( PanelBasic, _( "Options" ), TRUE );
pos.x = 5; pos.y = 25;
new wxStaticBox( PanelBasic, -1, _( " General : " ), pos, wxSize( 150, 120 ) );
pos.x = 10; pos.y += 22;
AsConvertButt = new wxCheckBox( PanelBasic, -1, _( "As Convert" ), pos );
if( g_AsDeMorgan )
AsConvertButt->SetValue( TRUE );
pos.y += 20;
ShowPinNumButt = new wxCheckBox( PanelBasic, -1, _( "Show Pin Num" ), pos );
if( CurrentLibEntry )
{
if( CurrentLibEntry->DrawPinNum )
ShowPinNumButt->SetValue( TRUE );
}
else
ShowPinNumButt->SetValue( TRUE );
pos.y += 20;
ShowPinNameButt = new wxCheckBox( PanelBasic, -1, _( "Show Pin Name" ), pos );
if( CurrentLibEntry )
{
if( CurrentLibEntry->DrawPinName )
ShowPinNameButt->SetValue( TRUE );
}
else
ShowPinNameButt->SetValue( TRUE );
pos.y += 20;
PinsNameInsideButt = new wxCheckBox( PanelBasic, -1, _( "Pin Name Inside" ), pos );
if( CurrentLibEntry )
{
if( CurrentLibEntry->TextInside )
PinsNameInsideButt->SetValue( TRUE );
}
else
PinsNameInsideButt->SetValue( TRUE );
pos.y += 40;
new wxStaticText( PanelBasic, -1, _( "Number of Units:" ), pos );
pos.y += 15;
wxString number;
if( CurrentLibEntry )
number.Printf( "%d", CurrentLibEntry->NumOfUnits );
else
number = "1";
SelNumberOfUnits = new wxSpinCtrl( PanelBasic, -1, number, pos,
wxDefaultSize, wxSP_ARROW_KEYS | wxSP_WRAP,
1, 16 );
pos.y -= 15; pos.x += 140;
new wxStaticText( PanelBasic, -1, _( "Skew:" ), pos );
pos.y += 15;
if( CurrentLibEntry && CurrentLibEntry->TextInside )
number.Printf( "%d", CurrentLibEntry->TextInside );
else
number = "40";
m_SetSkew = new wxSpinCtrl( PanelBasic, -1, number, pos,
wxDefaultSize, wxSP_ARROW_KEYS | wxSP_WRAP,
1, 100 );
// Add Panel Documentation
PanelDoc = new wxPanel( m_NoteBook, -1 );
c = new wxLayoutConstraints;
c->left.SameAs( m_NoteBook, wxLeft );
c->right.SameAs( m_NoteBook, wxRight );
c->bottom.SameAs( m_NoteBook, wxBottom );
PanelDoc->SetConstraints( c );
m_NoteBook->AddPage( PanelDoc, _( "Doc" ), FALSE );
pos.x = 5; pos.y = 40;
NewDoc = new WinEDA_EnterText( PanelDoc,
_( "Doc:" ), Doc,
pos, wxSize( 285, -1 ) );
pos.y += 50;
NewKeywoed = new WinEDA_EnterText( PanelDoc,
_( "Keywords:" ), Keywords,
pos, wxSize( 285, -1 ) );
pos.y += 50;
NewDocFile = new WinEDA_EnterText( PanelDoc,
_( "DocFileName:" ), Docfile,
pos, wxSize( 285, -1 ) );
// Add Panel Alias List
PanelAlias = new wxPanel( m_NoteBook, -1 );
c = new wxLayoutConstraints;
c->left.SameAs( m_NoteBook, wxLeft );
c->right.SameAs( m_NoteBook, wxRight );
c->bottom.SameAs( m_NoteBook, wxBottom );
PanelAlias->SetConstraints( c );
m_NoteBook->AddPage( PanelAlias, _( "Alias" ), FALSE );
pos.x = 200; pos.y = 70;
new wxButton( PanelAlias, ID_ADD_ALIAS,
_( "Add" ), pos );
pos.y += Button->GetDefaultSize().y + 10;
new wxButton( PanelAlias, ID_DELETE_ONE_ALIAS,
_( "Delete" ), pos );
pos.y += Button->GetDefaultSize().y + 10;
new wxButton( PanelAlias, ID_DELETE_ALL_ALIAS,
_( "Delete All" ), pos );
pos.x = 5; pos.y = 30;
PartAliasList = new wxListBox( PanelAlias,
-1,
pos, wxSize( 160, 170 ),
0, NULL,
wxLB_ALWAYS_SB | wxLB_SINGLE );
wxStaticText* Msg = new wxStaticText( PanelAlias, -1, _( "Alias" ),
wxPoint (pos.x, pos.y - 20) );
Msg->SetForegroundColour( wxColour( 200, 0, 0 ) );
/* lecture des alias */
ListOfAliasStruct* Alias = AliasListCopy;
while( Alias )
{
PartAliasList->Append( Alias->m_Name.m_Text );
Alias = Alias->Next;
}
// Add panel Fields
for( int ii = 0; ii < NUMBER_OF_FIELDS; ii++ )
{
PanelField[ii] = new wxPanel( m_NoteBook, ID_PANEL_REFERENCE + ii );
c = new wxLayoutConstraints;
c->left.SameAs( m_NoteBook, wxLeft );
c->right.SameAs( m_NoteBook, wxRight );
c->bottom.SameAs( m_NoteBook, wxBottom );
PanelField[ii]->SetConstraints( c );
m_NoteBook->AddPage( PanelField[ii], PanelText[ii], FALSE );
pos.x = 10; pos.y = 20;
ShowFieldText[ii] = new wxCheckBox( PanelField[ii], -1,
_( "Show Text" ), pos );
if( (FieldFlags[ii] & TEXT_NO_VISIBLE ) == 0 )
ShowFieldText[ii]->SetValue( TRUE );
pos.x += 150;
VorientFieldText[ii] = new wxCheckBox( PanelField[ii], -1,
_( "Vertical" ), pos );
if( FieldOrient[ii] )
VorientFieldText[ii]->SetValue( TRUE );
pos.x = 10; pos.y += 50;
wxPoint txtpos;
switch( ii )
{
case REFERENCE:
if( CurrentLibEntry )
txtpos = CurrentLibEntry->m_Prefix.m_Pos;
else
txtpos = wxPoint( 0, 0 );
FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl(
PanelField[ii],
PanelText[ii],
CurrentLibEntry ? CurrentLibEntry->
m_Prefix.m_Text : (char*) "U",
CurrentLibEntry ? CurrentLibEntry->
m_Prefix.m_Size : 50,
UnitMetric,
pos,
200,
TRUE );
FieldPosition[ii] = new WinEDA_PositionCtrl( PanelField[ii],
txtpos,
UnitMetric, wxPoint (pos.x + 150,
pos.y + 32) );
break;
case VALUE:
if( CurrentLibEntry )
txtpos = CurrentLibEntry->m_Name.m_Pos;
else
txtpos = wxPoint( 0, 0 );
FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl(
PanelField[ii],
PanelText[ii],
CurrentLibEntry ? CurrentLibEntry->
m_Name.m_Text : NULL,
CurrentLibEntry ? CurrentLibEntry->
m_Name.m_Size : 50,
UnitMetric,
pos,
200,
TRUE );
FieldPosition[ii] = new WinEDA_PositionCtrl( PanelField[ii],
txtpos,
UnitMetric, wxPoint (pos.x + 150,
pos.y + 32) );
break;
default:
int fsize; char* ftext; wxPoint fpos;
fsize = 50; ftext = NULL;
LibDrawField* Field = NULL;
fpos = wxPoint( 0, 0 );
//recherche du Field de FieldId correspondant, s'il existe
if( CurrentLibEntry )
{
Field = CurrentLibEntry->Fields;
while( Field )
{
if( Field->m_FieldId == ii )
{
fsize = Field->m_Size; ftext = Field->m_Text;
fpos = Field->m_Pos;
break;
}
Field = (LibDrawField*) Field->Pnext;
}
}
FieldTextCtrl[ii] = new WinEDA_GraphicTextCtrl( PanelField[ii],
PanelText[ii],
ftext, fsize,
UnitMetric,
pos, 200, TRUE );
FieldPosition[ii] = new WinEDA_PositionCtrl( PanelField[ii],
fpos,
UnitMetric, wxPoint (pos.x + 150,
pos.y + 32) );
break;
}
}
SetModal( TRUE );
}
/***************************************************************************/
/* WinEDA_PartPropertiesFrame::PartPropertiesAccept(wxCommandEvent& event) */
/***************************************************************************/
/* Met a jour les differents parametres pour le composant en cours d'dition
*/
void WinEDA_PartPropertiesFrame::PartPropertiesAccept( wxCommandEvent& event )
{
bool recreateTB = FALSE;
if( CurrentLibEntry == NULL )
{
Close(); return;
}
m_Parent->CurrentScreen->SetModify();
m_Parent->CurrentScreen->SetRefreshReq();
if( ListAlias )
ListAlias->FreeList();
if( AliasListCopy )
ListAlias = AliasListCopy->DupList();
if( CurrentLibEntry->Doc && strcmp( Doc, CurrentLibEntry->Doc ) )
{
free( CurrentLibEntry->Doc ); CurrentLibEntry->Doc = NULL;
}
if( strlen( Doc ) )
CurrentLibEntry->Doc = strdup( Doc );
if( CurrentLibEntry->KeyWord && strcmp( Keywords, CurrentLibEntry->KeyWord ) )
{
free( CurrentLibEntry->KeyWord ); CurrentLibEntry->KeyWord = NULL;
}
if( strlen( Keywords ) )
CurrentLibEntry->KeyWord = strdup( Keywords );
if( CurrentLibEntry->DocFile && strcmp( Docfile, CurrentLibEntry->DocFile ) )
{
free( CurrentLibEntry->DocFile ); CurrentLibEntry->DocFile = NULL;
}
if( strlen( Docfile ) )
CurrentLibEntry->DocFile = strdup( Docfile );
CurrentLibEntry->m_Prefix.SetText( (char*) FieldTextCtrl[REFERENCE]->GetText() );
CurrentLibEntry->m_Name.SetText( (char*) FieldTextCtrl[VALUE]->GetText() );
CurrentLibEntry->m_Prefix.m_Size = FieldTextCtrl[REFERENCE]->GetTextSize();
CurrentLibEntry->m_Name.m_Size = FieldTextCtrl[VALUE]->GetTextSize();
CurrentLibEntry->m_Prefix.m_Pos = FieldPosition[REFERENCE]->GetCoord();
CurrentLibEntry->m_Name.m_Pos = FieldPosition[VALUE]->GetCoord();
CurrentLibEntry->m_Prefix.m_Orient = VorientFieldText[REFERENCE]->GetValue() ? 1 : 0;
CurrentLibEntry->m_Name.m_Orient = VorientFieldText[VALUE]->GetValue() ? 1 : 0;
if( ShowFieldText[REFERENCE]->GetValue() )
CurrentLibEntry->m_Prefix.m_Attributs &= ~TEXT_NO_VISIBLE;
else
CurrentLibEntry->m_Prefix.m_Attributs |= TEXT_NO_VISIBLE;
if( ShowFieldText[VALUE]->GetValue() )
CurrentLibEntry->m_Name.m_Attributs &= ~TEXT_NO_VISIBLE;
else
CurrentLibEntry->m_Name.m_Attributs |= TEXT_NO_VISIBLE;
for( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ )
{
LibDrawField* Field = CurrentLibEntry->Fields;
LibDrawField* NextField, * previousField = NULL;
while( Field )
{
NextField = (LibDrawField*) Field->Pnext;
if( Field->m_FieldId == ii )
{
Field->SetText( (char*) FieldTextCtrl[ii]->GetText() );
Field->m_Size = FieldTextCtrl[ii]->GetTextSize();
if( ShowFieldText[ii]->GetValue() )
Field->m_Attributs &= ~TEXT_NO_VISIBLE;
else
Field->m_Attributs |= TEXT_NO_VISIBLE;
Field->m_Orient = VorientFieldText[ii]->GetValue() ? 1 : 0;
Field->m_Pos = FieldPosition[Field->m_FieldId]->GetCoord();
if( Field->m_Text == NULL )
{
delete Field;
if( previousField )
previousField->Pnext = NextField;
else
CurrentLibEntry->Fields = NextField;
}
break;
}
previousField = Field;
Field = NextField;
}
if( (Field == NULL) && strlen( FieldTextCtrl[ii]->GetText() ) )
{ // N'existe pas: a creer
Field = new LibDrawField( ii );
Field->SetText( (char*) FieldTextCtrl[ii]->GetText() );
Field->m_Size = FieldTextCtrl[ii]->GetTextSize();
Field->Pnext = CurrentLibEntry->Fields;
if( ShowFieldText[Field->m_FieldId]->GetValue() )
Field->m_Attributs &= ~TEXT_NO_VISIBLE;
else
Field->m_Attributs |= TEXT_NO_VISIBLE;
Field->m_Orient = VorientFieldText[Field->m_FieldId]->GetValue() ? 1 : 0;
Field->m_Pos = FieldPosition[Field->m_FieldId]->GetCoord();
CurrentLibEntry->Fields = Field;
}
}
int ii = SelNumberOfUnits->GetValue();
if( ChangeNbUnitsPerPackage( ii ) )
recreateTB = TRUE;
if( AsConvertButt->GetValue() )
{
if( !g_AsDeMorgan )
{
g_AsDeMorgan = 1;
if( SetUnsetConvert() )
recreateTB = TRUE;
}
}
else
{
if( g_AsDeMorgan )
{
g_AsDeMorgan = 0;
if( SetUnsetConvert() )
recreateTB = TRUE;
}
}
CurrentLibEntry->DrawPinNum = ShowPinNumButt->GetValue() ? 1 : 0;
CurrentLibEntry->DrawPinName = ShowPinNameButt->GetValue() ? 1 : 0;
if( PinsNameInsideButt->GetValue() == FALSE )
CurrentLibEntry->TextInside = 0;
else
CurrentLibEntry->TextInside = m_SetSkew->GetValue();
if( recreateTB )
m_Parent->ReCreateHToolbar();
Close();
}
/***************************************************************/
/* void WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart() */
/***************************************************************/
void WinEDA_PartPropertiesFrame::DeleteAllAliasOfPart()
{
if( CurrentLibEntry && AliasListCopy )
{
if( confirmation( _( "Ok to Delete Alias LIST" ) ) == YES )
{
if( AliasListCopy )
AliasListCopy->FreeList();
AliasListCopy = NULL;
PartAliasList->Clear();
}
}
}
/*********************************************************/
/* void WinEDA_PartPropertiesFrame::AddAliasOfPart() */
/*********************************************************/
void WinEDA_PartPropertiesFrame::AddAliasOfPart()
{
char Line[LINE_LEN];
int llen;
ListOfAliasStruct* NewAlias;
if( CurrentLibEntry == NULL )
return;
*Line = 0;
if( Get_Message( _( "Alias:" ), Line, this ) != 0 )
return;
ChangeSpaces( Line, '_' );
llen = strlen( Line ) + 1;
NewAlias = LocateAlias( AliasListCopy, Line );
if( NewAlias )
{
DisplayError( _( "Already in use" ), 10 ); return;
}
NewAlias = new ListOfAliasStruct( Line );
NewAlias->Next = AliasListCopy;
AliasListCopy = NewAlias;
/* affichage des alias */
PartAliasList->Clear();
ListOfAliasStruct* Alias = AliasListCopy;
while( Alias )
{
PartAliasList->Append( Alias->m_Name.m_Text );
Alias = Alias->Next;
}
}
/********************************/
/* void DeleteAliasOfPart() */
/********************************/
void WinEDA_PartPropertiesFrame::DeleteAliasOfPart()
{
ListOfAliasStruct* Alias;
wxString aliasname;
if( CurrentLibEntry == NULL )
return;
if( AliasListCopy == NULL )
return;
aliasname = PartAliasList->GetStringSelection();
if( aliasname == "" )
return;
Alias = AliasListCopy;
ListOfAliasStruct* Previous = NULL;
while( Alias )
{
if( stricmp( aliasname.GetData(), Alias->m_Name.m_Text ) == 0 )
{
if( Previous )
Previous->Next = Alias->Next;
else
AliasListCopy = Alias->Next;
delete Alias;
break;
}
Previous = Alias;
Alias = Alias->Next;
}
/* affichage des alias */
PartAliasList->Clear();
Alias = AliasListCopy;
while( Alias )
{
PartAliasList->Append( Alias->m_Name.m_Text );
Alias = Alias->Next;
}
}
/************************************************************/
static void ExitMoveField( WinEDA_DrawFrame* frame, wxDC* DC )
/************************************************************/
{
frame->CurrentScreen->ManageCurseur = NULL;
frame->CurrentScreen->ForceCloseManageCurseur = NULL;
if( CurrentDrawItem == NULL )
return;
wxPoint curpos;
curpos = frame->CurrentScreen->Curseur;
frame->CurrentScreen->Curseur = StartCursor;
MoveField( DC, 1 );
frame->CurrentScreen->Curseur = curpos;
CurrentDrawItem->m_Flags = 0;
CurrentDrawItem = NULL;
}
/*********************************************/
/* static void StartMoveField(COMMAND * Cmd) */
/*********************************************/
/* Initialise le deplacement d'un champ ( ref ou Name) */
void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LibDrawField* field )
{
if( (CurrentLibEntry == NULL) || ( field == NULL ) )
return;
CurrentDrawItem = field;
CurrentDrawItem->m_Flags |= IS_MOVED;
CurrentScreen->ManageCurseur = MoveField;
CurrentScreen->ForceCloseManageCurseur = ExitMoveField;
CurrentScreen->ManageCurseur( DC, 1 );
StartCursor = CurrentScreen->Curseur;
}
/*****************************************************************/
/* Routine d'affichage du texte 'Field' en cours de deplacement. */
/* Routine normalement attachee au curseur */
/*****************************************************************/
static void MoveField( wxDC* DC, int flag )
{
int color;
LibDrawField* Field = (LibDrawField*) CurrentDrawItem;
if( (CurrentLibEntry == NULL) || (Field == NULL) )
return;
GRSetDrawMode( DC, XOR_MODE );
switch( Field->m_FieldId )
{
case VALUE:
color = ReturnLayerColor( LAYER_VALUEPART );
break;
case REFERENCE:
color = ReturnLayerColor( LAYER_REFERENCEPART );
break;
default:
color = ReturnLayerColor( LAYER_FIELDS );
break;
}
if( Field->m_Attributs & TEXT_NO_VISIBLE )
color = DARKGRAY;
if( flag >= 0 )
Gr_E_texte( DC, Field->m_Pos.x, -Field->m_Pos.y,
color, Field->m_Text,
Field->m_Orient, Field->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER );
Field->m_Pos.x = ActiveScreen->Curseur.x;
Field->m_Pos.y = -ActiveScreen->Curseur.y;
Gr_E_texte( DC, Field->m_Pos.x, -Field->m_Pos.y,
color, Field->m_Text,
Field->m_Orient, Field->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER );
}
/********************************/
/* static void PlaceField() */
/********************************/
void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LibDrawField* Field )
{
int color;
if( Field == NULL )
return;
GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE );
switch( Field->m_FieldId )
{
case REFERENCE:
color = ReturnLayerColor( LAYER_REFERENCEPART );
break;
case VALUE:
color = ReturnLayerColor( LAYER_VALUEPART );
break;
default:
color = ReturnLayerColor( LAYER_FIELDS );
break;
}
if( Field->m_Attributs & TEXT_NO_VISIBLE )
color = DARKGRAY;
Gr_E_texte( DC, Field->m_Pos.x, -Field->m_Pos.y,
color, Field->m_Text,
Field->m_Orient, Field->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER );
Field->m_Flags = 0;
CurrentScreen->SetModify();
CurrentScreen->ManageCurseur = NULL;
CurrentScreen->ForceCloseManageCurseur = NULL;
CurrentDrawItem = NULL;
}
/****************************************/
/* static void EditField(COMMAND * Cmd) */
/****************************************/
void WinEDA_LibeditFrame::EditField( wxDC* DC, LibDrawField* Field )
{
char Text[LINE_LEN];
int color;
wxClientDC dc( DrawPanel );
if( Field== NULL )
return;
switch( Field->m_FieldId )
{
case REFERENCE:
color = ReturnLayerColor( LAYER_REFERENCEPART );
break;
case VALUE:
color = ReturnLayerColor( LAYER_VALUEPART );
break;
default:
color = ReturnLayerColor( LAYER_FIELDS );
break;
}
*Text = 0;
if( Field->m_Attributs & TEXT_NO_VISIBLE )
color = DARKGRAY;
if( Field->m_Text )
strcpy( Text, Field->m_Text );
Get_Message( _( "Text: " ), Text, this );
ChangeSpaces( Text, '_' );
GRSetDrawMode( &dc, XOR_MODE );
Gr_E_texte( DC, Field->m_Pos.x, -Field->m_Pos.y,
color, Field->m_Text,
Field->m_Orient, Field->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER );
Field->SetText( Text );
if( Field->m_Flags == 0 )
GRSetDrawMode( &dc, GR_DEFAULT_DRAWMODE );
Gr_E_texte( DC, Field->m_Pos.x, -Field->m_Pos.y,
color, Field->m_Text,
Field->m_Orient, Field->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER );
CurrentScreen->SetModify();
}
/*******************************************************************/
void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field )
/*******************************************************************/
/*
* Routine de modification de l'orientation ( Horiz ou Vert. ) du champ.
* si un champ est en cours d'edition, modif de celui ci.
* sinon Modif du champ pointe par la souris
*/
{
int color;
if( Field == NULL )
return;
CurrentScreen->SetModify();
switch( Field->m_FieldId )
{
case REFERENCE:
color = ReturnLayerColor( LAYER_REFERENCEPART );
break;
case VALUE:
color = ReturnLayerColor( LAYER_VALUEPART );
break;
default:
color = ReturnLayerColor( LAYER_FIELDS );
break;
}
if( Field->m_Attributs & TEXT_NO_VISIBLE )
color = DARKGRAY;
GRSetDrawMode( DC, XOR_MODE );
Gr_E_texte( DC, Field->m_Pos.x, -Field->m_Pos.y,
color, Field->m_Text,
Field->m_Orient, Field->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER );
if( Field->m_Orient )
Field->m_Orient = 0;
else
Field->m_Orient = 1;
if( Field->m_Flags == 0 )
GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE );
Gr_E_texte( DC, Field->m_Pos.x, -Field->m_Pos.y,
color, Field->m_Text,
Field->m_Orient, Field->m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER );
}
/********************************************************/
/* static int LocateField(LibraryEntryStruct *LibEntry) */
/********************************************************/
/* Localise le champ (ref ou name) pointe par la souris
* retourne:
* < 0: Pas de champ
* 0: Ref
* 1: Name(s)
* > 2 = Num Field
*/
LibDrawField* WinEDA_LibeditFrame::LocateField( LibraryEntryStruct* LibEntry )
{
int x0, y0, x1, y1; /* Rectangle d'encadrement des textes a localiser */
int dx, dy; /* Dimensions du texte */
LibDrawField* Field;
/* Localisation du Nom */
x0 = LibEntry->m_Name.m_Pos.x;
y0 = -LibEntry->m_Name.m_Pos.y;
dx = LibEntry->m_Name.m_Size * strlen( LibEntry->m_Name.m_Text ),
dy = LibEntry->m_Name.m_Size;
if( LibEntry->m_Name.m_Orient )
EXCHG( dx, dy );
x0 -= dx / 2; y0 -= dy / 2;
x1 = x0 + dx; y1 = y0 + dy;
if( (CurrentScreen->Curseur.x >= x0) && ( CurrentScreen->Curseur.x <= x1)
&& (CurrentScreen->Curseur.y >= y0) && ( CurrentScreen->Curseur.y <= y1) )
return &LibEntry->m_Name;
/* Localisation du Prefix */
x0 = LibEntry->m_Prefix.m_Pos.x;
y0 = -LibEntry->m_Prefix.m_Pos.y;
dx = LibEntry->m_Prefix.m_Size * strlen( LibEntry->m_Prefix.m_Text ),
dy = LibEntry->m_Prefix.m_Size;
if( LibEntry->m_Prefix.m_Orient )
EXCHG( dx, dy );
x0 -= dx / 2; y0 -= dy / 2;
x1 = x0 + dx; y1 = y0 + dy;
if( (CurrentScreen->Curseur.x >= x0) && ( CurrentScreen->Curseur.x <= x1)
&& (CurrentScreen->Curseur.y >= y0) && ( CurrentScreen->Curseur.y <= y1) )
return &LibEntry->m_Prefix;
/* Localisation des autres fields */
for( Field = LibEntry->Fields; Field != NULL;
Field = (LibDrawField*) Field->Pnext )
{
if( Field->m_Text == NULL )
continue;
x0 = Field->m_Pos.x; y0 = -Field->m_Pos.y;
dx = Field->m_Size * strlen( Field->m_Text ),
dy = Field->m_Size;
if( Field->m_Orient )
EXCHG( dx, dy );
x0 -= dx / 2; y0 -= dy / 2;
x1 = x0 + dx; y1 = y0 + dy;
if( (CurrentScreen->Curseur.x >= x0) && ( CurrentScreen->Curseur.x <= x1)
&& (CurrentScreen->Curseur.y >= y0) && ( CurrentScreen->Curseur.y <= y1) )
return Field;
}
return NULL;
}
/*********************************************************************/
/* static char * PrefixText(LibraryEntryStruct * LibEntry, int Unit) */
/*********************************************************************/
/* Calcule l'affichage complet du prefixe ( texte + '?' + ident unit )
* Retourne un pointeur sur le nouveau texte (allocation statique)
*/
static char* PrefixText( LibraryEntryStruct* LibEntry, int Unit )
{
static char Text[LINE_LEN];
if( LibEntry->NumOfUnits > 1 )
sprintf( Text, "%s?%c", LibEntry->m_Prefix.m_Text, Unit + 'A' - 1 );
else
sprintf( Text, "%s?", LibEntry->m_Prefix.m_Text );
return Text;
}
/*****************************************************************/
/* void WinEDA_PartPropertiesFrame::ChangeNbUnitsPerPackagevoid) */
/*****************************************************************/
/* Routine de modification du nombre d'unites par package pour le
* composant courant;
*/
bool WinEDA_PartPropertiesFrame::ChangeNbUnitsPerPackage( int MaxUnit )
{
int OldNumUnits, ii, FlagDel = -1;
LibEDA_BaseStruct* DrawItem, * NextDrawItem;
if( CurrentLibEntry == NULL )
return FALSE;
/* Si pas de changement: termine */
if( CurrentLibEntry->NumOfUnits == MaxUnit )
return FALSE;
OldNumUnits = CurrentLibEntry->NumOfUnits;
if( OldNumUnits < 1 )
OldNumUnits = 1;
CurrentLibEntry->NumOfUnits = MaxUnit;
/* Traitement des unites enlevees ou rajoutees */
if( OldNumUnits > CurrentLibEntry->NumOfUnits )
{
DrawItem = CurrentLibEntry->Drawings;
for( ; DrawItem != NULL; DrawItem = NextDrawItem )
{
NextDrawItem = DrawItem->Pnext;
if( DrawItem->m_Unit > MaxUnit ) /* Item a effacer */
{
if( FlagDel < 0 )
{
if( confirmation( _( "Delete units" ) ) == YES )
{
/* Si part selectee n'existe plus: selection 1ere unit */
if( CurrentUnit > MaxUnit )
CurrentUnit = 1;
FlagDel = 1;
}
else
{
FlagDel = 0;
MaxUnit = OldNumUnits;
CurrentLibEntry->NumOfUnits = MaxUnit;
return FALSE;
}
}
DeleteOneLibraryDrawStruct( NULL, CurrentLibEntry,
DrawItem, 0 );
}
}
return TRUE;
}
if( OldNumUnits < CurrentLibEntry->NumOfUnits )
{
DrawItem = CurrentLibEntry->Drawings;
for( ; DrawItem != NULL; DrawItem = DrawItem->Pnext )
{
/* Duplication des items pour autres elements */
if( DrawItem->m_Unit == 1 )
{
for( ii = OldNumUnits + 1; ii <= MaxUnit; ii++ )
{
NextDrawItem = CopyDrawEntryStruct( DrawItem );
NextDrawItem->Pnext = CurrentLibEntry->Drawings;
CurrentLibEntry->Drawings = NextDrawItem;
NextDrawItem->m_Unit = ii;
}
}
}
}
return TRUE;
}
/**********************************************************/
/* void WinEDA_PartPropertiesFrame::SetUnsetConvert() */
/**********************************************************/
/* cre ou efface (selon option AsConvert) les lments
* de la reprsentation convertie d'un composant
*/
bool WinEDA_PartPropertiesFrame::SetUnsetConvert()
{
int FlagDel = 0;
LibEDA_BaseStruct* DrawItem = NULL, * NextDrawItem;
if( g_AsDeMorgan ) /* Representation convertie a creer */
{
/* Traitement des elements a ajouter ( pins seulement ) */
if( CurrentLibEntry )
DrawItem = CurrentLibEntry->Drawings;
for( ; DrawItem != NULL; DrawItem = DrawItem->Pnext )
{
/* Duplication des items pour autres elements */
if( DrawItem->Type() != PIN_DRAW_TYPE )
continue;
if( DrawItem->m_Convert == 1 )
{
if( FlagDel == 0 )
{
if( confirmation( _( "Create pins for Convert items" ) ) == YES )
FlagDel = 1;
else
{
if( confirmation( _( "Part as \"De Morgan\" anymore" ) ) == YES )
return TRUE;
g_AsDeMorgan = 0; return FALSE;
}
}
NextDrawItem = CopyDrawEntryStruct( DrawItem );
NextDrawItem->Pnext = CurrentLibEntry->Drawings;
CurrentLibEntry->Drawings = NextDrawItem;
NextDrawItem->m_Convert = 2;
}
}
}
else /* Representation convertie a supprimer */
{
/* Traitement des elements supprimer */
if( CurrentLibEntry )
DrawItem = CurrentLibEntry->Drawings;
for( ; DrawItem != NULL; DrawItem = NextDrawItem )
{
NextDrawItem = DrawItem->Pnext;
if( DrawItem->m_Convert > 1 ) /* Item a effacer */
{
if( FlagDel == 0 )
{
if( confirmation( _( "Delete Convert items" ) ) == YES )
{
CurrentConvert = 1;
FlagDel = 1;
}
else
{
g_AsDeMorgan = 1;
return FALSE;
}
}
ActiveScreen->SetModify();
DeleteOneLibraryDrawStruct( NULL, CurrentLibEntry, DrawItem, 0 );
}
}
}
return TRUE;
}
This diff is collapsed.
Click to expand it.
eeschema/netlist.cpp
View file @
0a2ed094
...
...
@@ -36,6 +36,61 @@ static int LastNetCode, LastBusNetCode;
static
int
s_PassNumber
;
#if defined(DEBUG)
const
char
*
ShowType
(
NetObjetType
aType
)
{
const
char
*
ret
;
switch
(
aType
)
{
case
NET_SEGMENT
:
ret
=
"segment"
;
break
;
case
NET_BUS
:
ret
=
"bus"
;
break
;
case
NET_JONCTION
:
ret
=
"junction"
;
break
;
case
NET_LABEL
:
ret
=
"label"
;
break
;
case
NET_GLOBLABEL
:
ret
=
"glabel"
;
break
;
case
NET_BUSLABELMEMBER
:
ret
=
"buslblmember"
;
break
;
case
NET_GLOBBUSLABELMEMBER
:
ret
=
"gbuslblmember"
;
break
;
case
NET_SHEETBUSLABELMEMBER
:
ret
=
"sbuslblmember"
;
break
;
case
NET_SHEETLABEL
:
ret
=
"sheetlabel"
;
break
;
case
NET_PINLABEL
:
ret
=
"pinlabel"
;
break
;
case
NET_PIN
:
ret
=
"pin"
;
break
;
case
NET_NOCONNECT
:
ret
=
"noconnect"
;
break
;
default:
ret
=
"??"
;
break
;
}
return
ret
;
}
void
ObjetNetListStruct
::
Show
(
std
::
ostream
&
out
,
int
ndx
)
{
out
<<
"<netItem ndx=
\"
"
<<
ndx
<<
'"'
<<
" type=
\"
"
<<
ShowType
(
m_Type
)
<<
'"'
<<
" netCode=
\"
"
<<
m_NetCode
<<
'"'
<<
" sheet=
\"
"
<<
m_SheetNumber
<<
'"'
<<
">
\n
"
;
out
<<
" <start "
<<
m_Start
<<
"/> <end "
<<
m_End
<<
"/>
\n
"
;
if
(
m_Label
)
out
<<
" <label>"
<<
m_Label
->
mb_str
()
<<
"</label>
\n
"
;
if
(
m_Comp
)
m_Comp
->
Show
(
1
,
out
);
out
<<
"</netItem>
\n
"
;
}
void
dumpNetTable
()
{
for
(
int
i
=
0
;
i
<
g_NbrObjNet
;
++
i
)
{
g_TabObjNet
[
i
].
Show
(
std
::
cout
,
i
);
}
}
#endif
/***********************************************************************/
void
FreeTabNetList
(
ObjetNetListStruct
*
TabNetItems
,
int
NbrNetItems
)
/***********************************************************************/
...
...
@@ -134,10 +189,10 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
Affiche_1_Parametre
(
this
,
1
,
_
(
"List"
),
wxEmptyString
,
RED
);
screen
=
ScreenList
.
GetFirst
();
for
(
ObjetNetListStruct
*
baseT
abObjNet
=
g_TabObjNet
;
for
(
ObjetNetListStruct
*
t
abObjNet
=
g_TabObjNet
;
screen
!=
NULL
;
screen
=
ScreenList
.
GetNext
()
)
{
baseTabObjNet
+=
ListeObjetConnection
(
this
,
screen
,
baseT
abObjNet
);
tabObjNet
+=
ListeObjetConnection
(
this
,
screen
,
t
abObjNet
);
}
Affiche_1_Parametre
(
this
,
-
1
,
wxEmptyString
,
_
(
"Done"
),
RED
);
...
...
@@ -155,11 +210,12 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
SheetNumber
=
g_TabObjNet
[
0
].
m_SheetNumber
;
LastNetCode
=
LastBusNetCode
=
1
;
for
(
i
=
istart
=
0
;
i
<
g_NbrObjNet
;
i
++
)
for
(
i
=
istart
=
0
;
i
<
g_NbrObjNet
;
i
++
)
{
if
(
g_TabObjNet
[
i
].
m_SheetNumber
!=
SheetNumber
)
{
SheetNumber
=
g_TabObjNet
[
i
].
m_SheetNumber
;
istart
=
i
;
SheetNumber
=
g_TabObjNet
[
i
].
m_SheetNumber
;
istart
=
i
;
}
switch
(
g_TabObjNet
[
i
].
m_Type
)
...
...
@@ -237,6 +293,13 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
}
}
#if defined(DEBUG)
std
::
cout
<<
"after sheet local
\n
"
;
dumpNetTable
();
#endif
Affiche_1_Parametre
(
this
,
-
1
,
wxEmptyString
,
_
(
"Done"
),
CYAN
);
/* Mise a jour des NetCodes des Bus Labels connectes par les Bus */
...
...
@@ -245,7 +308,7 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
Affiche_1_Parametre
(
this
,
26
,
_
(
"Labels"
),
wxEmptyString
,
CYAN
);
/* Connections des groupes d'objets par labels identiques */
for
(
i
=
0
;
i
<
g_NbrObjNet
;
i
++
)
for
(
i
=
0
;
i
<
g_NbrObjNet
;
i
++
)
{
switch
(
g_TabObjNet
[
i
].
m_Type
)
{
...
...
@@ -270,22 +333,32 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
}
}
#if defined(DEBUG)
std
::
cout
<<
"after sheet global
\n
"
;
dumpNetTable
();
#endif
Affiche_1_Parametre
(
this
,
-
1
,
wxEmptyString
,
_
(
"Done"
),
CYAN
);
/* Connexion des hierarchies */
Affiche_1_Parametre
(
this
,
36
,
_
(
"Hierar."
),
wxEmptyString
,
LIGHTRED
);
for
(
i
=
0
;
i
<
g_NbrObjNet
;
i
++
)
for
(
i
=
0
;
i
<
g_NbrObjNet
;
i
++
)
{
if
(
(
g_TabObjNet
[
i
].
m_Type
==
NET_SHEETLABEL
)
||
(
g_TabObjNet
[
i
].
m_Type
==
NET_SHEETBUSLABELMEMBER
)
)
if
(
g_TabObjNet
[
i
].
m_Type
==
NET_SHEETLABEL
||
g_TabObjNet
[
i
].
m_Type
==
NET_SHEETBUSLABELMEMBER
)
SheetLabelConnection
(
g_TabObjNet
+
i
);
}
/* Tri du Tableau des objets de Net par NetCode */
qsort
(
g_TabObjNet
,
g_NbrObjNet
,
sizeof
(
ObjetNetListStruct
),
TriNetCode
);
#if defined(DEBUG)
std
::
cout
<<
"after qsort()
\n
"
;
dumpNetTable
();
#endif
Affiche_1_Parametre
(
this
,
-
1
,
wxEmptyString
,
_
(
"Done"
),
RED
);
/* Compression des numeros de NetCode a des valeurs consecutives */
...
...
@@ -295,7 +368,8 @@ void* WinEDA_SchematicFrame::BuildNetListBase()
{
if
(
g_TabObjNet
[
i
].
m_NetCode
!=
LastNetCode
)
{
NetCode
++
;
LastNetCode
=
g_TabObjNet
[
i
].
m_NetCode
;
NetCode
++
;
LastNetCode
=
g_TabObjNet
[
i
].
m_NetCode
;
}
g_TabObjNet
[
i
].
m_NetCode
=
NetCode
;
}
...
...
@@ -502,7 +576,7 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree
DEntry
=
Entry
->
m_Drawings
;
for
(
;
DEntry
!=
NULL
;
DEntry
=
DEntry
->
Next
()
)
for
(
;
DEntry
;
DEntry
=
DEntry
->
Next
()
)
{
LibDrawPin
*
Pin
=
(
LibDrawPin
*
)
DEntry
;
if
(
DEntry
->
Type
()
!=
COMPONENT_PIN_DRAW_TYPE
)
...
...
@@ -534,7 +608,7 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree
ObjNet
[
NbrItem
].
m_SheetNumber
=
NumSheet
;
ObjNet
[
NbrItem
].
m_Start
.
x
=
x2
;
ObjNet
[
NbrItem
].
m_Start
.
y
=
y2
;
ObjNet
[
NbrItem
].
m_End
=
ObjNet
[
NbrItem
].
m_Start
;
ObjNet
[
NbrItem
].
m_End
=
ObjNet
[
NbrItem
].
m_Start
;
}
NbrItem
++
;
...
...
@@ -551,7 +625,7 @@ static int ListeObjetConnection( WinEDA_SchematicFrame* frame, SCH_SCREEN* scree
ObjNet
[
NbrItem
].
m_Label
=
&
Pin
->
m_PinName
;
ObjNet
[
NbrItem
].
m_Start
.
x
=
x2
;
ObjNet
[
NbrItem
].
m_Start
.
y
=
y2
;
ObjNet
[
NbrItem
].
m_End
=
ObjNet
[
NbrItem
].
m_Start
;
ObjNet
[
NbrItem
].
m_End
=
ObjNet
[
NbrItem
].
m_Start
;
}
NbrItem
++
;
}
...
...
@@ -763,6 +837,7 @@ static int ConvertBusToMembers( ObjetNetListStruct* BusLabel )
/* Convertion du BusLabel en la racine du Label + le numero du fil */
BufLine
=
BusLabel
->
m_Label
->
Left
(
RootBusNameLength
);
BusMember
=
FirstNumWireBus
;
BufLine
<<
BusMember
;
BusLabel
->
m_Label
=
new
wxString
(
BufLine
);
...
...
@@ -772,7 +847,9 @@ static int ConvertBusToMembers( ObjetNetListStruct* BusLabel )
for
(
BusMember
++
;
BusMember
<=
LastNumWireBus
;
BusMember
++
)
{
*
(
BusLabel
+
1
)
=
*
BusLabel
;
BusLabel
++
;
NumItem
++
;
*
(
BusLabel
+
1
)
=
*
BusLabel
;
BusLabel
++
;
NumItem
++
;
/* Convertion du BusLabel en la racine du Label + le numero du fil */
BufLine
=
BusLabel
->
m_Label
->
Left
(
RootBusNameLength
);
...
...
@@ -849,18 +926,18 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start )
* ( il ne peut y avoir connexion physique entre elements de differentes sheets)
*/
{
int
i
,
N
etCode
;
ObjetNetListStruct
*
Point
=
g_TabObjNet
;
int
i
,
n
etCode
;
ObjetNetListStruct
*
netTable
=
g_TabObjNet
;
if
(
IsBus
==
0
)
/* Objets autres que BUS et BUSLABELS */
{
N
etCode
=
Ref
->
m_NetCode
;
n
etCode
=
Ref
->
m_NetCode
;
for
(
i
=
start
;
i
<
g_NbrObjNet
;
i
++
)
{
if
(
Point
[
i
].
m_SheetNumber
>
Ref
->
m_SheetNumber
)
if
(
netTable
[
i
].
m_SheetNumber
>
Ref
->
m_SheetNumber
)
break
;
switch
(
Point
[
i
].
m_Type
)
switch
(
netTable
[
i
].
m_Type
)
{
case
NET_SEGMENT
:
case
NET_PIN
:
...
...
@@ -870,18 +947,15 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start )
case
NET_PINLABEL
:
case
NET_JONCTION
:
case
NET_NOCONNECT
:
if
(
(
(
(
Ref
->
m_Start
.
x
==
Point
[
i
].
m_Start
.
x
)
&&
(
Ref
->
m_Start
.
y
==
Point
[
i
].
m_Start
.
y
)
)
)
||
(
(
(
Ref
->
m_Start
.
x
==
Point
[
i
].
m_End
.
x
)
&&
(
Ref
->
m_Start
.
y
==
Point
[
i
].
m_End
.
y
)
)
)
||
(
(
(
Ref
->
m_End
.
x
==
Point
[
i
].
m_Start
.
x
)
&&
(
Ref
->
m_End
.
y
==
Point
[
i
].
m_Start
.
y
)
)
)
||
(
(
(
Ref
->
m_End
.
x
==
Point
[
i
].
m_End
.
x
)
&&
(
Ref
->
m_End
.
y
==
Point
[
i
].
m_End
.
y
)
)
)
)
if
(
Ref
->
m_Start
==
netTable
[
i
].
m_Start
||
Ref
->
m_Start
==
netTable
[
i
].
m_End
||
Ref
->
m_End
==
netTable
[
i
].
m_Start
||
Ref
->
m_End
==
netTable
[
i
].
m_End
)
{
if
(
Point
[
i
].
m_NetCode
==
0
)
Point
[
i
].
m_NetCode
=
N
etCode
;
if
(
netTable
[
i
].
m_NetCode
==
0
)
netTable
[
i
].
m_NetCode
=
n
etCode
;
else
PropageNetCode
(
Point
[
i
].
m_NetCode
,
N
etCode
,
0
);
PropageNetCode
(
netTable
[
i
].
m_NetCode
,
n
etCode
,
0
);
}
break
;
...
...
@@ -893,15 +967,16 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start )
}
}
}
else
/* Objets type BUS et BUSLABELS ( et JONCTIONS )*/
{
N
etCode
=
Ref
->
m_BusNetCode
;
for
(
i
=
start
;
i
<
g_NbrObjNet
;
i
++
)
n
etCode
=
Ref
->
m_BusNetCode
;
for
(
i
=
start
;
i
<
g_NbrObjNet
;
i
++
)
{
if
(
Point
[
i
].
m_SheetNumber
>
Ref
->
m_SheetNumber
)
if
(
netTable
[
i
].
m_SheetNumber
>
Ref
->
m_SheetNumber
)
break
;
switch
(
Point
[
i
].
m_Type
)
switch
(
netTable
[
i
].
m_Type
)
{
case
NET_SEGMENT
:
case
NET_PIN
:
...
...
@@ -917,18 +992,15 @@ static void PointToPointConnect( ObjetNetListStruct* Ref, int IsBus, int start )
case
NET_SHEETBUSLABELMEMBER
:
case
NET_GLOBBUSLABELMEMBER
:
case
NET_JONCTION
:
if
(
(
(
(
Ref
->
m_Start
.
x
==
Point
[
i
].
m_Start
.
x
)
&&
(
Ref
->
m_Start
.
y
==
Point
[
i
].
m_Start
.
y
)
)
)
||
(
(
(
Ref
->
m_Start
.
x
==
Point
[
i
].
m_End
.
x
)
&&
(
Ref
->
m_Start
.
y
==
Point
[
i
].
m_End
.
y
)
)
)
||
(
(
(
Ref
->
m_End
.
x
==
Point
[
i
].
m_Start
.
x
)
&&
(
Ref
->
m_End
.
y
==
Point
[
i
].
m_Start
.
y
)
)
)
||
(
(
(
Ref
->
m_End
.
x
==
Point
[
i
].
m_End
.
x
)
&&
(
Ref
->
m_End
.
y
==
Point
[
i
].
m_End
.
y
)
)
)
)
if
(
Ref
->
m_Start
==
netTable
[
i
].
m_Start
||
Ref
->
m_Start
==
netTable
[
i
].
m_End
||
Ref
->
m_End
==
netTable
[
i
].
m_Start
||
Ref
->
m_End
==
netTable
[
i
].
m_End
)
{
if
(
Point
[
i
].
m_BusNetCode
==
0
)
Point
[
i
].
m_BusNetCode
=
N
etCode
;
if
(
netTable
[
i
].
m_BusNetCode
==
0
)
netTable
[
i
].
m_BusNetCode
=
n
etCode
;
else
PropageNetCode
(
Point
[
i
].
m_BusNetCode
,
N
etCode
,
1
);
PropageNetCode
(
netTable
[
i
].
m_BusNetCode
,
n
etCode
,
1
);
}
break
;
}
...
...
@@ -998,46 +1070,42 @@ static void SegmentToPointConnect( ObjetNetListStruct* Jonction,
/*****************************************************************
*
Routine qui connecte les groupes d'objets si labels identiques *
*
Function which connects the groups of object which have the same label
*******************************************************************/
static
void
LabelConnection
(
ObjetNetListStruct
*
LabelRef
)
{
int
i
,
NetCode
;
ObjetNetListStruct
*
ObjetNet
;
if
(
LabelRef
->
m_NetCode
==
0
)
return
;
ObjetNet
=
g_TabObjNet
;
ObjetNet
ListStruct
*
netTable
=
g_TabObjNet
;
for
(
i
=
0
;
i
<
g_NbrObjNet
;
i
++
)
for
(
i
nt
i
=
0
;
i
<
g_NbrObjNet
;
i
++
)
{
NetCode
=
ObjetNet
[
i
].
m_NetCode
;
if
(
NetCode
==
LabelRef
->
m_NetCode
)
if
(
netTable
[
i
].
m_NetCode
==
LabelRef
->
m_NetCode
)
continue
;
if
(
ObjetNet
[
i
].
m_SheetNumber
!=
LabelRef
->
m_SheetNumber
)
if
(
netTable
[
i
].
m_SheetNumber
!=
LabelRef
->
m_SheetNumber
)
{
if
(
ObjetNet
[
i
].
m_Type
!=
NET_PINLABEL
)
if
(
netTable
[
i
].
m_Type
!=
NET_PINLABEL
)
continue
;
}
if
(
(
ObjetNet
[
i
].
m_Type
==
NET_LABEL
)
||
(
ObjetNet
[
i
].
m_Type
==
NET_GLOBLABEL
)
||
(
ObjetNet
[
i
].
m_Type
==
NET_BUSLABELMEMBER
)
||
(
ObjetNet
[
i
].
m_Type
==
NET_GLOBBUSLABELMEMBER
)
||
(
ObjetNet
[
i
].
m_Type
==
NET_PINLABEL
)
)
if
(
netTable
[
i
].
m_Type
==
NET_LABEL
||
netTable
[
i
].
m_Type
==
NET_GLOBLABEL
||
netTable
[
i
].
m_Type
==
NET_BUSLABELMEMBER
||
netTable
[
i
].
m_Type
==
NET_GLOBBUSLABELMEMBER
||
netTable
[
i
].
m_Type
==
NET_PINLABEL
)
{
if
(
ObjetNet
[
i
].
m_Label
->
CmpNoCase
(
*
LabelRef
->
m_Label
)
!=
0
)
if
(
netTable
[
i
].
m_Label
->
CmpNoCase
(
*
LabelRef
->
m_Label
)
!=
0
)
continue
;
/* Ici 2 labels identiques */
/* Propagation du Netcode a tous les Objets de meme NetCode */
if
(
ObjetNet
[
i
].
m_NetCode
)
PropageNetCode
(
ObjetNet
[
i
].
m_NetCode
,
LabelRef
->
m_NetCode
,
0
);
if
(
netTable
[
i
].
m_NetCode
)
PropageNetCode
(
netTable
[
i
].
m_NetCode
,
LabelRef
->
m_NetCode
,
0
);
else
ObjetNet
[
i
].
m_NetCode
=
LabelRef
->
m_NetCode
;
netTable
[
i
].
m_NetCode
=
LabelRef
->
m_NetCode
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
eeschema/netlist.h
View file @
0a2ed094
...
...
@@ -36,7 +36,7 @@ typedef enum {
/* Max pin number per component and footprint */
#define MAXPIN 5000
typedef
enum
{
/* Type des objets de Net */
enum
NetObjetType
{
/* Type des objets de Net */
NET_SEGMENT
,
NET_BUS
,
NET_JONCTION
,
...
...
@@ -49,20 +49,21 @@ typedef enum { /* Type des objets de Net */
NET_PINLABEL
,
NET_PIN
,
NET_NOCONNECT
}
NetObjetType
;
};
typedef
enum
{
/* Valeur du Flag de connection */
enum
IsConnectType
{
/* Valeur du Flag de connection */
UNCONNECT
,
/* Pin ou Label non connecte */
NOCONNECT
,
/* Pin volontairement non connectee (Symb. NoConnect utilise) */
CONNECT
/* connexion normale */
}
IsConnectType
;
};
/* Structure decrivant 1 element de connexion (pour netlist ) */
class
ObjetNetListStruct
{
public
:
void
*
m_Comp
;
/* Pointeur sur la definition de l'objet */
EDA_BaseStruct
*
m_Comp
;
/* Pointeur sur la definition de l'objet */
void
*
m_Link
;
/* Pour SheetLabelStruct: Pointeur sur la feuille de hierarchie
* Pour les Pins: pointeur sur le composant */
int
m_Flag
;
/* flag pour calculs internes */
...
...
@@ -79,6 +80,11 @@ public:
long
m_PinNum
;
/* numero de pin( 4 octets -> 4 codes ascii) */
const
wxString
*
m_Label
;
/* Tous types Labels:pointeur sur la wxString definissant le label */
wxPoint
m_Start
,
m_End
;
#if defined(DEBUG)
void
Show
(
std
::
ostream
&
out
,
int
ndx
);
#endif
};
...
...
This diff is collapsed.
Click to expand it.
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