DrawingProperties.cc 6.51 KB
/*
 * DrawingProperties.cc
 *
 *  Created on: Dec 9, 2013
 *      Author: amdadev
 */

#include <cmath>

#include "DrawingProperties.hh"


namespace plot {

DrawingProperties::DrawingProperties() :
	_lineProperties(),
	_symbolProperties(),
	_timeTickProperties(),
	_intervalTickProperties(),
	_resamplingProperties(),
	_errorBarProperties(),
	_xAxisId(""),
	_yAxisId(""),
	_zAxisId(""),
	_color(),
	_min(nan("")),
	_max(nan("")),
	_maxResolution(3000)
{}
DrawingProperties::DrawingProperties(const DrawingProperties& ref_) :
	_lineProperties(ref_._lineProperties),
	_symbolProperties(ref_._symbolProperties),
	_timeTickProperties(ref_._timeTickProperties),
	_intervalTickProperties(ref_._intervalTickProperties),
	_resamplingProperties(ref_._resamplingProperties),
	_errorBarProperties(ref_._errorBarProperties),
	_xAxisId(ref_._xAxisId),
	_yAxisId(ref_._yAxisId),
	_zAxisId(ref_._zAxisId),
	_color(ref_._color),
	_min(ref_._min),
	_max(ref_._max),
	_maxResolution(ref_._maxResolution)
{
	// propagate general color
	if( !_lineProperties.getColor().isSet() && _color.isSet()){
		_lineProperties.setColor(_color);
	}
	if( !_symbolProperties.getColor().isSet() && _color.isSet() ){
		_symbolProperties.setColor(_color);
	}
}

DrawingProperties::~DrawingProperties()
{}

DrawingProperties& DrawingProperties::operator=(const DrawingProperties& ref_)
{
	_xAxisId = ref_._xAxisId;
	_yAxisId = ref_._yAxisId;
	_zAxisId = ref_._zAxisId;
	_lineProperties =  ref_._lineProperties;
	_symbolProperties = ref_._symbolProperties;
	_timeTickProperties = ref_._timeTickProperties;
	_intervalTickProperties = ref_._intervalTickProperties;
	_resamplingProperties = ref_._resamplingProperties;
	_errorBarProperties = ref_._errorBarProperties;
	_color = ref_._color;
	_min = ref_._min;
	_max = ref_._max;
	_maxResolution = ref_._maxResolution;
	// propagate color_ if not set in line or symbol:
	if( _color.isSet() ){
		if( !_lineProperties.getColor().isSet()){
			_lineProperties.setColor(_color);
		}
		if( !_symbolProperties.getColor().isSet() ){
			_symbolProperties.setColor(_color);
		}
	}
	return *this;
}

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

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

const LineProperties& DrawingProperties::getLineProperties() const
{
	return _lineProperties;
}

LineProperties& DrawingProperties::getLineProperties()
{
	return _lineProperties;
}

void DrawingProperties::setLineProperties(const LineProperties& lineProperties)
{
	_lineProperties = lineProperties;
}

const SymbolProperties& DrawingProperties::getSymbolProperties() const
{
	return _symbolProperties;
}
SymbolProperties& DrawingProperties::getSymbolProperties()
{
	return _symbolProperties;
}

void DrawingProperties::setSymbolProperties(const SymbolProperties& symbolProperties)
{
	_symbolProperties = symbolProperties;
}

const TimeTickProperties& DrawingProperties::getTimeTickProperties() const
{
	return _timeTickProperties;
}

TimeTickProperties& DrawingProperties::getTimeTickProperties()
{
	return _timeTickProperties;
}

void DrawingProperties::setTimeTickProperties(const TimeTickProperties& timeTickProperties)
{
	_timeTickProperties = timeTickProperties;
}

const IntervalTickProperties& DrawingProperties::getIntervalTickProperties() const
{
	return _intervalTickProperties;
}

IntervalTickProperties& DrawingProperties::getIntervalTickProperties()
{
	return _intervalTickProperties;
}

void DrawingProperties::setIntervalTickProperties(const IntervalTickProperties& intervalTickProperties)
{
	_intervalTickProperties = intervalTickProperties;
}

const std::string& DrawingProperties::getXAxisId() const
{
	return _xAxisId;
}

void DrawingProperties::setXAxisId(const std::string& axisId)
{
	_xAxisId = axisId;
}

const std::string& DrawingProperties::getYAxisId() const
{
	return _yAxisId;
}

void DrawingProperties::setYAxisId(const std::string& axisId)
{
	_yAxisId = axisId;
}

const std::string& DrawingProperties::getZAxisId() const
{
	return _zAxisId;
}

void DrawingProperties::setZAxisId(const std::string& axisId)
{
	_zAxisId = axisId;
}

double DrawingProperties::getMax() const {
	return _max;
}

void DrawingProperties::setMax(double max) {
	_max = max;
}

double DrawingProperties::getMin() const {
	return _min;
}

void DrawingProperties::setMin(double min) {
	_min = min;
}

int DrawingProperties::getMaxResolution() const{
	return _maxResolution;
}
void DrawingProperties::setMaxResolution(const int resolution){
	_maxResolution = resolution;
}

const ResamplingProperties& DrawingProperties::getResamplingProperties() const
{
	return _resamplingProperties;
}

ResamplingProperties& DrawingProperties::getResamplingProperties()
{
	return _resamplingProperties;
}

void DrawingProperties::setResamplingProperties(const ResamplingProperties& resamplingProperties)
{
	_resamplingProperties = resamplingProperties;
}

const ErrorBarProperties& DrawingProperties::getErrorBarProperties() const {
	return _errorBarProperties;
}

ErrorBarProperties& DrawingProperties::getErrorBarProperties(){
	return _errorBarProperties;
}

void DrawingProperties::setErrorBarProperties(
		const ErrorBarProperties& errorBarProperties) {
	_errorBarProperties = errorBarProperties;
}

void DrawingProperties::dump (std::ostream& out_, std::string& prefix_){
	out_ << prefix_ << "yAxisId="<< _yAxisId << std::endl;
	out_ << prefix_ << "zAxisId="<< _zAxisId << std::endl;
	out_ << prefix_ << "resolution="<<_maxResolution << std::endl;
	_color.dump(out_, prefix_);
	_lineProperties.dump(out_, prefix_);
	_symbolProperties.dump(out_, prefix_);
	_timeTickProperties.dump(out_, prefix_);
	_intervalTickProperties.dump(out_, prefix_);
	_resamplingProperties.dump(out_, prefix_);
	_errorBarProperties.dump(out_, prefix_);
}

std::ostream& operator<<(std::ostream& out_, const DrawingProperties& prop_){
	out_ << "[DRAWING PROPERTIES]" << std::endl;
	out_ << "{" << std::endl;
	out_ << "  xAxis Id = "<< prop_._xAxisId << std::endl;
	out_ << "  yAxis Id = "<< prop_._yAxisId << std::endl;
	out_ << "  zAxis Id = "<< prop_._zAxisId << std::endl;
	out_ << "  default color = "<<prop_._color << std::endl;
	out_ << "  resolution = "<<prop_._maxResolution << std::endl;
	out_ << "  " << prop_._lineProperties << std::endl;
	out_ << "  " << prop_._symbolProperties << std::endl;
	out_ << "  " << prop_._timeTickProperties << std::endl;
	out_ << "  " << prop_._intervalTickProperties << std::endl;
	out_ << "  " << prop_._resamplingProperties << std::endl;
	out_ << "  " << prop_._errorBarProperties << std::endl;
	out_ << "}" << std::endl;
	return out_;
}

} /* namespace plot */