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 class RE_Window;
23 class RE_Render;
24 
26 {
27 public:
28  RE_Server();
29  ~RE_Server();
30 
31  bool initServer();
32 
33  void flush() const;
34 
35  RE_IDType getFocusWindow() const { return myFocusWindow; }
36  void setFocusWindow(RE_IDType wid);
37 
38  static int getMinXRes() { return myMinXRes; }
39  static int getMinYRes() { return myMinYRes; }
40  bool meetsMinRes( ) const;
41 
42  /// Determine if the given window (and not a child window) is currently
43  /// under the mouse.
44  /// The current x,y mouse coordinates are optional under
45  /// certain platforms
46  bool windowUnderCursor(RE_IDType wid, int x, int y) const;
47 
48  /// Return the id of the Houdini window that appears immediately
49  /// underneath the mouse cursor. Return 0/nullptr if there is no Houdini
50  /// window immediately underneath the mouse cursor.
51  static RE_IDType windowUnderCursor();
52 
53  bool getColorUnderCursor(float color[3]) const;
54 
55  bool GLMakeCurrent( OGLDrawable draw, RE_OGLContext context,
56  bool ignore_errors);
57  RE_OGLContext GLCurrentContext() const;
58  int GLMakeCopyCurrent( OGLDrawable draw,
59  RE_OGLContext sourceContext,
60  RE_OGLContext targetContext );
61 
62  bool GLSwapBuffers(RE_Window *currentWindow);
63  OGLDrawable GLGetCurrentDrawable();
64  void GLWaitGL();
65 
66  // provide some reasonable defaults
67  static int getDragTolX() { return 4; }
68  static int getDragTolY() { return 4; }
69  static fpreal64 getDragDelay() { return 0.75; }
70 
71  /// @{
72  /// Desktop support.
73  static int primaryScreenNum();
74  static int numScreens();
75  static int screenContaining(int x, int y, bool native=false);
76  static const UT_DimRect &screenArea(int screen_num);
77  static const UT_DimRect &nativeScreenArea(int screen_num);
78  static const UT_DimRect &workArea(int screen_num);
79  static const UT_DimRect &nativeWorkArea(int screen_num);
80  static const UT_DimRect &displayScreenArea(int screen_num);
81  static const UT_DimRect &displayWorkArea(int screen_num);
82  static fpreal screenToDeviceScale(int screen_num);
83  static const UT_DimRect &virtualScreenArea();
84  static const UT_DimRect &virtualWorkArea();
85  /// @}
86 
87  /// @{
88  /// Convert from native coordinates to scaled Houdini UI coordinates
89  /// and vice versa.
90  /// @}
91  static void toScreenCoords(int &x, int &y);
92  static void fromScreenCoords(int &x, int &y);
93 
94  /// @{
95  /// Convert from a value that is scaled in Houdini UI space
96  /// to a value that is scaled in screen space and vice versa.
97  /// }@
98  ///
99  static void toScreenScale(int screen, int &value);
100  static void fromScreenScale(int screen, int &value);
101 
102  /// Add a window to the list of current main windows. If it is already in
103  /// the list, it will not be added again.
104  void addCurrentMainWindow(RE_Window *win);
105 
106  /// Remove a window from the list of current main windows.
107  void removeCurrentMainWindow(RE_Window *win);
108 
109  /// Find the current main window that's focused, so you can attach
110  /// dialog windows to it. If none is marked as focused, just returns
111  /// the first window.
112  RE_Window *getCurrentMainWindow() const;
113 
114  /// Find the first current main window, regardless of whether it's focused.
115  /// Used on Windows to ensure that all subwindows are made tool windows of
116  /// at least the main Houdini window.
117  RE_Window *getFirstCurrentMainWindow() const;
118 
119  /// Creates a new RE_Window, ready to be opened.
120  RE_Window *newWindow(RE_DisplayMode mode,
122  RE_VisualType visType=RE_NORMAL_VIS);
123 
124  /// Returns current render context matching the mode passed in. All render
125  /// contexts are tied to a specific drawable. This may return NULL if
126  /// there are no render contexts currently created that match mode.
127  RE_Render *getContextMatching(RE_DisplayMode mode) const;
128 
129  /// Return whether the Qt objects are valid or not.
130  /// Qt objects are not valid when the Qt main event loop has exited.
131  static bool isAppExiting();
132 
133  /// This method should only be called when the Qt main event loop has
134  /// exited. It lets RE know that it is no longer safe to work with any Qt
135  /// objects.
136  static void setAppExiting();
137 
138 private:
139  RE_OGLContext myCurrentContext;
140 
141  RE_IDType myFocusWindow;
142 
143  /// The current main windows are all the toplevel application windows.
144  /// We keep track of them to find out what window we should use when
145  /// creating dialogs - windowing systems can decorate and treat dialog
146  /// windows differently if they know which window is the parent.
147  UT_Array<RE_Window *> myCurrentMainWindows;
148 
149  static int myMinXRes;
150  static int myMinYRes;
151 };
152 
153 
154 #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:68
GLint y
Definition: glcorearb.h:102
static fpreal64 getDragDelay()
Definition: RE_Server.h:69
RE_IDType getFocusWindow() const
Definition: RE_Server.h:35
static int getDragTolX()
Definition: RE_Server.h:67
double fpreal64
Definition: SYS_Types.h:192
RE_DisplayMode
Definition: RE_Types.h:536
GLenum mode
Definition: glcorearb.h:98
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:270
GLint GLenum GLint x
Definition: glcorearb.h:408
RE_VisualType
Definition: RE_Types.h:586
static int getMinYRes()
Definition: RE_Server.h:39
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
RE_WindowType
Definition: RE_Types.h:20
QOpenGLContext * RE_OGLContext
Definition: RE_Types.h:891
static int getMinXRes()
Definition: RE_Server.h:38