-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.hpp
162 lines (134 loc) · 4.1 KB
/
view.hpp
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
/****************************************************************************
**
** Copyright (C) 2009 TECHNOGERMA Systems France and/or its subsidiary(-ies).
** Contact: Technogerma Systems France Information ([email protected])
**
** This file is part of the GICS library.
**
** Commercial Usage
** Licensees holding valid GICS Commercial licenses may use this file in
** accordance with the GICS Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and TECHNOGERMA Systems France.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL3.txt included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at [email protected].
**
****************************************************************************/
#ifndef VIEW_HPP
#define VIEW_HPP
#include <QGraphicsView>
#include <QGraphicsScene>
namespace gics
{
class Instrument;
}
class QTimeLine;
class QGraphicsWidget;
class QGraphicsLayout;
class QGraphicsPixmapItem;
class QResizeEvent;
/**
* \brief Main window class
*
* This is the main class of the application, it handles the
* graphics scene, view and instruments.
*/
class View : public QGraphicsView
{
Q_OBJECT
public:
/**
* \brief Default constructor
*
* \param parent Parent widget (0 by default)
*/
View(QWidget* parent = 0);
/**
* \brief Set the front instrument
*
* \param instrument Front instrument
*/
void setFrontInstrument(gics::Instrument* instrument);
/**
* \brief Get the front instrument
*
* \return Current front instrument
*/
gics::Instrument* frontInstrument() const;
/**
* \brief Set the back instrument
*
* \param instrument Back instrument
*/
void setBackInstrument(gics::Instrument* instrument);
/**
* \brief Get the back instrument
*
* \return Current back instrument
*/
gics::Instrument* backInstrument() const;
public slots:
/**
* \brief Switch between the front instrument and the back instrument
*/
void flip();
/**
* \brief Activate or deactivate the OpenGL renderer
*
* \param use True to enable the OpenGL renderer, false to disable it
*/
void useOpenGL(bool use);
protected:
/**
* \brief Called when the view is resized
*
* \param event Event's attributes
*/
virtual void resizeEvent(QResizeEvent* event);
/**
* \brief Called when the mouse moves over the view
*
* We override this event in order to ignore it, so that it is
* caught by the parent window.
*
* \param event Event's attributes
*/
virtual void mouseMoveEvent(QMouseEvent* event);
private:
/**
* \brief Return a pixmap containing a rendererd item
*
* \param instrument Item to render
*
* \return Pixmap containing the capture
*/
QPixmap capture(gics::Instrument* instrument);
private slots:
/**
* \brief Slot called whenever the timeline is updated
*
* \param value Current timeline's value
*/
void handleTimelineUpdated(qreal value);
/**
* \brief Slot called when the execution of the timeline finishes
*/
void handleTimelineFinished();
private:
QGraphicsScene m_scene; ///< Graphics scene containing the instruments
gics::Instrument* m_front; ///< Front instrument
gics::Instrument* m_back; ///< Back instrument
QTimeLine* m_timeline; ///< Timeline used for the flipping effect
QGraphicsPixmapItem* m_frontCapture; ///< Capture of the front instrument
QGraphicsPixmapItem* m_backCapture; ///< Capture of the back instrument
};
#endif // VIEW_HPP