ViewerProperties.hh 17.8 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3
*                                                                            *
*                              OpenFlipper                                   *
Martin Schultz's avatar
Martin Schultz committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * 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.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * 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 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Jan Möbius's avatar
Jan Möbius committed
39
*                                                                            *
40 41
\*===========================================================================*/

Jan Möbius's avatar
 
Jan Möbius committed
42 43 44 45 46 47 48 49 50 51 52 53 54


//=============================================================================
//
//  Property storage Class for glWidgets
//
//=============================================================================

/**
 * \file ViewerProperties.hh
 * This file contains a class for managing all viewer settings
 */

Jan Möbius's avatar
Jan Möbius committed
55
#pragma once
Jan Möbius's avatar
Jan Möbius committed
56

Jan Möbius's avatar
 
Jan Möbius committed
57
#include <QObject>
Dirk Wilden's avatar
Dirk Wilden committed
58
#include <QColor>
Jan Möbius's avatar
Jan Möbius committed
59
#include <OpenFlipper/common/GlobalDefines.hh>
60
#include <ACG/Math/VectorT.hh>
61
#include <ACG/Scenegraph/SceneGraph.hh>
Jan Möbius's avatar
Jan Möbius committed
62
#include <ACG/Scenegraph/DrawModes.hh>
63
#include <ACG/GL/GLState.hh>
64
#include <OpenFlipper/widgets/glWidget/CursorPainter.hh>
Jan Möbius's avatar
 
Jan Möbius committed
65

Jan Möbius's avatar
Jan Möbius committed
66 67 68
// forward declaration
class ViewObjectMarker;

Jan Möbius's avatar
 
Jan Möbius committed
69 70
namespace Viewer {

71 72 73 74
  /** \brief Enum listing action modes of the viewers.
   *
   * These enums are used to control the reaction of the MouseInterface and the viewer on mouse events.
   */
Jan Möbius's avatar
 
Jan Möbius committed
75
  enum ActionMode {
76 77 78 79 80
    /** \brief Examine or Move mode
     *
     *  In this mode no events are passed to the MouseInterface.
     *  Only the viewer is active with mouse navigation.
     */
Jan Möbius's avatar
 
Jan Möbius committed
81
    ExamineMode,
82 83 84 85 86 87 88 89 90

    /** \brief Picking Mode
     *
     * In this mode the MouseInterface::slotMouseEvent() function gets called.
     *
     * The picking itself has to be performed by the plugins e.g. when implementing
     * \ref mouseInterfacePage
     *
     */
Jan Möbius's avatar
 
Jan Möbius committed
91
    PickingMode,
92 93 94 95 96 97

    /** \brief Question Mode
     *
     * In this mode the MouseInterface::slotMouseEventIdentify() function gets called
     *
     */
Jan Möbius's avatar
 
Jan Möbius committed
98
    QuestionMode,
99 100 101 102 103

    /** \brief Light mode
     *
     * In this mode the MouseInterface::slotMouseEventLight() function is called
     */
Jan Möbius's avatar
 
Jan Möbius committed
104 105 106
    LightMode
  };

Jan Möbius's avatar
Jan Möbius committed
107
  class DLLEXPORT ViewerProperties : public QObject {
Jan Möbius's avatar
 
Jan Möbius committed
108 109 110 111

    Q_OBJECT

    public:
Jan Möbius's avatar
Jan Möbius committed
112
      explicit ViewerProperties(int _id);
Jan Möbius's avatar
 
Jan Möbius committed
113
      ~ViewerProperties();
114 115 116 117 118
      
    //===========================================================================
    /** @name Draw Mode States
     * @{ */
    //===========================================================================      
Jan Möbius's avatar
 
Jan Möbius committed
119

120 121
    public:
      /// set draw mode (No test if this mode is available!)
122
      void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode);
123 124
      
      /// get current draw mode
125
      ACG::SceneGraph::DrawModes::DrawMode drawMode();
126 127 128
      
