From eac7dee2d8ba86001afbc61c4e9d7baae7341cb8 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Tue, 10 Apr 2018 16:07:44 +0200 Subject: added edgestyles, but cant apply to nodes yet --- src/data/style.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/data/style.cpp (limited to 'src/data/style.cpp') diff --git a/src/data/style.cpp b/src/data/style.cpp new file mode 100644 index 0000000..927271c --- /dev/null +++ b/src/data/style.cpp @@ -0,0 +1,60 @@ +#include "style.h" + +Style::Style() : _name("none"), _data(0) +{ +} + +Style::Style(QString name, GraphElementData *data) : _name(name), _data(data) +{ +} + +bool Style::isNone() +{ + return _data == 0; +} + +GraphElementData *Style::data() const +{ + return _data; +} + +QString Style::name() const +{ + return _name; +} + +QColor Style::strokeColor() const +{ + if (_data == 0) return Qt::black; + + QString col = propertyWithDefault("draw", "black"); + + QColor namedColor(col); + if (namedColor.isValid()) { + return namedColor; + } else { + // TODO: read RGB colors + return QColor(Qt::black); + } +} + +// TODO +int Style::strokeThickness() const +{ + return 1; +} + +QPen Style::pen() const +{ + QPen p(strokeColor()); + p.setWidthF((float)strokeThickness() * 3.0f); + return p; +} + +QString Style::propertyWithDefault(QString prop, QString def) const +{ + QString val = _data->property("tikzit " + prop); + if (val.isNull()) val = _data->property(prop); + if (val.isNull()) val = def; + return val; +} -- cgit v1.2.3