00001 00002 #include "GLDriverQt.h" 00003 #include <QGLWidget> 00004 #ifndef GLDisplayListWidget_H 00005 #define GLDisplayListWidget_H 00006 00007 /*! 00008 \class GLDisplayListWidget 00009 \brief This class implements an Qt based OpenGL widget that renders 00010 UCdriver and UCdriverEx graphics calls. 00011 00012 This class is derived from QGLWidget. See the Qt reference guide for information 00013 about member functions associated with QGLwidget. 00014 00015 <p> 00016 The UCdriver (UCdriverEx) interface is provided by an internal 00017 instance of a GLDriverQt. Access to this interface is through 00018 a pointer obtained with the getGLDriverQtPtr() member function. 00019 00020 Sample Code Fragment: 00021 \code 00022 // Instantiate a GLDisplayListWidget in the containing window constructor 00023 00024 glWidget = new GLDisplayListWidget; 00025 00026 // 00027 // Elsewhere in containing window class (typically in a response function) 00028 // capture the GLDriverQt pointer. 00029 // 00030 GLDriverQt* Gldriver = glWidget->getGLDriverQtPtr(); 00031 00032 // Use the start() to open up a GL display list and then create 00033 // graphics by calling UCdriver or UCdriverEx methods. Close 00034 // the list and induce a repaint of glWidget by calling frame(). 00035 00036 Gldriver->start(); 00037 00038 Gldriver->point(...); // 00039 Gldriver->lines(...); // UCdriver or UCdriverEx calls 00040 Gldriver->pointEx(...); // 00041 00042 Gldriver->frame(); 00043 00044 \endcode 00045 00046 <i>Source</i>: 00047 <A HREF="../GLDisplayListWidget.h">GLDisplayListWidget.h</A>, 00048 <A HREF="../GLDisplayListWidget.cpp">GLDisplayListWidget.cpp</A><p> 00049 00050 @author Chris Anderson (C) UCLA 2007-09 00051 @version 2/16/09 00052 */ 00053 00054 class GLDisplayListWidget : public QGLWidget 00055 { 00056 Q_OBJECT 00057 00058 public: 00059 GLDisplayListWidget(QWidget *parent = 0); 00060 ~GLDisplayListWidget(); 00061 00062 QSize minimumSizeHint() const; 00063 QSize sizeHint() const; 00064 00065 GLDriverQt* getGLDriverQtPtr(){return &Gldriver;} 00066 00067 00068 public slots: 00069 void setXRotation(int angle); 00070 void setYRotation(int angle); 00071 void setZRotation(int angle); 00072 00073 protected: 00074 00075 void initializeGL(); 00076 void paintGL(); 00077 void resizeGL(int width, int height); 00078 void mousePressEvent(QMouseEvent *event); 00079 void mouseMoveEvent(QMouseEvent *event); 00080 00081 private: 00082 00083 GLDriverQt Gldriver; 00084 void normalizeAngle(int *angle); 00085 00086 00087 int xRot; 00088 int yRot; 00089 int zRot; 00090 00091 QPoint lastPos; 00092 00093 }; 00094 00095 #endif