| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#if !defined( INCLUDED_XYWINDOW_H ) |
| 23 |
#define INCLUDED_XYWINDOW_H |
| 24 |
|
| 25 |
#include "math/matrix.h" |
| 26 |
#include "signal/signal.h" |
| 27 |
|
| 28 |
#include "gtkutil/cursor.h" |
| 29 |
#include "gtkutil/window.h" |
| 30 |
#include "gtkutil/xorrectangle.h" |
| 31 |
#include "view.h" |
| 32 |
#include "map.h" |
| 33 |
#include "texturelib.h" |
| 34 |
|
| 35 |
#include "qerplugin.h" |
| 36 |
|
| 37 |
class Shader; |
| 38 |
class SelectionSystemWindowObserver; |
| 39 |
namespace scene |
| 40 |
{ |
| 41 |
class Node; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
void FlipClip(); |
| 46 |
void SplitClip(); |
| 47 |
void Clip(); |
| 48 |
void OnClipMode( bool enabled ); |
| 49 |
bool ClipMode(); |
| 50 |
|
| 51 |
inline const char* ViewType_getTitle( VIEWTYPE viewtype ){ |
| 52 |
if ( viewtype == XY ) { |
| 53 |
return "XY Top"; |
| 54 |
} |
| 55 |
if ( viewtype == XZ ) { |
| 56 |
return "XZ Front"; |
| 57 |
} |
| 58 |
if ( viewtype == YZ ) { |
| 59 |
return "YZ Side"; |
| 60 |
} |
| 61 |
return ""; |
| 62 |
} |
| 63 |
|
| 64 |
class XYWnd |
| 65 |
{ |
| 66 |
ui::GLArea m_gl_widget; |
| 67 |
guint m_sizeHandler; |
| 68 |
guint m_exposeHandler; |
| 69 |
|
| 70 |
DeferredDraw m_deferredDraw; |
| 71 |
DeferredMotion m_deferred_motion; |
| 72 |
public: |
| 73 |
ui::Window m_parent; |
| 74 |
XYWnd(); |
| 75 |
~XYWnd(); |
| 76 |
|
| 77 |
void queueDraw(){ |
| 78 |
m_deferredDraw.draw(); |
| 79 |
} |
| 80 |
ui::GLArea GetWidget(){ |
| 81 |
return m_gl_widget; |
| 82 |
} |
| 83 |
|
| 84 |
public: |
| 85 |
SelectionSystemWindowObserver* m_window_observer; |
| 86 |
XORRectangle m_XORRectangle; |
| 87 |
WindowPositionTracker m_positionTracker; |
| 88 |
|
| 89 |
static void captureStates(); |
| 90 |
static void releaseStates(); |
| 91 |
|
| 92 |
void PositionView( const Vector3& position ); |
| 93 |
const Vector3& GetOrigin(); |
| 94 |
void SetOrigin( const Vector3& origin ); |
| 95 |
void Scroll( int x, int y ); |
| 96 |
|
| 97 |
void XY_Draw(); |
| 98 |
void DrawCameraIcon( const Vector3& origin, const Vector3& angles ); |
| 99 |
void XY_DrawBlockGrid(); |
| 100 |
void XY_DrawAxis(); |
| 101 |
void XY_DrawGrid(); |
| 102 |
void XY_DrawBackground(); |
| 103 |
void XY_LoadBackgroundImage( const char *name ); |
| 104 |
void XY_DisableBackground(); |
| 105 |
|
| 106 |
void XY_MouseUp( int x, int y, unsigned int buttons ); |
| 107 |
void XY_MouseDown( int x, int y, unsigned int buttons ); |
| 108 |
void XY_MouseMoved( int x, int y, unsigned int buttons ); |
| 109 |
|
| 110 |
void NewBrushDrag_Begin( int x, int y ); |
| 111 |
void NewBrushDrag( int x, int y ); |
| 112 |
void NewBrushDrag_End( int x, int y ); |
| 113 |
|
| 114 |
void XY_ToPoint( int x, int y, Vector3& point ); |
| 115 |
void XY_SnapToGrid( Vector3& point ); |
| 116 |
|
| 117 |
void Move_Begin(); |
| 118 |
void Move_End(); |
| 119 |
bool m_move_started; |
| 120 |
guint m_move_focusOut; |
| 121 |
|
| 122 |
void Zoom_Begin( int x, int y ); |
| 123 |
void Zoom_End(); |
| 124 |
bool m_zoom_started; |
| 125 |
guint m_zoom_focusOut; |
| 126 |
|
| 127 |
void ZoomIn(); |
| 128 |
void ZoomOut(); |
| 129 |
void ZoomInWithMouse( int pointx, int pointy ); |
| 130 |
void FocusOnBounds( AABB& bounds ); |
| 131 |
|
| 132 |
void Redraw(); |
| 133 |
|
| 134 |
void RenderActive(); |
| 135 |
|
| 136 |
void SetActive( bool b ){ |
| 137 |
m_bActive = b; |
| 138 |
RenderActive(); |
| 139 |
}; |
| 140 |
bool Active(){ |
| 141 |
return m_bActive; |
| 142 |
}; |
| 143 |
struct camera_icon_t |
| 144 |
{ |
| 145 |
float x, y, fov, box; |
| 146 |
double a; |
| 147 |
}; |
| 148 |
camera_icon_t Cam; |
| 149 |
void UpdateCameraIcon(); |
| 150 |
|
| 151 |
|
| 152 |
void Clipper_OnLButtonDown( int x, int y ); |
| 153 |
void Clipper_OnLButtonUp( int x, int y ); |
| 154 |
void Clipper_OnMouseMoved( int x, int y ); |
| 155 |
void Clipper_Crosshair_OnMouseMoved( int x, int y ); |
| 156 |
void DropClipPoint( int pointx, int pointy ); |
| 157 |
|
| 158 |
void SetCustomPivotOrigin( int pointx, int pointy ); |
| 159 |
|
| 160 |
void SetViewType( VIEWTYPE n ); |
| 161 |
bool m_bActive; |
| 162 |
|
| 163 |
static ui::Menu m_mnuDrop; |
| 164 |
|
| 165 |
int m_chasemouse_current_x, m_chasemouse_current_y; |
| 166 |
int m_chasemouse_delta_x, m_chasemouse_delta_y; |
| 167 |
|
| 168 |
|
| 169 |
guint m_chasemouse_handler; |
| 170 |
void ChaseMouse(); |
| 171 |
bool chaseMouseMotion( int pointx, int pointy ); |
| 172 |
|
| 173 |
void updateModelview(bool reconstruct = true); |
| 174 |
void updateProjection(bool reconstruct = true); |
| 175 |
Matrix4 m_projection; |
| 176 |
Matrix4 m_modelview; |
| 177 |
|
| 178 |
int m_nWidth; |
| 179 |
int m_nHeight; |
| 180 |
|
| 181 |
qtexture_t *m_tex; |
| 182 |
bool m_backgroundActivated; |
| 183 |
float m_alpha; |
| 184 |
float m_xmin, m_ymin, m_xmax, m_ymax; |
| 185 |
private: |
| 186 |
float m_fScale; |
| 187 |
Vector3 m_vOrigin; |
| 188 |
|
| 189 |
|
| 190 |
View m_view; |
| 191 |
static Shader* m_state_selected; |
| 192 |
|
| 193 |
int m_ptCursorX, m_ptCursorY; |
| 194 |
|
| 195 |
unsigned int m_buttonstate; |
| 196 |
|
| 197 |
int m_nNewBrushPressx; |
| 198 |
int m_nNewBrushPressy; |
| 199 |
scene::Node* m_NewBrushDrag; |
| 200 |
bool m_bNewBrushDrag; |
| 201 |
|
| 202 |
Vector3 m_mousePosition; |
| 203 |
|
| 204 |
VIEWTYPE m_viewType; |
| 205 |
|
| 206 |
void OriginalButtonUp( guint32 nFlags, int point, int pointy ); |
| 207 |
void OriginalButtonDown( guint32 nFlags, int point, int pointy ); |
| 208 |
|
| 209 |
void OnContextMenu(); |
| 210 |
void PaintSizeInfo( int nDim1, int nDim2, Vector3& vMinBounds, Vector3& vMaxBounds ); |
| 211 |
|
| 212 |
int m_entityCreate_x, m_entityCreate_y; |
| 213 |
bool m_entityCreate; |
| 214 |
|
| 215 |
public: |
| 216 |
void ButtonState_onMouseDown( unsigned int buttons ){ |
| 217 |
|
| 218 |
m_buttonstate = buttons; |
| 219 |
} |
| 220 |
void ButtonState_onMouseUp( unsigned int buttons ){ |
| 221 |
|
| 222 |
m_buttonstate = 0; |
| 223 |
} |
| 224 |
unsigned int getButtonState() const { |
| 225 |
return m_buttonstate; |
| 226 |
} |
| 227 |
void EntityCreate_MouseDown( int x, int y ); |
| 228 |
void EntityCreate_MouseMove( int x, int y ); |
| 229 |
void EntityCreate_MouseUp( int x, int y ); |
| 230 |
|
| 231 |
void OnEntityCreate( const char* item ); |
| 232 |
VIEWTYPE GetViewType(){ |
| 233 |
return m_viewType; |
| 234 |
} |
| 235 |
void SetScale( float f ); |
| 236 |
float Scale(){ |
| 237 |
return m_fScale; |
| 238 |
} |
| 239 |
int Width(){ |
| 240 |
return m_nWidth; |
| 241 |
} |
| 242 |
int Height(){ |
| 243 |
return m_nHeight; |
| 244 |
} |
| 245 |
|
| 246 |
Signal0 onDestroyed; |
| 247 |
Signal3<const WindowVector&, ButtonIdentifier, ModifierFlags> onMouseDown; |
| 248 |
void mouseDown( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers ); |
| 249 |
typedef Member<XYWnd, void(const WindowVector&, ButtonIdentifier, ModifierFlags), &XYWnd::mouseDown> MouseDownCaller; |
| 250 |
}; |
| 251 |
|
| 252 |
inline void XYWnd_Update( XYWnd& xywnd ){ |
| 253 |
xywnd.queueDraw(); |
| 254 |
} |
| 255 |
|
| 256 |
void XY_Centralize(); |
| 257 |
|
| 258 |
struct xywindow_globals_t |
| 259 |
{ |
| 260 |
Vector3 color_gridback; |
| 261 |
Vector3 color_gridminor; |
| 262 |
Vector3 color_gridmajor; |
| 263 |
Vector3 color_gridblock; |
| 264 |
Vector3 color_gridtext; |
| 265 |
Vector3 color_brushes; |
| 266 |
Vector3 color_selbrushes; |
| 267 |
Vector3 color_clipper; |
| 268 |
Vector3 color_viewname; |
| 269 |
Vector3 color_gridminor_alt; |
| 270 |
Vector3 color_gridmajor_alt; |
| 271 |
Vector3 AxisColorX; |
| 272 |
Vector3 AxisColorY; |
| 273 |
Vector3 AxisColorZ; |
| 274 |
|
| 275 |
|
| 276 |
bool m_bNoStipple; |
| 277 |
bool m_bZoomInToPointer; |
| 278 |
|
| 279 |
xywindow_globals_t() : |
| 280 |
color_gridback( 0.77f, 0.77f, 0.77f ), |
| 281 |
color_gridminor( 0.83f, 0.83f, 0.83f ), |
| 282 |
color_gridmajor( 0.89f, 0.89f, 0.89f ), |
| 283 |
color_gridblock( 1.0f, 1.0f, 1.0f ), |
| 284 |
color_gridtext( 0.f, 0.f, 0.f ), |
| 285 |
color_brushes( 0.f, 0.f, 0.f ), |
| 286 |
color_selbrushes( 1.f, 0.f, 0.f ), |
| 287 |
color_clipper( 0.f, 0.f, 1.f ), |
| 288 |
color_viewname( 0.5f, 0.f, 0.75f ), |
| 289 |
color_gridminor_alt( 0.f, 0.f, 0.f ), |
| 290 |
color_gridmajor_alt( 0.f, 0.f, 0.f ), |
| 291 |
|
| 292 |
AxisColorX( 1.f, 0.f, 0.f ), |
| 293 |
AxisColorY( 0.f, 1.f, 0.f ), |
| 294 |
AxisColorZ( 0.f, 0.f, 1.f ), |
| 295 |
|
| 296 |
m_bNoStipple( true ), |
| 297 |
m_bZoomInToPointer( true ){ |
| 298 |
} |
| 299 |
|
| 300 |
}; |
| 301 |
|
| 302 |
extern xywindow_globals_t g_xywindow_globals; |
| 303 |
|
| 304 |
|
| 305 |
VIEWTYPE GlobalXYWnd_getCurrentViewType(); |
| 306 |
|
| 307 |
void XY_Top_Shown_Construct( ui::Window parent ); |
| 308 |
void YZ_Side_Shown_Construct( ui::Window parent ); |
| 309 |
void XZ_Front_Shown_Construct( ui::Window parent ); |
| 310 |
|
| 311 |
void XYWindow_Construct(); |
| 312 |
void XYWindow_Destroy(); |
| 313 |
|
| 314 |
void WXY_Print(); |
| 315 |
void WXY_BackgroundSelect(); |
| 316 |
|
| 317 |
void XYShow_registerCommands(); |
| 318 |
void XYWnd_registerShortcuts(); |
| 319 |
|
| 320 |
#endif |