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 #if !defined(SOQT) || defined(LOAD_DIALOGVIZ_FOR_IVTUNE)
00028 # ifdef _WIN32
00029 # include <DialogViz/SoDialogVizWinLibName.h>
00030 # define __DIALOGVIZDLL __DIALOGVIZWINDLL
00031 # define __DIALOGVIZLIB __DIALOGVIZWINLIB
00032 # else
00033 # include <DialogViz/SoDialogVizXtLibName.h>
00034 # define __DIALOGVIZDLL __DIALOGVIZXTDLL
00035 # define __DIALOGVIZLIB __DIALOGVIZXTLIB
00036 # endif
00037 #else
00038 # include <DialogViz/SoDialogVizQtLibName.h>
00039 # define __DIALOGVIZDLL __DIALOGVIZQTDLL
00040 # define __DIALOGVIZLIB __DIALOGVIZQTLIB
00041 #endif
00042
00043
00044
00045
00046 #ifdef _WIN32
00047 # if !defined(DialogVizWin_EXPORTS) && !defined(DialogVizQt_EXPORTS)
00048 # ifndef OIV_DISABLE_AUTOLINK
00049 # pragma comment(lib,__DIALOGVIZLIB)
00050 # endif
00051 # endif
00052 #endif
00053
00054 #include <Inventor/actions/SoGetBoundingBoxAction.h>
00055 #include <Inventor/draggers/SoDragger.h>
00056 #include <Inventor/fields/SoSFBool.h>
00057 #include <Inventor/fields/SoSFString.h>
00058 #if !defined(LOAD_DIALOGVIZ_FOR_IVTUNE) || defined(SCALEVIZGUIQTBUILD)
00059 #include <Inventor/Xt/SoXt.h>
00060 #else
00061
00062
00063 #endif
00064
00065 #include <DialogViz/auditors/SoAuditor.h>
00066 #include <DialogViz/dialog/SoSubDialogViz.h>
00067
00068 class SoGetMatrixAction;
00069 class SoMaterial;
00070 class SoNode;
00071 class SoPickStyle;
00072 class SoSearchAction;
00073 class SoText3;
00074 class SoTopLevelDialog;
00075 class SoTransform;
00076 class SoTranslation;
00077
00078 #include <Inventor/SoModule.h>
00079 SO_MODULE_HEADER(SoDialogViz,__DIALOGVIZDLL)
00080
00081
00161 class SoDialogViz : public SoDragger
00162 {
00163 SO_DG_HEADER(SoDialogViz);
00164
00165 public:
00170 SoSFBool enable;
00171
00180 SoSFString label;
00181
00182 enum LabelAlignment {
00184 LEFT,
00186 CENTER,
00188 RIGHT
00189 };
00190
00194 SoSFEnum labelAlignment;
00195
00199 SoSFString auditorID;
00200
00204 static void init();
00205
00216 static void finish();
00217
00221 static bool isInitialized();
00222
00226 static const char *getProductName();
00227
00231 static const char *getVersion();
00232
00242 static SoDialogViz* loadFromFile(SbString filename, SbString auditorID = "");
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00263 static void setSkin(SbString skinName);
00264
00270 static void setSkinsDirectories(SbString directories);
00271
00275 static SbString getSkinsDirectories();
00276
00280 static void setFont(DG_FONT font);
00281
00282
00283 private:
00284
00285 static SbBool setSkinsDirectory(SbString directory) { setSkin(directory); return TRUE; }
00286 static SbString getSkinsDirectory() {return getSkinsDirectories(); }
00287
00288 static void initClass();
00289 static void exitClass();
00290
00291 virtual void buildWidget(SoWidget parent, SbVec2i32 &rSize, SbVec2i32 &pos, SbBool is2dRender);
00292 virtual void destroyWidget();
00293 virtual void updateFromSensor(SoSensor* sensor);
00294 void setParent(SoDialogViz* parent);
00295 virtual void applyAuditor(SoDialogViz* ) {};
00296 SoDialogViz* getFirstTopParent(SbBool is2DRender = TRUE, SbBool getLastValidParent = FALSE);
00297 static SbVec2i32 getLabelPixelSize(SbString string, SoDialogViz* cpt);
00298 static DG_FONT getDialogVizFont();
00299
00300
00301
00302 static void setWidgetFont(SoWidget widget);
00303 virtual void resetSize() {};
00304 virtual void destroy();
00305
00306
00307
00308 private:
00309
00310 SbString m_cLabel;
00311 SbBool m_isActive2d;
00312 SoWidget m_topParentWidget;
00313
00314 static DG_FONT m_font;
00315
00316 SoDialogViz();
00317 virtual ~SoDialogViz();
00318
00319 static SbString convertToCString(const SbString& oldString, SoDialogViz* cpt);
00320 static SbString convertFromCString(const SbString& oldString, SbBool toEdit = FALSE);
00321 static void setStringToText3(SoText3* myText, const SbString& inString);
00322 static void destroyByRef(SoDialogViz* dialogToDestroy);
00323
00324 static SbBool existWidget(SoWidget widget);
00325 static void fieldChangedCB(void *guiComponent , SoSensor* sensor);
00326 static int getNumLines( const SbString& string);
00327
00328
00329 virtual void changeEnable() {};
00330 virtual void changeLabel() {};
00331 virtual void changeLabelAlignment() {};
00332
00333
00334 SoDialogViz* m_parentComponent;
00335 void addAuditor(SoAuditor* auditor);
00336 void removeAuditor(SoAuditor* auditor);
00337 SoAuditor*& getAuditor(int index);
00338 int getAuditorListLength();
00339
00340 private:
00341
00342 static int s_initRefCount;
00343
00344 static const char *s_versionString;
00345
00346 SbPList* m_auditorList;
00347 static SbBool m_errorMsgDelivered;
00348 static SbPList* s_listData;
00349
00350
00351 FIELD_SENSOR(enable);
00352 FIELD_SENSOR(label);
00353 FIELD_SENSOR(labelAlignment);
00354
00356
00357 private:
00358 static char* TextProperties;
00359 static void change3DSkin();
00360 static SbBool isSkinLoaded();
00361 static void setSkinLoaded(SbBool loaded);
00362 static void free3DSkin(SbString partName);
00363 static void load3DSkin(SbString partName);
00364
00365 virtual void show3D(SbBool show);
00366 SbVec3f get3DParentTranslation();
00367 virtual void set3DParentTranslation(SbVec3f& tsl);
00368 void apply3DParentTranslation();
00369
00370 SbBool isBuilt3D();
00371 SbBool canBeTraversed();
00372 void setBuilt3D(SbBool built);
00373 void setCanBeTraversed(SbBool enable);
00374
00375 virtual void change3DPosition() {};
00376 virtual void change3DWidgetEnable(SbBool state);
00377
00378 private:
00379
00380 SO_DG_CATALOG_ENTRY_HEADER(geomSwitch);
00381
00382 SoGetBoundingBoxAction* m_boundingBoxAction;
00383 SoSearchAction* m_searchAction;
00384 SoGetMatrixAction* m_getMatrixAction;
00385 SoPickStyle* m_enableNode;
00386 SoMaterial* m_enableMaterial;
00387
00388 SbBool isLabelCachedBBox();
00389 void setLabelCacheBBox(SbBox3f bBox);
00390 SbBox3f getLabelCachedBBox();
00391
00392 virtual void change3DEnable();
00393 virtual void change3DLabel();
00394 virtual void change3DLabelAlignment() {};
00395
00396 void loadFontProperties();
00397 void undoTransformMatrix(SoNode* searchInNode, SoTransform* tsf);
00398 #ifndef HIDDEN_FROM_DOC
00399 void writeNode(char* file);
00400 #endif
00401
00402 static void readDefaultSkinsParts( const SbString& fileName, char* defaultSkin );
00403
00404 float compute3DDepth(SoNode* node);
00405 void apply3DTranslation(SoNode* node, float& variable, SbVec3f& vec);
00406
00407 SbBool m_is3DVisible;
00408 static SoDialogViz* m_lastActive;
00409
00410 static void set3DCurrentActive(SoDialogViz* dvNode);
00411 virtual void set3DInactive();
00412
00413 static int insertTextTo3DText(SbString addStr, SoText3 * text, int line, int pos);
00414 static int wrap3DTextLine(SoText3* text, int line, float maxWidth, SoGroup* textProp, SoDialogViz* dv);
00415
00416 private:
00417 SbBox3f m_labelCachedBBox;
00418 static SbBool m_isSkinLoaded;
00419
00420 SbBool m_isBuilt3D;
00421 SbBool m_canBeTraversed;
00422
00423 static SbString s_skinsPath;
00424
00425 SoTranslation *m_parentTranslation;
00426 SbVec3f m_3DParentTranslation;
00427
00428 void create3DDialogViz();
00429
00430 static SoGroup *readFromFile( const SbString& fileName );
00431 #ifndef SOQT
00432 #ifndef _WIN32
00433 static XFontStruct *requestInstalledFont();
00434 #endif
00435 #endif
00437
00438 };
00439
00440 #endif // _SO_DIALOG_VIZ_
00441
00442
00443