Commit 0fa2d990c751cf719d253cc8cb1eff9cb1996e82

Authored by Erdogan Furkan
1 parent 62024e03

7616 - Adding labelised intervals in TT/cat plots

config/xsd/request/plot.xsd
... ... @@ -874,9 +874,12 @@
874 874 </xs:complexType>
875 875  
876 876 <xs:complexType name="ParameterIntervalsPropertiesType">
877   - <xs:attribute name="color" type="xs:string" use="optional"></xs:attribute>
  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>
878 880 <xs:attribute name="index" type="xs:string" use="optional"></xs:attribute>
879   - <xs:attribute name="colorMapIndex" type="xs:integer" use="optional"></xs:attribute>
  881 + <!-- <xs:attribute name="colorMapIndex" type="xs:integer" use="optional"></xs:attribute> -->
  882 + <xs:attributeGroup ref="labelGroup"/>
880 883 </xs:complexType>
881 884  
882 885 <xs:complexType name="ParameterSpectroPropertiesType">
... ...
src/ParamOutputImpl/Plot/IntervalsNode.hh
... ... @@ -76,6 +76,68 @@ public:
76 76 intervalsPropsPtr->setColor(color);
77 77 // add intervals definition to parameter
78 78 plotOutput->getParameter((const char*)name).addIntervalsProperties(intervalsPropsPtr);
  79 +
  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 == "POS_RIGHT" || strValue == "POS_LEFT" || strValue == "POS_TOP" || strValue == "POS_BOTTOM")
  88 + intervalsPropsPtr->setPosition(strValue);
  89 + else
  90 + intervalsPropsPtr->setPosition("POS_RIGHT");
  91 + }
  92 + catch (std::logic_error &e)
  93 + {
  94 + LOG4CXX_WARN(gLogger, "Intervals Legend position : " << e.what());
  95 + }
  96 + xmlFree(value);
  97 + }
  98 + // -- text
  99 + value = xmlGetProp(pNode_, (const xmlChar *)"text");
  100 + if (value)
  101 + {
  102 + intervalsPropsPtr->setText((const char *)value);
  103 + // label->_text = (const char *)value;
  104 + xmlFree(value);
  105 + }
  106 + // -- font name
  107 + Font labelFont("sans-serif", 12);
  108 + value = xmlGetProp(pNode_, (const xmlChar *)"fontName");
  109 + if (value)
  110 + {
  111 + labelFont.setName((const char *)value);
  112 + xmlFree(value);
  113 + }
  114 +
  115 + // -- font size
  116 + value = xmlGetProp(pNode_, (const xmlChar *)"fontSize");
  117 + if (value)
  118 + {
  119 +
  120 + labelFont.setSize(atoi((const char *)value));
  121 + xmlFree(value);
  122 + }
  123 +
  124 + // -- font style
  125 + value = xmlGetProp(pNode_, (const xmlChar *)"fontStyle");
  126 + if (value)
  127 + {
  128 + labelFont.setStyle(Font::getStyleByStr((const char *)value));
  129 + xmlFree(value);
  130 + }
  131 +
  132 + // -- font weight
  133 + value = xmlGetProp(pNode_, (const xmlChar *)"fontWeight");
  134 + if (value)
  135 + {
  136 + labelFont.setWeight(Font::getWeightByStr((const char *)value));
  137 + xmlFree(value);
  138 + }
  139 +
  140 + intervalsPropsPtr->setFont(labelFont);
