KGLLib
glwidget.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef KGLLIB_GLWIDGET_H
00019 #define KGLLIB_GLWIDGET_H
00020
00021
00022 #include "kgllib.h"
00023 #include <QtOpenGL/QGLWidget>
00024 #include <QtCore/QList>
00025
00026 #include <Eigen/Core>
00027
00028 class QAction;
00029
00030
00031 namespace KGLLib
00032 {
00033 class Camera;
00034 class FPSCounter;
00035 class TextRenderer;
00036
00048 class KGLLIB_EXPORT GLWidget : public QGLWidget
00049 {
00050 Q_OBJECT
00051 public:
00052 explicit GLWidget(QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
00053 explicit GLWidget(QGLContext* context, QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
00054 explicit GLWidget(const QGLFormat& format, QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
00055
00056 virtual ~GLWidget();
00057
00062 KGLLib::Camera* camera() const { return mCamera; }
00067 KGLLib::FPSCounter* fpsCounter() const { return mFpsCounter; }
00068
00072 KGLLib::TextRenderer* textRenderer() const;
00073
00077 bool glInitialized() const { return mGLInitialized; }
00078
00079 public Q_SLOTS:
00080 void toggleShowFps();
00081 void toggleWireframeMode();
00082
00083 protected:
00095 virtual void initializeGL();
00099 virtual void initializeGL(Renderer* r);
00105 virtual void resizeGL(int width, int height);
00116 virtual void paintGL();
00123 virtual void render();
00124
00130 void setClearColor(const Eigen::Vector4f& c);
00135 void setAutomaticClear(bool clear);
00136
00137 Eigen::Vector4f clearColor() const { return mClearColor; }
00138 bool automaticClear() const { return mAutomaticClear; }
00139
00150 void setErrorText(const QString& text);
00155 QString errorText() const { return mErrorText; }
00156
00161 bool shortcutsEnabled() const { return mShortcutsEnabled; }
00172 virtual void setShortcutsEnabled( bool enabled);
00173
00174 private:
00175 void init();
00176
00177 private:
00178 KGLLib::Camera* mCamera;
00179 KGLLib::FPSCounter* mFpsCounter;
00180 mutable KGLLib::TextRenderer* mTextRenderer;
00181
00182 bool mAutomaticClear;
00183 Eigen::Vector4f mClearColor;
00184 bool mGLInitialized;
00185
00186 bool mShowFps;
00187 bool mWireframeMode;
00188 QString mErrorText;
00189
00190
00191 QList<QAction*> mShortcuts;
00192 bool mShortcutsEnabled;
00193 };
00194
00195 }
00196
00197 #endif