EpochPlot.hh 2.57 KB
/*
 * EpochPlot.hh
 *
 *  Created on: 16 jan. 2015
 *      Author: AKKA
 */

#ifndef EPOCHPLOT_HH_
#define EPOCHPLOT_HH_

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

#include <algorithm>
#include <map>
#include <memory>

#include "EpochAxisDecorator.hh"


#include "TimeAxisDecorator.hh"

#include "EpochPlotNode.hh"

namespace plot {

class EpochAxis;

class EpochPlot: public PanelPlotOutput {
public:

	EpochPlot(AMDA::Parameters::ParameterManager& manager,
			boost::shared_ptr<Panel> panel);

	virtual ~EpochPlot();
	/**
	 * @overload plot::PanelPlotOutput
	 */
	virtual const std::string typeName(){
		return EPOCHPLOT_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);

	/*
	 * @brief get a pointer to the epoch axis
	 */
	EpochAxis* getEpochAxis();

	/*
	 * @brief set the center time id in the input catalog file
	 */
	void setCenterTimeId(std::string centerTimeId);

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

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

	void drawXAxis(boost::shared_ptr<Axis> pXAxis, PlWindow& pPlWindow, Bounds& pPlotAreaSize, TickConf& pTickConf);

private:
	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 Epoch time axis decorator
	 */
	std::shared_ptr<EpochAxisDecorator> _epochDecoratorPtr;

	/*
	 * @brief Center time id defined in the input catalog
	 */
	std::string _centerTimeId;
};

/**
 * @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 /* EPOCHPLOT_HH_ */