bioformats  5.1.3
GLWindow.h
1 /*
2  * #%L
3  * OME-QTWIDGETS C++ library for display of Bio-Formats pixel data and metadata.
4  * %%
5  * Copyright © 2014 - 2015 Open Microscopy Environment:
6  * - Massachusetts Institute of Technology
7  * - National Institutes of Health
8  * - University of Dundee
9  * - Board of Regents of the University of Wisconsin-Madison
10  * - Glencoe Software, Inc.
11  * %%
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are met:
14  *
15  * 1. Redistributions of source code must retain the above copyright notice,
16  * this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * The views and conclusions contained in the software and documentation are
34  * those of the authors and should not be interpreted as representing official
35  * policies, either expressed or implied, of any organization.
36  * #L%
37  */
38 
39 #ifndef OME_QTWIDGETS_GLWINDOW_H
40 #define OME_QTWIDGETS_GLWINDOW_H
41 
42 #include <QtGui/QWindow>
43 #include <QtGui/QOpenGLFunctions>
44 #include <QtGui/QOpenGLDebugMessage>
45 
46 QT_BEGIN_NAMESPACE
47 class QPainter;
48 class QOpenGLContext;
49 class QOpenGLPaintDevice;
50 class QOpenGLDebugLogger;
51 QT_END_NAMESPACE
52 
53 namespace ome
54 {
55  namespace qtwidgets
56  {
57 
65  class GLWindow : public QWindow,
66  protected QOpenGLFunctions
67  {
68  Q_OBJECT
69 
70  public:
76  explicit GLWindow(QWindow *parent = 0);
77 
79  ~GLWindow();
80 
89  virtual void
90  render(QPainter *painter);
91 
99  virtual void
100  render();
101 
105  virtual void
106  initialize();
107 
111  virtual void
112  resize();
113 
124  void
125  setAnimating(bool animating);
126 
127  public slots:
134  void
135  renderLater();
136 
143  void
144  renderNow();
145 
154  void
155  logMessage(QOpenGLDebugMessage message);
156 
157  protected:
166  bool
167  event(QEvent *event);
168 
176  void
177  exposeEvent(QExposeEvent *event);
178 
184  void
185  resizeEvent(QResizeEvent *event);
186 
192  QOpenGLContext *
193  context() const;
194 
198  void
199  makeCurrent();
200 
201  private:
205  bool animating;
207  QOpenGLContext *glcontext;
209  QOpenGLPaintDevice *device;
211  QOpenGLDebugLogger *logger;
212  };
213 
214  }
215 }
216 
217 #endif // OME_QTWIDGETS_GLWINDOW_H
218 
219 /*
220  * Local Variables:
221  * mode:C++
222  * End:
223  */
void exposeEvent(QExposeEvent *event)
Handle expose events.
Definition: GLWindow.cpp:126
void renderNow()
Render a frame immediately.
Definition: GLWindow.cpp:153
~GLWindow()
Destructor.
Definition: GLWindow.cpp:66
QOpenGLContext * context() const
Get GL context.
Definition: GLWindow.cpp:141
void setAnimating(bool animating)
Enable or disable animating.
Definition: GLWindow.cpp:217
QOpenGLPaintDevice * device
OpenGL paint device (if render is not reimplemented in subclass).
Definition: GLWindow.h:209
virtual void initialize()
Handle initialization of the window.
Definition: GLWindow.cpp:80
void resizeEvent(QResizeEvent *event)
Handle resize events.
Definition: GLWindow.cpp:134
QOpenGLContext * glcontext
OpenGL context.
Definition: GLWindow.h:207
void renderLater()
Render a frame at the next opportunity.
Definition: GLWindow.cpp:104
Open Microscopy Environment C++ implementation.
Definition: CoreMetadata.cpp:40
virtual void resize()
Handle resizing of the window.
Definition: GLWindow.cpp:85
bool event(QEvent *event)
Handle events.
Definition: GLWindow.cpp:113
Top level GL window.
Definition: GLWindow.h:65
virtual void render()
Render using OpenGL.
Definition: GLWindow.cpp:90
bool update_pending
Update at next opportunity?
Definition: GLWindow.h:203
bool animating
Animation enabled?
Definition: GLWindow.h:205
void makeCurrent()
Make the GL context for this window the current context.
Definition: GLWindow.cpp:147
GLWindow(QWindow *parent=0)
Create a GL window.
Definition: GLWindow.cpp:55
void logMessage(QOpenGLDebugMessage message)
Log a GL debug message.
Definition: GLWindow.cpp:226
QOpenGLDebugLogger * logger
OpenGL debug logger (if logging enabled).
Definition: GLWindow.h:211