ViewerProperties.hh 18.4 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 42
\*===========================================================================*/

/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
43 44 45 46 47
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
48
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67




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

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

//
#ifndef VIEWERPROPERTIES_HH
#define VIEWERPROPERTIES_HH

Jan Möbius's avatar
Jan Möbius committed
68

Jan Möbius's avatar
 
Jan Möbius committed
69
#include <QObject>
Dirk Wilden's avatar
Dirk Wilden committed
70
#include <QColor>
Jan Möbius's avatar
Jan Möbius committed
71
#include <OpenFlipper/common/GlobalDefines.hh>
72
#include <ACG/Math/VectorT.hh>
73
#include <ACG/Scenegraph/SceneGraph.hh>
Jan Möbius's avatar
Jan Möbius committed
74
#include <ACG/Scenegraph/DrawModes.hh>
75
#include <ACG/GL/GLState.hh>
76
#include <OpenFlipper/widgets/glWidget/CursorPainter.hh>
Jan Möbius's avatar
 
Jan Möbius committed
77

Jan Möbius's avatar
Jan Möbius committed
78 79 80
// forward declaration
class ViewObjectMarker;

Jan Möbius's avatar
 
Jan Möbius committed
81 82
namespace Viewer {

83 84 85 86
  /** \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
87
  enum ActionMode {
88 89 90 91 92
    /** \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
93
    ExamineMode,
94 95 96 97 98 99 100 101 102

    /** \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
103
    PickingMode,
104 105 106 107 108 109

    /** \brief Question Mode
     *
     * In this mode the MouseInterface::slotMouseEventIdentify() function gets called
     *
     */
Jan Möbius's avatar
 
Jan Möbius committed
110
    QuestionMode,
111 112 113 114 115

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

Jan Möbius's avatar
Jan Möbius committed
119
  class DLLEXPORT ViewerProperties : public QObject {
Jan Möbius's avatar
 
Jan Möbius committed
120 121 122 123

    Q_OBJECT

    public:
Jan Möbius's avatar
Jan Möbius committed
124
      explicit ViewerProperties(int _id);
Jan Möbius's avatar
 
Jan Möbius committed
125
      ~ViewerProperties();
126 127 128 129 130
      
    //===========================================================================
    /** @name Draw Mode States
     * @{ */
    //===========================================================================      
Jan Möbius's avatar
 
Jan Möbius committed
131

132 133
    public:
      /// set draw mode (No test if this mode is available!)
134
      void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode);
135 136
      
      /// get current draw mode
137
      ACG::SceneGraph::DrawModes::DrawMode drawMode();
138 139 140
      
    private:
      
Jan Möbius's avatar
Jan Möbius committed
141
      ACG::SceneGraph::DrawModes::DrawMode currentDrawMode_;
Jan Möbius's avatar
 
Jan Möbius committed
142

143 144
    /** @} */
      
Jan Möbius's avatar
 
Jan Möbius committed
145
    //===========================================================================
146
    /** @name Snapshot settings
Jan Möbius's avatar
 
Jan Möbius committed
147 148 149
    * @{ */
    //===========================================================================

150 151 152 153 154 155 156 157 158 159
    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);
160

161
      /** Set the file type for snapshots. defaults to png" */
162
      void snapshotFileType(const QString& _type);
163 164
      
      /** Set the start index for the snapshot counter */
165
      void snapshotCounter(const int _counter);
166
      
167
      /** Get the file type for the current snapshot */
168
      QString snapshotFileType();
169
      
170
      /** Get the name for the current snapshot */
171
      QString snapshotName();
172 173

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

176 177
    private:
      QString                      snapshotName_;
178
      QString                      snapshotFileType_;
179
      int                          snapshotCounter_;
Jan Möbius's avatar
 
Jan Möbius committed
180 181 182

    /** @} */

183 184 185 186 187 188 189 190 191
    //===========================================================================
    //===========================================================================
    /** @name Mouse Wheel Settings
    * @{ */
    //===========================================================================
    //===========================================================================


    public slots:
192
      /// Zoom factor when using mouse wheel
193
      double wheelZoomFactor();
194

195
      /// Zoom factor when using mouse wheel and pressing shift
196
      double wheelZoomFactorShift();
197

198
      /// Set zoom factor when using mouse wheel
