From 6359b28b155355e0be67961cc21eccdbd2c61cc2 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Sat, 6 Oct 2018 15:49:50 +0200 Subject: unified node and edge syles --- src/data/nodestyle.cpp | 145 +++++++++++++++++++++++++------------------------ 1 file changed, 75 insertions(+), 70 deletions(-) (limited to 'src/data/nodestyle.cpp') diff --git a/src/data/nodestyle.cpp b/src/data/nodestyle.cpp index 8bdb763..b379565 100644 --- a/src/data/nodestyle.cpp +++ b/src/data/nodestyle.cpp @@ -34,74 +34,79 @@ NodeStyle::NodeStyle(QString name, GraphElementData *data): Style(name, data) { } -QColor NodeStyle::fillColor(bool tikzitOverride) const -{ - if (_data == 0) return Qt::white; - - QString col = propertyWithDefault("fill", "white", tikzitOverride); - return tikzit->colorByName(col); -} - -QBrush NodeStyle::brush() const -{ - return QBrush(fillColor()); -} - -QString NodeStyle::shape(bool tikzitOverride) const -{ - return propertyWithDefault("shape", "circle", tikzitOverride); -} - -QPainterPath NodeStyle::path() const -{ - QPainterPath pth; - QString sh = shape(); - - if (sh == "rectangle") { - pth.addRect(-30.0f, -30.0f, 60.0f, 60.0f); - } else { // default is 'circle' - pth.addEllipse(QPointF(0.0f,0.0f), 30.0f, 30.0f); - } - return pth; -} - -QPainterPath NodeStyle::palettePath() const -{ - return path(); -} - -QIcon NodeStyle::icon() const -{ - // draw an icon matching the style - QImage px(100,100,QImage::Format_ARGB32_Premultiplied); - px.fill(Qt::transparent); - - - QPainter painter(&px); - painter.setRenderHint(QPainter::Antialiasing); - QPainterPath pth = path(); - pth.translate(50.0f, 50.0f); - - if (_data == 0) { - QColor c(180,180,200); - painter.setPen(QPen(c)); - painter.setBrush(QBrush(c)); - painter.drawEllipse(QPointF(50.0f,50.0f), 3,3); - - QPen pen(QColor(180,180,220)); - pen.setWidth(3); - QVector p; - p << 2.0 << 2.0; - pen.setDashPattern(p); - painter.setPen(pen); - painter.setBrush(Qt::NoBrush); - painter.drawPath(pth); - } else { - painter.setPen(pen()); - painter.setBrush(brush()); - painter.drawPath(pth); - } - - return QIcon(QPixmap::fromImage(px)); -} +//QColor NodeStyle::fillColor(bool tikzitOverride) const +//{ +// if (_data == 0) return Qt::white; + +// QString col = propertyWithDefault("fill", "white", tikzitOverride); +// return tikzit->colorByName(col); +//} + +//QBrush NodeStyle::brush() const +//{ +// return QBrush(fillColor()); +//} + +//QString NodeStyle::shape(bool tikzitOverride) const +//{ +// return propertyWithDefault("shape", "circle", tikzitOverride); +//} + +//QPainterPath NodeStyle::path() const +//{ +// QPainterPath pth; +// QString sh = shape(); + +// if (sh == "rectangle") { +// pth.addRect(-30.0f, -30.0f, 60.0f, 60.0f); +// } else { // default is 'circle' +// pth.addEllipse(QPointF(0.0f,0.0f), 30.0f, 30.0f); +// } +// return pth; +//} + +//QPainterPath NodeStyle::palettePath() const +//{ +// return path(); +//} + +//QIcon NodeStyle::icon() const +//{ +// // draw an icon matching the style +// QImage px(100,100,QImage::Format_ARGB32_Premultiplied); +// px.fill(Qt::transparent); + + +// QPainter painter(&px); +// painter.setRenderHint(QPainter::Antialiasing); +// QPainterPath pth = path(); +// pth.translate(50.0f, 50.0f); + +// if (_data == 0) { +// QColor c(180,180,200); +// painter.setPen(QPen(c)); +// painter.setBrush(QBrush(c)); +// painter.drawEllipse(QPointF(50.0f,50.0f), 3,3); + +// QPen pen(QColor(180,180,220)); +// pen.setWidth(3); +// QVector p; +// p << 2.0 << 2.0; +// pen.setDashPattern(p); +// painter.setPen(pen); +// painter.setBrush(Qt::NoBrush); +// painter.drawPath(pth); +// } else { +// painter.setPen(pen()); +// painter.setBrush(brush()); +// painter.drawPath(pth); +// } + +// return QIcon(QPixmap::fromImage(px)); +//} + +//QString NodeStyle::category() +//{ +// return propertyWithDefault("tikzit category", "", false); +//} -- cgit v1.2.3