LineProperties.hh 2.47 KB
/*
 * LineProperties.hh
 *
 *  Created on: Dec 9, 2013
 *      Author: amdadev
 */

#ifndef LINEPROPERTIES_HH_
#define LINEPROPERTIES_HH_

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

#include "Color.hh"

namespace plot {

/**
 * available line types drawing each parameter dimension.
 */
enum class LineType {
	EMPTY, LINE, HISTO
};
/**
 * string to enum translation. string values must be in
 * line with plot.xsd definition.
 */
static std::map<const std::string, LineType> stoLineType = {
		{"no", LineType::EMPTY},
		{"line", LineType::LINE},
		{"histo", LineType::HISTO}
};
/**
 * available line styles.
 */
enum class LineStyle {
	PLAIN, DOT, LONG_SPACED_DOT, LONG_SHORTED_DOT
};
/**
 * string to enum translation. string values must be in
 * line with plot.xsd definition.
 */
static std::map<std::string, LineStyle> stoLineStyle = {
		{"plain", LineStyle::PLAIN},
		{"dot", LineStyle::DOT},
		{"long-spaced-dot", LineStyle::LONG_SPACED_DOT},
		{"long-short-dot", LineStyle::LONG_SHORTED_DOT}
};

/**
 * Line properties. Defines type, style and color of each line drawn
 * on a panel for a parameter.
 */
class LineProperties {
public:
	friend std::ostream& operator<<(std::ostream& out_, const LineProperties& lprop_);
	/*
	 * Dumps properties for test.
	 */
	void dump(std::ostream& out_, std::string& prefix_);


	LineProperties() :
			_width(1), _color(), _type(LineType::LINE), _style(LineStyle::PLAIN) {
	}

	LineProperties(const LineProperties& pLineProperties_) :
			_width(pLineProperties_._width), _color(pLineProperties_._color), _type(
					pLineProperties_._type), _style(pLineProperties_._style) {
	}

	LineProperties& operator=(const LineProperties& pLineProperties_) {
		_width = pLineProperties_._width;
		_color = pLineProperties_._color;
		_style = pLineProperties_._style;
		_type = pLineProperties_._type;
		return *this;
	}

	virtual ~LineProperties() {
	}

	const Color& getColor() const{
		return _color;
	}
	Color& getColor() {
		return _color;
	}
	void setColor(const Color& color) {
		_color = color;
	}

	LineStyle getStyle() const {
		return _style;
	}
	void setStyle(const LineStyle& style) {
		_style = style;
	}

	LineType getType() const {
		return _type;
	}

	void setType(LineType type) {
		_type = type;
	}
	int getWidth() const {
		return _width;
	}

	void setWidth(int width) {
		_width = width;
	}

private:
	int _width;
	Color _color;
	LineType _type;
	LineStyle _style;
};

int getPlLineStyle (LineStyle pLineStyle);


} /* namespace plot */

#endif /* LINEPROPERTIES_HH_ */