199
      void wheelZoomFactor(double _factor);
200

201
      /// Set zoom factor when using mouse wheel and pressing shift
202
      void wheelZoomFactorShift(double _factor);
203 204

      /// Invert mouse wheel direction?
205
      bool wheelInvert();
206 207

      /// Invert mouse wheel direction
208
      void wheelInvert(bool _invert);
209 210 211 212 213 214

    private:
      double wZoomFactor_;

      double wZoomFactorShift_;

215 216
      bool   wInvert_;

217 218
    /** @} */

219 220 221 222 223 224 225 226 227
    //===========================================================================
    //===========================================================================
    /** @name View Control
    * @{ */
    //===========================================================================
    //===========================================================================

    /** @} */

228
    //===========================================================================
229 230 231 232
    //===========================================================================
    /** @name Rendering Settings
    * @{ */
    //===========================================================================
233 234
    //===========================================================================

235 236 237
    public slots:
      /** true if counter clockwise orientation should be used to define front facing orientation.
       */
238
      bool isCCWFront();
239 240

      /// Set counter clockwise orientation as front
241
      void ccwFront();
242
      /// Set clockwise orientation as front
243
      void cwFront();
244 245 246 247

    private:
      bool CCWFront_;

248 249 250

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

251 252 253
    public slots:

      /// Get current background color
254
      ACG::Vec4f backgroundColor();
255

Dirk Wilden's avatar
Dirk Wilden committed
256
      /// Get current background color
257
      QRgb backgroundColorRgb();
Dirk Wilden's avatar
Dirk Wilden committed
258

259
      /// Get current background color
260
      QColor backgroundQColor();
261

262 263
      /** Set background color.
      */
264
      void backgroundColor( ACG::Vec4f _color );
265

Dirk Wilden's avatar
Dirk Wilden committed
266 267
      /** Set background color.
      */
268
      void backgroundColor( QRgb _color );
Dirk Wilden's avatar
Dirk Wilden committed
269

270 271
      /** Set background color.
      */
272
      void backgroundColor( QColor _color );
273

274 275 276
    private:
      ACG::Vec4f backgroundColor_;

277 278 279 280 281 282 283 284 285

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

    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.
      */
286
      void lockUpdate();
287 288

      /// Unlock display locked by updateLock().
289
      void unLockUpdate();
290 291 292

      /** Are updateDisplayList() and updateGL() locked?
      (c.f. lockUpdate()) */
293
      bool updateLocked();
294 295 296 297

    private:
      int locked_;

298 299 300 301 302

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

    public slots:
      /// Get current state of backface culling
303
      bool backFaceCulling();
304 305

      /// Enable or disable backface culling
306
      void backFaceCulling(bool _state );
307 308 309 310 311 312 313 314

    private:
      bool backFaceCulling_;

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

    public slots:
      /// set 2-sided lighting on/off
315
      void twoSidedLighting(bool _state );
316 317

      /// is 2-sided lighing enabled?
318
      bool twoSidedLighting();
319 320 321

    private:
      bool twoSidedLighting_;
322 323 324 325 326
      
    //===========================================================================

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

      /// is multisampling enabled?
330
      bool multisampling();
331 332

    private:
333 334 335 336 337 338
      bool multisampling_;
      
    //===========================================================================

    public slots:
      /// set mipmapping on/off
339
      void mipmapping(bool _state );
340 341

      /// is mipmapping enabled?
342
      bool mipmapping();
343 344 345

    private:
      bool mipmapping_;
346 347 348 349 350

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

    public slots:
      /// set 2-sided lighting on/off
351
      void animation(bool _state );
352 353

      /// is 2-sided lighing enabled?
354
      bool animation();
355 356 357 358

    private:
      bool animation_;

359

360 361 362 363
    //===========================================================================

    public:
      /// Get the glState of the Viewer
364 365
      ACG::GLState& glState();
      const ACG::GLState& glState() const;
366

367
      void setglState(ACG::GLState* _glState);
368 369 370 371 372

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

Jan Möbius's avatar
Jan Möbius committed
373 374 375 376
    //===========================================================================

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

      /// current object marker
380
      ViewObjectMarker* objectMarker();
Jan Möbius's avatar
Jan Möbius committed
381 382 383 384

    private:
      ViewObjectMarker *objectMarker_;

