Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
44936a9b
Commit
44936a9b
authored
Mar 07, 2019
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ge barchart, negative bars added
parent
ca126d0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
152 additions
and
56 deletions
+152
-56
xtt/lib/glow/src/glow_growbarchart.cpp
xtt/lib/glow/src/glow_growbarchart.cpp
+152
-56
No files found.
xtt/lib/glow/src/glow_growbarchart.cpp
View file @
44936a9b
...
@@ -360,8 +360,10 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
...
@@ -360,8 +360,10 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
int
skip
;
int
skip
;
int
bar_ll_x
,
bar_ur_x
;
int
bar_ll_x
,
bar_ur_x
;
int
bar_ll_y
,
bar_ur_y
;
int
bar_up_ll_y
,
bar_up_ur_y
;
double
f_bar_ll_y
;
double
f_bar_up_ll_y
;
int
bar_down_ll_y
,
bar_down_ur_y
,
border_bar_down_ur_y
;
double
f_bar_down_ur_y
;
double
width
;
double
width
;
int
brect_ll_x
=
0
,
brect_ll_y
=
0
,
brect_width
=
0
,
brect_height
=
0
;
int
brect_ll_x
=
0
,
brect_ll_y
=
0
,
brect_width
=
0
,
brect_height
=
0
;
...
@@ -375,84 +377,153 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
...
@@ -375,84 +377,153 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
else
else
bar_ur_x
=
ll_x
+
(
j
+
1
)
*
width
;
bar_ur_x
=
ll_x
+
(
j
+
1
)
*
width
;
bar_ll_y
=
ur_y
;
if
(
min_value
>=
0
)
{
f_bar_ll_y
=
ur_y
;
bar_up_ll_y
=
ur_y
;
f_bar_up_ll_y
=
ur_y
;
}
else
{
bar_up_ll_y
=
ur_y
+
min_value
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
f_bar_up_ll_y
=
bar_up_ll_y
;
bar_down_ur_y
=
ur_y
+
min_value
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
f_bar_down_ur_y
=
bar_down_ur_y
;
}
for
(
int
i
=
0
;
i
<
barsegments
+
1
;
i
++
)
{
for
(
int
i
=
0
;
i
<
barsegments
+
1
;
i
++
)
{
glow_eDrawType
fillcolor
=
glow_eDrawType_Line
;
glow_eDrawType
fillcolor
=
glow_eDrawType_Line
;
skip
=
0
;
if
(
min_value
>
0
||
bar_values
[
i
][
j
]
>
0
)
{
bar_ur_y
=
bar_ll_y
;
skip
=
0
;
bar_up_ur_y
=
bar_up_ll_y
;
if
(
i
==
barsegments
)
{
if
(
bar_ll_y
<=
ll_y
)
if
(
i
==
barsegments
)
{
skip
=
1
;
if
(
bar_up_ll_y
<=
ll_y
)
else
skip
=
1
;
bar_ll_y
=
ll_y
;
else
fillcolor
=
ctx
->
get_drawtype
(
fill_drawtype
,
bar_up_ll_y
=
ll_y
;
glow_eDrawType_FillHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
1
);
fillcolor
=
ctx
->
get_drawtype
(
fill_drawtype
,
}
else
{
if
(
bar_values
[
i
][
j
]
<=
min_value
)
skip
=
1
;
else
if
(
bar_ur_y
<=
ll_y
)
skip
=
1
;
else
{
f_bar_ll_y
-=
(
bar_values
[
i
][
j
]
-
min_value
)
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
bar_ll_y
=
f_bar_ll_y
;
if
(
bar_ll_y
<
ll_y
)
bar_ll_y
=
ll_y
;
fillcolor
=
ctx
->
get_drawtype
(
bar_color
[
i
],
glow_eDrawType_FillHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
1
);
glow_eDrawType_FillHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
1
);
}
else
{
if
(
bar_values
[
i
][
j
]
<=
min_value
)
skip
=
1
;
else
if
(
bar_up_ur_y
<=
ll_y
)
skip
=
1
;
else
{
f_bar_up_ll_y
-=
bar_values
[
i
][
j
]
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
bar_up_ll_y
=
f_bar_up_ll_y
;
if
(
bar_up_ll_y
<
ll_y
)
bar_up_ll_y
=
ll_y
;
fillcolor
=
ctx
->
get_drawtype
(
bar_color
[
i
],
glow_eDrawType_FillHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
1
);
}
}
}
}
if
(
!
skip
)
{
if
(
grad
==
glow_eGradient_No
||
fillcolor
==
glow_eDrawType_ColorRed
if
(
!
skip
)
{
||
i
==
barsegments
)
{
if
(
grad
==
glow_eGradient_No
||
fillcolor
==
glow_eDrawType_ColorRed
if
(
chot
)
||
i
==
barsegments
)
{
drawtype
=
GlowColor
::
shift_drawtype
(
fillcolor
,
chot
,
0
);
if
(
chot
)
else
drawtype
=
GlowColor
::
shift_drawtype
(
fillcolor
,
chot
,
0
);
drawtype
=
fillcolor
;
ctx
->
gdraw
->
fill_rect
(
w
,
bar_ll_x
,
bar_up_ll_y
,
bar_ur_x
-
bar_ll_x
,
bar_up_ur_y
-
bar_up_ll_y
,
drawtype
);
}
else
{
glow_eDrawType
f1
,
f2
;
if
(
gradient_contrast
>=
0
)
{
f2
=
GlowColor
::
shift_drawtype
(
fillcolor
,
-
gradient_contrast
/
2
+
chot
,
0
);
f1
=
GlowColor
::
shift_drawtype
(
fillcolor
,
int
(
float
(
gradient_contrast
)
/
2
+
0.6
)
+
chot
,
0
);
}
else
{
f2
=
GlowColor
::
shift_drawtype
(
fillcolor
,
-
int
(
float
(
gradient_contrast
)
/
2
-
0.6
)
+
chot
,
0
);
f1
=
GlowColor
::
shift_drawtype
(
fillcolor
,
gradient_contrast
/
2
+
chot
,
0
);
}
ctx
->
gdraw
->
gradient_fill_rect
(
w
,
bar_ll_x
,
bar_up_ll_y
,
bar_ur_x
-
bar_ll_x
,
bar_up_ur_y
-
bar_up_ll_y
,
fillcolor
,
f1
,
f2
,
grad
);
}
}
}
else
{
// negative value, draw bar downwards
skip
=
0
;
bar_down_ll_y
=
bar_down_ur_y
;
if
(
i
==
barsegments
)
{
border_bar_down_ur_y
=
bar_down_ur_y
;
if
(
bar_down_ur_y
>=
ur_y
)
skip
=
1
;
else
else
drawtype
=
fillcolor
;
bar_down_ur_y
=
ur_y
;
ctx
->
gdraw
->
fill_rect
(
w
,
bar_ll_x
,
bar_ll_y
,
bar_ur_x
-
bar_ll_x
,
fillcolor
=
ctx
->
get_drawtype
(
fill_drawtype
,
bar_ur_y
-
bar_ll_y
,
drawtype
);
glow_eDrawType_FillHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
1
);
}
else
{
}
else
{
glow_eDrawType
f1
,
f2
;
if
(
bar_values
[
i
][
j
]
>=
0
)
if
(
gradient_contrast
>=
0
)
{
skip
=
1
;
f2
=
GlowColor
::
shift_drawtype
(
else
if
(
bar_down_ll_y
>=
ur_y
)
fillcolor
,
-
gradient_contrast
/
2
+
chot
,
0
);
skip
=
1
;
f1
=
GlowColor
::
shift_drawtype
(
else
{
fillcolor
,
int
(
float
(
gradient_contrast
)
/
2
+
0.6
)
+
chot
,
0
);
f_bar_down_ur_y
-=
bar_values
[
i
][
j
]
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
bar_down_ur_y
=
f_bar_down_ur_y
;
if
(
bar_down_ur_y
>
ur_y
)
bar_down_ur_y
=
ur_y
;
fillcolor
=
ctx
->
get_drawtype
(
bar_color
[
i
],
glow_eDrawType_FillHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
1
);
}
}
if
(
!
skip
)
{
if
(
grad
==
glow_eGradient_No
||
fillcolor
==
glow_eDrawType_ColorRed
||
i
==
barsegments
)
{
if
(
chot
)
drawtype
=
GlowColor
::
shift_drawtype
(
fillcolor
,
chot
,
0
);
else
drawtype
=
fillcolor
;
ctx
->
gdraw
->
fill_rect
(
w
,
bar_ll_x
,
bar_down_ll_y
,
bar_ur_x
-
bar_ll_x
,
bar_down_ur_y
-
bar_down_ll_y
,
drawtype
);
}
else
{
}
else
{
f2
=
GlowColor
::
shift_drawtype
(
glow_eDrawType
f1
,
f2
;
fillcolor
,
-
int
(
float
(
gradient_contrast
)
/
2
-
0.6
)
+
chot
,
0
);
if
(
gradient_contrast
>=
0
)
{
f1
=
GlowColor
::
shift_drawtype
(
f2
=
GlowColor
::
shift_drawtype
(
fillcolor
,
gradient_contrast
/
2
+
chot
,
0
);
fillcolor
,
-
gradient_contrast
/
2
+
chot
,
0
);
f1
=
GlowColor
::
shift_drawtype
(
fillcolor
,
int
(
float
(
gradient_contrast
)
/
2
+
0.6
)
+
chot
,
0
);
}
else
{
f2
=
GlowColor
::
shift_drawtype
(
fillcolor
,
-
int
(
float
(
gradient_contrast
)
/
2
-
0.6
)
+
chot
,
0
);
f1
=
GlowColor
::
shift_drawtype
(
fillcolor
,
gradient_contrast
/
2
+
chot
,
0
);
}
ctx
->
gdraw
->
gradient_fill_rect
(
w
,
bar_ll_x
,
bar_down_ll_y
,
bar_ur_x
-
bar_ll_x
,
bar_down_ur_y
-
bar_down_ll_y
,
fillcolor
,
f1
,
f2
,
grad
);
}
}
ctx
->
gdraw
->
gradient_fill_rect
(
w
,
bar_ll_x
,
bar_ll_y
,
bar_ur_x
-
bar_ll_x
,
bar_ur_y
-
bar_ll_y
,
fillcolor
,
f1
,
f2
,
grad
);
}
}
}
}
if
(
border
&&
i
==
barsegments
)
{
if
(
border
&&
i
==
barsegments
)
{
// Draw previous bar border
// Draw previous bar border
if
(
j
>
0
)
{
if
(
j
>
0
)
{
drawtype
=
ctx
->
get_drawtype
(
draw_type
,
glow_eDrawType_LineHighlight
,
drawtype
=
ctx
->
get_drawtype
(
draw_type
,
glow_eDrawType_LineHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
0
);
highlight
,
(
GrowNode
*
)
colornode
,
0
);
ctx
->
gdraw
->
rect
(
w
,
brect_ll_x
,
brect_ll_y
,
brect_width
,
brect_height
,
ctx
->
gdraw
->
rect
(
w
,
brect_ll_x
,
brect_ll_y
,
brect_width
,
brect_height
,
drawtype
,
idx
,
0
);
drawtype
,
idx
,
0
);
}
}
if
(
!
skip
)
{
if
(
min_value
>=
0
)
{
brect_ll_x
=
bar_ll_x
;
brect_ll_x
=
bar_ll_x
;
brect_ll_y
=
bar_u
r
_y
;
brect_ll_y
=
bar_u
p_ll
_y
;
brect_width
=
bar_ur_x
-
bar_ll_x
;
brect_width
=
bar_ur_x
-
bar_ll_x
;
brect_height
=
ur_y
-
bar_u
r
_y
;
brect_height
=
ur_y
-
bar_u
p_ll
_y
;
}
else
{
}
else
{
brect_ll_x
=
bar_ll_x
;
brect_ll_x
=
bar_ll_x
;
brect_ll_y
=
ll_y
;
brect_ll_y
=
bar_up_
ll_y
;
brect_width
=
bar_ur_x
-
bar_ll_x
;
brect_width
=
bar_ur_x
-
bar_ll_x
;
brect_height
=
ur_y
-
ll_y
;
brect_height
=
ur_y
+
min_value
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
)
-
bar_up_
ll_y
;
}
}
if
(
j
==
bars
-
1
)
{
if
(
j
==
bars
-
1
)
{
// Draw last bar border
// Draw last bar border
...
@@ -462,7 +533,32 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
...
@@ -462,7 +533,32 @@ void GrowBarChart::draw(GlowWind* w, GlowTransform* t, int highlight, int hot,
ctx
->
gdraw
->
rect
(
w
,
brect_ll_x
,
brect_ll_y
,
brect_width
,
brect_height
,
ctx
->
gdraw
->
rect
(
w
,
brect_ll_x
,
brect_ll_y
,
brect_width
,
brect_height
,
drawtype
,
idx
,
0
);
drawtype
,
idx
,
0
);
}
}
// Draw negative bar border
if
(
min_value
<
0
)
{
if
(
j
>
0
)
{
drawtype
=
ctx
->
get_drawtype
(
draw_type
,
glow_eDrawType_LineHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
0
);
ctx
->
gdraw
->
rect
(
w
,
brect_ll_x
,
brect_ll_y
,
brect_width
,
brect_height
,
drawtype
,
idx
,
0
);
}
brect_ll_x
=
bar_ll_x
;
brect_ll_y
=
ur_y
+
min_value
*
(
ur_y
-
ll_y
)
/
(
max_value
-
min_value
);
brect_width
=
bar_ur_x
-
bar_ll_x
;
brect_height
=
border_bar_down_ur_y
-
brect_ll_y
;
if
(
j
==
bars
-
1
)
{
// Draw last bar border
drawtype
=
ctx
->
get_drawtype
(
draw_type
,
glow_eDrawType_LineHighlight
,
highlight
,
(
GrowNode
*
)
colornode
,
0
);
ctx
->
gdraw
->
rect
(
w
,
brect_ll_x
,
brect_ll_y
,
brect_width
,
brect_height
,
drawtype
,
idx
,
0
);
}
}
}
}
}
}
}
}
...
...
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