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
Hide 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
// 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
();
)
{
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
// 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
// resolve most of the bug reports and questions regarding missing fields.
if
(
!
m_FieldsBuf
[
i
].
m_Name
.
IsEmpty
()
&&
m_FieldsBuf
[
i
].
m_Text
.
IsEmpty
()
&&
!
m_Parent
->
GetTemplates
().
HasFieldName
(
m_FieldsBuf
[
i
].
m_Name
)
if
(
!
m_FieldsBuf
[
i
].
GetName
(
false
).
IsEmpty
()
&&
m_FieldsBuf
[
i
].
GetText
()
.
IsEmpty
()
&&
!
m_Parent
->
GetTemplates
().
HasFieldName
(
m_FieldsBuf
[
i
].
GetName
(
false
)
)
&&
!
removeRemainingFields
)
{
wxString
msg
;
...
...
@@ -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 \
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?"
),
GetChars
(
m_FieldsBuf
[
i
].
m_Name
)
);
GetChars
(
m_FieldsBuf
[
i
].
GetName
(
false
)
)
);
wxMessageDialog
dlg
(
this
,
msg
,
_
(
"Remove Fields"
),
wxYES_NO
|
wxNO_DEFAULT
);
...
...
@@ -303,7 +303,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent&
blank
.
m_Orient
=
m_FieldsBuf
[
REFERENCE
].
m_Orient
;
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
;
setRowItem
(
fieldNdx
,
m_FieldsBuf
[
fieldNdx
]
);
...
...
@@ -361,7 +361,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& ev
SCH_FIELD
tmp
=
m_FieldsBuf
[
fieldNdx
-
1
];
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
];
setRowItem
(
fieldNdx
-
1
,
m_FieldsBuf
[
fieldNdx
]
);
...
...
@@ -408,7 +408,7 @@ SCH_FIELD* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::findField( const wxString& aField
{
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
];
}
...
...
@@ -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
)
{
SCH_FIELD
*
cmp
=
&
aComponent
->
m_Fields
[
i
];
SCH_FIELD
*
buf
=
findField
(
cmp
->
m_Name
);
SCH_FIELD
*
buf
=
findField
(
cmp
->
GetName
(
false
)
);
if
(
!
buf
)
{
...
...
@@ -516,7 +516,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
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,
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
...
...
@@ -560,8 +560,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_FI
fieldListCtrl
->
SetItem
(
ndx
,
1
,
wxEmptyString
);
}
fieldListCtrl
->
SetItem
(
aFieldNdx
,
0
,
aField
.
m_Name
);
fieldListCtrl
->
SetItem
(
aFieldNdx
,
1
,
aField
.
m_Text
);
fieldListCtrl
->
SetItem
(
aFieldNdx
,
0
,
aField
.
GetName
(
false
)
);
fieldListCtrl
->
SetItem
(
aFieldNdx
,
1
,
aField
.
GetText
()
);
// recompute the column widths here, after setting texts
fieldListCtrl
->
SetColumnWidth
(
0
,
wxLIST_AUTOSIZE
);
...
...
@@ -608,7 +608,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
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.
fieldNameTextCtrl
->
Enable
(
fieldNdx
>=
MANDATORY_FIELDS
);
...
...
@@ -698,7 +698,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
field
.
m_HJustify
=
hjustify
[
m_FieldHJustifyCtrl
->
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
* 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()
DrawPanel
->
m_IgnoreMouseEvents
=
true
;
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
);
int
response
=
dlg
.
ShowModal
();
...
...
@@ -95,7 +95,7 @@ create a new power component with the new value." ), GetChars( entry->GetName()
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_Size
.
x
=
aField
->
m_Size
.
y
=
m_TextFieldSize
;
...
...
@@ -107,7 +107,7 @@ create a new power component with the new value." ), GetChars( entry->GetName()
if
(
SCH_COMPONENT
::
IsReferenceStringValid
(
newtext
)
)
{
component
->
SetRef
(
GetSheet
(),
newtext
);
aField
->
m_Text
=
newtext
;
aField
->
SetText
(
newtext
)
;
}
else
{
...
...
eeschema/netform.cpp
View file @
16131a50
...
...
@@ -1010,11 +1010,11 @@ XNODE* EXPORT_HELP::makeGenericComponents()
SCH_FIELD
*
f
=
comp
->
GetField
(
fldNdx
);
// only output a field if non empty
if
(
!
f
->
m_Text
.
IsEmpty
()
)
if
(
!
f
->
GetText
()
.
IsEmpty
()
)
{
XNODE
*
xfield
;
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 )
SetRef
(
sheet
,
GetField
(
REFERENCE
)
->
m_Text
);
return
GetField
(
REFERENCE
)
->
m_Text
;
}
return
m_prefix
;
}
...
...
@@ -440,8 +441,7 @@ bool SCH_COMPONENT::IsReferenceStringValid( const wxString & aReferenceString )
bool
ok
=
true
;
// Try to unannotate this reference
while
(
!
text
.
IsEmpty
()
&&
(
text
.
Last
()
==
'?'
||
isdigit
(
text
.
Last
()
)
)
)
while
(
!
text
.
IsEmpty
()
&&
(
text
.
Last
()
==
'?'
||
isdigit
(
text
.
Last
()
)
)
)
text
.
RemoveLast
();
if
(
text
.
IsEmpty
()
)
...
...
@@ -502,13 +502,16 @@ void SCH_COMPONENT::SetRef( SCH_SHEET_PATH* sheet, const wxString& ref )
// Reinit the m_prefix member if needed
wxString
prefix
=
ref
;
if
(
IsReferenceStringValid
(
prefix
)
)
{
while
(
prefix
.
Last
()
==
'?'
||
isdigit
(
prefix
.
Last
()
)
)
prefix
.
RemoveLast
();
}
else
{
prefix
=
wxT
(
"U"
);
// Set to default ref prefix
}
if
(
m_prefix
!=
prefix
)
m_prefix
=
prefix
;
...
...
@@ -582,6 +585,7 @@ void SCH_COMPONENT::SetUnitSelection( SCH_SHEET_PATH* aSheet, int aUnitSelection
h_ref
+=
tokenizer
.
GetNextToken
();
// Add reference
h_ref
+=
wxT
(
" "
);
h_ref
<<
aUnitSelection
;
// Add part selection
// Ann the part selection
m_PathsAndReferences
[
ii
]
=
h_ref
;
notInArray
=
false
;
...
...
@@ -622,7 +626,7 @@ SCH_FIELD* SCH_COMPONENT::FindField( const wxString& aFieldName )
{
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
];
}
...
...
@@ -690,6 +694,7 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
// Build a reference with no annotation,
// i.e. a reference ended by only one '?'
wxString
defRef
=
m_prefix
;
if
(
IsReferenceStringValid
(
defRef
)
)
{
while
(
defRef
.
Last
()
==
'?'
)
...
...
@@ -966,8 +971,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
//files backwards-compatible.
if
(
m_PathsAndReferences
.
GetCount
()
>
0
)
{
reference_fields
=
wxStringTokenize
(
m_PathsAndReferences
[
0
],
delimiters
);
reference_fields
=
wxStringTokenize
(
m_PathsAndReferences
[
0
],
delimiters
);
name1
=
toUTFTildaText
(
reference_fields
[
1
]
);
}
...
...
@@ -984,7 +988,9 @@ bool SCH_COMPONENT::Save( FILE* f ) const
name2
=
toUTFTildaText
(
m_ChipName
);
}
else
{
name2
=
NULL_STRING
;
}
if
(
fprintf
(
f
,
"$Comp
\n
"
)
==
EOF
)
return
false
;
...
...
@@ -1031,7 +1037,7 @@ bool SCH_COMPONENT::Save( FILE* f ) const
for
(
unsigned
i
=
0
;
i
<
m_Fields
.
size
();
++
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:
...
...
@@ -1108,8 +1114,10 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
if
(
strcmp
(
name1
,
NULL_STRING
)
!=
0
)
{
for
(
ii
=
0
;
ii
<
(
int
)
strlen
(
name1
);
ii
++
)
{
if
(
name1
[
ii
]
==
'~'
)
name1
[
ii
]
=
' '
;
}
m_ChipName
=
FROM_UTF8
(
name1
);
...
...
@@ -1139,6 +1147,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
isDigit
=
true
;
name1
[
ii
]
=
0
;
//null-terminate.
}
if
(
!
isDigit
)
{
name1
[
ii
]
=
name2
[
ii
];
...
...
@@ -1226,11 +1235,15 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
// copy the multi, if exists
ii
=
ReadDelimitedText
(
name1
,
ptcar
,
255
);
if
(
name1
[
0
]
==
0
)
// Nothing read, put a default value
sprintf
(
name1
,
"%d"
,
m_unit
);
int
multi
=
atoi
(
name1
);
if
(
multi
<
0
||
multi
>
25
)
multi
=
1
;
AddHierarchicalReference
(
path
,
ref
,
multi
);
GetField
(
REFERENCE
)
->
m_Text
=
ref
;
}
...
...
@@ -1255,6 +1268,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
ptcar
+=
ReadDelimitedText
(
&
fieldText
,
ptcar
);
if
(
*
ptcar
==
0
)
{
aErrorMsg
.
Printf
(
wxT
(
"Component field F at line %d, aborted"
),
...
...
@@ -1290,11 +1304,12 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
}
else
{
GetField
(
fieldNdx
)
->
m_Name
=
fieldName
;
GetField
(
fieldNdx
)
->
SetName
(
fieldName
)
;
}
GetField
(
fieldNdx
)
->
m_Text
=
fieldText
;
memset
(
char3
,
0
,
sizeof
(
char3
)
);
if
(
(
ii
=
sscanf
(
ptcar
,
"%s %d %d %d %X %s %s"
,
char1
,
&
GetField
(
fieldNdx
)
->
m_Pos
.
x
,
&
GetField
(
fieldNdx
)
->
m_Pos
.
y
,
...
...
@@ -1322,14 +1337,17 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
hjustify
=
GR_TEXT_HJUSTIFY_LEFT
;
else
if
(
*
char2
==
'R'
)
hjustify
=
GR_TEXT_HJUSTIFY_RIGHT
;
if
(
char3
[
0
]
==
'B'
)
vjustify
=
GR_TEXT_VJUSTIFY_BOTTOM
;
else
if
(
char3
[
0
]
==
'T'
)
vjustify
=
GR_TEXT_VJUSTIFY_TOP
;
if
(
char3
[
1
]
==
'I'
)
GetField
(
fieldNdx
)
->
m_Italic
=
true
;
else
GetField
(
fieldNdx
)
->
m_Italic
=
false
;
if
(
char3
[
2
]
==
'B'
)
GetField
(
fieldNdx
)
->
m_Bold
=
true
;
else
...
...
@@ -1344,7 +1362,9 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
GetField
(
fieldNdx
)
->
m_Attributs
|=
TEXT_NO_VISIBLE
;
}
else
{
break
;
}
}
if
(
sscanf
(
line
,
"%d %d %d"
,
&
m_unit
,
&
m_Pos
.
x
,
&
m_Pos
.
y
)
!=
3
)
...
...
eeschema/sch_field.cpp
View file @
16131a50
...
...
@@ -58,10 +58,10 @@ SCH_FIELD::SCH_FIELD( const wxPoint& aPos, int aFieldId, SCH_COMPONENT* aParent,
SCH_ITEM
(
aParent
,
SCH_FIELD_T
),
EDA_TEXT
()
{
m_Pos
=
aPos
;
m_
FieldI
d
=
aFieldId
;
m_Attributs
=
TEXT_NO_VISIBLE
;
m_
N
ame
=
aName
;
m_Pos
=
aPos
;
m_
i
d
=
aFieldId
;
m_Attributs
=
TEXT_NO_VISIBLE
;
m_
n
ame
=
aName
;
SetLayer
(
LAYER_FIELDS
);
}
...
...
@@ -71,8 +71,8 @@ SCH_FIELD::SCH_FIELD( const SCH_FIELD& aField ) :
SCH_ITEM
(
aField
),
EDA_TEXT
(
aField
)
{
m_
FieldId
=
aField
.
m_FieldI
d
;
m_
Name
=
aField
.
m_N
ame
;
m_
id
=
aField
.
m_i
d
;
m_
name
=
aField
.
m_n
ame
;
}
...
...
@@ -93,7 +93,7 @@ const wxString SCH_FIELD::GetText() const
/* For more than one part per package, we must add the part selection
* 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
;
...
...
@@ -178,9 +178,9 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
EDA_RECT
boundaryBox
=
GetBoundingBox
();
textpos
=
boundaryBox
.
Centre
();
if
(
m_
FieldI
d
==
REFERENCE
)
if
(
m_
i
d
==
REFERENCE
)
color
=
ReturnLayerColor
(
LAYER_REFERENCEPART
);
else
if
(
m_
FieldI
d
==
VALUE
)
else
if
(
m_
i
d
==
VALUE
)
color
=
ReturnLayerColor
(
LAYER_VALUEPART
);
else
color
=
ReturnLayerColor
(
LAYER_FIELDS
);
...
...
@@ -306,7 +306,7 @@ bool SCH_FIELD::Save( FILE* aFile ) const
vjustify
=
'T'
;
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
m_Orient
==
TEXT_ORIENT_HORIZ
?
'H'
:
'V'
,
m_Pos
.
x
,
m_Pos
.
y
,
...
...
@@ -320,9 +320,9 @@ bool SCH_FIELD::Save( FILE* aFile ) const
}
// 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
;
}
...
...
@@ -358,14 +358,14 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint
bool
match
;
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
;
wxLogTrace
(
traceFindReplace
,
wxT
(
" child item "
)
+
GetSelectMenuText
()
);
// Take sheet path into account which effects the reference field and the unit for
// 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
;
...
...
@@ -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
()
)
return
m_Name
;
else
return
TEMPLATE_FIELDNAME
::
GetDefaultFieldName
(
m_FieldId
);
if
(
!
m_name
.
IsEmpty
()
)
return
m_name
;
else
if
(
aUseDefaultName
)
return
TEMPLATE_FIELDNAME
::
GetDefaultFieldName
(
m_id
);
return
wxEmptyString
;
}
BITMAP_DEF
SCH_FIELD
::
GetMenuImage
()
const
{
if
(
m_
FieldI
d
==
REFERENCE
)
if
(
m_
i
d
==
REFERENCE
)
return
edit_comp_ref_xpm
;
if
(
m_
FieldI
d
==
VALUE
)
if
(
m_
i
d
==
VALUE
)
return
edit_comp_value_xpm
;
if
(
m_
FieldI
d
==
FOOTPRINT
)
if
(
m_
i
d
==
FOOTPRINT
)
return
edit_comp_footprint_xpm
;
return
edit_text_xpm
;
...
...
@@ -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
)
{
SCH_COMPONENT
*
parent
=
(
SCH_COMPONENT
*
)
GetParent
();
...
...
@@ -518,7 +511,7 @@ void SCH_FIELD::doPlot( PLOTTER* aPlotter )
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
,
thickness
,
m_Italic
,
m_Bold
);
...
...
eeschema/sch_field.h
View file @
16131a50
...
...
@@ -55,10 +55,9 @@ class LIB_FIELD;
class
SCH_FIELD
:
public
SCH_ITEM
,
public
EDA_TEXT
{
public
:
int
m_FieldId
;
///< Field index, @see enum NumFieldType
int
m_id
;
///< Field index, @see enum NumFieldType
wxString
m_
N
ame
;
wxString
m_
n
ame
;
public
:
SCH_FIELD
(
const
wxPoint
&
aPos
,
int
aFieldId
,
SCH_COMPONENT
*
aParent
,
...
...
@@ -71,17 +70,23 @@ public:
virtual
wxString
GetClass
()
const
{
return
wxT
(
"SCH_FIELD"
);
}
}
/**
* Function GetName
* returns the field name. If the field name is empty, the default field name is
* returned. Field names are VALUE, REFERENCE, etc.
* @return The name of the field.
* returns the field name.
*
* @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
;
int
GetId
()
const
{
return
m_FieldId
;
}
void
SetName
(
const
wxString
&
aName
)
{
m_name
=
aName
;
}
int
GetId
()
const
{
return
m_id
;
}
void
SetId
(
int
aId
)
{
m_id
=
aId
;
}
/**
* Function GetText
...
...
@@ -109,7 +114,7 @@ public:
/**
* 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.
*/
...
...
@@ -192,15 +197,7 @@ public:
}
/**
* Compare schematic field text against search string.
*
* @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.
* @copydoc EDA_ITEM::Matches(wxFindReplaceData&,void*,wxPoint*)
*/
virtual
bool
Matches
(
wxFindReplaceData
&
aSearchData
,
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