Commit 8d19d171e599017f3f6b7158e4b01d40730096a0
1 parent
78e89487
Exists in
master
and in
100 other branches
Fix bug with relative / mm margins definition
Fix bug with title size and color Fix copyright position in page Add file prefix definition Give the possibility to run a request without parameters Give the possibility to plot an empty page
Showing
9 changed files
with
82 additions
and
36 deletions
Show diff stats
config/DataBaseParameters/xsd/request/plot.xsd
@@ -386,7 +386,8 @@ | @@ -386,7 +386,8 @@ | ||
386 | </xs:restriction> | 386 | </xs:restriction> |
387 | </xs:simpleType> | 387 | </xs:simpleType> |
388 | </xs:element> | 388 | </xs:element> |
389 | - <xs:element name="page" minOccurs="1" maxOccurs="1"> | 389 | + <xs:element name="filePrefix" type="xs:string" minOccurs="0" maxOccurs="1"/> |
390 | + <xs:element name="page" minOccurs="0" maxOccurs="1"> | ||
390 | <xs:complexType> | 391 | <xs:complexType> |
391 | <xs:sequence> | 392 | <xs:sequence> |
392 | <xs:element name="title" type="TitleType" | 393 | <xs:element name="title" type="TitleType" |
@@ -455,7 +456,7 @@ | @@ -455,7 +456,7 @@ | ||
455 | type="xs:integer" /> | 456 | type="xs:integer" /> |
456 | </xs:complexType> | 457 | </xs:complexType> |
457 | </xs:element> | 458 | </xs:element> |
458 | - <xs:element name="panel" minOccurs="1" | 459 | + <xs:element name="panel" minOccurs="0" |
459 | maxOccurs="unbounded"> | 460 | maxOccurs="unbounded"> |
460 | <xs:complexType> | 461 | <xs:complexType> |
461 | <xs:sequence> | 462 | <xs:sequence> |
@@ -635,6 +636,7 @@ | @@ -635,6 +636,7 @@ | ||
635 | </xs:element> | 636 | </xs:element> |
636 | <xs:element ref="PostProcessingElement" minOccurs="0" maxOccurs="1"/> | 637 | <xs:element ref="PostProcessingElement" minOccurs="0" maxOccurs="1"/> |
637 | </xs:sequence> | 638 | </xs:sequence> |
639 | + <xs:attribute name="writeContextFile" type="xs:boolean"/> | ||
638 | </xs:complexType> | 640 | </xs:complexType> |
639 | </xs:element> | 641 | </xs:element> |
640 | 642 |
config/DataBaseParameters/xsd/request/request.xsd
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | <xs:element name="params"> | 11 | <xs:element name="params"> |
12 | <xs:complexType> | 12 | <xs:complexType> |
13 | <xs:sequence> | 13 | <xs:sequence> |
14 | - <xs:element name="param" minOccurs="1" maxOccurs="unbounded"> | 14 | + <xs:element name="param" minOccurs="0" maxOccurs="unbounded"> |
15 | <xs:complexType> | 15 | <xs:complexType> |
16 | <xs:attribute name="id" type="xs:string" /> | 16 | <xs:attribute name="id" type="xs:string" /> |
17 | </xs:complexType> | 17 | </xs:complexType> |
src/ParamOutputImpl/Plot/CommonNode.cc
@@ -21,14 +21,14 @@ void MarginNode::proceed(xmlNodePtr pNode, | @@ -21,14 +21,14 @@ void MarginNode::proceed(xmlNodePtr pNode, | ||
21 | // -- horizontal margin | 21 | // -- horizontal margin |
22 | value = xmlGetProp(pNode, (const xmlChar *) "x"); | 22 | value = xmlGetProp(pNode, (const xmlChar *) "x"); |
23 | if (value) { | 23 | if (value) { |
24 | - element->_xMargin = atof((const char*) value); | 24 | + element->calculateRelativeXMargin(element->_orientation, element->_dimension, atof((const char*) value)); |
25 | xmlFree(value); | 25 | xmlFree(value); |
26 | } | 26 | } |
27 | 27 | ||
28 | // -- vertical margin | 28 | // -- vertical margin |
29 | value = xmlGetProp(pNode, (const xmlChar *) "y"); | 29 | value = xmlGetProp(pNode, (const xmlChar *) "y"); |
30 | if (value) { | 30 | if (value) { |
31 | - element->_yMargin = atof((const char*) value); | 31 | + element->calculateRelativeYMargin(element->_orientation, element->_dimension, atof((const char*) value)); |
32 | xmlFree(value); | 32 | xmlFree(value); |
33 | } | 33 | } |
34 | } | 34 | } |
src/ParamOutputImpl/Plot/Page.cc
@@ -262,13 +262,22 @@ void Page::draw(std::shared_ptr<plstream>& pls, bool newFile, const char *plotFi | @@ -262,13 +262,22 @@ void Page::draw(std::shared_ptr<plstream>& pls, bool newFile, const char *plotFi | ||
262 | // write title with dedicated position and align settings | 262 | // write title with dedicated position and align settings |
263 | pls->col0(0); | 263 | pls->col0(0); |
264 | 264 | ||
265 | + Color lInitialColor = changeColor(pls, _title._color, _mode); | ||
266 | + | ||
265 | // use page font if title font is not set | 267 | // use page font if title font is not set |
266 | pls->sfont(getPlFontFamily(_title._font.isSet() ? _title._font : _font), | 268 | pls->sfont(getPlFontFamily(_title._font.isSet() ? _title._font : _font), |
267 | - getPlFontStyle(_title._style), getPlFontWeight(_title._style)); | ||
268 | - pls->schr(getPlFontDef(_font), getPlFontScaleFactor(_font)); | 269 | + (_title._font.isSet() ? getPlFontStyle(_title._style) : _font._style), |
270 | + (_title._font.isSet() ? getPlFontWeight(_title._style) : _font._weight)); | ||
271 | + if (_title._font.isSet()) | ||
272 | + pls->schr(getPlFontDef(_title._font), getPlFontScaleFactor(_title._font)); | ||
273 | + else | ||
274 | + pls->schr(getPlFontDef(_font), getPlFontScaleFactor(_font)); | ||
269 | pls->mtex(getPlSide(_titlePosition).c_str(), -1., getPlPos(_titleAlign), | 275 | pls->mtex(getPlSide(_titlePosition).c_str(), -1., getPlPos(_titleAlign), |
270 | getPlJust(_titleAlign), _title._text.c_str()); | 276 | getPlJust(_titleAlign), _title._text.c_str()); |
271 | 277 | ||
278 | + // Restore initial color. | ||
279 | + restoreColor(pls, lInitialColor, _mode); | ||
280 | + | ||
272 | // write Created by AMDA(c) on bottom write | 281 | // write Created by AMDA(c) on bottom write |
273 | // write it on bottom right | 282 | // write it on bottom right |
274 | // if HIDE_AMDA_DATE is not defined (used for fitnesse automatic image comparison) | 283 | // if HIDE_AMDA_DATE is not defined (used for fitnesse automatic image comparison) |
@@ -290,15 +299,26 @@ void Page::writeCopywrite(std::shared_ptr<plstream>& pls) { | @@ -290,15 +299,26 @@ void Page::writeCopywrite(std::shared_ptr<plstream>& pls) { | ||
290 | timeinfo = localtime(&rawtime); | 299 | timeinfo = localtime(&rawtime); |
291 | strftime(buffer, 80, "%d/%m/%G %T", timeinfo); | 300 | strftime(buffer, 80, "%d/%m/%G %T", timeinfo); |
292 | 301 | ||
302 | + //set viewport | ||
303 | + pls->vpor(0, 1, 0, 1); | ||
304 | + | ||
305 | + //use page font | ||
306 | + std::vector<Label::Style> styles; | ||
307 | + pls->sfont(getPlFontFamily(_font), getPlFontStyle(styles), getPlFontWeight(styles)); | ||
308 | + pls->schr(getPlFontDef(_font), getPlFontScaleFactor(_font)); | ||
309 | + | ||
310 | + | ||
293 | // write text on right bottom of the page | 311 | // write text on right bottom of the page |
294 | pls->mtex("b", -1., 1, 1, | 312 | pls->mtex("b", -1., 1, 1, |
295 | std::string(createdby + " v" + version + " " + std::string(buffer)).c_str()); | 313 | std::string(createdby + " v" + version + " " + std::string(buffer)).c_str()); |
296 | } | 314 | } |
297 | 315 | ||
298 | void Page::initPageParameters(std::shared_ptr<plstream>& pls) { | 316 | void Page::initPageParameters(std::shared_ptr<plstream>& pls) { |
299 | - // calculate default margin if not set | ||
300 | - calculateXMargin(_orientation, _dimension); | ||
301 | - calculateYMargin(_orientation, _dimension); | 317 | + // get default margin if not set |
318 | + if (_xMargin == -1) | ||
319 | + _xMargin = DefaultPlotConfiguration::getInstance()._defaultPage._xMargin; | ||
320 | + if (_yMargin == -1) | ||
321 | + _yMargin = DefaultPlotConfiguration::getInstance()._defaultPage._yMargin; | ||
302 | 322 | ||
303 | // set page size according to page format A4 or letter | 323 | // set page size according to page format A4 or letter |
304 | // offset not seams to work | 324 | // offset not seams to work |
@@ -322,12 +342,8 @@ void Page::initPageParameters(std::shared_ptr<plstream>& pls) { | @@ -322,12 +342,8 @@ void Page::initPageParameters(std::shared_ptr<plstream>& pls) { | ||
322 | pls->setopt("dpi", dpi.str().c_str()); | 342 | pls->setopt("dpi", dpi.str().c_str()); |
323 | } | 343 | } |
324 | 344 | ||
325 | -void Page::calculateXMargin(PlotCommon::Orientation& orientation, | ||
326 | - PlotCommon::Dimension& dimension) { | ||
327 | - if (_xMargin != -1) { | ||
328 | - return; | ||
329 | - } | ||
330 | - | 345 | +void Page::calculateRelativeXMargin(PlotCommon::Orientation& orientation, |
346 | + PlotCommon::Dimension& dimension, float xMarginInMm) { | ||
331 | float xlengthInMm; | 347 | float xlengthInMm; |
332 | switch (dimension) { | 348 | switch (dimension) { |
333 | case PlotCommon::Dimension::US_letter: | 349 | case PlotCommon::Dimension::US_letter: |
@@ -345,17 +361,11 @@ void Page::calculateXMargin(PlotCommon::Orientation& orientation, | @@ -345,17 +361,11 @@ void Page::calculateXMargin(PlotCommon::Orientation& orientation, | ||
345 | xlengthInMm = Page::A4_Y_LENGTH_IN_MM; | 361 | xlengthInMm = Page::A4_Y_LENGTH_IN_MM; |
346 | } | 362 | } |
347 | } | 363 | } |
348 | - // default xmargin in mm, return margin as relative coordinate | ||
349 | - _xMargin = DefaultPlotConfiguration::getInstance()._defaultPage._xMargin | ||
350 | - / xlengthInMm; | 364 | + _xMargin = xMarginInMm / xlengthInMm; |
351 | } | 365 | } |
352 | 366 | ||
353 | -void Page::calculateYMargin(PlotCommon::Orientation& orientation, | ||
354 | - PlotCommon::Dimension& dimension) { | ||
355 | - if (_yMargin != -1) { | ||
356 | - return; | ||
357 | - } | ||
358 | - | 367 | +void Page::calculateRelativeYMargin(PlotCommon::Orientation& orientation, |
368 | + PlotCommon::Dimension& dimension, float yMarginInMm) { | ||
359 | float ylengthInMm; | 369 | float ylengthInMm; |
360 | switch (dimension) { | 370 | switch (dimension) { |
361 | case PlotCommon::Dimension::US_letter: | 371 | case PlotCommon::Dimension::US_letter: |
@@ -373,9 +383,7 @@ void Page::calculateYMargin(PlotCommon::Orientation& orientation, | @@ -373,9 +383,7 @@ void Page::calculateYMargin(PlotCommon::Orientation& orientation, | ||
373 | ylengthInMm = Page::A4_X_LENGTH_IN_MM; | 383 | ylengthInMm = Page::A4_X_LENGTH_IN_MM; |
374 | } | 384 | } |
375 | } | 385 | } |
376 | - // default xmargin in mm, return margin as relative coordinate | ||
377 | - _yMargin = DefaultPlotConfiguration::getInstance()._defaultPage._yMargin | ||
378 | - / ylengthInMm; | 386 | + _yMargin = yMarginInMm / ylengthInMm; |
379 | } | 387 | } |
380 | 388 | ||
381 | std::ostream& operator <<(std::ostream& out, Page& page) { | 389 | std::ostream& operator <<(std::ostream& out, Page& page) { |
src/ParamOutputImpl/Plot/Page.hh
@@ -166,17 +166,17 @@ public: | @@ -166,17 +166,17 @@ public: | ||
166 | */ | 166 | */ |
167 | bool _superposeMode; | 167 | bool _superposeMode; |
168 | 168 | ||
169 | + void calculateRelativeXMargin(PlotCommon::Orientation& orientation, | ||
170 | + PlotCommon::Dimension& dimension, float xMarginInMm); | ||
171 | + void calculateRelativeYMargin(PlotCommon::Orientation& orientation, | ||
172 | + PlotCommon::Dimension& dimension, float yMarginInMm); | ||
173 | + | ||
169 | private: | 174 | private: |
170 | 175 | ||
171 | void initPageParameters(std::shared_ptr<plstream>& pls); | 176 | void initPageParameters(std::shared_ptr<plstream>& pls); |
172 | 177 | ||
173 | void writeCopywrite(std::shared_ptr<plstream>& pls); | 178 | void writeCopywrite(std::shared_ptr<plstream>& pls); |
174 | 179 | ||
175 | - void calculateXMargin(PlotCommon::Orientation& orientation, | ||
176 | - PlotCommon::Dimension& dimension); | ||
177 | - void calculateYMargin(PlotCommon::Orientation& orientation, | ||
178 | - PlotCommon::Dimension& dimension); | ||
179 | - | ||
180 | }; | 180 | }; |
181 | 181 | ||
182 | std::ostream& operator <<(std::ostream& out, Page& page); | 182 | std::ostream& operator <<(std::ostream& out, Page& page); |
src/ParamOutputImpl/Plot/PlotNode.cc
@@ -19,6 +19,7 @@ namespace plot { | @@ -19,6 +19,7 @@ namespace plot { | ||
19 | PlotNode::PlotNode() : | 19 | PlotNode::PlotNode() : |
20 | NodeGrpCfg() { | 20 | NodeGrpCfg() { |
21 | getChildList()["outputStructure"] = AMDA::XMLConfigurator::NodeCfgSPtr(new OutputStructureNode()); | 21 | getChildList()["outputStructure"] = AMDA::XMLConfigurator::NodeCfgSPtr(new OutputStructureNode()); |
22 | + getChildList()["filePrefix"] = AMDA::XMLConfigurator::NodeCfgSPtr(new FilePrefixNode()); | ||
22 | getChildList()["page"] = AMDA::XMLConfigurator::NodeCfgSPtr(new PageNode()); | 23 | getChildList()["page"] = AMDA::XMLConfigurator::NodeCfgSPtr(new PageNode()); |
23 | getChildList()["postProcess"] = AMDA::XMLConfigurator::NodeCfgSPtr( | 24 | getChildList()["postProcess"] = AMDA::XMLConfigurator::NodeCfgSPtr( |
24 | new postprocessing::PostProcessingNode<PlotOutput>()); | 25 | new postprocessing::PostProcessingNode<PlotOutput>()); |
@@ -55,4 +56,14 @@ void OutputStructureNode::proceed(xmlNodePtr pNode, | @@ -55,4 +56,14 @@ void OutputStructureNode::proceed(xmlNodePtr pNode, | ||
55 | (const char*) pNode->children->content); | 56 | (const char*) pNode->children->content); |
56 | } | 57 | } |
57 | 58 | ||
59 | +void FilePrefixNode::proceed(xmlNodePtr pNode, | ||
60 | + const AMDA::Parameters::CfgContext& pContext) { | ||
61 | + LOG4CXX_DEBUG(gLogger, "FilePrefixNode::proceed") | ||
62 | + | ||
63 | + PlotOutput* lPlotOutput = | ||
64 | + pContext.get<PlotOutput*>(); | ||
65 | + lPlotOutput->setFilePrefix( | ||
66 | + (const char*) pNode->children->content); | ||
67 | +} | ||
68 | + | ||
58 | } /* namespace plot */ | 69 | } /* namespace plot */ |
src/ParamOutputImpl/Plot/PlotNode.hh
@@ -30,5 +30,16 @@ public: | @@ -30,5 +30,16 @@ public: | ||
30 | const AMDA::Parameters::CfgContext& pContext); | 30 | const AMDA::Parameters::CfgContext& pContext); |
31 | }; | 31 | }; |
32 | 32 | ||
33 | +/** | ||
34 | + * @class FilePrefixNode | ||
35 | + * @brief read the "filePrefix" node. | ||
36 | + */ | ||
37 | +class FilePrefixNode: public AMDA::XMLConfigurator::NodeCfg { | ||
38 | +public: | ||
39 | + void proceed(xmlNodePtr pNode, | ||
40 | + const AMDA::Parameters::CfgContext& pContext); | ||
41 | +}; | ||
42 | + | ||
43 | + | ||
33 | } /* namespace plot */ | 44 | } /* namespace plot */ |
34 | #endif /* PLOTNODE_HH_ */ | 45 | #endif /* PLOTNODE_HH_ */ |
src/ParamOutputImpl/Plot/PlotOutput.cc
@@ -17,7 +17,7 @@ namespace plot { | @@ -17,7 +17,7 @@ namespace plot { | ||
17 | 17 | ||
18 | PlotOutput::PlotOutput(AMDA::Parameters::ParameterManager& pParameterManager) : | 18 | PlotOutput::PlotOutput(AMDA::Parameters::ParameterManager& pParameterManager) : |
19 | AMDA::Parameters::VisitorOfParamData(), ParamOutput(pParameterManager), | 19 | AMDA::Parameters::VisitorOfParamData(), ParamOutput(pParameterManager), |
20 | - _currentParamId(""), _outputStructure(OutputStructure::ONE_FILE_PER_INTERVAL) { | 20 | + _currentParamId(""), _outputStructure(OutputStructure::ONE_FILE_PER_INTERVAL), _filePrefix("plot") { |
21 | 21 | ||
22 | } | 22 | } |
23 | 23 | ||
@@ -151,9 +151,9 @@ void PlotOutput::initNewPage(int intervalIndex) | @@ -151,9 +151,9 @@ void PlotOutput::initNewPage(int intervalIndex) | ||
151 | if ((_timeIntervalList->size() > 1) && | 151 | if ((_timeIntervalList->size() > 1) && |
152 | (_outputStructure == OutputStructure::ONE_FILE_PER_INTERVAL) && | 152 | (_outputStructure == OutputStructure::ONE_FILE_PER_INTERVAL) && |
153 | !_page->_superposeMode) | 153 | !_page->_superposeMode) |
154 | - plotFilePrefix << "plot_" << intervalIndex << "_"; | 154 | + plotFilePrefix << _filePrefix << "_" << intervalIndex << "_"; |
155 | else | 155 | else |
156 | - plotFilePrefix << "plot_"; | 156 | + plotFilePrefix << _filePrefix << "_"; |
157 | 157 | ||
158 | //draw page | 158 | //draw page |
159 | _page->draw(_pls, newFile, plotFilePrefix.str().c_str()); | 159 | _page->draw(_pls, newFile, plotFilePrefix.str().c_str()); |
src/ParamOutputImpl/Plot/PlotOutput.hh
@@ -70,6 +70,15 @@ public: | @@ -70,6 +70,15 @@ public: | ||
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | + /** | ||
74 | + * @brief sets the file prefix to use. | ||
75 | + */ | ||
76 | + void setFilePrefix(const std::string& filePrefix) | ||
77 | + { | ||
78 | + LOG4CXX_DEBUG(gLogger,"PlotOutput::setFilePrefix " << filePrefix); | ||
79 | + _filePrefix = filePrefix; | ||
80 | + } | ||
81 | + | ||
73 | AMDA::Parameters::ParameterManager& getParameterManager(){ | 82 | AMDA::Parameters::ParameterManager& getParameterManager(){ |
74 | return _parameterManager; | 83 | return _parameterManager; |
75 | } | 84 | } |
@@ -270,6 +279,11 @@ private: | @@ -270,6 +279,11 @@ private: | ||
270 | * Files to output, default is ONE_FILE_PER_INTERVAL | 279 | * Files to output, default is ONE_FILE_PER_INTERVAL |
271 | */ | 280 | */ |
272 | OutputStructure _outputStructure; | 281 | OutputStructure _outputStructure; |
282 | + | ||
283 | + /** | ||
284 | + * File prefix to use | ||
285 | + */ | ||
286 | + std::string _filePrefix; | ||
273 | }; | 287 | }; |
274 | 288 | ||
275 | } /* namespace plot */ | 289 | } /* namespace plot */ |