QtBaseViewer.hh

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 8548 $                                                       *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2010-02-12 14:40:13 +0100 (Fr, 12. Feb 2010) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 //=============================================================================
00046 //
00047 //  CLASS QtBaseViewer
00048 //
00049 //=============================================================================
00050 
00051 #ifndef ACG_QTBASEVIEWER_HH
00052 #define ACG_QTBASEVIEWER_HH
00053 
00054 //== INCLUDES =================================================================
00055 
00056 
00057 #include "../GL/GLState.hh"
00058 #include "../Scenegraph/SceneGraph.hh"
00059 #include "../Scenegraph/DrawModes.hh"
00060 
00061 #include <QtOpenGL/QGLFormat>
00062 #include <QBoxLayout>
00063 #include <QtNetwork/QUdpSocket>
00064 #include <QWheelEvent>
00065 #include <QKeyEvent>
00066 #include <QDropEvent>
00067 #include <QContextMenuEvent>
00068 #include <QDragEnterEvent>
00069 #include <QMouseEvent>
00070 #include <QAction>
00071 #include <QSize>
00072 #include <QMap>
00073 #include <QString>
00074 #include <QMenu>
00075 #include <QToolBar>
00076 #include <QTime>
00077 
00078 #include <vector>
00079 #include <string>
00080 
00081 
00082 //== FORWARDDECLARATIONS ======================================================
00083 
00084 
00085 class QPushButton;
00086 class QToolButton;
00087 class QStatusBar;
00088 class QSplitter;
00089 class QTimer;
00090 class QImage;
00091 class QSocketNotifier;
00092 class QGraphicsWidget;
00093 class QGraphicsGridLayout;
00094 
00095 
00096 //== NAMESPACES ===============================================================
00097 
00098 
00099 namespace ACG {
00100 namespace QtWidgets {
00101 
00102 
00103 //== FORWARDDECLARATIONS ======================================================
00104 
00105 
00106 class QtWheel;
00107 class QtGLGraphicsScene;
00108 class QtGLGraphicsView;
00109 class QtSceneGraphDialog;
00110 class QtShiftPopupMenu;
00111 
00112 
00113 //== CLASS DEFINITION =========================================================
00114 
00115 
00123 class ACGDLLEXPORT QtBaseViewer : public QWidget
00124 {
00125 Q_OBJECT
00126 
00127 //-------------------------------------------------------------- public methods
00128 public:
00129 
00133   enum Options {
00135     Nothing=0,
00136 
00143     ShowPrivateStatusBar=1,
00144 
00154     ShowToolBar=2,
00155 
00157     ShowPickButton=4,
00159     ShowLassoButton=8,
00161     ShowQuestionButton=0x10,
00162 
00164     ShowWheelX=0x20,
00166     ShowWheelY=0x40,
00170     ShowWheelZ=0x80,
00171 
00173     ShowWheels=0xe0,
00174 
00176     DefaultOptions = 0xffff & (~ShowPrivateStatusBar)
00177   };
00178 
00179 
00180 
00181 
00182   //--------------------------------------------------- constructor / destructor
00183 
00192   QtBaseViewer( QWidget* _parent=0,
00193                 const char* _name=0,
00194                 QStatusBar *_statusBar=0,
00195                 const QGLFormat* _format=0,
00196                 const QtBaseViewer* _share=0,
00197                 Options _options=DefaultOptions );
00198 
00200   virtual ~QtBaseViewer();
00201 
00202 
00203 
00204 
00205 
00206   //------------------------------------------------------------- public methods
00207 
00208   virtual QSize sizeHint () const;
00209 
00211   QStatusBar* statusBar() { return statusbar_; }
00220   void setStatusBar(QStatusBar* _sb);
00221 
00223   void applyOptions(int _options);
00225   int options() const { return options_; }
00226 
00227 
00229   virtual void makeCurrent();
00231   virtual void swapBuffers();
00232 
00233 
00235   GLState& glState() { return *glstate_; }
00236 
00237 
00241   void backgroundColor(const Vec4f& _color) {
00242     glstate_->set_clear_color(_color); updateGL();
00243   }
00245   Vec4f backgroundColor() { return glstate_->clear_color(); }
00246 
00247 
00253   virtual void lockUpdate();
00255   virtual void unlockUpdate();
00260   virtual void unlockAndUpdate();
00263   bool isUpdateLocked() const { return updateLocked_; }
00264 
00265 
00267   void lockProjectionUpdate( void ) { projectionUpdateLocked_ = true; }
00268 
00270   void unlockProjectionUpdate( void ) { projectionUpdateLocked_ = false; }
00271 
00273   bool animation() const { return animation_; }
00275   void animation(bool _b);
00276 
00278   void trackMouse(bool _track);
00279 
00281   void enablePopupMenu(bool _enable);
00282 
00283 
00284 
00285 
00286 
00287 
00289   SceneGraph::BaseNode* sceneGraph() { return sceneGraphRoot_; }
00291   const SceneGraph::BaseNode* sceneGraph() const { return sceneGraphRoot_; }
00299   void sceneGraph(SceneGraph::BaseNode* _root);
00300 
00302   enum NavigationMode {
00303     NORMAL_NAVIGATION,     
00304     FIRSTPERSON_NAVIGATION  
00305   };
00306 
00308   enum ProjectionMode {
00309     ORTHOGRAPHIC_PROJECTION, 
00310     PERSPECTIVE_PROJECTION   
00311   };
00312 
00314   void projectionMode(ProjectionMode _p);
00316   ProjectionMode projectionMode() const { return projectionMode_; }
00317 
00319   void navigationMode(NavigationMode _n);
00321   NavigationMode navigationMode() const { return navigationMode_; }
00322 
00327   void setScenePos( const ACG::Vec3d& _center, double _radius, const bool _setCenter = true );
00328 
00332   void setSceneCenter( const ACG::Vec3d& _center );
00333   
00337   const ACG::Vec3d& scene_center() const { return scene_center_; }
00341   double scene_radius() const { return scene_radius_; }
00342   
00344   void viewingDirection( const ACG::Vec3d& _dir, const ACG::Vec3d& _up );
00345 
00347   enum ActionMode {
00348     // examine geometry, get transformations from mouse events
00349     ExamineMode,
00353     PickingMode,
00354     // same as picking, but emit signalMouseEventIdentify()
00355     QuestionMode,
00356     // Ligh rotation mode
00357     LightMode
00358   };
00359 
00360 
00366   void actionMode(ActionMode);
00367 
00369   ActionMode lastActionMode(){ return lastActionMode_; };
00370 
00372   ActionMode actionMode() const { return actionMode_; }
00373 
00374 
00376  enum FaceOrientation {
00377     CCW_ORIENTATION, 
00378     CW_ORIENTATION   
00379   };
00380 
00382   void faceOrientation(FaceOrientation);
00384   FaceOrientation faceOrientation() const { return faceOrientation_; }
00385 
00387   void backFaceCulling( bool _b );
00389   bool backFaceCulling() const { return backFaceCulling_; }
00390 
00392   void twoSidedLighting( bool _b );
00394   bool twoSidedLighting() const { return twoSidedLighting_; }
00395 
00397   enum NormalsMode {
00399     DONT_TOUCH_NORMALS,
00404     NORMALIZE_NORMALS
00405   };
00406 
00408   void normalsMode(NormalsMode _mode);
00410   NormalsMode normalsMode() const { return normalsMode_; }
00411 
00412 
00414   GLMatrixd& light_matrix() { return light_matrix_; }
00416   void rotate_lights(Vec3d& _axis, double _angle);
00418   void update_lights();
00419 
00420 
00422   void copyToImage( QImage& _image, GLenum _buffer=GL_BACK) {
00423     copyToImage(_image, 0, 0, glWidth(), glHeight(), _buffer);
00424   }
00425 
00427   void copyToImage( QImage& _image,
00428                     unsigned int _left,  unsigned int _top,
00429                     unsigned int _width, unsigned int _height,
00430                     GLenum _buffer );
00431 
00432 
00434   unsigned int glWidth() const;
00436   unsigned int glHeight() const;
00438   QSize glSize() const;
00440   QPoint glMapFromGlobal( const QPoint& _pos ) const;
00442   QPoint glMapToGlobal( const QPoint& _pos ) const;
00443 
00444 
00446   void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
00447   {
00448     curDrawMode_=_mode;
00449     updatePopupMenu();
00450   }
00451 
00453   ACG::SceneGraph::DrawModes::DrawMode drawMode() { return curDrawMode_; }
00454 
00456   void encodeView(QString& _view);
00461   bool decodeView(const QString& _view);
00462 
00464   void initModelviewMatrix();
00465 
00466   // get all Mouse & Key Events for GlWidget
00467   void grabGLArea();
00468 
00469   // undo grabbing GLArea
00470   void releaseGLArea();
00471 
00473   void drawBlendedObjects(bool _status) { blending_ = _status; }
00474 
00476   void translate(const Vec3d& trans);
00477 
00479   void rotate(const Vec3d& axis, double angle)
00480   { rotate(axis, angle, trackball_center_); }
00481 
00483   void rotate(const Vec3d& axis, double angle, const Vec3d& _center);
00484 
00486   QMenu * getPickMenu() { return pickMenu_; };
00487   QMenu * getFuncMenu() { return funcMenu_; };
00488   QMenu * getDrawMenu() { return drawMenu_; };
00489 
00491   QToolBar* getToolBar();
00492 
00494   QToolBar* removeToolBar();
00495   
00497   void moveForward();
00498   
00500   void moveBack();
00501   
00503   void strafeLeft();
00504   
00506   void strafeRight();
00507 
00508 //---------------------------------------------------------------- public slots
00509 public slots:
00510 
00516   virtual void drawNow();
00518   virtual void updateGL();
00519 
00521   virtual void setHome();
00523   virtual void home();
00525   virtual void viewAll();
00527   virtual void flyTo(const QPoint& _pos, bool _move_back);
00529   virtual void flyTo(const QPoint& _pos) { flyTo(_pos,false); }
00531   virtual void flyFrom(const QPoint& _pos) { flyTo(_pos,true); }
00532 
00538   virtual void flyTo(const Vec3d& _position,
00539                                const Vec3d& _center,
00540                                double       _time = 1000.0);
00541 
00543   virtual void examineMode() { actionMode(ExamineMode); }
00545   virtual void lightMode() { actionMode(LightMode); }
00547   virtual void questionMode() { actionMode(QuestionMode); }
00548 
00550   virtual void perspectiveProjection();
00552   virtual void orthographicProjection();
00554   virtual void toggleProjectionMode();
00556   virtual void toggleNavigationMode();
00557   
00558   signals:
00559     
00560     void projectionModeChanged( bool _ortho );
00561     void navigationModeChanged( bool _normal );  
00562 
00563   public slots:
00564     
00566   virtual void showSceneGraphDialog();
00567 
00569   virtual void setView( const GLMatrixd& _modelview,
00570                         const GLMatrixd& _inverse_modelview );
00571 
00572   void actionBackground();
00573   void actionCopyView();
00574   void actionPasteView();
00575   void actionPasteDropSize();
00576   void actionSynchronize();
00577   void actionAnimation();
00578   void actionBackfaceCulling();
00579   void actionTwoSidedLighting();
00580   void actionSynchronize(bool _enable);
00581   void actionAnimation(bool _enable);
00582   void actionBackfaceCulling(bool _enable);
00583   void actionTwoSidedLighting(bool _enable);
00584 
00585   void actionDrawMenu( QAction * _action );
00586   void actionPickMenu( QAction * _action );
00587 
00588 
00589 
00590 
00591 //-------------------------------------------------------------- public signals
00592 signals:
00593 
00595   void signalInitializeGL();
00596 
00607   void signalMouseEvent(QMouseEvent*, const std::string&);
00608 
00610   void signalMouseEvent(QMouseEvent*);
00611 
00613   void signalWheelEvent(QWheelEvent*, const std::string&);
00614 
00618   void signalMouseEventIdentify( QMouseEvent* );
00619 
00620 
00622   void signalSetView( const GLMatrixd& _modelview,
00623                       const GLMatrixd& _inverse_modelview );
00625   void signalSceneGraphChanged(ACG::SceneGraph::BaseNode* _root);
00627   void signalNodeChanged(ACG::SceneGraph::BaseNode* _node);
00629   void signalActionModeChanged(ACG::QtWidgets::QtBaseViewer::ActionMode _m);
00631   void signalDrawScene(ACG::GLState* _state);
00632 
00633 
00634   signals:
00635 
00640   void signalCustomContextMenuRequested ( const QPoint & );
00641 
00642 
00643 //----------------------------------------------------------- protected methods
00644 protected:
00645 
00646   friend class QtGLGraphicsScene;
00647   friend class QtGLGraphicsView;
00648 
00650   virtual void initializeGL();
00652   virtual void paintGL();
00654   virtual void resizeGL(int _w, int _h);
00655 
00656 
00658   virtual void glMousePressEvent(QMouseEvent* _event);
00660   virtual void glMouseDoubleClickEvent(QMouseEvent* _event);
00662   virtual void glMouseMoveEvent(QMouseEvent* _event);
00664   virtual void glMouseReleaseEvent(QMouseEvent* _event);
00666   virtual void glMouseWheelEvent(QWheelEvent* _event);
00668   virtual void glContextMenuEvent(QContextMenuEvent* _event);
00669 
00670 
00672   virtual void viewMouseEvent( QMouseEvent* _event) = 0;
00674   virtual void viewWheelEvent(QWheelEvent* _event) = 0;
00675 
00677   virtual void lightMouseEvent( QMouseEvent* /* _event */ ) {}
00678 
00679 
00680   protected:
00681 
00682 
00684   void updateProjectionMatrix();
00686   void updatePickMenu();
00687 
00688 
00689 
00690 //------------------------------------------------------------- protected slots
00691 protected slots:
00692 
00694   virtual void sceneRectChanged(const QRectF & rect);
00695 
00697   virtual void slotWheelX(double _dAngle);
00699   virtual void slotWheelY(double _dAngle);
00701   virtual void slotWheelZ(double _dist);
00702 
00704   virtual void slotNodeChanged(ACG::SceneGraph::BaseNode* _node);
00705 
00707   virtual void cleanupEventFilter()
00708   { removeEventFilter( sender());}
00709 
00710 
00711 
00712 //--------------------------------------------------------------- private slots
00713 private slots:
00714 
00715   void hidePopupMenus();
00716 
00717 //----------------------------------------------------------- private functions
00718 private:
00719 
00720   // IDs for \c funcMenu_
00721   enum FuncMenuID {
00722     M_CopyView=0x100,
00723     M_PasteView,
00724     M_PasteDropSize,
00725     M_Animation,
00726     M_BackfaceCulling,
00727     M_TwoSidedLighting,
00728     M_Background,
00729     M_Snapshot,
00730     M_SnapshotName,
00731     M_SnapshotSavesView,
00732     M_Synchronize
00733   };
00734 
00736   QtBaseViewer(const QtBaseViewer&);
00738   QtBaseViewer& operator=(const QtBaseViewer&);
00739 
00740   // create widgets
00741   void createWidgets(const QGLFormat* _format,QStatusBar* _sb,
00742                      const QtBaseViewer* _share);
00743 
00744   /* Recursively draws each node in the scene graph.
00745       Called by paintGL(). */
00746   void drawScene();
00747   // helper called by drawScene().
00748   void drawScene_mono();
00749   // helper called by drawScene() when stereo viewing is active.
00750   void drawScene_stereo();
00751 
00752 
00753   // updates popup menu with the available draw modes
00754   void updatePopupMenu();
00755 
00756 //-------------------------------------------------------------- protected data
00757 protected:
00758 
00759 
00760   // scene center and radius
00761   Vec3d                        scene_center_, trackball_center_;
00762   double                       scene_radius_, trackball_radius_;
00763 
00764 
00765   // projection stuff
00766   GLdouble                     orthoWidth_;
00767   GLdouble                     near_, far_, fovy_;
00768 
00769 
00770   // scenegraph
00771   GLState                     *glstate_;
00772 
00773 
00774   // helper
00775   bool                         isRotating_;
00776 
00777 
00778   // current status bar, guaranteed to be !=0
00779   QStatusBar* statusbar_;
00780 
00781 
00782 
00783 //---------------------------------------------------------------- private data
00784 private:
00785 
00786 
00787   // data stored for home view
00788   Vec3d                        home_center_;
00789   double                       home_radius_;
00790   GLMatrixd                    home_modelview_,
00791                                home_inverse_modelview_;
00792   double                       homeOrthoWidth_;
00793 
00794 
00795   // matrix for rotating light position
00796   GLMatrixd                    light_matrix_;
00797 
00798 
00799   // modi
00800   NormalsMode                  normalsMode_;
00801   FaceOrientation              faceOrientation_;
00802   ProjectionMode               projectionMode_;
00803   NavigationMode               navigationMode_;
00804   
00805   ActionMode                   actionMode_, lastActionMode_;
00806   bool                         backFaceCulling_;
00807   bool                         twoSidedLighting_;
00808   bool                         animation_;
00809 
00810   // helper
00811   bool                         trackMouse_;
00812   bool                         popupEnabled_;
00813   bool                         glareaGrabbed_;
00814   double                       frame_time_;
00815 
00816 
00817   QMenu * pickMenu_;
00818   QMenu * funcMenu_;
00819   QMenu * drawMenu_;
00820 
00821   // scenegraph stuff
00822   SceneGraph::BaseNode*        sceneGraphRoot_;
00823 
00824   ACG::SceneGraph::DrawModes::DrawMode curDrawMode_,
00825                                        availDrawModes_;
00826 
00827   bool                         updateLocked_;
00828   bool                         projectionUpdateLocked_;
00829   bool                         blending_;
00830 
00831 
00832   // widget showing the scenegraph
00833   QtSceneGraphDialog*          sceneGraphDialog_;
00834 
00835 
00836 
00837   // options
00838   Options options_;
00839   // gl widget used as drawing area to paint the graphics scene
00840   QGLWidget* glWidget_;
00841   // graphics scene used to paint gl context and widgets
00842   QtGLGraphicsScene* glScene_;
00843   // graphics view that holds the gl scene
00844   QtGLGraphicsView* glView_;
00845 
00846   // Base graphics widget for wheels in the scene
00847   QGraphicsWidget* glBase_;
00848   // Base graphics widget layout
00849   QGraphicsGridLayout* glBaseLayout_;
00850 
00851   // private status bar, 0 if status bar is provided externally
00852   QStatusBar* privateStatusBar_;
00853 
00854   // Layout for the basic widget ( viewer + wheels )
00855   QGridLayout* glLayout_;
00856 
00857   // tool bar
00858   QToolBar    * buttonBar_;
00859 
00860   // set pick mode
00861   QToolButton* pickButton_;
00862   // set move mode
00863   QToolButton* moveButton_;
00864   // set light mode
00865   QToolButton* lightButton_;
00866   // set question mode
00867   QToolButton* questionButton_;
00868   // change projection mode (perspective/orthographic)
00869   QToolButton* projectionButton_;
00870   // go to home() position
00871   QToolButton* homeButton_;
00872   // setHome()
00873   QToolButton* setHomeButton_;
00874   // viewAll()
00875   QToolButton* viewAllButton_;
00876   // show sceneGraphDialog_
00877   QToolButton* sceneGraphButton_;
00878   // enable/disable stereo viewing
00879   QToolButton* stereoButton_;
00880 
00881   // rotate around x-axis
00882   QtWheel* wheelX_;
00883   // rotate around y-axis
00884   QtWheel* wheelY_;
00885   // translate along z-axis
00886   QtWheel* wheelZ_;
00887 
00888   // all actions
00889   QMap< QString, QAction * > action_;
00890 
00891   // vector of current draw mode actions
00892   std::vector< QAction * > drawMenuActions_;
00893 
00894   // Used to calculate the time passed between redraws
00895   QTime redrawTime_;
00896   
00897   //===========================================================================
00900   //===========================================================================
00901   signals:
00903     void viewUpdated();
00904     
00906     void viewChanged();  
00907     
00910   //===========================================================================
00913   //===========================================================================
00914 
00915   public slots:
00916 
00918     virtual void toggleStereoMode();
00919 
00921     virtual void setStereoMode(bool _b);
00922 
00923   public:
00928     void setEyeDistance(double _distance);
00929 
00931     double eyeDistance( );
00932 
00937     void setFocalDistance(double _distance);
00938 
00940     double focalDistance( );
00941 
00942   private:
00943     // stereo stuff
00944     bool                         stereo_;
00945     double                       eyeDist_, focalDist_;
00946 
00947 
00951   //===========================================================================
00954   //===========================================================================
00955 
00956   signals:
00963     void signalKeyPressEvent(QKeyEvent*);
00964 
00965   public:
00971     void disableKeyHandling(bool _state );
00972 
00976     bool keyHandlingState();
00977 
00978   protected:
00979 
00984     virtual void glKeyPressEvent(QKeyEvent*);
00985 
00992     virtual void glKeyReleaseEvent(QKeyEvent* _event);
00993 
01001     virtual bool viewKeyPressEvent(QKeyEvent* _event) = 0;
01002 
01003   private:
01004     bool disableKeyHandling_;
01005 
01008   //===========================================================================
01011   //===========================================================================
01012 
01013   protected:
01014 
01016     virtual void startDrag();
01018     virtual void glDragEnterEvent(QDragEnterEvent* _event);
01020     virtual void glDropEvent(QDropEvent* _event);
01021 
01022   public:
01024     void setExternalDrag( bool _external ) { externalDrag_ = _external; };
01025 
01026   signals:
01030     void startDragEvent( QMouseEvent* _event );
01031 
01035     void dragEnterEvent(QDragEnterEvent* _event);
01036 
01040     void dropEvent( QDropEvent* _event );
01041 
01042   private:
01043 
01047     bool externalDrag_;
01048 
01052   //===========================================================================
01055   //===========================================================================
01056 
01057   public:
01062     void sync_connect(const QtBaseViewer*);
01063 
01065     void sync_disconnect(const QtBaseViewer*);
01066 
01068     virtual void setSynchronization(bool _b);
01069 
01071     bool add_sync_host(const QString& _name);
01073     void add_sync_host(QHostAddress& _adr);
01074 
01075     bool synchronization();
01076 
01077   private slots:
01078 
01079     void sync_receive();
01080     void sync_send(const GLMatrixd& _modelview,
01081         const GLMatrixd& _inverse_modelview);
01082 
01083   private:
01085     bool                         synchronized_;
01086 
01088     bool                         skipNextSync_;
01089 
01091     QUdpSocket *                 socket_;
01092 
01094     std::vector<QHostAddress>    sync_hosts_;
01095 
01098   //===========================================================================
01101   //===========================================================================
01102 
01103   public slots:
01115     virtual void snapshotBaseFileName(const QString& _fname);
01116 
01121     virtual void snapshot();
01122 
01125     void actionSnapshot();
01126 
01129     void actionSnapshotName();
01130 
01133     void actionSnapshotSavesView();
01134 
01135   private:
01136 
01137     QString                      snapshotName_;
01138     int                          snapshotCounter_;
01139     QImage*                      snapshot_;
01140 
01143   //===========================================================================
01146   //===========================================================================
01147   public:
01161     bool pick( SceneGraph::PickTarget _pickTarget,
01162                const QPoint& _mousePos,
01163                unsigned int& _nodeIdx,
01164                unsigned int& _targetIdx,
01165                Vec3d* _hitPointPtr=0 );
01166 
01172     bool fast_pick( const QPoint&  _mousePos,
01173                     Vec3d&         _hitPoint );
01174 
01181     void addPickMode(const std::string& _name,
01182                      bool               _mouse_tracking = false,
01183                      int                _pos            = -1,
01184                      bool               _visible        = true,
01185                      QCursor            _cursor         = Qt::ArrowCursor );
01186 
01189     void clearPickModes();
01190 
01193     const std::string& pickMode() const;
01194 
01198     void pickMode(const std::string& _name);
01199 
01203     void pickMode( int _id );
01204 
01209     void renderPicking(bool _renderPicking, ACG::SceneGraph::PickTarget _mode);
01210 
01211   public slots:
01212 
01216     virtual void pickingMode();
01217 
01223     void setPickModeCursor(const std::string& _name, QCursor _cursor);
01224 
01230     void setPickModeMouseTracking(const std::string& _name, bool _mouseTracking);
01231 
01232   signals:
01235     void signalPickModeChanged(const std::string&);
01236 
01237   private:
01238 
01241     struct PickMode
01242     {
01244       PickMode(const std::string& _n, bool _t, bool _v, QCursor _c) :
01245                name(_n), tracking(_t), visible(_v), cursor(_c) {}
01246 
01249       std::string  name;
01250 
01253       bool         tracking;
01254 
01257       bool         visible;
01258 
01261       QCursor      cursor;
01262     };
01263 
01266     std::vector<PickMode>  pick_modes_;
01267 
01270     std::string            pick_mode_name_;
01271 
01274     int                    pick_mode_idx_;
01275 
01278     bool renderPicking_;
01279 
01284     ACG::SceneGraph::PickTarget pickRendererMode_;
01285 
01287 };
01288 
01289 
01290 //=============================================================================
01291 } // namespace QtWidgets
01292 } // namespace ACG
01293 //=============================================================================
01294 #endif // ACG_QTBASEVIEWER_HH defined
01295 //=============================================================================

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .