DefaultPlotConfiguration.hh 1.99 KB
/*
 * DefaultPlotConfiguration.hh
 *
 *  Created on: 28 oct. 2013
 *      Author: CS
 */

#ifndef DEFAULTPLOTCONFIGURATION_HH_
#define DEFAULTPLOTCONFIGURATION_HH_

#include <map>
#include <mutex>
#include "Page.hh"
#include "TimeAxis.hh"
#include "EpochAxis.hh"
#include "DigitalAxis.hh"
#include "ColorAxis.hh"
#include "DrawingProperties.hh"


namespace plot {


class DefaultPlotConfiguration {
public:

	static const std::string TIME_DEFAULT_ID;

	static const std::string EPOCH_DEFAULT_ID;

	static const std::string COLORAXIS_ID;

	/**
	 * Gets singleton instance.
	 */
	static DefaultPlotConfiguration& getInstance() {
		std::call_once(_instanceOnceFlag, [] {
			_instance.reset(new DefaultPlotConfiguration);
		});
		return *_instance.get();
	}

	virtual ~DefaultPlotConfiguration();

	TimeAxis* getDefaultTimeAxis(){
		return dynamic_cast<TimeAxis*> (_defaultPanel.getAxis(TIME_DEFAULT_ID).get());
	}

	EpochAxis* getDefaultEpochAxis(){
		return dynamic_cast<EpochAxis*> (_defaultPanel.getAxis(EPOCH_DEFAULT_ID).get());
	}

	ColorAxis* getDefaultColorAxis(){
		return dynamic_cast<ColorAxis*> (_defaultPanel.getAxis(COLORAXIS_ID).get());
	}

	DigitalAxis* getDefaultXAxis(){
		std::string id = "xAxis";
		return dynamic_cast<DigitalAxis*> (_defaultPanel.getAxis(id).get());
	}

	DigitalAxis* getDefaultYAxis(){
		std::string id = "yAxis";
		return dynamic_cast<DigitalAxis*>(_defaultPanel.getAxis(id).get());
	}


	void applyDefaultDrawingProperties(const std::string& key_, DrawingProperties& p_);

	// ********************* DEFAULT PROPERTIES *************************** //

	Page _defaultPage;

	Panel _defaultPanel;

	Axis _defaultAxis;

	std::map<const std::string,DrawingProperties> _defaultDrawingProperties;


private:

	DefaultPlotConfiguration();

	/**
	 * Singleton unique instance
	 */
	static std::unique_ptr<DefaultPlotConfiguration> _instance;

	/**
	 * Flag to guarantee singleton unicity.
	 */
	static std::once_flag _instanceOnceFlag;


};

} /* namespace plot */
#endif /* DEFAULTPLOTCONFIGURATION_HH_ */