Commit 08ec1dde709de6fe520165512f61bd5f323f6e04
1 parent
2d40f7de
Exists in
master
and in
100 other branches
Add propertie _used to an axis to know if the axes is used by a parameter
Fix a bug with page margin calculation Axes are stored by a map in Panel, that don't preserve the insertion order. In calculatePlotArea we need to be sure that ZAxis are taking in account at last.
Showing
9 changed files
with
66 additions
and
8 deletions
Show diff stats
src/ParamOutputImpl/Plot/Axis.cc
src/ParamOutputImpl/Plot/Axis.hh
src/ParamOutputImpl/Plot/CommonNode.cc
... | ... | @@ -21,14 +21,14 @@ void MarginNode::proceed(xmlNodePtr pNode, |
21 | 21 | // -- horizontal margin |
22 | 22 | value = xmlGetProp(pNode, (const xmlChar *) "x"); |
23 | 23 | if (value) { |
24 | - element->calculateRelativeXMargin(element->_orientation, element->_dimension, atof((const char*) value)); | |
24 | + element->_xMargin = atof((const char*) value); | |
25 | 25 | xmlFree(value); |
26 | 26 | } |
27 | 27 | |
28 | 28 | // -- vertical margin |
29 | 29 | value = xmlGetProp(pNode, (const xmlChar *) "y"); |
30 | 30 | if (value) { |
31 | - element->calculateRelativeYMargin(element->_orientation, element->_dimension, atof((const char*) value)); | |
31 | + element->_yMargin = atof((const char*) value); | |
32 | 32 | xmlFree(value); |
33 | 33 | } |
34 | 34 | } | ... | ... |
src/ParamOutputImpl/Plot/Epoch/EpochPlot.cc
... | ... | @@ -70,6 +70,8 @@ void EpochPlot::preparePlotArea(double startTime, double stopTime, int intervalI |
70 | 70 | _epochDecoratorPtr->configure(this, getEpochAxis(), |
71 | 71 | getEpochAxis()->getRange().getMin(), getEpochAxis()->getRange().getMax(), _pParameterValues); |
72 | 72 | |
73 | + getEpochAxis()->_used = true; | |
74 | + | |
73 | 75 | PanelPlotOutput::preparePlotArea(startTime,stopTime,intervalIndex); |
74 | 76 | } |
75 | 77 | |
... | ... | @@ -180,6 +182,7 @@ void EpochPlot::configureSeriesAxis() { |
180 | 182 | lError << "EpochPlot::configureSeriesAxis" << ": Y axis with id '" << lSeriesProperties.getYAxisId() << "' not found."; |
181 | 183 | BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); |
182 | 184 | } |
185 | + lYAxis->_used = true; | |
183 | 186 | |
184 | 187 | Range lRange(lYAxis->getRange()); |
185 | 188 | // If range status for this axis is set by the user do not update range "automatically". |
... | ... | @@ -206,6 +209,7 @@ void EpochPlot::configureSeriesAxis() { |
206 | 209 | { |
207 | 210 | if (!lSeriesProperties.getColorParamId().empty()) |
208 | 211 | { |
212 | + lZAxis->_used = true; | |
209 | 213 | Range lRange(lZAxis->getRange()); |
210 | 214 | ParameterAxes* colorSerieParameterAxes = getParameterAxesByColorSerieId(lSeriesProperties.getColorSerieId()); |
211 | 215 | if (colorSerieParameterAxes == NULL) | ... | ... |
src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc
... | ... | @@ -593,6 +593,8 @@ void InstantPlot::configureSeriesAxis() { |
593 | 593 | BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); |
594 | 594 | } |
595 | 595 | |
596 | + lXAxis->_used = true; | |
597 | + | |
596 | 598 | boost::shared_ptr<Axis> lYAxis = _panel->getAxis(_iSerieProperties->getYAxisId()); |
597 | 599 | if (lYAxis.get() == nullptr) { |
598 | 600 | std::stringstream lError; |
... | ... | @@ -600,6 +602,8 @@ void InstantPlot::configureSeriesAxis() { |
600 | 602 | BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); |
601 | 603 | } |
602 | 604 | |
605 | + lYAxis->_used = true; | |
606 | + | |
603 | 607 | if (_iSerieProperties->getTableOnXAxis()) |
604 | 608 | { |
605 | 609 | configureTableAxis (lXAxis, false, 0); |
... | ... | @@ -973,6 +977,7 @@ void InstantPlot::configureSpectroAxis() |
973 | 977 | lError << "InstantPlot::configureSpectroAxis" << ": X axis with id '" << _iSpectroProperties->getXAxisId() << "' not found."; |
974 | 978 | BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); |
975 | 979 | } |
980 | + lXAxis->_used = true; | |
976 | 981 | |
977 | 982 | boost::shared_ptr<Axis> lYAxis = _panel->getAxis(_iSpectroProperties->getYAxisId()); |
978 | 983 | if (lYAxis.get() == nullptr) { |
... | ... | @@ -980,6 +985,7 @@ void InstantPlot::configureSpectroAxis() |
980 | 985 | lError << "InstantPlot::configureSpectroAxis" << ": Y axis with id '" << _iSpectroProperties->getYAxisId() << "' not found."; |
981 | 986 | BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); |
982 | 987 | } |
988 | + lYAxis->_used = true; | |
983 | 989 | |
984 | 990 | boost::shared_ptr<Axis> lZAxis = _panel->getAxis(_iSpectroProperties->getZAxisId()); |
985 | 991 | if (lZAxis.get() == nullptr) { |
... | ... | @@ -987,6 +993,7 @@ void InstantPlot::configureSpectroAxis() |
987 | 993 | lError << "InstantPlot::configureSpectroAxis" << ": Z axis with id '" << _iSpectroProperties->getYAxisId() << "' not found."; |
988 | 994 | BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); |
989 | 995 | } |
996 | + lZAxis->_used = true; | |
990 | 997 | |
991 | 998 | if (_iSpectroProperties->getDimOnXAxis() == 0) |
992 | 999 | { | ... | ... |
src/ParamOutputImpl/Plot/Page.cc
... | ... | @@ -316,9 +316,13 @@ void Page::writeCopywrite(std::shared_ptr<plstream>& pls) { |
316 | 316 | void Page::initPageParameters(std::shared_ptr<plstream>& pls) { |
317 | 317 | // get default margin if not set |
318 | 318 | if (_xMargin == -1) |
319 | - _xMargin = DefaultPlotConfiguration::getInstance()._defaultPage._xMargin; | |
319 | + calculateRelativeXMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._xMargin); | |
320 | + else | |
321 | + calculateRelativeXMargin(_orientation, _dimension, _xMargin); | |
320 | 322 | if (_yMargin == -1) |
321 | - _yMargin = DefaultPlotConfiguration::getInstance()._defaultPage._yMargin; | |
323 | + calculateRelativeYMargin(_orientation, _dimension, DefaultPlotConfiguration::getInstance()._defaultPage._yMargin); | |
324 | + else | |
325 | + calculateRelativeYMargin(_orientation, _dimension, _yMargin); | |
322 | 326 | |
323 | 327 | // set page size according to page format A4 or letter |
324 | 328 | // offset not seams to work | ... | ... |
src/ParamOutputImpl/Plot/PanelPlotOutput.cc
... | ... | @@ -173,14 +173,36 @@ void PanelPlotOutput::calculatePlotArea(Bounds& bounds_) { |
173 | 173 | float leftTickMarkSpace = 0; |
174 | 174 | float rightTickMarkSpace = 0; |
175 | 175 | |
176 | + // ZAxis must be drawn at last! | |
177 | + std::vector<std::pair<std::string,boost::shared_ptr<Axis>>> workingAxesList; | |
178 | + for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it) | |
179 | + { | |
180 | + //Add X and Y axis to the working list | |
181 | + boost::shared_ptr<Axis> lAxis = it->second; | |
182 | + if (lAxis->_isZAxis) | |
183 | + continue; | |
184 | + workingAxesList.push_back(std::pair<std::string,boost::shared_ptr<Axis>>(it->first,lAxis)); | |
185 | + } | |
186 | + for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it) | |
187 | + { | |
188 | + //Add Z axis to the working list | |
189 | + boost::shared_ptr<Axis> lAxis = it->second; | |
190 | + if (!lAxis->_isZAxis) | |
191 | + continue; | |
192 | + workingAxesList.push_back(std::pair<std::string,boost::shared_ptr<Axis>>(it->first,lAxis)); | |
193 | + } | |
194 | + | |
176 | 195 | // Get each axes information to create plot area bounds (set space for legends). |
177 | - for (Axes::iterator it = _panel->_axes.begin(); it != _panel->_axes.end(); ++it) { | |
196 | + for (std::vector<std::pair<std::string,boost::shared_ptr<Axis>>>::iterator it = workingAxesList.begin(); it != workingAxesList.end(); ++it) { | |
178 | 197 | |
179 | 198 | boost::shared_ptr<Axis> lAxis = it->second; |
180 | 199 | |
181 | 200 | if (lAxis == nullptr) |
182 | 201 | continue; |
183 | 202 | |
203 | + if (!lAxis->_used) | |
204 | + continue; | |
205 | + | |
184 | 206 | // Axis space legends is only took into account when axis is visible |
185 | 207 | // otherwise legend is not drawn. |
186 | 208 | if (lAxis->_visible) { |
... | ... | @@ -2189,7 +2211,7 @@ void PanelPlotOutput::writeContext(ContextFileWriter& writer) { |
2189 | 2211 | if (lAxis == nullptr) |
2190 | 2212 | continue; |
2191 | 2213 | |
2192 | - if (lAxis->_visible) | |
2214 | + if (lAxis->_visible && lAxis->_used) | |
2193 | 2215 | lAxis->writeContext(writer); |
2194 | 2216 | } |
2195 | 2217 | } |
... | ... | @@ -2247,6 +2269,11 @@ void PanelPlotOutput::draw(double startTime, double stopTime, int intervalIndex, |
2247 | 2269 | // Sets panel plplot viewport, draw background & title for the panel |
2248 | 2270 | _panel->draw(_pls); |
2249 | 2271 | |
2272 | + if (_parameterAxesList.empty()) | |
2273 | + { | |
2274 | + _pls->mtex("b", -1., 1, 1, std::string("Empty panel").c_str()); | |
2275 | + } | |
2276 | + | |
2250 | 2277 | if (isFirstInterval) |
2251 | 2278 | _panel->_paramsLegendProperties.reset(); |
2252 | 2279 | ... | ... |
src/ParamOutputImpl/Plot/Scatter/XYPlot.cc
... | ... | @@ -871,6 +871,7 @@ void XYPlot::configureSeriesAxis() { |
871 | 871 | lError << "XYPlot::configureSeriesAxis" << ": X axis with id '" << lSeriesProperties.getXAxisId() << "' not found."; |
872 | 872 | BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); |
873 | 873 | } |
874 | + lXAxis->_used = true; | |
874 | 875 | |
875 | 876 | Range lXRange(lXAxis->getRange()); |
876 | 877 | // If user didn't set a range, calculate range automatically (based on parameters values). |
... | ... | @@ -907,6 +908,7 @@ void XYPlot::configureSeriesAxis() { |
907 | 908 | lError << "XYPlot::configureSeriesAxis" << ": Y axis with id '" << lSeriesProperties.getYAxisId() << "' not found."; |
908 | 909 | BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); |
909 | 910 | } |
911 | + lYAxis->_used = true; | |
910 | 912 | |
911 | 913 | // Configure range for Y axis. |
912 | 914 | Range lYRange(lYAxis->getRange()); |
... | ... | @@ -934,6 +936,7 @@ void XYPlot::configureSeriesAxis() { |
934 | 936 | { |
935 | 937 | if (!lSeriesProperties.getColorParamId().empty()) |
936 | 938 | { |
939 | + lZAxis->_used = true; | |
937 | 940 | Range lRange(lZAxis->getRange()); |
938 | 941 | ParameterAxes* colorSerieParameterAxes = getParameterAxesByColorSerieId(lSeriesProperties.getColorSerieId()); |
939 | 942 | if (colorSerieParameterAxes == NULL) | ... | ... |
src/ParamOutputImpl/Plot/Time/TimePlot.cc
... | ... | @@ -80,6 +80,7 @@ void TimePlot::preparePlotArea(double startTime, double stopTime, int intervalIn |
80 | 80 | |
81 | 81 | // configure X axis |
82 | 82 | getTimeAxisDecorator()->configure(this, getTimeAxis(), startTime, stopTime, _pParameterValues); |
83 | + getTimeAxis()->_used = true; | |
83 | 84 | _pls->timefmt(getTimeAxisDecorator()->getPlFormat().c_str()); |
84 | 85 | |
85 | 86 | PanelPlotOutput::preparePlotArea(startTime,stopTime,intervalIndex); |
... | ... | @@ -91,7 +92,7 @@ void TimePlot::draw(double startTime, double stopTime, int intervalIndex, |
91 | 92 | PanelPlotOutput::draw(startTime,stopTime,intervalIndex,isFirstInterval,isLastInterval); |
92 | 93 | |
93 | 94 | // Draw start date |
94 | - if (!_startDateDrawn) | |
95 | + if (!_startDateDrawn && getTimeAxis()->_used) | |
95 | 96 | drawStartDate (getTimeAxis(), startTime,stopTime); |
96 | 97 | _startDateDrawn = true; |
97 | 98 | } |
... | ... | @@ -128,6 +129,7 @@ void TimePlot::configureSeriesAxis() { |
128 | 129 | BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); |
129 | 130 | } |
130 | 131 | |
132 | + lYAxis->_used = true; | |
131 | 133 | Range lRange(lYAxis->getRange()); |
132 | 134 | // If range status for this axis is set by the user do not update range "automatically". |
133 | 135 | if (isnan(lRange.getMin()) && isnan(lRange.getMax())) { |
... | ... | @@ -174,6 +176,7 @@ void TimePlot::configureSeriesAxis() { |
174 | 176 | { |
175 | 177 | if (!lSeriesProperties.getColorParamId().empty()) |
176 | 178 | { |
179 | + lZAxis->_used = true; | |
177 | 180 | Range lRange(lZAxis->getRange()); |
178 | 181 | ParameterAxes* colorSerieParameterAxes = getParameterAxesByColorSerieId(lSeriesProperties.getColorSerieId()); |
179 | 182 | if (colorSerieParameterAxes == NULL) |
... | ... | @@ -238,6 +241,8 @@ void TimePlot::configureSpectroAxis() { |
238 | 241 | BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); |
239 | 242 | } |
240 | 243 | |
244 | + lYAxis->_used = true; | |
245 | + | |
241 | 246 | //set Z axis range |
242 | 247 | boost::shared_ptr<Axis> lZAxis = _panel->getAxis(spectroPropertiesPtr->getZAxisId()); |
243 | 248 | if (lZAxis.get() == nullptr) { |
... | ... | @@ -246,6 +251,8 @@ void TimePlot::configureSpectroAxis() { |
246 | 251 | BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); |
247 | 252 | } |
248 | 253 | |
254 | + lZAxis->_used = true; | |
255 | + | |
249 | 256 | ParameterSPtr p = _parameterManager.getParameter(param._originalParamId); |
250 | 257 | int parameterDimension; |
251 | 258 | if (spectroPropertiesPtr->getRelatedDim() == 0) |
... | ... | @@ -947,7 +954,7 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam |
947 | 954 | void TimePlot::drawStartDate(TimeAxis* pXAxis, double startTime, double stopTime) { |
948 | 955 | LOG4CXX_DEBUG(gLogger, "Drawing start date."); |
949 | 956 | |
950 | - if (pXAxis->_showTickMark == false) | |
957 | + if (pXAxis->_showTickMark == false || !pXAxis->_drawn || !pXAxis->_visible) | |
951 | 958 | return; |
952 | 959 | |
953 | 960 | // use panel font to draw start date. | ... | ... |