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
8931b1fc
Commit
8931b1fc
authored
Mar 16, 2010
by
charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed issues 2970757 and 2970825
parent
458f7626
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
33 deletions
+75
-33
class_BodyItem_Text.cpp
eeschema/class_BodyItem_Text.cpp
+54
-8
class_sch_cmp_field.cpp
eeschema/class_sch_cmp_field.cpp
+20
-25
class_text-label.cpp
eeschema/class_text-label.cpp
+1
-0
No files found.
eeschema/class_BodyItem_Text.cpp
View file @
8931b1fc
...
@@ -305,15 +305,54 @@ void LIB_TEXT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
...
@@ -305,15 +305,54 @@ void LIB_TEXT::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
GRSetDrawMode
(
aDC
,
aDrawMode
);
GRSetDrawMode
(
aDC
,
aDrawMode
);
/* Calculate the text orientation, according to the component
* orientation/mirror (needed when draw text in schematic)
*/
int
orient
=
m_Orient
;
if
(
aTransformMatrix
[
0
][
1
]
)
// Rotate component 90 degrees.
{
if
(
orient
==
TEXT_ORIENT_HORIZ
)
orient
=
TEXT_ORIENT_VERT
;
else
orient
=
TEXT_ORIENT_HORIZ
;
}
/* Calculate the text justification, according to the component
* orientation/mirror this is a bit complicated due to cumulative
* calculations:
* - numerous cases (mirrored or not, rotation)
* - the DrawGraphicText function recalculate also H and H justifications
* according to the text orientation.
* - When a component is mirrored, the text is not mirrored and
* justifications are complicated to calculate
* so the more easily way is to use no justifications ( Centered text )
* and use GetBoundaryBox to know the text coordinate considered as centered
*/
EDA_Rect
bBox
=
GetBoundingBox
();
pos1
=
bBox
.
Centre
();
// this is the coordinates of the graphic text relative to the component position
// in schematic Y axis orientation
/* convert y coordinate from schematic to library Y axis orientation
* because we want to call TransformCoordinate to calculate real coordinates
*/
NEGATE
(
pos1
.
y
);
pos1
=
TransformCoordinate
(
aTransformMatrix
,
pos1
)
+
aOffset
;
DrawGraphicText
(
aPanel
,
aDC
,
pos1
,
(
EDA_Colors
)
color
,
m_Text
,
DrawGraphicText
(
aPanel
,
aDC
,
pos1
,
(
EDA_Colors
)
color
,
m_Text
,
m_Orient
,
m_Size
,
m_HJustify
,
m_VJustify
,
orient
,
m_Size
,
GR_TEXT_HJUSTIFY_CENTER
,
GR_TEXT_VJUSTIFY_CENTER
,
GetPenSize
(
),
m_Italic
,
m_Bold
);
GetPenSize
(
),
m_Italic
,
m_Bold
);
/* Enable this to draw the bounding box around the text field to validate
* the bounding box calculations.
*/
#if 0
#if 0
EDA_Rect bBox = GetBoundingBox();
EDA_Rect grBox;
bBox.Inflate( 1, 1 );
bBox.SetY( -bBox.GetY() );
GRRect( &aPanel->m_ClipBox, aDC, bBox.GetOrigin().x, bBox.GetOrigin().y,
bBox.SetHeight( -bBox.GetHeight());
bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
grBox.SetOrigin( TransformCoordinate( aTransformMatrix, bBox.GetOrigin() ) );
grBox.SetEnd( TransformCoordinate( aTransformMatrix, bBox.GetEnd() ) );
grBox.Move( aOffset );
GRRect( &aPanel->m_ClipBox, aDC, grBox.GetOrigin().x, grBox.GetOrigin().y,
grBox.GetEnd().x, grBox.GetEnd().y, 0, LIGHTMAGENTA );
#endif
#endif
}
}
...
@@ -331,11 +370,18 @@ void LIB_TEXT::DisplayInfo( WinEDA_DrawFrame* frame )
...
@@ -331,11 +370,18 @@ void LIB_TEXT::DisplayInfo( WinEDA_DrawFrame* frame )
}
}
/**
* @return the boundary box for this, in schematic coordinates
*/
EDA_Rect
LIB_TEXT
::
GetBoundingBox
()
EDA_Rect
LIB_TEXT
::
GetBoundingBox
()
{
{
/* remenber Y coordinates in lib are bottom to top, so we must
* negate the Y position befire calling GetTextBox() that works using top to bottom
* Y axis orientation
*/
NEGATE
(
m_Pos
.
y
);
EDA_Rect
rect
=
GetTextBox
();
EDA_Rect
rect
=
GetTextBox
();
rect
.
m_Pos
.
y
*=
-
1
;
NEGATE
(
m_Pos
.
y
);
// restore Y cooordinate for the graphic text
rect
.
m_Pos
.
y
-=
rect
.
GetHeight
();
wxPoint
orig
=
rect
.
GetOrigin
();
wxPoint
orig
=
rect
.
GetOrigin
();
wxPoint
end
=
rect
.
GetEnd
();
wxPoint
end
=
rect
.
GetEnd
();
...
@@ -345,6 +391,6 @@ EDA_Rect LIB_TEXT::GetBoundingBox()
...
@@ -345,6 +391,6 @@ EDA_Rect LIB_TEXT::GetBoundingBox()
RotatePoint
(
&
end
,
center
,
m_Orient
);
RotatePoint
(
&
end
,
center
,
m_Orient
);
rect
.
SetOrigin
(
orig
);
rect
.
SetOrigin
(
orig
);
rect
.
SetEnd
(
end
);
rect
.
SetEnd
(
end
);
rect
.
Normalize
();
return
rect
;
return
rect
;
}
}
eeschema/class_sch_cmp_field.cpp
View file @
8931b1fc
...
@@ -155,10 +155,10 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
...
@@ -155,10 +155,10 @@ void SCH_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
LineWidth
,
m_Italic
,
LineWidth
,
m_Italic
,
m_Bold
,
false
);
m_Bold
,
false
);
}
}
/* Enable this to draw the bounding box around the text field to validate
/* Enable this to draw the bounding box around the text field to validate
* the bounding box calculations.
* the bounding box calculations.
*/
*/
#if 0
#if 0
// Draw boundary box:
// Draw boundary box:
int x1 = BoundaryBox.GetX();
int x1 = BoundaryBox.GetX();
...
@@ -243,27 +243,24 @@ bool SCH_FIELD::IsVoid()
...
@@ -243,27 +243,24 @@ bool SCH_FIELD::IsVoid()
*/
*/
EDA_Rect
SCH_FIELD
::
GetBoundaryBox
()
const
EDA_Rect
SCH_FIELD
::
GetBoundaryBox
()
const
{
{
EDA_Rect
BoundaryBox
;
EDA_Rect
BoundaryBox
;
int
hjustify
,
vjustify
;
int
hjustify
,
vjustify
;
int
orient
;
int
orient
;
int
dx
,
dy
,
x1
,
y1
,
x2
,
y2
;
wxSize
size
;
wxPoint
pos1
,
pos2
;
SCH_COMPONENT
*
parentComponent
=
(
SCH_COMPONENT
*
)
m_Parent
;
SCH_COMPONENT
*
parentComponent
=
(
SCH_COMPONENT
*
)
m_Parent
;
orient
=
m_Orient
;
orient
=
m_Orient
;
wxPoint
pos
=
parentComponent
->
m_Pos
;
wxPoint
pos
=
parentComponent
->
m_Pos
;
x1
=
m_Pos
.
x
-
pos
.
x
;
pos1
=
m_Pos
-
pos
;
y1
=
m_Pos
.
y
-
pos
.
y
;
d
x
=
LenSize
(
m_Text
);
size
.
x
=
LenSize
(
m_Text
);
d
y
=
m_Size
.
y
;
size
.
y
=
m_Size
.
y
;
hjustify
=
m_HJustify
;
hjustify
=
m_HJustify
;
vjustify
=
m_VJustify
;
vjustify
=
m_VJustify
;
x2
=
pos
.
x
+
(
parentComponent
->
m_Transform
[
0
][
0
]
*
x1
)
pos2
=
pos
+
TransformCoordinate
(
parentComponent
->
m_Transform
,
pos1
);
+
(
parentComponent
->
m_Transform
[
0
][
1
]
*
y1
);
y2
=
pos
.
y
+
(
parentComponent
->
m_Transform
[
1
][
0
]
*
x1
)
+
(
parentComponent
->
m_Transform
[
1
][
1
]
*
y1
);
/* Calculate the text orientation, according to the component
/* Calculate the text orientation, according to the component
* orientation/mirror */
* orientation/mirror */
...
@@ -295,42 +292,40 @@ EDA_Rect SCH_FIELD::GetBoundaryBox() const
...
@@ -295,42 +292,40 @@ EDA_Rect SCH_FIELD::GetBoundaryBox() const
}
}
if
(
orient
==
TEXT_ORIENT_VERT
)
if
(
orient
==
TEXT_ORIENT_VERT
)
EXCHG
(
dx
,
d
y
);
EXCHG
(
size
.
x
,
size
.
y
);
switch
(
hjustify
)
switch
(
hjustify
)
{
{
case
GR_TEXT_HJUSTIFY_CENTER
:
case
GR_TEXT_HJUSTIFY_CENTER
:
x1
=
x2
-
(
d
x
/
2
);
pos1
.
x
=
pos2
.
x
-
(
size
.
x
/
2
);
break
;
break
;
case
GR_TEXT_HJUSTIFY_RIGHT
:
case
GR_TEXT_HJUSTIFY_RIGHT
:
x1
=
x2
-
d
x
;
pos1
.
x
=
pos2
.
x
-
size
.
x
;
break
;
break
;
default
:
default
:
x1
=
x2
;
pos1
.
x
=
pos2
.
x
;
break
;
break
;
}
}
switch
(
vjustify
)
switch
(
vjustify
)
{
{
case
GR_TEXT_VJUSTIFY_CENTER
:
case
GR_TEXT_VJUSTIFY_CENTER
:
y1
=
y2
-
(
d
y
/
2
);
pos1
.
y
=
pos2
.
y
-
(
size
.
y
/
2
);
break
;
break
;
case
GR_TEXT_VJUSTIFY_BOTTOM
:
case
GR_TEXT_VJUSTIFY_BOTTOM
:
y1
=
y2
-
d
y
;
pos1
.
y
=
pos2
.
y
-
size
.
y
;
break
;
break
;
default
:
default
:
y1
=
y2
;
pos1
.
y
=
pos2
.
y
;
break
;
break
;
}
}
BoundaryBox
.
SetX
(
x1
);
BoundaryBox
.
SetOrigin
(
pos1
);
BoundaryBox
.
SetY
(
y1
);
BoundaryBox
.
SetSize
(
size
);
BoundaryBox
.
SetWidth
(
dx
);
BoundaryBox
.
SetHeight
(
dy
);
// Take thickness in account:
// Take thickness in account:
int
linewidth
=
(
m_Width
==
0
)
?
g_DrawDefaultLineThickness
:
m_Width
;
int
linewidth
=
(
m_Width
==
0
)
?
g_DrawDefaultLineThickness
:
m_Width
;
...
...
eeschema/class_text-label.cpp
View file @
8931b1fc
...
@@ -1219,5 +1219,6 @@ EDA_Rect SCH_TEXT::GetBoundingBox()
...
@@ -1219,5 +1219,6 @@ EDA_Rect SCH_TEXT::GetBoundingBox()
rect
.
SetEnd
(
end
);
rect
.
SetEnd
(
end
);
}
}
rect
.
Normalize
();
return
rect
;
return
rect
;
}
}
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