79 141 }
80 142 };
81 143  
... ...
src/ParamOutputImpl/Plot/IntervalsProperties.hh
... ... @@ -16,86 +16,127 @@
16 16  
17 17 namespace plot {
18 18  
19   -/**
20   - * Drawing properties for a parameter intervals.
21   - */
22   -class IntervalsProperties: public DrawingProperties {
23   -public:
24   -
25   - friend std::ostream& operator<<(std::ostream& out_,
26   - const IntervalsProperties& lprop_);
27   -
28   - /*
29   - * @brief Dumps properties for test.
30   - */
31   - void dump(std::ostream& out_, std::string& prefix_);
32   -
33   - IntervalsProperties() :
34   - DrawingProperties(), _paramId(""), _indexDef("") {
35   - }
36   -
37   - IntervalsProperties(const DrawingProperties& ref_) :
38   - DrawingProperties(ref_), _paramId(""), _indexDef("") {
39   -
40   - }
41   -
42   - IntervalsProperties(const IntervalsProperties& pParamDrawingProperties_) :
43   - DrawingProperties(pParamDrawingProperties_), _paramId(""),
44   - _indexDef(pParamDrawingProperties_._indexDef) {
45   - }
46   -
47   - IntervalsProperties& operator=(const IntervalsProperties& ref_) {
48   - DrawingProperties::operator=(ref_);
49   - _paramId = ref_._paramId;
50   - _indexDef = ref_._indexDef;
51   - return *this;
52   - }
53   -
54   - virtual ~IntervalsProperties() {
55   - }
56   -
57   - std::string getParamId(){
58   - return _paramId;
59   - }
60   -
61   - void setParamId(std::string paramId_) {
62   - _paramId = paramId_;
63   - }
64   -
65   - std::string getIndexDef() const {
66   - return _indexDef;
67   - }
68   -
69   - void setIndexDef(std::string indexDef) {
70   - _indexDef = indexDef;
71   - }
72   -
73   - AMDA::Common::ParameterIndexComponentList& getIndexes()
74   - {
75   - return _indexList;
76   - }
77   -
78   - void setIndexes(AMDA::Common::ParameterIndexComponentList indexList)
79   - {
80   - _indexList = indexList;
81   - }
82   -
83   -private:
84 19 /**
85   - * @brief Calculated paramId (from resolution).
  20 + * Drawing properties for a parameter intervals.
86 21 */
87   - std::string _paramId;
88   -
89   - /**
90   - * @brief Index definition (give by the request)
91   - */
92   - std::string _indexDef;
93   -
94   - /*
95   - * @brief List of components used by the spectro
96   - */
97   - AMDA::Common::ParameterIndexComponentList _indexList;
98   -};
  22 + class IntervalsProperties : public DrawingProperties
  23 + {
  24 + public:
  25 + friend std::ostream &operator<<(std::ostream &out_,
  26 + const IntervalsProperties &lprop_);
  27 +
  28 + /*
  29 + * @brief Dumps properties for test.
  30 + */
  31 + void dump(std::ostream &out_, std::string &prefix_);
  32 +
  33 + IntervalsProperties() : DrawingProperties(), _paramId(""), _indexDef(""), _font("sans-serif", 12)
  34 + {
  35 + }
  36 +
  37 + IntervalsProperties(const DrawingProperties &ref_) : DrawingProperties(ref_), _paramId(""), _indexDef(""), _font("sans-serif", 12)
  38 + {
  39 + }
  40 +
  41 + IntervalsProperties(const IntervalsProperties &pParamDrawingProperties_) : DrawingProperties(pParamDrawingProperties_), _paramId(""),
  42 + _indexDef(pParamDrawingProperties_._indexDef), _font("sans-serif", 12)
  43 + {
  44 + }
  45 +
  46 + IntervalsProperties &operator=(const IntervalsProperties &ref_)
  47 + {
  48 + DrawingProperties::operator=(ref_);
  49 + _paramId = ref_._paramId;
  50 + _indexDef = ref_._indexDef;
  51 + return *this;
  52 + }
  53 +
  54 + virtual ~IntervalsProperties()
  55 + {
  56 + }
  57 +
  58 + std::string getParamId()
  59 + {
  60 + return _paramId;
  61 + }
  62 +
  63 + void setParamId(std::string paramId_)
  64 + {
  65 + _paramId = paramId_;
  66 + }
  67 +
  68 + std::string getIndexDef() const
  69 + {
  70 + return _indexDef;
  71 + }
  72 +
  73 + void setIndexDef(std::string indexDef)
  74 + {
  75 + _indexDef = indexDef;
  76 + }
  77 +
  78 + std::string getPosition() const
  79 + {
  80 + return _position;
  81 + }
  82 +
  83 + void setPosition(std::string position)
  84 + {
  85 + _position = position;
  86 + }
  87 +
  88 + std::string getText() const
  89 + {
  90 + return _text;
  91 + }
  92 +
  93 + void setText(std::string text)
  94 + {
  95 + _text = text;
  96 + }
  97 +
  98 + Font getFont() const
  99 + {
  100 + return _font;
  101 + }
  102 +
  103 + void setFont(Font font)
  104 + {
  105 + _font = font;
  106 + }
  107 +
  108 + AMDA::Common::ParameterIndexComponentList &getIndexes()
  109 + {
  110 + return _indexList;
  111 + }
  112 +
  113 + void setIndexes(AMDA::Common::ParameterIndexComponentList indexList)
  114 + {
  115 + _indexList = indexList;
  116 + }
  117 +
  118 + private:
  119 + /**
  120 + * @brief Calculated paramId (from resolution).
  121 + */
  122 + std::string _paramId;
  123 +
  124 + /**
  125 + * @brief Index definition (give by the request)
  126 + */
  127 + std::string _indexDef;
  128 +
  129 + std::string _position;
  130 +
  131 + std::string _text = "";
  132 +
  133 + Font _font;
  134 +
  135 + /*
  136 + * @brief List of components used by the spectro
  137 + */
  138 + AMDA::Common::ParameterIndexComponentList _indexList;
  139 + };
99 140  
100 141 } /* namespace plot */
101 142  
... ...
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... ... @@ -1980,10 +1980,10 @@ void PanelPlotOutput::drawTextLegends(void) {
1980 1980 double ymin = _plotAreaBounds._y;
1981 1981 double ymax = _plotAreaBounds._y + _plotAreaBounds._height;
1982 1982  
1983   - bool leftTextLegendFound = false;
  1983 + /*bool leftTextLegendFound = false;
1984 1984 bool rightTextLegendFound = false;
1985 1985 bool topTextLegendFound = false;
1986   - bool bottomTextLegendFound = false;
  1986 + bool bottomTextLegendFound = false;*/
1987 1987  
1988 1988 for (auto textLegend : _panel->_textLegendPropertiesList) {
1989 1989 if (textLegend->isDrawn())
... ... @@ -2011,8 +2011,8 @@ void PanelPlotOutput::drawTextLegends(void) {
2011 2011 _pls->mtex("l", disp, 0.5, 0.5, textLines.at(textLines.size() - 1 - i).c_str());
2012 2012 disp += 1.5;
2013 2013 }
2014   - leftTextLegendFound = true;
2015   - //}
  2014 + // leftTextLegendFound = true;
  2015 + // }
2016 2016 break;
2017 2017  
2018 2018 case TextLegendPosition::POS_RIGHT :
... ... @@ -2023,9 +2023,9 @@ void PanelPlotOutput::drawTextLegends(void) {
2023 2023 _pls->mtex("r", disp, 0.5, 0.5, textLines.at(i).c_str());
2024 2024 disp += 1.5;
2025 2025 }
2026   - rightTextLegendFound = true;
2027   - //}
2028   - break;
  2026 + // rightTextLegendFound = true;
  2027 + // }
  2028 + break;
2029 2029  
2030 2030 case TextLegendPosition::POS_TOP :
2031 2031 // if (topTextLegendFound == false) {
... ... @@ -2035,9 +2035,9 @@ void PanelPlotOutput::drawTextLegends(void) {
2035 2035 _pls->mtex("t", disp, 0.5, 0.5, textLines.at(textLines.size() - 1 - i).c_str());
2036 2036 disp += 1.5;
2037 2037 }
2038   - topTextLegendFound = true;
2039   - //}
2040   - break;
  2038 + // topTextLegendFound = true;
  2039 + // }
  2040 + break;
2041 2041  
2042 2042 case TextLegendPosition::POS_BOTTOM :
2043 2043 // if (bottomTextLegendFound == false) {
... ... @@ -2047,9 +2047,9 @@ void PanelPlotOutput::drawTextLegends(void) {
2047 2047 _pls->mtex("b", disp, 0.5, 0.5, textLines.at(i).c_str());
2048 2048 disp += 1.5;
2049 2049 }
2050   - bottomTextLegendFound = true;
2051   - //}
2052   - break;
  2050 + // bottomTextLegendFound = true;
  2051 + // }
  2052 + break;
2053 2053  
2054 2054 default :
2055 2055 break;
... ...
src/ParamOutputImpl/Plot/Time/TimePlot.cc
... ... @@ -276,16 +276,42 @@ namespace plot
276 276  
277 277 void TimePlot::configureIntervalsLegend()
278 278 {
  279 + ParamMgr *piMgr = ParamMgr::getInstance();
279 280 for (auto param : _parameterAxesList)
280 281 {
281   - if (param.getIntervalsProperties() != nullptr)
282   - {
283   - std::cout << "BRE - INTERVALS LEGEND" << std::endl;
  282 + std::shared_ptr<IntervalsProperties> intervalsPropertiesPtr = param.getIntervalsProperties();
  283 + ParameterSPtr p = _parameterManager.getParameter(param._originalParamId);
  284 + AMDA::Info::ParamInfoSPtr paramInfo = piMgr->getParamInfoFromId(p->getInfoId());
284 285  
  286 + if (intervalsPropertiesPtr != nullptr)
  287 + {
285 288 boost::shared_ptr<TextLegendProperties> pTextLegendProperties(new TextLegendProperties());
286   - pTextLegendProperties->setText("Coucou");
287   - pTextLegendProperties->setPosition(TextLegendPosition::POS_RIGHT);
288   - pTextLegendProperties->setFont(_panel->getFont());
  289 +
  290 + if (intervalsPropertiesPtr->getText() != "")
  291 + {
  292 + pTextLegendProperties->setText(intervalsPropertiesPtr->getText());
  293 + }
  294 + else
  295 + {
  296 + pTextLegendProperties->setText(paramInfo->getShortName());
  297 + }
  298 +
  299 + 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 +
289 315 _panel->_textLegendPropertiesList.push_back(pTextLegendProperties);
290 316 }
291 317 }
... ... @@ -337,33 +363,36 @@ namespace plot
337 363 //set Y axis range
338 364 Range lYAxisRequestRange = lYAxis->Axis::getRequestedRange();
339 365 Range lYAxisRange = lYAxis->Axis::getRange();
340   -
  366 +
341 367 AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());
342   -
343   -
344   -
  368 +
345 369 if (isnan(lYAxisRequestRange.getMin()) && isnan(lYAxisRequestRange.getMax()))
346 370 {
347 371 boost::shared_ptr<AMDA::Info::ParamTable> tableSPtr;
348 372 if (paramInfo != nullptr)
349 373 tableSPtr = paramInfo->getTable(spectroPropertiesPtr->getRelatedDim());
350   -
351   - if (tableSPtr == nullptr){
352   - // look for unique embedded table
353   - boost::shared_ptr<AMDA::Info::ParamTable> linkedTableSPtr;
354   - int counter = 0;
355   - for (auto pInfo :paramInfo->getLinkedParamList()){
356   - linkedTableSPtr = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(pInfo)->getTable(spectroPropertiesPtr->getRelatedDim());
357   - if (linkedTableSPtr == nullptr)
358   - continue;
359   - counter ++;
360   - }
361   - if(linkedTableSPtr == nullptr || counter !=1){
362   - LOG4CXX_DEBUG(gLogger, "table cannot be defined from linked info params");
363   - }else{
364   - tableSPtr = linkedTableSPtr;
365   - }
366   - }
  374 +
  375 + if (tableSPtr == nullptr)
  376 + {
  377 + // look for unique embedded table
  378 + boost::shared_ptr<AMDA::Info::ParamTable> linkedTableSPtr;
  379 + int counter = 0;
  380 + for (auto pInfo : paramInfo->getLinkedParamList())
  381 + {
  382 + linkedTableSPtr = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(pInfo)->getTable(spectroPropertiesPtr->getRelatedDim());
  383 + if (linkedTableSPtr == nullptr)
  384 + continue;
  385 + counter++;
  386 + }
  387 + if (linkedTableSPtr == nullptr || counter != 1)
  388 + {
  389 + LOG4CXX_DEBUG(gLogger, "table cannot be defined from linked info params");
  390 + }
  391 + else
  392 + {
  393 + tableSPtr = linkedTableSPtr;
  394 + }
  395 + }
367 396  
368 397 if (tableSPtr == nullptr)
369 398 {
... ... @@ -484,9 +513,8 @@ namespace plot
484 513 lZAxis->setRange(lParamRange);
485 514 }
486 515 }
487   -
488   -
489   - void TimePlot::configureSauvaudAxis()
  516 +
  517 + void TimePlot::configureSauvaudAxis()
490 518 {
491 519 // Parse each parameter to define on which axis to draw Sauvaud
492 520 for (auto param : _parameterAxesList)
... ... @@ -509,7 +537,7 @@ namespace plot
509 537 }
510 538  
511 539 lYAxis->_used = true;
512   -
  540 +
513 541 //set Z axis range
514 542 boost::shared_ptr<Axis> lZAxis = _panel->getAxis(sauvaudPropertiesPtr->getZAxisId());
515 543 if (lZAxis.get() == nullptr)
... ... @@ -524,39 +552,37 @@ namespace plot
524 552  
525 553 ParameterSPtr p = _parameterManager.getParameter(param._originalParamId);
526 554 int rightParameterDimension;
527   - int rightDim = sauvaudPropertiesPtr->getRightDim();
  555 + int rightDim = sauvaudPropertiesPtr->getRightDim();
528 556 if (rightDim == 0){
529 557 rightParameterDimension = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getDim1Size();
530 558 }else{
531 559 rightParameterDimension = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getDim2Size();
532   - }
  560 + }
533 561 //set Y axis range
534 562  
535   -
536 563 AMDA::Info::ParamInfoSPtr paramInfo = AMDA::Info::ParamMgr::getInstance()->getParamInfoFromId(p->getInfoId());
537   -
538   - // configure right axis
539   - Range lYAxisRequestRange = lYAxis->Axis::getRequestedRange();
  564 +
  565 + // configure right axis
  566 + Range lYAxisRequestRange = lYAxis->Axis::getRequestedRange();
540 567 Range lYAxisRange = lYAxis->Axis::getRange();
541 568 if (isnan(lYAxisRequestRange.getMin()) && isnan(lYAxisRequestRange.getMax()))
542 569 {
543 570 boost::shared_ptr<AMDA::Info::ParamTable> rightTableSPtr;
544   -
545   - if (paramInfo != nullptr){
546   -
547   -
548   - rightTableSPtr = paramInfo->getTable(rightDim);
549   -
550   -
551   - }
  571 +
  572 + if (paramInfo != nullptr)
  573 + {
  574 +
  575 + rightTableSPtr = paramInfo->getTable(rightDim);
  576 + }
552 577 if (rightTableSPtr == nullptr)
553 578 {
554 579 LOG4CXX_DEBUG(gLogger, "No table defined => use index");
555 580 lYAxisRange.setMin(std::min(0., lYAxisRange.getMin()));
556 581 lYAxisRange.setMax(std::max((double)rightParameterDimension, lYAxisRange.getMax()));
557 582 }
558   - else{
559   - AMDA::Info::t_TableBound crtBound;
  583 + else
  584 + {
  585 + AMDA::Info::t_TableBound crtBound;
560 586 if (!rightTableSPtr->isVariable(&_parameterManager))
561 587 {
562 588 for (int i = 0; i < rightParameterDimension; ++i)
... ... @@ -576,7 +602,7 @@ namespace plot
576 602 }
577 603 else
578 604 {
579   - //Variable table => we need to loop under all records to find axis min & max values
  605 + // Variable table => we need to loop under all records to find axis min & max values
580 606 for (int i = 0; i < (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getSize(); ++i)
581 607 {
582 608 std::map<std::string, std::vector<double>> paramsTableData;
... ... @@ -611,18 +637,17 @@ namespace plot
611 637 }
612 638 }
613 639 }
614   -
615   - }
616   -
  640 + }
  641 +
617 642 //do not extend the axis
618   - lYAxisRange._extend = false;
  643 + lYAxisRange._extend = false;
619 644  
620 645 fixRange(lYAxisRange, lYAxis->_scale == Axis::Scale::LOGARITHMIC);
621 646  
622 647 lYAxis->setRange(lYAxisRange);
623 648  
624   - LOG4CXX_DEBUG(gLogger, "Y right axis range : min = " << lYAxisRange.getMin() << ", max = " << lYAxisRange.getMax());
625   -
  649 + LOG4CXX_DEBUG(gLogger, "Y right axis range : min = " << lYAxisRange.getMin() << ", max = " << lYAxisRange.getMax());
  650 +
626 651 Range lParamRange = lZAxis->Axis::getRange();
627 652 if (isnan(lParamRange.getMin()) && isnan(lParamRange.getMax()))
628 653 {
... ... @@ -634,10 +659,10 @@ namespace plot
634 659 }
635 660 else
636 661 {
637   - //auto range
  662 + // auto range
638 663 for (auto index : sauvaudPropertiesPtr->getIndexes())
639 664 {
640   - //compute global range for all indexes
  665 + // compute global range for all indexes
641 666 double minVal, maxVal;
642 667 if (lZAxis->_scale == Axis::Scale::LOGARITHMIC)
643 668 minVal = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getMinStrictPos(index);
... ... @@ -646,11 +671,11 @@ namespace plot
646 671 maxVal = (*_pParameterValues)[sauvaudPropertiesPtr->getParamId()].getMax(index);
647 672 if (!isnan(minVal))
648 673 lParamRange.setMin(std::min(minVal, lParamRange.getMin()));
649   - //else
  674 + // else
650 675 // lParamRange.setMin(0);
651 676 if (!isnan(maxVal))
652 677 lParamRange.setMax(std::max(maxVal, lParamRange.getMax()));
653   - //else
  678 + // else
654 679 // lParamRange.setMax(10);
655 680 }
656 681 if (isnan(lParamRange.getMin()))
... ...
src/ParamOutputImpl/Plot/Time/TimePlot.hh
... ... @@ -187,7 +187,7 @@ namespace plot
187 187 * @brief configure the TT/Catalogue intervals legend
188 188 *
189 189 */
190   - void TimePlot::configureIntervalsLegend();
  190 + void configureIntervalsLegend();
191 191 /**
192 192 * @brief Retrieve ConstantLine informations for a given serieId and constantId.
193 193 */
... ...