SymbolProperties.hh 3.55 KB
/*
 * SymbolProperties.hh
 *
 *  Created on: Dec 9, 2013
 *      Author: amdadev
 */

#ifndef SYMBOLPROPERTIES_HH_
#define SYMBOLPROPERTIES_HH_

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

#include "Color.hh"

namespace plot {
/**
 * available symbol types.
 */
enum class SymbolType {
	NO = 0, // no symbol
	DOT = 1, // .
	PLUS = 2, // +
	WILDCARD = 3, // *
	CIRCLE = 4, // circle
	CRUX = 5, // x
	SQUARE = 6, // empty square
	TRIANGLE = 7, // empty triangle
	CRUX_IN_CIRCLE = 8, // crux in a circle
	DOT_IN_CIRCLE = 9, // dot in circle
	//SQUARE_2 = 10, // strange square with rounded corners. - Obsolete
	DIAMOND = 11, // diamond
	STAR = 12, // star
	//CHRISTIAN_CRUX = 14, // Christian crux - Obsolete
	DAVID_STAR = 15, // david star
	FULL_SQUARE = 16, // full square
	FULL_CIRCLE = 17, // full circle
	FULL_STAR = 18 // fullstar
};

static std::map<SymbolType,std::string> fontTypeToSymSymbol = {
		{SymbolType::NO, ""},
		{SymbolType::DOT, "148"},
		{SymbolType::PLUS, "126"},
		{SymbolType::WILDCARD, "128"},
		{SymbolType::CIRCLE, "135"},
		{SymbolType::CRUX,"141"},
		{SymbolType::SQUARE,"136"},
		{SymbolType::TRIANGLE,"137"},
		{SymbolType::CRUX_IN_CIRCLE, "172"},
		{SymbolType::DOT_IN_CIRCLE,"171"},
		//{SymbolType::SQUARE_2, "235"},
		{SymbolType::DIAMOND, "138"},
		{SymbolType::STAR,"139"},
		//{SymbolType::CHRISTIAN_CRUX,"866"},
		{SymbolType::DAVID_STAR,"147"},
		{SymbolType::FULL_SQUARE,"144"},
		{SymbolType::FULL_CIRCLE,"143"},
		{SymbolType::FULL_STAR,"145"}
};


/**
 * string to enum translation. string values must be in
 * line with plot.xsd definition.
 */
static std::map<const std::string,SymbolType> stoSymbolType = {
		{"no", SymbolType::NO},
		{"dot", SymbolType::DOT},
		{"plus", SymbolType::PLUS},
		{"wildcard", SymbolType::WILDCARD},
		{"circle", SymbolType::CIRCLE},
		{"crux", SymbolType::CRUX},
		{"square", SymbolType::SQUARE},
		{"triangle", SymbolType::TRIANGLE},
		{"crux-in-circle", SymbolType::CRUX_IN_CIRCLE},
		{"dot-in-circle", SymbolType::DOT_IN_CIRCLE},
		//{"square-2", SymbolType::SQUARE_2},
		{"diamond", SymbolType::DIAMOND},
		{"star", SymbolType::STAR},
		//{"christian-crux", SymbolType::CHRISTIAN_CRUX},
		{"david-star", SymbolType::DAVID_STAR},
		{"full-square", SymbolType::FULL_SQUARE},
		{"full-circle", SymbolType::FULL_CIRCLE},
		{"full-star", SymbolType::FULL_STAR}
};




/**
 * Symbol properties. Defines symbol to use, size and color for each
 * point to draw for a parameter
 */
class SymbolProperties {
public:
	friend std::ostream& operator<<(std::ostream& out_, const SymbolProperties& prop_);
	/*
	 * Dumps properties for test.
	 */
	void dump(std::ostream& out_, std::string& prefix_);

	SymbolProperties() :
			_type(SymbolType::DOT), _size(4), _color() {
	}
	SymbolProperties(const SymbolProperties& pSymbolProperties_) :
			_type(pSymbolProperties_._type), _size(pSymbolProperties_._size), _color(
					pSymbolProperties_._color) {
	}

	SymbolProperties& operator=(const SymbolProperties& pSymbolProperties_) {
		_type = pSymbolProperties_._type;
		_size = pSymbolProperties_._size;
		_color = pSymbolProperties_._color;
		return *this;
	}

	virtual ~SymbolProperties() {
	}

	const Color& getColor() const {
		return _color;
	}

	Color& getColor(){
		return _color;
	}

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

	int getSize() const {
		return _size;
	}

	void setSize(int size) {
		_size = size;
	}

	SymbolType getType() const {
		return _type;
	}

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

private:

	SymbolType _type;
	int _size;
	Color _color;

};




} /* namespace plot */

#endif /* SYMBOLPROPERTIES_HH_ */