1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/*
TikZiT - a GUI diagram editor for TikZ
Copyright (C) 2018 Aleks Kissinger
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "nodestyle.h"
#include "tikzit.h"
#include <QPainter>
#include <QImage>
NodeStyle *noneStyle = new NodeStyle();
NodeStyle *unknownStyle = new NodeStyle("unknown", new GraphElementData({GraphElementProperty("tikzit fill", "blue")}));
NodeStyle::NodeStyle() : Style()
{
}
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<qreal> 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);
//}
|