00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SO_DIALOG_VIZ_
00024 #define _SO_DIALOG_VIZ_
00025
00026 #include <SoVersion.h>
00027
00028
00029
00030
00031 #ifdef _WIN32
00032 # if !defined(SOQT) || defined(LOAD_DIALOGVIZ_FOR_IVTUNE)
00033 # if defined(_DEBUG)
00034 # define __DIALOGVIZDLL "DialogVizWinD.dll"
00035 # define __DIALOGVIZLIB "DialogVizWinD.lib"
00036 # else
00037 # define __DIALOGVIZDLL "DialogVizWin.dll"
00038 # define __DIALOGVIZLIB "DialogVizWin.lib"
00039 # endif
00040 # else
00041 # if defined(_DEBUG)
00042 # define __DIALOGVIZDLL "DialogVizQtD.dll"
00043 # define __DIALOGVIZLIB "DialogVizQtD.lib"
00044 # else
00045 # define __DIALOGVIZDLL "DialogVizQt.dll"
00046 # define __DIALOGVIZLIB "DialogVizQt.lib"
00047 # endif
00048 # endif
00049 # if !defined(DialogVizWin_EXPORTS) && !defined(DialogVizQt_EXPORTS)
00050 # ifndef OIV_DISABLE_AUTOLINK
00051 # pragma comment(lib,__DIALOGVIZLIB)
00052 # endif
00053 # endif
00054 #else
00055 # if !defined(SOQT) || defined(LOAD_DIALOGVIZ_FOR_IVTUNE)
00056 # define __DIALOGVIZDLL "libDialogVizXt"
00057 # else
00058 # define __DIALOGVIZDLL "libDialogVizQt"
00059 # endif
00060 #endif
00061
00062 #include <Inventor/actions/SoGetBoundingBoxAction.h>
00063 #include <Inventor/draggers/SoDragger.h>
00064 #include <Inventor/fields/SoSFBool.h>
00065 #include <Inventor/fields/SoSFString.h>
00066 #if !defined(LOAD_DIALOGVIZ_FOR_IVTUNE) || defined(SCALEVIZGUIQTBUILD)
00067 #include <Inventor/Xt/SoXt.h>
00068 #else
00069
00070
00071 #endif
00072
00073 #include <DialogViz/auditors/SoAuditor.h>
00074 #include <DialogViz/dialog/SoSubDialogViz.h>
00075
00076 class SoGetMatrixAction;
00077 class SoMaterial;
00078 class SoNode;
00079 class SoPickStyle;
00080 class SoSearchAction;
00081 class SoText3;
00082 class SoTopLevelDialog;
00083 class SoTransform;
00084 class SoTranslation;
00085
00086 #include <Inventor/SoModule.h>
00087 SO_MODULE_HEADER(SoDialogViz,__DIALOGVIZDLL)
00088
00089
00170 class SoDialogViz : public SoDragger
00171 {
00172 SO_DG_HEADER(SoDialogViz);
00173
00174 public:
00179 SoSFBool enable;
00180
00189 SoSFString label;
00190
00191 enum LabelAlignment {
00193 LEFT,
00195 CENTER,
00197 RIGHT
00198 };
00199
00203 SoSFEnum labelAlignment;
00204
00208 SoSFString auditorID;
00209
00213 static void init();
00214
00225 static void finish();
00226
00230 static bool isInitialized();
00231
00235 static const char *getProductName();
00236
00240 static const char *getVersion();
00241
00251 static SoDialogViz* loadFromFile(SbString filename, SbString auditorID = "");
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00272 static void setSkin(SbString skinName);
00273
00279 static void setSkinsDirectories(SbString directories);
00280
00284 static SbString getSkinsDirectories();
00285
00289 static void setFont(DG_FONT font);
00290
00291
00292 private:
00293
00294 static SbBool setSkinsDirectory(SbString directory) { setSkin(directory); return TRUE; }
00295 static SbString getSkinsDirectory() {return getSkinsDirectories(); }
00296
00297 static void initClass();
00298 static void exitClass();
00299
00300 virtual void buildWidget(SoWidget parent, SbVec2i32 &rSize, SbVec2i32 &pos, SbBool is2dRender);
00301 virtual void destroyWidget();
00302 virtual void updateFromSensor(SoSensor* sensor);
00303 void setParent(SoDialogViz* parent);
00304 virtual void applyAuditor(SoDialogViz* ) {};
00305 SoDialogViz* getFirstTopParent(SbBool is2DRender = TRUE, SbBool getLastValidParent = FALSE);
00306 static SbVec2i32 getLabelPixelSize(SbString string, SoDialogViz* cpt);
00307 static DG_FONT getDialogVizFont();
00308
00309
00310
00311 static void setWidgetFont(SoWidget widget);
00312 virtual void resetSize() {};
00313 virtual void destroy();
00314
00315
00316
00317 private:
00318
00319 SbString m_cLabel;
00320 SbBool m_isActive2d;
00321 SoWidget m_topParentWidget;
00322
00323 static DG_FONT m_font;
00324
00325 SoDialogViz();
00326 virtual ~SoDialogViz();
00327
00328 static SbString convertToCString(const SbString& oldString, SoDialogViz* cpt);
00329 static SbString convertFromCString(const SbString& oldString, SbBool toEdit = FALSE);
00330 static void setStringToText3(SoText3* myText, const SbString& inString);
00331 static void destroyByRef(SoDialogViz* dialogToDestroy);
00332
00333 static SbBool existWidget(SoWidget widget);
00334 static void fieldChangedCB(void *guiComponent , SoSensor* sensor);
00335 static int getNumLines( const SbString& string);
00336
00337
00338 virtual void changeEnable() {};
00339 virtual void changeLabel() {};
00340 virtual void changeLabelAlignment() {};
00341
00342
00343 SoDialogViz* m_parentComponent;
00344 void addAuditor(SoAuditor* auditor);
00345 void removeAuditor(SoAuditor* auditor);
00346 SoAuditor*& getAuditor(int index);
00347 int getAuditorListLength();
00348
00349 private:
00350
00351 static int s_initRefCount;
00352
00353 static const char *s_versionString;
00354
00355 SbPList* m_auditorList;
00356 static SbBool m_errorMsgDelivered;
00357 static SbPList* s_listData;
00358
00359
00360 FIELD_SENSOR(enable);
00361 FIELD_SENSOR(label);
00362 FIELD_SENSOR(labelAlignment);
00363
00365
00366 private:
00367 static char* TextProperties;
00368 static void change3DSkin();
00369 static SbBool isSkinLoaded();
00370 static void setSkinLoaded(SbBool loaded);
00371 static void free3DSkin(SbString partName);
00372 static void load3DSkin(SbString partName);
00373
00374 virtual void show3D(SbBool show);
00375 SbVec3f get3DParentTranslation();
00376 virtual void set3DParentTranslation(SbVec3f& tsl);
00377 void apply3DParentTranslation();
00378
00379 SbBool isBuilt3D();
00380 SbBool canBeTraversed();
00381 void setBuilt3D(SbBool built);
00382 void setCanBeTraversed(SbBool enable);
00383
00384 virtual void change3DPosition() {};
00385 virtual void change3DWidgetEnable(SbBool state);
00386
00387 private:
00388
00389 SO_DG_CATALOG_ENTRY_HEADER(geomSwitch);
00390
00391 SoGetBoundingBoxAction* m_boundingBoxAction;
00392 SoSearchAction* m_searchAction;
00393 SoGetMatrixAction* m_getMatrixAction;
00394 SoPickStyle* m_enableNode;
00395 SoMaterial* m_enableMaterial;
00396
00397 SbBool isLabelCachedBBox();
00398 void setLabelCacheBBox(SbBox3f bBox);
00399 SbBox3f getLabelCachedBBox();
00400
00401 virtual void change3DEnable();
00402 virtual void change3DLabel();
00403 virtual void change3DLabelAlignment() {};
00404
00405 void loadFontProperties();
00406 void undoTransformMatrix(SoNode* searchInNode, SoTransform* tsf);
00407 #ifndef HIDDEN_FROM_DOC
00408 void writeNode(char* file);
00409 #endif
00410
00411 static void readDefaultSkinsParts( const SbString& fileName, char* defaultSkin );
00412
00413 float compute3DDepth(SoNode* node);
00414 void apply3DTranslation(SoNode* node, float& variable, SbVec3f& vec);
00415
00416 SbBool m_is3DVisible;
00417 static SoDialogViz* m_lastActive;
00418
00419 static void set3DCurrentActive(SoDialogViz* dvNode);
00420 virtual void set3DInactive();
00421
00422 static int insertTextTo3DText(SbString addStr, SoText3 * text, int line, int pos);
00423 static int wrap3DTextLine(SoText3* text, int line, float maxWidth, SoGroup* textProp, SoDialogViz* dv);
00424
00425 private:
00426 SbBox3f m_labelCachedBBox;
00427 static SbBool m_isSkinLoaded;
00428
00429 SbBool m_isBuilt3D;
00430 SbBool m_canBeTraversed;
00431
00432 static SbString s_skinsPath;
00433
00434 SoTranslation *m_parentTranslation;
00435 SbVec3f m_3DParentTranslation;
00436
00437 void create3DDialogViz();
00438
00439 static SoGroup *readFromFile( const SbString& fileName );
00440 #ifndef SOQT
00441 #ifndef _WIN32
00442 static XFontStruct *requestInstalledFont();
00443 #endif
00444 #endif
00446
00447 };
00448
00449 #endif // _SO_DIALOG_VIZ_
00450
00451
00452