WSL/SLF GitLab Repository
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
snow-models
meteoio
Commits
b51c3e4f
Commit
b51c3e4f
authored
Mar 22, 2016
by
Mathias Bavay
Browse files
Fixed the case of the "Legend" class name to make it more consistent
parent
abd517c4
Changes
3
Hide whitespace changes
Inline
Side-by-side
meteoio/Graphics.cc
View file @
b51c3e4f
...
...
@@ -29,49 +29,49 @@ namespace mio {
// Legend class
/////////////////////////////////////////////////////////////////////////////////////////////////
const
double
l
egend
::
bg_color
=
IOUtils
::
nodata
-
1
;
const
double
l
egend
::
text_color
=
IOUtils
::
nodata
-
2
;
const
unsigned
int
l
egend
::
char_width
=
6
;
const
unsigned
int
l
egend
::
char_height
=
10
;
const
unsigned
int
l
egend
::
text_chars_nb
=
9
;
//each label will contain 9 chars
const
unsigned
int
l
egend
::
char_space
=
1
;
//horizontal space between two chars
const
unsigned
int
l
egend
::
text_width
=
l
egend
::
text_chars_nb
*
(
l
egend
::
char_width
+
l
egend
::
char_space
);
//whole text line
const
unsigned
int
l
egend
::
sample_width
=
l
egend
::
char_width
*
1
;
//color sample 2 chars wide
const
unsigned
int
l
egend
::
sample_text_space
=
6
;
//width of the color sample
const
unsigned
int
l
egend
::
legend_plot_space
=
l
egend
::
char_width
*
1
;
const
unsigned
int
l
egend
::
total_width
=
l
egend
::
legend_plot_space
+
l
egend
::
sample_width
+
l
egend
::
sample_text_space
+
l
egend
::
text_width
;
const
unsigned
int
l
egend
::
interline
=
5
;
const
unsigned
int
l
egend
::
label_height
=
l
egend
::
char_height
+
l
egend
::
interline
;
//1 char + interline
const
unsigned
int
l
egend
::
nb_labels
=
12
+
1
;
//every decile + 0 level
const
unsigned
int
l
egend
::
total_height
=
l
egend
::
nb_labels
*
l
egend
::
label_height
+
l
egend
::
interline
;
const
unsigned
int
l
egend
::
font_0
[
char_height
][
char_width
]
=
{{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
1
,
0
,
0
,
1
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
1
,
0
,
0
,
1
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
}};
const
unsigned
int
l
egend
::
font_1
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
1
,
1
,
1
,
0
,
0
},
{
1
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
}};
const
unsigned
int
l
egend
::
font_2
[
char_height
][
char_width
]
=
{{
0
,
1
,
1
,
1
,
1
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
1
,
1
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
1
,
1
,
1
,
1
}};
const
unsigned
int
l
egend
::
font_3
[
char_height
][
char_width
]
=
{{
0
,
1
,
1
,
1
,
1
,
0
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
1
,
1
,
1
,
0
},
{
0
,
0
,
0
,
0
,
1
,
0
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
1
,
1
,
1
,
1
,
0
}};
const
unsigned
int
l
egend
::
font_4
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
1
,
1
,
1
,
0
},
{
0
,
1
,
1
,
1
,
1
,
0
},
{
1
,
1
,
0
,
1
,
1
,
0
},
{
1
,
0
,
0
,
1
,
1
,
0
},
{
1
,
1
,
1
,
1
,
1
,
1
},
{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
1
,
1
,
1
,
1
}};
const
unsigned
int
l
egend
::
font_5
[
char_height
][
char_width
]
=
{{
1
,
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
1
,
1
,
0
,
0
},
{
0
,
0
,
0
,
0
,
1
,
0
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
1
,
0
,
0
,
0
,
1
,
0
},
{
0
,
1
,
1
,
1
,
0
,
0
}};
const
unsigned
int
l
egend
::
font_6
[
char_height
][
char_width
]
=
{{
0
,
1
,
1
,
1
,
1
,
0
},
{
1
,
1
,
0
,
0
,
1
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
1
,
1
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
0
,
1
,
1
,
0
,
0
}};
const
unsigned
int
l
egend
::
font_7
[
char_height
][
char_width
]
=
{{
1
,
1
,
1
,
1
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
0
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
0
,
0
,
0
},
{
0
,
1
,
1
,
0
,
0
,
0
},
{
0
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
}};
const
unsigned
int
l
egend
::
font_8
[
char_height
][
char_width
]
=
{{
0
,
0
,
1
,
1
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
0
,
1
,
1
,
0
,
0
}};
const
unsigned
int
l
egend
::
font_9
[
char_height
][
char_width
]
=
{{
0
,
0
,
1
,
1
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
0
,
1
,
1
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
1
,
0
,
0
,
1
,
1
},
{
0
,
1
,
1
,
1
,
1
,
0
}};
const
unsigned
int
l
egend
::
font_plus
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
1
,
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
1
,
1
,
1
,
1
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
}};
const
unsigned
int
l
egend
::
font_minus
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
1
,
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
1
,
1
,
1
,
1
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
}};
const
unsigned
int
l
egend
::
font_dot
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
}};
const
unsigned
int
l
egend
::
font_E
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
1
,
1
,
1
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
0
},
{
1
,
1
,
1
,
1
,
1
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
0
},
{
0
,
1
,
1
,
1
,
0
,
0
}};
const
double
L
egend
::
bg_color
=
IOUtils
::
nodata
-
1
;
const
double
L
egend
::
text_color
=
IOUtils
::
nodata
-
2
;
const
unsigned
int
L
egend
::
char_width
=
6
;
const
unsigned
int
L
egend
::
char_height
=
10
;
const
unsigned
int
L
egend
::
text_chars_nb
=
9
;
//each label will contain 9 chars
const
unsigned
int
L
egend
::
char_space
=
1
;
//horizontal space between two chars
const
unsigned
int
L
egend
::
text_width
=
L
egend
::
text_chars_nb
*
(
L
egend
::
char_width
+
L
egend
::
char_space
);
//whole text line
const
unsigned
int
L
egend
::
sample_width
=
L
egend
::
char_width
*
1
;
//color sample 2 chars wide
const
unsigned
int
L
egend
::
sample_text_space
=
6
;
//width of the color sample
const
unsigned
int
L
egend
::
legend_plot_space
=
L
egend
::
char_width
*
1
;
const
unsigned
int
L
egend
::
total_width
=
L
egend
::
legend_plot_space
+
L
egend
::
sample_width
+
L
egend
::
sample_text_space
+
L
egend
::
text_width
;
const
unsigned
int
L
egend
::
interline
=
5
;
const
unsigned
int
L
egend
::
label_height
=
L
egend
::
char_height
+
L
egend
::
interline
;
//1 char + interline
const
unsigned
int
L
egend
::
nb_labels
=
12
+
1
;
//every decile + 0 level
const
unsigned
int
L
egend
::
total_height
=
L
egend
::
nb_labels
*
L
egend
::
label_height
+
L
egend
::
interline
;
const
unsigned
int
L
egend
::
font_0
[
char_height
][
char_width
]
=
{{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
1
,
0
,
0
,
1
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
1
,
0
,
0
,
1
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
}};
const
unsigned
int
L
egend
::
font_1
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
1
,
1
,
1
,
0
,
0
},
{
1
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
}};
const
unsigned
int
L
egend
::
font_2
[
char_height
][
char_width
]
=
{{
0
,
1
,
1
,
1
,
1
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
1
,
1
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
1
,
1
,
1
,
1
}};
const
unsigned
int
L
egend
::
font_3
[
char_height
][
char_width
]
=
{{
0
,
1
,
1
,
1
,
1
,
0
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
1
,
1
,
1
,
0
},
{
0
,
0
,
0
,
0
,
1
,
0
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
1
,
1
,
1
,
1
,
0
}};
const
unsigned
int
L
egend
::
font_4
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
1
,
1
,
1
,
0
},
{
0
,
1
,
1
,
1
,
1
,
0
},
{
1
,
1
,
0
,
1
,
1
,
0
},
{
1
,
0
,
0
,
1
,
1
,
0
},
{
1
,
1
,
1
,
1
,
1
,
1
},
{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
1
,
1
,
1
,
1
}};
const
unsigned
int
L
egend
::
font_5
[
char_height
][
char_width
]
=
{{
1
,
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
1
,
1
,
0
,
0
},
{
0
,
0
,
0
,
0
,
1
,
0
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
1
,
0
,
0
,
0
,
1
,
0
},
{
0
,
1
,
1
,
1
,
0
,
0
}};
const
unsigned
int
L
egend
::
font_6
[
char_height
][
char_width
]
=
{{
0
,
1
,
1
,
1
,
1
,
0
},
{
1
,
1
,
0
,
0
,
1
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
1
,
1
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
0
,
1
,
1
,
0
,
0
}};
const
unsigned
int
L
egend
::
font_7
[
char_height
][
char_width
]
=
{{
1
,
1
,
1
,
1
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
1
,
1
,
0
},
{
0
,
0
,
0
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
0
,
0
,
0
},
{
0
,
1
,
1
,
0
,
0
,
0
},
{
0
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
}};
const
unsigned
int
L
egend
::
font_8
[
char_height
][
char_width
]
=
{{
0
,
0
,
1
,
1
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
0
,
1
,
1
,
0
,
0
}};
const
unsigned
int
L
egend
::
font_9
[
char_height
][
char_width
]
=
{{
0
,
0
,
1
,
1
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
1
,
1
,
0
,
0
,
1
,
1
},
{
0
,
0
,
1
,
1
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
0
,
0
,
0
,
1
,
1
},
{
0
,
1
,
0
,
0
,
1
,
1
},
{
0
,
1
,
1
,
1
,
1
,
0
}};
const
unsigned
int
L
egend
::
font_plus
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
1
,
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
1
,
1
,
1
,
1
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
}};
const
unsigned
int
L
egend
::
font_minus
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
1
,
1
,
1
,
1
,
1
,
1
},
{
1
,
1
,
1
,
1
,
1
,
1
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
}};
const
unsigned
int
L
egend
::
font_dot
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
},
{
0
,
0
,
1
,
1
,
0
,
0
}};
const
unsigned
int
L
egend
::
font_E
[
char_height
][
char_width
]
=
{{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
0
,
0
,
0
,
0
,
0
},
{
0
,
1
,
1
,
1
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
0
},
{
1
,
1
,
1
,
1
,
1
,
0
},
{
1
,
1
,
0
,
0
,
0
,
0
},
{
1
,
1
,
0
,
0
,
1
,
0
},
{
0
,
1
,
1
,
1
,
0
,
0
}};
//create a legend of given height
//if height is insufficient, we don't generate any content, only transparent pixels
l
egend
::
l
egend
(
const
unsigned
int
&
height
,
const
double
&
minimum
,
const
double
&
maximum
)
:
grid
(
total_width
,
height
,
IOUtils
::
nodata
)
L
egend
::
L
egend
(
const
unsigned
int
&
height
,
const
double
&
minimum
,
const
double
&
maximum
)
:
grid
(
total_width
,
height
,
IOUtils
::
nodata
)
{
drawLegend
(
height
,
minimum
,
maximum
);
}
//uniform division of the given range
void
l
egend
::
simpleLegend
(
const
unsigned
int
&
height
,
const
double
&
minimum
,
const
double
&
maximum
)
void
L
egend
::
simpleLegend
(
const
unsigned
int
&
height
,
const
double
&
minimum
,
const
double
&
maximum
)
{
grid
.
resize
(
total_width
,
height
,
IOUtils
::
nodata
);
const
double
level_inc
=
(
maximum
-
minimum
)
/
(
double
)(
nb_labels
-
1
);
//the infamous interval thing...
...
...
@@ -96,7 +96,7 @@ void legend::simpleLegend(const unsigned int &height, const double &minimum, con
}
//this tries to properly round to legend min, max and steps so that it gets easier to follow
void
l
egend
::
smartLegend
(
const
unsigned
int
&
height
,
const
double
&
minimum
,
const
double
&
maximum
)
void
L
egend
::
smartLegend
(
const
unsigned
int
&
height
,
const
double
&
minimum
,
const
double
&
maximum
)
{
grid
.
resize
(
total_width
,
height
,
IOUtils
::
nodata
);
...
...
@@ -127,7 +127,7 @@ void legend::smartLegend(const unsigned int &height, const double &minimum, cons
}
//vertically center legend in free space
const
unsigned
int
smart_height
=
nb_labels_norm
*
l
egend
::
label_height
+
l
egend
::
interline
;
const
unsigned
int
smart_height
=
nb_labels_norm
*
L
egend
::
label_height
+
L
egend
::
interline
;
if
(
height
>=
smart_height
)
{
const
unsigned
int
free_space
=
height
-
smart_height
;
const
unsigned
int
start_legend
=
free_space
/
2
;
//we will start from the bottom
...
...
@@ -147,16 +147,16 @@ void legend::smartLegend(const unsigned int &height, const double &minimum, cons
}
}
void
l
egend
::
drawLegend
(
const
unsigned
int
&
height
,
const
double
&
minimum
,
const
double
&
maximum
){
void
L
egend
::
drawLegend
(
const
unsigned
int
&
height
,
const
double
&
minimum
,
const
double
&
maximum
){
smartLegend
(
height
,
minimum
,
maximum
);
//simpleLegend(height, minimum, maximum);
}
unsigned
int
l
egend
::
getLegendWidth
()
{
unsigned
int
L
egend
::
getLegendWidth
()
{
return
total_width
;
}
void
l
egend
::
writeLine
(
const
double
&
val
,
const
unsigned
int
&
px_row
)
void
L
egend
::
writeLine
(
const
double
&
val
,
const
unsigned
int
&
px_row
)
{
std
::
ostringstream
ss
;
ss
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
text_chars_nb
)
<<
std
::
left
<<
val
;
...
...
@@ -197,7 +197,7 @@ void legend::writeLine(const double& val, const unsigned int& px_row)
}
}
void
l
egend
::
writeChar
(
const
unsigned
int
i_char
[
char_height
][
char_width
],
const
unsigned
int
&
px_col
,
const
unsigned
int
&
px_row
)
void
L
egend
::
writeChar
(
const
unsigned
int
i_char
[
char_height
][
char_width
],
const
unsigned
int
&
px_col
,
const
unsigned
int
&
px_row
)
{
for
(
unsigned
int
jj
=
0
;
jj
<
char_height
;
jj
++
)
{
for
(
unsigned
int
ii
=
0
;
ii
<
char_width
;
ii
++
)
{
...
...
@@ -210,7 +210,7 @@ void legend::writeChar(const unsigned int i_char[char_height][char_width], const
}
}
const
Array2D
<
double
>
l
egend
::
getLegend
()
const
{
const
Array2D
<
double
>
L
egend
::
getLegend
()
const
{
return
grid
;
}
...
...
@@ -369,11 +369,11 @@ void Gradient::getColor(const double& val, unsigned char& r, unsigned char& g, u
r
=
0
;
g
=
0
;
b
=
0
;
a
=
true
;
return
;
}
if
(
val
==
l
egend
::
bg_color
)
{
if
(
val
==
L
egend
::
bg_color
)
{
r
=
channel_max_color
-
1
;
g
=
channel_max_color
-
1
;
b
=
channel_max_color
-
1
;
a
=
false
;
return
;
}
if
(
val
==
l
egend
::
text_color
)
{
if
(
val
==
L
egend
::
text_color
)
{
r
=
0
;
g
=
0
;
b
=
0
;
a
=
false
;
return
;
}
...
...
@@ -405,11 +405,11 @@ void Gradient::getColor(const double& val, unsigned char& index) const
index
=
0
;
return
;
}
if
(
val
==
l
egend
::
bg_color
)
{
if
(
val
==
L
egend
::
bg_color
)
{
index
=
1
;
return
;
}
if
(
val
==
l
egend
::
text_color
)
{
if
(
val
==
L
egend
::
text_color
)
{
index
=
2
;
return
;
}
...
...
meteoio/Graphics.h
View file @
b51c3e4f
...
...
@@ -35,7 +35,7 @@ namespace mio {
* @author Mathias Bavay
* @date 2011-12-23
*/
class
l
egend
{
class
L
egend
{
public:
/**
* @brief Constructor.
...
...
@@ -43,7 +43,7 @@ class legend {
* @param minimum start value of the legend
* @param maximum end value of the legend
*/
l
egend
(
const
unsigned
int
&
height
,
const
double
&
minimum
,
const
double
&
maximum
);
L
egend
(
const
unsigned
int
&
height
,
const
double
&
minimum
,
const
double
&
maximum
);
/**
* @brief Get the actual width of the legend
...
...
meteoio/plugins/PNGIO.cc
View file @
b51c3e4f
...
...
@@ -170,8 +170,8 @@ void PNGIO::setOptions()
cfg
.
getValue
(
"PNG_WORLD_FILE"
,
"Output"
,
has_world_file
,
IOUtils
::
nothrow
);
if
(
has_legend
)
{
//we need to save room for the legend
if
(
min_w
!=
IOUtils
::
unodata
)
min_w
-=
l
egend
::
getLegendWidth
();
if
(
max_w
!=
IOUtils
::
unodata
)
max_w
-=
l
egend
::
getLegendWidth
();
if
(
min_w
!=
IOUtils
::
unodata
)
min_w
-=
L
egend
::
getLegendWidth
();
if
(
max_w
!=
IOUtils
::
unodata
)
max_w
-=
L
egend
::
getLegendWidth
();
}
cfg
.
getValue
(
"PNG_INDEXED"
,
"Output"
,
indexed_png
,
IOUtils
::
nothrow
);
...
...
@@ -330,8 +330,8 @@ void PNGIO::setFile(const std::string& filename, png_structp& png_ptr, png_infop
size_t
PNGIO
::
setLegend
(
const
size_t
&
ncols
,
const
size_t
&
nrows
,
const
double
&
min
,
const
double
&
max
,
Array2D
<
double
>
&
legend_array
)
{
if
(
has_legend
)
{
const
l
egend
leg
(
static_cast
<
unsigned
int
>
(
nrows
),
min
,
max
);
legend_array
=
leg
.
getLegend
();
const
L
egend
leg
end
(
static_cast
<
unsigned
int
>
(
nrows
),
min
,
max
);
legend_array
=
leg
end
.
getLegend
();
const
size_t
nx
=
legend_array
.
getNx
();
return
(
ncols
+
nx
);
}
else
{
...
...
Write
Preview
Supports
Markdown
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