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
29namespace 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
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:
106
109
110 private:
112 std::vector<Entry> entries_;
113
115 unsigned max_chars_;
116 };
117
118} // namespace scatter
define a RGBA colour
Definition Colour.hpp:34
[brief description]
Definition LegendOptions.hpp:32
[brief description]
Definition Legend.hpp:40
virtual ~Legend()
destructor
void add(const Entry &entry)
add an entry to the Legend
const LegendOptions *const options_
pointer to LegendOptions (coming from Plot)
Definition Legend.hpp:105
Legend(const LegendOptions *const options, const TextOptions *const text_options)
constructor
const TextOptions *const text_options_
pointer to TextOptions (coming from Plot)
Definition Legend.hpp:108
Symbol
[brief description]
Definition Legend.hpp:47
void render(Renderer &renderer, const Transform &transform)
render the Legend using the given Renderer
[brief description]
Definition Renderer.hpp:38
[brief description]
Definition TextOptions.hpp:32
[brief description]
Definition Transform.hpp:36
[brief description]
Definition Legend.hpp:59
std::string label
label of the plot
Definition Legend.hpp:61
Colour colour
colour used for plotting
Definition Legend.hpp:64
std::variant< Marker, Symbol > symbol
Marker or Symbol representing the data.
Definition Legend.hpp:67