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 "RE_API.h"
16 #include "RE_IDType.h"
17 #include "RE_Types.h"
18 
19 #include <UT/UT_Array.h>
20 #include <UT/UT_UniquePtr.h>
21 #include <UT/UT_Rect.h>
22 #include <SYS/SYS_Compiler.h>
23 
24 
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  bool GLSwapBuffers(RE_Window *currentWindow);
68  OGLDrawable GLGetCurrentDrawable();
69  void GLWaitGL();
70 
71  // provide some reasonable defaults
72  static int getDragTolX() { return 4; }
73  static int getDragTolY() { return 4; }
74  static fpreal64 getDragDelay() { return 0.75; }
75 
76  /// @{
77  /// Desktop support.
78  static int primaryScreenNum();
79  static int numScreens();
80  static int screenContaining(int x, int y, bool native=false);
81  static const UT_DimRect &screenArea(int screen_num);
82  static const UT_DimRect &nativeScreenArea(int screen_num);
83  static const UT_DimRect &workArea(int screen_num);
84  static const UT_DimRect &nativeWorkArea(int screen_num);
85  static const UT_DimRect &displayScreenArea(int screen_num);
86  static const UT_DimRect &displayWorkArea(int screen_num);
87  static fpreal screenToDeviceScale(int screen_num);
88  static fpreal physicalDPI(int screen_num);
89  static const UT_DimRect &virtualScreenArea();
90  static const UT_DimRect &virtualWorkArea();
91  /// @}
92 
93  /// @{
94  /// Convert from native coordinates to scaled Houdini UI coordinates
95  /// and vice versa.
96  /// @}
97  static void toScreenCoords(int &x, int &y);
98  static void fromScreenCoords(int &x, int &y);
99 
100  /// @{
101  /// Convert from a value that is scaled in Houdini UI space
102  /// to a value that is scaled in screen space and vice versa.
103  /// }@
104  ///
105  static void toScreenScale(int screen, int &value);
106  static void fromScreenScale(int screen, int &value);
107 
108  /// Add a window to the list of current main windows. If it is already in
109  /// the list, it will not be added again.
110  void addCurrentMainWindow(RE_Window *win);
111 
112  /// Remove a window from the list of current main windows.
113  void removeCurrentMainWindow(RE_Window *win);
114 
115  /// Find the current main window that's focused, so you can attach
116  /// dialog windows to it. If none is marked as focused, just returns
117  /// the first window.
118  RE_Window *getCurrentMainWindow() const;
119 
120  /// Find the first current main window, regardless of whether it's focused.
121  /// Used on Windows to ensure that all subwindows are made tool windows of
122  /// at least the main Houdini window.
123  RE_Window *getFirstCurrentMainWindow() const;
124 
125  /// Creates a new RE_Window, ready to be opened.
127  UT_UniquePtr<RE_Window> newWindow(
130  RE_VisualType vis_type = RE_NORMAL_VIS);
131 
132  /// Returns current render context matching the mode passed in. All render
133  /// contexts are tied to a specific drawable. This may return nullptr if
134  /// there are no render contexts currently created that match mode.
135  RE_Render *getContextMatching(RE_DisplayMode mode) const;
136 
137  /// Return whether the Qt objects are valid or not.
138  /// Qt objects are not valid when the Qt main event loop has exited.
139  static bool isAppExiting();
140 
141  /// This method should only be called when the Qt main event loop has
142  /// exited. It lets RE know that it is no longer safe to work with any Qt
143  /// objects.
144  static void setAppExiting();
145 
146 private:
147  /// Helper method for making the given context the current context
148  /// and binding it to the given drawable surface.
149  bool makeContextCurrent(
150  RE_OGLContext context, QSurface *surface);
151 
152  RE_OGLContext myCurrentContext;
153 
154  RE_IDType myFocusWindow;
155 
156  /// The current main windows are all the toplevel application windows.
157  /// We keep track of them to find out what window we should use when
158  /// creating dialogs - windowing systems can decorate and treat dialog
159  /// windows differently if they know which window is the parent.
160  UT_Array<RE_Window *> myCurrentMainWindows;
161 
162  static int myMinXRes;
163  static int myMinYRes;
164 };
165 
166 
167 #endif
void * RE_IDType
Definition: RE_IDType.h:20
#define RE_API
Definition: RE_API.h:10
static int getDragTolY()
Definition: RE_Server.h:73
GLint y
Definition: glcorearb.h:103
static fpreal64 getDragDelay()
Definition: RE_Server.h:74
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
double fpreal64
Definition: SYS_Types.h:201
RE_IDType getFocusWindow() const
Definition: RE_Server.h:40
static int getDragTolX()
Definition: RE_Server.h:72
#define SYS_NO_DISCARD_RESULT
Definition: SYS_Compiler.h:93
RE_DisplayMode
Definition: RE_Types.h:573
GLint GLenum GLint x
Definition: glcorearb.h:409
GLenum mode
Definition: glcorearb.h:99
GLuint color
Definition: glcorearb.h:1261
fpreal64 fpreal
Definition: SYS_Types.h:277
RE_VisualType
Definition: RE_Types.h:623
static int getMinYRes()
Definition: RE_Server.h:44
Definition: core.h:1131
RE_WindowType
Definition: RE_Types.h:20
QOpenGLContext * RE_OGLContext
Definition: RE_Types.h:941
type
Definition: core.h:1059
static int getMinXRes()
Definition: RE_Server.h:43