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
a6232e2c
Commit
a6232e2c
authored
Mar 26, 2013
by
Wayne Stambaugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix field text position access bug in Eeschema. (fixes lp:1160214)
parent
f824c838
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
26 deletions
+29
-26
dialog_edit_component_in_schematic.cpp
eeschema/dialogs/dialog_edit_component_in_schematic.cpp
+10
-9
dialog_edit_libentry_fields_in_lib.cpp
eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp
+6
-4
sch_component.cpp
eeschema/sch_component.cpp
+11
-11
sch_screen.cpp
eeschema/sch_screen.cpp
+2
-2
No files found.
eeschema/dialogs/dialog_edit_component_in_schematic.cpp
View file @
a6232e2c
...
...
@@ -233,7 +233,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event
// change all field positions from relative to absolute
for
(
unsigned
i
=
0
;
i
<
m_FieldsBuf
.
size
();
++
i
)
{
m_FieldsBuf
[
i
].
Set
Position
(
m_FieldsBuf
[
i
].
Ge
tPosition
()
+
m_Cmp
->
m_Pos
);
m_FieldsBuf
[
i
].
Set
TextPosition
(
m_FieldsBuf
[
i
].
GetTex
tPosition
()
+
m_Cmp
->
m_Pos
);
}
// Delete any fields with no name before we copy all of m_FieldsBuf back into the component.
...
...
@@ -458,7 +458,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
m_FieldsBuf
.
push_back
(
aComponent
->
m_Fields
[
i
]
);
// make the editable field position relative to the component
m_FieldsBuf
[
i
].
Set
Position
(
m_FieldsBuf
[
i
].
Ge
tPosition
()
-
m_Cmp
->
m_Pos
);
m_FieldsBuf
[
i
].
Set
TextPosition
(
m_FieldsBuf
[
i
].
GetTex
tPosition
()
-
m_Cmp
->
m_Pos
);
}
// Add template fieldnames:
...
...
@@ -491,7 +491,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
fld
=
*
schField
;
// make the editable field position relative to the component
fld
.
Set
Position
(
fld
.
Ge
tPosition
()
-
m_Cmp
->
m_Pos
);
fld
.
Set
TextPosition
(
fld
.
GetTex
tPosition
()
-
m_Cmp
->
m_Pos
);
}
m_FieldsBuf
.
push_back
(
fld
);
...
...
@@ -510,7 +510,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent
m_FieldsBuf
.
push_back
(
*
cmp
);
// make the editable field position relative to the component
m_FieldsBuf
[
newNdx
].
SetPosition
(
m_FieldsBuf
[
newNdx
].
GetPosition
()
-
m_Cmp
->
m_Pos
);
m_FieldsBuf
[
newNdx
].
SetTextPosition
(
m_FieldsBuf
[
newNdx
].
GetTextPosition
()
-
m_Cmp
->
m_Pos
);
}
}
...
...
@@ -644,7 +645,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
textSizeTextCtrl
->
SetValue
(
EDA_GRAPHIC_TEXT_CTRL
::
FormatSize
(
g_UserUnit
,
field
.
GetSize
().
x
)
);
wxPoint
coord
=
field
.
GetPosition
();
wxPoint
coord
=
field
.
Get
Text
Position
();
wxPoint
zero
=
-
m_Cmp
->
m_Pos
;
// relative zero
// If the field value is empty and the position is at relative zero, we
...
...
@@ -655,10 +656,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
{
rotateCheckBox
->
SetValue
(
m_FieldsBuf
[
REFERENCE
].
GetOrientation
()
==
TEXT_ORIENT_VERT
);
coord
.
x
=
m_FieldsBuf
[
REFERENCE
].
GetPosition
().
x
coord
.
x
=
m_FieldsBuf
[
REFERENCE
].
Get
Text
Position
().
x
+
(
fieldNdx
-
MANDATORY_FIELDS
+
1
)
*
100
;
coord
.
y
=
m_FieldsBuf
[
REFERENCE
].
GetPosition
().
y
coord
.
y
=
m_FieldsBuf
[
REFERENCE
].
Get
Text
Position
().
y
+
(
fieldNdx
-
MANDATORY_FIELDS
+
1
)
*
100
;
// coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
...
...
@@ -844,11 +845,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
// Perhaps the FOOTPRINT field should also be considered,
// but for most of components it is not set in library
LIB_FIELD
&
refField
=
entry
->
GetReferenceField
();
m_Cmp
->
GetField
(
REFERENCE
)
->
Set
Position
(
refField
.
Ge
tPosition
()
+
m_Cmp
->
m_Pos
);
m_Cmp
->
GetField
(
REFERENCE
)
->
Set
TextPosition
(
refField
.
GetTex
tPosition
()
+
m_Cmp
->
m_Pos
);
m_Cmp
->
GetField
(
REFERENCE
)
->
ImportValues
(
refField
);
LIB_FIELD
&
valField
=
entry
->
GetValueField
();
m_Cmp
->
GetField
(
VALUE
)
->
Set
Position
(
valField
.
Ge
tPosition
()
+
m_Cmp
->
m_Pos
);
m_Cmp
->
GetField
(
VALUE
)
->
Set
TextPosition
(
valField
.
GetTex
tPosition
()
+
m_Cmp
->
m_Pos
);
m_Cmp
->
GetField
(
VALUE
)
->
ImportValues
(
valField
);
m_Cmp
->
SetOrientation
(
CMP_NORMAL
);
...
...
eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp
View file @
a6232e2c
...
...
@@ -661,7 +661,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
textSizeTextCtrl
->
SetValue
(
EDA_GRAPHIC_TEXT_CTRL
::
FormatSize
(
g_UserUnit
,
field
.
GetSize
().
x
)
);
wxPoint
coord
=
field
.
GetPosition
();
wxPoint
coord
=
field
.
Get
Text
Position
();
wxPoint
zero
;
// If the field value is empty and the position is at relative zero, we set the
...
...
@@ -672,8 +672,10 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
{
rotateCheckBox
->
SetValue
(
m_FieldsBuf
[
REFERENCE
].
GetOrientation
()
==
TEXT_ORIENT_VERT
);
coord
.
x
=
m_FieldsBuf
[
REFERENCE
].
GetPosition
().
x
+
(
fieldNdx
-
MANDATORY_FIELDS
+
1
)
*
100
;
coord
.
y
=
m_FieldsBuf
[
REFERENCE
].
GetPosition
().
y
+
(
fieldNdx
-
MANDATORY_FIELDS
+
1
)
*
100
;
coord
.
x
=
m_FieldsBuf
[
REFERENCE
].
GetTextPosition
().
x
+
(
fieldNdx
-
MANDATORY_FIELDS
+
1
)
*
100
;
coord
.
y
=
m_FieldsBuf
[
REFERENCE
].
GetTextPosition
().
y
+
(
fieldNdx
-
MANDATORY_FIELDS
+
1
)
*
100
;
// coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
// That is ok, we basically don't want all the new empty fields on
...
...
@@ -761,7 +763,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
// and the screen axis is top to bottom: we must change the y coord sign for editing
NEGATE
(
pos
.
y
);
field
.
SetPosition
(
pos
);
field
.
Set
Text
Position
(
pos
);
return
true
;
}
eeschema/sch_component.cpp
View file @
a6232e2c
...
...
@@ -157,7 +157,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_COMPONENT& libComponent, SCH_SHEET_PATH* sheet
schField
=
AddField
(
fld
);
}
schField
->
Set
Position
(
m_Pos
+
it
->
Ge
tPosition
()
);
schField
->
Set
TextPosition
(
m_Pos
+
it
->
GetTex
tPosition
()
);
schField
->
ImportValues
(
*
it
);
...
...
@@ -490,11 +490,11 @@ void SCH_COMPONENT::SetRef( const SCH_SHEET_PATH* sheet, const wxString& ref )
SCH_FIELD
*
rf
=
GetField
(
REFERENCE
);
if
(
rf
->
GetText
().
IsEmpty
()
||
(
abs
(
rf
->
GetPosition
().
x
-
m_Pos
.
x
)
+
abs
(
rf
->
GetPosition
().
y
-
m_Pos
.
y
)
>
10000
)
)
||
(
abs
(
rf
->
Get
Text
Position
().
x
-
m_Pos
.
x
)
+
abs
(
rf
->
Get
Text
Position
().
y
-
m_Pos
.
y
)
>
10000
)
)
{
// move it to a reasonable position
rf
->
SetPosition
(
m_Pos
+
wxPoint
(
50
,
50
)
);
rf
->
Set
Text
Position
(
m_Pos
+
wxPoint
(
50
,
50
)
);
}
rf
->
SetText
(
ref
);
// for drawing.
...
...
@@ -1206,7 +1206,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
for
(
int
i
=
0
;
i
<
GetFieldCount
();
i
++
)
{
if
(
GetField
(
i
)
->
GetText
().
IsEmpty
()
)
GetField
(
i
)
->
SetPosition
(
m_Pos
);
GetField
(
i
)
->
Set
Text
Position
(
m_Pos
);
}
}
else
if
(
line
[
0
]
==
'A'
&&
line
[
1
]
==
'R'
)
...
...
@@ -1511,9 +1511,9 @@ void SCH_COMPONENT::MirrorY( int aYaxis_position )
for
(
int
ii
=
0
;
ii
<
GetFieldCount
();
ii
++
)
{
// Move the fields to the new position because the component itself has moved.
wxPoint
pos
=
GetField
(
ii
)
->
GetPosition
();
wxPoint
pos
=
GetField
(
ii
)
->
Get
Text
Position
();
pos
.
x
-=
dx
;
GetField
(
ii
)
->
SetPosition
(
pos
);
GetField
(
ii
)
->
Set
Text
Position
(
pos
);
}
}
...
...
@@ -1531,9 +1531,9 @@ void SCH_COMPONENT::MirrorX( int aXaxis_position )
for
(
int
ii
=
0
;
ii
<
GetFieldCount
();
ii
++
)
{
// Move the fields to the new position because the component itself has moved.
wxPoint
pos
=
GetField
(
ii
)
->
GetPosition
();
wxPoint
pos
=
GetField
(
ii
)
->
Get
Text
Position
();
pos
.
y
-=
dy
;
GetField
(
ii
)
->
SetPosition
(
pos
);
GetField
(
ii
)
->
Set
Text
Position
(
pos
);
}
}
...
...
@@ -1550,10 +1550,10 @@ void SCH_COMPONENT::Rotate( wxPoint aPosition )
for
(
int
ii
=
0
;
ii
<
GetFieldCount
();
ii
++
)
{
// Move the fields to the new position because the component itself has moved.
wxPoint
pos
=
GetField
(
ii
)
->
GetPosition
();
wxPoint
pos
=
GetField
(
ii
)
->
Get
Text
Position
();
pos
.
x
-=
prev
.
x
-
m_Pos
.
x
;
pos
.
y
-=
prev
.
y
-
m_Pos
.
y
;
GetField
(
ii
)
->
SetPosition
(
pos
);
GetField
(
ii
)
->
Set
Text
Position
(
pos
);
}
}
...
...
eeschema/sch_screen.cpp
View file @
a6232e2c
...
...
@@ -1084,10 +1084,10 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri
*/
SCH_FIELD
*
fpfield
=
component
->
GetField
(
FOOTPRINT
);
if
(
fpfield
->
GetText
().
IsEmpty
()
&&
(
fpfield
->
GetPosition
()
==
component
->
GetPosition
()
)
)
&&
(
fpfield
->
Get
Text
Position
()
==
component
->
GetPosition
()
)
)
{
fpfield
->
SetOrientation
(
component
->
GetField
(
VALUE
)
->
GetOrientation
()
);
fpfield
->
Set
Position
(
component
->
GetField
(
VALUE
)
->
Ge
tPosition
()
);
fpfield
->
Set
TextPosition
(
component
->
GetField
(
VALUE
)
->
GetTex
tPosition
()
);
fpfield
->
SetSize
(
component
->
GetField
(
VALUE
)
->
GetSize
()
);
if
(
fpfield
->
GetOrientation
()
==
0
)
...
...
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