diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..976d9ca --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +## Version: $Id$ +## +###################################################################### +## +### Commentary: +## +###################################################################### +## +### Change Log: +## +###################################################################### +## +### Code: + +.qmake.stash +Makefile +PyQGLViewer.api +PyQGLViewer.pro +build +src/sip/QGLViewerModuleConfig.sip + +###################################################################### +### .gitignore ends here diff --git a/configureQt5.py b/configureQt5.py old mode 100644 new mode 100755 index 4303eaf..dc4ac61 --- a/configureQt5.py +++ b/configureQt5.py @@ -1,16 +1,18 @@ +#! /usr/bin/env python + # Copyright (c) 2016, Riverbank Computing Limited # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. -# +# # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. -# +# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -25,19 +27,16 @@ # This is v2.0 of this boilerplate. - from distutils import sysconfig import glob import os import optparse import sys - ############################################################################### # You shouldn't need to modify anything above this line. ############################################################################### - class PyQGLViewerConfiguration(object): """ This class encapsulates the module specific information. """ @@ -318,7 +317,7 @@ def apply_options(target_configuration, options): else: libname = 'lib'+libname+'.dylib' else: - libname = 'lib'+libname+'.so' + libname = 'lib'+libname+'.so' defaultdir = [ qglviewer_includes, pj(qglviewer_includes, "QGLViewer"), pj(qglviewer_includes,os.path.pardir,'lib'),pj('/','usr','lib'),pj('/','usr','local','lib'),pj('/','opt','local','lib')] for ddir in defaultdir: @@ -328,7 +327,7 @@ def apply_options(target_configuration, options): break target_configuration.qglviewer_libpath = qglviewer_libpath - + if options.qglviewer_includes: print ("Found libQGLViewer-%s in '%s'." % (target_configuration.qglviewer_version_str, qglviewer_includes)) else: @@ -1139,7 +1138,7 @@ def _create_optparser(target_config, pkg_config): if _has_stubs(pkg_config): p.add_option('--stubsdir', dest='stubsdir', type='string', default=None, action='callback', - callback=optparser_store_abspath, metavar="DIR", + callback=optparser_store_abspath, metavar="DIR", help="the PEP 484 stubs will be installed in DIR [default: " "with the module]") p.add_option('--no-stubs', dest='no_stubs', default=False, @@ -1150,7 +1149,7 @@ def _create_optparser(target_config, pkg_config): if pkg_config.qscintilla_api_file: p.add_option('--apidir', '-a', dest='apidir', type='string', default=None, action='callback', - callback=optparser_store_abspath, metavar="DIR", + callback=optparser_store_abspath, metavar="DIR", help="the QScintilla API file will be installed in DIR " "[default: QT_INSTALL_DATA/qsci]") p.add_option('--no-qsci-api', dest='no_qsci_api', default=False, @@ -1227,7 +1226,7 @@ def _create_optparser(target_config, pkg_config): "[default: %s]" % target_config.pyqt_sip_dir) p.add_option('--concatenate', '-c', dest='concat', default=False, - action='store_true', + action='store_true', help="concatenate the C++ source files") p.add_option('--concatenate-split', '-j', dest='split', type='int', default=1, metavar="N", @@ -1527,11 +1526,11 @@ def _generate_pro(target_config, opts, module_config): else: entry_point = 'init%s' % mname - exp = open('%s.exp' % mname, 'wt') - exp.write('{ global: %s; local: *; };' % entry_point) - exp.close() + # exp = open('%s.exp' % mname, 'wt') + # exp.write('{ global: %s; local: *; };' % entry_point) + # exp.close() - pro.write('QMAKE_LFLAGS += -Wl,--version-script=%s.exp\n' % mname) + # pro.write('QMAKE_LFLAGS += -Wl,--version-script=%s.exp\n' % mname) if target_config.prot_is_public: pro.write('DEFINES += SIP_PROTECTED_IS_PUBLIC protected=public\n') diff --git a/doc/INSTALL.txt b/doc/INSTALL.txt index c60f43d..80f32bd 100644 --- a/doc/INSTALL.txt +++ b/doc/INSTALL.txt @@ -1,35 +1,42 @@ - -This project requires a recent version of SIP (tested with 4.17), Qt4, PyQt4 and libQGLViewer. - -Note: PyQt4 should be installed with its sip and development files. - -To build Python wrapper , you should simply do the following command -> python configure.py -You can specify the source repository of libQGLViewer with -Q option. -For instance -> python configure.py -Q ../libQGLViewer-2.2.6-3 - -Note: on windows you may have to specify the include and lib directories also, using absolute paths -> python configure.py -Q ../libQGLViewer-2.2.6-3 -I c:\path_to_libQGLViewer-2.2.6-3 -L c:\path_to_libQGLViewer-2.2.6-3\QGLViewer\release - -Then you simply have to compile and install with -> make (or nmake) -> make install (or nmake install, you should be root) - -You can then test the new module with all examples -that you can find in the directory PyQGLViewer/examples. - -Good luck, - -Fred - - ------------- -News: -The setup.py file has been updated to allow you to compile the project. -For this, -python setup.py build # to compile -python setup.py install # to install on your system -python setup.py bdist # to create a binary distribution - - +This project requires a recent version of SIP (tested with 4.17), Qt4, PyQt4 and libQGLViewer. + +Note: PyQt4 should be installed with its sip and development files. + +To build Python wrapper , you should simply do the following command +> python configure.py +You can specify the source repository of libQGLViewer with -Q option. +For instance +> python configure.py -Q ../libQGLViewer-2.2.6-3 + +Note: on windows you may have to specify the include and lib directories also, using absolute paths +> python configure.py -Q ../libQGLViewer-2.2.6-3 -I c:\path_to_libQGLViewer-2.2.6-3 -L c:\path_to_libQGLViewer-2.2.6-3\QGLViewer\release + +Then you simply have to compile and install with +> make (or nmake) +> make install (or nmake install, you should be root) + +You can then test the new module with all examples +that you can find in the directory PyQGLViewer/examples. + +Good luck, + +Fred + + +------------ +News: +The setup.py file has been updated to allow you to compile the project. +For this, +python setup.py build # to compile +python setup.py install # to install on your system +python setup.py bdist # to create a binary distribution + + +------------ +News: +The configureQt5.py file has been updated to allow you to compile the project. +For this, +chmod u+x configureQt5.py +./configureQt5.py --qglviewer-sources=/path/to/qglviewer/ --qglviewer-libpath=/path/to/qglviewer/ --qglviewer-libs=QGLViewer --sip-incdir=/usr/local/include/ # --qglviewer-libs=QGLViewer-qt5 on Linux +make +sudo make install diff --git a/src/sip/QGLViewerModule.sip b/src/sip/QGLViewerModule.sip index 53cbdec..4e19f89 100644 --- a/src/sip/QGLViewerModule.sip +++ b/src/sip/QGLViewerModule.sip @@ -28,13 +28,14 @@ %Import QtOpenGL/QtOpenGLmod.sip %Import QtXml/QtXmlmod.sip -%Timeline {QGLViewer_2_2_3 QGLViewer_2_2_4 QGLViewer_2_2_5 QGLViewer_2_2_6 - QGLViewer_2_3_0 QGLViewer_2_3_1 QGLViewer_2_3_2 QGLViewer_2_3_3 QGLViewer_2_3_4 QGLViewer_2_3_5 +%Timeline {QGLViewer_2_2_3 QGLViewer_2_2_4 QGLViewer_2_2_5 QGLViewer_2_2_6 + QGLViewer_2_3_0 QGLViewer_2_3_1 QGLViewer_2_3_2 QGLViewer_2_3_3 QGLViewer_2_3_4 QGLViewer_2_3_5 QGLViewer_2_3_6 QGLViewer_2_3_7 QGLViewer_2_3_8 QGLViewer_2_3_9 QGLViewer_2_3_10 QGLViewer_2_3_11 QGLViewer_2_3_12 QGLViewer_2_3_13 QGLViewer_2_3_14 QGLViewer_2_3_15 QGLViewer_2_3_16 QGLViewer_2_3_17 QGLViewer_2_4_0 QGLViewer_2_4_1 QGLViewer_2_5_0 QGLViewer_2_5_1 QGLViewer_2_5_2 QGLViewer_2_5_3 QGLViewer_2_5_4 - QGLViewer_2_6_0 QGLViewer_2_6_1 QGLViewer_2_6_2 QGLViewer_2_6_3 QGLViewer_2_6_4} + QGLViewer_2_6_0 QGLViewer_2_6_1 QGLViewer_2_6_2 QGLViewer_2_6_3 QGLViewer_2_6_4 + QGLViewer_2_7_0} %Feature FRIEND_EQUAL_SUPPORT %Copying diff --git a/src/sip/qglviewer.sip b/src/sip/qglviewer.sip index 1ad5d37..31e4a44 100644 --- a/src/sip/qglviewer.sip +++ b/src/sip/qglviewer.sip @@ -1,561 +1,412 @@ -/**************************************************************************** - - Copyright (C) 2007 Frederic Boudon (frederic.boudon@cirad.fr) - This file is part of the PyQGLViewer Python extension module. - It is based on libQGLViewer project developped by Gilles Debunne - http://artis.imag.fr/Members/Gilles.Debunne/QGLViewer - - PyQGLViewer is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - PyQGLViewer is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with PyQGLViewer; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*****************************************************************************/ - -class QGLViewer : QGLWidget -{ - -%TypeHeaderCode -#include - - -#include - -#ifdef Q_OS_MAC -#include -#else -#include -#endif - -#ifdef Q_WS_X11 -#define GL_GLEXT_PROTOTYPES -#include -#endif - -#ifndef GL_BGRA -#define GL_BGRA 0x80E1 -#endif - -#ifndef GL_TEXTURE_3D -#define GL_TEXTURE_3D 0x806F -#define GL_TEXTURE_3D_NO_DEFAULT_DEFINITION -#ifdef Q_WS_X11 -#warning "No default glTexture3D definition found" -#endif -#endif - -%End - -public: - explicit QGLViewer(QWidget* parent /TransferThis/ =0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0); - explicit QGLViewer(QGLContext *context, QWidget* parent /TransferThis/=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0); - explicit QGLViewer(const QGLFormat& format, QWidget* parent /TransferThis/=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0); - virtual ~QGLViewer(); - - bool axisIsDrawn() const; - bool gridIsDrawn() const; - bool FPSIsDisplayed() const; - bool textIsEnabled() const; - bool cameraIsEdited() const; - -public slots: - void setAxisIsDrawn(bool draw=true); - void setGridIsDrawn(bool draw=true); - void setFPSIsDisplayed(bool display=true); - void setTextIsEnabled(bool enable=true); - void setCameraIsEdited(bool edit=true); - - void toggleAxisIsDrawn(); - void toggleGridIsDrawn(); - void toggleFPSIsDisplayed(); - void toggleTextIsEnabled(); - void toggleCameraIsEdited(); - -public: - QColor backgroundColor() const; - QColor foregroundColor() const; - -public slots: - - void setBackgroundColor(const QColor& color /In/); - void setForegroundColor(const QColor& color /In/); - -public: - qreal sceneRadius() const; - Vec sceneCenter() const; - -public slots: - virtual void setSceneRadius(qreal radius); - virtual void setSceneCenter(const Vec& center /In/); - - void setSceneBoundingBox(const Vec& min /In/, const Vec& max /In/); - void showEntireScene(); - -public: - Camera* camera() const; - ManipulatedFrame* manipulatedFrame() const; - -public slots: - void setCamera(Camera* camera /Transfer/); - void setManipulatedFrame(ManipulatedFrame* frame /Transfer/); - -public: - MouseGrabber* mouseGrabber() const; - void setMouseGrabberIsEnabled(const MouseGrabber * mouseGrabber /In/, bool enabled=true); - bool mouseGrabberIsEnabled(const MouseGrabber* mouseGrabber /In/); - -public slots: - void setMouseGrabber(MouseGrabber* mouseGrabber /Transfer/); - -public: - qreal aspectRatio() const; - qreal currentFPS(); - bool isFullScreen() const; - bool displaysInStereo() const; - virtual QSize sizeHint() const; - - -public slots: - void setFullScreen(bool fullScreen=true); - void setStereoDisplay(bool stereo=true); - void toggleFullScreen(); - void toggleStereoDisplay(); - void toggleCameraMode(); - -public: - static void drawArrow(qreal length=1.0, qreal radius=-1.0, int nbSubdivisions=12); - static void drawArrow(const Vec& from, const Vec& to, qreal radius=-1.0, int nbSubdivisions=12); - static void drawAxis(qreal length=1.0); - static void drawGrid(qreal size=1.0, int nbSubdivisions=10); - - virtual void startScreenCoordinatesSystem(bool upward=false) const; - virtual void stopScreenCoordinatesSystem() const; - - void drawText(int x, int y, const QString& text, const QFont& fnt=QFont()); - void displayMessage(const QString& message, int delay=2000); - -protected: - virtual void drawLight(GLenum light, qreal scale = 1.0) const; - -public: - int width() const; - int height() const; - virtual void updateGL(); - static QImage convertToGLFormat(const QImage & image /In/); - void qglColor(const QColor& color /In/) const; - void qglClearColor(const QColor& color /In/) const; - bool isValid() const; - bool isSharing() const; - virtual void makeCurrent(); - bool hasMouseTracking () const; - -public slots: - virtual void resize(int width, int height); - virtual void setMouseTracking(bool enable); - -protected: - bool autoBufferSwap() const; - -protected slots: - void setAutoBufferSwap(bool on); - -public: - const QString& snapshotFileName() const; - const QString& snapshotFormat() const; - int snapshotCounter() const; - int snapshotQuality(); - -public slots: - void saveSnapshot(bool automatic=true, bool overwrite=false); - void saveSnapshot(const QString& fileName /In/, bool overwrite=false); - void setSnapshotFileName(const QString& name /In/); - void setSnapshotFormat(const QString& format /In/); - void setSnapshotCounter(int counter); - void setSnapshotQuality(int quality); - bool openSnapshotFormatDialog(); - void snapshotToClipboard(); - -public: - GLuint bufferTextureId() const; - qreal bufferTextureMaxU() const; - qreal bufferTextureMaxV() const; - -public slots: - void copyBufferToTexture(GLint internalFormat, GLenum format=GL_NONE); - -public: - bool animationIsStarted() const; - int animationPeriod() const; - -public slots: - void setAnimationPeriod(int period); - virtual void startAnimation(); - virtual void stopAnimation(); - - virtual void animate(); - void toggleAnimation(); - -signals: - - void viewerInitialized(); - void drawNeeded(); - void drawFinished(bool automatic); - void animateNeeded(); - void helpRequired(); - void axisIsDrawnChanged(bool drawn); - void gridIsDrawnChanged(bool drawn); - void FPSIsDisplayedChanged(bool displayed); - void textIsEnabledChanged(bool enabled); - void cameraIsEditedChanged(bool edited); - void stereoChanged(bool on); - void pointSelected(QMouseEvent* e /In/); - void mouseGrabberChanged(MouseGrabber* mouseGrabber /In/); - -public: - virtual QString helpString() const ; - virtual QString mouseString() const; - virtual QString keyboardString() const; - - virtual QString mouseBindingsString () const; - virtual QString shortcutBindingsString () const; - -public slots: - virtual void help(); - virtual void aboutQGLViewer(); - -protected: - QTabWidget* helpWidget(); - - virtual void resizeGL(int width, int height); - virtual void initializeGL(); - - virtual void init(); - - virtual void paintGL(); - virtual void preDraw(); - virtual void preDrawStereo(bool leftBuffer=true); - - virtual void draw(); - virtual void fastDraw(); - virtual void postDraw(); - - virtual void mousePressEvent(QMouseEvent * event /In/); - virtual void mouseMoveEvent(QMouseEvent * event /In/); - virtual void mouseReleaseEvent(QMouseEvent * event /In/); - virtual void mouseDoubleClickEvent(QMouseEvent * event /In/); - virtual void wheelEvent(QWheelEvent * event /In/); - virtual void keyPressEvent(QKeyEvent * event /In/); - virtual void timerEvent(QTimerEvent * event /In/); - virtual void closeEvent(QCloseEvent * event /In/); - -public: - int selectedName() const; - int selectBufferSize() const; - int selectRegionWidth() const; - int selectRegionHeight() const; - void* selectBuffer(); -%MethodCode - sipRes = sipCpp->selectBuffer(); -%End - - SIP_PYOBJECT getMultipleSelection() ; -%MethodCode - // Flush GL buffers - glFlush(); - - // Get the number of objects that were seen through the pick matrix frustum. Reset GL_RENDER mode. - GLint nbHits = glRenderMode(GL_RENDER); - - if (nbHits > 0) - { - sipRes = PyList_New(nbHits); - // Interpret results : each object created 4 values in the selectBuffer(). - // (selectBuffer())[4*i+3] is the id pushed on the stack. - GLuint * buffer = sipCpp->selectBuffer(); - GLuint names; - float zmax, zmin; - GLuint id; - for (int i=0; i& QGLViewerPool() ; - static int QGLViewerIndex(const QGLViewer* viewer); - -public: - virtual void setVisualHintsMask(int mask, int delay = 2000); - virtual void drawVisualHints(); - -public slots: - virtual void resetVisualHints(); - - -public: - -%TypeCode - static bool isPowerOfTwo(int val){ - long i=0; - while ((1< & images, GLenum target = GL_TEXTURE_3D, GLint format = GL_RGBA ); -%MethodCode - - sipRes = 0; - -#ifdef GL_TEXTURE_3D_NO_DEFAULT_DEFINITION -#ifndef APIENTRY -#define APIENTRY -#endif - typedef void (APIENTRY *_glTexImage3D) (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); - static _glTexImage3D glTexImage3D = NULL; - if (glTexImage3D == NULL){ - const QGLContext * context = QGLContext::currentContext(); - if (context) - glTexImage3D = (_glTexImage3D)context->getProcAddress("glTexImage3D"); - } - if (glTexImage3D == NULL){ - printf("Cannot load 'glTexImage3D' function.\n"); - sipIsErr = -1; - } - else { -#endif - int depth = a0->size(); - if(depth == 0 || !isPowerOfTwo(depth) ){ - sipIsErr = -1; - printf("Number of images is not a power of two.\n"); - } - else{ - int w = a0->at(0).width(); - int h = a0->at(0).height(); - if( w == 0 || h == 0 || ! isPowerOfTwo(w) || ! isPowerOfTwo(h) ){ - sipIsErr = -1; - printf("Width or height of images are not a power of two.\n"); - } - else{ - for(QVector::const_iterator itImage = a0->begin()+1; (itImage != a0->end()) && (sipIsErr != -1); ++itImage){ - if (itImage->width() != w || itImage->height() != h){ - printf("Width or height of images are not homogeneous.\n"); - sipIsErr = -1; - } - } - if (sipIsErr != -1){ - - size_t byteperpixel = 4; - size_t msize= w*h*depth*byteperpixel; - GLubyte * texels = (GLubyte *)malloc(msize); - if (texels == NULL) { - printf("Cannot allocate memory for 3D texture.\n"); - sipIsErr = -1; - } - else { - GLubyte * itTexel = texels; - - for(QVector::const_iterator itImage = a0->begin(); itImage != a0->end(); ++itImage){ - QImage img = sipCpp->convertToGLFormat(*itImage); - size_t imsize = img.byteCount(); - memcpy(itTexel,img.bits(),imsize); - itTexel += imsize; - } - - if(itTexel != texels+msize) printf("Invalid texture size.\n"); - - glEnable(GL_TEXTURE_3D); - glGenTextures(1, &sipRes); - glBindTexture(GL_TEXTURE_3D, sipRes); - if (sipRes != 0) - { - glTexParameterf(a1, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(a1, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexImage3D(a1, 0, a2, w, h, depth, 0, GL_RGBA, GL_UNSIGNED_BYTE, texels); - GLenum error; - if ((error = glGetError()) != GL_NO_ERROR) - printf("Error with 3D texture creation : %s \n",gluErrorString(error)); - } - else { - printf("Cannot generate 3D texture in OpenGL.\n"); - sipIsErr = -1; - } - delete [] texels; - } - } -#ifdef GL_TEXTURE_3D_NO_DEFAULT_DEFINITION - } -#endif - } } -%End -private: - QGLViewer(const QGLViewer& v); - - -}; +/**************************************************************************** + + Copyright (C) 2007 Frederic Boudon (frederic.boudon@cirad.fr) + This file is part of the PyQGLViewer Python extension module. + It is based on libQGLViewer project developped by Gilles Debunne + http://artis.imag.fr/Members/Gilles.Debunne/QGLViewer + + PyQGLViewer is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PyQGLViewer is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PyQGLViewer; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*****************************************************************************/ + +class QGLViewer : QOpenGLWidget +{ + +%TypeHeaderCode +#include + + +#include + +#ifdef Q_OS_MAC +#include +#else +#include +#endif + +#ifdef Q_WS_X11 +#define GL_GLEXT_PROTOTYPES +#include +#endif + +#ifndef GL_BGRA +#define GL_BGRA 0x80E1 +#endif + +#ifndef GL_TEXTURE_3D +#define GL_TEXTURE_3D 0x806F +#define GL_TEXTURE_3D_NO_DEFAULT_DEFINITION +#ifdef Q_WS_X11 +#warning "No default glTexture3D definition found" +#endif +#endif + +%End + +public: + explicit QGLViewer(QWidget* parent /TransferThis/ =0, QGLWidget *shareWidget = 0, Qt::WindowFlags flags=0); + virtual ~QGLViewer(); + + bool axisIsDrawn() const; + bool gridIsDrawn() const; + bool FPSIsDisplayed() const; + bool textIsEnabled() const; + bool cameraIsEdited() const; + +public slots: + void setAxisIsDrawn(bool draw=true); + void setGridIsDrawn(bool draw=true); + void setFPSIsDisplayed(bool display=true); + void setTextIsEnabled(bool enable=true); + void setCameraIsEdited(bool edit=true); + + void toggleAxisIsDrawn(); + void toggleGridIsDrawn(); + void toggleFPSIsDisplayed(); + void toggleTextIsEnabled(); + void toggleCameraIsEdited(); + +public: + QColor backgroundColor() const; + QColor foregroundColor() const; + +public slots: + + void setBackgroundColor(const QColor& color /In/); + void setForegroundColor(const QColor& color /In/); + +public: + qreal sceneRadius() const; + Vec sceneCenter() const; + +public slots: + virtual void setSceneRadius(qreal radius); + virtual void setSceneCenter(const Vec& center /In/); + + void setSceneBoundingBox(const Vec& min /In/, const Vec& max /In/); + void showEntireScene(); + +public: + Camera* camera() const; + ManipulatedFrame* manipulatedFrame() const; + +public slots: + void setCamera(Camera* camera /Transfer/); + void setManipulatedFrame(ManipulatedFrame* frame /Transfer/); + +public: + MouseGrabber* mouseGrabber() const; + void setMouseGrabberIsEnabled(const MouseGrabber * mouseGrabber /In/, bool enabled=true); + bool mouseGrabberIsEnabled(const MouseGrabber* mouseGrabber /In/); + +public slots: + void setMouseGrabber(MouseGrabber* mouseGrabber /Transfer/); + +public: + qreal aspectRatio() const; + qreal currentFPS(); + bool isFullScreen() const; + bool displaysInStereo() const; + virtual QSize sizeHint() const; + + +public slots: + void setFullScreen(bool fullScreen=true); + void setStereoDisplay(bool stereo=true); + void toggleFullScreen(); + void toggleStereoDisplay(); + void toggleCameraMode(); + +public: + static void drawArrow(qreal length=1.0, qreal radius=-1.0, int nbSubdivisions=12); + static void drawArrow(const Vec& from, const Vec& to, qreal radius=-1.0, int nbSubdivisions=12); + static void drawAxis(qreal length=1.0); + static void drawGrid(qreal size=1.0, int nbSubdivisions=10); + + virtual void startScreenCoordinatesSystem(bool upward=false) const; + virtual void stopScreenCoordinatesSystem() const; + + void drawText(int x, int y, const QString& text, const QFont& fnt=QFont()); + void displayMessage(const QString& message, int delay=2000); + +protected: + virtual void drawLight(GLenum light, qreal scale = 1.0) const; + +public: + int width() const; + int height() const; + bool isValid() const; + virtual void makeCurrent(); + bool hasMouseTracking () const; + +public slots: + virtual void resize(int width, int height); + virtual void setMouseTracking(bool enable); + +public: + const QString& snapshotFileName() const; + const QString& snapshotFormat() const; + int snapshotCounter() const; + int snapshotQuality(); + +public slots: + void saveSnapshot(bool automatic=true, bool overwrite=false); + void saveSnapshot(const QString& fileName /In/, bool overwrite=false); + void setSnapshotFileName(const QString& name /In/); + void setSnapshotFormat(const QString& format /In/); + void setSnapshotCounter(int counter); + void setSnapshotQuality(int quality); + bool openSnapshotFormatDialog(); + void snapshotToClipboard(); + +public: + GLuint bufferTextureId() const; + qreal bufferTextureMaxU() const; + qreal bufferTextureMaxV() const; + +public slots: + void copyBufferToTexture(GLint internalFormat, GLenum format=GL_NONE); + +public: + bool animationIsStarted() const; + int animationPeriod() const; + +public slots: + void setAnimationPeriod(int period); + virtual void startAnimation(); + virtual void stopAnimation(); + + virtual void animate(); + void toggleAnimation(); + +signals: + + void viewerInitialized(); + void drawNeeded(); + void drawFinished(bool automatic); + void animateNeeded(); + void helpRequired(); + void axisIsDrawnChanged(bool drawn); + void gridIsDrawnChanged(bool drawn); + void FPSIsDisplayedChanged(bool displayed); + void textIsEnabledChanged(bool enabled); + void cameraIsEditedChanged(bool edited); + void stereoChanged(bool on); + void pointSelected(QMouseEvent* e /In/); + void mouseGrabberChanged(MouseGrabber* mouseGrabber /In/); + +public: + virtual QString helpString() const ; + virtual QString mouseString() const; + virtual QString keyboardString() const; + + virtual QString mouseBindingsString () const; + virtual QString shortcutBindingsString () const; + +public slots: + virtual void help(); + virtual void aboutQGLViewer(); + +protected: + QTabWidget* helpWidget(); + + virtual void resizeGL(int width, int height); + virtual void initializeGL(); + + virtual void init(); + + virtual void paintGL(); + virtual void preDraw(); + virtual void preDrawStereo(bool leftBuffer=true); + + virtual void draw(); + virtual void fastDraw(); + virtual void postDraw(); + + virtual void mousePressEvent(QMouseEvent * event /In/); + virtual void mouseMoveEvent(QMouseEvent * event /In/); + virtual void mouseReleaseEvent(QMouseEvent * event /In/); + virtual void mouseDoubleClickEvent(QMouseEvent * event /In/); + virtual void wheelEvent(QWheelEvent * event /In/); + virtual void keyPressEvent(QKeyEvent * event /In/); + virtual void timerEvent(QTimerEvent * event /In/); + virtual void closeEvent(QCloseEvent * event /In/); + +public: + int selectedName() const; + int selectBufferSize() const; + int selectRegionWidth() const; + int selectRegionHeight() const; + void* selectBuffer(); + +public slots: + virtual void select(const QMouseEvent* event /In/); + virtual void select(const QPoint& point /In/); + + void setSelectBufferSize(int size); + void setSelectRegionWidth(int width); + void setSelectRegionHeight(int height); + void setSelectedName(int id); + + protected: + + virtual void beginSelection(const QPoint& point /In/); + virtual void drawWithNames(); + virtual void endSelection(const QPoint& point /In/); + virtual void postSelection(const QPoint& point /In/) ; + +public: + enum KeyboardAction { DRAW_AXIS, DRAW_GRID, DISPLAY_FPS, ENABLE_TEXT, EXIT_VIEWER, + SAVE_SCREENSHOT, CAMERA_MODE, FULL_SCREEN, STEREO, ANIMATION, HELP, EDIT_CAMERA, + MOVE_CAMERA_LEFT, MOVE_CAMERA_RIGHT, MOVE_CAMERA_UP, MOVE_CAMERA_DOWN, + INCREASE_FLYSPEED, DECREASE_FLYSPEED, SNAPSHOT_TO_CLIPBOARD + }; + + unsigned int shortcut(KeyboardAction action) const; + + unsigned int keyboardAccelerator(KeyboardAction action) const; + Qt::Key keyFrameKey(unsigned int index) const; + Qt::KeyboardModifiers playKeyFramePathStateKey() const; + Qt::KeyboardModifiers addKeyFrameStateKey() const; + Qt::KeyboardModifiers playPathStateKey() const; + + Qt::Key pathKey(unsigned int index) const; + Qt::KeyboardModifiers addKeyFrameKeyboardModifiers() const; + Qt::KeyboardModifiers playPathKeyboardModifiers() const; + +public slots: + void setShortcut(KeyboardAction action, unsigned int key); + void setKeyboardAccelerator(KeyboardAction action, unsigned int key); + void setKeyDescription(unsigned int key, QString description); + void clearShortcuts(); + + + virtual void setKeyFrameKey(unsigned int index, int key); + virtual void setPlayKeyFramePathStateKey(unsigned int buttonState); + virtual void setPlayPathStateKey(unsigned int buttonState); + virtual void setAddKeyFrameStateKey(unsigned int buttonState); + virtual void setPathKey(int key, unsigned int index = 0); + virtual void setPlayPathKeyboardModifiers(Qt::KeyboardModifiers modifiers); + virtual void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers modifiers); + +public: + + enum MouseHandler { CAMERA, FRAME }; + + enum ClickAction { NO_CLICK_ACTION, ZOOM_ON_PIXEL, ZOOM_TO_FIT, SELECT, RAP_FROM_PIXEL, RAP_IS_CENTER, + CENTER_FRAME, CENTER_SCENE, SHOW_ENTIRE_SCENE, ALIGN_FRAME, ALIGN_CAMERA }; + + + enum MouseAction { NO_MOUSE_ACTION, + ROTATE, ZOOM, TRANSLATE, + MOVE_FORWARD, LOOK_AROUND, MOVE_BACKWARD, + SCREEN_ROTATE, ROLL, DRIVE, + SCREEN_TRANSLATE, ZOOM_ON_REGION }; + + + MouseAction mouseAction(unsigned int state) const; + int mouseHandler(unsigned int state) const; + int mouseButtonState(MouseHandler handler, MouseAction action, bool withConstraint=true) const; + ClickAction clickAction(unsigned int state, bool doubleClick, Qt::MouseButtons buttonsBefore) const; + void getClickButtonState(ClickAction action, unsigned int& state, bool& doubleClick, Qt::MouseButtons& buttonsBefore) const; + unsigned int wheelButtonState(MouseHandler handler, MouseAction action, bool withConstraint=true) const; + + + MouseAction mouseAction(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button) const; + int mouseHandler(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button) const; + + void getMouseActionBinding(MouseHandler handler, MouseAction action, bool withConstraint, + Qt::Key& key, Qt::KeyboardModifiers& modifiers, Qt::MouseButton& button) const; + + ClickAction clickAction(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button, + bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton) const; + + void getClickActionBinding(ClickAction action, Qt::Key& key, Qt::KeyboardModifiers& modifiers, + Qt::MouseButton& button, bool& doubleClick, Qt::MouseButtons& buttonsBefore) const; + + MouseAction wheelAction(Qt::Key key, Qt::KeyboardModifiers modifiers) const; + int wheelHandler(Qt::Key key, Qt::KeyboardModifiers modifiers) const; + + void getWheelActionBinding(MouseHandler handler, MouseAction action, bool withConstraint, + Qt::Key& key, Qt::KeyboardModifiers& modifiers) const; +public slots: + void setMouseBinding(unsigned int state, MouseHandler handler, MouseAction action, bool withConstraint=true); + void setMouseBinding(unsigned int state, ClickAction action, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton); + void setMouseBindingDescription(unsigned int state, QString description, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton); + + void setMouseBinding(Qt::KeyboardModifiers modifiers, Qt::MouseButton buttons, MouseHandler handler, MouseAction action, bool withConstraint=true); + void setMouseBinding(Qt::KeyboardModifiers modifiers, Qt::MouseButton button, ClickAction action, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton); + void setWheelBinding(Qt::KeyboardModifiers modifiers, MouseHandler handler, MouseAction action, bool withConstraint=true); + void setMouseBindingDescription(Qt::KeyboardModifiers modifiers, Qt::MouseButton button, QString description, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton); + + void setMouseBinding(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton buttons, MouseHandler handler, MouseAction action, bool withConstraint=true); + void setMouseBinding(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button, ClickAction action, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton); + void setWheelBinding(Qt::Key key, Qt::KeyboardModifiers modifiers, MouseHandler handler, MouseAction action, bool withConstraint=true); + void setMouseBindingDescription(Qt::Key key, Qt::KeyboardModifiers modifiers, Qt::MouseButton button, QString description, bool doubleClick=false, Qt::MouseButtons buttonsBefore=Qt::NoButton); + + void clearMouseBindings(); + + MouseAction wheelAction(Qt::KeyboardModifiers modifiers) const; + int wheelHandler(Qt::KeyboardModifiers modifiers) const; + + void setHandlerKeyboardModifiers(MouseHandler handler, Qt::KeyboardModifiers modifiers); + void setHandlerStateKey(MouseHandler handler, unsigned int buttonState); + void setMouseStateKey(MouseHandler handler, unsigned int buttonState); + +public: + + QString stateFileName() const; + virtual QDomElement domElement(const QString& name /In/, QDomDocument& document /In/) const; + +public slots: + + virtual void initFromDOMElement(const QDomElement& element /In/); + virtual void saveStateToFile(); // cannot be const because of QMessageBox + virtual bool restoreStateFromFile(); + + void setStateFileName(const QString& name /In/) ; + + void saveToFile(const QString& fileName /In/ =QString::null); + bool restoreFromFile(const QString& fileName /In/ =QString::null); + + +public: + static const QList& QGLViewerPool() ; + static int QGLViewerIndex(const QGLViewer* viewer); + +public: + virtual void setVisualHintsMask(int mask, int delay = 2000); + virtual void drawVisualHints(); + +public slots: + virtual void resetVisualHints(); + + +public: + +%TypeCode + static bool isPowerOfTwo(int val){ + long i=0; + while ((1<