-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmygraphics.h
169 lines (143 loc) · 4.38 KB
/
mygraphics.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#ifndef MYGRAPHICS_H
#define MYGRAPHICS_H
#include <QMainWindow>
#include <QtGui>
#include <QtCore>
#include "mygraphicsscene.h"
#include "GluGraphicsView.h"
#include "global_types.h"
#include <QGraphicsItem>
#include <QShowEvent>
#include <QMap>
#include <QList>
QT_BEGIN_NAMESPACE
class QAction;
class QToolBar;
class QMenu;
class QUndoStack;
class QUndoView;
QT_END_NAMESPACE
class QtVariantProperty;
class QtProperty;
namespace Ui {
class MyGraphics;
}
class MyGraphics : public QMainWindow
{
Q_OBJECT
public:
explicit MyGraphics(QWidget *parent = 0);
~MyGraphics();
void writeItems(QDataStream &out, const QList<QGraphicsItem *> &itemList);
void setDirty(bool on);
void loadFile();
void clear();
void readItems(QDataStream &in);
QList<QGraphicsItem*> readItems(QDataStream &in, int offset);
void updateExpandState();
void addProperty(QtVariantProperty *property, const QString &id);
void maxzValue(qreal mxValue);
void setItemszValue(QList<QGraphicsItem*> &itList);
protected:
void showEvent(QShowEvent *event);
void closeEvent(QCloseEvent *event);
signals:
void firstSelectedItem(QGraphicsItem *item);
private slots:
void createUndoView();
void addCustomItem();
void itemClicked(QGraphicsItem *item);
void itemsMoving(QGraphicsItem *item);
void itemsMoved(QMap<QGraphicsItem*, QPointF> itemsnewpos,
QMap<QGraphicsItem*, QPointF> itemsoldpos);
void selectionChanged();
void valueChanged(QtProperty *property, const QVariant &value);
void fileNew();
void fileOpen();
bool fileSave();
bool fileSaveAs();
void fileExport();
void filePrint();
void editCopy();
void editCut();
void editPaste();
void editDelete();
void editCleanScreen();
void editAlign();
void editBringToFront();
void editSendToBack();
void viewZoomIn();
void viewZoomOut();
void viewRestore();
void openRecentFile();
private:
void readSettings();
void writeSettings();
bool okToClearData();
void copyItems(const QList<QGraphicsItem*> &items);
void selectItems(const QSet<QGraphicsItem*> &items);
void createActions();
void createMenusAndToolBars();
void createConnections();
void exportImage(const QString &filename);
void exportSvg(const QString &filename);
void paintScene(QPainter *painter);
void populateMenuAndToolBar(QMenu *menu,
QToolBar *toolBar,
QList<QAction *> actions);
void populateCoordinates(const Qt::Alignment &alignment,
QVector<double> *coordinates,
const QList<QGraphicsItem*> &items);
void animateAlignment(const QList<QGraphicsItem *> &items,
const QList<QPointF> &positions);
void setCurrentFile(const QString &fileName);
void updateRecentFileActions();
QString strippedName(const QString &fullFileName);
private:
Ui::MyGraphics *ui;
GluGraphicsView *view;
MyGraphicsScene *scene;
QPrinter *printer;
QAction *fileNewAction;
QAction *fileOpenAction;
QAction *fileSaveAction;
QAction *fileSaveAsAction;
QAction *fileExportAction;
QAction *filePrintAction;
QAction *fileQuitAction;
QAction *editUndoAction;
QAction *editRedoAction;
QAction *editCopyAction;
QAction *editCutAction;
QAction *editPasteAction;
QAction *editDeleteAction;
QAction *editCleanScreenAction;
QAction *editAlignmentAction;
QAction *editAlignLeftAction;
QAction *editAlignRightAction;
QAction *editAlignTopAction;
QAction *editAlignBottomAction;
QAction *editBringToFrontAction;
QAction *editSendToBackAction;
QAction *viewZoomInAction;
QAction *viewZoomOutAction;
QAction *viewRestoreAction;
QStringList recentFiles;
QString curFile;
enum { MaxRecentFiles = 5 };
QAction *recentFileActions[MaxRecentFiles];
QAction *separatorAction;
QPointF originP;
class QtVariantPropertyManager *variantManager;
class QtTreePropertyBrowser *propertyEditor;
QGraphicsItem *currentItem;
QMap<QtProperty *, QString> propertyToId;
QMap<QString, QtVariantProperty *> idToProperty;
QMap<QString, bool> idToExpanded;
QUndoStack *undoStack;
QUndoView *undoView;
int pasteOffset;
qreal z_value;
qreal maxValue;
};
#endif // MYGRAPHICS_H