Go to the documentation of this file.00001
00006
00007
00008
00009
00010 #include <QtGui/qapplication.h>
00011 #include <QSplitter>
00012 #include <QGLViewer/qglviewer.h>
00013 #include <QGLViewer/manipulatedCameraFrame.h>
00014
00015 using namespace qglviewer;
00016
00017
00018
00019
00020
00021 class Scene
00022 {
00023 public:
00024 void draw() const;
00025 };
00026
00027 class MultiView : public QGLViewer
00028 {
00029 public:
00030 MultiView(const Scene* const s, int type, QWidget* parent, const QGLWidget* shareWidget=NULL);
00031
00032 protected :
00033 virtual void draw();
00034
00035 private:
00036 const Scene* const scene_;
00037 };
00038
00039
00040
00041
00042
00043 MultiView::MultiView(const Scene* const s, int type, QWidget* parent, const QGLWidget* shareWidget)
00044 : QGLViewer(parent, shareWidget), scene_(s)
00045 {
00046 setAxisIsDrawn();
00047 setGridIsDrawn();
00048
00049 if (type < 3)
00050 {
00051
00052 camera()->setPosition(Vec((type==0)? 1.0 : 0.0, (type==1)? 1.0 : 0.0, (type==2)? 1.0 : 0.0));
00053 camera()->lookAt(sceneCenter());
00054
00055 camera()->setType(Camera::ORTHOGRAPHIC);
00056 camera()->showEntireScene();
00057
00058
00059 WorldConstraint* constraint = new WorldConstraint();
00060 constraint->setRotationConstraintType(AxisPlaneConstraint::FORBIDDEN);
00061 camera()->frame()->setConstraint(constraint);
00062 }
00063
00064 restoreStateFromFile();
00065 }
00066
00067 void MultiView::draw()
00068 {
00069 scene_->draw();
00070 }
00071
00072
00073 void Scene::draw() const
00074 {
00075 const float nbSteps = 200.0;
00076 glBegin(GL_QUAD_STRIP);
00077 for (float i=0; i<nbSteps; ++i)
00078 {
00079 float ratio = i/nbSteps;
00080 float angle = 21.0*ratio;
00081 float c = cos(angle);
00082 float s = sin(angle);
00083 float r1 = 1.0 - 0.8f*ratio;
00084 float r2 = 0.8f - 0.8f*ratio;
00085 float alt = ratio - 0.5f;
00086 const float nor = 0.5f;
00087 const float up = sqrt(1.0-nor*nor);
00088 glColor3f(1.0-ratio, 0.2f , ratio);
00089 glNormal3f(nor*c, up, nor*s);
00090 glVertex3f(r1*c, alt, r1*s);
00091 glVertex3f(r2*c, alt+0.05f, r2*s);
00092 }
00093 glEnd();
00094 }
00095
00096
00097
00098
00099
00100 int main(int argc, char** argv)
00101 {
00102 QApplication application(argc,argv);
00103
00104
00105 QSplitter *hSplit = new QSplitter(Qt::Vertical);
00106 QSplitter *vSplit1 = new QSplitter(hSplit);
00107 QSplitter *vSplit2 = new QSplitter(hSplit);
00108
00109
00110 Scene* s = new Scene();
00111
00112
00113 MultiView side (s,0,vSplit1);
00114 MultiView top (s,1,vSplit1, &side);
00115 MultiView front (s,2,vSplit2, &side);
00116 MultiView persp (s,3,vSplit2, &side);
00117
00118
00119 hSplit->setWindowTitle("multiView");
00120
00121
00122 hSplit->show();
00123
00124 return application.exec();
00125 }