/* * InstantPlot.hh * * Created on: 29 oct. 2013 * Author: CS */ #ifndef INSTANTPLOT_HH_ #define INSTANTPLOT_HH_ //includes boost #include #include "PanelPlotOutput.hh" #include "NodeCfg.hh" #include "InstantPlotNode.hh" #include "InstantSeriesProperties.hh" #include "InstantSpectroProperties.hh" namespace plot { /** * @brief Plot that draws f(x). */ class InstantPlot: public PanelPlotOutput { public: InstantPlot(AMDA::Parameters::ParameterManager& manager, boost::shared_ptr panel); virtual ~InstantPlot(); /** * @overload plot::PanelPlotOutput */ virtual const std::string typeName() { return INSTANTPLOT_NODENAME; } /** * @overload plot::PanelPlotOutput::preparePlotArea() */ virtual void preparePlotArea(double startTime, double stopTime, int intervalIndex); /** * @overload plot::PanelPlotOutput::createParameters() */ virtual void createParameters(std::list& usedParametersId_); /** * Adds a parameter */ virtual void addParam(const std::string& name) { // There is only one parameter for instant plots _originalParamId = name; } /** * @brief draw the plot for the current time interval */ virtual bool draw(double startTime, double stopTime, int intervalIndex, bool isFirstInterval, bool isLastInterval); /** * @brief Override drawAdditionalObjects * draw additional objects */ virtual void drawAdditionalObjects(); /** * @overload PanelPlotOutput::getLayoutConstraint (void) * @brief Defines the layout constraint to be used for the panel when used within a layout */ virtual PanelConstraint getLayoutConstraint (void) { return PanelConstraint::Square; } double getTime() const { return _time; } void setTime(double time) { _time = time; } const boost::shared_ptr& getInstantSerieProperties() const { return _iSerieProperties; } void setInstantSerieProperties( const boost::shared_ptr& instantSerieProperties) { _iSerieProperties = instantSerieProperties; } const boost::shared_ptr& getInstantSpectroProperties() const { return _iSpectroProperties; } void setInstantSpectroProperties( const boost::shared_ptr& instantSpectroProperties) { _iSpectroProperties = instantSpectroProperties; } const std::string& getOriginalParamId() const { return _originalParamId; } void setOriginalParamId(const std::string& originalParamId) { _originalParamId = originalParamId; } protected: /** * @overload PanelPlotOutput::drawFills(double startDate, double stopDate) * @brief Draw fill area between parameter and constant or between parameters */ virtual void drawFills(double startDate, double stopDate); /** * @brief Draw series of parameter on plot. */ virtual void drawSeries(double startDate, double stopDate, int intervalIndex, std::string pParamId, SeriesProperties& pSerie, AMDA::Common::ParameterIndexComponent pParamIndex, ParameterAxes& param, bool moreThanOneSerieForAxis, bool& noData); /** * @brief Draw sprctro of parameter on plot. */ virtual void drawSpectro(double startDate, double stopDate, std::string pParamId, SpectroProperties& pSpectro, bool& noData); /* * Dumps properties for test. */ virtual void dump(std::ostream& fileName_); private: /** * @brief Configure series color (symbols and line) and range of axis (depending of parameters series to draw). */ void configureSeriesAxis(); /** * @brief Configure serie axis legend with paramInfo. */ void configureSeriesAxisLegend(); /** * @overload PanelPlotOutput::getSerieParamsLegendString Get the instant serie legend */ std::string getSerieParamsLegendString(SeriesProperties &rSeriesProperties, AMDA::Common::ParameterIndexComponent& index, std::string originalParamId); /** * @overload PanelPlotOutput::configureParamsLegend Configure params legend for an instant plot. */ virtual void configureParamsLegend(double startTime, double stopTime, int intervalIndex); /** * @brief Configure table axis for the parameter */ void configureTableAxis (boost::shared_ptr axisSPtr, bool isSpectro, int relatedDim); /** * @brief Configure data axis for the parameter */ void configureDataAxis (boost::shared_ptr axisSPtr, bool isSpectro); /** * @brief Configure legend for table axis */ void configureTableAxisLegend(boost::shared_ptr axisSPtr, int relatedDim); /** * @brief Configure legend for data axis */ void configureDataAxisLegend(boost::shared_ptr axisSPtr, bool isSpectro); /** * @brief Configure spectro range of axis (depending of parameters spectro to draw). */ void configureSpectroAxis(); /** * @brief Configure spectro axis legend with paramInfo. */ void configureSpectroAxisLegend(); /** * @brief Retrieve ConstantLine informations for a given serieId and constantId. */ ConstantLine * getConstantLineFromSerieId (int serieId, int constantId); /** * @brief Retrieve values for a given serieId. */ void getSerieParameterValues(int serieId, double **xValues, double **yValues, int *nbValues); /** * @brief Merge, sort and remove duplicate from 2 arrays in a vector */ void mergeAndSortTime ( double *values1Time, int values1Nb, double *values2Time, int values2Nb, std::vector &values); /** * @brief Return or compute an interpolated value */ double getInterpolatedValue (double *values, double *valuesTime, int valuesNb, double atTime); /** * @brief Compute if two ligne segments intersects */ bool intersect (double xi, double y1i, double y2i, double xj, double y1j, double y2j, double *xInter); /** * @brief Compute and add intersections time to the vector if intersections exist */ void addIntersectionTable ( double *values1, double *values1Time, int values1Nb, double *values2, double *values2Time, int values2Nb, std::vector &valuesTime); /** * @brief Draw Fill Area for the given arrays and the valueTime timeline */ void drawFillArea ( double *values1, double *values1Time, int values1Nb, double *values2, double *values2Time, int values2Nb, std::vector &valuesTime, bool colorGreaterSpecified, Color& colorGreater, bool colorLessSpecified, Color& colorLess); /** * @brief time used for instantPlot plotting. */ double _time; /** * @brief Intant pot param Id. */ std::string _originalParamId; /** * @brief Instant plot serie properties */ boost::shared_ptr _iSerieProperties; /* * @brief Instant plot spectro properties */ boost::shared_ptr _iSpectroProperties; }; } /* namespace plot */ #endif /* INSTANTPLOT_HH_ */