-
Notifications
You must be signed in to change notification settings - Fork 1
/
FractalTree.h
108 lines (93 loc) · 2.53 KB
/
FractalTree.h
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
#ifndef FRACTALTREE_H
#define FRACTALTREE_H
#include <QMainWindow>
#include <QLayout>
#include <QLabel>
#include <QRect>
#include <QFileDialog>
#include <limits>
#include <QValidator>
#include <QTimer>
#include <QColorDialog>
#include <QSpinBox>
#include <QSignalMapper>
#include <QMenu>
#include <QCursor>
#include <QErrorMessage>
#include <QPainter>
#include <QPainterPath>
#include <QMap>
#include "FractalTreeImage.h"
#include "SpinBox.h"
#include "ExtendedButton.h"
#include "ReadOnlyLineEdit.h"
#include <iostream>
using namespace std;
namespace Ui {
class FractalTree;
}
class FractalTree : public QMainWindow
{
Q_OBJECT
public:
explicit FractalTree(QWidget *parent = 0);
~FractalTree();
public slots:
void render();
void save();
void updateTree();
void clickedLeafColor(QWidget *widget);
void clickedTreeColor();
void changedValue();
void updateColor();
void pushedAddColorButton();
void rightClickedColor(QWidget *widget);
void changedFilter(QObject *dialog);
signals:
protected:
Ui::FractalTree *ui;
FractalTreeImage *curTree;
QTimer *timer;
SpinBox *widthBox;
SpinBox *heightBox;
SpinBox *branchesBox;
SpinBox *depthBox;
SpinBox *rootBox;
QColor *colorPtr;
QPushButton *addColorButton;
bool changedTree;
QColorDialog colorDialog;
QColor treeColor;
QMap<QWidget*, QColor> leafColors;
QList<QPushButton *> leafColorButtons;
QSignalMapper leafColorLCMapper;
QSignalMapper leafColorRCMapper;
ReadOnlyLineEdit *curSeedEdit;
ReadOnlyLineEdit *curHashEdit;
//private class
class SeedValidator : public QValidator {
QValidator::State validate(QString &str, int &) const {
if (str.trimmed().isEmpty() || str.trimmed().startsWith("#"))
return State::Acceptable;
bool ok;
long value = str.toLong(&ok);
if (ok)
ok = value <= UINT_MAX;
return ok?State::Acceptable:State::Invalid;
}
};
void drawTree();
QString colorToRGBA(const QColor &color = QColor(0, 198, 0, 200));
void updateStyleSheet();
void changeColor(QColor &curColor);
void addLeafColor(QColor color = QColor(0, 198, 0, 200));
void addAddColorButton();
void deleteLeafColor(QWidget *widget);
bool checkHashList(QStringList list);
QColor getColorFromHash(QString hash);
//needls seperated with |
bool endsWith(QString text, QString needls);
protected slots:
void resizeEvent(QResizeEvent *event);
};
#endif // FRACTALTREE_H