Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoXtExaminerViewer.h
Go to the documentation of this file.
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Alain Dumesny (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifdef SOQT
52#elif defined _WIN32
54#else // _WIN32
55
56#ifndef _SO_XT_EXAMINER_VIEWER_
57#define _SO_XT_EXAMINER_VIEWER_
58
62
63// classes used
65class SoFieldSensor;
66class SoSeparator;
67class SoSwitch;
68class SoTranslation;
69class SoScale;
71
73//
74// Class: SoXtExaminerViewer
75//
76// Examiner viewer - allows the user to change the camera position
77// by spinning a sphere in front of the viewpoint.
78//
79//
80// Keys used by this viewer:
81// -------------------------
82//
83// Left Mouse: Tumbles the virtual trackball.
84//
85// Middle Mouse:
86// Ctrl + Left Mouse: Translate up, down, left and right.
87//
88// Ctrl + Middle Mouse:
89// Left + Middle Mouse: Dolly in and out (gets closer to and further
90// away from the object).
91//
92// <s> + click: Alternative to the Seek button. Press (but do not hold
93// down) the <s> key, then click on a target object.
94//
95// Right Mouse: Open the popup menu.
96//
98
219{
220 public:
221
254
279
285 const char* name = NULL,
286 SbBool buildInsideParent = TRUE,
287 SoXtFullViewer::BuildFlag flag = SoXtFullViewer::BUILD_ALL,
288 SoXtViewer::Type type = SoXtViewer::BROWSER );
293
300 void setViewingMode( ViewingMode viewingMode ) ;
301
306 { return (ViewingMode)m_guiExamViewer->getViewingMode(); }
307
320
325 { return m_constrainedMode; }
326
332
336 SbBool isFeedbackVisible() const { return m_guiExamViewer->isFeedbackVisible(); }
337
341 void setFeedbackSize( int newSize );
342
346 int getFeedbackSize() const { return m_guiExamViewer->getFeedbackSize(); }
347
356
360 SbBool isAnimationEnabled() { return m_guiExamViewer->isAnimationEnabled(); }
361
366
370 SbBool isAnimating() { return m_guiExamViewer->isAnimating(); }
371
372 //
373 // redefine these to add Examiner viewer functionality
374 //
375 virtual void viewAll();
376 virtual void resetToHomePosition();
377 virtual void setCamera( SoCamera* cam );
378 virtual void setViewing( SbBool onOrOff );
379 virtual void setCursorEnabled( SbBool onOrOff );
380 virtual void setSeekMode( SbBool onOrOff );
381
392 virtual void activateSpinning( const SbVec2s& newLocator );
393
404 virtual void activatePanning( const SbVec2s& newLocator );
405
416 virtual void activateDolly( const SbVec2s& newLocator );
417
428 virtual void activateRoll( const SbVec2s& newLocator );
429
436 virtual void rollCamera( const SbVec2s& newLocator );
437
438
445 virtual void spinCamera( const SbVec2f& newLocator );
446
457 virtual void spinConstrainedCamera( const SbVec2f& newLocator, int axisIndex );
458
467 virtual void dollyCamera( const SbVec2s& newLocator );
468
475 virtual void reverseDollyCamera( const SbVec2s& newLocator );
476
483 virtual void panCamera( const SbVec2f& newLocator );
484
485 private:
486
491 virtual void rotateCamera( const SbRotation& rot );
492
502 void constrainCameraRotation( bool x = false, bool y = false, bool z = false );
503
504 private:
505
506 SoGuiExaminerViewer* getGuiExaminerViewer() const;
507
508
509 // This constructor takes a boolean whether to build the widget now.
510 // Subclasses can pass FALSE, then call SoXtExaminerViewer::buildWidget()
511 // when they are ready for it to be built.
512 private:
514 const char* name,
515 SbBool buildInsideParent,
516 SoXtFullViewer::BuildFlag flag,
517 SoXtViewer::Type type,
518 SbBool buildNow,
519 SbBool sync = TRUE );
520
521 private:
522 // redefine these
523 virtual SbString getDefaultWidgetName() const;
524 virtual SbString getDefaultTitle() const;
525 virtual SbString getDefaultIconTitle() const;
526
527 // redefine those routines to do viewer specific stuff
528 virtual void processEvent( XAnyEvent* anyevent );
529 virtual void actualRedraw();
530
531 // Get X resources for the widget.
532 SoWidget buildWidget( SoWidget parent );
533
534 // Define those thumb wheels to rotate the object
535 virtual void bottomWheelMotion( float newVal );
536 virtual void leftWheelMotion( float newVal );
537 virtual void rightWheelMotion( float newVal );
538
539 // redefine those routines to also stop animation if any
540 virtual void bottomWheelStart();
541 virtual void leftWheelStart();
542
543 // add viewer preference stuff
544 virtual void createPrefSheet();
545
546 // add some viewer buttons
547 virtual void createViewerButtons( SoWidget parent );
548
549 // Define this to bring the viewer help card
550 virtual void openViewerHelpCard();
551
552 virtual void updateCursor();
553
554 private:
555 // viewer state variables
556 Cursor spinCursor, panCursor, dollyCursor, seekCursor;
557 SbBool firstBuild; // set FALSE after buildWidget called once
558
559 // point of rotation feedback vars
560 void createFeedbackNodes();
561
562 // variables used for doing spinning animation
563 unsigned long lastMotionTime;
564 static void visibilityChangeCB( void* pt, SbBool visible );
565
566 void setViewerMode();
567 void updateViewerMode( unsigned int state );
568 void switchMode( int newMode );
569 void defineCursors();
570
571 // preference sheet stuff
572 SoWidget createExamPrefSheetGuts( SoWidget parent );
573 static void animPrefSheetToggleCB( SoWidget w, SoXtExaminerViewer* v, void* data );
574
575 // point of rotation pref sheet stuff
576 int feedbackSizeWheelVal;
577 SoWidget feedbackLabel[2], feedbackField, feedbackSizeWheel;
578 static void feedbackSizeWheelCB( SoWidget w, SoXtExaminerViewer* v, XtPointer* d );
579 static void feedbackSizeFieldCB( SoWidget w, SoXtExaminerViewer* v, void* data );
580 static void feedbackPrefSheetToggleCB( SoWidget w, SoXtExaminerViewer* v, void* data );
581 void toggleFeedbackWheelSize( SoWidget toggle );
582
583 // push button vars and callbacks
584 SoXtBitmapButton* buttonList[10];
585 static void camPushCB( SoWidget w, SoXtExaminerViewer* v, void* data);
586
587 // this is called by both constructors
588 void constructorCommon( SbBool buildNow );
589
590 SoGuiExaminerViewer* m_guiExamViewer; // Implementation class for SoXxExaminerViewer
591
592 // Viewer state variables
593 SoGuiExaminerViewer::ViewingSpinType m_viewingSpinType;
594 ConstrainedViewingMode m_constrainedMode; // Constrained viewing type
595};
596
597#endif /* _SO_XT_EXAMINER_VIEWER_ */
598
599#endif // _WIN32
600
601
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
void * XtPointer
Definition SoQtDef.h:118
#define SoWidget
Definition SoQtDef.h:40
#define XAnyEvent
Definition SoWinDef.h:100
#define Cursor
Definition SoWinDef.h:42
#define SoXtBitmapButton
Definition SoXt2SoQt.h:36
#define SoXtExaminerViewer
Definition SoXt2SoQt.h:66
Class for representing a rotation.
Definition SbRotation.h:126
Sphere-sheet projector.
Class for smart character strings.
Definition SbString.h:202
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.
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.
Viewer component which uses a virtual trackball to view the data.
ViewingMode getViewingMode() const
Gets the current viewing mode.
virtual void activatePanning(const SbVec2s &newLocator)
Sets the start locator for pan camera animation.
virtual void activateSpinning(const SbVec2s &newLocator)
Sets the start locator for spin camera animation.
SbBool isFeedbackVisible() const
Returns the rotation feedback flag.
virtual void activateDolly(const SbVec2s &newLocator)
Sets the start locator for dolly camera animation.
virtual void dollyCamera(const SbVec2s &newLocator)
Move the camera on the z axis based on cursor motion.
~SoXtExaminerViewer()
Destructor.
virtual void resetToHomePosition()
Restores the camera values.
virtual void reverseDollyCamera(const SbVec2s &newLocator)
Same as dollyCamera but reversed.
ConstrainedViewingMode
Constrained viewing mode.
@ CONSTRAINED_VIEWING_MODE_X
Constrains camera rotation around X axis.
@ NONE
No axis constraints.
@ CONSTRAINED_VIEWING_MODE_Y
Constrains camera rotation around Y axis.
@ CONSTRAINED_VIEWING_MODE_Z
Constrains camera rotation around Z axis.
void setViewingMode(ViewingMode viewingMode)
Sets the viewing mode.
virtual void setCamera(SoCamera *cam)
Sets the edited camera.
int getFeedbackSize() const
Returns the point of rotation feedback size in pixels.
virtual void activateRoll(const SbVec2s &newLocator)
Sets the start locator for roll camera animation.
virtual void setSeekMode(SbBool onOrOff)
Externally set the viewer into/out off seek mode (default OFF).
ConstrainedViewingMode getConstrainedViewingMode() const
Returns the current constrained viewing mode.
void stopAnimating()
Stops animation, if it is occurring.
@ VIEWING_MODE_SPIN_CONSTRAINED
Same as VIEWING_MODE_SPIN but add also constrained camera rotation.
@ VIEWING_MODE_ZOOM
Dolly/Zoom (move forward and backward) to get closer to or further away from the point of interest.
@ VIEWING_MODE_SPIN
Rotate the camera around the point of interest.
@ VIEWING_MODE_PAN
Translate the camera in the viewer plane.
virtual void spinCamera(const SbVec2f &newLocator)
Spin the camera based on cursor motion.
virtual void setViewing(SbBool onOrOff)
Sets whether the viewer is turned on or off.
void setAnimationEnabled(SbBool onOrOff)
Enables/disables the spinning 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)...
SbBool isAnimating()
Queries if the viewer is currently animating.
void setFeedbackSize(int newSize)
Sets the point of rotation feedback size in pixels (default 20 pix).
virtual void spinConstrainedCamera(const SbVec2f &newLocator, int axisIndex)
Spin the constrained camera based on cursor motion.
virtual void setCursorEnabled(SbBool onOrOff)
Sets whether the viewer is allowed to change the cursor over the renderArea window.
virtual void viewAll()
Changes the camera position to view the entire scene (the camera zoom or orientation isn't changed).
void setConstrainedViewingMode(ConstrainedViewingMode mode)
Sets the constrained viewing mode.
SoXtExaminerViewer(SoWidget parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE, SoXtFullViewer::BuildFlag flag=SoXtFullViewer::BUILD_ALL, SoXtViewer::Type type=SoXtViewer::BROWSER)
Constructor which specifies the viewer type.
virtual void panCamera(const SbVec2f &newLocator)
Pans the camera based on cursor motion.
SbBool isAnimationEnabled()
Returns whether spin animation is enabled.
virtual void rollCamera(const SbVec2s &newLocator)
Roll the camera based on cursor motion.
Base viewer class which adds a decoration around the rendering area.
int SbBool
Boolean type.
Definition SbBase.h:87