interface.cpp
Go to the documentation of this file.
00001 
00006 /*****************************************************************************
00007 ** Includes
00008 *****************************************************************************/
00009 
00010 #include <qapplication.h>
00011 #include <QDialog>
00012 #include <QGLViewer/qglviewer.h>
00013 #include "../include/qglv/gallery.hpp"
00014 #include "ui_gallery_interface.h"
00015 
00016 /*****************************************************************************
00017 ** UI Derived Classes
00018 *****************************************************************************/
00019 
00020 class ViewerInterface : public QDialog, public Ui::Dialog
00021 {
00022 public:
00023   ViewerInterface() { setupUi(this); }
00024 };
00025 
00026 /*****************************************************************************
00027 ** Interface
00028 *****************************************************************************/
00029 
00030 namespace qglv {
00031 namespace gallery {
00032 
00033 // Constructor must call the base class constructor.
00034 Interface::Interface(QWidget *parent)
00035         : QGLViewer(parent)
00036 {
00037   restoreStateFromFile();
00038   help();
00039 }
00040 
00041 void Interface::draw()
00042 {
00043   // Draws a spiral
00044   const float nbSteps = 200.0;
00045   glBegin(GL_QUAD_STRIP);
00046   for (float i=0; i<nbSteps; ++i)
00047         {
00048           float ratio = i/nbSteps;
00049           float angle = 21.0*ratio;
00050           float c = cos(angle);
00051           float s = sin(angle);
00052           float r1 = 1.0 - 0.8*ratio;
00053           float r2 = 0.8 - 0.8*ratio;
00054           float alt = ratio - 0.5;
00055           const float nor = .5;
00056           const float up = sqrt(1.0-nor*nor);
00057           glColor3f(1.0-ratio, 0.2f , ratio);
00058           glNormal3f(nor*c, up, nor*s);
00059           glVertex3f(r1*c, alt, r1*s);
00060           glVertex3f(r2*c, alt+0.05, r2*s);
00061         }
00062   glEnd();
00063 }
00064 
00065 QString Interface::helpString() const
00066 {
00067   QString text("<h2>I n t e r f a c e</h2>");
00068   text += "A GUI can be added to a QGLViewer widget using Qt's <i>Designer</i>. Signals and slots ";
00069   text += "can then be connected to and from the viewer.<br><br>";
00070   text += "You can install the QGLViewer designer plugin to make the QGLViewer appear as a ";
00071   text += "standard Qt widget in the Designer's widget tabs. See installation pages for details.";
00072   return text;
00073 }
00074 
00075 } // gallery
00076 } // qglv
00077 
00078 /*****************************************************************************
00079 ** Main
00080 *****************************************************************************/
00081 
00082 int main(int argc, char** argv)
00083 {
00084   QApplication application(argc,argv);
00085 
00086   ViewerInterface viewer;
00087   viewer.setWindowTitle("QGL Demo - Interface");
00088   viewer.show();
00089 
00090   return application.exec();
00091 }


qglv_gallery
Author(s): Daniel Stonier
autogenerated on Sat Jun 18 2016 08:19:24