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
520be6f6
Commit
520be6f6
authored
Apr 17, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added GAL::DrawSegment for drawing rounded segments (used for drawing tracks).
parent
6cf04e68
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
104 additions
and
24 deletions
+104
-24
cairo_gal.cpp
common/gal/cairo/cairo_gal.cpp
+40
-0
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+39
-0
cairo_gal.h
include/gal/cairo/cairo_gal.h
+3
-0
graphics_abstraction_layer.h
include/gal/graphics_abstraction_layer.h
+11
-0
opengl_gal.h
include/gal/opengl/opengl_gal.h
+3
-0
pcb_painter.cpp
pcbnew/pcb_painter.cpp
+8
-24
No files found.
common/gal/cairo/cairo_gal.cpp
View file @
520be6f6
...
@@ -301,6 +301,46 @@ void CAIRO_GAL::DrawLine( VECTOR2D aStartPoint, VECTOR2D aEndPoint )
...
@@ -301,6 +301,46 @@ void CAIRO_GAL::DrawLine( VECTOR2D aStartPoint, VECTOR2D aEndPoint )
}
}
void
CAIRO_GAL
::
DrawSegment
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
,
double
aWidth
)
{
cairo_set_line_cap
(
cairoImage
,
CAIRO_LINE_CAP_ROUND
);
cairo_set_line_join
(
cairoImage
,
CAIRO_LINE_JOIN_ROUND
);
if
(
isFillEnabled
)
{
cairo_set_line_width
(
cairoImage
,
aWidth
);
cairo_move_to
(
cairoImage
,
(
double
)
aStartPoint
.
x
,
(
double
)
aStartPoint
.
y
);
cairo_line_to
(
cairoImage
,
(
double
)
aEndPoint
.
x
,
(
double
)
aEndPoint
.
y
);
}
else
{
VECTOR2D
startEndVector
=
aEndPoint
-
aStartPoint
;
double
lineAngle
=
atan2
(
startEndVector
.
y
,
startEndVector
.
x
);
double
lineLength
=
startEndVector
.
EuclideanNorm
();
cairo_save
(
cairoImage
);
cairo_translate
(
cairoImage
,
aStartPoint
.
x
,
aStartPoint
.
y
);
cairo_rotate
(
cairoImage
,
lineAngle
);
cairo_arc
(
cairoImage
,
0.0
,
0.0
,
aWidth
/
2.0
,
M_PI
/
2.0
,
3.0
*
M_PI
/
2.0
);
cairo_arc
(
cairoImage
,
lineLength
,
0.0
,
aWidth
/
2.0
,
-
M_PI
/
2.0
,
M_PI
/
2.0
);
cairo_move_to
(
cairoImage
,
0.0
,
aWidth
/
2.0
);
cairo_line_to
(
cairoImage
,
lineLength
,
aWidth
/
2.0
);
cairo_move_to
(
cairoImage
,
0.0
,
-
aWidth
/
2.0
);
cairo_line_to
(
cairoImage
,
lineLength
,
-
aWidth
/
2.0
);
cairo_restore
(
cairoImage
);
}
isElementAdded
=
true
;
}
void
CAIRO_GAL
::
DrawCircle
(
VECTOR2D
aCenterPoint
,
double
aRadius
)
void
CAIRO_GAL
::
DrawCircle
(
VECTOR2D
aCenterPoint
,
double
aRadius
)
{
{
// A circle is drawn using an arc
// A circle is drawn using an arc
...
...
common/gal/opengl/opengl_gal.cpp
View file @
520be6f6
...
@@ -525,6 +525,45 @@ inline void OPENGL_GAL::drawLineQuad( VECTOR2D aStartPoint, VECTOR2D aEndPoint )
...
@@ -525,6 +525,45 @@ inline void OPENGL_GAL::drawLineQuad( VECTOR2D aStartPoint, VECTOR2D aEndPoint )
}
}
void
OPENGL_GAL
::
DrawSegment
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
,
double
aWidth
)
{
VECTOR2D
startEndVector
=
aEndPoint
-
aStartPoint
;
double
lineAngle
=
atan2
(
startEndVector
.
y
,
startEndVector
.
x
);
if
(
isFillEnabled
)
{
glColor4d
(
fillColor
.
r
,
fillColor
.
g
,
fillColor
.
b
,
fillColor
.
a
);
SetLineWidth
(
aWidth
);
drawSemiCircle
(
aStartPoint
,
aWidth
/
2
,
lineAngle
+
M_PI
/
2
,
layerDepth
);
drawSemiCircle
(
aEndPoint
,
aWidth
/
2
,
lineAngle
-
M_PI
/
2
,
layerDepth
);
drawLineQuad
(
aStartPoint
,
aEndPoint
);
}
else
{
double
lineLength
=
startEndVector
.
EuclideanNorm
();
glColor4d
(
strokeColor
.
r
,
strokeColor
.
g
,
strokeColor
.
b
,
strokeColor
.
a
);
glPushMatrix
();
glTranslated
(
aStartPoint
.
x
,
aStartPoint
.
y
,
0.0
);
glRotated
(
lineAngle
*
(
360
/
(
2
*
M_PI
)
),
0
,
0
,
1
);
drawLineQuad
(
VECTOR2D
(
0.0
,
aWidth
/
2.0
),
VECTOR2D
(
lineLength
,
aWidth
/
2.0
)
);
drawLineQuad
(
VECTOR2D
(
0.0
,
-
aWidth
/
2.0
),
VECTOR2D
(
lineLength
,
-
aWidth
/
2.0
)
);
DrawArc
(
VECTOR2D
(
0.0
,
0.0
),
aWidth
/
2.0
,
M_PI
/
2.0
,
3.0
*
M_PI
/
2.0
);
DrawArc
(
VECTOR2D
(
lineLength
,
0.0
),
aWidth
/
2.0
,
M_PI
/
2.0
,
-
M_PI
/
2.0
);
glPopMatrix
();
}
}
inline
void
OPENGL_GAL
::
drawLineCap
(
VECTOR2D
aStartPoint
,
VECTOR2D
aEndPoint
,
double
aDepthOffset
)
inline
void
OPENGL_GAL
::
drawLineCap
(
VECTOR2D
aStartPoint
,
VECTOR2D
aEndPoint
,
double
aDepthOffset
)
{
{
VECTOR2D
startEndVector
=
aEndPoint
-
aStartPoint
;
VECTOR2D
startEndVector
=
aEndPoint
-
aStartPoint
;
...
...
include/gal/cairo/cairo_gal.h
View file @
520be6f6
...
@@ -98,6 +98,9 @@ public:
...
@@ -98,6 +98,9 @@ public:
/// @copydoc GAL::DrawLine()
/// @copydoc GAL::DrawLine()
virtual
void
DrawLine
(
VECTOR2D
aStartPoint
,
VECTOR2D
aEndPoint
);
virtual
void
DrawLine
(
VECTOR2D
aStartPoint
,
VECTOR2D
aEndPoint
);
/// @copydoc GAL::DrawSegment()
virtual
void
DrawSegment
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
,
double
aWidth
);
/// @copydoc GAL::DrawPolyline()
/// @copydoc GAL::DrawPolyline()
virtual
void
DrawPolyline
(
std
::
deque
<
VECTOR2D
>&
aPointList
);
virtual
void
DrawPolyline
(
std
::
deque
<
VECTOR2D
>&
aPointList
);
...
...
include/gal/graphics_abstraction_layer.h
View file @
520be6f6
...
@@ -107,6 +107,17 @@ public:
...
@@ -107,6 +107,17 @@ public:
*/
*/
virtual
void
DrawLine
(
VECTOR2D
aStartPoint
,
VECTOR2D
aEndPoint
)
=
0
;
virtual
void
DrawLine
(
VECTOR2D
aStartPoint
,
VECTOR2D
aEndPoint
)
=
0
;
/**
* @brief Draw a rounded segment.
*
* Start and end points are defined as 2D-Vectors.
*
* @param aStartPoint is the start point of the segment.
* @param aEndPoint is the end point of the segment.
* @param aWidth is a width of the segment
*/
virtual
void
DrawSegment
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
,
double
aWidth
)
=
0
;
/**
/**
* @brief Draw a polyline
* @brief Draw a polyline
*
*
...
...
include/gal/opengl/opengl_gal.h
View file @
520be6f6
...
@@ -105,6 +105,9 @@ public:
...
@@ -105,6 +105,9 @@ public:
/// @copydoc GAL::DrawLine()
/// @copydoc GAL::DrawLine()
virtual
void
DrawLine
(
VECTOR2D
aStartPoint
,
VECTOR2D
aEndPoint
);
virtual
void
DrawLine
(
VECTOR2D
aStartPoint
,
VECTOR2D
aEndPoint
);
/// @copydoc GAL::DrawSegment()
virtual
void
DrawSegment
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
,
double
aWidth
);
/// @copydoc GAL::DrawPolyline()
/// @copydoc GAL::DrawPolyline()
virtual
void
DrawPolyline
(
std
::
deque
<
VECTOR2D
>&
aPointList
);
virtual
void
DrawPolyline
(
std
::
deque
<
VECTOR2D
>&
aPointList
);
...
...
pcbnew/pcb_painter.cpp
View file @
520be6f6
...
@@ -224,42 +224,26 @@ void PCB_PAINTER::draw( const TRACK* aTrack )
...
@@ -224,42 +224,26 @@ void PCB_PAINTER::draw( const TRACK* aTrack )
{
{
VECTOR2D
start
(
aTrack
->
GetStart
()
);
VECTOR2D
start
(
aTrack
->
GetStart
()
);
VECTOR2D
end
(
aTrack
->
GetEnd
()
);
VECTOR2D
end
(
aTrack
->
GetEnd
()
);
COLOR4D
strokeColor
=
getLayerColor
(
aTrack
->
GetLayer
(),
aTrack
->
GetNet
()
);
int
width
=
aTrack
->
GetWidth
();
COLOR4D
color
=
getLayerColor
(
aTrack
->
GetLayer
(),
aTrack
->
GetNet
()
);
m_gal
->
SetStrokeColor
(
color
);
m_gal
->
SetIsStroke
(
true
);
m_gal
->
SetLineCap
(
LINE_CAP_ROUND
);
m_gal
->
SetLineJoin
(
LINE_JOIN_ROUND
);
m_gal
->
SetStrokeColor
(
strokeColor
);
if
(
m_pcbSettings
->
m_sketchModeSelect
[
TRACKS_VISIBLE
]
)
if
(
m_pcbSettings
->
m_sketchModeSelect
[
TRACKS_VISIBLE
]
)
{
{
// Outline mode
// Outline mode
VECTOR2D
line
=
end
-
start
;
double
length
=
line
.
EuclideanNorm
();
int
width
=
aTrack
->
GetWidth
();
m_gal
->
SetLineWidth
(
m_pcbSettings
->
m_outlineWidth
);
m_gal
->
SetLineWidth
(
m_pcbSettings
->
m_outlineWidth
);
m_gal
->
SetIsFill
(
false
);
m_gal
->
SetIsFill
(
false
);
m_gal
->
SetIsStroke
(
true
);
m_gal
->
Save
();
m_gal
->
Translate
(
start
);
m_gal
->
Rotate
(
line
.
Angle
()
);
m_gal
->
DrawLine
(
VECTOR2D
(
0
,
width
/
2
),
VECTOR2D
(
length
,
width
/
2
)
);
m_gal
->
DrawLine
(
VECTOR2D
(
0
,
-
width
/
2
),
VECTOR2D
(
length
,
-
width
/
2
)
);
m_gal
->
DrawArc
(
VECTOR2D
(
0
,
0
),
width
/
2
,
M_PI
/
2
,
3
*
M_PI
/
2
);
m_gal
->
DrawArc
(
VECTOR2D
(
length
,
0
),
width
/
2
,
M_PI
/
2
,
-
M_PI
/
2
);
m_gal
->
Restore
();
}
}
else
else
{
{
// Filled mode
// Filled mode
m_gal
->
SetFillColor
(
color
);
m_gal
->
SetIsFill
(
true
);
m_gal
->
SetIsFill
(
true
);
m_gal
->
SetIsStroke
(
false
);
m_gal
->
SetLineWidth
(
aTrack
->
GetWidth
()
);
m_gal
->
DrawLine
(
start
,
end
);
}
}
m_gal
->
DrawSegment
(
start
,
end
,
width
);
}
}
...
...
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