Open Inventor Release 2024.1.1
 
Loading...
Searching...
No Matches
SoDialogViz.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Nicolas DAGUISE (Oct 2002)
22**=======================================================================*/
23#ifndef _SO_DIALOG_VIZ_
24#define _SO_DIALOG_VIZ_
25
26#include <SoVersion.h>
27#if !defined(SOQT) || defined(LOAD_DIALOGVIZ_FOR_IVTUNE)
28# ifdef _WIN32
29# include <DialogViz/SoDialogVizWinLibName.h>
30# define __DIALOGVIZDLL __DIALOGVIZWINDLL
31# define __DIALOGVIZLIB __DIALOGVIZWINLIB
32# else
33# include <DialogViz/SoDialogVizXtLibName.h>
34# define __DIALOGVIZDLL __DIALOGVIZXTDLL
35# define __DIALOGVIZLIB __DIALOGVIZXTLIB
36# endif
37#else
38# include <DialogViz/SoDialogVizQtLibName.h>
39# define __DIALOGVIZDLL __DIALOGVIZQTDLL
40# define __DIALOGVIZLIB __DIALOGVIZQTLIB
41#endif
42
43// On Windows the "comment" pragma will automatically add our DialogViz
44// library to the application's link string.
45
46#ifdef _WIN32
47# if !defined(DialogVizWin_EXPORTS) && !defined(DialogVizQt_EXPORTS)
48# ifndef OIV_DISABLE_AUTOLINK
49# pragma comment(lib,__DIALOGVIZLIB)
50# endif
51# endif
52#endif
53
54#include <Inventor/actions/SoGetBoundingBoxAction.h>
55#include <Inventor/draggers/SoDragger.h>
56#include <Inventor/fields/SoSFBool.h>
57#include <Inventor/fields/SoSFString.h>
58#if !defined(LOAD_DIALOGVIZ_FOR_IVTUNE) || defined(SCALEVIZGUIQTBUILD)
59#include <Inventor/Xt/SoXt.h>
60#else
61//#undef SoWidget
62//#define SoWidget QWidget
63#endif
64
65#include <DialogViz/auditors/SoAuditor.h>
66#include <DialogViz/dialog/SoSubDialogViz.h>
67
69class SoMaterial;
70class SoNode;
71class SoPickStyle;
72class SoSearchAction;
73class SoText3;
75class SoTransform;
76class SoTranslation;
77
78#include <Inventor/SoModule.h>
79SO_MODULE_HEADER(SoDialogViz,__DIALOGVIZDLL)
80
81
161class SoDialogViz : public SoDragger
162{
163 SO_DG_HEADER(SoDialogViz);
164
165 public:
171
181
190
195
200
204 static void init();
205
216 static void finish();
217
221 static bool isInitialized();
222
226 static const char *getProductName();
227
228#if 1 SoDEPRECATED
233 static const char *getVersion();
234#endif
245 static SoDialogViz* loadFromFile(SbString filename, SbString auditorID = "");
246
247 // /**
248 // * Shows the component.
249 // */
250 // virtual void show() {};
251
252 // /**
253 // * Hides the component.
254 // */
255 // virtual void hide() {};
256
266 static void setSkin(SbString skinName);
267
273 static void setSkinsDirectories(SbString directories);
274
279
283 static void setFont(DG_FONT font);
284
285/*==============================================================================*/
286 private:
287//#pragma deprecated(setSkinsDirectory, getSkinsDirectory)
288 static SbBool setSkinsDirectory(SbString directory) { setSkin(directory); return TRUE; }
289 static SbString getSkinsDirectory() {return getSkinsDirectories(); }
290
291 static void initClass();
292 static void exitClass();
293
294 virtual void buildWidget(SoWidget parent, SbVec2i32 &rSize, SbVec2i32 &pos, SbBool is2dRender);
295 virtual void destroyWidget();
296 virtual void updateFromSensor(SoSensor* sensor);
297 void setParent(SoDialogViz* parent);
298 virtual void applyAuditor(SoDialogViz* ) {};
299 SoDialogViz* getFirstTopParent(SbBool is2DRender = TRUE, SbBool getLastValidParent = FALSE);
300 static SbVec2i32 getLabelPixelSize(SbString string, SoDialogViz* cpt);
301 static DG_FONT getDialogVizFont();
302
303// static void PrintMemoryInfo(SbString name);
304
305 static void setWidgetFont(SoWidget widget);
306 virtual void resetSize() {};
307 virtual void destroy();
308
309
310
311 private:
312
313 SbString m_cLabel;
314 SbBool m_isActive2d;
315 SoWidget m_topParentWidget;
316
317 static DG_FONT m_font;
318
319 SoDialogViz();
320 virtual ~SoDialogViz();
321
322 static SbString convertToCString(const SbString& oldString, SoDialogViz* cpt);
323 static SbString convertFromCString(const SbString& oldString, SbBool toEdit = FALSE);
324 static void setStringToText3(SoText3* myText, const SbString& inString);
325 static void destroyByRef(SoDialogViz* dialogToDestroy);
326
327 static SbBool existWidget(SoWidget widget);
328 static void fieldChangedCB(void *guiComponent , SoSensor* sensor);
329 static int getNumLines( const SbString& string); // retrieve the number of lines in the string.
330
331 // reflex functions when fields change
332 virtual void changeEnable() {};
333 virtual void changeLabel() {};
334 virtual void changeLabelAlignment() {};
335
336 // auditor methods
337 SoDialogViz* m_parentComponent;
338 void addAuditor(SoAuditor* auditor);
339 void removeAuditor(SoAuditor* auditor);
340 SoAuditor*& getAuditor(int index);
341 int getAuditorListLength();
342
343 private:
344
345 static int s_initRefCount;
346
347 static const char *s_versionString;
348
349 SbPList* m_auditorList;
350 static SbBool m_errorMsgDelivered;
351 static SbPList* s_listData;
352
353 // Field sensors declare
354 FIELD_SENSOR(enable);
355 FIELD_SENSOR(label);
356 FIELD_SENSOR(labelAlignment);
357
359// 3D methods
360private:
361 static char* TextProperties; // Internal default skins.
362 static void change3DSkin();
363 static SbBool isSkinLoaded();
364 static void setSkinLoaded(SbBool loaded);
365 static void free3DSkin(SbString partName);
366 static void load3DSkin(SbString partName);
367
368 virtual void show3D(SbBool show);
369 SbVec3f get3DParentTranslation();
370 virtual void set3DParentTranslation(SbVec3f& tsl);
371 void apply3DParentTranslation(); // this method need to be applied in each component create method.
372
373 SbBool isBuilt3D();
374 SbBool canBeTraversed();
375 void setBuilt3D(SbBool built);
376 void setCanBeTraversed(SbBool enable);
377
378 virtual void change3DPosition() {};
379 virtual void change3DWidgetEnable(SbBool state);
380
381private:
382
383 SO_DG_CATALOG_ENTRY_HEADER(geomSwitch);
384
385 SoGetBoundingBoxAction* m_boundingBoxAction;
386 SoSearchAction* m_searchAction;
387 SoGetMatrixAction* m_getMatrixAction;
388 SoPickStyle* m_enableNode;
389 SoMaterial* m_enableMaterial;
390
391 SbBool isLabelCachedBBox();
392 void setLabelCacheBBox(SbBox3f bBox);
393 SbBox3f getLabelCachedBBox();
394
395 virtual void change3DEnable();
396 virtual void change3DLabel();
397 virtual void change3DLabelAlignment() {};
398
399 void loadFontProperties();
400 void undoTransformMatrix(SoNode* searchInNode, SoTransform* tsf);
401#ifndef HIDDEN_FROM_DOC
402 void writeNode(char* file);
403#endif
404
405 static void readDefaultSkinsParts( const SbString& fileName, char* defaultSkin );
406
407 float compute3DDepth(SoNode* node);
408 void apply3DTranslation(SoNode* node, float& variable, SbVec3f& vec);
409
410 SbBool m_is3DVisible;
411 static SoDialogViz* m_lastActive;
412
413 static void set3DCurrentActive(SoDialogViz* dvNode);
414 virtual void set3DInactive();
415
416 static int insertTextTo3DText(SbString addStr, SoText3 * text, int line, int pos);
417 static int wrap3DTextLine(SoText3* text, int line, float maxWidth, SoGroup* textProp, SoDialogViz* dv);
418
419private:
420 SbBox3f m_labelCachedBBox;
421 static SbBool m_isSkinLoaded;
422
423 SbBool m_isBuilt3D;
424 SbBool m_canBeTraversed;
425
426 static SbString s_skinsPath;
427
428 SoTranslation *m_parentTranslation;
429 SbVec3f m_3DParentTranslation;
430
431 void create3DDialogViz();
432
433 static SoGroup *readFromFile( const SbString& fileName );
434#ifndef SOQT
435#ifndef _WIN32
436 static XFontStruct *requestInstalledFont();
437#endif
438#endif
440
441};
442
443#endif // _SO_DIALOG_VIZ_
444
445
3D box class.
Definition SbBox.h:649
List of generic (void *) pointers.
Definition SbPList.h:77
Class for smart character strings.
Definition SbString.h:202
2D vector class.
Definition SbVec.h:517
3D vector class.
Definition SbVec.h:932
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Base class for a...
Definition SoAuditor.h:55
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
SoSFString auditorID
Specifies the auditor ID of the node.
static void setSkinsDirectories(SbString directories)
Sets a list of directories where to search for skins.
static SbString getSkinsDirectories()
Returns the skins directory.
static void setFont(DG_FONT font)
Sets the DialogViz font.
SoSFBool enable
Enables component.
static bool isInitialized()
Returns TRUE if module is currently initialized.
static const char * getProductName()
Returns a character string identifying the name of the extension.
static void init()
Initalizes the DialogViz classes.
SoSFString label
Label string of the element.
static void setSkin(SbString skinName)
Sets the directory for 3D DialogViz component skins.
SoSFEnum labelAlignment
Specifies the label alignment.
@ CENTER
Label is center aligned.
@ LEFT
Label is left aligned.
static SoDEPRECATED const char * getVersion()
Returns a character string identifying the version of the extension.
static void finish()
Shuts down the DialogViz module, which includes freeing any internal static memory that it allocated.
static SoDialogViz * loadFromFile(SbString filename, SbString auditorID="")
Loads a DialogViz node from an Inventor file.
Base class for nodekits that move in response to click-drag-release mouse events.
Definition SoDragger.h:537
Computes bounding box of a scene.
Computes transformation matrix for a subgraph.
Base class for all group nodes.
Definition SoGroup.h:122
Surface material definition node.
Definition SoMaterial.h:173
Abstract base class for all database nodes.
Definition SoNode.h:145
Picking style node.
Definition SoPickStyle.h:94
Field containing a single Boolean value.
Definition SoSFBool.h:79
Field containing an enumerated value.
Definition SoSFEnum.h:89
Field containing a string.
Definition SoSFString.h:117
Searches for nodes in a scene graph.
Abstract base class for Open Inventor sensors.
Definition SoSensor.h:100
3D text shape node.
Definition SoText3.h:204
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Top Level Dialog...
General 3D geometric transformation node.
Node representing a 3D translation.
int SbBool
Boolean type.
Definition SbBase.h:87