/* * PlotOutput.hh * * Created on: 28 oct. 2013 * Author: CS */ #ifndef PLOTOUTPUT_HH_ #define PLOTOUTPUT_HH_ #include "ParamOutput.hh" #include "Page.hh" #include "PanelPlotOutput.hh" #include "ContextFileWriter.hh" #include #include namespace plot { enum OutputStructure { ONE_FILE, ONE_FILE_PER_INTERVAL }; class PlotOutput: public AMDA::Parameters::VisitorOfParamData, public AMDA::Parameters::ParamOutput { public: PlotOutput(AMDA::Parameters::ParameterManager& pParameterManager); virtual ~PlotOutput(); /** * @overload DataClient::establishConnection() */ virtual void establishConnection(); /** * @overload ParamOutput::apply() */ virtual void apply(); /** * @brief Adds a plot to the plot list. */ void addPlot(boost::shared_ptr plot) { _plots.push_back(plot); } /** * @brief Set option to write the context file */ void setWriteContextFile(bool writeContextFile) { _writeContextFile = writeContextFile; } /** * @brief Gets a list of plots on the same panel */ std::vector> getPlots(Panel* panel_); /** * @brief Sets the page configuration */ void setPage(boost::shared_ptr page) { _page = page; } /** * @brief sets the output structure (one file, one file per interval). */ void setOutputStructure(const std::string& pstructure) { LOG4CXX_DEBUG(gLogger,"PlotOutput::setOutputStructure " << pstructure); if (pstructure == "one-file") { _outputStructure = OutputStructure::ONE_FILE; } else if (pstructure == "one-file-per-interval") { _outputStructure = OutputStructure::ONE_FILE_PER_INTERVAL; } } /** * @brief sets the file prefix to use. */ void setFilePrefix(const std::string& filePrefix) { LOG4CXX_DEBUG(gLogger,"PlotOutput::setFilePrefix " << filePrefix); _filePrefix = filePrefix; } /** * @brief sets the file prefix to use. */ std::string& getFilePrefix() { return _filePrefix; } AMDA::Parameters::ParameterManager& getParameterManager(){ return _parameterManager; } /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataScalaireShort *) */ virtual void visit(AMDA::Parameters::ParamDataScalaireShort *); /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataScalaireFloat *) */ virtual void visit(AMDA::Parameters::ParamDataScalaireFloat *); /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataScalaireDouble *) */ virtual void visit(AMDA::Parameters::ParamDataScalaireDouble *); /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataScalaireLongDouble *) */ virtual void visit(AMDA::Parameters::ParamDataScalaireLongDouble *); /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataScalaireInt *) */ virtual void visit(AMDA::Parameters::ParamDataScalaireInt *); /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataLogicalData *) */ virtual void visit(AMDA::Parameters::ParamDataLogicalData *); /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataTab1DShort *) */ virtual void visit(AMDA::Parameters::ParamDataTab1DShort *); /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataTab1DFloat *) */ virtual void visit(AMDA::Parameters::ParamDataTab1DFloat *); /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataTab1DDouble *) */ virtual void visit(AMDA::Parameters::ParamDataTab1DDouble *); /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataTab1DLongDouble *) */ virtual void visit(AMDA::Parameters::ParamDataTab1DLongDouble *); /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataTab1DInt *) */ virtual void visit(AMDA::Parameters::ParamDataTab1DInt *); /** * @overload VisitorOfParamData::visit(AMDA::Parameters::ParamDataTab1DLogicalData *) */ virtual void visit(AMDA::Parameters::ParamDataTab1DLogicalData *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DShort *) */ virtual void visit(AMDA::Parameters::ParamDataTab2DShort *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *) */ virtual void visit(AMDA::Parameters::ParamDataTab2DFloat *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *) */ virtual void visit(AMDA::Parameters::ParamDataTab2DDouble *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *) */ virtual void visit(AMDA::Parameters::ParamDataTab2DLongDouble *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DInt *) */ virtual void visit(AMDA::Parameters::ParamDataTab2DInt *); /** * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *) */ virtual void visit(AMDA::Parameters::ParamDataTab2DLogicalData *); protected: /** * @overload ParamOutput::init() */ virtual void init(); /** * Gets parameter value from server and stores them into dedicated * structure. */ virtual void getDataFromServer(); /** * @brief Compute panel position depending on the page layout */ virtual void computePanelBounds (void); /** * @brief Compute panel plot area position depending on the panel constraints */ virtual void computePanelPlotAreaBounds (void); /** * @brief Compute panel plot area position for manual layout */ virtual void computePanelPlotAreaBoundsForManualLayout(void); /** * @brief Compute legend position depending on the panel constraints */ virtual void computePanelLegendPosition (void); private: /** * @brief Init new page - Create also the new file if necessary */ bool initNewPage(int intervalIndex, std::string& ttName); /* * @brief Sequence to draw one interval by page */ void drawOneIntervalByPage(); /* * @brief Sequence to draw all intervals in one page */ void drawAllIntervalsInOnePage(); /** * @brief Get the list of indexes used for a vector parameter */ template std::vector getParamUsedIndexes(std::string paramId, AMDA::Parameters::ParamDataSpec>* pParamData); /** * @brief Get the list of indexes used for a Tab2D parameter */ template std::vector getParamUsedIndexes(std::string paramId, AMDA::Parameters::ParamDataSpec>* pParamData); /** * @brief Get parameter gap size */ template double getParamGapSize(std::string paramId, ParamData* pParamData); /** * @brief Option to know if the context file must be write */ bool _writeContextFile; /** * @brief Context file writer */ ContextFileWriter _contextWriter; /** * @brief Main container */ boost::shared_ptr _page; /** * @brief List of plots */ std::vector> _plots; /** * @brief List of all the plot outputs */ std::vector _outputs; /** * @brief PLplot stream */ std::shared_ptr _pls; /** * Parameter instance (hold values) for each sampling value */ std::list _usedParametersId; /** * @brief Parameter values by component indexed on paramId */ std::map _parameterValues; /** * @brief Currently managed paramId in apply method (for visitor) */ std::string _currentParamId; /** * Files to output, default is ONE_FILE_PER_INTERVAL */ OutputStructure _outputStructure; /** * File prefix to use */ std::string _filePrefix; }; } /* namespace plot */ #endif /* PLOTOUTPUT_HH_ */