Blame view

src/ParamOutputImpl/Plot/Time/DefaultTimeAxisDecorator.hh 2.23 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * 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
	 */
8c860e4f   Benjamin Renard   Rework for tickpl...
49
	void updatePlotArea(PanelPlotOutput* pplot_, Axis* axis_, const Bounds& panelBounds_, Bounds& bounds_);
fbe3c2bb   Benjamin Renard   First commit
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
	
	/**
	 * @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_ */