00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SoTVizViewer_H
00026 #define SoTVizViewer_H
00027
00028
00029
00030
00031 #ifdef _WIN32
00032 class SoWinBitmapButton;
00033 #ifdef TVIZ_USE_JOYSTICK
00034 class SiTVizJoystick;
00035 #endif
00036 #endif
00037
00038 #include <Inventor/Xt/viewers/SoXtConstrainedViewer.h>
00039 #include <TerrainViz/viewer/SoTVizCameraManager.h>
00040
00041 #ifdef _WIN32
00042 # include <Inventor/sys/SoDynamicLibManager.h>
00043 # include <SoVersion.h>
00044 # if defined(_DEBUG)
00045 # define __INVTVIZWDLL "TerrainVizWinD.dll"
00046 # define __INVTVIZWLIB "TerrainVizWinD.lib"
00047 # else
00048 # define __INVTVIZWDLL "TerrainVizWin.dll"
00049 # define __INVTVIZWLIB "TerrainVizWin.lib"
00050 # endif
00051 # ifndef TerrainVizWin_EXPORTS
00052 # ifndef OIV_DISABLE_AUTOLINK
00053 # pragma comment(lib,__INVTVIZWLIB)
00054 # endif
00055 # endif
00056 #else
00057 # define __INVTVIZWDLL "libTerrainVizXt"
00058 #endif
00059
00060 #include <Inventor/SoModule.h>
00061 SO_MODULE_HEADER(SoTerrainVizWin, __INVTVIZWDLL)
00062
00063 class SoSwitch;
00064 class SoSeparator;
00065 class SoPerspectiveCamera;
00066 class SoDirectionalLight;
00067 class SoCallback;
00068 class SoNode;
00069 class SoTransform;
00070 class SoFieldSensor;
00071 class SoTVizControls;
00072 class SoTVizNavigationTools;
00073 class SoTVizNavigationToolBase;
00074
00075
00076
00077 #define DEFAULT_SPD_MOD_COEF 1.f
00078 #define DEFAULT_MAX_ROLL_ANGLE 30.f
00079 #define DEFAULT_TERRAINSIZE_TO_MAXSPEED .1f
00080 #define FLY_SPD_FACTOR .3f
00081 #define TOPLEFTWHEEL_FACTOR .1f
00082 class SoDEPRECATED SoTVizViewer : public SoXtConstrainedViewer, public SoTVizCameraManager
00112 {
00113 public:
00114
00118 SoTVizViewer ( SoWidget parent = NULL,
00119 const char *name = NULL,
00120 SbBool buildwithDefaultTools = TRUE,
00121 SbBool buildInsideParent = TRUE,
00122 SoXtFullViewer::BuildFlag flag = BUILD_ALL,
00123 SoXtViewer::Type type = BROWSER);
00124
00128 ~SoTVizViewer ();
00129
00130
00134 virtual void setFlyMode (SbBool onOff);
00135
00139 virtual SbBool isFlyMode () const;
00140
00145 virtual void setInvertedControlsMode (SbBool onOff);
00146
00150 virtual SbBool isInvertedControlsMode () const;
00151
00158 virtual void setMaxRollAngle (float newAngle);
00159
00163 virtual float getMaxRollAngle () const;
00164
00165
00170 virtual void setElevationRelativeSpeedMode (SbBool onOff);
00171
00175 virtual SbBool isElevationRelativeSpeedMode () const;
00176
00177
00178 enum speedUnits {
00182 KILOMETERS_PER_HOUR,
00186 METERS_PER_SECOND,
00190 MILES_PER_HOUR
00191 };
00192
00193
00197 virtual void setSpeedUnit (SoTVizViewer::speedUnits newSpeedUnit = SoTVizViewer::KILOMETERS_PER_HOUR);
00198
00202 virtual SoTVizViewer::speedUnits getSpeedUnit () const;
00203
00210 virtual void setSpeedModulationCoeff (float newCoeff);
00211
00215 virtual float getSpeedModulationCoeff () const;
00216
00229 virtual void setMaxSpeed (float newSpeed, SbBool autoMaxSpeed = FALSE);
00230
00234 virtual float getMaxSpeed () const;
00235
00239 virtual void setBorderRespect (SbBool onOff);
00240
00241
00252 virtual void setConstantElevationMode (SbBool onOff, SbBool resetElevation = FALSE);
00253
00259 virtual void setTargetRelativeElevation (double newElevation);
00260
00264 virtual void setMinimumElevation (double newMinimalElevation);
00265
00269 virtual void setTerrain (SoNode* t);
00270
00274 void setNorth (SbVec3f& newNorth);
00275
00279 SbVec3f getNorth() const;
00280
00285 virtual void openControls();
00286
00291 virtual SoTVizNavigationTools* getTerrainNavigationTools () const;
00292
00296 virtual void setTerrainNavigationToolsVisibility (SbBool onOff);
00297
00301 virtual SbBool getTerrainNavigationToolsVisibility () const;
00302
00303
00307 virtual void setTerrainNavigationToolsInteractivity (SbBool onOff);
00308
00312 virtual SbBool getTerrainNavigationToolsInteractivity () const;
00313
00314
00315
00322 virtual void setSceneGraph (SoNode *);
00323
00329 virtual void setCamera (SoCamera *);
00330
00334 virtual SoCamera* getCamera () const;
00335
00339 virtual void setHeadlight(SbBool);
00340
00344 virtual void setUpDirection (SbVec3f& newUpDirection);
00345
00349 virtual SbVec3f getUpDirection() const { return getGuiConstrainedViewer()->getUpDirection(); }
00350
00355 virtual void viewAll();
00356
00360 virtual void resetToHomePosition();
00361
00362
00374 virtual void setViewing (SbBool onOff);
00375
00384 virtual void setCursorEnabled(SbBool onOff);
00385
00386
00387
00388 private:
00389
00390
00391 SoTVizViewer(SoWidget parent,
00392 const char *name,
00393 SbBool buildwithDefaultTools,
00394 SbBool buildInsideParent,
00395 SoXtFullViewer::BuildFlag flag,
00396 SoXtViewer::Type type,
00397 SbBool buildNow);
00398
00399 void
00400 SoTVizViewerCommon(SoWidget parent,
00401 const char *name,
00402 SbBool buildwithDefaultTools,
00403 SbBool buildInsideParent,
00404 SoXtFullViewer::BuildFlag flag,
00405 SoXtViewer::Type type,
00406 SbBool buildNow);
00407
00408
00409
00410 enum {
00411 PICK_MODE,
00412 WALK_MODE,
00413 WALK_MODE_ACTIVE,
00414 TILT_MODE,
00415 TILT_MODE_ACTIVE,
00416 PAN_MODE,
00417 PAN_MODE_ACTIVE,
00418 FLY_MODE,
00419 FLY_MODE_ACTIVE,
00420 SEEK_MODE
00421 };
00422 int m_mode;
00423
00424
00425 enum {
00426
00427 FLY_PUSH = 8,
00428 CT_ELEVATION_PUSH = 9
00429 };
00430
00431
00432 SbVec2s m_locator;
00433
00434 void commonDelete() ;
00435
00436
00437 #ifdef _WIN32
00438
00439 HCURSOR sizeCursor, moveCursor;
00440
00441 virtual void buildPopupMenu();
00442
00443 virtual void pushButtonCB (SoWidget w, int id, void *);
00444
00445 virtual void processPopupItem(int item);
00446
00447 static void topLeftWheelCB (SoTVizViewer *v, XtPointer *d);
00448 #elif defined(__APPLE__)
00449
00450 #else
00451 SbBool createdCursors;
00452 Cursor walkCursor, spinCursor, panCursor, flyCursor, seekCursor;
00453
00454
00455 virtual SoWidget buildFunctionsSubmenu(SoWidget popup);
00456 virtual void rightWheelMotion(float newVal);
00457
00458 static void topLeftWheelCB(SoWidget, SoTVizViewer *v, XtPointer *d);
00459 #endif
00460
00461 void setFlyModeCommon (SbBool onOff);
00462 void setConstantElevationModeCommon (SbBool onOff, SbBool resetElevation);
00463
00464 virtual void defineCursors();
00465 virtual void updateCursor();
00466
00467
00468 virtual void sizeChanged(const SbVec2s & newSize);
00469
00470
00471 virtual SoWidget buildLeftTrim(SoWidget parent);
00472
00473
00474 virtual void createViewerButtons(SoWidget parent);
00475
00476
00477 virtual void processEvent (XAnyEvent *);
00478
00479
00480 virtual void setSeekMode (SbBool flag);
00481
00482
00483 void switchMode (int newMode);
00484
00485 float topLeftWheelVal;
00486 virtual void topLeftWheelStart();
00487 virtual void topLeftWheelFinish();
00488 virtual void topLeftWheelMotion(float newVal);
00489
00490
00491
00492 virtual void updateIOUnits();
00493
00494
00495 SoTVizNavigationTools * m_navTools;
00496 SbBool m_terrainNavigationToolsVisibility;
00497 SbBool m_terrainNavigationToolsInteractivity;
00498
00499
00500 SbBool m_controlKey;
00501 SbBool m_shiftKey;
00502 SbBool m_leftButton;
00503
00504 private:
00505
00506
00507 void constructorCommon (SbBool buildNow);
00508
00509
00510 SoTVizControls * m_controlsBox;
00511 SoSwitch * m_navToolsSwitch;
00512
00513
00514
00515 SbVec3f m_northVector;
00516 SbVec3f m_internalNorthDirection;
00517
00518 void updateNorthDirection();
00519
00520 SbBool m_flyMode;
00521 SbBool m_invertedControlsMode;
00522 SbBool m_buildwithDefaultTools;
00523 float m_maxRollingAngle;
00524
00525 SoNode* m_sceneGraph;
00526 SoNode* m_terrain;
00527
00528 SoTVizViewer::speedUnits m_speedUnit;
00529 float m_toIOSpeed;
00530 SbBool m_elevationRelativeSpeedMode;
00531 float m_speedModulationCoeff;
00532 float m_maxSpeed;
00533 float m_previousAngleX;
00534
00535
00536 void computeViewerSpeed ();
00537
00538
00539 SoFieldSensor * m_cameraPositionSensor;
00540 SoFieldSensor * m_cameraOrientationSensor;
00541 static void cameraPositionCB (void *, SoSensor *);
00542 static void cameraOrientationCB (void *, SoSensor *);
00543
00544
00545 static void animationSensorCB (void *, SoSensor *);
00546 void startAnimating ();
00547 void stopAnimating ();
00548 void doCameraAnimation ();
00549 SbRotation m_noRolling;
00550 SbTime m_prevAnimTime;
00551 SoFieldSensor * m_animationSensor;
00552
00553 SbVec3f m_previousCameraPosition;
00554 SbBool m_resetCamera;
00555
00556 float m_maxHeight;
00557
00558 double m_previousTargetHeight;
00559
00560 SbVec2s m_locatorOnLeftClick;
00561
00562 SbBool m_autoMaxSpeed;
00563
00564 #ifdef _WIN32
00565 private:
00566
00567 SoWinBitmapButton* fly_Button;
00568 SoWinBitmapButton* ct_Elevation_Button;
00569
00570
00571 SoWinBitmapButton* buttonList[12];
00572
00573 SoDynamicLibManager::SafeLibraryHandle TVizWinDLL;
00574
00575 SoDynamicLibManager::SafeLibraryHandle resDLL;
00576
00577 #ifdef TVIZ_USE_JOYSTICK
00578 private:
00579 SiTVizJoystick* m_joystick;
00580 SbBool m_joystickUsed;
00581 int m_previousMode;
00582
00583 private:
00584 static void setJoystickCallback(void *data, SoSensor *);
00585 void joystickControl ();
00586 SbBool isJoystickActivated();
00587
00588 void switchControlInput();
00589 SbBool isJoystickUsed();
00590 SbBool isButtonPressed(unsigned char which_one);
00591 #endif
00592
00593 #elif defined(__APPLE__)
00594
00595 #else
00596 private:
00597
00598 SoXtBitmapButton* flyPushButton;
00599 SoXtBitmapButton* cstElevPushButton;
00600
00601 static void menuPick(SoWidget, int id, XmAnyCallbackStruct *);
00602
00603 static void pushButtonCB (SoWidget w, int id, void *);
00604 #endif
00605
00606 };
00607
00608 #endif // SoTVizViewer_H
00609
00610
00611