Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoQtExaminerViewer.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Alain Dumesny (MMM yyyy)
22**=======================================================================*/
23
24
25#ifndef _SO_QT_EXAMINER_VIEWER_
26#define _SO_QT_EXAMINER_VIEWER_
30
31#include <QPointer>
32#include <QCursor>
33
35// classes used
37class SoFieldSensor;
38class SoSeparator;
39class SoSwitch;
40class SoTranslation;
41class SoScale;
42
43class SbTime;
44
46//
47// Class: SoQtExaminerViewer
48//
49// Examiner viewer - allows the user to change the camera position
50// by spinning a sphere in front of the viewpoint.
51//
52//
53// Keys used by this viewer:
54// -------------------------
55//
56// Left Mouse: Tumbles the virtual trackball.
57//
58// Middle Mouse:
59// Ctrl + Left Mouse: Translate up, down, left and right.
60//
61// Ctrl + Middle Mouse:
62// Left + Middle Mouse: Dolly in and out (gets closer to and further
63// away from the object).
64//
65// Shift + Ctrl + Left Mouse: Dolly in and out (same as Left + Middle
66// behavior but added by VSG to support the
67// standard Microsoft 2-button mouse).
68//
69// <s> + click: Alternative to the Seek button. Press (but do not hold
70// down) the <s> key, then click on a target object.
71//
72// Right Mouse: Open the popup menu.
73//
75
188{
189
190 Q_OBJECT
191
192public:
193
231
256
261 SoQtExaminerViewer( QWidget* parent = NULL,
262 const char* name = NULL,
263 SbBool buildInsideParent = TRUE,
270
277 void setViewingMode( ViewingMode viewingMode ) ;
278
282 ViewingMode getViewingMode() const { return (ViewingMode)m_guiExamViewer->getViewingMode(); }
283
296
301 { return m_constrainedMode; }
302
308
312 SbBool isFeedbackVisible() const { return m_guiExamViewer->isFeedbackVisible(); }
313
317 void setFeedbackSize( int newSize );
318
322 int getFeedbackSize() const { return m_guiExamViewer->getFeedbackSize(); }
323
332
336 SbBool isAnimationEnabled() { return m_guiExamViewer->isAnimationEnabled(); }
337
342
346 SbBool isAnimating() { return m_guiExamViewer->isAnimating(); }
347
348 //
349 // redefine these to add Examiner viewer functionality
350 //
351 virtual void viewAll();
352 virtual void resetToHomePosition();
353 virtual void setCamera( SoCamera* cam );
354 virtual void setViewing( SbBool onOrOff );
355 virtual void setCursorEnabled( SbBool onOrOff );
356 virtual void setSeekMode( SbBool onOrOff );
357
368 virtual void activateSpinning( const SbVec2s& newLocator );
369
380 virtual void activatePanning( const SbVec2s& newLocator );
381
392 virtual void activateDolly( const SbVec2s& newLocator );
393
404 virtual void activateRoll( const SbVec2s& newLocator );
405
412 virtual void rollCamera( const SbVec2s& newLocator );
413
420 virtual void spinCamera( const SbVec2f& newLocator );
421
432 virtual void spinConstrainedCamera( const SbVec2f& newLocator, int axisIndex );
433
442 virtual void dollyCamera( const SbVec2s& newLocator );
443
450 virtual void reverseDollyCamera( const SbVec2s& newLocator );
451
458 virtual void panCamera( const SbVec2f& newLocator );
459
460 private:
461
462 SoGuiExaminerViewer* getGuiExaminerViewer() const;
463
464 virtual void internalSetViewingMode( int viewingMode ) { setViewingMode( ViewingMode(viewingMode) ); };
465 virtual int internalGetViewingMode() const { return (int)m_guiExamViewer->getViewingMode(); };
466
467 private:
468
473 virtual void rotateCamera( const SbRotation& rot );
474
484 void constrainCameraRotation( bool x = false, bool y = false, bool z = false );
485
486 // This constructor takes a boolean whether to build the widget now.
487 // Subclasses can pass FALSE, then call SoQtExaminerViewer::buildWidget()
488 // when they are ready for it to be built.
489 SoQtExaminerViewer( QWidget* parent,
490 const char* name,
491 SbBool buildInsideParent,
493 SoQtViewer::Type type,
494 SbBool buildNow,
495 SbBool sync = true );
496 private:
497
498 // redefine these
499 virtual SbString getDefaultWidgetName() const;
500 virtual SbString getDefaultTitle() const;
501 virtual SbString getDefaultIconTitle() const;
502
503 // redefine those routines to do viewer specific stuff
504 virtual void processEvent( QEvent* anyevent );
505 virtual void actualRedraw();
506
507 // Get X resources for the widget.
508 QWidget* buildWidget( QWidget* parent );
509
510 // Define those thumb wheels to rotate the object
511 virtual void bottomWheelMotion( float newVal );
512 virtual void leftWheelMotion( float newVal );
513 virtual void rightWheelMotion( float newVal );
514 virtual void mouseWheelMotion( float newVal );
515
516 // redefine those routines to also stop animation if any
517 virtual void bottomWheelStart();
518 virtual void leftWheelStart();
519
520 // add viewer preference stuff
521 virtual void createPrefSheet();
522
523 // add some viewer buttons
524 virtual void createViewerButtons( QWidget* parent );
525
526 // build examiner viewer specific popup menu
527 // Note: Examiner viewer uses a slightly different popup menu
528 // resource that has two more items in the preferences submenu.
529 virtual void buildPopupMenu();
530
531 // Define this to bring the viewer help card
532 virtual void openViewerHelpCard();
533
534 virtual void pushButtonCB( int id );
535
536 virtual void updateCursor();
537
538 virtual void switchMode( int newMode );
539
540 virtual void doSpinAnimation();
541
542 int mode;
543
544 SbVec2s locator; // mouse position
545
546private:
547 SoGuiExaminerViewer* m_guiExamViewer; // Implementation class for SoXxExaminerViewer
548
549 // Viewer state variables
550 SoGuiExaminerViewer::ViewingSpinType m_viewingSpinType;
551 ConstrainedViewingMode m_constrainedMode; // Constrained viewing type
552
553 SbBool firstBuild; // set FALSE after buildWidget called once
554
555 // variables used for doing spinning animation
556 SbTime lastMotionTime;
557
558 void setViewerMode();
559 void updateViewerMode( unsigned int state );
560
561 // push button vars and callbacks
562 QPointer<SoQtButton> buttonList[10];
563 static void camPushCB( SoQtExaminerViewer* v);
564
565 // this is called by both constructors
566 void constructorCommon( SbBool buildNow );
567
568 //pixmap
569 QPixmap IDB_PUSH_PERSP;
570 QPixmap IDB_PUSH_ORTHO;
571
572#ifndef HIDDEN_FROM_DOC
573 private Q_SLOTS:
574 //slot for cam button
575 void slotCamPushButton();
576
577 //preference menu
578 void slot_popup_spin();
579 void slot_popup_axes();
580
581#endif // HIDDEN_FROM_DOC
582
583 private Q_SLOTS:
584 void visibilityChangeCB( SbBool visible );
585
586};
587
588#endif /* _SO_QT_EXAMINER_VIEWER_ */
589
590
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
Class for representing a rotation.
Definition SbRotation.h:126
Sphere-sheet projector.
Class for smart character strings.
Definition SbString.h:202
Class for representation of a time.
Definition SbTime.h:91
2D vector class.
Definition SbVec.h:76
2D vector class.
Definition SbVec.h:700
Abstract base class for camera nodes.
Definition SoCamera.h:188
Sensor class that can be attached to Open Inventor fields.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewer component...
SbBool isFeedbackVisible() const
Returns the rotation feedback flag.
virtual void dollyCamera(const SbVec2s &newLocator)
Move the camera on the z axis based on cursor motion.
virtual void activateDolly(const SbVec2s &newLocator)
Sets the start locator for dolly camera animation.
ViewingMode getViewingMode() const
Gets the current viewing mode.
SbBool isAnimating()
Queries if the viewer is currently animating.
virtual void activateSpinning(const SbVec2s &newLocator)
Sets the start locator for spin camera animation.
virtual void activateRoll(const SbVec2s &newLocator)
Sets the start locator for roll camera animation.
~SoQtExaminerViewer()
Destructor.
virtual void setViewing(SbBool onOrOff)
Sets whether the viewer is turned on or off.
ConstrainedViewingMode
Constrained viewing mode.
@ NONE
No axis constraints.
@ CONSTRAINED_VIEWING_MODE_X
Constrains camera rotation around X axis.
@ CONSTRAINED_VIEWING_MODE_Z
Constrains camera rotation around Z axis.
@ CONSTRAINED_VIEWING_MODE_Y
Constrains camera rotation around Y axis.
void setViewingMode(ViewingMode viewingMode)
Sets the viewing mode.
void setConstrainedViewingMode(ConstrainedViewingMode mode)
Sets the constrained viewing mode.
void setFeedbackSize(int newSize)
Sets the point of rotation feedback size in pixels (default 20 pix).
SbBool isAnimationEnabled()
Returns whether spin animation is enabled.
int getFeedbackSize() const
Returns the point of rotation feedback size in pixels.
virtual void setCursorEnabled(SbBool onOrOff)
Sets whether the viewer is allowed to change the cursor over the renderArea window.
SoQtExaminerViewer(QWidget *parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE, SoQtFullViewer::BuildFlag flag=SoQtFullViewer::BUILD_ALL, SoQtViewer::Type type=SoQtViewer::BROWSER)
Constructor which specifies the viewer type.
virtual void spinConstrainedCamera(const SbVec2f &newLocator, int axisIndex)
Spin the constrained camera based on cursor motion.
virtual void setSeekMode(SbBool onOrOff)
Set the viewer into/out of seek mode (default OFF).
virtual void reverseDollyCamera(const SbVec2s &newLocator)
Same as dollyCamera but reversed.
virtual void rollCamera(const SbVec2s &newLocator)
Roll the camera based on cursor motion.
void stopAnimating()
Stops animation, if it is occurring.
virtual void viewAll()
Changes the camera position to view the entire scene (the camera zoom or orientation isn't changed).
@ VIEWING_MODE_ROLL
Roll the camera in the viewer plane.
@ VIEWING_MODE_ZOOM
Dolly/Zoom (move forward and backward) to get closer to or further away from the point of interest.
@ VIEWING_MODE_PAN
Translate the camera in the viewer plane.
@ VIEWING_MODE_SPIN_CONSTRAINED
Same as VIEWING_MODE_SPIN but add also constrained camera rotation.
@ VIEWING_MODE_SPIN
Rotate the camera around the point of interest.
virtual void panCamera(const SbVec2f &newLocator)
Pans the camera based on cursor motion.
ConstrainedViewingMode getConstrainedViewingMode() const
Returns the current constrained viewing mode.
virtual void resetToHomePosition()
Restores the camera values.
virtual void spinCamera(const SbVec2f &newLocator)
Spin the camera based on cursor motion.
virtual void setCamera(SoCamera *cam)
Sets the edited camera.
virtual void activatePanning(const SbVec2s &newLocator)
Sets the start locator for pan camera animation.
void setAnimationEnabled(SbBool onOrOff)
Enables/disables the spin animation feature of the viewer (enabled by default).
void setFeedbackVisibility(SbBool onOrOff)
Shows/hides the point of rotation feedback, which only appears while in viewing mode (default is off)...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Base viewer clas...
BuildFlag
Build flags.
@ BUILD_ALL
Build everything by default.
Type
Editor types.
Definition SoQtViewer.h:186
@ BROWSER
Camera views scene, but is not added to scene.
Definition SoQtViewer.h:190
Node representing a 3D geometric scaling.
Definition SoScale.h:96
Group node that saves and restores traversal state.
Group node that traverses one chosen child.
Definition SoSwitch.h:167
Node representing a 3D translation.
int SbBool
Boolean type.
Definition SbBase.h:87