/* * TimePlot.hh * * Created on: 22 nov. 2013 * Author: CS */ #ifndef TIMEPLOT_HH_ #define TIMEPLOT_HH_ #include "PanelPlotOutput.hh" #include "NodeCfg.hh" #include #include #include #include "DefaultTimeAxisDecorator.hh" #include "TimeAxisDecorator.hh" #include "TimePlotNode.hh" extern "C" { #include } namespace plot { class TimeAxis; /** * Plot that draws f(t) */ class TimePlot: public PanelPlotOutput { public: TimePlot(AMDA::Parameters::ParameterManager& manager, boost::shared_ptr panel, TimeAxisDecorator* timeAxisDecorator = new DefaultTimeAxisDecorator()); virtual ~TimePlot(); /** * @overload plot::PanelPlotOutput */ virtual const std::string typeName(){ return TIMEPLOT_NODENAME; } /** * @brief overloads ParamOutput::preparePlotArea */ virtual void preparePlotArea (double startTime, double stopTime, int intervalIndex); /** * @brief overloads ParamOutput::draw() */ virtual bool draw(double startTime, double stopTime, int intervalIndex, bool isFirstInterval, bool isLastInterval); TimeAxis* getTimeAxis(); void setTimeAxisDecorator(std::shared_ptr pDecorator_){ _xdecoratorPtr = pDecorator_; } std::shared_ptr getTimeAxisDecorator(){ return _xdecoratorPtr; } /** * @brief QSAS time configuration for time formatting */ static QSASConfig* qsasconfig; protected: /** * @overload PanelPlotOutput::calculatePlotArea(Bounds const& pPanelBounds, bool pKeepRatio) * @brief Calculate and draw plot area. */ virtual void calculatePlotArea(Bounds& bounds_); /** * @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); /** * @overload PanelPlotOutput::drawSeries(double startDate, double stopDate, std::string pParamId, SeriesProperties const& pSerie) * @brief Draw series of parameter on plot. */ virtual void drawSeries(double startDate, double stopDate, int intervalIndex, std::string pParamId, SeriesProperties& pSeries, AMDA::Common::ParameterIndexComponent pParamIndex, ParameterAxes& param, bool moreThanOneSerieForAxis); /** * @overload PanelPlotOutput::drawSpectro(double startDate, double stopDate, std::string pParamId, SpectroProperties& pSpectro) * @brief Draw spectro of parameter on plot. */ virtual void drawSpectro(double startDate, double stopDate, std::string pParamId, SpectroProperties& pSpectro); void drawXAxis(boost::shared_ptr pXAxis, PlWindow& pPlWindow, Bounds& pPlotAreaSize, TickConf& pTickConf); /** // * @overload convertXAxisValue(const std::string &value) // * @brief Convert an X axis string value to a double X value * Subclasses may override it to take into account specific value meaning. * @param value string value to convert. */ virtual double convertXAxisValue(const std::string &value); /** * @brief Identify if other side of the plot area need to be drawn or not. * @note A plot area side need to be drawn when there is no axis associated to it. */ std::string drawOppositeSide(boost::shared_ptr pAxis); /** * @overload PanelPlotOutput::reset - reset plot */ virtual void reset() { _startDateDrawn = false; PanelPlotOutput::reset(); } /* * */ private: void drawStartDate(TimeAxis* pXAxis, double startTime, double stopTime); const std::string getXAxisId() const; /** * @brief Configure series color (symbols and line) and range of axis (depending of parameters series to draw). */ void configureSeriesAxis(); /** * @brief Configure axis legend with paramInfo. */ void configureAxisLegend(); /** * @brief Configure spectro. */ void configureSpectroAxis(); /** * @brief Retrieve ConstantLine informations for a given serieId and constantId. */ ConstantLine * getConstantLineFromId (int serieId, int constantId, boost::shared_ptr& yAxis); /** * @brief Retrieve serie properties by serie Id. */ bool getSeriePropertiesById(int serieId, SeriesProperties &rSerieProperties); /** * @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 addIntersectionTime ( 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, SeriesProperties &rSeriesProperties); std::shared_ptr _xdecoratorPtr; bool _startDateDrawn; }; /** * @brief Custom generator for time label, just not display min time. */ void generateTimeLabel(PLINT axis, PLFLT value, char *label, PLINT length, PLPointer data); } /* namespace plot */ #endif /* TIMEPLOT_HH_ */