    private:
      
Jan Möbius's avatar
Jan Möbius committed
129
      ACG::SceneGraph::DrawModes::DrawMode currentDrawMode_;
Jan Möbius's avatar
 
Jan Möbius committed
130

131 132
    /** @} */
      
Jan Möbius's avatar
 
Jan Möbius committed
133
    //===========================================================================
134
    /** @name Snapshot settings
Jan Möbius's avatar
 
Jan Möbius committed
135 136 137
    * @{ */
    //===========================================================================

138 139 140 141 142 143 144 145 146 147
    public slots:
      /** Set the base file name and reset the counter for snapshots.

        The current snapshot counter will be added in front of the last "."
        in the filename.

        \a Note: Calling snapshotBaseFileName() will always reset the snapshot
        counter to 0.
      */
      void snapshotBaseFileName(const QString& _fname);
148

149
      /** Set the file type for snapshots. defaults to png" */
150
      void snapshotFileType(const QString& _type);
151 152
      
      /** Set the start index for the snapshot counter */
153
      void snapshotCounter(const int _counter);
154
      
Ellen Dekkers's avatar
Ellen Dekkers committed
155
      /** Get the file type for the current snapshot */
156
      QString snapshotFileType();
Ellen Dekkers's avatar
Ellen Dekkers committed
157
      
158
      /** Get the name for the current snapshot */
159
      QString snapshotName();
160 161

      /** Get the counter for the current snapshot and increases the counter */
162
      int snapshotCounter();
Jan Möbius's avatar
 
Jan Möbius committed
163

164 165
    private:
      QString                      snapshotName_;
166
      QString                      snapshotFileType_;
167
      int                          snapshotCounter_;
Jan Möbius's avatar
 
Jan Möbius committed
168 169 170

    /** @} */

171 172 173 174 175 176 177 178 179
    //===========================================================================
    //===========================================================================
    /** @name Mouse Wheel Settings
    * @{ */
    //===========================================================================
    //===========================================================================


    public slots:
180
      /// Zoom factor when using mouse wheel
181
      double wheelZoomFactor();
182

183
      /// Zoom factor when using mouse wheel and pressing shift
184
      double wheelZoomFactorShift();
185

186
      /// Set zoom factor when using mouse wheel
187
      void wheelZoomFactor(double _factor);
188

189
      /// Set zoom factor when using mouse wheel and pressing shift
190
      void wheelZoomFactorShift(double _factor);
191 192

      /// Invert mouse wheel direction?
193
      bool wheelInvert();
194 195

      /// Invert mouse wheel direction
196
      void wheelInvert(bool _invert);
197 198 199 200 201 202

    private:
      double wZoomFactor_;

      double wZoomFactorShift_;

203 204
      bool   wInvert_;

205 206
    /** @} */

207 208 209 210 211 212 213 214 215
    //===========================================================================
    //===========================================================================
    /** @name View Control
    * @{ */
    //===========================================================================
    //===========================================================================

    /** @} */

216
    //===========================================================================
217 218 219 220
    //===========================================================================
    /** @name Rendering Settings
    * @{ */
    //===========================================================================
221 222
    //===========================================================================

223 224 225
    public slots:
      /** true if counter clockwise orientation should be used to define front facing orientation.
       */
226
      bool isCCWFront();
227 228

      /// Set counter clockwise orientation as front
229
      void ccwFront();
230
      /// Set clockwise orientation as front
231
      void cwFront();
232 233 234 235

    private:
      bool CCWFront_;

236 237 238

    //===========================================================================

239 240 241
    public slots:

      /// Get current background color
242
      ACG::Vec4f backgroundColor();
243

Dirk Wilden's avatar
Dirk Wilden committed
244
      /// Get current background color
245
      QRgb backgroundColorRgb();
Dirk Wilden's avatar
Dirk Wilden committed
246

247
      /// Get current background color
248
      QColor backgroundQColor();
249

250 251
      /** Set background color.
      */
252
      void backgroundColor( ACG::Vec4f _color );
253

Dirk Wilden's avatar
Dirk Wilden committed
254 255
      /** Set background color.
      */
256
      void backgroundColor( QRgb _color );
Dirk Wilden's avatar
Dirk Wilden committed
257

258 259
      /** Set background color.
      */
260
      void backgroundColor( QColor _color );
261

262 263 264
    private:
      ACG::Vec4f backgroundColor_;

265 266 267 268 269 270 271 272 273

    //===========================================================================

