HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  bool getColorUnderCursor(float color[3]) const;
49 
50  bool GLMakeCurrent( OGLDrawable draw, RE_OGLContext context,
51  bool ignore_errors);
52 #if defined(USE_QT5)
53  RE_OGLContext GLCurrentContext() const;
54 #endif
55  int GLMakeCopyCurrent( OGLDrawable draw,
56  RE_OGLContext sourceContext,
57  RE_OGLContext targetContext );
58 
59  bool GLSwapBuffers(RE_Window *currentWindow);
60  OGLDrawable GLGetCurrentDrawable();
61  void GLWaitGL();
62 
63  // provide some reasonable defaults
64  static int getDragTolX() { return 4; }
65  static int getDragTolY() { return 4; }
66  static fpreal64 getDragDelay() { return 0.75; }
67 
68  /// @{
69  /// Desktop support.
70  static int primaryScreenNum();
71  static int numScreens();
72  static int screenContaining(int x, int y, bool native=false);
73  static const UT_DimRect &screenArea(int screen_num);
74  static const UT_DimRect &nativeScreenArea(int screen_num);
75  static const UT_DimRect &workArea(int screen_num);
76  static const UT_DimRect &nativeWorkArea(int screen_num);
77 #if defined(USE_QT5)
78  static const UT_DimRect &displayScreenArea(int screen_num);
79  static const UT_DimRect &displayWorkArea(int screen_num);
80 #endif
81  static fpreal screenToDeviceScale(int screen_num);
82  static const UT_DimRect &virtualScreenArea();
83  static const UT_DimRect &virtualWorkArea();
84  /// @}
85 
86  /// @{
87  /// Convert from native coordinates to scaled Houdini UI coordinates
88  /// and vice versa. You can optionally pass in a screen hint indicating
89  /// which screen should be queried for the scale factor when scaling the
90  /// coordinates.
91  /// @}
92  static void toScreenCoords(int &x, int &y, int screen=-1);
93  static void fromScreenCoords(int &x, int &y, int screen=-1);
94 
95  /// Add a window to the list of current main windows. If it is already in
96  /// the list, it will not be added again.
97  void addCurrentMainWindow(RE_Window *win);
98 
99  /// Remove a window from the list of current main windows.
100  void removeCurrentMainWindow(RE_Window *win);
101 
102  /// Find the current main window that's focused, so you can attach
103  /// dialog windows to it. If none is marked as focused, just returns
104  /// the first window.
105  RE_Window *getCurrentMainWindow() const;
106 
107  /// Find the first current main window, regardless of whether it's focused.
108  /// Used on Windows to ensure that all subwindows are made tool windows of
109  /// at least the main Houdini window.
110  RE_Window *getFirstCurrentMainWindow() const;
111 
112  /// Creates a new RE_Window, ready to be opened.
113  RE_Window *newWindow(RE_DisplayMode mode,
115  RE_VisualType visType=RE_NORMAL_VIS);
116 
117  /// Returns current render context matching the mode passed in. All render
118  /// contexts are tied to a specific drawable. This may return NULL if
119  /// there are no render contexts currently created that match mode.
120  RE_Render *getContextMatching(RE_DisplayMode mode) const;
121 
122  /// Return whether the Qt objects are valid or not.
123  /// Qt objects are not valid when the Qt main event loop has exited.
124  static bool isAppExiting();
125 
126  /// This method should only be called when the Qt main event loop has
127  /// exited. It lets RE know that it is no longer safe to work with any Qt
128  /// objects.
129  static void setAppExiting();
130 
131 private:
132 #if defined(USE_QT5)
133  RE_OGLContext myCurrentContext;
134 #endif
135 
136  RE_IDType myFocusWindow;
137 
138  /// The current main windows are all the toplevel application windows.
139  /// We keep track of them to find out what window we should use when
140  /// creating dialogs - windowing systems can decorate and treat dialog
141  /// windows differently if they know which window is the parent.
142  UT_Array<RE_Window *> myCurrentMainWindows;
143 
144  static int myMinXRes;
145  static int myMinYRes;
146 };
147 
148 
149 #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:65
GLint y
Definition: glcorearb.h:102
static fpreal64 getDragDelay()
Definition: RE_Server.h:66
void * RE_OGLContext
Definition: RE_Types.h:865
RE_IDType getFocusWindow() const
Definition: RE_Server.h:35
static int getDragTolX()
Definition: RE_Server.h:64
double fpreal64
Definition: SYS_Types.h:185
RE_DisplayMode
Definition: RE_Types.h:533
GLenum mode
Definition: glcorearb.h:98
double fpreal
Definition: SYS_Types.h:263
GLint GLenum GLint x
Definition: glcorearb.h:408
RE_VisualType
Definition: RE_Types.h:583
static int getMinYRes()
Definition: RE_Server.h:39
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
QGLWidget * OGLDrawable
Definition: RE_Types.h:872
RE_WindowType
Definition: RE_Types.h:20
static int getMinXRes()
Definition: RE_Server.h:38