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
48f9ea22
Commit
48f9ea22
authored
Nov 29, 2013
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eeschema, Pcbnew: fix Bug #1255822 (incorrect position of multiline texts when plotting them)
parent
a105a1ea
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
53 deletions
+72
-53
eda_text.cpp
common/eda_text.cpp
+49
-36
sch_text.cpp
eeschema/sch_text.cpp
+6
-9
eda_text.h
include/eda_text.h
+11
-0
plot_brditems_plotter.cpp
pcbnew/plot_brditems_plotter.cpp
+6
-8
No files found.
common/eda_text.cpp
View file @
48f9ea22
...
@@ -265,8 +265,38 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
...
@@ -265,8 +265,38 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
{
{
if
(
m_MultilineAllowed
)
if
(
m_MultilineAllowed
)
{
{
std
::
vector
<
wxPoint
>
positions
;
wxArrayString
*
list
=
wxStringSplit
(
m_Text
,
'\n'
);
wxArrayString
*
list
=
wxStringSplit
(
m_Text
,
'\n'
);
positions
.
reserve
(
list
->
Count
()
);
GetPositionsOfLinesOfMultilineText
(
positions
,
list
->
Count
()
);
for
(
unsigned
ii
=
0
;
ii
<
list
->
Count
();
ii
++
)
{
wxString
&
txt
=
list
->
Item
(
ii
);
drawOneLineOfText
(
aClipBox
,
aDC
,
aOffset
,
aColor
,
aDrawMode
,
aFillMode
,
txt
,
positions
[
ii
]
);
}
delete
(
list
);
}
else
drawOneLineOfText
(
aClipBox
,
aDC
,
aOffset
,
aColor
,
aDrawMode
,
aFillMode
,
m_Text
,
m_Pos
);
// Draw text anchor, if requested
if
(
aAnchor_color
!=
UNSPECIFIED_COLOR
)
{
GRDrawAnchor
(
aClipBox
,
aDC
,
m_Pos
.
x
+
aOffset
.
x
,
m_Pos
.
y
+
aOffset
.
y
,
DIM_ANCRE_TEXTE
,
aAnchor_color
);
}
}
void
EDA_TEXT
::
GetPositionsOfLinesOfMultilineText
(
std
::
vector
<
wxPoint
>&
aPositions
,
int
aLineCount
)
{
wxPoint
pos
=
m_Pos
;
// Position of first line of the
wxPoint
pos
=
m_Pos
;
// Position of first line of the
// multiline text according to
// multiline text according to
// the center of the multiline text block
// the center of the multiline text block
...
@@ -276,7 +306,7 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
...
@@ -276,7 +306,7 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
offset
.
y
=
GetInterline
();
offset
.
y
=
GetInterline
();
#ifdef FIX_MULTILINE_VERT_JUSTIF
#ifdef FIX_MULTILINE_VERT_JUSTIF
if
(
list
->
Count
()
>
1
)
if
(
aLineCount
>
1
)
{
{
switch
(
m_VJustify
)
switch
(
m_VJustify
)
{
{
...
@@ -284,11 +314,11 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
...
@@ -284,11 +314,11 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
break
;
break
;
case
GR_TEXT_VJUSTIFY_CENTER
:
case
GR_TEXT_VJUSTIFY_CENTER
:
pos
.
y
-=
(
list
->
Count
()
-
1
)
*
offset
.
y
/
2
;
pos
.
y
-=
(
aLineCount
-
1
)
*
offset
.
y
/
2
;
break
;
break
;
case
GR_TEXT_VJUSTIFY_BOTTOM
:
case
GR_TEXT_VJUSTIFY_BOTTOM
:
pos
.
y
-=
(
list
->
Count
()
-
1
)
*
offset
.
y
;
pos
.
y
-=
(
aLineCount
-
1
)
*
offset
.
y
;
break
;
break
;
}
}
}
}
...
@@ -300,30 +330,13 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
...
@@ -300,30 +330,13 @@ void EDA_TEXT::Draw( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aOffset,
// Rotate the offset lines to increase happened in the right direction
// Rotate the offset lines to increase happened in the right direction
RotatePoint
(
&
offset
,
m_Orient
);
RotatePoint
(
&
offset
,
m_Orient
);
for
(
unsigned
i
=
0
;
i
<
list
->
Count
();
i
++
)
for
(
int
ii
=
0
;
ii
<
aLineCount
;
i
i
++
)
{
{
wxString
txt
=
list
->
Item
(
i
);
aPositions
.
push_back
(
pos
);
drawOneLineOfText
(
aClipBox
,
aDC
,
aOffset
,
aColor
,
aDrawMode
,
aFillMode
,
txt
,
pos
);
pos
+=
offset
;
pos
+=
offset
;
}
}
delete
(
list
);
}
else
drawOneLineOfText
(
aClipBox
,
aDC
,
aOffset
,
aColor
,
aDrawMode
,
aFillMode
,
m_Text
,
m_Pos
);
// Draw text anchor, if requested
if
(
aAnchor_color
!=
UNSPECIFIED_COLOR
)
{
GRDrawAnchor
(
aClipBox
,
aDC
,
m_Pos
.
x
+
aOffset
.
x
,
m_Pos
.
y
+
aOffset
.
y
,
DIM_ANCRE_TEXTE
,
aAnchor_color
);
}
}
}
void
EDA_TEXT
::
drawOneLineOfText
(
EDA_RECT
*
aClipBox
,
wxDC
*
aDC
,
void
EDA_TEXT
::
drawOneLineOfText
(
EDA_RECT
*
aClipBox
,
wxDC
*
aDC
,
const
wxPoint
&
aOffset
,
EDA_COLOR_T
aColor
,
const
wxPoint
&
aOffset
,
EDA_COLOR_T
aColor
,
GR_DRAWMODE
aDrawMode
,
EDA_DRAW_MODE_T
aFillMode
,
GR_DRAWMODE
aDrawMode
,
EDA_DRAW_MODE_T
aFillMode
,
...
...
eeschema/sch_text.cpp
View file @
48f9ea22
...
@@ -673,20 +673,17 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter )
...
@@ -673,20 +673,17 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter )
if
(
m_MultilineAllowed
)
if
(
m_MultilineAllowed
)
{
{
wxPoint
pos
=
textpo
s
;
std
::
vector
<
wxPoint
>
position
s
;
wxArrayString
*
list
=
wxStringSplit
(
m_Text
,
'\n'
);
wxArrayString
*
list
=
wxStringSplit
(
m_Text
,
'\n'
);
wxPoint
offset
;
positions
.
reserve
(
list
->
Count
()
)
;
offset
.
y
=
GetInterline
(
);
GetPositionsOfLinesOfMultilineText
(
positions
,
list
->
Count
()
);
RotatePoint
(
&
offset
,
m_Orient
);
for
(
unsigned
ii
=
0
;
ii
<
list
->
Count
();
ii
++
)
for
(
unsigned
i
=
0
;
i
<
list
->
Count
();
i
++
)
{
{
wxString
txt
=
list
->
Item
(
i
);
wxString
&
txt
=
list
->
Item
(
i
i
);
aPlotter
->
Text
(
pos
,
color
,
txt
,
m_Orient
,
m_Size
,
m_HJustify
,
aPlotter
->
Text
(
pos
itions
[
ii
]
,
color
,
txt
,
m_Orient
,
m_Size
,
m_HJustify
,
m_VJustify
,
thickness
,
m_Italic
,
m_Bold
);
m_VJustify
,
thickness
,
m_Italic
,
m_Bold
);
pos
+=
offset
;
}
}
delete
(
list
);
delete
(
list
);
...
...
include/eda_text.h
View file @
48f9ea22
...
@@ -265,6 +265,17 @@ public:
...
@@ -265,6 +265,17 @@ public:
void
SetHorizJustify
(
EDA_TEXT_HJUSTIFY_T
aType
)
{
m_HJustify
=
aType
;
};
void
SetHorizJustify
(
EDA_TEXT_HJUSTIFY_T
aType
)
{
m_HJustify
=
aType
;
};
void
SetVertJustify
(
EDA_TEXT_VJUSTIFY_T
aType
)
{
m_VJustify
=
aType
;
};
void
SetVertJustify
(
EDA_TEXT_VJUSTIFY_T
aType
)
{
m_VJustify
=
aType
;
};
/**
* Function GetPositionsOfLinesOfMultilineText
* Populates aPositions with the position of each line of
* a multiline text, according to the vertical justification and the
* rotation of the whole text
* @param aPositions is the list to populate by the wxPoint positions
* @param aLineCount is the number of lines (not recalculated here
* for efficiency reasons
*/
void
GetPositionsOfLinesOfMultilineText
(
std
::
vector
<
wxPoint
>&
aPositions
,
int
aLineCount
);
/**
/**
* Function Format
* Function Format
* outputs the object to \a aFormatter in s-expression form.
* outputs the object to \a aFormatter in s-expression form.
...
...
pcbnew/plot_brditems_plotter.cpp
View file @
48f9ea22
...
@@ -477,20 +477,18 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
...
@@ -477,20 +477,18 @@ void BRDITEMS_PLOTTER::PlotTextePcb( TEXTE_PCB* pt_texte )
if
(
pt_texte
->
IsMultilineAllowed
()
)
if
(
pt_texte
->
IsMultilineAllowed
()
)
{
{
std
::
vector
<
wxPoint
>
positions
;
wxArrayString
*
list
=
wxStringSplit
(
pt_texte
->
GetText
(),
'\n'
);
wxArrayString
*
list
=
wxStringSplit
(
pt_texte
->
GetText
(),
'\n'
);
wxPoint
offset
;
positions
.
reserve
(
list
->
Count
()
)
;
offset
.
y
=
pt_texte
->
GetInterline
(
);
pt_texte
->
GetPositionsOfLinesOfMultilineText
(
positions
,
list
->
Count
()
);
RotatePoint
(
&
offset
,
orient
);
for
(
unsigned
ii
=
0
;
ii
<
list
->
Count
();
ii
++
)
for
(
unsigned
i
=
0
;
i
<
list
->
Count
();
i
++
)
{
{
wxString
txt
=
list
->
Item
(
i
);
wxString
&
txt
=
list
->
Item
(
i
i
);
m_plotter
->
Text
(
pos
,
UNSPECIFIED_COLOR
,
txt
,
orient
,
size
,
m_plotter
->
Text
(
pos
itions
[
ii
]
,
UNSPECIFIED_COLOR
,
txt
,
orient
,
size
,
pt_texte
->
GetHorizJustify
(),
pt_texte
->
GetVertJustify
(),
pt_texte
->
GetHorizJustify
(),
pt_texte
->
GetVertJustify
(),
thickness
,
pt_texte
->
IsItalic
(),
allow_bold
);
thickness
,
pt_texte
->
IsItalic
(),
allow_bold
);
pos
+=
offset
;
}
}
delete
list
;
delete
list
;
...
...
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