    public slots:
      /** Lock update of display.
      If locked (isUpdateLocked()) then all calls to updateDisplayList()
      and updateGL() will have no effect! This is true until the display is
      unlockUpdate()'ed.
      */
274
      void lockUpdate();
275 276

      /// Unlock display locked by updateLock().
277
      void unLockUpdate();
278 279 280

      /** Are updateDisplayList() and updateGL() locked?
      (c.f. lockUpdate()) */
281
      bool updateLocked();
282 283 284 285

    private:
      int locked_;

286 287 288 289 290

    //===========================================================================

    public slots:
      /// Get current state of backface culling
291
      bool backFaceCulling();
292 293

      /// Enable or disable backface culling
294
      void backFaceCulling(bool _state );
295 296 297 298 299 300 301 302

    private:
      bool backFaceCulling_;

    //===========================================================================

    public slots:
      /// set 2-sided lighting on/off
303
      void twoSidedLighting(bool _state );
304 305

      /// is 2-sided lighing enabled?
306
      bool twoSidedLighting();
307 308 309

    private:
      bool twoSidedLighting_;
310 311 312 313 314
      
    //===========================================================================

    public slots:
      /// set multisampling on/off
315
      void multisampling(bool _state );
316 317

      /// is multisampling enabled?
318
      bool multisampling();
319 320

    private:
321 322 323 324 325 326
      bool multisampling_;
      
    //===========================================================================

    public slots:
      /// set mipmapping on/off
327
      void mipmapping(bool _state );
328 329

      /// is mipmapping enabled?
330
      bool mipmapping();
331 332 333

    private:
      bool mipmapping_;
334 335 336 337 338

    //===========================================================================

    public slots:
      /// set 2-sided lighting on/off
339
      void animation(bool _state );
340 341

      /// is 2-sided lighing enabled?
342
      bool animation();
343 344 345 346

    private:
      bool animation_;

347

348 349 350 351
    //===========================================================================

    public:
      /// Get the glState of the Viewer
352 353
      ACG::GLState& glState();
      const ACG::GLState& glState() const;
354

355
      void setglState(ACG::GLState* _glState);
356 357 358 359 360

    private:
      /// Pointer to the glState of the Viewer
      ACG::GLState* glState_;

Jan Möbius's avatar
Jan Möbius committed
361 362 363 364
    //===========================================================================

    public slots:
      /// set object marker for viewer
365
      void objectMarker (ViewObjectMarker* _marker);
Jan Möbius's avatar
Jan Möbius committed
366 367

      /// current object marker
368
      ViewObjectMarker* objectMarker();
Jan Möbius's avatar
Jan Möbius committed
369 370 371 372

    private:
      ViewObjectMarker *objectMarker_;

373 374 375 376 377 378 379 380 381
    //===========================================================================

    public:
      int currentViewingDirection();

      void currentViewingDirection(int _dir);

    private:
      int currentViewingDirection_;
382 383 384 385 386 387 388 389 390 391
      
    //===========================================================================

    public:
      bool rotationLocked();

      void rotationLocked(bool _lock);

    private:
      bool rotationLocked_;
Jan Möbius's avatar
Jan Möbius committed
392 393

    //===========================================================================
394

395
    /** @} */
396 397 398 399 400 401 402 403 404 405 406
    
    //===========================================================================
    //===========================================================================
    /** @name Projection controls and information
    * @{ */
    //===========================================================================
    //===========================================================================

    public:
      
      /// Get width of the gl scene in orthogonal projection mode (defaults to 2.0)
407
      double orthoWidth();
408 409
      
      /// Set the width of the gl scene in orthogonal projection mode
410
      void orthoWidth(double _width);
411
      
412
      
413
      /// Return distance to near Plane
414
      double nearPlane();
415
      
416
      /// Set near and far plane at the same time
417
      void setPlanes( double _near, double _far  );
418
      
419
      /// Return distance to far Plane
420
      double farPlane();
421
      
422
      /// Get current scene center (rendering center)
423
      ACG::Vec3d sceneCenter();
424 425
      
      /// Set current scene center (rendering center)
426
      void sceneCenter(ACG::Vec3d _center);
427 428 429

      
      /// Get radius of the current scene
430
      double sceneRadius();
431 432
      
      /// Set radius of the current scene
433
      void sceneRadius(double _radius );
434 435 436
      
      
      /// Get virtual trackball center (rotation center when using mouse)
437
      ACG::Vec3d trackballCenter();
438 439
      
