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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #ifndef _SCENE_VIEWER_
00056 #define _SCENE_VIEWER_
00057
00058 #include <X11/Intrinsic.h>
00059 #include <Xm/Xm.h>
00060 #include <Xm/RowColumn.h>
00061
00062 #include <Inventor/nodes/SoNode.h>
00063 #include <Inventor/SbPList.h>
00064 #include <Inventor/nodes/SoPerspectiveCamera.h>
00065 #include <Inventor/actions/SoGLRenderAction.h>
00066 #include <Inventor/actions/SoCallbackAction.h>
00067 #include <Inventor/Xt/viewers/SoXtFullViewer.h>
00068
00069
00070 class MyColorEditor;
00071 class SoXtMaterialEditor;
00072 class SoXtPrintDialog;
00073 class SoXtTransformSliderSet;
00074 class SoXtClipboard;
00075 class SoXtDirectionalLightEditor;
00076
00077
00078 class SoBoxHighlightRenderAction;
00079 class SoSelection;
00080 class SoPickedPoint;
00081
00082
00083 class SoDirectionalLight;
00084 class SoEnvironment;
00085 class SoGroup;
00086 class SoLabel;
00087 class SoMaterial;
00088 class SoSceneViewer;
00089 class SoSwitch;
00090 class SoLight;
00091 class SoTransform;
00092
00093
00094 class SvManipList;
00095
00096 enum SvEViewer {
00097 SV_VWR_EXAMINER = 0,
00098 SV_VWR_FLY,
00099 SV_VWR_WALK,
00100 SV_VWR_PLANE
00101 };
00102
00103 enum SvEManipMode {
00104 SV_NONE,
00105 SV_TRANSFORMER,
00106 SV_TRACKBALL,
00107 SV_HANDLEBOX,
00108 SV_JACK,
00109 SV_CENTERBALL,
00110 SV_XFBOX,
00111 SV_TABBOX
00112 };
00113
00114 struct SoSceneViewerData;
00115 struct SvLightData;
00116
00118
00119
00120
00121
00122
00123
00124
00126
00127 class SoSceneViewer : public SoXtComponent {
00128
00129 public:
00130
00131
00132
00133
00134
00135
00136
00137
00138 SoSceneViewer(
00139 Widget parent = NULL,
00140 const char *name = NULL,
00141 SbBool buildInsideParent = TRUE,
00142 SoSelection *root = NULL,
00143 const char *envFile = NULL);
00144 ~SoSceneViewer();
00145
00146 protected:
00147
00148
00149
00150 SoEXTENDER
00151 SoSceneViewer(
00152 Widget parent,
00153 const char *name,
00154 SbBool buildInsideParent,
00155 SoSelection *root,
00156 const char *envFile,
00157 SbBool buildNow);
00158
00159
00160 public:
00161
00162
00163
00164 void viewAll()
00165 { if (currentViewer != NULL) currentViewer->viewAll(); }
00166 void viewSelection();
00167 void saveHomePosition()
00168 { if (currentViewer != NULL) currentViewer->saveHomePosition(); }
00169 void setCamera(SoCamera *cam)
00170 { if (currentViewer != NULL) currentViewer->setCamera(cam); }
00171
00172
00173 SoCamera *getCamera()
00174 { return (currentViewer) ? currentViewer->getCamera() : NULL; }
00175
00176
00177
00178
00179
00180 void newData();
00181
00182
00183 void showMenu(SbBool onOrOff);
00184 SbBool isMenuShown() { return showMenuFlag; }
00185
00186
00187 void setDecoration(SbBool onOrOff)
00188 { if (currentViewer != NULL) currentViewer->setDecoration(onOrOff); }
00189 SbBool isDecoration()
00190 { return currentViewer != NULL ? currentViewer->isDecoration() : FALSE; }
00191
00192
00193 void setHeadlight(SbBool onOrOff)
00194 { if (currentViewer != NULL) currentViewer->setHeadlight(onOrOff); }
00195 SbBool isHeadlight()
00196 { return currentViewer != NULL ? currentViewer->isHeadlight() : FALSE; }
00197 SoDirectionalLight *getHeadlight()
00198 { return currentViewer != NULL ? currentViewer->getHeadlight() : NULL; }
00199
00200
00201
00202
00203
00204
00205
00206
00207 void setDrawStyle(SoXtViewer::DrawType type,
00208 SoXtViewer::DrawStyle style)
00209 { currentViewer->setDrawStyle(type, style); }
00210 SoXtViewer::DrawStyle getDrawStyle(SoXtViewer::DrawType type)
00211 { return currentViewer->getDrawStyle(type); }
00212
00213
00214
00215
00216
00217 void setBufferingType(SoXtViewer::BufferType type)
00218 { currentViewer->setBufferingType(type); }
00219 SoXtViewer::BufferType getBufferingType()
00220 { return currentViewer->getBufferingType(); }
00221
00222
00223 void setViewing(SbBool onOrOff) { currentViewer->setViewing(onOrOff); }
00224 SbBool isViewing() { return currentViewer->isViewing(); }
00225
00226
00227 void setTransparencyType(SoGLRenderAction::TransparencyType type)
00228 { currentViewer->setTransparencyType(type); }
00229 SoGLRenderAction::TransparencyType getTransparencyType()
00230 { return currentViewer->getTransparencyType(); }
00231
00232
00233 Widget getRenderAreaWidget() { return currentViewer->getRenderAreaWidget(); }
00234
00235 #ifdef EXPLORER
00236
00237 void setUserModeEventCallback(SoXtRenderAreaEventCB *fcn);
00238 #endif
00239
00240 protected:
00241
00242 virtual const char * getDefaultWidgetName() const;
00243 virtual const char * getDefaultTitle() const;
00244 virtual const char * getDefaultIconTitle() const;
00245
00246 private:
00247
00248 SoSelection *selection;
00249 SoSeparator *sceneGraph;
00250
00251
00252 SoGroup *lightsCameraEnvironment;
00253 SoLabel *envLabel;
00254 SoEnvironment *environment;
00255 SoGroup *lightGroup;
00256
00257 void createLightsCameraEnvironment();
00258
00259
00260 SoBoxHighlightRenderAction *highlightRA;
00261
00262
00263
00264
00265
00266 Widget mgrWidget;
00267 Widget menuWidget;
00268 SbBool showMenuFlag;
00269 SoSceneViewerData *menuItems;
00270
00271 Widget buildWidget(Widget parent);
00272 void buildAndLayoutMenu(Widget parent);
00273 void buildAndLayoutViewer(SoXtFullViewer *vwr);
00274
00275
00276 static void processTopbarEvent(Widget, SoSceneViewerData *,
00277 XmAnyCallbackStruct *);
00278
00279 static void menuDisplay(Widget, SoSceneViewerData *, XtPointer);
00280
00281
00282 void updateCommandAvailability();
00283
00284
00285
00286
00287
00288
00289 int fileMode;
00290 char *fileName;
00291 SbBool useShowcaseBrowser;
00292 void getFileName();
00293 SbBool doFileIO(const char *filename);
00294 SbBool readFile(const char *filename);
00295 SbBool writeFile(const char *filename);
00296 SbBool readEnvFile(const char *filename);
00297 SbBool writeEnvFile(const char *filename);
00298 void deleteScene();
00299 void save();
00300
00301
00302 void removeCameras(SoGroup *root);
00303
00304 SoCamera *getLastSceneKitCamera(SoGroup *root);
00305
00306 void setLastSceneKitCamera(SoGroup *root, SoCamera *theCam);
00307
00308 void switchOffSceneKitCameras(SoGroup *root);
00309 void restoreSceneKitCameras(SoGroup *root);
00310
00311 void setCameraFields( SoCamera *fromCam );
00312 SbDict *sceneKitCamNumDict;
00313
00314
00315 Widget fileDialog;
00316 static void fileDialogCB(Widget, SoSceneViewer *,
00317 XmFileSelectionBoxCallbackStruct *);
00318
00319
00320 SoXtPrintDialog *printDialog;
00321 void print();
00322 static void beforePrintCallback(void *uData, SoXtPrintDialog *);
00323 static void afterPrintCallback(void *uData, SoXtPrintDialog *);
00324
00325
00326 SbBool feedbackShown;
00327
00328 void showAboutDialog();
00329
00330
00331
00332
00333
00334
00335 void pickParent();
00336 void pickAll();
00337
00338
00339 SoXtClipboard *clipboard;
00340 void destroySelectedObjects();
00341
00342
00343 void pasteDone(SoPathList *pathList);
00344 static void pasteDoneCB(void *userData, SoPathList *pathList);
00345
00346
00347 static SbBool iconDropCB(void *userData, const char *filename);
00348 static SbBool objDropCB(
00349 void *userData,
00350 Atom dataType,
00351 void *data, uint32_t numBytes);
00352
00353
00354
00355
00356
00357
00358 SoXtFullViewer *viewerList[4];
00359 SvEViewer whichViewer;
00360 SoXtFullViewer *currentViewer;
00361
00362 void switchToViewer(SvEViewer newViewer);
00363
00364
00365 SbBool fogFlag;
00366 void setFog(SbBool onOrOff);
00367 SbBool antialiasingFlag;
00368 void setAntialiasing(SbBool onOrOff);
00369
00370
00371 MyColorEditor *backgroundColorEditor;
00372 const SbColor & getBackgroundColor() { return currentViewer->getBackgroundColor(); }
00373 void editBackgroundColor();
00374 static void backgroundColorCallback(void *userData,
00375 const SbColor *color);
00376
00377
00378
00379
00380
00381 SbBool ignoreCallback;
00382 SoMaterial *findMaterialForAttach( const SoPath *target );
00383 SoPath *findTransformForAttach( const SoPath * target );
00384
00385 static SoCallbackAction::Response findMtlPreTailCB(void *data,
00386 SoCallbackAction *accum,
00387 const SoNode *);
00388
00389
00390 SoXtTransformSliderSet *transformSliderSet;
00391 void createTransformSliderSet();
00392
00393
00394 SoXtMaterialEditor *materialEditor;
00395 void createMaterialEditor();
00396
00397
00398 MyColorEditor *colorEditor;
00399 void createColorEditor();
00400
00401
00402
00403
00404
00405 SvEManipMode curManip;
00406 SbBool curManipReplaces;
00407 SvManipList *maniplist;
00408
00409
00410 void replaceAllManips( SvEManipMode manipType );
00411
00412
00413 void attachManip( SvEManipMode manipType, SoPath *p );
00414 void attachManipToAll( SvEManipMode manipType );
00415
00416
00417 void detachManip( SoPath *p );
00418 void detachManipFromAll();
00419
00420
00421
00422 void removeManips();
00423 void restoreManips();
00424
00425
00426
00427 static void adjustScaleTabSizeCB( void *, SoXtViewer *);
00428
00429
00430
00431
00432
00433 SbPList lightDataList;
00434 SoXtDirectionalLightEditor *headlightEditor;
00435 SvLightData *headlightData;
00436 void addLight(SoLight *light);
00437 SvLightData *addLightEntry(SoLight *light, SoSwitch *lightSwitch);
00438 void addLightMenuEntry(SvLightData *);
00439 void turnLightOnOff(SvLightData *data, SbBool flag);
00440 static void lightToggleCB(Widget, SvLightData *, void *);
00441 void editLight(SvLightData *data, SbBool flag);
00442 static void editLightToggleCB(Widget, SvLightData *, void *);
00443 static void editLightColorCB(Widget, SvLightData *, void *);
00444 void removeLight(SvLightData *);
00445 static void removeLightCB(Widget, SvLightData *, void *);
00446 static void lightSubmenuDisplay(Widget, SvLightData *, void *);
00447 void transferDirectionalLightLocation( SvLightData *data );
00448
00449
00450 void calculateLightManipSize();
00451 float lightManipSize;
00452 SbBool calculatedLightManipSize;
00453
00454
00455
00456 void removeAttachedLightManipGeometry();
00457 void addAttachedLightManipGeometry();
00458
00459
00460 MyColorEditor *ambientColorEditor;
00461 void editAmbientColor();
00462 static void ambientColorCallback(void *userData,
00463 const SbColor *color);
00464
00465
00466
00467
00468
00469 static void deselectionCallback(void *userData, SoPath *obj);
00470 static void selectionCallback(void *userData, SoPath *obj);
00471 static SoPath * pickFilterCB(void *userData, const SoPickedPoint *pick);
00472
00473
00474
00475
00476 static SbBool isAffectedByTransform( SoNode *node );
00477 static SbBool isAffectedByMaterial( SoNode *node );
00478
00479 #ifdef EXPLORER
00480
00481
00482
00483 SoXtRenderAreaEventCB *userModeCB;
00484 void *userModedata;
00485 SbBool userModeFlag;
00486 #endif
00487
00488 void constructorCommon(SoSelection *root, const char *envFile, SbBool buildNow);
00489 };
00490
00491 #endif