Commit 11080d606668170515486901f6425f0c9cd2ab98

Authored by Erdogan Furkan
1 parent ff4791c4

Previous/next button added

src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc
... ... @@ -27,6 +27,8 @@ InstantPlot::InstantPlot(AMDA::Parameters::ParameterManager& manager,
27 27 boost::shared_ptr<Panel> panel) :
28 28 PanelPlotOutput(manager, panel),
29 29 _time(0),
  30 + _prevTime(0),
  31 + _nextTime(0),
30 32 _originalParamId("") {
31 33 }
32 34  
... ... @@ -283,8 +285,7 @@ void InstantPlot::getSerieParameterValues(int serieId, double **xValues, double
283 285 AMDA::Info::t_TableBound crtBound;
284 286  
285 287 for (int i = 0; i < *nbValues; ++i) {
286   - double value = paramData.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(i));
287   -
  288 + double value = paramData.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(i),_prevTime, _nextTime);
288 289 valueData[i] = value;
289 290 valueMin = std::min (valueMin,value);
290 291 valueMax = std::max (valueMax,value);
... ... @@ -868,7 +869,7 @@ void InstantPlot::configureDataAxis (boost::shared_ptr&lt;Axis&gt; axisSPtr, bool isSp
868 869 {
869 870 for (int i = 0; i < dim1Size; ++i) {
870 871 for (int j = 0; j < dim2Size; ++j) {
871   - double valIdx = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(i,j));
  872 + double valIdx = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(i,j),_prevTime, _nextTime);
872 873  
873 874 if (!isNAN(valIdx)) {
874 875 if (isNAN(instantTimeMax) || (valIdx > instantTimeMax))
... ... @@ -883,7 +884,7 @@ void InstantPlot::configureDataAxis (boost::shared_ptr&lt;Axis&gt; axisSPtr, bool isSp
883 884 else
884 885 {
885 886 for (int i = 0; i < dim1Size; ++i) {
886   - double valIdx = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(i));
  887 + double valIdx = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(i),_prevTime, _nextTime);
887 888  
888 889 if (!isNAN(valIdx)) {
889 890 if (isNAN(instantTimeMax) || (valIdx > instantTimeMax))
... ... @@ -1015,7 +1016,6 @@ void InstantPlot::drawSpectro(double startDate, double stopDate, std::string pPa
1015 1016 LOG4CXX_INFO(gLogger, "InstantPlot::drawSpectro - No data to plot");
1016 1017 return;
1017 1018 }
1018   -
1019 1019 MatrixGrid matrixGrid;
1020 1020 for (int i = 0; i < dimOnXSize; ++i)
1021 1021 {
... ... @@ -1115,10 +1115,10 @@ void InstantPlot::drawSpectro(double startDate, double stopDate, std::string pPa
1115 1115  
1116 1116 part.isColorIndex = false;
1117 1117 if (_iSpectroProperties->getDimOnXAxis() == 0) {
1118   - part.value = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(i,j));
  1118 + part.value = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(i,j),_prevTime, _nextTime);
1119 1119 }
1120 1120 else {
1121   - part.value = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(j,i));
  1121 + part.value = data.getInterpolatedValue(_time, AMDA::Common::ParameterIndexComponent(j,i),_prevTime, _nextTime);
1122 1122 }
1123 1123  
1124 1124 if (!isNAN(part.value))
... ... @@ -1419,4 +1419,17 @@ void InstantPlot::drawAdditionalObjects() {
1419 1419 }
1420 1420 }
1421 1421  
  1422 +void InstantPlot::writeContext(ContextFileWriter &writer, AMDA::Parameters::TimeIntervalList::iterator currentTimeInterval)
  1423 +{
  1424 + PanelPlotOutput::writeContext(writer, currentTimeInterval);
  1425 + if (!isStandalone())
  1426 + return;
  1427 +
  1428 + writer.startElement("instantTimeNav");
  1429 + writer.addAttribute("prevTime", std::to_string(_prevTime).c_str());
  1430 + writer.addAttribute("nextTime", std::to_string(_nextTime).c_str());
  1431 + writer.endElement();
  1432 +
  1433 +}
  1434 +
1422 1435 } /* namespace plot */
... ...
src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.hh
... ... @@ -133,6 +133,8 @@ protected:
133 133 */
134 134 virtual void dump(std::ostream& fileName_);
135 135  
  136 + virtual void writeContext(ContextFileWriter &writer, AMDA::Parameters::TimeIntervalList::iterator currentTimeInterval);
  137 +
136 138 private:
137 139 /**
138 140 * @brief Configure series color (symbols and line) and range of axis (depending of parameters series to draw).
... ... @@ -234,6 +236,8 @@ private:
234 236 * @brief time used for instantPlot plotting.
235 237 */
236 238 double _time;
  239 + double _prevTime;
  240 + double _nextTime;
237 241  
238 242 /**
239 243 * @brief Intant pot param Id.
... ...
src/ParamOutputImpl/Plot/PanelPlotOutput.hh
... ... @@ -108,7 +108,7 @@ public:
108 108 /**
109 109 * @brief Write plot context
110 110 */
111   - void writeContext(ContextFileWriter &writer, AMDA::Parameters::TimeIntervalList::iterator currentTimeInterval);
  111 + virtual void writeContext(ContextFileWriter &writer, AMDA::Parameters::TimeIntervalList::iterator currentTimeInterval);
112 112  
113 113 /*
114 114 * @brief Set a pointer to the time intervals list
... ...
src/ParamOutputImpl/Plot/ParameterData.cc
... ... @@ -112,22 +112,27 @@ int ParameterData::indexOf(double time_){
112 112 /**
113 113 * @brief Computes an interpolated value at a given time
114 114 */
115   -double ParameterData::getInterpolatedValue (double atTime, AMDA::Common::ParameterIndexComponent index) {
  115 +double ParameterData::getInterpolatedValue (double atTime, AMDA::Common::ParameterIndexComponent index , double& prevTime, double& nextTime) {
116 116  
117 117 // get index of first time after given time_
118 118 if(isnan(atTime)){
119 119 return nan("");
120 120 }
121   -
  121 + prevTime = 0;
  122 + nextTime = 0;
122 123 int firstSuperiorIndex = 0;
123 124 for(auto time : _dates){
124 125 // No interpolation required
125 126 if (time == atTime){
  127 + prevTime = _dates [firstSuperiorIndex-1];
  128 + nextTime = _dates [firstSuperiorIndex+1];
126 129 return getValues (index, firstSuperiorIndex) [0];
127 130 }
128 131 // Interpolation required
129 132 if (time >= atTime){
130 133 if (firstSuperiorIndex == 0) {
  134 + prevTime = _dates [firstSuperiorIndex];
  135 + nextTime = _dates [firstSuperiorIndex+1];
131 136 return nan("");
132 137 }
133 138 else {
... ... @@ -135,6 +140,9 @@ double ParameterData::getInterpolatedValue (double atTime, AMDA::Common::Paramet
135 140 double v2 = getValues (index, firstSuperiorIndex) [0];
136 141 double d1 = _dates [firstSuperiorIndex-1];
137 142 double d2 = _dates [firstSuperiorIndex];
  143 +
  144 + prevTime = d1;
  145 + nextTime = _dates [firstSuperiorIndex+1];
138 146 // Return a linear interpolation of the value for the index
139 147 return (v1 + (v2-v1) * (atTime-d1)/(d2-d1));
140 148 }
... ...
src/ParamOutputImpl/Plot/ParameterData.hh
... ... @@ -256,7 +256,7 @@ public:
256 256 /**
257 257 * @brief Computes an interpolated value at a given time
258 258 */
259   - double getInterpolatedValue (double atTime = nan(""), AMDA::Common::ParameterIndexComponent index = AMDA::Common::ParameterIndexComponent(-1,-1));
  259 + double getInterpolatedValue (double atTime, AMDA::Common::ParameterIndexComponent index , double& prevTime, double& nextTime);
260 260  
261 261 /*
262 262 * @brief Reset ParamData
... ...
src/ParamOutputImpl/Plot/Scatter/XYPlot.cc
... ... @@ -528,6 +528,9 @@ void XYPlot::drawTimeTicks(SeriesProperties&amp; pSeries, AMDA::Common::ParameterInd
528 528 int curMajorGrad = 0;
529 529 int curMinorGrad = 0;
530 530  
  531 + double prevTime = 0;
  532 + double nextTime = 0;
  533 +
531 534 for (int grad=0; grad<nbGrad; grad++) {
532 535 double curTime = startTime + grad * (totalDuration / (nbGrad - 1));
533 536  
... ... @@ -535,14 +538,14 @@ void XYPlot::drawTimeTicks(SeriesProperties&amp; pSeries, AMDA::Common::ParameterInd
535 538 if ((grad%(nbMinorPerMajor+1)) == 0) {
536 539 tickLabel [curMajorGrad] = curTime;
537 540  
538   - majorX [curMajorGrad] = xData.getInterpolatedValue (curTime, xSerie.getIndex());
539   - majorY [curMajorGrad] = yData.getInterpolatedValue (curTime, pParamIndex);
  541 + majorX [curMajorGrad] = xData.getInterpolatedValue (curTime, xSerie.getIndex(), prevTime,nextTime );
  542 + majorY [curMajorGrad] = yData.getInterpolatedValue (curTime, pParamIndex, prevTime,nextTime );
540 543 curMajorGrad++;
541 544 }
542 545 // Compute minor graduation pos
543 546 else {
544   - minorX [curMinorGrad] = xData.getInterpolatedValue (curTime, xSerie.getIndex());
545   - minorY [curMinorGrad] = yData.getInterpolatedValue (curTime, pParamIndex);
  547 + minorX [curMinorGrad] = xData.getInterpolatedValue (curTime, xSerie.getIndex(), prevTime,nextTime );
  548 + minorY [curMinorGrad] = yData.getInterpolatedValue (curTime, pParamIndex, prevTime,nextTime );
546 549 curMinorGrad++;
547 550 }
548 551 }
... ...