/
DrawingView.h
121 lines (97 loc) · 3.79 KB
/
DrawingView.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
/***************************************************************************
* Copyright (c) 2007 Jürgen Riegel <juergen.riegel@web.de> *
* *
* This file is Drawing of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 DrawingICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef DRAWINGGUI_DRAWINGVIEW_H
#define DRAWINGGUI_DRAWINGVIEW_H
#include <Gui/MDIView.h>
#include <QGraphicsView>
QT_BEGIN_NAMESPACE
class QSlider;
class QAction;
class QActionGroup;
class QFile;
class QPopupMenu;
class QToolBar;
class QSvgWidget;
class QScrollArea;
class QPrinter;
QT_END_NAMESPACE
namespace DrawingGui
{
class DrawingGuiExport SvgView : public QGraphicsView
{
Q_OBJECT
public:
enum RendererType { Native, OpenGL, Image };
SvgView(QWidget *parent = 0);
void openFile(const QFile &file);
void setRenderer(RendererType type = Native);
void drawBackground(QPainter *p, const QRectF &rect);
public Q_SLOTS:
void setHighQualityAntialiasing(bool highQualityAntialiasing);
void setViewBackground(bool enable);
void setViewOutline(bool enable);
protected:
void wheelEvent(QWheelEvent *event);
void paintEvent(QPaintEvent *event);
private:
RendererType m_renderer;
QGraphicsItem *m_svgItem;
QGraphicsRectItem *m_backgroundItem;
QGraphicsRectItem *m_outlineItem;
QImage m_image;
};
class DrawingGuiExport DrawingView : public Gui::MDIView
{
Q_OBJECT
public:
DrawingView(Gui::Document* doc, QWidget* parent = 0);
virtual ~DrawingView();
public Q_SLOTS:
void load(const QString &path = QString());
void setRenderer(QAction *action);
void viewAll();
public:
bool onMsg(const char* pMsg,const char** ppReturn);
bool onHasMsg(const char* pMsg) const;
void onRelabel(Gui::Document *pDoc);
void print();
void printPdf();
void printPreview();
void print(QPrinter* printer);
void setDocumentObject(const std::string&);
PyObject* getPyObject();
protected:
void contextMenuEvent(QContextMenuEvent *event);
void closeEvent(QCloseEvent*);
private:
QAction *m_nativeAction;
QAction *m_glAction;
QAction *m_imageAction;
QAction *m_highQualityAntialiasingAction;
QAction *m_backgroundAction;
QAction *m_outlineAction;
SvgView *m_view;
std::string m_objectName;
QString m_currentPath;
};
} // namespace DrawingViewGui
#endif // DRAWINGGUI_DRAWINGVIEW_H