Commit df45df5e65a5e018f3a6f49ecb1b382d3cd10a59

Authored by Benjamin Renard
1 parent 61086868

Introduce AxisLegend object (for #5965)

src/ParamOutputImpl/Plot/AxesNode.hh
... ... @@ -175,17 +175,19 @@ public:
175 175 AxisType* axis = pContext.get<AxisType*>();
176 176  
177 177 xmlChar* value = NULL;
178   - // -- text
  178 + // -- label
  179 + Label label;
179 180 value = xmlGetProp(pNode, (const xmlChar *) "text");
180 181 if (value) {
181   - axis->_legend._text = (const char*) value;
  182 + label._text = (const char*) value;
182 183 xmlFree(value);
183 184 }
184 185  
185 186 AMDA::Parameters::CfgContext context;
186   - context.push<Label*>(&axis->_legend);
  187 + context.push<Label*>(&label);
187 188  
188 189 LabelNode::proceed(pNode, context);
  190 + axis->_legend.setLabel(label);
189 191 }
190 192 };
191 193  
... ...
src/ParamOutputImpl/Plot/Axis.cc
... ... @@ -85,10 +85,11 @@ Axis::~Axis() {
85 85  
86 86 Font Axis::getLegendFont(Panel* pPanel) {
87 87 Font legendFont(_legend.getFont());
88   - if (legendFont._name == "")
89   - legendFont._name = pPanel->getFont()._name;
90   - if (legendFont._size == 0)
91   - legendFont._size = pPanel->getFont()._size;
  88 + Font panelFont = pPanel->getFont();
  89 + if (legendFont.getName() == "")
  90 + legendFont.setName(panelFont.getName());
  91 + if (legendFont.getSize() == 0)
  92 + legendFont.setSize(panelFont.getSize());
92 93  
93 94 return legendFont;
94 95 }
... ...
src/ParamOutputImpl/Plot/Axis.hh
... ... @@ -12,7 +12,7 @@
12 12 #include "PlotCommon.hh"
13 13 #include "Range.hh"
14 14 #include "Tick.hh"
15   -#include "Label.hh"
  15 +#include "AxisLegend.hh"
16 16 #include "ConstantLine.hh"
17 17 #include "ContextFileWriter.hh"
18 18 #include <boost/shared_ptr.hpp>
... ... @@ -138,9 +138,9 @@ public:
138 138 int _thickness;
139 139  
140 140 /**
141   - * @brief Axis label
  141 + * @brief Axis legend definition
142 142 */
143   - Label _legend;
  143 + AxisLegend _legend;
144 144  
145 145 /**
146 146 * @brief _drawn Define if axis is already drawn (true) or not (false).
... ...
src/ParamOutputImpl/Plot/AxisLegend.cc 0 โ†’ 100644
... ... @@ -0,0 +1,49 @@
  1 +/*
  2 + * AxisLegend.cc
  3 + *
  4 + * Created on: 01 jun. 2018
  5 + * Author: AKKA
  6 + */
  7 +
  8 +#include "AxisLegend.hh"
  9 +#include <sstream>
  10 +#include <algorithm>
  11 +#include <boost/regex.hpp>
  12 +#include <boost/algorithm/string/regex.hpp>
  13 +
  14 +namespace plot {
  15 +
  16 +LabelRowInfo append(LabelRowInfo& a, LabelRowInfo& b)
  17 +{
  18 + LabelRowInfo result;
  19 + for (auto row : a) {
  20 + result.push_back(row);
  21 + }
  22 + for (auto row : b) {
  23 + result.push_back(row);
  24 + }
  25 + return result;
  26 +}
  27 +
  28 +LabelRowInfo AxisLegend::getRowNumber(AxisLegend const& pLegend) {
  29 + LabelRowInfo lMergedLegend;
  30 +
  31 + for (auto label : pLegend._labels) {
  32 + LabelRowInfo labelRow = Label::getRowNumber(label);
  33 + lMergedLegend = append(lMergedLegend, labelRow);
  34 + }
  35 +
  36 + return lMergedLegend;
  37 +}
  38 +
  39 +void AxisLegend::dump(std::ostream& out, std::string& prefix) {
  40 + prefix += "legend.";
  41 + out << prefix << "color=" << _color << std::endl;
  42 + _font.dump(out, prefix);
  43 + for (auto label : _labels) {
  44 + label.dump(out, prefix);
  45 + }
  46 +}
  47 +
  48 +}
  49 +
... ...
src/ParamOutputImpl/Plot/AxisLegend.hh 0 โ†’ 100644
... ... @@ -0,0 +1,139 @@
  1 +/*
  2 + * AxisLegend.hh
  3 + *
  4 + * Created on: 01 jun. 2018
  5 + * Author: AKKA
  6 + */
  7 +
  8 +#ifndef AXISLEGEND_HH_
  9 +#define AXISLEGEND_HH_
  10 +
  11 +#include "Label.hh"
  12 +#include <vector>
  13 +
  14 +namespace plot {
  15 +
  16 +class AxisLegend {
  17 +public:
  18 + AxisLegend() : _color(0, 0, 0), _font(Font("", 0)) {
  19 + }
  20 +
  21 + AxisLegend(Font font) : _color(0, 0, 0), _font(font) {
  22 + }
  23 +
  24 + AxisLegend(Font font, Color color) : _color(color), _font(font) {
  25 + }
  26 +
  27 + AxisLegend(const AxisLegend& legend) :
  28 + _labels(legend._labels), _color(legend._color), _font(legend._font) {
  29 + }
  30 +
  31 + virtual ~AxisLegend() {
  32 + _labels.clear();
  33 + }
  34 +
  35 + const std::vector<Label> getLabels() const {
  36 + return _labels;
  37 + }
  38 +
  39 + const Color& getColor() const {
  40 + return _color;
  41 + }
  42 +
  43 + const Font& getFont() const {
  44 + return _font;
  45 + }
  46 +
  47 + void setFont(const Font& font) {
  48 + _font = font;
  49 + }
  50 +
  51 + void setLabel(Label &label) {
  52 + if (!label._text.empty()) {
  53 + _labels.clear();
  54 + _labels.push_back(label);
  55 + }
  56 + _color = label._color;
  57 + _font = label.getFont();
  58 + }
  59 +
  60 + void pushLabel(Label &label) {
  61 + if (!label._text.empty()) {
  62 + _labels.push_back(label);
  63 + }
  64 + }
  65 +
  66 + void clearLabels() {
  67 + _labels.clear();
  68 + }
  69 +
  70 + std::string getText() {
  71 + std::string result = "";
  72 + bool isFirstLabel = true;
  73 + for (auto label : _labels) {
  74 + if (label._text.empty()) {
  75 + continue;
  76 + }
  77 + if (!isFirstLabel) {
  78 + result += Label::DELIMITER;
  79 + }
  80 + result += label._text;
  81 + }
  82 + return result;
  83 + }
  84 +
  85 + bool isEmpty() {
  86 + if (_labels.empty()) {
  87 + return true;
  88 + }
  89 + for (auto label : _labels) {
  90 + if (!label._text.empty()) {
  91 + return false;
  92 + }
  93 + }
  94 + return true;
  95 + }
  96 +
  97 + /**
  98 + * @brief Determine number of line that compose the legend.
  99 + */
  100 + static LabelRowInfo getRowNumber(AxisLegend const& pLegend);
  101 +
  102 + /**
  103 + * Dumps legend properties, used for test.
  104 + */
  105 + void dump(std::ostream& out, std::string& prefix);
  106 +
  107 +private:
  108 + /**
  109 + * List of labels that compose the legend.
  110 + */
  111 + std::vector<Label> _labels;
  112 +
  113 + /**
  114 + * Text color
  115 + */
  116 + Color _color;
  117 +
  118 + /**
  119 + * Legend font name and size.
  120 + */
  121 + Font _font;
  122 +};
  123 +
  124 +inline std::ostream& operator <<(std::ostream& out, AxisLegend& legend) {
  125 + out << "[AXIS LEGEND]" << std::endl;
  126 + out << "legend.color=" << legend.getColor() << std::endl;
  127 + std::string prefix = "legend";
  128 + Font font = legend.getFont();
  129 + font.dump(out, prefix);
  130 + prefix = "legend.label";
  131 + for (auto label : legend.getLabels()) {
  132 + label.dump(out,prefix);
  133 + }
  134 + return out;
  135 +}
  136 +
  137 +
  138 +} /* namespace plot */
  139 +#endif /* AXISLEGEND_HH_ */
... ...
src/ParamOutputImpl/Plot/AxisLegendManager.cc
... ... @@ -59,7 +59,7 @@ void AxisLegendManager::configureYAxisLegendForSpectro(
59 59 if (lYAxis.get() == nullptr)
60 60 continue;
61 61  
62   - if (!lYAxis->_legend._text.empty())
  62 + if (!lYAxis->_legend.isEmpty())
63 63 continue;
64 64  
65 65 setAxisLegendForTable(plot, lYAxis, param._originalParamId, spectroPropertiesPtr->getParamId(), spectroPropertiesPtr->getIndexes(), spectroPropertiesPtr->getRelatedDim());
... ... @@ -186,15 +186,13 @@ void AxisLegendManager::pushComponentInList(std::string paramId, AMDA::Common::P
186 186 }
187 187  
188 188 void AxisLegendManager::setAxisLegendForSeries(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, AxisParamsComponents& axisParamsComponents) {
189   - if (pAxis == nullptr || !pAxis->_legend._text.empty()) {
  189 + if (pAxis == nullptr || !pAxis->_legend.isEmpty()) {
190 190 return;
191 191 }
192 192  
193 193 // Retrieve ParamInfo Manager
194 194 ParamMgr* piMgr = ParamMgr::getInstance();
195 195  
196   - //Build list of legend lines
197   - std::list<std::string> legendLines;
198 196 for (auto paramsComponents : axisParamsComponents) {
199 197 ParameterSPtr p = plot->_parameterManager.getParameter(paramsComponents.first);
200 198 ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId());
... ... @@ -204,29 +202,26 @@ void AxisLegendManager::setAxisLegendForSeries(PanelPlotOutput* plot, boost::sha
204 202 paramsComponents.second.push_back(AMDA::Common::ParameterIndexComponent(-1,-1));
205 203 }
206 204 bool isFirstComponent = true;
  205 + Label label(pAxis->_legend.getFont(), pAxis->_legend.getColor());
207 206 for (auto components : paramsComponents.second) {
208 207 if (paramInfo == nullptr)
209 208 continue;
210 209 if ((axisParamsComponents.size() == 1) && isFirstComponent) {
211 210 std::string info = getMissionInstrumentInfo(paramInfo);
212 211 if (!info.empty()) {
213   - legendLines.push_back(info);
  212 + label._text = info;
214 213 }
215 214 }
216   - legendLines.push_back(getParamLegend(paramInfo, components));
  215 + addBreakLine(label._text);
  216 + label._text += getParamLegend(paramInfo, components);
217 217 isFirstComponent = false;
218 218 }
219   - }
220   -
221   - //Set legend to axis
222   - for (auto line : legendLines) {
223   - addBreakLine(pAxis->_legend._text);
224   - pAxis->_legend._text += line;
  219 + pAxis->_legend.pushLabel(label);
225 220 }
226 221 }
227 222  
228 223 void AxisLegendManager::setAxisLegendForSpectro(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, std::string originalParamId) {
229   - if (pAxis == nullptr || !pAxis->_legend._text.empty()) {
  224 + if (pAxis == nullptr || !pAxis->_legend.isEmpty()) {
230 225 return;
231 226 }
232 227  
... ... @@ -238,12 +233,14 @@ void AxisLegendManager::setAxisLegendForSpectro(PanelPlotOutput* plot, boost::sh
238 233 if (paramInfo == nullptr)
239 234 return;
240 235  
241   - addInfoPart(pAxis->_legend._text, paramInfo->getShortName());
242   - addInfoPart(pAxis->_legend._text, paramInfo->getUnits());
  236 + Label label(pAxis->_legend.getFont(), pAxis->_legend.getColor());
  237 + addInfoPart(label._text, paramInfo->getShortName());
  238 + addInfoPart(label._text, paramInfo->getUnits());
  239 + pAxis->_legend.setLabel(label);
243 240 }
244 241  
245 242 void AxisLegendManager::setAxisLegendForTable(PanelPlotOutput* plot, boost::shared_ptr<Axis>& pAxis, std::string originalParamId, std::string paramId, AMDA::Common::ParameterIndexComponentList& indexes, int relatedDim) {
246   - if (pAxis == nullptr || !pAxis->_legend._text.empty()) {
  243 + if (pAxis == nullptr || !pAxis->_legend.isEmpty()) {
247 244 return;
248 245 }
249 246  
... ... @@ -256,10 +253,11 @@ void AxisLegendManager::setAxisLegendForTable(PanelPlotOutput* plot, boost::shar
256 253 if (paramInfo == nullptr)
257 254 return;
258 255  
  256 + Label label(pAxis->_legend.getFont(), pAxis->_legend.getColor());
259 257 std::string info = getMissionInstrumentInfo(paramInfo);
260 258 if (!info.empty()) {
261   - addInfoPart(pAxis->_legend._text, info);
262   - addBreakLine(pAxis->_legend._text);
  259 + addInfoPart(label._text, info);
  260 + addBreakLine(label._text);
263 261 }
264 262  
265 263 boost::shared_ptr<AMDA::Info::ParamTable> tableSPtr;
... ... @@ -269,7 +267,8 @@ void AxisLegendManager::setAxisLegendForTable(PanelPlotOutput* plot, boost::shar
269 267 std::string tableInfo = "Table ";
270 268 tableInfo += std::to_string(relatedDim);
271 269 tableInfo += " indexes";
272   - addInfoPart(pAxis->_legend._text, tableInfo);
  270 + addInfoPart(label._text, tableInfo);
  271 + pAxis->_legend.pushLabel(label);
273 272 return;
274 273 }
275 274  
... ... @@ -292,24 +291,25 @@ void AxisLegendManager::setAxisLegendForTable(PanelPlotOutput* plot, boost::shar
292 291 if ((otherTableSPtr != nullptr) && !otherTableSPtr->isVariable())
293 292 {
294 293 if (otherTableSPtr->getName().empty())
295   - addInfoPart(pAxis->_legend._text, "Table bounds");
  294 + addInfoPart(label._text, "Table bounds");
296 295 else
297   - addInfoPart(pAxis->_legend._text, otherTableSPtr->getName());
  296 + addInfoPart(label._text, otherTableSPtr->getName());
298 297  
299 298 AMDA::Info::t_TableBound crtBound = otherTableSPtr->getBound(&plot->_parameterManager, otherDimIndex);
300   - addBoundsPart(pAxis->_legend._text, crtBound.min, crtBound.max);
301   - addInfoPart(pAxis->_legend._text, otherTableSPtr->getUnits());
  299 + addBoundsPart(label._text, crtBound.min, crtBound.max);
  300 + addInfoPart(label._text, otherTableSPtr->getUnits());
302 301 }
303 302 else
304 303 {
305 304 std::string part = "Table Index: ";
306 305 part += otherDimIndex;
307   - addInfoPart(pAxis->_legend._text, part);
  306 + addInfoPart(label._text, part);
308 307 }
309   - addBreakLine(pAxis->_legend._text);
  308 + addBreakLine(label._text);
310 309 }
311   - addInfoPart(pAxis->_legend._text, tableSPtr->getName());
312   - addInfoPart(pAxis->_legend._text, tableSPtr->getUnits());
  310 + addInfoPart(label._text, tableSPtr->getName());
  311 + addInfoPart(label._text, tableSPtr->getUnits());
  312 + pAxis->_legend.pushLabel(label);
313 313 }
314 314  
315 315 void AxisLegendManager::addInfoPart(std::string& legend, std::string info) {
... ...
src/ParamOutputImpl/Plot/CommonNode.cc
... ... @@ -50,7 +50,7 @@ void LabelNode::proceed(xmlNodePtr pNode,
50 50 Font labelFont(label->getFont());
51 51 value = xmlGetProp(pNode, (const xmlChar *) "fontName");
52 52 if (value) {
53   - labelFont._name = (const char*) value;
  53 + labelFont.setName((const char*) value);
54 54 xmlFree(value);
55 55 }
56 56  
... ... @@ -58,23 +58,26 @@ void LabelNode::proceed(xmlNodePtr pNode,
58 58 value = xmlGetProp(pNode, (const xmlChar *) "fontSize");
59 59 if (value) {
60 60  
61   - labelFont._size = atoi((const char*) value);
  61 + labelFont.setSize(atoi((const char*) value));
62 62 xmlFree(value);
63 63 }
64 64  
65   - label->setFont(labelFont);
  65 + // -- font style
  66 + value = xmlGetProp(pNode, (const xmlChar *) "fontStyle");
  67 + if (value) {
  68 + labelFont.setStyle(Font::getStyleByStr((const char*) value));
  69 + xmlFree(value);
  70 + }
66 71  
67   - // -- style
68   - value = xmlGetProp(pNode, (const xmlChar *) "style");
  72 + // -- font weight
  73 + value = xmlGetProp(pNode, (const xmlChar *) "fontWeight");
69 74 if (value) {
70   - char split_char = ',';
71   - std::istringstream split((const char*) value);
72   - for (std::string style; std::getline(split, style, split_char);
73   - label->_style.push_back(Font::getStyleByStr(style)))
74   - ;
  75 + labelFont.setWeight(Font::getWeightByStr((const char*) value));
75 76 xmlFree(value);
76 77 }
77 78  
  79 + label->setFont(labelFont);
  80 +
78 81 // -- axis color
79 82 value = xmlGetProp(pNode, (const xmlChar *) "color");
80 83 if (value) {
... ...
src/ParamOutputImpl/Plot/CommonNode.hh
... ... @@ -171,28 +171,28 @@ public:
171 171 // -- name
172 172 value = xmlGetProp(pNode, (const xmlChar *) "name");
173 173 if (value) {
174   - elementFont._name = (const char*) value;
  174 + elementFont.setName((const char*) value);
175 175 xmlFree(value);
176 176 }
177 177  
178 178 // -- size
179 179 value = xmlGetProp(pNode, (const xmlChar *) "size");
180 180 if (value) {
181   - elementFont._size = atoi((const char*) value);
  181 + elementFont.setSize(atoi((const char*) value));
182 182 xmlFree(value);
183 183 }
184 184  
185 185 // -- style
186 186 value = xmlGetProp(pNode, (const xmlChar *) "style");
187 187 if (value) {
188   - elementFont.setStyle((const char*) value);
  188 + elementFont.setStyle(Font::getStyleByStr((const char*) value));
189 189 xmlFree(value);
190 190 }
191 191  
192 192 // -- weight
193 193 value = xmlGetProp(pNode, (const xmlChar *) "weight");
194 194 if (value) {
195   - elementFont.setWeight((const char*) value);
  195 + elementFont.setWeight(Font::getWeightByStr((const char*) value));
196 196 xmlFree(value);
197 197 }
198 198  
... ...
src/ParamOutputImpl/Plot/Font.cc
... ... @@ -16,7 +16,7 @@ const std::vector&lt;std::string&gt; Font::sStyle = { &quot;upright&quot;, &quot;italic&quot;, &quot;oblique&quot; }
16 16 const std::vector<std::string> Font::sWeight = { "medium", "bold" };
17 17  
18 18 Font::Font(const std::string& pname, int psize) :
19   - _name(pname), _size(psize), _style(0), _weight(0) {
  19 + _name(pname), _size(psize), _style(Style::NORMAL), _weight(Weight::NORMAL) {
20 20 }
21 21  
22 22 Font::Font(const Font& pfont) :
... ... @@ -34,28 +34,43 @@ void Font::setSize (int size) {
34 34 _size = size;
35 35 }
36 36  
37   -void Font::setStyle (const std::string & style) {
38   - for (size_t i = 0; i < sStyle.size(); ++i) {
39   - if (style.compare(sStyle[i]) == 0) {
40   - _style = i;
41   - }
42   - }
  37 +void Font::setStyle (Style style) {
  38 + _style = style;
43 39 }
44 40  
45   -void Font::setWeight (const std::string & weight) {
46   - for (size_t i = 0; i < sWeight.size(); ++i) {
47   - if (weight.compare(sWeight[i]) == 0) {
48   - _weight = i;
49   - }
50   - }
  41 +void Font::setWeight (Weight weight) {
  42 + _weight = weight;
  43 +}
  44 +
  45 +std::string Font::getName() const {
  46 + return _name;
  47 +}
  48 +
  49 +int Font::getSize() const {
  50 + return _size;
  51 +}
  52 +
  53 +Font::Style Font::getStyle() const {
  54 + return _style;
  55 +}
  56 +
  57 +Font::Weight Font::getWeight() const {
  58 + return _weight;
  59 +}
  60 +
  61 +void Font::dump(std::ostream& out, std::string& prefix) {
  62 + out << prefix << ".font.name=" << _name << std::endl;
  63 + out << prefix << ".font.size=" << _size << std::endl;
  64 + out << prefix << ".font.style=" << _style << std::endl;
  65 + out << prefix << ".font.weight=" << _weight << std::endl;
51 66 }
52 67  
53 68 std::ostream& operator <<(std::ostream& out,const Font& font) {
54 69 out << "[FONT]" << std::endl;
55   - out << "font.name=" << font._name << std::endl;
56   - out << "font.size=" << font._size << std::endl;
57   - out << "font.style=" << font.sStyle[font._style] << std::endl;
58   - out << "font.weight=" << font.sWeight[font._weight] << std::endl;
  70 + out << "font.name=" << font.getName() << std::endl;
  71 + out << "font.size=" << font.getSize() << std::endl;
  72 + out << "font.style=" << font.getStyle() << std::endl;
  73 + out << "font.weight=" << font.getWeight() << std::endl;
59 74 return out;
60 75 }
61 76  
... ...
src/ParamOutputImpl/Plot/Font.hh
... ... @@ -12,6 +12,7 @@
12 12 #include <vector>
13 13 #include <plplot/plstream.h>
14 14 #include <ostream>
  15 +#include <boost/algorithm/string/trim.hpp>
15 16  
16 17 namespace plot {
17 18  
... ... @@ -19,8 +20,12 @@ typedef std::pair&lt;double, double&gt; CharSize;
19 20  
20 21 class Font {
21 22 public:
22   - enum Style {
23   - BOLD, ITALIC, NORMAL
  23 + enum class Style {
  24 + NORMAL, ITALIC, OBLIQUE
  25 + };
  26 +
  27 + enum class Weight {
  28 + NORMAL, BOLD
24 29 };
25 30  
26 31 Font(const std::string& pname, int psize);
... ... @@ -29,11 +34,6 @@ public:
29 34  
30 35 virtual ~Font();
31 36  
32   - std::string _name;
33   - int _size;
34   - int _style;
35   - int _weight;
36   -
37 37 static const std::vector<std::string> sFamily;
38 38 static const std::vector<std::string> sStyle;
39 39 static const std::vector<std::string> sWeight;
... ... @@ -43,29 +43,77 @@ public:
43 43 }
44 44  
45 45 static Style getStyleByStr(std::string style) {
46   - if (style == "italic") {
  46 + boost::trim(style);
  47 + if (style.compare("italic") == 0) {
47 48 return Style::ITALIC;
48   - } else if (style == "bold") {
49   - return Style::BOLD;
  49 + }
  50 + else if (style.compare("oblique") == 0) {
  51 + return Style::OBLIQUE;
50 52 }
51 53 return Style::NORMAL;
52 54 }
53 55  
  56 + static Weight getWeightByStr(std::string weight) {
  57 + boost::trim(weight);
  58 + if (weight.compare("bold") == 0) {
  59 + return Weight::BOLD;
  60 + }
  61 + return Weight::NORMAL;
  62 + }
  63 +
54 64 void setName (const std::string & name);
55 65 void setSize (int size);
56   - void setStyle (const std::string & style);
57   - void setWeight (const std::string & weight);
58   -
59   - void dump(std::ostream& out, std::string& prefix) {
60   - out << prefix << ".font.name=" << _name << std::endl;
61   - out << prefix << ".font.size=" << _size << std::endl;
62   - out << prefix << ".font.style=" << sStyle[_style] << std::endl;
63   - out << prefix << ".font.weight=" << sWeight[_weight] << std::endl;
64   - }
  66 + void setStyle (Style style);
  67 + void setWeight (Weight weight);
  68 +
  69 + std::string getName() const;
  70 + int getSize() const;
  71 + Style getStyle() const;
  72 + Weight getWeight() const;
65 73  
  74 + void dump(std::ostream& out, std::string& prefix);
  75 +
  76 +private:
  77 + std::string _name;
  78 + int _size;
  79 + Style _style;
  80 + Weight _weight;
66 81  
67 82 };
68 83  
  84 +inline std::ostream& operator <<(std::ostream& out,
  85 + Font::Style const & style) {
  86 + std::string strStyle;
  87 + switch (style) {
  88 + case Font::Style::ITALIC:
  89 + strStyle = "italic";
  90 + break;
  91 + case Font::Style::OBLIQUE:
  92 + strStyle = "oblique";
  93 + break;
  94 + case Font::Style::NORMAL:
  95 + default:
  96 + strStyle = "normal";
  97 + }
  98 + out << strStyle;
  99 + return out;
  100 +}
  101 +
  102 +inline std::ostream& operator <<(std::ostream& out,
  103 + Font::Weight const & weight) {
  104 + std::string strWeight;
  105 + switch (weight) {
  106 + case Font::Weight::BOLD:
  107 + strWeight = "bold";
  108 + break;
  109 + case Font::Weight::NORMAL:
  110 + default:
  111 + strWeight = "normal";
  112 + }
  113 + out << strWeight;
  114 + return out;
  115 +}
  116 +
69 117 std::ostream& operator << (std::ostream& out, const Font& font);
70 118  
71 119 } /* namespace plot */
... ...
src/ParamOutputImpl/Plot/IntervalTickProperties.hh
... ... @@ -79,13 +79,6 @@ public:
79 79 _font = font;
80 80 }
81 81  
82   - void setFontStyle(Font::Style fontStyle) {
83   - _font._style = fontStyle;
84   - }
85   -
86   - void setFontWeight(int fontWeight) {
87   - _font._weight = fontWeight;
88   - }
89 82  
90 83 SymbolProperties& getSymbol() {
91 84 return _symbol;
... ...
src/ParamOutputImpl/Plot/Label.cc
... ... @@ -16,10 +16,10 @@ namespace plot {
16 16 const std::string Label::DELIMITER = "/breakline/";
17 17  
18 18 LabelRowInfo Label::getRowNumber(Label const& pLegend) {
19   - LabelRowInfo lSplittedLegend(new std::vector<std::string>());
  19 + LabelRowInfo lSplittedLegend;
20 20  
21 21 if (!pLegend._text.empty()) {
22   - boost::split_regex(*lSplittedLegend.get(), pLegend._text,
  22 + boost::split_regex(lSplittedLegend, pLegend._text,
23 23 boost::regex(Label::DELIMITER));
24 24 }
25 25  
... ... @@ -27,32 +27,11 @@ LabelRowInfo Label::getRowNumber(Label const&amp; pLegend) {
27 27 }
28 28  
29 29 void Label::dump(std::ostream& out, std::string& prefix) {
30   - prefix += "label.";
31   - out << prefix << "font.name=" << _font._name << std::endl;
32   - out << prefix << "font.size=" << _font._size << std::endl;
33   - out << prefix << "style=";
34   - std::string styleStr;
35   - for (size_t i = 0; i < _style.size(); ++i) {
36   - Font::Style style = _style[i];
37   - switch (style) {
38   - case Font::Style::BOLD:
39   - styleStr += "bold";
40   - break;
41   - case Font::Style::ITALIC:
42   - styleStr += "italic";
43   - break;
44   - case Font::Style::NORMAL:
45   - default:
46   - styleStr += "normal";
47   - }
48   - if (i < _style.size() - 1) {
49   - styleStr += ",";
50   - }
51   - }
52   - out << styleStr << std::endl;
53   - out << prefix << "text=" << _text << std::endl;
54   - _color.dump(out, prefix);
55   - }
  30 + prefix += "label.";
  31 + out << prefix << "text=" << _text;
  32 + out << prefix << "color=" << _color;
  33 + _font.dump(out, prefix);
  34 +}
56 35  
57 36 }
58 37  
... ...
src/ParamOutputImpl/Plot/Label.hh
... ... @@ -14,7 +14,7 @@
14 14 #include <boost/shared_ptr.hpp>
15 15  
16 16 namespace plot {
17   -typedef boost::shared_ptr<std::vector<std::string>> LabelRowInfo;
  17 +typedef std::vector<std::string> LabelRowInfo;
18 18  
19 19 class Label {
20 20 public:
... ... @@ -33,8 +33,7 @@ public:
33 33 }
34 34  
35 35 Label(const Label& label) :
36   - _style(label._style), _text(
37   - label._text), _color(label._color), _font(label._font) {
  36 + _text(label._text), _color(label._color), _font(label._font) {
38 37 }
39 38  
40 39 virtual ~Label() {
... ... @@ -48,25 +47,12 @@ public:
48 47 _font = font;
49 48 }
50 49  
51   - void setFontStyle(Font::Style fontStyle) {
52   - _font._style = fontStyle;
53   - }
54   -
55   - void setFontWeight(int fontWeight) {
56   - _font._weight = fontWeight;
57   - }
58   -
59 50 /**
60 51 * @brief Determine number of line that compose label.
61 52 */
62 53 static LabelRowInfo getRowNumber(Label const& pLegend);
63 54  
64 55 /**
65   - * Label style.
66   - */
67   - std::vector<Font::Style> _style;
68   -
69   - /**
70 56 * Label text.
71 57 */
72 58 std::string _text;
... ... @@ -88,56 +74,13 @@ private:
88 74 Font _font;
89 75 };
90 76  
91   -inline std::ostream& operator <<(std::ostream& out,
92   - Font::Style const & style) {
93   -
94   - std::string strStyle;
95   - switch (style) {
96   - case Font::Style::BOLD:
97   - strStyle = "bold";
98   - break;
99   - case Font::Style::ITALIC:
100   - strStyle = "italic";
101   - break;
102   - case Font::Style::NORMAL:
103   - default:
104   - strStyle = "normal";
105   - }
106   - out << strStyle;
107   - return out;
108   -}
109   -
110   -inline std::ostream& operator <<(std::ostream& out,
111   - std::vector<Font::Style>const & styles) {
112   - std::string styleStr;
113   - for (size_t i = 0; i < styles.size(); ++i) {
114   - Font::Style style = styles[i];
115   - switch (style) {
116   - case Font::Style::BOLD:
117   - styleStr += "bold";
118   - break;
119   - case Font::Style::ITALIC:
120   - styleStr += "italic";
121   - break;
122   - case Font::Style::NORMAL:
123   - default:
124   - styleStr += "normal";
125   - }
126   - if (i < styles.size() - 1) {
127   - styleStr += ",";
128   - }
129   - }
130   - out << styleStr;
131   - return out;
132   -}
133   -
134 77 inline std::ostream& operator <<(std::ostream& out, Label& label) {
135 78 out << "[LABEL]" << std::endl;
136   - out << "label.font.name=" << label.getFont()._name << std::endl;
137   - out << "label.font.size=" << label.getFont()._size << std::endl;
138   - out << "label.style=" << label._style << std::endl;
139   - out << "label.text=" << label._text << std::endl;
140   - out << "label.color=" << label._color << std::endl;
  79 + out << "label.text=" << label._text;
  80 + out << "label.color=" << label._color;
  81 + std::string prefix = "label";
  82 + Font font = label.getFont();
  83 + font.dump(out, prefix);
141 84 return out;
142 85 }
143 86  
... ...
src/ParamOutputImpl/Plot/Page.cc
... ... @@ -224,15 +224,15 @@ void Page::getDrawableBoundsInPlPage(Bounds&amp; pBounds) {
224 224  
225 225  
226 226 LabelRowInfo titleRows(Label::getRowNumber(_title));
227   - if (!titleRows->empty()) {
  227 + if (!titleRows.empty()) {
228 228 //Reserve title space
229 229 CharSize lCharSizeTitle;
230 230  
231 231 Font titleFont(getTitleFont());
232   - PlPlotUtil::setPlFont(titleFont, &_title._style);
  232 + PlPlotUtil::setPlFont(titleFont);
233 233 lCharSizeTitle = PlPlotUtil::getCharacterSizeInPlPage(this);
234 234  
235   - double titleHeight = (titleRows->size() + PlPlotUtil::LINE_SPACE_TITLE * (titleRows->size() + 1)) * lCharSizeTitle.second;
  235 + double titleHeight = (titleRows.size() + PlPlotUtil::LINE_SPACE_TITLE * (titleRows.size() + 1)) * lCharSizeTitle.second;
236 236  
237 237 switch (_titlePosition) {
238 238 case PlotCommon::Position::POS_TOP :
... ... @@ -356,7 +356,7 @@ void Page::drawTitle(std::shared_ptr&lt;plstream&gt;&amp; pls) {
356 356 plgpage (&p_xp, &p_yp, &p_xleng, &p_yleng, &p_xoff, &p_yoff);
357 357  
358 358 LabelRowInfo titleRows(Label::getRowNumber(_title));
359   - if (titleRows->empty())
  359 + if (titleRows.empty())
360 360 return;
361 361  
362 362 Bounds drawableBounds;
... ... @@ -371,7 +371,7 @@ void Page::drawTitle(std::shared_ptr&lt;plstream&gt;&amp; pls) {
371 371 // use page font if title font is not set
372 372 Font titleFont(getTitleFont());
373 373  
374   - PlPlotUtil::setPlFont(titleFont, &_title._style);
  374 + PlPlotUtil::setPlFont(titleFont);
375 375  
376 376 pls->mtex(getPlSide(_titlePosition).c_str(), 0.5 + PlPlotUtil::LINE_SPACE_TITLE, getPlPos(_titleAlign),
377 377 getPlJust(_titleAlign), _title._text.c_str());
... ...
src/ParamOutputImpl/Plot/Page.hh
... ... @@ -76,14 +76,6 @@ public:
76 76 _font = font;
77 77 }
78 78  
79   - void setFontStyle(Font::Style fontStyle) {
80   - _font._style = fontStyle;
81   - }
82   -
83   - void setFontWeight(int fontWeight) {
84   - _font._weight = fontWeight;
85   - }
86   -
87 79 Label* getTitle() {
88 80 return &_title;
89 81 }
... ... @@ -98,10 +90,10 @@ public:
98 90  
99 91 Font getTitleFont() {
100 92 Font titleFont(_title.getFont());
101   - if (titleFont._name == "")
102   - titleFont._name = _font._name;
103   - if (titleFont._size == 0)
104   - titleFont._size = _font._size;
  93 + if (titleFont.getName() == "")
  94 + titleFont.setName(_font.getName());
  95 + if (titleFont.getSize() == 0)
  96 + titleFont.setSize(_font.getSize());
105 97 return titleFont;
106 98 }
107 99  
... ...
src/ParamOutputImpl/Plot/Panel.cc
... ... @@ -84,10 +84,10 @@ Panel::Panel(Page* page) :
84 84 _bottomMargin(DefaultPlotConfiguration::getInstance()._defaultPanel._bottomMargin),
85 85 _textLegendPropertiesList(DefaultPlotConfiguration::getInstance()._defaultPanel._textLegendPropertiesList),
86 86 _font(Font(
87   - DefaultPlotConfiguration::getInstance()._defaultPanel.getFont()._name.empty() ?
88   - page->getFont()._name : DefaultPlotConfiguration::getInstance()._defaultPanel.getFont()._name,
89   - DefaultPlotConfiguration::getInstance()._defaultPanel.getFont()._size != 0 ?
90   - DefaultPlotConfiguration::getInstance()._defaultPanel.getFont()._size : page->getFont()._size)),
  87 + DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getName().empty() ?
  88 + page->getFont().getName() : DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getName(),
  89 + DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getSize() != 0 ?
  90 + DefaultPlotConfiguration::getInstance()._defaultPanel.getFont().getSize() : page->getFont().getSize())),
91 91 _title(_font)
92 92 {
93 93 }
... ... @@ -98,25 +98,25 @@ Panel::~Panel() {
98 98  
99 99 Font Panel::getTitleFont() {
100 100 Font titleFont(_title.getFont());
101   - if (titleFont._name == "")
102   - titleFont._name = _font._name;
103   - if (titleFont._size == 0)
104   - titleFont._size = _font._size;
  101 + if (titleFont.getName() == "")
  102 + titleFont.setName(_font.getName());
  103 + if (titleFont.getSize() == 0)
  104 + titleFont.setSize(_font.getSize());
105 105 return titleFont;
106 106 }
107 107  
108 108 void Panel::reserveSpaceForTitle(double& topSpace, double& bottomSpace, double& titleHeight) {
109 109 LabelRowInfo titleRows(Label::getRowNumber(_title));
110   - if (titleRows->empty())
  110 + if (titleRows.empty())
111 111 return;
112 112  
113 113 CharSize lCharSizeTitle;
114 114  
115 115 Font titleFont(getTitleFont());
116   - PlPlotUtil::setPlFont(titleFont, &_title._style);
  116 + PlPlotUtil::setPlFont(titleFont);
117 117 lCharSizeTitle = PlPlotUtil::getCharacterSizeInPlPage(_page);
118 118  
119   - titleHeight = (titleRows->size() + PlPlotUtil::LINE_SPACE_TITLE * (titleRows->size() + 1)) * lCharSizeTitle.second;
  119 + titleHeight = (titleRows.size() + PlPlotUtil::LINE_SPACE_TITLE * (titleRows.size() + 1)) * lCharSizeTitle.second;
120 120  
121 121 switch (_titlePosition)
122 122 {
... ... @@ -134,7 +134,7 @@ void Panel::reserveSpaceForTitle(double&amp; topSpace, double&amp; bottomSpace, double&amp;
134 134  
135 135 void Panel::drawTitle(std::shared_ptr<plstream>& pls) {
136 136 LabelRowInfo titleRows(Label::getRowNumber(_title));
137   - if (titleRows->empty())
  137 + if (titleRows.empty())
138 138 return;
139 139  
140 140 if ((_titlePosition != PlotCommon::Position::POS_TOP) && (_titlePosition != PlotCommon::Position::POS_BOTTOM))
... ... @@ -146,7 +146,7 @@ void Panel::drawTitle(std::shared_ptr&lt;plstream&gt;&amp; pls) {
146 146 Color lInitialColor = changeColor(pls, _title._color, _page->_mode);
147 147  
148 148 Font titleFont(getTitleFont());
149   - PlPlotUtil::setPlFont(titleFont, &_title._style);
  149 + PlPlotUtil::setPlFont(titleFont);
150 150  
151 151 // Specify viewport for the panel
152 152 pls->vpor(lBounds._x, lBounds._x + lBounds._width,
... ... @@ -155,7 +155,7 @@ void Panel::drawTitle(std::shared_ptr&lt;plstream&gt;&amp; pls) {
155 155 float lRowDisp = -0.5 - PlPlotUtil::LINE_SPACE_TITLE;
156 156  
157 157 // Draw each line of title
158   - for (auto row : *(titleRows.get())) {
  158 + for (auto row : titleRows) {
159 159 pls->mtex(
160 160 getPlSide(_titlePosition).c_str(),
161 161 lRowDisp,
... ...
src/ParamOutputImpl/Plot/Panel.hh
... ... @@ -99,14 +99,6 @@ public:
99 99 _font = font;
100 100 }
101 101  
102   - void setFontStyle(Font::Style fontStyle) {
103   - _font._style = fontStyle;
104   - }
105   -
106   - void setFontWeight(int fontWeight) {
107   - _font._weight = fontWeight;
108   - }
109   -
110 102 Label* getTitle() {
111 103 return &_title;
112 104 }
... ...
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... ... @@ -232,14 +232,14 @@ void PanelPlotOutput::reserveSpaceForAxis (boost::shared_ptr&lt;Axis&gt;&amp; pAxis, doubl
232 232 return;
233 233  
234 234 // Get number of line to draw for legend.
235   - LabelRowInfo lAxisLegendRowInfo(Label::getRowNumber(pAxis->_legend));
236   - int nbLegendRows = lAxisLegendRowInfo->size();
  235 + LabelRowInfo lAxisLegendRowInfo = AxisLegend::getRowNumber(pAxis->_legend);
  236 + int nbLegendRows = lAxisLegendRowInfo.size();
237 237 if ((nbLegendRows == 0) && pAxis->_showLegend)
238 238 nbLegendRows = 1;
239 239  
240 240 // Compute legend character size
241 241 Font legendFont(pAxis->getLegendFont(this->_panel.get()));
242   - PlPlotUtil::setPlFont(legendFont, &pAxis->_legend._style);
  242 + PlPlotUtil::setPlFont(legendFont);
243 243 CharSize legendCharSizePanel = PlPlotUtil::getCharacterSizeInPlPage(_panel->_page);
244 244  
245 245 std::tuple<float, float> pageSize = _panel->_page->getSizeInMm();
... ... @@ -274,7 +274,7 @@ void PanelPlotOutput::reserveSpaceForAxis (boost::shared_ptr&lt;Axis&gt;&amp; pAxis, doubl
274 274 if (!_panel->getTitle()->_text.empty() && (_panel->_titlePosition == PlotCommon::Position::POS_BOTTOM))
275 275 legendOffset -= titleHeight;
276 276 pAxis->setLegendOffset(legendOffset);
277   - bottomSpace += (lAxisLegendRowInfo->size() + PlPlotUtil::LINE_SPACE_TITLE * (nbLegendRows + 1)) * legendCharSizePanel.second;
  277 + bottomSpace += (lAxisLegendRowInfo.size() + PlPlotUtil::LINE_SPACE_TITLE * (nbLegendRows + 1)) * legendCharSizePanel.second;
278 278 }
279 279  
280 280 break;
... ... @@ -433,30 +433,31 @@ void PanelPlotOutput::computePanelPlotXYRatio (void) {
433 433 * @brief Draw legend for each axis.
434 434 */
435 435 void PanelPlotOutput::drawLegends(boost::shared_ptr<Axis>& pAxis, PlWindow& pPlWindow, Bounds& pPlotAreaSize) {
436   - LOG4CXX_DEBUG(gLogger, "Drawing legend for axis "<< pAxis->_id << " : " << pAxis->_legend._text);
  436 + LOG4CXX_DEBUG(gLogger, "Drawing legend for axis "<< pAxis->_id << " : " << pAxis->_legend.getText());
437 437  
438 438 // Set legend font
439 439 Font legendFont(pAxis->getLegendFont(this->_panel.get()));
440   - PlPlotUtil::setPlFont(legendFont, &pAxis->_legend._style);
  440 + PlPlotUtil::setPlFont(legendFont);
441 441  
442 442 // Get legend row info
443   - LabelRowInfo lAxisLegendRowInfo(Label::getRowNumber(pAxis->_legend));
  443 + LabelRowInfo lAxisLegendRowInfo = AxisLegend::getRowNumber(pAxis->_legend);
444 444  
445 445 // Check if there is something to draw !
446 446 if ((pAxis->_visible == true) &&
447 447 (pAxis->_showLegend == true) &&
448   - (lAxisLegendRowInfo->size() != 0)) {
  448 + (lAxisLegendRowInfo.size() != 0)) {
449 449  
450 450 Color lInitialColor;
451 451 // If legend has not it's own color set axis color.
452   - if ((pAxis->_legend._color._colorIndex == -1)
453   - && ((pAxis->_legend._color._red == -1)
454   - && (pAxis->_legend._color._green == -1)
455   - && (pAxis->_legend._color._blue == -1))) {
  452 + if ((pAxis->_legend.getColor()._colorIndex == -1)
  453 + && ((pAxis->_legend.getColor()._red == -1)
  454 + && (pAxis->_legend.getColor()._green == -1)
  455 + && (pAxis->_legend.getColor()._blue == -1))) {
456 456 lInitialColor = changeColor(_pls, pAxis->_color,
457 457 _panel->_page->_mode);
458 458 } else {
459   - lInitialColor = changeColor(_pls, pAxis->_legend._color,
  459 + Color legendColor = pAxis->_legend.getColor();
  460 + lInitialColor = changeColor(_pls, legendColor,
460 461 _panel->_page->_mode);
461 462 }
462 463  
... ... @@ -476,9 +477,9 @@ void PanelPlotOutput::drawLegends(boost::shared_ptr&lt;Axis&gt;&amp; pAxis, PlWindow&amp; pPlW
476 477 std::get<2>(pPlWindow), std::get<3>(pPlWindow));
477 478  
478 479 // Draw lines, beginning by the first one
479   - for (int r=0; r< (int) lAxisLegendRowInfo->size(); r++) {
480   - std::string lineToDraw = lAxisLegendRowInfo->at(r);
481   - if (r == (int)lAxisLegendRowInfo->size() - 1)
  480 + for (int r=0; r< (int) lAxisLegendRowInfo.size(); r++) {
  481 + std::string lineToDraw = lAxisLegendRowInfo.at(r);
  482 + if (r == (int)lAxisLegendRowInfo.size() - 1)
482 483 {
483 484 //add unit if defined
484 485 if (!pAxis->getAxisUnits().empty())
... ... @@ -503,9 +504,9 @@ void PanelPlotOutput::drawLegends(boost::shared_ptr&lt;Axis&gt;&amp; pAxis, PlWindow&amp; pPlW
503 504 std::get<2>(pPlWindow), std::get<3>(pPlWindow));
504 505  
505 506 // Draw lines, beginning by the last one
506   - for (int r=(lAxisLegendRowInfo->size() - 1); r>=0; r--) {
507   - std::string lineToDraw = lAxisLegendRowInfo->at(r);
508   - if (r == (int)lAxisLegendRowInfo->size() - 1)
  507 + for (int r=(lAxisLegendRowInfo.size() - 1); r>=0; r--) {
  508 + std::string lineToDraw = lAxisLegendRowInfo.at(r);
  509 + if (r == (int)lAxisLegendRowInfo.size() - 1)
509 510 {
510 511 //add unit if defined
511 512 if (!pAxis->getAxisUnits().empty())
... ... @@ -531,9 +532,9 @@ void PanelPlotOutput::drawLegends(boost::shared_ptr&lt;Axis&gt;&amp; pAxis, PlWindow&amp; pPlW
531 532 std::get<2>(pPlWindow), std::get<3>(pPlWindow));
532 533  
533 534 // Draw lines, beginning by the first one
534   - for (int r=0; r< (int) lAxisLegendRowInfo->size(); r++) {
535   - std::string lineToDraw = lAxisLegendRowInfo->at(r);
536   - if (r == (int)lAxisLegendRowInfo->size() - 1)
  535 + for (int r=0; r< (int) lAxisLegendRowInfo.size(); r++) {
  536 + std::string lineToDraw = lAxisLegendRowInfo.at(r);
  537 + if (r == (int)lAxisLegendRowInfo.size() - 1)
537 538 {
538 539 //add unit if defined
539 540 if (!pAxis->getAxisUnits().empty())
... ... @@ -560,9 +561,9 @@ void PanelPlotOutput::drawLegends(boost::shared_ptr&lt;Axis&gt;&amp; pAxis, PlWindow&amp; pPlW
560 561 std::get<2>(pPlWindow), std::get<3>(pPlWindow));
561 562  
562 563 // Draw lines, beginning by the last one
563   - for (int r=(lAxisLegendRowInfo->size() - 1); r>=0; r--) {
564   - std::string lineToDraw = lAxisLegendRowInfo->at(r);
565   - if (r == (int)lAxisLegendRowInfo->size() - 1)
  564 + for (int r=(lAxisLegendRowInfo.size() - 1); r>=0; r--) {
  565 + std::string lineToDraw = lAxisLegendRowInfo.at(r);
  566 + if (r == (int)lAxisLegendRowInfo.size() - 1)
566 567 {
567 568 //add unit if defined
568 569 if (!pAxis->getAxisUnits().empty())
... ... @@ -872,8 +873,8 @@ double PanelPlotOutput::estimateZAxisWidth(boost::shared_ptr&lt;Axis&gt; pZAxis)
872 873 PlPlotUtil::setPlFont(_panel->getFont());
873 874 CharSize lCharSize = PlPlotUtil::getCharacterSizeInPlPage(_panel->_page);
874 875  
875   - LabelRowInfo lAxisLegendRowInfo(Label::getRowNumber(pZAxis->_legend));
876   - int nbLineLegend = lAxisLegendRowInfo->size();
  876 + LabelRowInfo lAxisLegendRowInfo = AxisLegend::getRowNumber(pZAxis->_legend);
  877 + int nbLineLegend = lAxisLegendRowInfo.size();
877 878  
878 879 if ((pZAxis->_showLegend == true) && (nbLineLegend != 0))
879 880 {
... ... @@ -901,7 +902,7 @@ void PanelPlotOutput::drawZAxis(boost::shared_ptr&lt;Axis&gt; pZAxis, PlWindow&amp; pPlWin
901 902 PlPlotUtil::setPlFont(_panel->getFont());
902 903  
903 904 std::string lAxisOption = pZAxis->getPlotOpt();
904   - std::string lAxisLegend = pZAxis->_legend._text;
  905 + std::string lAxisLegend = pZAxis->_legend.getText();
905 906  
906 907 PLFLT colorbar_width, colorbar_height;
907 908 const int cont_color = 0;
... ...
src/ParamOutputImpl/Plot/PanelPlotOutput.hh
... ... @@ -487,6 +487,13 @@ protected:
487 487 AMDA::Common::ParameterIndexComponent& index, std::string originalParamId);
488 488  
489 489 /**
  490 + * @brief Reset cursor used to attribute automatically a color to a serie
  491 + */
  492 + void resetAutomaticSerieColorCursor() {
  493 + _automaticSerieColorCursor = 0;
  494 + }
  495 +
  496 + /**
490 497 * @brief plplot stream
491 498 */
492 499 std::shared_ptr<plstream> _pls;
... ...
src/ParamOutputImpl/Plot/ParamsLegendProperties.hh
... ... @@ -179,14 +179,6 @@ namespace plot
179 179 */
180 180 Font& getFont(void);
181 181  
182   - void setFontStyle(Font::Style fontStyle) {
183   - _font._style = fontStyle;
184   - }
185   -
186   - void setFontWeight(int fontWeight) {
187   - _font._weight = fontWeight;
188   - }
189   -
190 182 /*
191 183 * @brief Set default text color
192 184 */
... ...
src/ParamOutputImpl/Plot/PlPlotUtil.cc
... ... @@ -22,10 +22,10 @@
22 22 * @brief Set font to plPlot.
23 23 * @return
24 24 */
25   - void PlPlotUtil::setPlFont(const Font& font, std::vector<Font::Style> *styles) {
  25 + void PlPlotUtil::setPlFont(const Font& font) {
26 26 plsfont(PlPlotUtil::getPlFontFamily(font),
27   - (styles != NULL) ? PlPlotUtil::getPlFontStyle(*styles) : font._style,
28   - (styles != NULL) ? PlPlotUtil::getPlFontWeight(*styles) : font._weight);
  27 + PlPlotUtil::getPlFontStyle(font),
  28 + PlPlotUtil::getPlFontWeight(font));
29 29 plschr(getPlFontDef(font), PlPlotUtil::getPlFontScaleFactor(font));
30 30 }
31 31  
... ... @@ -58,7 +58,7 @@
58 58  
59 59 PLINT PlPlotUtil::getPlFontFamily(const Font& font) {
60 60 for (size_t i = 0; i < Font::sFamily.size(); ++i) {
61   - if (Font::sFamily[i] == font._name) {
  61 + if (Font::sFamily[i] == font.getName()) {
62 62 return i;
63 63 }
64 64 }
... ... @@ -66,34 +66,30 @@
66 66 }
67 67  
68 68 PLFLT PlPlotUtil::getPlFontScaleFactor(const Font& font) {
69   - return (float) font._size / PlPlotUtil::DEFAULT_CHARACTER_SIZE;
  69 + return (float) font.getSize() / PlPlotUtil::DEFAULT_CHARACTER_SIZE;
70 70 }
71 71  
72 72 PLFLT PlPlotUtil::getPlFontDef(const Font& /*font*/) {
73 73 return 0.0; // keep default font
74 74 }
75 75  
76   - PLINT PlPlotUtil::getPlFontStyle(const std::vector<Font::Style>& styles) {
77   - for (auto style : styles) {
78   - std::ostringstream strStyle;
79   - strStyle << style;
80   - for (size_t i = 0; i < Font::sStyle.size(); ++i) {
81   - if (Font::sStyle[i] == strStyle.str()) {
82   - return i;
83   - }
  76 + PLINT PlPlotUtil::getPlFontStyle(const Font& font) {
  77 + std::ostringstream strStyle;
  78 + strStyle << font.getStyle();
  79 + for (size_t i = 0; i < Font::sStyle.size(); ++i) {
  80 + if (Font::sStyle[i] == strStyle.str()) {
  81 + return i;
84 82 }
85 83 }
86 84 return 0; // upright
87 85 }
88   - PLINT PlPlotUtil::getPlFontWeight(const std::vector<Font::Style>& styles) {
89   - for (auto style : styles) {
90   - std::ostringstream strStyle;
91   - strStyle << style;
92   - for (size_t i = 0; i < Font::sWeight.size(); ++i) {
93   - if (Font::sWeight[i] == strStyle.str()) {
94   - return i;
95   - }
96   - }
  86 + PLINT PlPlotUtil::getPlFontWeight(const Font& font) {
  87 + std::ostringstream strWeight;
  88 + strWeight << font.getWeight();
  89 + for (size_t i = 0; i < Font::sWeight.size(); ++i) {
  90 + if (Font::sWeight[i] == strWeight.str()) {
  91 + return i;
  92 + }
97 93 }
98 94 return 0; // medium
99 95 }
... ...
src/ParamOutputImpl/Plot/PlPlotUtil.hh
... ... @@ -28,7 +28,7 @@ public:
28 28 * @brief Set font to plPlot.
29 29 * @return
30 30 */
31   - static void setPlFont(const Font& font, std::vector<Font::Style> *styles = NULL);
  31 + static void setPlFont(const Font& font);
32 32  
33 33 /**
34 34 * @brief Calculate character height and width.
... ... @@ -43,9 +43,9 @@ public:
43 43  
44 44 static PLFLT getPlFontDef(const Font& font);
45 45  
46   - static PLINT getPlFontStyle(const std::vector<Font::Style>& styles);
  46 + static PLINT getPlFontStyle(const Font& font);
47 47  
48   - static PLINT getPlFontWeight(const std::vector<Font::Style>& styles);
  48 + static PLINT getPlFontWeight(const Font& font);
49 49 };
50 50  
51 51 } /* namespace plot */
... ...
src/ParamOutputImpl/Plot/StatusPlot/StatusBarDecorator.cc
... ... @@ -75,11 +75,11 @@ void StatusBarDecorator::updatePlotArea(PanelPlotOutput* pplot_, Axis* axis_, Bo
75 75 // calculate char size for labels:
76 76 Font legendFont(pAxis->_legend.getFont());
77 77 Font panelFont(pplot_->_panel->getFont());
78   - if (legendFont._size == 0) {
  78 + if (!legendFont.isSet()) {
79 79 legendFont = panelFont;
80 80 }
81 81  
82   - PlPlotUtil::setPlFont(legendFont, &pAxis->_legend._style);
  82 + PlPlotUtil::setPlFont(legendFont);
83 83 CharSize legendSize = PlPlotUtil::getCharacterSizeInPlPage(pplot_->_panel->_page);
84 84  
85 85 double barSpace = 0;
... ... @@ -172,12 +172,10 @@ void StatusBarDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_,
172 172 std::vector<Font::Style> panelStyles;
173 173 Font panelFont(pplot_->_panel->getFont());
174 174  
175   - std::vector<Font::Style> legendStyles(pAxis->_legend._style);
176 175 Font legendFont(pAxis->_legend.getFont());
177   - if (legendFont._size == 0) {
  176 + if (!legendFont.isSet()) {
178 177 // font has not been defined for that axis, used default panel font :
179 178 legendFont = panelFont;
180   - legendStyles = panelStyles;
181 179 }
182 180  
183 181  
... ... @@ -195,7 +193,7 @@ void StatusBarDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_,
195 193 delta += getVerticalTickLength(pAxis, panelCharSize.second);
196 194  
197 195 //add space for time axis
198   - if (pAxis->_visible && (_barPosition == pAxis->_position) && pAxis->_showLegend && !pAxis->_legend._text.empty())
  196 + if (pAxis->_visible && (_barPosition == pAxis->_position) && pAxis->_showLegend && !pAxis->_legend.isEmpty())
199 197 {
200 198 delta += 3*panelCharSize.second;
201 199 }
... ... @@ -302,7 +300,7 @@ void StatusBarDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_,
302 300 pls_->box("bc", 0, 0, "bc", 0, 0);
303 301  
304 302 //draw legend
305   - PlPlotUtil::setPlFont(legendFont, &legendStyles);
  303 + PlPlotUtil::setPlFont(legendFont);
306 304 std::string legendText = _barInfoList[i]._name;
307 305 legendText += ": ";
308 306 //plot parameter name
... ...
src/ParamOutputImpl/Plot/TextLegendProperties.hh
... ... @@ -33,14 +33,6 @@ namespace plot
33 33  
34 34 Font& getFont(void);
35 35  
36   - void setFontStyle(Font::Style fontStyle) {
37   - _font._style = fontStyle;
38   - }
39   -
40   - void setFontWeight(int fontWeight) {
41   - _font._weight = fontWeight;
42   - }
43   -
44 36 void setPosition(TextLegendPosition position);
45 37 TextLegendPosition getPosition(void);
46 38  
... ...
src/ParamOutputImpl/Plot/TextPlot.hh
... ... @@ -72,14 +72,6 @@ public:
72 72 _font = font;
73 73 }
74 74  
75   - void setFontStyle(Font::Style fontStyle) {
76   - _font._style = fontStyle;
77   - }
78   -
79   - void setFontWeight(int fontWeight) {
80   - _font._weight = fontWeight;
81   - }
82   -
83 75 void reset()
84 76 {
85 77 _drawn = false;
... ...
src/ParamOutputImpl/Plot/TickPlot/TickMarkDecorator.cc
... ... @@ -81,7 +81,7 @@ void TickMarkDecorator::updatePlotArea(PanelPlotOutput* pplot_, Axis* axis_, Bou
81 81 // calculate char size for labels:
82 82 Font legendFont(pAxis->_legend.getFont());
83 83 Font panelFont(pplot_->_panel->getFont());
84   - if (legendFont._size == 0) {
  84 + if (!legendFont.isSet()) {
85 85 legendFont = panelFont;
86 86 }
87 87  
... ... @@ -121,7 +121,7 @@ void TickMarkDecorator::updatePlotArea(PanelPlotOutput* pplot_, Axis* axis_, Bou
121 121 // reserve same space amount in both side (since text are centered on ticks, only half length is taken into account).
122 122 double minspaceleft = std::max((const int) (_pTimeInfo->_maxLen + 1),
123 123 (const int) _maxValueLen + 1);
124   - if (legendFont._size > panelFont._size) {
  124 + if (legendFont.getSize() > panelFont.getSize()) {
125 125 minspaceleft *= legendSize.first;
126 126 } else {
127 127 PlPlotUtil::setPlFont(panelFont);
... ... @@ -256,12 +256,10 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_,
256 256 std::vector<Font::Style> panelStyles;
257 257 Font panelFont(pplot_->_panel->getFont());
258 258  
259   - std::vector<Font::Style> legendStyles(pAxis->_legend._style);
260 259 Font legendFont(pAxis->_legend.getFont());
261   - if (legendFont._size == 0) {
  260 + if (!legendFont.isSet()) {
262 261 // font has not been defined for that axis, used default panel font :
263 262 legendFont = panelFont;
264   - legendStyles = panelStyles;
265 263 }
266 264  
267 265  
... ... @@ -281,7 +279,7 @@ void TickMarkDecorator::draw(PanelPlotOutput* pplot_, Axis* axis_,
281 279 int end;
282 280 int dir;
283 281  
284   - PlPlotUtil::setPlFont(legendFont, &legendStyles);
  282 + PlPlotUtil::setPlFont(legendFont);
285 283  
286 284 if (pAxis->_position == PlotCommon::POS_TOP) {
287 285 options = "mxo"; // options means : m=display above axe, x=do not plot ticks, o=user label function provided.
... ... @@ -347,10 +345,11 @@ void TickMarkDecorator::installLabelGenerator(PanelPlotOutput* /*pplot_*/, TimeA
347 345  
348 346 LOG4CXX_TRACE(_logger, "installing LabelGenerator function");
349 347 // axis label :
350   - LOG4CXX_TRACE(_logger, "processing axis : "<< timeAxis_->_legend._text);
  348 + LOG4CXX_TRACE(_logger, "processing axis : "<< timeAxis_->_legend.getText());
351 349 // install time format
352 350 _pTimeInfo->_timeFormat = getPlFormat();
353   - _pTimeInfo->_timeTitle = timeAxis_->_legend._text;
  351 + _pTimeInfo->_timeTitle = timeAxis_->_legend.getText();
  352 +LOG4CXX_DEBUG(_logger, "BRE - " << _pTimeInfo->_timeTitle)
354 353 _pTimeInfo->_isFirstLabel = true;
355 354  
356 355 unsigned int maxNameLen = _pTimeInfo->_timeTitle.size();
... ... @@ -412,7 +411,7 @@ void TickMarkDecorator::installLabelGenerator(PanelPlotOutput* /*pplot_*/, TimeA
412 411 }
413 412  
414 413 // no legend for this axe since it is displayed at axis origin:
415   - timeAxis_->_legend._text = ""; //titles.str();
  414 + timeAxis_->_legend.clearLabels();
416 415  
417 416 // install label generator for main axe (the one that is displayed)
418 417 timeAxis_->_labelGenerator->_data = _pTimeInfo.get();
... ...
src/ParamOutputImpl/Plot/Time/DefaultTimeAxisDecorator.cc
... ... @@ -39,7 +39,7 @@ void DefaultTimeAxisDecorator::updatePlotArea( PanelPlotOutput* pplot_,Axis* axi
39 39 // Only if panel font size is not twice time high than legend font size.
40 40 if ((pAxis->_showLegend == true) &&
41 41 (pAxis->_showTickMark == true) &&
42   - (pAxis->_legend._text.empty() == true)) {
  42 + (pAxis->_legend.isEmpty() == true)) {
43 43 lBottomSpace += panelCharHeight * 2;
44 44 }
45 45 }
... ...
src/ParamOutputImpl/Plot/TimeTickProperties.hh
... ... @@ -75,14 +75,6 @@ public:
75 75 _font = font;
76 76 }
77 77  
78   - void setFontStyle(Font::Style fontStyle) {
79   - _font._style = fontStyle;
80   - }
81   -
82   - void setFontWeight(int fontWeight) {
83   - _font._weight = fontWeight;
84   - }
85   -
86 78 int getMinor() const {
87 79 return _minor;
88 80 }
... ...