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
16131a50
Commit
16131a50
authored
Dec 07, 2011
by
Wayne Stambaugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Encapsulate SCH_FIELD class.
parent
bcbde5d8
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
76 deletions
+86
-76
dialog_edit_component_in_schematic.cpp
eeschema/dialogs/dialog_edit_component_in_schematic.cpp
+13
-13
edit_component_in_schematic.cpp
eeschema/edit_component_in_schematic.cpp
+3
-3
netform.cpp
eeschema/netform.cpp
+2
-2
sch_component.cpp
eeschema/sch_component.cpp
+27
-7
sch_field.cpp
eeschema/sch_field.cpp
+25
-32
sch_field.h
eeschema/sch_field.h
+16
-19
No files found.
eeschema/dialogs/dialog_edit_component_in_schematic.cpp
View file @
16131a50
...
@@ -236,14 +236,14 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
...
@@ -236,14 +236,14 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
// Delete any fields with no name before we copy all of m_FieldsBuf back into the component.
// Delete any fields with no name before we copy all of m_FieldsBuf back into the component.
for
(
unsigned
i
=
MANDATORY_FIELDS
;
i
<
m_FieldsBuf
.
size
();
)
for
(
unsigned
i
=
MANDATORY_FIELDS
;
i
<
m_FieldsBuf
.
size
();
)
{
{
if
(
m_FieldsBuf
[
i
].
m_Name
.
IsEmpty
()
||
m_FieldsBuf
[
i
].
m_Text
.
IsEmpty
()
)
if
(
m_FieldsBuf
[
i
].
GetName
(
false
).
IsEmpty
()
||
m_FieldsBuf
[
i
].
GetText
()
.
IsEmpty
()
)
{
{
// If a field has no value and is not it the field template list, warn the user
// If a field has no value and is not it the field template list, warn the user
// that it will be remove from the component. This gives the user a chance to
// that it will be remove from the component. This gives the user a chance to
// correct the problem before removing the undefined fields. It should also
// correct the problem before removing the undefined fields. It should also
// resolve most of the bug reports and questions regarding missing fields.
// resolve most of the bug reports and questions regarding missing fields.
if
(
!
m_FieldsBuf
[
i
].
m_Name
.
IsEmpty
()
&&
m_FieldsBuf
[
i
].
m_Text
.
IsEmpty
()
if
(
!
m_FieldsBuf
[
i
].
GetName
(
false
).
IsEmpty
()
&&
m_FieldsBuf
[
i
].
GetText
()
.
IsEmpty
()
&&
!
m_Parent
->
GetTemplates
().
HasFieldName
(
m_FieldsBuf
[
i
].
m_Name
)
&&
!
m_Parent
->
GetTemplates
().
HasFieldName
(
m_FieldsBuf
[
i
].
GetName
(
false
)
)
&&
!
removeRemainingFields
)
&&
!
removeRemainingFields
)
{
{
wxString
msg
;
wxString
msg
;
...
@@ -251,7 +251,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
...
@@ -251,7 +251,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
msg
.
Printf
(
_
(
"The field name <%s> does not have a value and is not defined in \
msg
.
Printf
(
_
(
"The field name <%s> does not have a value and is not defined in \
the field template list. Empty field values are invalid an will be removed from the component. \
the field template list. Empty field values are invalid an will be removed from the component. \
Do you wish to remove this and all remaining undefined fields?"
),
Do you wish to remove this and all remaining undefined fields?"
),
GetChars
(
m_FieldsBuf
[
i
].
m_Name
)
);
GetChars
(
m_FieldsBuf
[
i
].
GetName
(
false
)
)
);
wxMessageDialog
dlg
(
this
,
msg
,
_
(
"Remove Fields"
),
wxYES_NO
|
wxNO_DEFAULT
);
wxMessageDialog
dlg
(
this
,
msg
,
_
(
"Remove Fields"
),
wxYES_NO
|
wxNO_DEFAULT
);
...
@@ -303,7 +303,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent&
...
@@ -303,7 +303,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent&
blank
.
m_Orient
=
m_FieldsBuf
[
REFERENCE
].
m_Orient
;
blank
.
m_Orient
=
m_FieldsBuf
[
REFERENCE
].
m_Orient
;
m_FieldsBuf
.
push_back
(
blank
);
m_FieldsBuf
.
push_back
(
blank
);
m_FieldsBuf
[
fieldNdx
].
m_Name
=
TEMPLATE_FIELDNAME
::
GetDefaultFieldName
(
fieldNdx
);
m_FieldsBuf
[
fieldNdx
].
SetName
(
TEMPLATE_FIELDNAME
::
GetDefaultFieldName
(
fieldNdx
)
);
m_skipCopyFromPanel
=
true
;
m_skipCopyFromPanel
=
true
;
setRowItem
(
fieldNdx
,
m_FieldsBuf
[
fieldNdx
]
);
setRowItem
(
fieldNdx
,
m_FieldsBuf
[
fieldNdx
]
);
...
@@ -361,7 +361,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& ev
...
@@ -361,7 +361,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& ev
SCH_FIELD
tmp
=
m_FieldsBuf
[
fieldNdx
-
1
];
SCH_FIELD
tmp
=
m_FieldsBuf
[
fieldNdx
-
1
];
D
(
printf
(
"tmp.m_Text=
\"
%s
\"
tmp.m_Name=
\"
%s
\"\n
"
,
D
(
printf
(
"tmp.m_Text=
\"
%s
\"
tmp.m_Name=
\"
%s
\"\n
"
,
TO_UTF8
(
tmp
.
m_Text
),
TO_UTF8
(
tmp
.
m_Name
)
);
)
TO_UTF8
(
tmp
.
m_Text
),
TO_UTF8
(
tmp
.
GetName
(
false
)
)
);
)
m_FieldsBuf
[
fieldNdx
-
1
]
=
m_FieldsBuf
[
fieldNdx
];
m_FieldsBuf
[
fieldNdx
-
1
]
=
m_FieldsBuf
[
fieldNdx
];
setRowItem
(
fieldNdx
-
1
,
m_FieldsBuf
[
fieldNdx
]
);
setRowItem
(
fieldNdx
-
1
,
m_FieldsBuf
[
fieldNdx
]
);
...
@@ -408,7 +408,7 @@ SCH_FIELD* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::findField( const wxString& aField
...
@@ -408,7 +408,7 @@ SCH_FIELD* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::findField( const wxString& aField
{
{
for
(
unsigned
i
=
0
;
i
<
m_FieldsBuf
.
size
();
++
i
)
for
(
unsigned
i
=
0
;
i
<
m_FieldsBuf
.
size
();
++
i
)
{
{
if
(
aFieldName
==
m_FieldsBuf
[
i
].
m_Name
)
if
(
aFieldName
==
m_FieldsBuf
[
i
].
GetName
(
false
)
)
return
&
m_FieldsBuf
[
i
];
return
&
m_FieldsBuf
[
i
];
}
}
...
@@ -499,7 +499,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
...
@@ -499,7 +499,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
for
(
unsigned
i
=
MANDATORY_FIELDS
;
i
<
aComponent
->
m_Fields
.
size
();
++
i
)
for
(
unsigned
i
=
MANDATORY_FIELDS
;
i
<
aComponent
->
m_Fields
.
size
();
++
i
)
{
{
SCH_FIELD
*
cmp
=
&
aComponent
->
m_Fields
[
i
];
SCH_FIELD
*
cmp
=
&
aComponent
->
m_Fields
[
i
];
SCH_FIELD
*
buf
=
findField
(
cmp
->
m_Name
);
SCH_FIELD
*
buf
=
findField
(
cmp
->
GetName
(
false
)
);
if
(
!
buf
)
if
(
!
buf
)
{
{
...
@@ -516,7 +516,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
...
@@ -516,7 +516,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
{
{
printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x,
printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x,
m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].
m_Name
) );
m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].
GetName( false )
) );
}
}
#endif
#endif
...
@@ -560,8 +560,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_FI
...
@@ -560,8 +560,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_FI
fieldListCtrl
->
SetItem
(
ndx
,
1
,
wxEmptyString
);
fieldListCtrl
->
SetItem
(
ndx
,
1
,
wxEmptyString
);
}
}
fieldListCtrl
->
SetItem
(
aFieldNdx
,
0
,
aField
.
m_Name
);
fieldListCtrl
->
SetItem
(
aFieldNdx
,
0
,
aField
.
GetName
(
false
)
);
fieldListCtrl
->
SetItem
(
aFieldNdx
,
1
,
aField
.
m_Text
);
fieldListCtrl
->
SetItem
(
aFieldNdx
,
1
,
aField
.
GetText
()
);
// recompute the column widths here, after setting texts
// recompute the column widths here, after setting texts
fieldListCtrl
->
SetColumnWidth
(
0
,
wxLIST_AUTOSIZE
);
fieldListCtrl
->
SetColumnWidth
(
0
,
wxLIST_AUTOSIZE
);
...
@@ -608,7 +608,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
...
@@ -608,7 +608,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
m_FieldVJustifyCtrl
->
SetSelection
(
1
);
m_FieldVJustifyCtrl
->
SetSelection
(
1
);
fieldNameTextCtrl
->
SetValue
(
field
.
m_Name
);
fieldNameTextCtrl
->
SetValue
(
field
.
GetName
(
false
)
);
// the names of the fixed fields are not editable, others are.
// the names of the fixed fields are not editable, others are.
fieldNameTextCtrl
->
Enable
(
fieldNdx
>=
MANDATORY_FIELDS
);
fieldNameTextCtrl
->
Enable
(
fieldNdx
>=
MANDATORY_FIELDS
);
...
@@ -698,7 +698,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
...
@@ -698,7 +698,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
field
.
m_HJustify
=
hjustify
[
m_FieldHJustifyCtrl
->
GetSelection
()];
field
.
m_HJustify
=
hjustify
[
m_FieldHJustifyCtrl
->
GetSelection
()];
field
.
m_VJustify
=
vjustify
[
m_FieldVJustifyCtrl
->
GetSelection
()];
field
.
m_VJustify
=
vjustify
[
m_FieldVJustifyCtrl
->
GetSelection
()];
field
.
m_Name
=
fieldNameTextCtrl
->
GetValue
(
);
field
.
SetName
(
fieldNameTextCtrl
->
GetValue
()
);
/* Void fields texts for REFERENCE and VALUE (value is the name of the
/* Void fields texts for REFERENCE and VALUE (value is the name of the
* component in lib ! ) are not allowed
* component in lib ! ) are not allowed
...
...
eeschema/edit_component_in_schematic.cpp
View file @
16131a50
...
@@ -77,7 +77,7 @@ create a new power component with the new value." ), GetChars( entry->GetName()
...
@@ -77,7 +77,7 @@ create a new power component with the new value." ), GetChars( entry->GetName()
DrawPanel
->
m_IgnoreMouseEvents
=
true
;
DrawPanel
->
m_IgnoreMouseEvents
=
true
;
wxString
title
;
wxString
title
;
title
.
Printf
(
_
(
"Edit %s Field"
),
GetChars
(
aField
->
m_Name
)
);
title
.
Printf
(
_
(
"Edit %s Field"
),
GetChars
(
aField
->
GetName
()
)
);
wxTextEntryDialog
dlg
(
this
,
wxEmptyString
,
title
,
newtext
);
wxTextEntryDialog
dlg
(
this
,
wxEmptyString
,
title
,
newtext
);
int
response
=
dlg
.
ShowModal
();
int
response
=
dlg
.
ShowModal
();
...
@@ -95,7 +95,7 @@ create a new power component with the new value." ), GetChars( entry->GetName()
...
@@ -95,7 +95,7 @@ create a new power component with the new value." ), GetChars( entry->GetName()
if
(
!
newtext
.
IsEmpty
()
)
if
(
!
newtext
.
IsEmpty
()
)
{
{
if
(
aField
->
m_Text
.
IsEmpty
()
)
// Means the field was not already in use
if
(
aField
->
GetText
()
.
IsEmpty
()
)
// Means the field was not already in use
{
{
aField
->
m_Pos
=
component
->
GetPosition
();
aField
->
m_Pos
=
component
->
GetPosition
();
aField
->
m_Size
.
x
=
aField
->
m_Size
.
y
=
m_TextFieldSize
;
aField
->
m_Size
.
x
=
aField
->
m_Size
.
y
=
m_TextFieldSize
;
...
@@ -107,7 +107,7 @@ create a new power component with the new value." ), GetChars( entry->GetName()
...
@@ -107,7 +107,7 @@ create a new power component with the new value." ), GetChars( entry->GetName()
if
(
SCH_COMPONENT
::
IsReferenceStringValid
(
newtext
)
)
if
(
SCH_COMPONENT
::
IsReferenceStringValid
(
newtext
)
)
{
{
component
->
SetRef
(
GetSheet
(),
newtext
);
component
->
SetRef
(
GetSheet
(),
newtext
);
aField
->
m_Text
=
newtext
;
aField
->
SetText
(
newtext
)
;
}
}
else
else
{
{
...
...
eeschema/netform.cpp
View file @
16131a50
...
@@ -1010,11 +1010,11 @@ XNODE* EXPORT_HELP::makeGenericComponents()
...
@@ -1010,11 +1010,11 @@ XNODE* EXPORT_HELP::makeGenericComponents()
SCH_FIELD
*
f
=
comp
->
GetField
(
fldNdx
);
SCH_FIELD
*
f
=
comp
->
GetField
(
fldNdx
);
// only output a field if non empty
// only output a field if non empty
if
(
!
f
->
m_Text
.
IsEmpty
()
)
if
(
!
f
->
GetText
()
.
IsEmpty
()
)
{
{
XNODE
*
xfield
;
XNODE
*
xfield
;
xfields
->
AddChild
(
xfield
=
node
(
sField
,
f
->
m_Text
)
);
xfields
->
AddChild
(
xfield
=
node
(
sField
,
f
->
m_Text
)
);
xfield
->
AddAttribute
(
sName
,
f
->
m_Name
);
xfield
->
AddAttribute
(
sName
,
f
->
GetName
()
);
}
}
}
}
}
}
...
...
eeschema/sch_component.cpp
View file @
16131a50
...
@@ -424,6 +424,7 @@ const wxString SCH_COMPONENT::GetRef( SCH_SHEET_PATH* sheet )
...
@@ -424,6 +424,7 @@ const wxString SCH_COMPONENT::GetRef( SCH_SHEET_PATH* sheet )
SetRef
(
sheet
,
GetField
(
REFERENCE
)
->
m_Text
);
SetRef
(
sheet
,
GetField
(
REFERENCE
)
->
m_Text
);
return
GetField
(
REFERENCE
)
->
m_Text
;
return
GetField
(
REFERENCE
)
->
m_Text
;
}
}
return
m_prefix
;
return
m_prefix
;
}
}
...
@@ -440,8 +441,7 @@ bool SCH_COMPONENT::IsReferenceStringValid( const wxString & aReferenceString )
...
@@ -440,8 +441,7 @@ bool SCH_COMPONENT::IsReferenceStringValid( const wxString & aReferenceString )
bool
ok
=
true
;
bool
ok
=
true
;
// Try to unannotate this reference
// Try to unannotate this reference
while
(
!
text
.
IsEmpty
()
&&
while
(
!
text
.
IsEmpty
()
&&
(
text
.
Last
()
==
'?'
||
isdigit
(
text
.
Last
()
)
)
)
(
text
.
Last
()
==
'?'
||
isdigit
(
text
.
Last
()
)
)
)
text
.
RemoveLast
();
text
.
RemoveLast
();
if
(
text
.
IsEmpty
()
)
if
(
text
.
IsEmpty
()
)
...
@@ -502,13 +502,16 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref )
...
@@ -502,13 +502,16 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref )
// Reinit the m_prefix member if needed
// Reinit the m_prefix member if needed
wxString
prefix
=
ref
;
wxString
prefix
=
ref
;
if
(
IsReferenceStringValid
(
prefix
)
)
if
(
IsReferenceStringValid
(
prefix
)
)
{
{
while
(
prefix
.
Last
()
==
'?'
||
isdigit
(
prefix
.
Last
()
)
)
while
(
prefix
.
Last
()
==
'?'
||
isdigit
(
prefix
.
Last
()
)
)
prefix
.
RemoveLast
();
prefix
.
RemoveLast
();
}
}
else
else
{
prefix
=
wxT
(
"U"
);
// Set to default ref prefix
prefix
=
wxT
(
"U"
);
// Set to default ref prefix
}
if
(
m_prefix
!=
prefix
)
if
(
m_prefix
!=
prefix
)
m_prefix
=
prefix
;
m_prefix
=
prefix
;
...
@@ -582,6 +585,7 @@ void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection
...
@@ -582,6 +585,7 @@ void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection
h_ref
+=
tokenizer
.
GetNextToken
();
// Add reference
h_ref
+=
tokenizer
.
GetNextToken
();
// Add reference
h_ref
+=
wxT
(
" "
);
h_ref
+=
wxT
(
" "
);
h_ref
<<
aUnitSelection
;
// Add part selection
h_ref
<<
aUnitSelection
;
// Add part selection
// Ann the part selection
// Ann the part selection
m_PathsAndReferences
[
ii
]
=
h_ref
;
m_PathsAndReferences
[
ii
]
=
h_ref
;
notInArray
=
false
;
notInArray
=
false
;
...
@@ -622,7 +626,7 @@ SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName )
...
@@ -622,7 +626,7 @@ SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName )
{
{
for
(
unsigned
i
=
0
;
i
<
m_Fields
.
size
();
++
i
)
for
(
unsigned
i
=
0
;
i
<
m_Fields
.
size
();
++
i
)
{
{
if
(
aFieldName
==
m_Fields
[
i
].
m_Name
)
if
(
aFieldName
==
m_Fields
[
i
].
GetName
(
false
)
)
return
&
m_Fields
[
i
];
return
&
m_Fields
[
i
];
}
}
...
@@ -690,6 +694,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
...
@@ -690,6 +694,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
// Build a reference with no annotation,
// Build a reference with no annotation,
// i.e. a reference ended by only one '?'
// i.e. a reference ended by only one '?'
wxString
defRef
=
m_prefix
;
wxString
defRef
=
m_prefix
;
if
(
IsReferenceStringValid
(
defRef
)
)
if
(
IsReferenceStringValid
(
defRef
)
)
{
{
while
(
defRef
.
Last
()
==
'?'
)
while
(
defRef
.
Last
()
==
'?'
)
...
@@ -966,8 +971,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
...
@@ -966,8 +971,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
//files backwards-compatible.
//files backwards-compatible.
if
(
m_PathsAndReferences
.
GetCount
()
>
0
)
if
(
m_PathsAndReferences
.
GetCount
()
>
0
)
{
{
reference_fields
=
wxStringTokenize
(
m_PathsAndReferences
[
0
],
reference_fields
=
wxStringTokenize
(
m_PathsAndReferences
[
0
],
delimiters
);
delimiters
);
name1
=
toUTFTildaText
(
reference_fields
[
1
]
);
name1
=
toUTFTildaText
(
reference_fields
[
1
]
);
}
}
...
@@ -984,7 +988,9 @@ bool SCH_COMPONENT::Save( FILE* f ) const
...
@@ -984,7 +988,9 @@ bool SCH_COMPONENT::Save( FILE* f ) const
name2
=
toUTFTildaText
(
m_ChipName
);
name2
=
toUTFTildaText
(
m_ChipName
);
}
}
else
else
{
name2
=
NULL_STRING
;
name2
=
NULL_STRING
;
}
if
(
fprintf
(
f
,
"$Comp
\n
"
)
==
EOF
)
if
(
fprintf
(
f
,
"$Comp
\n
"
)
==
EOF
)
return
false
;
return
false
;
...
@@ -1031,7 +1037,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
...
@@ -1031,7 +1037,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
for
(
unsigned
i
=
0
;
i
<
m_Fields
.
size
();
++
i
)
for
(
unsigned
i
=
0
;
i
<
m_Fields
.
size
();
++
i
)
{
{
SCH_FIELD
*
fld
=
GetField
(
i
);
SCH_FIELD
*
fld
=
GetField
(
i
);
fld
->
m_FieldId
=
i
;
// we don't need field Ids, please be gone.
fld
->
SetId
(
i
)
;
// we don't need field Ids, please be gone.
}
}
// Fixed fields:
// Fixed fields:
...
@@ -1108,8 +1114,10 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
...
@@ -1108,8 +1114,10 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
if
(
strcmp
(
name1
,
NULL_STRING
)
!=
0
)
if
(
strcmp
(
name1
,
NULL_STRING
)
!=
0
)
{
{
for
(
ii
=
0
;
ii
<
(
int
)
strlen
(
name1
);
ii
++
)
for
(
ii
=
0
;
ii
<
(
int
)
strlen
(
name1
);
ii
++
)
{
if
(
name1
[
ii
]
==
'~'
)
if
(
name1
[
ii
]
==
'~'
)
name1
[
ii
]
=
' '
;
name1
[
ii
]
=
' '
;
}
m_ChipName
=
FROM_UTF8
(
name1
);
m_ChipName
=
FROM_UTF8
(
name1
);
...
@@ -1139,6 +1147,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
...
@@ -1139,6 +1147,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
isDigit
=
true
;
isDigit
=
true
;
name1
[
ii
]
=
0
;
//null-terminate.
name1
[
ii
]
=
0
;
//null-terminate.
}
}
if
(
!
isDigit
)
if
(
!
isDigit
)
{
{
name1
[
ii
]
=
name2
[
ii
];
name1
[
ii
]
=
name2
[
ii
];
...
@@ -1226,11 +1235,15 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
...
@@ -1226,11 +1235,15 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
// copy the multi, if exists
// copy the multi, if exists
ii
=
ReadDelimitedText
(
name1
,
ptcar
,
255
);
ii
=
ReadDelimitedText
(
name1
,
ptcar
,
255
);
if
(
name1
[
0
]
==
0
)
// Nothing read, put a default value
if
(
name1
[
0
]
==
0
)
// Nothing read, put a default value
sprintf
(
name1
,
"%d"
,
m_unit
);
sprintf
(
name1
,
"%d"
,
m_unit
);
int
multi
=
atoi
(
name1
);
int
multi
=
atoi
(
name1
);
if
(
multi
<
0
||
multi
>
25
)
if
(
multi
<
0
||
multi
>
25
)
multi
=
1
;
multi
=
1
;
AddHierarchicalReference
(
path
,
ref
,
multi
);
AddHierarchicalReference
(
path
,
ref
,
multi
);
GetField
(
REFERENCE
)
->
m_Text
=
ref
;
GetField
(
REFERENCE
)
->
m_Text
=
ref
;
}
}
...
@@ -1255,6 +1268,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
...
@@ -1255,6 +1268,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
}
ptcar
+=
ReadDelimitedText
(
&
fieldText
,
ptcar
);
ptcar
+=
ReadDelimitedText
(
&
fieldText
,
ptcar
);
if
(
*
ptcar
==
0
)
if
(
*
ptcar
==
0
)
{
{
aErrorMsg
.
Printf
(
wxT
(
"Component field F at line %d, aborted"
),
aErrorMsg
.
Printf
(
wxT
(
"Component field F at line %d, aborted"
),
...
@@ -1290,11 +1304,12 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
...
@@ -1290,11 +1304,12 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
}
else
else
{
{
GetField
(
fieldNdx
)
->
m_Name
=
fieldName
;
GetField
(
fieldNdx
)
->
SetName
(
fieldName
)
;
}
}
GetField
(
fieldNdx
)
->
m_Text
=
fieldText
;
GetField
(
fieldNdx
)
->
m_Text
=
fieldText
;
memset
(
char3
,
0
,
sizeof
(
char3
)
);
memset
(
char3
,
0
,
sizeof
(
char3
)
);
if
(
(
ii
=
sscanf
(
ptcar
,
"%s %d %d %d %X %s %s"
,
char1
,
if
(
(
ii
=
sscanf
(
ptcar
,
"%s %d %d %d %X %s %s"
,
char1
,
&
GetField
(
fieldNdx
)
->
m_Pos
.
x
,
&
GetField
(
fieldNdx
)
->
m_Pos
.
x
,
&
GetField
(
fieldNdx
)
->
m_Pos
.
y
,
&
GetField
(
fieldNdx
)
->
m_Pos
.
y
,
...
@@ -1322,14 +1337,17 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
...
@@ -1322,14 +1337,17 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
hjustify
=
GR_TEXT_HJUSTIFY_LEFT
;
hjustify
=
GR_TEXT_HJUSTIFY_LEFT
;
else
if
(
*
char2
==
'R'
)
else
if
(
*
char2
==
'R'
)
hjustify
=
GR_TEXT_HJUSTIFY_RIGHT
;
hjustify
=
GR_TEXT_HJUSTIFY_RIGHT
;
if
(
char3
[
0
]
==
'B'
)
if
(
char3
[
0
]
==
'B'
)
vjustify
=
GR_TEXT_VJUSTIFY_BOTTOM
;
vjustify
=
GR_TEXT_VJUSTIFY_BOTTOM
;
else
if
(
char3
[
0
]
==
'T'
)
else
if
(
char3
[
0
]
==
'T'
)
vjustify
=
GR_TEXT_VJUSTIFY_TOP
;
vjustify
=
GR_TEXT_VJUSTIFY_TOP
;
if
(
char3
[
1
]
==
'I'
)
if
(
char3
[
1
]
==
'I'
)
GetField
(
fieldNdx
)
->
m_Italic
=
true
;
GetField
(
fieldNdx
)
->
m_Italic
=
true
;
else
else
GetField
(
fieldNdx
)
->
m_Italic
=
false
;
GetField
(
fieldNdx
)
->
m_Italic
=
false
;
if
(
char3
[
2
]
==
'B'
)
if
(
char3
[
2
]
==
'B'
)
GetField
(
fieldNdx
)
->
m_Bold
=
true
;
GetField
(
fieldNdx
)
->
m_Bold
=
true
;
else
else
...
@@ -1344,8 +1362,10 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
...
@@ -1344,8 +1362,10 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
GetField
(
fieldNdx
)
->
m_Attributs
|=
TEXT_NO_VISIBLE
;
GetField
(
fieldNdx
)
->
m_Attributs
|=
TEXT_NO_VISIBLE
;
}
}
else
else
{
break
;
break
;
}
}
}
if
(
sscanf
(
line
,
"%d %d %d"
,
&
m_unit
,
&
m_Pos
.
x
,
&
m_Pos
.
y
)
!=
3
)
if
(
sscanf
(
line
,
"%d %d %d"
,
&
m_unit
,
&
m_Pos
.
x
,
&
m_Pos
.
y
)
!=
3
)
{
{
...
...
eeschema/sch_field.cpp
View file @
16131a50
...
@@ -59,9 +59,9 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
...
@@ -59,9 +59,9 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
EDA_TEXT
()
EDA_TEXT
()
{
{
m_Pos
=
aPos
;
m_Pos
=
aPos
;
m_
FieldI
d
=
aFieldId
;
m_
i
d
=
aFieldId
;
m_Attributs
=
TEXT_NO_VISIBLE
;
m_Attributs
=
TEXT_NO_VISIBLE
;
m_
N
ame
=
aName
;
m_
n
ame
=
aName
;
SetLayer
(
LAYER_FIELDS
);
SetLayer
(
LAYER_FIELDS
);
}
}
...
@@ -71,8 +71,8 @@ SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) :
...
@@ -71,8 +71,8 @@ SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) :
SCH_ITEM
(
aField
),
SCH_ITEM
(
aField
),
EDA_TEXT
(
aField
)
EDA_TEXT
(
aField
)
{
{
m_
FieldId
=
aField
.
m_FieldI
d
;
m_
id
=
aField
.
m_i
d
;
m_
Name
=
aField
.
m_N
ame
;
m_
name
=
aField
.
m_n
ame
;
}
}
...
@@ -93,7 +93,7 @@ const wxString SCH_FIELD::GetText() const
...
@@ -93,7 +93,7 @@ const wxString SCH_FIELD::GetText() const
/* For more than one part per package, we must add the part selection
/* For more than one part per package, we must add the part selection
* A, B, ... or 1, 2, .. to the reference. */
* A, B, ... or 1, 2, .. to the reference. */
if
(
m_
FieldI
d
==
REFERENCE
)
if
(
m_
i
d
==
REFERENCE
)
{
{
SCH_COMPONENT
*
component
=
(
SCH_COMPONENT
*
)
m_Parent
;
SCH_COMPONENT
*
component
=
(
SCH_COMPONENT
*
)
m_Parent
;
...
@@ -178,9 +178,9 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
...
@@ -178,9 +178,9 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
EDA_RECT
boundaryBox
=
GetBoundingBox
();
EDA_RECT
boundaryBox
=
GetBoundingBox
();
textpos
=
boundaryBox
.
Centre
();
textpos
=
boundaryBox
.
Centre
();
if
(
m_
FieldI
d
==
REFERENCE
)
if
(
m_
i
d
==
REFERENCE
)
color
=
ReturnLayerColor
(
LAYER_REFERENCEPART
);
color
=
ReturnLayerColor
(
LAYER_REFERENCEPART
);
else
if
(
m_
FieldI
d
==
VALUE
)
else
if
(
m_
i
d
==
VALUE
)
color
=
ReturnLayerColor
(
LAYER_VALUEPART
);
color
=
ReturnLayerColor
(
LAYER_VALUEPART
);
else
else
color
=
ReturnLayerColor
(
LAYER_FIELDS
);
color
=
ReturnLayerColor
(
LAYER_FIELDS
);
...
@@ -306,7 +306,7 @@ bool SCH_FIELD::Save( FILE* aFile ) const
...
@@ -306,7 +306,7 @@ bool SCH_FIELD::Save( FILE* aFile ) const
vjustify
=
'T'
;
vjustify
=
'T'
;
if
(
fprintf
(
aFile
,
"F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c"
,
if
(
fprintf
(
aFile
,
"F %d %s %c %-3d %-3d %-3d %4.4X %c %c%c%c"
,
m_
FieldI
d
,
m_
i
d
,
EscapedUTF8
(
m_Text
).
c_str
(),
// wraps in quotes too
EscapedUTF8
(
m_Text
).
c_str
(),
// wraps in quotes too
m_Orient
==
TEXT_ORIENT_HORIZ
?
'H'
:
'V'
,
m_Orient
==
TEXT_ORIENT_HORIZ
?
'H'
:
'V'
,
m_Pos
.
x
,
m_Pos
.
y
,
m_Pos
.
x
,
m_Pos
.
y
,
...
@@ -320,9 +320,9 @@ bool SCH_FIELD::Save( FILE* aFile ) const
...
@@ -320,9 +320,9 @@ bool SCH_FIELD::Save( FILE* aFile ) const
}
}
// Save field name, if the name is user definable
// Save field name, if the name is user definable
if
(
m_
FieldI
d
>=
FIELD1
)
if
(
m_
i
d
>=
FIELD1
)
{
{
if
(
fprintf
(
aFile
,
" %s"
,
EscapedUTF8
(
m_
N
ame
).
c_str
()
)
==
EOF
)
if
(
fprintf
(
aFile
,
" %s"
,
EscapedUTF8
(
m_
n
ame
).
c_str
()
)
==
EOF
)
{
{
return
false
;
return
false
;
}
}
...
@@ -358,14 +358,14 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint
...
@@ -358,14 +358,14 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint
bool
match
;
bool
match
;
wxString
text
=
GetText
();
wxString
text
=
GetText
();
if
(
(
m_
FieldI
d
>
VALUE
)
&&
!
(
aSearchData
.
GetFlags
()
&
FR_SEARCH_ALL_FIELDS
)
)
if
(
(
m_
i
d
>
VALUE
)
&&
!
(
aSearchData
.
GetFlags
()
&
FR_SEARCH_ALL_FIELDS
)
)
return
false
;
return
false
;
wxLogTrace
(
traceFindReplace
,
wxT
(
" child item "
)
+
GetSelectMenuText
()
);
wxLogTrace
(
traceFindReplace
,
wxT
(
" child item "
)
+
GetSelectMenuText
()
);
// Take sheet path into account which effects the reference field and the unit for
// Take sheet path into account which effects the reference field and the unit for
// components with multiple parts.
// components with multiple parts.
if
(
m_
FieldI
d
==
REFERENCE
&&
aAuxData
!=
NULL
)
if
(
m_
i
d
==
REFERENCE
&&
aAuxData
!=
NULL
)
{
{
SCH_COMPONENT
*
component
=
(
SCH_COMPONENT
*
)
m_Parent
;
SCH_COMPONENT
*
component
=
(
SCH_COMPONENT
*
)
m_Parent
;
...
@@ -407,24 +407,26 @@ wxString SCH_FIELD::GetSelectMenuText() const
...
@@ -407,24 +407,26 @@ wxString SCH_FIELD::GetSelectMenuText() const
}
}
wxString
SCH_FIELD
::
GetName
()
const
wxString
SCH_FIELD
::
GetName
(
bool
aUseDefaultName
)
const
{
{
if
(
!
m_Name
.
IsEmpty
()
)
if
(
!
m_name
.
IsEmpty
()
)
return
m_Name
;
return
m_name
;
else
else
if
(
aUseDefaultName
)
return
TEMPLATE_FIELDNAME
::
GetDefaultFieldName
(
m_FieldId
);
return
TEMPLATE_FIELDNAME
::
GetDefaultFieldName
(
m_id
);
return
wxEmptyString
;
}
}
BITMAP_DEF
SCH_FIELD
::
GetMenuImage
()
const
BITMAP_DEF
SCH_FIELD
::
GetMenuImage
()
const
{
{
if
(
m_
FieldI
d
==
REFERENCE
)
if
(
m_
i
d
==
REFERENCE
)
return
edit_comp_ref_xpm
;
return
edit_comp_ref_xpm
;
if
(
m_
FieldI
d
==
VALUE
)
if
(
m_
i
d
==
VALUE
)
return
edit_comp_value_xpm
;
return
edit_comp_value_xpm
;
if
(
m_
FieldI
d
==
FOOTPRINT
)
if
(
m_
i
d
==
FOOTPRINT
)
return
edit_comp_footprint_xpm
;
return
edit_comp_footprint_xpm
;
return
edit_text_xpm
;
return
edit_text_xpm
;
...
@@ -462,15 +464,6 @@ bool SCH_FIELD::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
...
@@ -462,15 +464,6 @@ bool SCH_FIELD::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
}
}
/* Plot field text.
* Input:
* DrawLibItem: pointer to the component
* FieldNumber: Number Field
* IsMulti: true flag if there are several parts per package.
* Only useful for the field to add a reference to this one
* The identification from (A, B ...)
* DrawMode: trace mode
*/
void
SCH_FIELD
::
doPlot
(
PLOTTER
*
aPlotter
)
void
SCH_FIELD
::
doPlot
(
PLOTTER
*
aPlotter
)
{
{
SCH_COMPONENT
*
parent
=
(
SCH_COMPONENT
*
)
GetParent
();
SCH_COMPONENT
*
parent
=
(
SCH_COMPONENT
*
)
GetParent
();
...
@@ -518,7 +511,7 @@ void SCH_FIELD::doPlot( PLOTTER* aPlotter )
...
@@ -518,7 +511,7 @@ void SCH_FIELD::doPlot( PLOTTER* aPlotter )
int
thickness
=
GetPenSize
();
int
thickness
=
GetPenSize
();
if
(
(
parent
->
GetPartCount
()
<=
1
)
||
(
m_
FieldI
d
!=
REFERENCE
)
)
if
(
(
parent
->
GetPartCount
()
<=
1
)
||
(
m_
i
d
!=
REFERENCE
)
)
{
{
aPlotter
->
text
(
textpos
,
color
,
m_Text
,
orient
,
m_Size
,
hjustify
,
vjustify
,
aPlotter
->
text
(
textpos
,
color
,
m_Text
,
orient
,
m_Size
,
hjustify
,
vjustify
,
thickness
,
m_Italic
,
m_Bold
);
thickness
,
m_Italic
,
m_Bold
);
...
...
eeschema/sch_field.h
View file @
16131a50
...
@@ -55,10 +55,9 @@ class LIB_FIELD;
...
@@ -55,10 +55,9 @@ class LIB_FIELD;
class
SCH_FIELD
:
public
SCH_ITEM
,
public
EDA_TEXT
class
SCH_FIELD
:
public
SCH_ITEM
,
public
EDA_TEXT
{
{
public
:
int
m_id
;
///< Field index, @see enum NumFieldType
int
m_FieldId
;
///< Field index, @see enum NumFieldType
wxString
m_
N
ame
;
wxString
m_
n
ame
;
public
:
public
:
SCH_FIELD
(
const
wxPoint
&
aPos
,
int
aFieldId
,
SCH_COMPONENT
*
aParent
,
SCH_FIELD
(
const
wxPoint
&
aPos
,
int
aFieldId
,
SCH_COMPONENT
*
aParent
,
...
@@ -75,13 +74,19 @@ public:
...
@@ -75,13 +74,19 @@ public:
/**
/**
* Function GetName
* Function GetName
* returns the field name. If the field name is empty, the default field name is
* returns the field name.
* returned. Field names are VALUE, REFERENCE, etc.
*
* @return The name of the field.
* @param aUseDefaultName When true return the default field name if the field name is
* empty. Otherwise the default field name is returned.
* @return A wxString object containing the name of the field.
*/
*/
wxString
GetName
()
const
;
wxString
GetName
(
bool
aUseDefaultName
=
true
)
const
;
void
SetName
(
const
wxString
&
aName
)
{
m_name
=
aName
;
}
int
GetId
()
const
{
return
m_FieldId
;
}
int
GetId
()
const
{
return
m_id
;
}
void
SetId
(
int
aId
)
{
m_id
=
aId
;
}
/**
/**
* Function GetText
* Function GetText
...
@@ -109,7 +114,7 @@ public:
...
@@ -109,7 +114,7 @@ public:
/**
/**
* Function SwapData
* Function SwapData
* exchanges the date between the field and \a a
Field.
* exchanges the date between the field and \a a
Item
*
*
* @param aItem The field to exchange data with.
* @param aItem The field to exchange data with.
*/
*/
...
@@ -192,15 +197,7 @@ public:
...
@@ -192,15 +197,7 @@ public:
}
}
/**
/**
* Compare schematic field text against search string.
* @copydoc EDA_ITEM::Matches(wxFindReplaceData&,void*,wxPoint*)
*
* @param aSearchData - Criteria to search against.
* @param aAuxData - a pointer on auxiliary data, if needed.
* the sheet path is needed for REFERENCE field because m_Text
* value is just the value displayed, and in complex hierarchies
* this is only one of all references (one per sheet path)
* @param aFindLocation - a wxPoint where to put the location of matched item. can be NULL.
* @return True if this field text matches the search criteria.
*/
*/
virtual
bool
Matches
(
wxFindReplaceData
&
aSearchData
,
virtual
bool
Matches
(
wxFindReplaceData
&
aSearchData
,
void
*
aAuxData
,
wxPoint
*
aFindLocation
);
void
*
aAuxData
,
wxPoint
*
aFindLocation
);
...
...
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