summaryrefslogtreecommitdiff
path: root/src/data/style.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/style.cpp')
-rw-r--r--src/data/style.cpp75
1 files changed, 51 insertions, 24 deletions
diff --git a/src/data/style.cpp b/src/data/style.cpp
index d0f011d..f4aa892 100644
--- a/src/data/style.cpp
+++ b/src/data/style.cpp
@@ -62,7 +62,22 @@ QColor Style::fillColor(bool tikzitOverride) const
QBrush Style::brush() const
{
- return QBrush(fillColor());
+ if (hasFill()) {
+ return QBrush(fillColor());
+ } else {
+ return Qt::NoBrush;
+ }
+}
+
+bool Style::hasFill() const
+{
+ return (propertyWithDefault("fill", "none") != "none");
+}
+
+bool Style::hasStroke() const
+{
+ if (isEdgeStyle()) return propertyWithDefault("draw", "black") != "none";
+ else return (propertyWithDefault("draw", "none") != "none");
}
QString Style::shape(bool tikzitOverride) const
@@ -152,24 +167,28 @@ Style::DrawStyle Style::drawStyle() const
QPen Style::pen() const
{
- QPen p(strokeColor());
- p.setWidthF((float)strokeThickness() * 2.0f);
-
- QVector<qreal> pat;
- switch (drawStyle()) {
- case Dashed:
- pat << 3.0 << 3.0;
- p.setDashPattern(pat);
- break;
- case Dotted:
- pat << 1.0 << 1.0;
- p.setDashPattern(pat);
- break;
- case Solid:
- break;
- }
+ if (hasStroke()) {
+ QPen p(strokeColor());
+ p.setWidthF((float)strokeThickness() * 2.0f);
+
+ QVector<qreal> pat;
+ switch (drawStyle()) {
+ case Dashed:
+ pat << 3.0 << 3.0;
+ p.setDashPattern(pat);
+ break;
+ case Dotted:
+ pat << 1.0 << 1.0;
+ p.setDashPattern(pat);
+ break;
+ case Solid:
+ break;
+ }
- return p;
+ return p;
+ } else {
+ return Qt::NoPen;
+ }
}
QPainterPath Style::path() const
@@ -225,19 +244,27 @@ QIcon Style::icon() const
px.fill(Qt::transparent);
QPainter painter(&px);
- if (_data == 0) {
- QPen pen(Qt::black);
- pen.setWidth(3);
- } else {
- painter.setPen(pen());
+// if (_data == 0) {
+// QPen pen(Qt::black);
+// pen.setWidth(3);
+// } else {
+// painter.setPen(pen());
+// }
+
+ QPen pn = pen();
+ painter.setPen(pn);
+
+ if (hasFill()) {
+ painter.fillRect(10,50,80,30,brush());
}
painter.drawLine(10, 50, 90, 50);
- QPen pn = pen();
pn.setStyle(Qt::SolidLine);
painter.setPen(pn);
+
+
switch (arrowHead()) {
case Pointer:
painter.drawLine(90,50,80,40);