Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoQt.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 : Nick Thompson (MMM yyyy)
22** Modified by : Paul Isaacs (MMM yyyy)
23** Modified by : David Mott (MMM yyyy)
24** Modified by : Gavin Bell (MMM yyyy)
25**=======================================================================*/
26
27
28#ifndef _SO_QT_
29#define _SO_QT_
30
31#ifndef SOQT
32#define SOQT
33#endif
34
35#include <Inventor/Qt/SoXt2SoQt.h>
36
37#include <qglobal.h>
38
39#include <QEvent>
40#include <QObject>
41#include <QWidget>
42#include <QToolButton>
43#include <QPushButton>
44#include <QApplication>
45#include <QPointer>
46
47#include <Inventor/SbLinear.h>
48#include <Inventor/SbString.h>
49#include <Inventor/Qt/SoQtDef.h>
50#include <Inventor/Qt/SoInventorQtLibName.h>
51
52#include <Inventor/SoModule.h>
53SO_MODULE_HEADER(SoInventorQt, __INVENTORQTDLL)
54
55#ifdef _WIN32
56#if !defined(InventorQt_EXPORTS)
57#ifndef OIV_DISABLE_AUTOLINK
58# pragma comment(lib,__INVENTORQTLIB)
59#endif
60#endif
61#endif //win
62
63class SbPList;
64class SoQtSensorHandler;
65class SoAction;
66
89class SoQt : public QObject
90{
91 Q_OBJECT
92 // QObject inheritance is not required here.
93 // Just for consistency and to allow possible Q_SLOTS.
94 public:
104 SoNONUNICODE static QWidget *init(const char *appName, const char *className = "Inventor");
105
113 static QWidget *init(const SbString& appName, const SbString& className = "Inventor");
114
121 static void init( QWidget *topLevelWidget );
122
123#if 1 SoDEPRECATED
128 SoNONUNICODE static QWidget *threadInit(const char *appName,
129 const char *className = "Inventor");
130SoDEPRECATED
132 static QWidget *threadInit(const SbString& appName,
133 const SbString& className = "Inventor");
134SoDEPRECATED
136 static void threadInit(QWidget *topLevelWidget);
137#endif
144 static void show(QWidget *widget);
150 static void hide(QWidget *widget);
151
159 static int mainLoop();
160
169 static void exit(int returnCode = 0);
170
175 static void nextEvent(XtAppContext appContext, XEvent *event);
195 static QWidget *getTopLevelWidget();
199 static void setWidgetSize(QWidget *widget, const SbVec2s &size);
203 static SbVec2s getWidgetSize(QWidget *widget);
204
212 SoNONUNICODE static void createSimpleErrorDialog(QWidget *widget, char *dialogTitle,
213 char *errorStr1, char *errorStr2 = NULL);
214
220 static void createSimpleErrorDialog( QWidget *widget, const SbString& sdialogTitle,
221 const SbString& errorStr1, const SbString& errorStr2 = "" );
222
282 static void finish();
283
287 static bool isInitialized();
288
295
296private:
297 // Hide from docs...
298
299 static QPointer<QWidget> mainWidget;
300 static QPointer<QApplication> qapplication;
301 static QApplication *getQApp() {return qapplication;};
302
303 // Add/remove the passed event handler for X extension device events
304 // (Xt does not handle extension events.)
305 // Extension event types are queried from the server at runtime.
306 static void addExtensionEventHandler(QWidget *w,
307 int extensionEventType,
308 XtEventHandler proc,
309 XtPointer clientData);
310 static void removeExtensionEventHandler(QWidget *w,
311 int extensionEventType,
312 XtEventHandler proc,
313 XtPointer clientData);
314
315 static void getExtensionEventHandler(XEvent *event, QWidget *w,
316 XtEventHandler &proc,
317 XtPointer &clientData);
318
319private:
320
321 static SoQtSensorHandler *sensorHandler;
322
323private:
324
325 // Code factorization for init(SbString&, SbString&) and threadInit(SbString&, SbString&)
326 // Return true if init is ok (false if init is already done)
327 static bool commonInit(const SbString& appName, const SbString& className);
328
329 static void setupInventorGLDisplay();
330
331 static int s_returnCode;
332
333 static SbPList *handlerList;
334 static int OIVExtensionEventNumber;
335 static int s_initRefCount;
336 static const char *s_versionString;
337 static SbBool s_ownTopLevelWindow;
338 static SbBool s_ownApplication;
339 static int s_defaultArgc;
340 static char** s_defaultArgv;
341};
342
343#ifdef __APPLE__
344#define SoQtButton QToolButton
345#else
346#define SoQtButton QPushButton
347#endif
348
349#endif // _SO_QT_
350
351
List of generic (void *) pointers.
Definition SbPList.h:77
Class for smart character strings.
Definition SbString.h:202
2D vector class.
Definition SbVec.h:700
Abstract base class for all actions.
Definition SoAction.h:132
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Routines for Ope...
Definition SoQt.h:90
SoDEPRECATED static SoNONUNICODE QWidget * threadInit(const char *appName, const char *className="Inventor")
Non Unicode: This function should not be used in a Unicode application.
static void exit(int returnCode=0)
Tells the main event loop to exit with a return code.
static void show(QWidget *widget)
Convenience routine to show the passed widget handle.
static bool isInitialized()
Returns TRUE if SoQt module is currently initialized.
static int getExtensionEventNumber()
Returns the type number of the Open Inventor extension QCustomEvent.
static void createSimpleErrorDialog(QWidget *widget, const SbString &sdialogTitle, const SbString &errorStr1, const SbString &errorStr2="")
Convenience routine which brings a simple Qt error dialog box displaying the given error string(s) an...
static SoDEPRECATED QWidget * threadInit(const SbString &appName, const SbString &className="Inventor")
static void hide(QWidget *widget)
Convenience routine to hide the passed widget handle.
static SbGlContextHelper::GLContext getAppContext()
This method is included for portability only.
static SbGlContextHelper::Display getDisplay()
This method is included for portability only.
static SoDEPRECATED void threadInit(QWidget *topLevelWidget)
static int mainLoop()
Enters the main event loop and waits until exit() is called or QCoreApplication::exit() is called.
static QWidget * getTopLevelWidget()
Returns information based on the initial QWidget handle returned by or passed to init.
static SbVec2s getWidgetSize(QWidget *widget)
Convenience routine to get the size of the given widget.
static SoNONUNICODE void createSimpleErrorDialog(QWidget *widget, char *dialogTitle, char *errorStr1, char *errorStr2=NULL)
Convenience routine which brings a simple Qt error dialog box displaying the given error string(s) an...
static SoNONUNICODE QWidget * init(const char *appName, const char *className="Inventor")
This is called to initialize Open Inventor and Qt, and bind Open Inventor with Qt message handling so...
static QWidget * init(const SbString &appName, const SbString &className="Inventor")
This is called to initialize Open Inventor and Qt, and bind Open Inventor with Qt message handling so...
static void finish()
Frees Open Inventor's internal static memory allocations.
static Boolean dispatchEvent(XEvent *)
This method is included for portability only.
static void init(QWidget *topLevelWidget)
This alternate form of init allows the application to initialize Qt.
static void nextEvent(XtAppContext appContext, XEvent *event)
This method is included for portability only.
static void setWidgetSize(QWidget *widget, const SbVec2s &size)
Convenience routine to set the size of the given widget.
int SbBool
Boolean type.
Definition SbBase.h:87
union _XEvent XEvent
Definition SoQtDef.h:126
char Boolean
Definition SoQtDef.h:124
struct _XtAppStruct * XtAppContext
Definition SoQtDef.h:130
void * XtPointer
Definition SoQtDef.h:122