diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2018-04-10 16:07:44 +0200 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2018-04-10 16:07:44 +0200 |
commit | eac7dee2d8ba86001afbc61c4e9d7baae7341cb8 (patch) | |
tree | 4214eb557fbeee94144c298bd2ec5e5a0e2df27f /src/data/style.cpp | |
parent | facfa3e8aa7e3c278b0016c02c6a9f1f019903e2 (diff) |
added edgestyles, but cant apply to nodes yet
Diffstat (limited to 'src/data/style.cpp')
-rw-r--r-- | src/data/style.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
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; +} |