LayoutProperties.hh 3 KB
/*
 * LayoutProperties.hh
 *
 *  Created on: Sep, 2, 2014
 *      Author: AKKA
 */

#ifndef LAYOUTPROPERTIES_HH_
#define LAYOUTPROPERTIES_HH_

#include <iostream>
#include <map>
#include <string>

namespace plot {

/**
 * available layout types.
 */
enum class LayoutType {
	MANUAL, AUTO, VERTICAL, TEMPLATE
};
/**
 * string to enum translation. string values must be in
 * phase with plot.xsd definition.
 */
static std::map<const std::string, LayoutType> stoLayoutType = {
		{"manual", LayoutType::MANUAL},
		{"auto", LayoutType::AUTO},
		{"vertical", LayoutType::VERTICAL},
		{"template", LayoutType::TEMPLATE}
};

/**
 * Layout properties. Defines type, height and margin defined for the page layout.
 */
class LayoutProperties {
public:
	friend std::ostream& operator<<(std::ostream& out_, const LayoutProperties& lprop_);
	/*
	 * Dumps properties for test.
	 */
	void dump(std::ostream& out_, std::string& prefix_);


	LayoutProperties() :
		_type(LayoutType::MANUAL), _panelHeight(0.5), _panelSpacing(0.05), _firstPanelHeightFactor(1.0), _expand(false), _onlyLowerTimeAxesLegend(false)
	{
	}

	LayoutProperties(const LayoutProperties& pLayoutProperties_) :
		_type(pLayoutProperties_._type),
		_panelHeight(pLayoutProperties_._panelHeight),
		_panelSpacing(pLayoutProperties_._panelSpacing),
		_firstPanelHeightFactor(pLayoutProperties_._firstPanelHeightFactor),
		_expand(pLayoutProperties_._expand),
		_onlyLowerTimeAxesLegend(pLayoutProperties_._onlyLowerTimeAxesLegend)
	{
	}

	LayoutProperties& operator=(const LayoutProperties& pLayoutProperties_) {
		_type					= pLayoutProperties_._type;
		_panelHeight 			= pLayoutProperties_._panelHeight;
		_panelSpacing 			= pLayoutProperties_._panelSpacing;
		_firstPanelHeightFactor	= pLayoutProperties_._firstPanelHeightFactor;
		_expand 				= pLayoutProperties_._expand;
		_onlyLowerTimeAxesLegend = pLayoutProperties_._onlyLowerTimeAxesLegend;
		return *this;
	}

	virtual ~LayoutProperties() {
	}

	LayoutType getType() const {
		return _type;
	}

	void setType(LayoutType type) {
		_type = type;
	}

	double getPanelHeight() const {
		return _panelHeight;
	}

	void setPanelHeight(double panelHeight) {
		_panelHeight = panelHeight;
	}

	double getPanelSpacing() const {
		return _panelSpacing;
	}

	void setPanelSpacing(double panelSpacing) {
		_panelSpacing = panelSpacing;
	}

	double getFirstPanelHeightFactor() const {
		return _firstPanelHeightFactor;
	}

	void setFirstPanelHeightFactor(double firstPanelHeightFactor) {
		_firstPanelHeightFactor = firstPanelHeightFactor;
	}

	bool isExpand() const {
		return _expand;
	}

	void setExpand(bool expand) {
		_expand = expand;
	}

	bool isOnlyLowerTimeAxesLegend() const {
		return _onlyLowerTimeAxesLegend;
	}

	void setOnlyLowerTimeAxesLegend(bool onlyLowerTimeAxesLegend) {
		_onlyLowerTimeAxesLegend = onlyLowerTimeAxesLegend;
	}

private:

	LayoutType 	_type;
	double 		_panelHeight;
	double 		_panelSpacing;
	double 		_firstPanelHeightFactor;
	bool		_expand;
	bool		_onlyLowerTimeAxesLegend;
};


} /* namespace plot */

#endif /* LAYOUTPROPERTIES_HH_ */