XYPlot.hh 3.3 KB
/*
 * XYPlot.hh
 *
 *  Created on: 29 oct. 2013
 *      Author: CS
 */

#ifndef XYPLOT_HH_
#define XYPLOT_HH_

#include "PanelPlotOutput.hh"
#include "NodeCfg.hh"
#include "XYPlotNode.hh"

namespace plot {

/**
 *  @brief Plot that draws f(x).
 */
class XYPlot: public PanelPlotOutput {
public:
	XYPlot(AMDA::Parameters::ParameterManager& manager,
			boost::shared_ptr<Panel> panel);
	virtual ~XYPlot();

	/**
	 * @overload plot::PanelPlotOutput
	 */
	virtual const std::string typeName() {
		return XYPLOT_NODENAME;
	}

	/**
	 * @overload plot::PanelPlotOutput::preparePlotArea()
	 */
	virtual void preparePlotArea(double startTime, double stopTime, int intervalIndex);

	/**
	 * @overload plot::PanelPlotOutput::createParameters()
	 */
	virtual void createParameters(std::list<std::string>& usedParametersId_);

	/**
	 * @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;
	}

	/**
	 * @brief Flag to make x axis and y axis have the same length
	 */
	bool _isIsotropic;

protected:
	/**
	 * @overload PanelPlotOutput::calculatePlotArea(Bounds const& pPanelBounds)
	 * @brief Calculate and draw plot area.
	 */
	virtual void calculatePlotArea(const Bounds& panelBounds_, Bounds& bounds_);


	/**
	 * @brief Format a date / time according to a given format.
	 */
	virtual std::string formatDateTime (double dateTime, const std::string &format);
	/**
	 * @brief Draw time ticks for a serie on plot.
	 */
	virtual void drawTimeTicks(SeriesProperties& pSeries, AMDA::Common::ParameterIndexComponent pParamIndex,
			double* timeValues, int nbTimeValues);

	/**
	 * @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& pSerie,
			AMDA::Common::ParameterIndexComponent pParamIndex, ParameterAxes& param,
			bool moreThanOneSerieForAxis);

	/**
	 * @overload PanelPlotOutput::drawCurvePlot(CurvePlot &curvePlot)
	 * @brief Draw curvePlot for a panel.
	 */
	virtual void drawCurvePlot(CurvePlot &curvePlot);

	/*
	 * Dumps properties for test.
	 */
	virtual void dump(std::ostream& fileName_);

	/*
	 * @brief Get computed X values (in relation with the x axis definition) for a serie and a time interval
	 * Do not forget to delete computedValues !!
	 * Don't delete timeValues !!
	 */
	bool getXComputedValuesFromSerieAndInterval(double startDate, double stopDate, SeriesProperties &rSeriesProperties,
			double** computedValues, double** timeValues, int& nbValues);

	/*
	 * @overload PanelPlotOutput::getSerieParamsLegendString Return the associated params legend to a xy serie
	 */
	virtual std::string getSerieParamsLegendString(SeriesProperties &rSeriesProperties,
			AMDA::Common::ParameterIndexComponent& index, std::string originalParamId);

private:
	/**
	 * @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();
};

} /* namespace plot */
#endif /* XYPLOT_HH_ */