385 386 387 388 389 390 391 392 393
    //===========================================================================

    public:
      int currentViewingDirection();

      void currentViewingDirection(int _dir);

    private:
      int currentViewingDirection_;
394 395 396 397 398 399 400 401 402 403
      
    //===========================================================================

    public:
      bool rotationLocked();

      void rotationLocked(bool _lock);

    private:
      bool rotationLocked_;
Jan Möbius's avatar
Jan Möbius committed
404 405

    //===========================================================================
406

407
    /** @} */
408 409 410 411 412 413 414 415 416 417 418
    
    //===========================================================================
    //===========================================================================
    /** @name Projection controls and information
    * @{ */
    //===========================================================================
    //===========================================================================

    public:
      
      /// Get width of the gl scene in orthogonal projection mode (defaults to 2.0)
419
      double orthoWidth();
420 421
      
      /// Set the width of the gl scene in orthogonal projection mode
422
      void orthoWidth(double _width);
423
      
424
      
425
      /// Return distance to near Plane
426
      double nearPlane();
427
      
428
      /// Set near and far plane at the same time
429
      void setPlanes( double _near, double _far  );
430
      
431
      /// Return distance to far Plane
432
      double farPlane();
433
      
434
      /// Get current scene center (rendering center)
435
      ACG::Vec3d sceneCenter();
436 437
      
      /// Set current scene center (rendering center)
438
      void sceneCenter(ACG::Vec3d _center);
439 440 441

      
      /// Get radius of the current scene
442
      double sceneRadius();
443 444
      
      /// Set radius of the current scene
445
      void sceneRadius(double _radius );
446 447 448
      
      
      /// Get virtual trackball center (rotation center when using mouse)
449
      ACG::Vec3d trackballCenter();
450 451
      
      /// Set virtual trackball center (rotation center when using mouse)
452
      void trackballCenter(ACG::Vec3d _center);
453 454 455
      
      
      /// Get trackball radius (rotation sphere when using mouse)
456
      double trackballRadius();
457 458
      
      /// Set trackball radius   (rotation sphere when using mouse)
459
      void trackballRadius(double _radius );
460
      
461 462 463 464 465 466 467 468 469 470
    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_;
471 472 473 474 475 476 477 478 479 480 481 482 483
      
      /// 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_;
      
484
    /** @} */
485 486 487 488 489 490 491

    //===========================================================================
    //===========================================================================
    /** @name Stereo Settings
     * @{ */
    //===========================================================================
    //===========================================================================
492
    
493 494
    public:

495 496
      void stereo(bool _stereo);
      bool stereo();
497 498 499 500 501 502 503

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


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

505 506 507 508 509 510 511 512
    //===========================================================================
    //===========================================================================
    /** @name Stereo Settings
     * @{ */
    //===========================================================================
    //===========================================================================

    public:
513 514
      CursorPainter* cursorPainter();
      void cursorPainter( CursorPainter* _painter );
515

516 517
      ACG::Vec3d cursorPoint3D();
      void cursorPoint3D(ACG::Vec3d _pos);
518

519 520
      bool cursorPositionValid();
      void cursorPositionValid(bool _valid);
521 522 523 524 525 526 527 528 529 530 531 532 533 534

    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
535
    signals:
536

Jan Möbius's avatar
 
Jan Möbius committed
537
      /** \brief This signal is emitted when the configuration has been changed
538
       *
Jan Möbius's avatar
 
Jan Möbius committed
539 540 541
      */
      void updated();

542 543 544 545 546
      /** \brief This signal is emitted when the drawmode changed
       *
       */
      void drawModeChanged(int _viewerId );

547
      void getPickMode(std::string& _mode );
Jan Möbius's avatar
Jan Möbius committed
548
      void setPickMode(const std::string&  _mode );
549 550 551 552 553 554 555 556 557 558

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

    public:

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

      /// set the pickMode
559
      void pickMode(const std::string& _name);
560 561 562

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

564 565
      /// set active action mode
      void actionMode(const Viewer::ActionMode _am);
566

567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
    //===========================================================================
    //===========================================================================
    /** @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
590 591 592 593 594
  };

}


595 596
#endif //VIEWERPROPERTIES_HH