Blame view

src/ParamOutputImpl/Plot/ParameterAxes.hh 5.06 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * ParameterAxes.hh
 *
 *  Created on: 21 nov. 2013
 *      Author: guillaume
 */

#ifndef PARAMETERAXES_HH_
#define PARAMETERAXES_HH_

#include <iostream>
#include <iterator>
#include <string>
#include <vector>

#include "SeriesProperties.hh"
#include "XSeriesProperties.hh"
#include "DrawingProperties.hh"
#include "SpectroProperties.hh"
#include "ColorSeriesProperties.hh"
#include "Parameter.hh"
#include "ParameterData.hh"

namespace plot {

/**
 * holds all properties related to a parameter.
 * series properties field is hidden in this class, because we have to check
 * for inclusion of the same serie (same index) twice.
 */
class ParameterAxes {
public:
	friend std::ostream& operator<<(std::ostream& out_,
			const ParameterAxes& prop_);
	/*
	 * Dumps properties for test.
	 */
	void dump(std::ostream& out_, std::string& prefix_);

	ParameterAxes() :
			_originalParamId(""),
			_defaultProperties(),
			_ySeriesProperties(),
			_spectroPropertiesPtr(nullptr),
			_colorSeriesProperties()
	{

	}

	ParameterAxes(const std::string& _originalParamId) :
			_originalParamId(_originalParamId),
			_defaultProperties(),
			_ySeriesProperties(),
			_spectroPropertiesPtr(nullptr),
			_colorSeriesProperties()
	{

	}

	ParameterAxes(const ParameterAxes& pParamAxes) :
			_originalParamId(pParamAxes._originalParamId),
			_defaultProperties(pParamAxes._defaultProperties),
			_ySeriesProperties(pParamAxes._ySeriesProperties),
			_xSeriesProperties(pParamAxes._xSeriesProperties),
			_spectroPropertiesPtr(pParamAxes._spectroPropertiesPtr),
			_colorSeriesProperties(pParamAxes._colorSeriesProperties) {

	}

	ParameterAxes& operator=(const ParameterAxes& pParamAxes_) {
		_originalParamId = pParamAxes_._originalParamId;
		_defaultProperties = pParamAxes_._defaultProperties;
		_ySeriesProperties = pParamAxes_._ySeriesProperties;
		_xSeriesProperties = pParamAxes_._xSeriesProperties;
		_spectroPropertiesPtr = pParamAxes_._spectroPropertiesPtr;
		_colorSeriesProperties = pParamAxes_._colorSeriesProperties;
		return *this;
	}

	virtual ~ParameterAxes() {
	}

	/**
	 * add a new series properties. If a series with the same index
	 * already exist, it will be overridden.
	 * _index field of SerieProperties must have been properly set
	 * before calling this method.
	 * @param series properties to add.
	 */
	void addYSerieProperties(const SeriesProperties&);

	/**
c46af5a8   Benjamin Renard   Implements multi ...
93
	 * adds a new X series.
fbe3c2bb   Benjamin Renard   First commit
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
	 * already exist, it will be overridden.
	 * _index field of SerieProperties must have been properly set
	 * before calling this method.
	 * @param series properties to add, with no drawing settings, just index and xAxis
	 */
	void addXSerieProperties(const XSeriesProperties&);

	/**
	 * add a new spectro
	 */
	void addSpectroProperties(std::shared_ptr<SpectroProperties> pSPectroProperties);

	/**
	 * add a new color serie
	 */
	void addColorSerieProperties(const ColorSeriesProperties&);

	/**
	 * retrieve the series properties for the given 'index' key. Index is the
	 * value defined by the 'index' element in xml definition.
	 * If an entry with index=-1 exists and the required index is not found, then
	 * the serie at index==-1 is returned. Otherwise, an out_of_range exception is raised.
	 *
	 * @param index of the serie.
	 * @return the serie.
	 * @throw out_of_range exception if not found.
	 */
	SeriesProperties& getYSeriePropertiesAt(AMDA::Common::ParameterIndexComponent index);

	std::map<AMDA::Common::ParameterIndexComponent, SeriesProperties>& getYSeriePropertiesMap() {
		return _ySeriesProperties;
	}

c46af5a8   Benjamin Renard   Implements multi ...
127
128
129
130
131
132
	/**
	 * Get x serie properties by id
	 */
	XSeriesProperties& getXSeriePropertiesById(int id_);

	std::vector<XSeriesProperties>& getXSeriePropertiesList() {
fbe3c2bb   Benjamin Renard   First commit
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
		return _xSeriesProperties;
	}

	std::shared_ptr<SpectroProperties> getSpectroProperties() {
		return _spectroPropertiesPtr;
	}

	std::vector<ColorSeriesProperties>& getColorSeriePropertiesList() {
		return _colorSeriesProperties;
	}

	/**
	 * Get the list of indexes used for a parameter
	 */
	std::vector<AMDA::Common::ParameterIndexComponent> getParamUsedIndexes(std::string paramId_);

	/**
	 * Gets all real index for y series.
	 */
	std::vector<AMDA::Common::ParameterIndexComponent> getYSerieIndexList(std::map<std::string, ParameterData> *pParameterValues);

	/**
     * Get color serie properties by id
     */
    ColorSeriesProperties& getColorSeriePropertiesById(int id_);

	DrawingProperties& getDefaultProperties() {
		return _defaultProperties;
	}

	void setDefaultProperties(const DrawingProperties& default_) {
		_defaultProperties = default_;
	}

	/**
	 * Original parameter Id
	 */
	std::string _originalParamId;

private:

	/**
	 * Common drawing properties
	 */
	DrawingProperties _defaultProperties;

	/**
	 * Y Series
	 */
	std::map<AMDA::Common::ParameterIndexComponent, SeriesProperties> _ySeriesProperties;

	/**
	 * X Series
	 */
c46af5a8   Benjamin Renard   Implements multi ...
187
	std::vector<XSeriesProperties> _xSeriesProperties;
fbe3c2bb   Benjamin Renard   First commit
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203

	/**
	 * Spectro
	 */
	std::shared_ptr<SpectroProperties> _spectroPropertiesPtr;

	/**
	 * Color Series
	 */
	std::vector<ColorSeriesProperties> _colorSeriesProperties;
};

typedef std::vector<ParameterAxes> ParameterAxesList;

} /* namespace plot */
#endif /* PARAMETERAXES_HH_ */