Blame view

src/ParamOutputImpl/Plot/Label.hh 1.41 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * Label.hh
 *
 *  Created on: 25 nov. 2013
 *      Author: CS
 */

#ifndef LABEL_HH_
#define LABEL_HH_

#include "Font.hh"
#include "Color.hh"
#include <vector>
#include <boost/shared_ptr.hpp>

namespace plot {
df45df5e   Benjamin Renard   Introduce AxisLeg...
17
typedef std::vector<std::string> LabelRowInfo;
fbe3c2bb   Benjamin Renard   First commit
18
19
20
21
22

class Label {
public:
	static const std::string DELIMITER;

fbe3c2bb   Benjamin Renard   First commit
23
	Label() :
f6eaec4e   Benjamin Renard   Optimize plot ele...
24
			_color(0, 0, 0), _font(Font("", 0)) {
fbe3c2bb   Benjamin Renard   First commit
25
26
27
	}

	Label(Font font) :
f6eaec4e   Benjamin Renard   Optimize plot ele...
28
			_color(0, 0, 0), _font(font) {
fbe3c2bb   Benjamin Renard   First commit
29
30
31
	}

	Label(Font font, Color color) :
f6eaec4e   Benjamin Renard   Optimize plot ele...
32
			_color(color), _font(font) {
fbe3c2bb   Benjamin Renard   First commit
33
34
35
	}

	Label(const Label& label) :
df45df5e   Benjamin Renard   Introduce AxisLeg...
36
			_text(label._text), _color(label._color), _font(label._font) {
fbe3c2bb   Benjamin Renard   First commit
37
38
39
40
41
	}

	virtual ~Label() {
	}

f6eaec4e   Benjamin Renard   Optimize plot ele...
42
43
44
45
46
47
48
49
	const Font& getFont() const {
		return _font;
	}

	void setFont(const Font& font) {
		_font = font;
	}

fbe3c2bb   Benjamin Renard   First commit
50
51
52
53
54
55
	/**
	 * @brief Determine number of line that compose label.
	 */
	static LabelRowInfo getRowNumber(Label const& pLegend);

	/**
fbe3c2bb   Benjamin Renard   First commit
56
57
58
59
60
61
62
63
64
65
66
67
68
	 * Label text.
	 */
	std::string _text;

	/**
	 * Text color
	 */
	Color _color;

	/**
	 * Dumps label properties, used for test.
	 */
	void dump(std::ostream& out, std::string& prefix);
f6eaec4e   Benjamin Renard   Optimize plot ele...
69
70
71
72
73
74

private:
	/**
	 * Label font name and size.
	 */
	Font _font;
fbe3c2bb   Benjamin Renard   First commit
75
76
};

fbe3c2bb   Benjamin Renard   First commit
77
78
inline std::ostream& operator <<(std::ostream& out, Label& label) {
	out << "[LABEL]" << std::endl;
df45df5e   Benjamin Renard   Introduce AxisLeg...
79
80
81
82
83
	out << "label.text=" << label._text;
	out << "label.color=" << label._color;
	std::string prefix = "label";
	Font font = label.getFont();
	font.dump(out, prefix);
fbe3c2bb   Benjamin Renard   First commit
84
85
86
	return out;
}

fbe3c2bb   Benjamin Renard   First commit
87
88
89

} /* namespace plot */
#endif /* LABEL_HH_ */