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
45cd2756
Commit
45cd2756
authored
Dec 05, 2013
by
Orson
Committed by
Dick Hollenbeck
Dec 05, 2013
Browse files
Options
Browse Files
Download
Plain Diff
merge lp:~cern-kicad/kicad/bugfix_1256302 from Orson
parents
7985a4b1
a2f6faf1
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
186 additions
and
129 deletions
+186
-129
stroke_font.cpp
common/gal/stroke_font.cpp
+129
-99
worksheet_viewitem.cpp
common/worksheet_viewitem.cpp
+1
-1
graphics_abstraction_layer.h
include/gal/graphics_abstraction_layer.h
+1
-1
stroke_font.h
include/gal/stroke_font.h
+49
-21
pcb_painter.cpp
pcbnew/pcb_painter.cpp
+6
-7
No files found.
common/gal/stroke_font.cpp
View file @
45cd2756
This diff is collapsed.
Click to expand it.
common/worksheet_viewitem.cpp
View file @
45cd2756
...
...
@@ -191,7 +191,7 @@ void WORKSHEET_VIEWITEM::draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const
aGal
->
SetStrokeColor
(
COLOR4D
(
aItem
->
GetColor
()
)
);
aGal
->
SetLineWidth
(
aItem
->
GetThickness
()
);
aGal
->
SetTextAttributes
(
aItem
);
aGal
->
StrokeText
(
std
::
string
(
aItem
->
GetText
().
mb
_str
()
),
position
,
0.0
);
aGal
->
StrokeText
(
std
::
wstring
(
aItem
->
GetText
().
wc
_str
()
),
position
,
0.0
);
}
...
...
include/gal/graphics_abstraction_layer.h
View file @
45cd2756
...
...
@@ -277,7 +277,7 @@ public:
* @param aPosition is the text position in world coordinates.
* @param aRotationAngle is the text rotation angle.
*/
inline
virtual
void
StrokeText
(
const
std
::
s
tring
&
aText
,
const
VECTOR2D
&
aPosition
,
inline
virtual
void
StrokeText
(
const
wxS
tring
&
aText
,
const
VECTOR2D
&
aPosition
,
double
aRotationAngle
)
{
strokeFont
.
Draw
(
aText
,
aPosition
,
aRotationAngle
);
...
...
include/gal/stroke_font.h
View file @
45cd2756
...
...
@@ -3,6 +3,8 @@
*
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
* Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors.
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* Stroke font class
*
...
...
@@ -39,7 +41,7 @@ namespace KIGFX
class
GAL
;
typedef
std
::
deque
<
std
::
deque
<
VECTOR2D
>
>
GLYPH
;
typedef
std
::
deque
<
GLYPH
>
GLYPH_LIST
;
typedef
std
::
vector
<
GLYPH
>
GLYPH_LIST
;
/**
* @brief Class STROKE_FONT implements stroke font drawing.
...
...
@@ -52,11 +54,6 @@ public:
/// Constructor
STROKE_FONT
(
GAL
*
aGal
);
/// Destructor
~
STROKE_FONT
();
// TODO Load font from a text file
/**
* @brief Load the new stroke font.
*
...
...
@@ -73,17 +70,7 @@ public:
* @param aPosition is the text position in world coordinates.
* @param aRotationAngle is the text rotation angle.
*/
void
Draw
(
std
::
string
aText
,
const
VECTOR2D
&
aPosition
,
double
aRotationAngle
);
/**
* @brief Set the scale factor of the font for the glyph size.
*
* @param aScaleFactor is the scale factor of the font.
*/
inline
void
SetScaleFactor
(
const
double
aScaleFactor
)
{
m_scaleFactor
=
aScaleFactor
;
}
void
Draw
(
const
wxString
&
aText
,
const
VECTOR2D
&
aPosition
,
double
aRotationAngle
);
/**
* @brief Set the glyph size.
...
...
@@ -158,13 +145,19 @@ public:
private
:
GAL
*
m_gal
;
///< Pointer to the GAL
GLYPH_LIST
m_glyphs
;
///< Glyph list
std
::
deque
<
BOX2D
>
m_glyphBoundingBoxes
;
///< Bounding boxes of the glyphs
double
m_scaleFactor
;
///< Scale factor for the glyph
std
::
vector
<
BOX2D
>
m_glyphBoundingBoxes
;
///< Bounding boxes of the glyphs
VECTOR2D
m_glyphSize
;
///< Size of the glyphs
EDA_TEXT_HJUSTIFY_T
m_horizontalJustify
;
///< Horizontal justification
EDA_TEXT_VJUSTIFY_T
m_verticalJustify
;
///< Vertical justification
bool
m_bold
,
m_italic
,
m_mirrored
,
m_overbar
;
///< Properties of text
/**
* @brief Returns a single line height using current settings.
*
* @return The line height.
*/
int
getInterline
()
const
;
/**
* @brief Compute the bounding box of a given glyph.
*
...
...
@@ -174,15 +167,50 @@ private:
*/
BOX2D
computeBoundingBox
(
const
GLYPH
&
aGlyph
,
const
VECTOR2D
&
aGlyphBoundingX
)
const
;
/**
* @brief Draws a single line of text. Multiline texts should be split before using the
* function.
*
* @param aText is the text to be drawn.
*/
void
drawSingleLineText
(
const
wxString
&
aText
);
/**
* @brief Compute the size of a given text.
*
* @param aText is the text string.
* @return is the text size.
*/
VECTOR2D
computeTextSize
(
const
std
::
string
&
aText
)
const
;
VECTOR2D
computeTextSize
(
const
wxString
&
aText
)
const
;
/**
* @brief Returns number of lines for a given text.
*
* @param aText is the text to be checked.
* @return Number of lines of aText.
*/
unsigned
int
linesCount
(
const
wxString
&
aText
)
const
{
wxString
::
const_iterator
it
,
itEnd
;
unsigned
int
lines
=
1
;
for
(
it
=
aText
.
begin
(),
itEnd
=
aText
.
end
();
it
!=
itEnd
;
++
it
)
{
if
(
*
it
==
'\n'
)
++
lines
;
}
return
lines
;
}
///> Factor that determines relative height of overbar.
static
const
double
OVERBAR_HEIGHT
;
///> Factor that determines relative line width for bold text.
static
const
double
BOLD_FACTOR
;
static
const
double
LINE_HEIGHT_RATIO
;
///> Scale factor for the glyph
static
const
double
HERSHEY_SCALE
;
};
}
// namespace KIGFX
...
...
pcbnew/pcb_painter.cpp
View file @
45cd2756
...
...
@@ -280,7 +280,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
if
(
!
net
)
return
;
std
::
string
netName
=
std
::
string
(
net
->
GetShortNetname
().
mb
_str
()
);
std
::
wstring
netName
=
std
::
wstring
(
net
->
GetShortNetname
().
wc
_str
()
);
VECTOR2D
textPosition
=
start
+
line
/
2.0
;
// center of the track
double
textOrientation
=
-
atan
(
line
.
y
/
line
.
x
);
double
textSize
=
std
::
min
(
static_cast
<
double
>
(
width
),
length
/
netName
.
length
()
);
...
...
@@ -456,7 +456,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
VECTOR2D
namesize
(
tsize
,
tsize
);
m_gal
->
SetGlyphSize
(
namesize
);
m_gal
->
SetLineWidth
(
namesize
.
x
/
12.0
);
m_gal
->
StrokeText
(
std
::
string
(
aPad
->
GetShortNetname
().
mb
_str
()
),
m_gal
->
StrokeText
(
std
::
wstring
(
aPad
->
GetShortNetname
().
wc
_str
()
),
textpos
,
0.0
);
}
...
...
@@ -474,8 +474,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m_gal
->
SetGlyphSize
(
numsize
);
m_gal
->
SetLineWidth
(
numsize
.
x
/
12.0
);
m_gal
->
StrokeText
(
std
::
string
(
aPad
->
GetPadName
().
mb_str
()
),
textpos
,
0.0
);
m_gal
->
StrokeText
(
std
::
wstring
(
aPad
->
GetPadName
().
wc_str
()
),
textpos
,
0.0
);
}
m_gal
->
Restore
();
...
...
@@ -720,7 +719,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
m_gal
->
SetStrokeColor
(
strokeColor
);
m_gal
->
SetLineWidth
(
aText
->
GetThickness
()
);
m_gal
->
SetTextAttributes
(
aText
);
m_gal
->
StrokeText
(
std
::
string
(
aText
->
GetText
().
mb_str
()
),
position
,
orientation
);
m_gal
->
StrokeText
(
aText
->
GetText
(
),
position
,
orientation
);
}
...
...
@@ -736,7 +735,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
m_gal
->
SetStrokeColor
(
strokeColor
);
m_gal
->
SetLineWidth
(
aText
->
GetThickness
()
);
m_gal
->
SetTextAttributes
(
aText
);
m_gal
->
StrokeText
(
std
::
string
(
aText
->
GetText
().
mb_str
()
),
position
,
orientation
);
m_gal
->
StrokeText
(
aText
->
GetText
(
),
position
,
orientation
);
}
...
...
@@ -836,7 +835,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
m_gal
->
SetLineWidth
(
text
.
GetThickness
()
);
m_gal
->
SetTextAttributes
(
&
text
);
m_gal
->
StrokeText
(
std
::
string
(
text
.
GetText
().
mb
_str
()
),
position
,
orientation
);
m_gal
->
StrokeText
(
std
::
wstring
(
text
.
GetText
().
wc
_str
()
),
position
,
orientation
);
}
...
...
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