Commit 078ec265e8b84cea282f0bf3bbffe564ea4f288d

Authored by Benjamin Renard
1 parent dbcd9795

Give the possibility to attach a text object to a specified axis

config/DataBaseParameters/xsd/request/plot.xsd
... ... @@ -900,6 +900,8 @@ Note : This attribute may be unecessary since kind of line may be deduce from Pl
900 900 </xs:element>
901 901 </xs:sequence>
902 902 <xs:attribute name="text" type="xs:string" use="required"></xs:attribute>
  903 + <xs:attribute name="xAxis" type="xs:string" use="optional"></xs:attribute>
  904 + <xs:attribute name="yAxis" type="xs:string" use="required"></xs:attribute>
903 905 <xs:attribute name="x" type="xs:string" use="optional"></xs:attribute>
904 906 <xs:attribute name="y" type="xs:string"></xs:attribute>
905 907 <xs:attribute name="angle" type="xs:string"></xs:attribute>
... ...
src/ParamOutputImpl/Plot/AdditionalObjectsNode.hh
... ... @@ -49,6 +49,18 @@ public:
49 49 xmlFree(value);
50 50 }
51 51  
  52 + // -- xAxis
  53 + if ((value = xmlGetProp(pNode, (const xmlChar *) "xAxis"))) {
  54 + textPlot->_xAxisId = (const char *) value;
  55 + xmlFree(value);
  56 + }
  57 +
  58 + // -- yAxis
  59 + if ((value = xmlGetProp(pNode, (const xmlChar *) "yAxis"))) {
  60 + textPlot->_yAxisId = (const char *) value;
  61 + xmlFree(value);
  62 + }
  63 +
52 64 // -- x
53 65 if ((value = xmlGetProp(pNode, (const xmlChar *) "x"))) {
54 66 textPlot->_x = (const char *) value;
... ...
src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc
... ... @@ -1169,7 +1169,7 @@ void InstantPlot::draw(double startTime, double stopTime, int intervalIndex,
1169 1169 param, false);
1170 1170  
1171 1171 // Draw additionnal objects for this series.
1172   - drawAdditionalObjects(_originalParamId, *_iSerieProperties, 0);
  1172 + drawAdditionalObjects();
1173 1173 }
1174 1174 else if (_iSpectroProperties != nullptr)
1175 1175 {
... ...
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... ... @@ -1674,6 +1674,8 @@ void PanelPlotOutput::drawYErrors
1674 1674 void PanelPlotOutput::drawXConstantLines(boost::shared_ptr<Axis> pAxis, PlWindow& pPlWindow) {
1675 1675 double x [2], y [2];
1676 1676  
  1677 + _pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow), std::get<2>(pPlWindow), std::get<3>(pPlWindow));
  1678 +
