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
664692b2
Commit
664692b2
authored
Apr 08, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added outline display mode for pads, vias & tracks
parent
850c0a84
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
143 additions
and
34 deletions
+143
-34
painter.cpp
common/painter.cpp
+1
-0
painter.h
include/painter.h
+1
-0
basepcbframe.cpp
pcbnew/basepcbframe.cpp
+21
-5
pcb_painter.cpp
pcbnew/pcb_painter.cpp
+120
-29
No files found.
common/painter.cpp
View file @
664692b2
...
...
@@ -43,6 +43,7 @@ RENDER_SETTINGS::RENDER_SETTINGS()
m_hiContrastEnabled
=
false
;
m_hiContrastFactor
=
0.2
;
m_activeLayer
=
0
;
m_outlineWidth
=
60000
;
// Store the predefined colors used in KiCad in format used by GAL
for
(
int
i
=
0
;
i
<
NBCOLOR
;
i
++
)
...
...
include/painter.h
View file @
664692b2
...
...
@@ -132,6 +132,7 @@ protected:
float
m_selectFactor
;
/// Specifies how color of selected items is changed
float
m_layerOpacity
;
/// Determines opacity of all layers, so every can be seen
/// at the same time
float
m_outlineWidth
;
/// Line width used when drawing outlines
/// Map of colors that were usually used for display
std
::
map
<
EDA_COLOR_T
,
COLOR4D
>
m_legacyColorMap
;
...
...
pcbnew/basepcbframe.cpp
View file @
664692b2
...
...
@@ -211,14 +211,17 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
view
->
Add
(
zone
);
}
// Apply layer coloring scheme
// Apply layer coloring scheme
& display options
if
(
view
->
GetPainter
()
)
{
KiGfx
::
PCB_RENDER_SETTINGS
*
colorS
ettings
=
new
KiGfx
::
PCB_RENDER_SETTINGS
();
KiGfx
::
PCB_RENDER_SETTINGS
*
s
ettings
=
new
KiGfx
::
PCB_RENDER_SETTINGS
();
// Load layers' colors from PCB data
colorSettings
->
ImportLegacyColors
(
m_Pcb
->
GetColorsSettings
()
);
view
->
GetPainter
()
->
ApplySettings
(
colorSettings
);
settings
->
ImportLegacyColors
(
m_Pcb
->
GetColorsSettings
()
);
view
->
GetPainter
()
->
ApplySettings
(
settings
);
// Load display options (such as filled/outline display of items)
settings
->
LoadDisplayOptions
(
DisplayOpt
);
}
// Set rendering order of layers (check m_galLayerOrder to see the order)
...
...
@@ -489,6 +492,19 @@ void PCB_BASE_FRAME::OnTogglePolarCoords( wxCommandEvent& aEvent )
void
PCB_BASE_FRAME
::
OnTogglePadDrawMode
(
wxCommandEvent
&
aEvent
)
{
m_DisplayPadFill
=
DisplayOpt
.
DisplayPadFill
=
!
m_DisplayPadFill
;
#ifdef KICAD_GAL
// Apply new display options to the GAL canvas
KiGfx
::
PCB_PAINTER
*
painter
=
static_cast
<
KiGfx
::
PCB_PAINTER
*>
(
m_galCanvas
->
GetView
()
->
GetPainter
()
);
KiGfx
::
PCB_RENDER_SETTINGS
*
settings
=
static_cast
<
KiGfx
::
PCB_RENDER_SETTINGS
*>
(
painter
->
GetSettings
()
);
settings
->
LoadDisplayOptions
(
DisplayOpt
);
if
(
IsGalCanvasActive
()
)
m_galCanvas
->
Refresh
();
else
#endif
m_canvas
->
Refresh
();
}
...
...
pcbnew/pcb_painter.cpp
View file @
664692b2
...
...
@@ -45,6 +45,12 @@ using namespace KiGfx;
PCB_RENDER_SETTINGS
::
PCB_RENDER_SETTINGS
()
{
// By default everything should be displayed as filled
for
(
unsigned
int
i
=
0
;
i
<
END_PCB_VISIBLE_LIST
;
++
i
)
{
m_sketchModeSelect
[
i
]
=
false
;
}
Update
();
}
...
...
@@ -61,10 +67,10 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings
m_itemColors
[
i
]
=
m_legacyColorMap
[
aSettings
->
GetItemColor
(
i
)];
}
m_itemColors
[
VIA_HOLES_VISIBLE
]
=
COLOR4D
(
0.5
f
,
0.4
f
,
0.0
f
,
1.0
f
);
m_itemColors
[
PAD_HOLES_VISIBLE
]
=
COLOR4D
(
0.0
f
,
0.5
f
,
0.5
f
,
1.0
f
);
m_itemColors
[
VIAS_VISIBLE
]
=
COLOR4D
(
0.7
f
,
0.7
f
,
0.7
f
,
1.0
f
);
m_itemColors
[
PADS_VISIBLE
]
=
COLOR4D
(
0.7
f
,
0.7
f
,
0.7
f
,
1.0
f
);
m_itemColors
[
VIA_HOLES_VISIBLE
]
=
COLOR4D
(
0.5
,
0.4
,
0.0
,
1.0
);
m_itemColors
[
PAD_HOLES_VISIBLE
]
=
COLOR4D
(
0.0
,
0.5
,
0.5
,
1.0
);
m_itemColors
[
VIAS_VISIBLE
]
=
COLOR4D
(
0.7
,
0.7
,
0.7
,
1.0
);
m_itemColors
[
PADS_VISIBLE
]
=
COLOR4D
(
0.7
,
0.7
,
0.7
,
1.0
);
Update
();
}
...
...
@@ -73,6 +79,11 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings
void
PCB_RENDER_SETTINGS
::
LoadDisplayOptions
(
const
DISPLAY_OPTIONS
&
aOptions
)
{
m_hiContrastEnabled
=
aOptions
.
ContrastModeDisplay
;
// Whether to draw tracks, vias & pads filled or as outlines
m_sketchModeSelect
[
PADS_VISIBLE
]
=
!
aOptions
.
DisplayPadFill
;
m_sketchModeSelect
[
VIAS_VISIBLE
]
=
!
aOptions
.
DisplayViaFill
;
m_sketchModeSelect
[
TRACKS_VISIBLE
]
=
!
aOptions
.
DisplayPcbTrackFill
;
}
...
...
@@ -217,9 +228,38 @@ void PCB_PAINTER::draw( const TRACK* aTrack )
m_gal
->
SetLineCap
(
LINE_CAP_ROUND
);
m_gal
->
SetLineJoin
(
LINE_JOIN_ROUND
);
m_gal
->
SetLineWidth
(
aTrack
->
GetWidth
()
);
m_gal
->
SetStrokeColor
(
strokeColor
);
if
(
m_pcbSettings
->
m_sketchModeSelect
[
TRACKS_VISIBLE
]
)
{
// Outline mode
VECTOR2D
line
=
end
-
start
;
double
length
=
line
.
EuclideanNorm
();
int
width
=
aTrack
->
GetWidth
();
m_gal
->
SetLineWidth
(
m_pcbSettings
->
m_outlineWidth
);
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
{
// Filled mode
m_gal
->
SetIsFill
(
true
);
m_gal
->
SetIsStroke
(
false
);
m_gal
->
SetLineWidth
(
aTrack
->
GetWidth
()
);
m_gal
->
DrawLine
(
start
,
end
);
}
}
...
...
@@ -227,36 +267,69 @@ void PCB_PAINTER::draw( const SEGVIA* aVia, int aLayer )
{
VECTOR2D
center
(
aVia
->
GetStart
()
);
double
radius
;
COLOR4D
fillC
olor
;
COLOR4D
c
olor
;
// Choose drawing settings depending on if we are drawing via's pad or hole
if
(
aLayer
==
ITEM_GAL_LAYER
(
VIAS_VISIBLE
)
)
{
radius
=
aVia
->
GetWidth
()
/
2.0
f
;
radius
=
aVia
->
GetWidth
()
/
2.0
;
}
else
if
(
aLayer
==
ITEM_GAL_LAYER
(
VIA_HOLES_VISIBLE
)
)
{
radius
=
aVia
->
GetDrillValue
()
/
2.0
f
;
radius
=
aVia
->
GetDrillValue
()
/
2.0
;
}
else
return
;
fillC
olor
=
getLayerColor
(
aLayer
,
aVia
->
GetNet
()
);
c
olor
=
getLayerColor
(
aLayer
,
aVia
->
GetNet
()
);
m_gal
->
SetIsStroke
(
false
);
if
(
m_pcbSettings
->
m_sketchModeSelect
[
VIAS_VISIBLE
]
)
{
// Outline mode
m_gal
->
SetIsFill
(
false
);
m_gal
->
SetIsStroke
(
true
);
m_gal
->
SetLineWidth
(
m_pcbSettings
->
m_outlineWidth
);
m_gal
->
SetStrokeColor
(
color
);
m_gal
->
DrawCircle
(
center
,
radius
);
}
else
{
// Filled mode
m_gal
->
SetIsFill
(
true
);
m_gal
->
SetFillColor
(
fillColor
);
m_gal
->
SetIsStroke
(
false
);
m_gal
->
SetFillColor
(
color
);
m_gal
->
DrawCircle
(
center
,
radius
);
}
}
void
PCB_PAINTER
::
draw
(
const
D_PAD
*
aPad
,
int
aLayer
)
{
COLOR4D
fillC
olor
;
COLOR4D
c
olor
;
VECTOR2D
size
;
PAD_SHAPE_T
shape
;
double
m
,
n
;
color
=
getLayerColor
(
aLayer
,
aPad
->
GetNet
()
);
if
(
m_pcbSettings
->
m_sketchModeSelect
[
PADS_VISIBLE
]
)
{
// Outline mode
m_gal
->
SetIsFill
(
false
);
m_gal
->
SetIsStroke
(
true
);
m_gal
->
SetLineCap
(
LINE_CAP_ROUND
);
m_gal
->
SetLineJoin
(
LINE_JOIN_MITER
);
m_gal
->
SetLineWidth
(
m_pcbSettings
->
m_outlineWidth
);
m_gal
->
SetStrokeColor
(
color
);
}
else
{
// Filled mode
m_gal
->
SetIsFill
(
true
);
m_gal
->
SetIsStroke
(
false
);
m_gal
->
SetFillColor
(
color
);
}
m_gal
->
Save
();
m_gal
->
Translate
(
VECTOR2D
(
aPad
->
GetPosition
()
)
);
m_gal
->
Rotate
(
-
aPad
->
GetOrientation
()
*
M_PI
/
1800.0
);
// orientation is in tenths of degree
...
...
@@ -265,23 +338,17 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
if
(
aLayer
==
ITEM_GAL_LAYER
(
PAD_HOLES_VISIBLE
)
)
{
// Drawing hole
size
=
VECTOR2D
(
aPad
->
GetDrillSize
()
)
/
2.0
f
;
size
=
VECTOR2D
(
aPad
->
GetDrillSize
()
)
/
2.0
;
shape
=
aPad
->
GetDrillShape
();
}
else
{
// Drawing every kind of pad
m_gal
->
Translate
(
VECTOR2D
(
aPad
->
GetOffset
()
)
);
size
=
VECTOR2D
(
aPad
->
GetSize
()
)
/
2.0
f
;
size
=
VECTOR2D
(
aPad
->
GetSize
()
)
/
2.0
;
shape
=
aPad
->
GetShape
();
}
fillColor
=
getLayerColor
(
aLayer
,
aPad
->
GetNet
()
);
m_gal
->
SetIsFill
(
true
);
m_gal
->
SetIsStroke
(
false
);
m_gal
->
SetFillColor
(
fillColor
);
switch
(
shape
)
{
case
PAD_OVAL
:
...
...
@@ -290,19 +357,43 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m
=
(
size
.
y
-
size
.
x
);
n
=
size
.
x
;
if
(
m_pcbSettings
->
m_sketchModeSelect
[
PADS_VISIBLE
]
)
{
// Outline mode
m_gal
->
DrawArc
(
VECTOR2D
(
0
,
-
m
),
n
,
-
M_PI
,
0
);
m_gal
->
DrawArc
(
VECTOR2D
(
0
,
m
),
n
,
M_PI
,
0
);
m_gal
->
DrawLine
(
VECTOR2D
(
-
n
,
-
m
),
VECTOR2D
(
-
n
,
m
)
);
m_gal
->
DrawLine
(
VECTOR2D
(
n
,
-
m
),
VECTOR2D
(
n
,
m
)
);
}
else
{
// Filled mode
m_gal
->
DrawCircle
(
VECTOR2D
(
0
,
-
m
),
n
);
m_gal
->
DrawCircle
(
VECTOR2D
(
0
,
m
),
n
);
m_gal
->
DrawRectangle
(
VECTOR2D
(
-
n
,
-
m
),
VECTOR2D
(
n
,
m
)
);
}
}
else
{
m
=
(
size
.
x
-
size
.
y
);
n
=
size
.
y
;
if
(
m_pcbSettings
->
m_sketchModeSelect
[
PADS_VISIBLE
]
)
{
// Outline mode
m_gal
->
DrawArc
(
VECTOR2D
(
-
m
,
0
),
n
,
M_PI
/
2
,
3
*
M_PI
/
2
);
m_gal
->
DrawArc
(
VECTOR2D
(
m
,
0
),
n
,
M_PI
/
2
,
-
M_PI
/
2
);
m_gal
->
DrawLine
(
VECTOR2D
(
-
m
,
-
n
),
VECTOR2D
(
m
,
-
n
)
);
m_gal
->
DrawLine
(
VECTOR2D
(
-
m
,
n
),
VECTOR2D
(
m
,
n
)
);
}
else
{
// Filled mode
m_gal
->
DrawCircle
(
VECTOR2D
(
-
m
,
0
),
n
);
m_gal
->
DrawCircle
(
VECTOR2D
(
m
,
0
),
n
);
m_gal
->
DrawRectangle
(
VECTOR2D
(
-
m
,
-
n
),
VECTOR2D
(
m
,
n
)
);
}
}
break
;
case
PAD_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