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
6c3534bd
Commit
6c3534bd
authored
Jul 08, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dynamic color setting for netnames.
parent
32db0d46
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
6 deletions
+29
-6
color4d.h
include/gal/color4d.h
+11
-0
pcb_painter.cpp
pcbnew/pcb_painter.cpp
+18
-6
No files found.
include/gal/color4d.h
View file @
6c3534bd
...
...
@@ -132,6 +132,17 @@ public:
a
);
}
/**
* Function GetBrightness
* Returns the brightness value of the color ranged from 0.0 to 1.0.
* @return The brightness value.
*/
double
GetBrightness
()
const
{
// Weighted W3C formula
return
(
r
*
0
.
299
+
g
*
0
.
587
+
b
*
0
.
117
);
}
/// @brief Equality operator, are two colors equal
const
bool
operator
==
(
const
COLOR4D
&
aColor
);
...
...
pcbnew/pcb_painter.cpp
View file @
6c3534bd
...
...
@@ -263,9 +263,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
VECTOR2D
end
(
aTrack
->
GetEnd
()
);
int
width
=
aTrack
->
GetWidth
();
int
netNumber
=
aTrack
->
GetNet
();
COLOR4D
color
=
getLayerColor
(
aLayer
,
netNumber
);
m_gal
->
SetStrokeColor
(
color
);
COLOR4D
color
;
if
(
IsNetnameLayer
(
aLayer
)
)
{
...
...
@@ -285,6 +283,13 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
double
textOrientation
=
-
atan
(
line
.
y
/
line
.
x
);
double
textSize
=
std
::
min
(
static_cast
<
double
>
(
width
),
length
/
netName
.
length
()
);
// Set a proper color for the label
color
=
getLayerColor
(
aTrack
->
GetLayer
(),
aTrack
->
GetNet
()
);
if
(
color
.
GetBrightness
()
>
0.5
)
m_gal
->
SetStrokeColor
(
color
.
Darkened
(
0.8
)
);
else
m_gal
->
SetStrokeColor
(
color
.
Highlighted
(
0.8
)
);
m_gal
->
SetLineWidth
(
width
/
10.0
);
m_gal
->
SetBold
(
false
);
m_gal
->
SetItalic
(
false
);
...
...
@@ -298,6 +303,8 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
else
if
(
IsCopperLayer
(
aLayer
))
{
// Draw a regular track
color
=
getLayerColor
(
aLayer
,
netNumber
);
m_gal
->
SetStrokeColor
(
color
);
m_gal
->
SetIsStroke
(
true
);
if
(
m_pcbSettings
->
m_sketchModeSelect
[
TRACKS_VISIBLE
]
)
...
...
@@ -368,8 +375,6 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
NORMALIZE_ANGLE_90
(
orientation
);
// do not display descriptions upside down
orientation
=
orientation
*
M_PI
/
1800.0
;
color
=
getLayerColor
(
aLayer
,
aPad
->
GetNet
()
);
// Draw description layer
if
(
aLayer
==
ITEM_GAL_LAYER
(
PADS_NETNAMES_VISIBLE
)
)
{
...
...
@@ -409,7 +414,13 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m_gal
->
SetBold
(
false
);
m_gal
->
SetItalic
(
false
);
m_gal
->
SetMirrored
(
false
);
m_gal
->
SetStrokeColor
(
color
);
// Set a proper color for the label
color
=
getLayerColor
(
aPad
->
GetParent
()
->
GetLayer
(),
aPad
->
GetNet
()
);
if
(
color
.
GetBrightness
()
>
0.5
)
m_gal
->
SetStrokeColor
(
color
.
Darkened
(
0.8
)
);
else
m_gal
->
SetStrokeColor
(
color
.
Highlighted
(
0.8
)
);
// Let's make some space for a netname too, if there's one to display
if
(
!
aPad
->
GetNetname
().
empty
()
)
...
...
@@ -435,6 +446,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
return
;
}
color
=
getLayerColor
(
aLayer
,
aPad
->
GetNet
()
);
if
(
m_pcbSettings
->
m_sketchModeSelect
[
PADS_VISIBLE
]
)
{
// Outline mode
...
...
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