1677 1679 for (auto constantLine : pAxis->_constantLines) {
1678 1680 if (constantLine->isDrawn())
1679 1681 continue;
... ... @@ -1704,6 +1706,8 @@ void PanelPlotOutput::drawXConstantLines(boost::shared_ptr&lt;Axis&gt; pAxis, PlWindow
1704 1706 void PanelPlotOutput::drawYConstantLines(boost::shared_ptr<Axis> pAxis, PlWindow& pPlWindow) {
1705 1707 double x [2], y [2];
1706 1708  
  1709 + _pls->wind(std::get<0>(pPlWindow), std::get<1>(pPlWindow), std::get<2>(pPlWindow), std::get<3>(pPlWindow));
  1710 +
1707 1711 for (auto constantLine : pAxis->_constantLines) {
1708 1712 if (constantLine->isDrawn())
1709 1713 continue;
... ... @@ -1732,7 +1736,7 @@ void PanelPlotOutput::drawYConstantLines(boost::shared_ptr&lt;Axis&gt; pAxis, PlWindow
1732 1736 /**
1733 1737 * Draws TextPlots
1734 1738 */
1735   -void PanelPlotOutput::drawTextPlots(PlWindow& pPlWindow, const TextPlots &textPlots) {
  1739 +void PanelPlotOutput::drawTextPlots(boost::shared_ptr<Axis> pXAxis, boost::shared_ptr<Axis> pYAxis, PlWindow& pPlWindow, const TextPlots &textPlots) {
1736 1740 double x, y;
1737 1741 double x1, x2, y1, y2;
1738 1742  
... ... @@ -1741,10 +1745,18 @@ void PanelPlotOutput::drawTextPlots(PlWindow&amp; pPlWindow, const TextPlots &amp;textPl
1741 1745 y1 = std::get<2>(pPlWindow);
1742 1746 y2 = std::get<3>(pPlWindow);
1743 1747  
  1748 + _pls->wind(x1, x2, y1, y2);
  1749 +
1744 1750 for (auto textPlot: textPlots) {
1745 1751 if (textPlot->isDrawn())
1746 1752 continue;
1747 1753  
  1754 + if (!textPlot->_xAxisId.empty() && (textPlot->_xAxisId.compare(pXAxis->_id) != 0))
  1755 + continue;
  1756 +
  1757 + if (!textPlot->_yAxisId.empty() && (textPlot->_yAxisId.compare(pYAxis->_id) != 0))
  1758 + continue;
  1759 +
1748 1760 // Compute x y position for the text
1749 1761 if (textPlot->_x.find("%") != std::string::npos) {
1750 1762 // Remove % before conversion
... ... @@ -1899,7 +1911,7 @@ void PanelPlotOutput::drawSerieInterval(SeriesProperties&amp; pSeries,
1899 1911 textPlots.push_back(stopTextPlot);
1900 1912 }
1901 1913  
1902   - drawTextPlots (lPlWindow, textPlots);
  1914 + drawTextPlots (lXAxis, lYAxis, lPlWindow, textPlots);
1903 1915 }
1904 1916  
1905 1917 /**
... ... @@ -2354,19 +2366,8 @@ void PanelPlotOutput::draw(double startTime, double stopTime, int intervalIndex,
2354 2366  
2355 2367  
2356 2368  
2357   - // Draw additional objects for parameters.
2358   - // Done after series plotting to override previous plots
2359   - for (auto parameter : _parameterAxesList) {
2360   - // Get series index to draw for parameter
2361   - // Draw each index of parameter
2362   - for (auto lIndex : parameter.getYSerieIndexList(_pParameterValues)) {
2363   - // Get series properties
2364   - lSeries = parameter.getYSeriePropertiesAt(lIndex);
2365   -
2366   - // Draw (configure) window for this series.
2367   - drawAdditionalObjects(parameter._originalParamId, lSeries, lIndex);
2368   - }
2369   - }
  2369 + // Draw additional objects
  2370 + drawAdditionalObjects();
2370 2371  
2371 2372 //Draw parameter legend
2372 2373 if (isLastInterval || !_panel->_page->_superposeMode)
... ... @@ -2543,35 +2544,59 @@ void PanelPlotOutput::drawSeries(double /*startDate*/, double /*stopDate*/, int
2543 2544 }
2544 2545 }
2545 2546  
2546   -void PanelPlotOutput::drawAdditionalObjects(std::string /*pParamId*/,
2547   - SeriesProperties& pSeries, AMDA::Common::ParameterIndexComponent /*pParamIndex*/) {
2548   - // Get X and Y axis.
2549   - boost::shared_ptr<Axis> lXAxis(_panel->getAxis(pSeries.getXAxisId()));
2550   - boost::shared_ptr<Axis> lYAxis(_panel->getAxis(pSeries.getYAxisId()));
  2547 +void PanelPlotOutput::drawAdditionalObjects() {
  2548 + for (auto parameter : _parameterAxesList) {
  2549 + if (parameter.getSpectroProperties() != nullptr) {
  2550 + boost::shared_ptr<Axis> lXAxis(_panel->getAxis(parameter.getSpectroProperties()->getXAxisId()));
  2551 + boost::shared_ptr<Axis> lYAxis(_panel->getAxis(parameter.getSpectroProperties()->getYAxisId()));
2551 2552  
2552   - Range lXRange = getXAxisRange (pSeries, lXAxis);
2553   - Range lYRange = getYAxisRange (pSeries, lYAxis);
  2553 + Range lXRange = lXAxis->getRange();
  2554 + Range lYRange = lYAxis->getRange();
2554 2555  
2555   - PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
  2556 + PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
2556 2557  
2557   - // Draw additional objects for y axis
2558   - if (pSeries.hasYAxis() && !lYAxis->_additionalObjDrawn) {
2559   - drawYConstantLines (lYAxis, lPlWindow);
  2558 + if (!lXAxis->_additionalObjDrawn)
  2559 + drawXConstantLines (lXAxis, lPlWindow);
2560 2560  
2561   - // Set additional objects drawn for axis.
2562   - lYAxis->_additionalObjDrawn = true;
2563   - }
  2561 + if (!lYAxis->_additionalObjDrawn)
  2562 + drawYConstantLines (lYAxis, lPlWindow);
2564 2563  
2565   - // Draw additional objects for x axis
2566   - if (pSeries.hasXAxis() && !lXAxis->_additionalObjDrawn) {
2567   - drawXConstantLines (lXAxis, lPlWindow);
  2564 + if (!lXAxis->_additionalObjDrawn || !lYAxis->_additionalObjDrawn)
  2565 + drawTextPlots (lXAxis, lYAxis, lPlWindow, _panel->_textPlots);
2568 2566  
2569   - // Set additional objects drawn for axis.
2570   - lXAxis->_additionalObjDrawn = true;
  2567 + lXAxis->_additionalObjDrawn = true;
  2568 + lYAxis->_additionalObjDrawn = true;
  2569 + }
2571 2570 }
2572 2571  
2573   - // Draw textPlots for the panel
2574   - drawTextPlots (lPlWindow, _panel->_textPlots);
  2572 + SeriesProperties lSeries;
  2573 + for (auto parameter : _parameterAxesList) {
  2574 + std::vector<AMDA::Common::ParameterIndexComponent> parameterYSerieIndexList = parameter.getYSerieIndexList(_pParameterValues);
  2575 + for (auto lIndex : parameterYSerieIndexList) {
  2576 + // Get series properties
  2577 + lSeries = parameter.getYSeriePropertiesAt(lIndex);
  2578 +
  2579 + boost::shared_ptr<Axis> lXAxis(_panel->getAxis(lSeries.getXAxisId()));
  2580 + boost::shared_ptr<Axis> lYAxis(_panel->getAxis(lSeries.getYAxisId()));
  2581 +
  2582 + Range lXRange = lXAxis->getRange();
  2583 + Range lYRange = lYAxis->getRange();
  2584 +
  2585 + PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
  2586 +
  2587 + if (!lXAxis->_additionalObjDrawn)
  2588 + drawXConstantLines (lXAxis, lPlWindow);
  2589 +
  2590 + if (!lYAxis->_additionalObjDrawn)
  2591 + drawYConstantLines (lYAxis, lPlWindow);
  2592 +
  2593 + if (!lXAxis->_additionalObjDrawn || !lYAxis->_additionalObjDrawn)
  2594 + drawTextPlots (lXAxis, lYAxis, lPlWindow, _panel->_textPlots);
  2595 +
  2596 + lXAxis->_additionalObjDrawn = true;
  2597 + lYAxis->_additionalObjDrawn = true;
  2598 + }
  2599 + }
2575 2600  
2576 2601 // Draw curvePlots
2577 2602 for (auto curvePlot : _panel->_curvePlots)
... ...
src/ParamOutputImpl/Plot/PanelPlotOutput.hh
... ... @@ -422,7 +422,7 @@ protected:
422 422 * Subclasses may override it for specific drawings.
423 423 * @param pPlWindow real word ranges.
424 424 */
425   - virtual void drawTextPlots(PlWindow& pPlWindow, const TextPlots &textPlots);
  425 + virtual void drawTextPlots(boost::shared_ptr<Axis> pXAxis, boost::shared_ptr<Axis> pYAxis, PlWindow& pPlWindow, const TextPlots &textPlots);
426 426  
427 427  
428 428 /**
... ... @@ -441,8 +441,7 @@ protected:
441 441 /**
442 442 *@brief Draw additional objects on plot.
443 443 */
444   - virtual void drawAdditionalObjects (std::string pParamId, SeriesProperties& pSeries,
445   - AMDA::Common::ParameterIndexComponent pParamIndex = AMDA::Common::ParameterIndexComponent(-1,-1));
  444 + virtual void drawAdditionalObjects ();
446 445  
447 446 /**
448 447 * Draw a z axis
... ...
src/ParamOutputImpl/Plot/Scatter/XYPlot.cc
... ... @@ -667,7 +667,7 @@ void XYPlot::drawTimeTicks(SeriesProperties&amp; pSeries, AMDA::Common::ParameterInd
667 667 PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
668 668  
669 669 // Draw textPlots for major graduations
670   - drawTextPlots (lPlWindow, textPlots);
  670 + drawTextPlots (_panel->getAxis(pSeries.getXAxisId()), _panel->getAxis(pSeries.getYAxisId()), lPlWindow, textPlots);
671 671 }
672 672  
673 673 // Free major & minor graduations positions
... ...
src/ParamOutputImpl/Plot/TextPlot.hh
... ... @@ -29,11 +29,13 @@ public:
29 29  
30 30  
31 31 TextPlot() :
32   - _text(), _x("auto"), _y("auto"), _angle(0), _align(0), _color(), _font("sans-serif", 12), _drawn(false) {
  32 + _text(), _xAxisId(""), _yAxisId(""), _x("auto"), _y("auto"), _angle(0), _align(0), _color(), _font("sans-serif", 12), _drawn(false) {
33 33 }
34 34  
35 35 TextPlot(const TextPlot& pTextPlot_) :
36 36 _text(pTextPlot_._text),
  37 + _xAxisId(pTextPlot_._xAxisId),
  38 + _yAxisId(pTextPlot_._yAxisId),
37 39 _x(pTextPlot_._x),
38 40 _y(pTextPlot_._y),
39 41 _angle(pTextPlot_._angle),
... ... @@ -46,6 +48,8 @@ public:
46 48  
47 49 TextPlot& operator=(const TextPlot& pTextPlot_) {
48 50 _text = pTextPlot_._text;
  51 + _xAxisId = pTextPlot_._xAxisId;
  52 + _yAxisId = pTextPlot_._yAxisId;
49 53 _x = pTextPlot_._x;
50 54 _y = pTextPlot_._y;
51 55 _angle = pTextPlot_._angle;
... ... @@ -71,6 +75,8 @@ public:
71 75 public:
72 76  
73 77 std::string _text;
  78 + std::string _xAxisId;
  79 + std::string _yAxisId;
74 80 std::string _x;
75 81 std::string _y;
76 82 int _angle;
... ...
test/FitNesseRoot/ReleaseS/ThirdPart/ReLease1/SprinT1/UserStory1/request_us1_01.xml
... ... @@ -42,72 +42,72 @@
42 42 </yAxis>
43 43 </axes>
44 44 <additionalObjects>
45   - <textPlot text="Texte rouge" x="2008010040000000" y="20" color="[128,0,0]"/>
46   - <textPlot text="Texte vert" x="2008010040000000" y="40" color="[0,128,0]"/>
47   - <textPlot text="Texte Bleu" x="2008010040000000" y="60" color="[0,0,128]"/>
  45 + <textPlot text="Texte rouge" yAxis="1" x="2008010040000000" y="20" color="[128,0,0]"/>
  46 + <textPlot text="Texte vert" yAxis="1" x="2008010040000000" y="40" color="[0,128,0]"/>
  47 + <textPlot text="Texte Bleu" yAxis="1" x="2008010040000000" y="60" color="[0,0,128]"/>
48 48  
49   - <textPlot text="Align left" x="2008010080000000" y="20" align="left" color="[0,0,0]"/>
50   - <textPlot text="Align center" x="2008010080000000" y="40" align="center" color="[0,0,0]"/>
51   - <textPlot text="Align right" x="2008010080000000" y="60" align="right" color="[0,0,0]"/>
  49 + <textPlot text="Align left" yAxis="1" x="2008010080000000" y="20" align="left" color="[0,0,0]"/>
  50 + <textPlot text="Align center" yAxis="1" x="2008010080000000" y="40" align="center" color="[0,0,0]"/>
  51 + <textPlot text="Align right" yAxis="1" x="2008010080000000" y="60" align="right" color="[0,0,0]"/>
52 52  
53   - <textPlot text="Fonte 4" x="2008010120000000" y="20" color="[0,0,0]">
  53 + <textPlot text="Fonte 4" yAxis="1" x="2008010120000000" y="20" color="[0,0,0]">
54 54 <font name="sans-serif" size="4" style="upright" weight="medium"/>
55 55 </textPlot>
56   - <textPlot text="Fonte 8" x="2008010120000000" y="40" color="[0,0,0]">
  56 + <textPlot text="Fonte 8" yAxis="1" x="2008010120000000" y="40" color="[0,0,0]">
57 57 <font name="sans-serif" size="8" style="upright" weight="medium"/>
58 58 </textPlot>
59   - <textPlot text="Fonte 14" x="2008010120000000" y="60" color="[0,0,0]">
  59 + <textPlot text="Fonte 14" yAxis="1" x="2008010120000000" y="60" color="[0,0,0]">
60 60 <font name="sans-serif" size="14" style="upright" weight="medium"/>
61 61 </textPlot>
62   - <textPlot text="Fonte 20" x="2008010120000000" y="80" color="[0,0,0]">
  62 + <textPlot text="Fonte 20" yAxis="1" x="2008010120000000" y="80" color="[0,0,0]">
63 63 <font name="sans-serif" size="20" style="upright" weight="medium"/>
64 64 </textPlot>
65 65  
66   - <textPlot text="Fonte sans-serif" x="2008010120000000" y="-80" color="[0,0,0]">
  66 + <textPlot text="Fonte sans-serif" yAxis="1" x="2008010120000000" y="-80" color="[0,0,0]">
67 67 <font name="sans-serif" size="14" style="upright" weight="medium"/>
68 68 </textPlot>
69   - <textPlot text="Fonte serif" x="2008010120000000" y="-70" color="[0,0,0]">
  69 + <textPlot text="Fonte serif" yAxis="1" x="2008010120000000" y="-70" color="[0,0,0]">
70 70 <font name="serif" size="14" style="upright" weight="medium"/>
71 71 </textPlot>
72   - <textPlot text="Fonte monospace" x="2008010120000000" y="-60" color="[0,0,0]">
  72 + <textPlot text="Fonte monospace" yAxis="1" x="2008010120000000" y="-60" color="[0,0,0]">
73 73 <font name="monospace" size="14" style="upright" weight="medium"/>
74 74 </textPlot>
75   - <textPlot text="Fonte script" x="2008010120000000" y="-50" color="[0,0,0]">
  75 + <textPlot text="Fonte script" yAxis="1" x="2008010120000000" y="-50" color="[0,0,0]">
76 76 <font name="script" size="14" style="upright" weight="medium"/>
77 77 </textPlot>
78   - <textPlot text="Fonte symbol" x="2008010120000000" y="-40" color="[0,0,0]">
  78 + <textPlot text="Fonte symbol" yAxis="1" x="2008010120000000" y="-40" color="[0,0,0]">
79 79 <font name="symbol" size="14" style="upright" weight="medium"/>
80 80 </textPlot>
81 81  
82   - <textPlot text="Angle 0°" x="2008010160000000" y="-80" angle="0" color="[0,128,0]"/>
83   - <textPlot text="Angle 45°" x="2008010160000000" y="-60" angle="45" color="[0,128,0]"/>
84   - <textPlot text="Angle 90°" x="2008010160000000" y="-40" angle="90" color="[0,128,0]"/>
85   - <textPlot text="Angle 180°" x="2008010160000000" y="0" angle="180" color="[0,128,0]"/>
86   - <textPlot text="Angle 270°" x="2008010160000000" y="40" angle="270" color="[0,128,0]"/>
87   - <textPlot text="Angle -45°" x="2008010160000000" y="60" angle="-45" color="[0,128,0]"/>
88   - <textPlot text="Angle 70°" x="2008010160000000" y="80" angle="70" color="[0,128,0]"/>
  82 + <textPlot text="Angle 0°" yAxis="1" x="2008010160000000" y="-80" angle="0" color="[0,128,0]"/>
  83 + <textPlot text="Angle 45°" yAxis="1" x="2008010160000000" y="-60" angle="45" color="[0,128,0]"/>
  84 + <textPlot text="Angle 90°" yAxis="1" x="2008010160000000" y="-40" angle="90" color="[0,128,0]"/>
  85 + <textPlot text="Angle 180°" yAxis="1" x="2008010160000000" y="0" angle="180" color="[0,128,0]"/>
  86 + <textPlot text="Angle 270°" yAxis="1" x="2008010160000000" y="40" angle="270" color="[0,128,0]"/>
  87 + <textPlot text="Angle -45°" yAxis="1" x="2008010160000000" y="60" angle="-45" color="[0,128,0]"/>
  88 + <textPlot text="Angle 70°" yAxis="1" x="2008010160000000" y="80" angle="70" color="[0,128,0]"/>
89 89  
90   - <textPlot text="Fonte upright-medium" x="2008010190000000" y="-80" angle="0" color="[0,0,0]">
  90 + <textPlot text="Fonte upright-medium" yAxis="1" x="2008010190000000" y="-80" angle="0" color="[0,0,0]">
91 91 <font name="sans-serif" size="12" style="upright" weight="medium"/>
92 92 </textPlot>
93   - <textPlot text="Fonte upright-bold" x="2008010190000000" y="-60" angle="0" color="[0,0,0]">
  93 + <textPlot text="Fonte upright-bold" yAxis="1" x="2008010190000000" y="-60" angle="0" color="[0,0,0]">
94 94 <font name="sans-serif" size="12" style="upright" weight="bold"/>
95 95 </textPlot>
96   - <textPlot text="Fonte italic-medium" x="2008010190000000" y="-40" angle="0" color="[0,0,0]">
  96 + <textPlot text="Fonte italic-medium" yAxis="1" x="2008010190000000" y="-40" angle="0" color="[0,0,0]">
97 97 <font name="sans-serif" size="12" style="italic" weight="medium"/>
98 98 </textPlot>
99   - <textPlot text="Fonte italic-bold" x="2008010190000000" y="-20" angle="0" color="[0,0,0]">
  99 + <textPlot text="Fonte italic-bold" yAxis="1" x="2008010190000000" y="-20" angle="0" color="[0,0,0]">
100 100 <font name="sans-serif" size="12" style="italic" weight="bold"/>
101 101 </textPlot>
102   - <textPlot text="Fonte oblique-medium" x="2008010190000000" y="0" angle="0" color="[0,0,0]">
  102 + <textPlot text="Fonte oblique-medium" yAxis="1" x="2008010190000000" y="0" angle="0" color="[0,0,0]">
103 103 <font name="sans-serif" size="12" style="oblique" weight="medium"/>
104 104 </textPlot>
105   - <textPlot text="Fonte oblique-bold" x="2008010190000000" y="20" angle="0" color="[0,0,0]">
  105 + <textPlot text="Fonte oblique-bold" yAxis="1" x="2008010190000000" y="20" angle="0" color="[0,0,0]">
106 106 <font name="sans-serif" size="12" style="oblique" weight="bold"/>
107 107 </textPlot>
108 108  
109   - <textPlot text="Pos x=10% y=-80" x="10%" y="-80" color="[0,128,0]"/>
110   - <textPlot text="Pos x=2008010040000000 y=25%" x="2008010040000000" y="25%" color="[0,128,0]"/>
  109 + <textPlot text="Pos x=10% y=-80" yAxis="1" x="10%" y="-80" color="[0,128,0]"/>
  110 + <textPlot text="Pos x=2008010040000000 y=25%" yAxis="1" x="2008010040000000" y="25%" color="[0,128,0]"/>
111 111 </additionalObjects>
112 112 </timePlot>
113 113 </panel>
... ...