DefaultTimeAxisDecorator.hh 2.21 KB
/*
 * DefaultTimeAxisDecorator.hh
 *
 *  Created on: Dec 17, 2013
 *      Author: amdadev
 */

#ifndef DEFAULTIMEAXISDECORATOR_HH_
#define DEFAULTIMEAXISDECORATOR_HH_

#include <boost/smart_ptr/shared_ptr.hpp>
#include <iosfwd>

#include "plplot/plplot.h"

#include "plplot/plstream.h"

#include "TimeAxisDecorator.hh"


namespace plot {

/**
 * @brief A simple decorator that just display time with a calculated format 
 * on each major tickmark of a time axis.
 */
class DefaultTimeAxisDecorator: public TimeAxisDecorator {
public:
	DefaultTimeAxisDecorator() : TimeAxisDecorator() {
		_timeFormat = boost::shared_ptr<std::string>(new std::string());
	}
	DefaultTimeAxisDecorator(const DefaultTimeAxisDecorator& ref_ ) : TimeAxisDecorator(ref_){
		_timeFormat = boost::shared_ptr<std::string>(new std::string(*(ref_._timeFormat)));
	}
	DefaultTimeAxisDecorator& operator=(const DefaultTimeAxisDecorator& ref_) {
		if( _timeFormat == nullptr ){
			_timeFormat = boost::shared_ptr<std::string>(new std::string(*(ref_._timeFormat)));
		}
		else{
			_timeFormat->assign(*(ref_._timeFormat));
		}
		return *this;
	}
	virtual ~DefaultTimeAxisDecorator(){
	}
	/**
	 * @overloads XAxisDecorator::updatePlotArea
	 */
	void updatePlotArea(PanelPlotOutput* pplot_, Axis* axis_, Bounds& bounds_);
	
	/**
	 * @overloads XAxisDecorator::configure
	 */
	void configure(PanelPlotOutput* pplot_, Axis* axis_, double start_,
			double stop_, std::map<std::string, ParameterData> *pParameterValues);
	/**
	 * @overloads XAxisDecorator::draw
	 */			
	void draw(PanelPlotOutput* pplot_, Axis* axis_,
			std::shared_ptr<plstream> pls_);
protected:
	/**
	 * @overload TimeAxisDecorator::installLabelGenerator
	 */
	void installLabelGenerator(PanelPlotOutput* pplot_, TimeAxis* axis_);

	boost::shared_ptr<std::string> _timeFormat;
};

/**
 * @brief Custom generator for time label, just not display min time.
 */
void generateDefaultTimeLabel(PLINT axis, PLFLT value, char *label, PLINT length,
		PLPointer data);

/**
 * @brief Custom generator for time label, doesn't display anything (if showTickMark = false).
 */
void generateNoTimeLabel(PLINT axis, PLFLT value, char *label, PLINT length,
		PLPointer data);

} /* namespace plot */

#endif /* DEFAULTIMEAXISDECORATOR_HH_ */