diff --git a/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc b/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc index 06a64af..13c2cdb 100644 --- a/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc +++ b/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.cc @@ -688,9 +688,20 @@ void InstantPlot::drawSeries(double startDate, double stopDate, int intervalInde addSerieToParamsLegend(*_iSerieProperties,pParamIndex,param._originalParamId, lineColor,symbolColor,startDate,stopDate, intervalIndex); - //delete data - delete [] xValues; - delete [] yValues; + for (int index = 0; index < nbValues; index++) + { + double x = xValues[index]; + double y = yValues[index]; + + xValuesData.push_back(x); + yValuesData.push_back(y); + } + + // delete data + delete[] xValues; + delete[] yValues; + + InstantPlot::writeDataFile(); } void InstantPlot::configureSeriesAxis() { @@ -1433,10 +1444,28 @@ void InstantPlot::writeContext(ContextFileWriter &writer, AMDA::Parameters::Time } -void InstantPlot::writeDataFile(){ - std::string fileName = _panel->_page->fileDataName; - LOG4CXX_DEBUG(gLogger, "Name of the data file is " << fileName); +void InstantPlot::writeDataFile() +{ + PanelPlotOutput::writeDataFile(); + + std::string fileName = _panel->_page->fileDataName; + LOG4CXX_DEBUG(gLogger, "Name of the data file is " << fileName); -} + std::ofstream file(fileName); + for (std::size_t index = 0; index < headers.size(); index++) + { + file << headers[index] << std::endl; + } + + for (std::size_t index = 0; index < xValuesData.size(); index++) + { + double x = xValuesData[index]; + double y = yValuesData[index]; + + file << std::fixed << x << " " << std::fixed << y << std::endl; + } + + file.close(); +} } /* namespace plot */ diff --git a/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.hh b/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.hh index 2d3cafa..04d5013 100644 --- a/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.hh +++ b/src/ParamOutputImpl/Plot/InstantPlot/InstantPlot.hh @@ -260,6 +260,9 @@ private: * @brief Instant plot spectro properties */ boost::shared_ptr _iSpectroProperties; + + std::vector xValuesData; + std::vector yValuesData; }; } /* namespace plot */ diff --git a/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.cc b/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.cc index 7acc27b..56ac006 100644 --- a/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.cc +++ b/src/ParamOutputImpl/Plot/InstantPlot/PlotFunction.cc @@ -596,10 +596,18 @@ namespace plot } void PlotFunction::writeDataFile(){ + PanelPlotOutput::writeDataFile(); + std::string fileName = _panel->_page->fileDataName; LOG4CXX_DEBUG(gLogger, "Name of the data file is " << fileName); std::ofstream file(fileName); + + for (std::size_t index = 0; index < headers.size(); index++) + { + file << headers[index] << std::endl; + } + std::map> ::iterator it; for (it = xValuesMap.begin(); it != xValuesMap.end(); it++) { diff --git a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc index 491c55d..0f231da 100644 --- a/src/ParamOutputImpl/Plot/PanelPlotOutput.cc +++ b/src/ParamOutputImpl/Plot/PanelPlotOutput.cc @@ -4067,6 +4067,25 @@ namespace plot } } - void PanelPlotOutput::writeDataFile(){} + void PanelPlotOutput::writeDataFile() + { + headers.clear(); + if (!writeData_) + return; + headers.push_back("# -----------"); + headers.push_back("# AMDA INFO :"); + headers.push_back("# -----------"); + headers.push_back("# AMDA_ABOUT : Created by AMDA"); + headers.push_back("# AMDA_ACKNOWLEDGEMENT : CDPP/AMDA Team"); + headers.push_back("#"); + headers.push_back("# -----------"); + headers.push_back("# REQUEST INFO :"); + headers.push_back("# -----------"); + headers.push_back("# DOWNLOADING DATA FOR PLOT PREVIEW : "); + headers.push_back("# ------"); + headers.push_back("#DATA:"); + headers.push_back("# ------"); + headers.push_back("# DATA_COLUMNS : x-axis values, y-axis values"); + } } /* namespace plot */ diff --git a/src/ParamOutputImpl/Plot/PanelPlotOutput.hh b/src/ParamOutputImpl/Plot/PanelPlotOutput.hh index f387dfc..ceb9533 100644 --- a/src/ParamOutputImpl/Plot/PanelPlotOutput.hh +++ b/src/ParamOutputImpl/Plot/PanelPlotOutput.hh @@ -326,10 +326,16 @@ public: _isHeightFixed = isHeightFixed; } + void setWriteData(bool value){ + writeData_ = value; + } + protected: + std::vector headers; + bool writeData_; /** * @brief Write data into file for a plot preview - * + * */ virtual void writeDataFile(); AMDA::Parameters::TimeIntervalList *_timeIntervalListPtr; diff --git a/src/ParamOutputImpl/Plot/PlotOutput.cc b/src/ParamOutputImpl/Plot/PlotOutput.cc index 3d0a1ad..76bf06f 100644 --- a/src/ParamOutputImpl/Plot/PlotOutput.cc +++ b/src/ParamOutputImpl/Plot/PlotOutput.cc @@ -295,6 +295,7 @@ void PlotOutput::drawAllIntervalsInOnePage() //Initialize panel plot for (auto plot : _plots) { + plot->setWriteData(writeDataFile); // set current plplot stream for plot, plot->setPlStream(_pls); // set link to parameters data -- libgit2 0.21.2