Commit ac0e4b166e1a21aff8cbb0bc0550a017ee7f3b87
1 parent
9eb08cf7
Exists in
master
and in
49 other branches
Some modifications
Showing
5 changed files
with
51 additions
and
163 deletions
Show diff stats
config/xsd/request/plot.xsd
... | ... | @@ -115,6 +115,28 @@ |
115 | 115 | </xs:element> |
116 | 116 | </xs:sequence> |
117 | 117 | </xs:complexType> |
118 | + | |
119 | + <xs:complexType name="TextLegendType"> | |
120 | + <xs:sequence> | |
121 | + <xs:element name="font" type="FontType" | |
122 | + minOccurs="0" maxOccurs="1"> | |
123 | + </xs:element> | |
124 | + </xs:sequence> | |
125 | + <xs:attribute name="text" type="xs:string"> | |
126 | + </xs:attribute> | |
127 | + <xs:attribute name="position"> | |
128 | + <xs:simpleType> | |
129 | + <xs:restriction base="xs:string"> | |
130 | + <xs:enumeration value="right" /> | |
131 | + <xs:enumeration value="left" /> | |
132 | + <xs:enumeration value="top" /> | |
133 | + <xs:enumeration value="bottom" /> | |
134 | + </xs:restriction> | |
135 | + </xs:simpleType> | |
136 | + </xs:attribute> | |
137 | + <xs:attribute name="color" type="xs:string"> | |
138 | + </xs:attribute> | |
139 | + </xs:complexType> | |
118 | 140 | |
119 | 141 | <xs:complexType name="PlotLegendType"> |
120 | 142 | <xs:annotation> |
... | ... | @@ -161,30 +183,7 @@ |
161 | 183 | <xs:attribute name="borderColor" type="xs:string" /> |
162 | 184 | </xs:complexType> |
163 | 185 | </xs:element> |
164 | - <xs:element name="textLegend" minOccurs="0" maxOccurs="unbounded"> | |
165 | - <xs:complexType> | |
166 | - <xs:sequence> | |
167 | - <xs:element name="font" type="FontType" | |
168 | - minOccurs="0" maxOccurs="1"> | |
169 | - </xs:element> | |
170 | - </xs:sequence> | |
171 | - <xs:attribute name="text" type="xs:string"> | |
172 | - </xs:attribute> | |
173 | - <xs:attribute name="position"> | |
174 | - <xs:simpleType> | |
175 | - <xs:restriction base="xs:string"> | |
176 | - <xs:enumeration value="right" /> | |
177 | - <xs:enumeration value="left" /> | |
178 | - <xs:enumeration value="top" /> | |
179 | - <xs:enumeration value="bottom" /> | |
180 | - </xs:restriction> | |
181 | - </xs:simpleType> | |
182 | - </xs:attribute> | |
183 | - <xs:attribute name="color" | |
184 | - type="xs:string"> | |
185 | - </xs:attribute> | |
186 | - </xs:complexType> | |
187 | - </xs:element> | |
186 | + <xs:element name="textLegend" type="TextLegendType" minOccurs="0" maxOccurs="unbounded"/> | |
188 | 187 | </xs:sequence> |
189 | 188 | </xs:complexType> |
190 | 189 | |
... | ... | @@ -874,12 +873,11 @@ |
874 | 873 | </xs:complexType> |
875 | 874 | |
876 | 875 | <xs:complexType name="ParameterIntervalsPropertiesType"> |
877 | - <!--<xs:attribute name="color" type="xs:string" use="optional"></xs:attribute> --> | |
878 | - <xs:attribute name="position" type="xs:string" use="optional"></xs:attribute> | |
879 | - <xs:attribute name="text" type="xs:string" use="optional"></xs:attribute> | |
876 | + <xs:sequence> | |
877 | + <xs:element name="textLegend" type="TextLegendType" minOccurs="0" maxOccurs="1"/> | |
878 | + </xs:sequence> | |
879 | + <xs:attribute name="color" type="xs:string" use="optional"></xs:attribute> | |
880 | 880 | <xs:attribute name="index" type="xs:string" use="optional"></xs:attribute> |
881 | - <!-- <xs:attribute name="colorMapIndex" type="xs:integer" use="optional"></xs:attribute> --> | |
882 | - <xs:attributeGroup ref="labelGroup"/> | |
883 | 881 | </xs:complexType> |
884 | 882 | |
885 | 883 | <xs:complexType name="ParameterSpectroPropertiesType"> | ... | ... |
src/ParamOutputImpl/Plot/IntervalsNode.hh
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | #include "DrawingPropertiesNode.hh" |
18 | 18 | #include "PlotLogger.hh" |
19 | 19 | #include "IntervalsProperties.hh" |
20 | +#include "PlotLegendNode.hh" | |
20 | 21 | |
21 | 22 | namespace plot { |
22 | 23 | /** |
... | ... | @@ -29,6 +30,8 @@ class IntervalsNode: public plot::DrawingPropertiesNode<PlotType> { |
29 | 30 | public: |
30 | 31 | IntervalsNode(): |
31 | 32 | DrawingPropertiesNode<PlotType>() { |
33 | + DrawingPropertiesNode<PlotType>::getChildList()["textLegend"] = AMDA::XMLConfigurator::NodeCfgSPtr( | |
34 | + new TextLegendNode()); | |
32 | 35 | } |
33 | 36 | virtual ~IntervalsNode() { |
34 | 37 | } |
... | ... | @@ -77,85 +80,11 @@ public: |
77 | 80 | // add intervals definition to parameter |
78 | 81 | plotOutput->getParameter((const char*)name).addIntervalsProperties(intervalsPropsPtr); |
79 | 82 | |
80 | - // -- Position | |
81 | - value = xmlGetProp(pNode_, (const xmlChar *)"position"); | |
82 | - if (value) | |
83 | - { | |
84 | - try | |
85 | - { | |
86 | - std::string strValue((const char *)value); | |
87 | - if (strValue == "right") | |
88 | - { | |
89 | - intervalsPropsPtr->setPosition("POS_RIGHT"); | |
90 | - } | |
91 | - else if (strValue == "left") | |
92 | - { | |
93 | - intervalsPropsPtr->setPosition("POS_RIGHT"); | |
94 | - } | |
95 | - else if (strValue == "top") | |
96 | - { | |
97 | - intervalsPropsPtr->setPosition("POS_TOP"); | |
98 | - } | |
99 | - else if (strValue == "bottom") | |
100 | - { | |
101 | - intervalsPropsPtr->setPosition("POS_BOTTOM"); | |
102 | - } | |
103 | - else | |
104 | - intervalsPropsPtr->setPosition("POS_RIGHT"); | |
105 | - } | |
106 | - catch (std::logic_error &e) | |
107 | - { | |
108 | - LOG4CXX_WARN(gLogger, "Intervals Legend position : " << e.what()); | |
109 | - } | |
110 | - xmlFree(value); | |
111 | - } | |
112 | - else | |
113 | - { | |
114 | - intervalsPropsPtr->setPosition("POS_RIGHT"); | |
115 | - } | |
116 | - // -- text | |
117 | - value = xmlGetProp(pNode_, (const xmlChar *)"text"); | |
118 | - if (value) | |
119 | - { | |
120 | - intervalsPropsPtr->setText((const char *)value); | |
121 | - // label->_text = (const char *)value; | |
122 | - xmlFree(value); | |
123 | - } | |
124 | - // -- font name | |
125 | - Font labelFont("sans-serif", 10); | |
126 | - value = xmlGetProp(pNode_, (const xmlChar *)"fontName"); | |
127 | - if (value) | |
128 | - { | |
129 | - labelFont.setName((const char *)value); | |
130 | - xmlFree(value); | |
131 | - } | |
132 | - | |
133 | - // -- font size | |
134 | - value = xmlGetProp(pNode_, (const xmlChar *)"fontSize"); | |
135 | - if (value) | |
136 | - { | |
137 | - | |
138 | - labelFont.setSize(atoi((const char *)value)); | |
139 | - xmlFree(value); | |
140 | - } | |
141 | - | |
142 | - // -- font style | |
143 | - value = xmlGetProp(pNode_, (const xmlChar *)"fontStyle"); | |
144 | - if (value) | |
145 | - { | |
146 | - labelFont.setStyle(Font::getStyleByStr((const char *)value)); | |
147 | - xmlFree(value); | |
148 | - } | |
149 | - | |
150 | - // -- font weight | |
151 | - value = xmlGetProp(pNode_, (const xmlChar *)"fontWeight"); | |
152 | - if (value) | |
153 | - { | |
154 | - labelFont.setWeight(Font::getWeightByStr((const char *)value)); | |
155 | - xmlFree(value); | |
156 | - } | |
83 | + AMDA::Parameters::CfgContext context; | |
84 | + context.push<Panel *>(plotOutput->_panel.get()); | |
85 | + context.push<IntervalsProperties *>(intervalsPropsPtr.get()); | |
157 | 86 | |
158 | - intervalsPropsPtr->setFont(labelFont); | |
87 | + AMDA::XMLConfigurator::NodeGrpCfg::proceed(pNode_, context); | |
159 | 88 | } |
160 | 89 | }; |
161 | 90 | ... | ... |
src/ParamOutputImpl/Plot/IntervalsProperties.hh
... | ... | @@ -13,6 +13,7 @@ |
13 | 13 | #include <string> |
14 | 14 | |
15 | 15 | #include "DrawingProperties.hh" |
16 | +#include "TextLegendProperties.hh" | |
16 | 17 | |
17 | 18 | namespace plot { |
18 | 19 | |
... | ... | @@ -30,18 +31,16 @@ namespace plot { |
30 | 31 | */ |
31 | 32 | void dump(std::ostream &out_, std::string &prefix_); |
32 | 33 | |
33 | - IntervalsProperties() : DrawingProperties(), _paramId(""), _indexDef(""), _font("sans-serif", 10), _position("POS_RIGHT") | |
34 | + IntervalsProperties() : DrawingProperties(), _paramId(""), _indexDef("") | |
34 | 35 | { |
35 | 36 | } |
36 | 37 | |
37 | - IntervalsProperties(const DrawingProperties &ref_) : DrawingProperties(ref_), _paramId(""), _indexDef(""), _font("sans-serif", 10), | |
38 | - _position("POS_RIGHT") | |
38 | + IntervalsProperties(const DrawingProperties &ref_) : DrawingProperties(ref_), _paramId(""), _indexDef("") | |
39 | 39 | { |
40 | 40 | } |
41 | 41 | |
42 | 42 | IntervalsProperties(const IntervalsProperties &pParamDrawingProperties_) : DrawingProperties(pParamDrawingProperties_), _paramId(""), |
43 | - _indexDef(pParamDrawingProperties_._indexDef), _font("sans-serif", 10), | |
44 | - _position("POS_RIGHT") | |
43 | + _indexDef(pParamDrawingProperties_._indexDef) | |
45 | 44 | { |
46 | 45 | } |
47 | 46 | |
... | ... | @@ -77,34 +76,14 @@ namespace plot { |
77 | 76 | _indexDef = indexDef; |
78 | 77 | } |
79 | 78 | |
80 | - std::string getPosition() const | |
79 | + boost::shared_ptr<TextLegendProperties> getLegend() const | |
81 | 80 | { |
82 | - return _position; | |
81 | + return _legend; | |
83 | 82 | } |
84 | 83 | |
85 | - void setPosition(std::string position) | |
84 | + void setLegend(boost::shared_ptr<TextLegendProperties> legend) | |
86 | 85 | { |
87 | - _position = position; | |
88 | - } | |
89 | - | |
90 | - std::string getText() const | |
91 | - { | |
92 | - return _text; | |
93 | - } | |
94 | - | |
95 | - void setText(std::string text) | |
96 | - { | |
97 | - _text = text; | |
98 | - } | |
99 | - | |
100 | - Font getFont() const | |
101 | - { | |
102 | - return _font; | |
103 | - } | |
104 | - | |
105 | - void setFont(Font font) | |
106 | - { | |
107 | - _font = font; | |
86 | + _legend = legend; | |
108 | 87 | } |
109 | 88 | |
110 | 89 | AMDA::Common::ParameterIndexComponentList &getIndexes() |
... | ... | @@ -128,11 +107,7 @@ namespace plot { |
128 | 107 | */ |
129 | 108 | std::string _indexDef; |
130 | 109 | |
131 | - std::string _position; | |
132 | - | |
133 | - std::string _text = ""; | |
134 | - | |
135 | - Font _font; | |
110 | + boost::shared_ptr<TextLegendProperties> _legend; | |
136 | 111 | |
137 | 112 | /* |
138 | 113 | * @brief List of components used by the spectro | ... | ... |
src/ParamOutputImpl/Plot/PlotLegendNode.cc
... | ... | @@ -145,6 +145,7 @@ void TextLegendNode::proceed(xmlNodePtr pNode_, |
145 | 145 | LOG4CXX_DEBUG(gLogger, "TextLegendNode::proceed"); |
146 | 146 | |
147 | 147 | Panel* panel = pContext_.get<Panel *>(); |
148 | + IntervalsProperties *intervalsProps = pContext_.get<IntervalsProperties *>(); | |
148 | 149 | |
149 | 150 | boost::shared_ptr<TextLegendProperties> pTextLegendProperties (new TextLegendProperties()); |
150 | 151 | |
... | ... | @@ -184,6 +185,11 @@ void TextLegendNode::proceed(xmlNodePtr pNode_, |
184 | 185 | |
185 | 186 | panel->_textLegendPropertiesList.push_back(pTextLegendProperties); |
186 | 187 | |
188 | + if (intervalsProps != nullptr) | |
189 | + { | |
190 | + intervalsProps->setLegend(pTextLegendProperties); | |
191 | + } | |
192 | + | |
187 | 193 | AMDA::Parameters::CfgContext context; |
188 | 194 | context.push<TextLegendProperties*>(pTextLegendProperties.get()); |
189 | 195 | ... | ... |
src/ParamOutputImpl/Plot/Time/TimePlot.cc
... | ... | @@ -285,34 +285,14 @@ namespace plot |
285 | 285 | |
286 | 286 | if (intervalsPropertiesPtr != nullptr) |
287 | 287 | { |
288 | - boost::shared_ptr<TextLegendProperties> pTextLegendProperties(new TextLegendProperties()); | |
288 | + boost::shared_ptr<TextLegendProperties> pTextLegendProperties = intervalsPropertiesPtr->getLegend(); | |
289 | 289 | |
290 | - if (intervalsPropertiesPtr->getText() != "") | |
291 | - { | |
292 | - pTextLegendProperties->setText(intervalsPropertiesPtr->getText()); | |
293 | - } | |
294 | - else | |
290 | + if (pTextLegendProperties->getText() == "") | |
295 | 291 | { |
296 | 292 | pTextLegendProperties->setText(paramInfo->getShortName()); |
297 | 293 | } |
298 | 294 | |
299 | 295 | pTextLegendProperties->setColor(intervalsPropertiesPtr->getColor()); |
300 | - std::string Pos = intervalsPropertiesPtr->getPosition(); | |
301 | - | |
302 | - if (Pos == "POS_RIGHT") | |
303 | - pTextLegendProperties->setPosition(TextLegendPosition::POS_RIGHT); | |
304 | - else if (Pos == "POS_LEFT") | |
305 | - pTextLegendProperties->setPosition(TextLegendPosition::POS_LEFT); | |
306 | - else if (Pos == "POS_TOP") | |
307 | - pTextLegendProperties->setPosition(TextLegendPosition::POS_TOP); | |
308 | - else if (Pos == "POS_BOTTOM") | |
309 | - pTextLegendProperties->setPosition(TextLegendPosition::POS_BOTTOM); | |
310 | - else | |
311 | - pTextLegendProperties->setPosition(TextLegendPosition::POS_TOP); | |
312 | - | |
313 | - pTextLegendProperties->setFont(intervalsPropertiesPtr->getFont()); | |
314 | - | |
315 | - _panel->_textLegendPropertiesList.push_back(pTextLegendProperties); | |
316 | 296 | } |
317 | 297 | } |
318 | 298 | } | ... | ... |