      /// Set virtual trackball center (rotation center when using mouse)
440
      void trackballCenter(ACG::Vec3d _center);
441 442 443
      
      
      /// Get trackball radius (rotation sphere when using mouse)
444
      double trackballRadius();
445 446
      
      /// Set trackball radius   (rotation sphere when using mouse)
447
      void trackballRadius(double _radius );
448
      
449 450 451 452 453 454 455 456 457 458
    private:
      
      /// Width of the gl scene in orthogonal mode ( defaults to 2.0 )
      double orthoWidth_;
      
      /// Distance to near Plane
      double nearPlane_;
      
      ///distance to far Plane
      double farPlane_;
459 460 461 462 463 464 465 466 467 468 469 470 471
      
      /// Current scene center (rendering center)
      ACG::Vec3d sceneCenter_;
      
      /// Radius of the current scene
      double sceneRadius_;
      
      /// Virtual trackball center (rotation center when using mouse)
      ACG::Vec3d trackballCenter_;
      
      /// trackball radius   (rotation sphere when using mouse)
      double trackballRadius_;
      
472
    /** @} */
473 474 475 476 477 478 479

    //===========================================================================
    //===========================================================================
    /** @name Stereo Settings
     * @{ */
    //===========================================================================
    //===========================================================================
480
    
481 482
    public:

483 484
      void stereo(bool _stereo);
      bool stereo();
485 486 487 488 489 490 491

    private:
      /// Flag if stereo should be enabled for the current viewer
      bool stereo_;


    /** @} */
Jan Möbius's avatar
 
Jan Möbius committed
492

493 494 495 496 497 498 499 500
    //===========================================================================
    //===========================================================================
    /** @name Stereo Settings
     * @{ */
    //===========================================================================
    //===========================================================================

    public:
501 502
      CursorPainter* cursorPainter();
      void cursorPainter( CursorPainter* _painter );
503

504 505
      ACG::Vec3d cursorPoint3D();
      void cursorPoint3D(ACG::Vec3d _pos);
506

507 508
      bool cursorPositionValid();
      void cursorPositionValid(bool _valid);
509 510 511 512 513 514 515 516 517 518 519 520 521 522

    private:

      // Used to draw the current cursor in the scene
      CursorPainter *cursorPainter_;

      // position of the cursor picked into the scenegraph
      ACG::Vec3d cursorPoint3D_;

      // indicates that we successfully mapped the cursor into the scene
      bool cursorPositionValid_;

    /** @} */

Jan Möbius's avatar
 
Jan Möbius committed
523
    signals:
524

Jan Möbius's avatar
 
Jan Möbius committed
525
      /** \brief This signal is emitted when the configuration has been changed
526
       *
Jan Möbius's avatar
 
Jan Möbius committed
527 528 529
      */
      void updated();

530 531 532 533 534
      /** \brief This signal is emitted when the drawmode changed
       *
       */
      void drawModeChanged(int _viewerId );

535
      void getPickMode(std::string& _mode );
Jan Möbius's avatar
Jan Möbius committed
536
      void setPickMode(const std::string&  _mode );
537 538 539 540 541 542 543 544 545 546

      void getActionMode(Viewer::ActionMode& _am);
      void setActionMode(const Viewer::ActionMode  _am);

    public:

      /// get active pick mode
      std::string pickMode();

      /// set the pickMode
547
      void pickMode(const std::string& _name);
548 549 550

      /// get the action mode
      Viewer::ActionMode actionMode();
551

552 553
      /// set active action mode
      void actionMode(const Viewer::ActionMode _am);
554

555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
    //===========================================================================
    //===========================================================================
    /** @name Viewer id handling
     * @{ */
    //===========================================================================
    //===========================================================================

      /// Get the id of the viewer this viewerproperties belongs to
      int viewerId();

      /// Set the id of the viewer this viewerproperties belongs to
      void viewerId(int _id);

    private:

      /// Stores the id of the viewer this property belongs to
      int viewerId_;

      /// String for the Settings storage
      QString settingsSection_;

    /** @} */

Jan Möbius's avatar
 
Jan Möbius committed
578 579 580 581 582
  };

}


583