Commit 6fc1d86bea264c9134fc57b9f8fda004ef60764d

Authored by Benjamin Renard
1 parent 634d98b1

Fix bug in ticks draw along a serie for a scatter plot when a tick is in a NaN value

Showing 1 changed file with 48 additions and 6 deletions   Show diff stats
src/ParamOutputImpl/Plot/Scatter/XYPlot.cc
... ... @@ -134,7 +134,7 @@ void XYPlot::createParameters(std::list<std::string>& usedParametersId_)
134 134 boost::replace_all(expr, OrbitParamComponentName, usedXParam->getId());
135 135  
136 136 //create parameter from expression
137   - usedYParam = _parameterManager.getParameterFromExpression(expr);
  137 + usedYParam = _parameterManager.getParameterFromExpression(expr, usedXParam->getGapThreshold());
138 138  
139 139 if (usedYParam == nullptr)
140 140 {
... ... @@ -618,6 +618,12 @@ void XYPlot::drawTimeTicks(SeriesProperties& pSeries, AMDA::Common::ParameterInd
618 618 }
619 619  
620 620 // Draw first time tick major symbol, other time tick major Symbols and minor time ticks symbols
  621 +
  622 + PlWindow lPlWindow = PlWindow(_panel->getAxis(pSeries.getXAxisId())->getRange().getMin(), _panel->getAxis(pSeries.getXAxisId())->getRange().getMax(),
  623 + _panel->getAxis(pSeries.getYAxisId())->getRange().getMin(), _panel->getAxis(pSeries.getYAxisId())->getRange().getMax());
  624 +
  625 + _pls->wind(std::get<0>(lPlWindow), std::get<1>(lPlWindow), std::get<2>(lPlWindow), std::get<3>(lPlWindow));
  626 +
621 627 if (nbTotMajor != 0) {
622 628 drawSymbols(
623 629 ttProps.getFirstSymbol().getType(),
... ... @@ -650,13 +656,14 @@ void XYPlot::drawTimeTicks(SeriesProperties&amp; pSeries, AMDA::Common::ParameterInd
650 656 std::string computedTimeFormat = getPlTimeFormat (std::string("hh:mm"), startTime, stopTime, nbTotMajor);
651 657 // LOG4CXX_DEBUG(gLogger, "drawTimeTicks computedTimeFormat" << computedTimeFormat);
652 658  
653   - Range lXRange = getXAxisRange (pSeries, _panel->getAxis(pSeries.getXAxisId()));
654 659 Range lYRange = getYAxisRange (pSeries, _panel->getAxis(pSeries.getYAxisId()));
655 660  
656 661 double deltaX = 0; // (lXRange.getMax () - lXRange.getMin ()) / 80;
657 662 double deltaY = (lYRange.getMax () - lYRange.getMin ()) / 80;
658 663  
659 664 for (int g=0; g<nbTotMajor; g++) {
  665 + if (isNAN(majorX[g]) || isNAN(majorY[g]))
  666 + continue;
660 667 boost::shared_ptr<TextPlot> textPlot (new TextPlot (baseTextPlot));
661 668 textPlot->_x = boost::lexical_cast<std::string>(majorX [g] + deltaX);
662 669 textPlot->_y = boost::lexical_cast<std::string>(majorY [g] + deltaY);
... ... @@ -665,8 +672,6 @@ void XYPlot::drawTimeTicks(SeriesProperties&amp; pSeries, AMDA::Common::ParameterInd
665 672 textPlots.push_back (textPlot);
666 673 }
667 674  
668   - PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
669   -
670 675 // Draw textPlots for major graduations
671 676 drawTextPlots (_panel->getAxis(pSeries.getXAxisId()), _panel->getAxis(pSeries.getYAxisId()), lPlWindow, textPlots);
672 677 }
... ... @@ -784,7 +789,7 @@ void XYPlot::drawCurvePlot(CurvePlot &amp;curvePlot)
784 789 for (ity = it->getYSeriePropertiesMap().begin(); ity != it->getYSeriePropertiesMap().end();
785 790 ++ity)
786 791 {
787   - if (curvePlot._serieId == ity->second.getId())
  792 + if (curvePlot._serieId == ity->second.getId());
788 793 {
789 794 //get curve points
790 795 int resolution = ity->second.getMaxResolution();
... ... @@ -792,8 +797,9 @@ void XYPlot::drawCurvePlot(CurvePlot &amp;curvePlot)
792 797 resolution = 100;
793 798 CurveFunctionWriter::CurvePointList pointList = curvePlot.getPointList(resolution);
794 799  
795   - if (pointList.empty())
  800 + if (pointList.empty()) {
796 801 return; //nothing to plot
  802 + }
797 803  
798 804 //prepare data in relation to axis of the associated serie
799 805 double xData[pointList.size()];
... ... @@ -814,6 +820,16 @@ void XYPlot::drawCurvePlot(CurvePlot &amp;curvePlot)
814 820 ++i;
815 821 }
816 822  
  823 + boost::shared_ptr<Axis> lXAxis(_panel->getAxis(ity->second.getXAxisId()));
  824 +
  825 + if ((lXAxis == nullptr))
  826 + {
  827 + std::stringstream lError;
  828 + lError << "XYPlot::drawCurvePlot : cannot retrieve X Axis";
  829 + BOOST_THROW_EXCEPTION(
  830 + PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
  831 + }
  832 +
817 833 double* lXData = _panel->getAxis(ity->second.getXAxisId())->getComputedValues(
818 834 xData,
819 835 pointList.size(), xMin, xMax);
... ... @@ -826,10 +842,36 @@ void XYPlot::drawCurvePlot(CurvePlot &amp;curvePlot)
826 842 PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
827 843 }
828 844  
  845 + boost::shared_ptr<Axis> lYAxis(_panel->getAxis(ity->second.getYAxisId()));
  846 +
  847 + if ((lYAxis == nullptr))
  848 + {
  849 + std::stringstream lError;
  850 + lError << "XYPlot::drawCurvePlot : cannot retrieve Y Axis";
  851 + BOOST_THROW_EXCEPTION(
  852 + PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
  853 + }
  854 +
829 855 double* lYData = _panel->getAxis(ity->second.getYAxisId())->getComputedValues(
830 856 yData,
831 857 pointList.size(), yMin, yMax);
832 858  
  859 + if(lYData == NULL)
  860 + {
  861 + std::stringstream lError;
  862 + lError << "XYPlot::drawCurvePlot : no value for y, check the request y parameter definition";
  863 + BOOST_THROW_EXCEPTION(
  864 + PanelPlotOutputException() << AMDA::ex_msg(lError.str()));
  865 + }
  866 +
  867 +
  868 + Range lXRange = lXAxis->getRange();
  869 + Range lYRange = lYAxis->getRange();
  870 +
  871 + PlWindow lPlWindow = PlWindow(lXRange.getMin(), lXRange.getMax(), lYRange.getMin(), lYRange.getMax());
  872 +
  873 + _pls->wind(std::get<0>(lPlWindow), std::get<1>(lPlWindow), std::get<2>(lPlWindow), std::get<3>(lPlWindow));
  874 +
833 875 //draw the curve
834 876 drawLines(
835 877 LineType::LINE,
... ...