HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_Server.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RE_Server.h (C++)
7  *
8  * COMMENTS:
9  * Window server.
10  *
11  */
12 #ifndef __RE_Server__
13 #define __RE_Server__
14 
15 #include <UT/UT_Array.h>
16 #include <UT/UT_Rect.h>
17 
18 #include "RE_API.h"
19 #include "RE_IDType.h"
20 #include "RE_Types.h"
21 
22 #if defined(EXPERIMENTAL_GL_DRAWABLE_FEEL)
23 class RE_GLContext;
24 #endif
25 class RE_Window;
26 class RE_Render;
27 
28 class QSurface;
29 
31 {
32 public:
33  RE_Server();
34  ~RE_Server();
35 
36  bool initServer();
37 
38  void flush() const;
39 
40  RE_IDType getFocusWindow() const { return myFocusWindow; }
41  void setFocusWindow(RE_IDType wid);
42 
43  static int getMinXRes() { return myMinXRes; }
44  static int getMinYRes() { return myMinYRes; }
45  bool meetsMinRes( ) const;
46 
47  /// Determine if the given window (and not a child window) is currently
48  /// under the mouse.
49  /// The current x,y mouse coordinates are optional under
50  /// certain platforms
51  bool windowUnderCursor(RE_IDType wid, int x, int y) const;
52 
53  /// Return the id of the Houdini window that appears immediately
54  /// underneath the mouse cursor. Return 0/nullptr if there is no Houdini
55  /// window immediately underneath the mouse cursor.
56  static RE_IDType windowUnderCursor();
57 
58  bool getColorUnderCursor(float color[3]) const;
59 
60  bool GLMakeCurrent( OGLDrawable draw, RE_OGLContext context,
61  bool ignore_errors);
62  RE_OGLContext GLCurrentContext() const;
63  int GLMakeCopyCurrent( OGLDrawable draw,
64  RE_OGLContext sourceContext,
65  RE_OGLContext targetContext );
66 
67 #if !defined(EXPERIMENTAL_GL_DRAWABLE_FEEL)
68  bool GLSwapBuffers(RE_Window *currentWindow);
69 #else
70  bool GLSwapBuffers(RE_OGLContext context);
71 #endif
72  OGLDrawable GLGetCurrentDrawable();
73  void GLWaitGL();
74 
75  // provide some reasonable defaults
76  static int getDragTolX() { return 4; }
77  static int getDragTolY() { return 4; }
78  static fpreal64 getDragDelay() { return 0.75; }
79 
80  /// @{
81  /// Desktop support.
82  static int primaryScreenNum();
83  static int numScreens();
84  static int screenContaining(int x, int y, bool native=false);
85  static const UT_DimRect &screenArea(int screen_num);
86  static const UT_DimRect &nativeScreenArea(int screen_num);
87  static const UT_DimRect &workArea(int screen_num);
88  static const UT_DimRect &nativeWorkArea(int screen_num);
89  static const UT_DimRect &displayScreenArea(int screen_num);
90  static const UT_DimRect &displayWorkArea(int screen_num);
91  static fpreal screenToDeviceScale(int screen_num);
92  static fpreal physicalDPI(int screen_num);
93  static const UT_DimRect &virtualScreenArea();
94  static const UT_DimRect &virtualWorkArea();
95  /// @}
96 
97  /// @{
98  /// Convert from native coordinates to scaled Houdini UI coordinates
99  /// and vice versa.
100  /// @}
101  static void toScreenCoords(int &x, int &y);
102  static void fromScreenCoords(int &x, int &y);
103 
104  /// @{
105  /// Convert from a value that is scaled in Houdini UI space
106  /// to a value that is scaled in screen space and vice versa.
107  /// }@
108  ///
109  static void toScreenScale(int screen, int &value);
110  static void fromScreenScale(int screen, int &value);
111 
112  /// Add a window to the list of current main windows. If it is already in
113  /// the list, it will not be added again.
114  void addCurrentMainWindow(RE_Window *win);
115 
116  /// Remove a window from the list of current main windows.
117  void removeCurrentMainWindow(RE_Window *win);
118 
119  /// Find the current main window that's focused, so you can attach
120  /// dialog windows to it. If none is marked as focused, just returns
121  /// the first window.
122  RE_Window *getCurrentMainWindow() const;
123 
124  /// Find the first current main window, regardless of whether it's focused.
125  /// Used on Windows to ensure that all subwindows are made tool windows of
126  /// at least the main Houdini window.
127  RE_Window *getFirstCurrentMainWindow() const;
128 
129  /// Creates a new RE_Window, ready to be opened.
130  RE_Window *newWindow(RE_DisplayMode mode,
132  RE_VisualType visType=RE_NORMAL_VIS);
133 
134  /// Returns current render context matching the mode passed in. All render
135  /// contexts are tied to a specific drawable. This may return nullptr if
136  /// there are no render contexts currently created that match mode.
137  RE_Render *getContextMatching(RE_DisplayMode mode) const;
138 
139  /// Return whether the Qt objects are valid or not.
140  /// Qt objects are not valid when the Qt main event loop has exited.
141  static bool isAppExiting();
142 
143  /// This method should only be called when the Qt main event loop has
144  /// exited. It lets RE know that it is no longer safe to work with any Qt
145  /// objects.
146  static void setAppExiting();
147 
148 private:
149  /// Helper method for making the given context the current context
150  /// and binding it to the given drawable surface.
151  bool makeContextCurrent(
152  RE_OGLContext context, QSurface *surface);
153 
154  RE_OGLContext myCurrentContext;
155 
156  RE_IDType myFocusWindow;
157 
158  /// The current main windows are all the toplevel application windows.
159  /// We keep track of them to find out what window we should use when
160  /// creating dialogs - windowing systems can decorate and treat dialog
161  /// windows differently if they know which window is the parent.
162  UT_Array<RE_Window *> myCurrentMainWindows;
163 
164  static int myMinXRes;
165  static int myMinYRes;
166 };
167 
168 
169 #endif
void * RE_IDType
Definition: RE_IDType.h:20
#define RE_API
Definition: RE_API.h:10
GLuint color
Definition: glcorearb.h:1260
static int getDragTolY()
Definition: RE_Server.h:77
static fpreal64 getDragDelay()
Definition: RE_Server.h:78
GLint GLenum GLint x
Definition: glcorearb.h:408
double fpreal64
Definition: SYS_Types.h:201
RE_IDType getFocusWindow() const
Definition: RE_Server.h:40
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
static int getDragTolX()
Definition: RE_Server.h:76
RE_DisplayMode
Definition: RE_Types.h:553
GLenum mode
Definition: glcorearb.h:98
fpreal64 fpreal
Definition: SYS_Types.h:277
RE_VisualType
Definition: RE_Types.h:603
GLsizei const GLfloat * value
Definition: glcorearb.h:823
static int getMinYRes()
Definition: RE_Server.h:44
RE_WindowType
Definition: RE_Types.h:20
QOpenGLContext * RE_OGLContext
Definition: RE_Types.h:918
static int getMinXRes()
Definition: RE_Server.h:43
GLint y
Definition: glcorearb.h:102