scatter
0.1.0
Legend.hpp
1
/*
2
* Copyright (C) Tobias Löw (tobi.loew@protonmail.ch)
3
*
4
* This file is part of Scatter
5
*
6
* Scatter is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* Scatter is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with Scatter. If not, see <https://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include <scatter/Colour.hpp>
23
#include <scatter/LegendOptions.hpp>
24
#include <scatter/Plot.hpp>
25
#include <string>
26
#include <variant>
27
#include <vector>
28
29
namespace
scatter
30
{
32
class
Renderer;
33
class
Transform;
34
39
class
Legend
40
{
41
public
:
46
enum class
Symbol
47
{
48
LINE,
49
BAR,
50
ARROW,
51
ELLIPSE
52
};
53
58
struct
Entry
59
{
61
std::string
label
;
62
64
Colour
colour
;
65
67
std::variant<Marker, Symbol>
symbol
;
68
};
69
70
public
:
78
Legend
(
const
LegendOptions
*
const
options,
const
TextOptions
*
const
text_options);
79
84
virtual
~Legend
();
85
92
void
add
(
const
Entry
&entry);
93
101
void
render
(
Renderer
&renderer,
const
Transform
&transform);
102
103
protected
:
105
const
LegendOptions
*
const
options_
;
106
108
const
TextOptions
*
const
text_options_
;
109
110
private
:
112
std::vector<Entry> entries_;
113
115
unsigned
max_chars_;
116
};
117
118
}
// namespace scatter
scatter::Colour
define a RGBA colour
Definition
Colour.hpp:34
scatter::LegendOptions
[brief description]
Definition
LegendOptions.hpp:32
scatter::Legend
[brief description]
Definition
Legend.hpp:40
scatter::Legend::~Legend
virtual ~Legend()
destructor
scatter::Legend::add
void add(const Entry &entry)
add an entry to the Legend
scatter::Legend::options_
const LegendOptions *const options_
pointer to LegendOptions (coming from Plot)
Definition
Legend.hpp:105
scatter::Legend::Legend
Legend(const LegendOptions *const options, const TextOptions *const text_options)
constructor
scatter::Legend::text_options_
const TextOptions *const text_options_
pointer to TextOptions (coming from Plot)
Definition
Legend.hpp:108
scatter::Legend::Symbol
Symbol
[brief description]
Definition
Legend.hpp:47
scatter::Legend::render
void render(Renderer &renderer, const Transform &transform)
render the Legend using the given Renderer
scatter::Renderer
[brief description]
Definition
Renderer.hpp:38
scatter::TextOptions
[brief description]
Definition
TextOptions.hpp:32
scatter::Transform
[brief description]
Definition
Transform.hpp:36
scatter::Legend::Entry
[brief description]
Definition
Legend.hpp:59
scatter::Legend::Entry::label
std::string label
label of the plot
Definition
Legend.hpp:61
scatter::Legend::Entry::colour
Colour colour
colour used for plotting
Definition
Legend.hpp:64
scatter::Legend::Entry::symbol
std::variant< Marker, Symbol > symbol
Marker or Symbol representing the data.
Definition
Legend.hpp:67
src
scatter
Legend.hpp
Generated by
1.11.0