2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 // Leonardo Zide (leo@lokigames.com)
30 #include "debugging/debugging.h"
37 #include "ifilesystem.h"
40 #include "gtkutil/messagebox.h"
42 #include <gtk/gtklabel.h>
43 #include <gtk/gtkmenuitem.h>
45 #include "generic/callback.h"
46 #include "string/string.h"
47 #include "stream/stringstream.h"
50 #include "eclasslib.h"
52 #include "moduleobserver.h"
54 #include "gtkutil/menu.h"
55 #include "gtkutil/container.h"
56 #include "gtkutil/widget.h"
57 #include "gtkutil/glwidget.h"
58 #include "gtkutil/filechooser.h"
62 #include "brushmanip.h"
63 #include "selection.h"
65 #include "camwindow.h"
66 #include "texwindow.h"
67 #include "mainframe.h"
68 #include "preferences.h"
72 #include "windowobservers.h"
74 void LoadTextureRGBA( qtexture_t* q, unsigned char* pPixels, int nWidth, int nHeight );
77 extern bool g_brush_always_caulk;
83 Vector3 m_ptClip; // the 3d point
90 m_ptClip[0] = m_ptClip[1] = m_ptClip[2] = 0.0;
104 /*! Draw clip/path point with rasterized number label */
105 void Draw( int num, float scale );
106 /*! Draw clip/path point with rasterized string label */
107 void Draw( const char *label, float scale );
110 VIEWTYPE g_clip_viewtype;
111 bool g_bSwitch = true;
112 bool g_clip_useCaulk = false;
113 bool g_quick_clipper = false;
117 ClipPoint* g_pMovingClip = 0;
119 /* Drawing clip points */
120 void ClipPoint::Draw( int num, float scale ){
121 StringOutputStream label( 4 );
123 Draw( label.c_str(), scale );
126 void ClipPoint::Draw( const char *label, float scale ){
129 glColor3fv( vector3_to_array( g_xywindow_globals.color_clipper ) );
130 glBegin( GL_POINTS );
131 glVertex3fv( vector3_to_array( m_ptClip ) );
135 float offset = 2.0f / scale;
138 glRasterPos3f( m_ptClip[0] + offset, m_ptClip[1] + offset, m_ptClip[2] + offset );
139 //glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, label ); //fails with GCC
140 //glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, reinterpret_cast<const GLubyte*>( label ) ); //worx
141 GlobalOpenGL().drawString( label );
144 float fDiff( float f1, float f2 ){
153 inline double ClipPoint_Intersect( const ClipPoint& clip, const Vector3& point, VIEWTYPE viewtype, float scale ){
154 int nDim1 = ( viewtype == YZ ) ? 1 : 0;
155 int nDim2 = ( viewtype == XY ) ? 1 : 2;
156 double screenDistanceSquared( vector2_length_squared( Vector2( fDiff( clip.m_ptClip[nDim1], point[nDim1] ) * scale, fDiff( clip.m_ptClip[nDim2], point[nDim2] ) * scale ) ) );
157 if ( screenDistanceSquared < 8 * 8 ) {
158 return screenDistanceSquared;
163 inline void ClipPoint_testSelect( ClipPoint& clip, const Vector3& point, VIEWTYPE viewtype, float scale, double& bestDistance, ClipPoint*& bestClip ){
165 double distance = ClipPoint_Intersect( clip, point, viewtype, scale );
166 if ( distance < bestDistance ) {
167 bestDistance = distance;
173 inline ClipPoint* GlobalClipPoints_Find( const Vector3& point, VIEWTYPE viewtype, float scale ){
174 double bestDistance = FLT_MAX;
175 ClipPoint* bestClip = 0;
176 ClipPoint_testSelect( g_Clip1, point, viewtype, scale, bestDistance, bestClip );
177 ClipPoint_testSelect( g_Clip2, point, viewtype, scale, bestDistance, bestClip );
178 ClipPoint_testSelect( g_Clip3, point, viewtype, scale, bestDistance, bestClip );
182 inline void GlobalClipPoints_Draw( float scale ){
184 if ( g_Clip1.Set() ) {
185 g_Clip1.Draw( 1, scale );
187 if ( g_Clip2.Set() ) {
188 g_Clip2.Draw( 2, scale );
190 if ( g_Clip3.Set() ) {
191 g_Clip3.Draw( 3, scale );
195 inline bool GlobalClipPoints_valid(){
196 return g_Clip1.Set() && g_Clip2.Set();
199 void PlanePointsFromClipPoints( Vector3 planepts[3], const AABB& bounds, int viewtype ){
200 ASSERT_MESSAGE( GlobalClipPoints_valid(), "clipper points not initialised" );
201 planepts[0] = g_Clip1.m_ptClip;
202 planepts[1] = g_Clip2.m_ptClip;
203 planepts[2] = g_Clip3.m_ptClip;
204 Vector3 maxs( vector3_added( bounds.origin, bounds.extents ) );
205 Vector3 mins( vector3_subtracted( bounds.origin, bounds.extents ) );
206 if ( !g_Clip3.Set() ) {
207 int n = ( viewtype == XY ) ? 2 : ( viewtype == YZ ) ? 0 : 1;
208 int x = ( n == 0 ) ? 1 : 0;
209 int y = ( n == 2 ) ? 1 : 2;
211 if ( n == 1 ) { // on viewtype XZ, flip clip points
212 planepts[0][n] = maxs[n];
213 planepts[1][n] = maxs[n];
214 planepts[2][x] = g_Clip1.m_ptClip[x];
215 planepts[2][y] = g_Clip1.m_ptClip[y];
216 planepts[2][n] = mins[n];
220 planepts[0][n] = mins[n];
221 planepts[1][n] = mins[n];
222 planepts[2][x] = g_Clip1.m_ptClip[x];
223 planepts[2][y] = g_Clip1.m_ptClip[y];
224 planepts[2][n] = maxs[n];
231 if ( !GlobalClipPoints_valid() ) {
232 planepts[0] = Vector3( 0, 0, 0 );
233 planepts[1] = Vector3( 0, 0, 0 );
234 planepts[2] = Vector3( 0, 0, 0 );
235 Scene_BrushSetClipPlane( GlobalSceneGraph(), Plane3( 0, 0, 0, 0 ) );
239 AABB bounds( Vector3( 0, 0, 0 ), Vector3( 64, 64, 64 ) );
240 PlanePointsFromClipPoints( planepts, bounds, g_clip_viewtype );
242 std::swap( planepts[0], planepts[1] );
244 Scene_BrushSetClipPlane( GlobalSceneGraph(), plane3_for_points( planepts[0], planepts[1], planepts[2] ) );
246 ClipperChangeNotify();
249 const char* Clip_getShader(){
250 return g_clip_useCaulk ? "textures/common/caulk" : TextureBrowser_GetSelectedShader( GlobalTextureBrowser() );
254 if ( ClipMode() && GlobalClipPoints_valid() ) {
256 AABB bounds( Vector3( 0, 0, 0 ), Vector3( 64, 64, 64 ) );
257 PlanePointsFromClipPoints( planepts, bounds, g_clip_viewtype );
258 Scene_BrushSplitByPlane( GlobalSceneGraph(), planepts[0], planepts[1], planepts[2], Clip_getShader(), ( !g_bSwitch ) ? eFront : eBack );
263 ClipperChangeNotify();
264 if( g_quick_clipper ){
265 g_quick_clipper = false;
272 if ( ClipMode() && GlobalClipPoints_valid() ) {
274 AABB bounds( Vector3( 0, 0, 0 ), Vector3( 64, 64, 64 ) );
275 PlanePointsFromClipPoints( planepts, bounds, g_clip_viewtype );
276 Scene_BrushSplitByPlane( GlobalSceneGraph(), planepts[0], planepts[1], planepts[2], Clip_getShader(), eFrontAndBack );
281 ClipperChangeNotify();
282 if( g_quick_clipper ){
283 g_quick_clipper = false;
290 g_bSwitch = !g_bSwitch;
292 ClipperChangeNotify();
295 void OnClipMode( bool enabled ){
300 if ( !enabled && g_pMovingClip ) {
305 ClipperChangeNotify();
309 return GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eClip;
312 void NewClipPoint( const Vector3& point ){
313 if ( g_Clip1.Set() == false ) {
314 g_Clip1.m_ptClip = point;
317 else if ( g_Clip2.Set() == false ) {
318 g_Clip2.m_ptClip = point;
321 else if ( g_Clip3.Set() == false ) {
322 g_Clip3.m_ptClip = point;
330 g_Clip1.m_ptClip = point;
335 ClipperChangeNotify();
340 struct xywindow_globals_private_t
344 // these are in the View > Show menu with Show coordinates
346 bool show_coordinates;
356 // bool m_bCamXYUpdate;
360 xywindow_globals_private_t() :
364 show_coordinates( false ),
366 show_outline( true ),
369 d_show_work( false ),
371 show_blocks( false ),
373 // m_bCamXYUpdate( true ),
374 m_bChaseMouse( true ),
375 m_bSizePaint( true ){
380 xywindow_globals_t g_xywindow_globals;
381 xywindow_globals_private_t g_xywindow_globals_private;
383 const unsigned int RAD_NONE = 0x00;
384 const unsigned int RAD_SHIFT = 0x01;
385 const unsigned int RAD_ALT = 0x02;
386 const unsigned int RAD_CONTROL = 0x04;
387 const unsigned int RAD_PRESS = 0x08;
388 const unsigned int RAD_LBUTTON = 0x10;
389 const unsigned int RAD_MBUTTON = 0x20;
390 const unsigned int RAD_RBUTTON = 0x40;
392 inline ButtonIdentifier button_for_flags( unsigned int flags ){
393 if ( flags & RAD_LBUTTON ) {
396 if ( flags & RAD_RBUTTON ) {
397 return c_buttonRight;
399 if ( flags & RAD_MBUTTON ) {
400 return c_buttonMiddle;
402 return c_buttonInvalid;
405 inline ModifierFlags modifiers_for_flags( unsigned int flags ){
406 ModifierFlags modifiers = c_modifierNone;
407 if ( flags & RAD_SHIFT ) {
408 modifiers |= c_modifierShift;
410 if ( flags & RAD_CONTROL ) {
411 modifiers |= c_modifierControl;
413 if ( flags & RAD_ALT ) {
414 modifiers |= c_modifierAlt;
419 inline unsigned int buttons_for_button_and_modifiers( ButtonIdentifier button, ModifierFlags flags ){
420 unsigned int buttons = 0;
422 switch ( button.get() )
424 case ButtonEnumeration::LEFT: buttons |= RAD_LBUTTON; break;
425 case ButtonEnumeration::MIDDLE: buttons |= RAD_MBUTTON; break;
426 case ButtonEnumeration::RIGHT: buttons |= RAD_RBUTTON; break;
429 if ( bitfield_enabled( flags, c_modifierControl ) ) {
430 buttons |= RAD_CONTROL;
433 if ( bitfield_enabled( flags, c_modifierShift ) ) {
434 buttons |= RAD_SHIFT;
437 if ( bitfield_enabled( flags, c_modifierAlt ) ) {
444 inline unsigned int buttons_for_event_button( GdkEventButton* event ){
445 unsigned int flags = 0;
447 switch ( event->button )
449 case 1: flags |= RAD_LBUTTON; break;
450 case 2: flags |= RAD_MBUTTON; break;
451 case 3: flags |= RAD_RBUTTON; break;
454 if ( ( event->state & GDK_CONTROL_MASK ) != 0 ) {
455 flags |= RAD_CONTROL;
458 if ( ( event->state & GDK_SHIFT_MASK ) != 0 ) {
462 if ( ( event->state & GDK_MOD1_MASK ) != 0 ) {
469 inline unsigned int buttons_for_state( guint state ){
470 unsigned int flags = 0;
472 if ( ( state & GDK_BUTTON1_MASK ) != 0 ) {
473 flags |= RAD_LBUTTON;
476 if ( ( state & GDK_BUTTON2_MASK ) != 0 ) {
477 flags |= RAD_MBUTTON;
480 if ( ( state & GDK_BUTTON3_MASK ) != 0 ) {
481 flags |= RAD_RBUTTON;
484 if ( ( state & GDK_CONTROL_MASK ) != 0 ) {
485 flags |= RAD_CONTROL;
488 if ( ( state & GDK_SHIFT_MASK ) != 0 ) {
492 if ( ( state & GDK_MOD1_MASK ) != 0 ) {
500 void XYWnd::SetScale( float f ){
504 XYWnd_Update( *this );
507 void XYWnd::ZoomIn(){
508 float max_scale = 64;
509 float scale = Scale() * 5.0f / 4.0f;
510 if ( scale > max_scale ) {
511 if ( Scale() != max_scale ) {
512 SetScale( max_scale );
522 // NOTE: the zoom out factor is 4/5, we could think about customizing it
523 // we don't go below a zoom factor corresponding to 10% of the max world size
524 // (this has to be computed against the window size)
525 void XYWnd::ZoomOut(){
526 float min_scale = MIN( Width(), Height() ) / ( 1.1f * ( g_MaxWorldCoord - g_MinWorldCoord ) );
527 float scale = Scale() * 4.0f / 5.0f;
528 if ( scale < min_scale ) {
529 if ( Scale() != min_scale ) {
530 SetScale( min_scale );
539 void XYWnd::ZoomInWithMouse( int pointx, int pointy ){
540 float old_scale = Scale();
542 if ( g_xywindow_globals.m_bZoomInToPointer ) {
543 float scale_diff = 1.0 / old_scale - 1.0 / Scale();
544 int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
545 int nDim2 = ( m_viewType == XY ) ? 1 : 2;
546 Vector3 origin = GetOrigin();
547 origin[nDim1] += scale_diff * (pointx - 0.5 * Width());
548 origin[nDim2] -= scale_diff * (pointy - 0.5 * Height());
553 VIEWTYPE GlobalXYWnd_getCurrentViewType(){
554 ASSERT_NOTNULL( g_pParentWnd );
555 ASSERT_NOTNULL( g_pParentWnd->ActiveXY() );
556 return g_pParentWnd->ActiveXY()->GetViewType();
559 // =============================================================================
562 bool g_bCrossHairs = false;
564 GtkMenu* XYWnd::m_mnuDrop = 0;
566 // this is disabled, and broken
567 // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394
571 width = g_pParentWnd->ActiveXY()->Width();
572 height = g_pParentWnd->ActiveXY()->Height();
574 const char* filename;
576 filename = file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, "Save Image", 0, FILTER_BMP );
581 g_pParentWnd->ActiveXY()->MakeCurrent();
582 img = (unsigned char*)malloc( width * height * 3 );
583 glReadPixels( 0,0,width,height,GL_RGB,GL_UNSIGNED_BYTE,img );
586 fp = fopen( filename, "wb" );
589 unsigned long cmap, bfSize;
593 bfSize = 54 + width * height * 3;
595 long byteswritten = 0;
596 long pixoff = 54 + cmap * 4;
598 char m1 = 'B', m2 = 'M';
599 fwrite( &m1, 1, 1, fp ); byteswritten++; // B
600 fwrite( &m2, 1, 1, fp ); byteswritten++; // M
601 fwrite( &bfSize, 4, 1, fp ); byteswritten += 4; // bfSize
602 fwrite( &res, 2, 1, fp ); byteswritten += 2; // bfReserved1
603 fwrite( &res, 2, 1, fp ); byteswritten += 2; // bfReserved2
604 fwrite( &pixoff, 4, 1, fp ); byteswritten += 4; // bfOffBits
606 unsigned long biSize = 40, compress = 0, size = 0;
608 unsigned short planes = 1;
609 fwrite( &biSize, 4, 1, fp ); byteswritten += 4; // biSize
610 fwrite( &width, 4, 1, fp ); byteswritten += 4; // biWidth
611 fwrite( &height, 4, 1, fp ); byteswritten += 4; // biHeight
612 fwrite( &planes, 2, 1, fp ); byteswritten += 2; // biPlanes
613 fwrite( &bits, 2, 1, fp ); byteswritten += 2; // biBitCount
614 fwrite( &compress, 4, 1, fp ); byteswritten += 4; // biCompression
615 fwrite( &size, 4, 1, fp ); byteswritten += 4; // biSizeImage
616 fwrite( &pixels, 4, 1, fp ); byteswritten += 4; // biXPelsPerMeter
617 fwrite( &pixels, 4, 1, fp ); byteswritten += 4; // biYPelsPerMeter
618 fwrite( &cmap, 4, 1, fp ); byteswritten += 4; // biClrUsed
619 fwrite( &cmap, 4, 1, fp ); byteswritten += 4; // biClrImportant
621 unsigned long widthDW = ( ( ( width * 24 ) + 31 ) / 32 * 4 );
622 long row, row_size = width * 3;
623 for ( row = 0; row < height; row++ )
625 unsigned char* buf = img + row * row_size;
629 for ( col = 0; col < row_size; col += 3 )
631 putc( buf[col + 2], fp );
632 putc( buf[col + 1], fp );
633 putc( buf[col], fp );
635 byteswritten += row_size;
638 for ( count = row_size; count < widthDW; count++ )
640 putc( 0, fp ); // dummy
655 Timer g_chasemouse_timer;
657 void XYWnd::ChaseMouse(){
658 float multiplier = g_chasemouse_timer.elapsed_msec() / 10.0f;
659 Scroll( float_to_integer( multiplier * m_chasemouse_delta_x ), float_to_integer( multiplier * -m_chasemouse_delta_y ) );
661 //globalOutputStream() << "chasemouse: multiplier=" << multiplier << " x=" << m_chasemouse_delta_x << " y=" << m_chasemouse_delta_y << '\n';
663 XY_MouseMoved( m_chasemouse_current_x, m_chasemouse_current_y, getButtonState() );
664 g_chasemouse_timer.start();
667 gboolean xywnd_chasemouse( gpointer data ){
668 reinterpret_cast<XYWnd*>( data )->ChaseMouse();
672 inline const int& min_int( const int& left, const int& right ){
673 return std::min( left, right );
676 bool XYWnd::chaseMouseMotion( int pointx, int pointy ){
677 m_chasemouse_delta_x = 0;
678 m_chasemouse_delta_y = 0;
680 if ( g_xywindow_globals_private.m_bChaseMouse && getButtonState() == RAD_LBUTTON ) {
681 const int epsilon = 16;
683 if ( pointx < epsilon ) {
684 m_chasemouse_delta_x = std::max( pointx, 0 ) - epsilon;
686 else if ( ( pointx - m_nWidth ) > -epsilon ) {
687 m_chasemouse_delta_x = min_int( ( pointx - m_nWidth ), 0 ) + epsilon;
690 if ( pointy < epsilon ) {
691 m_chasemouse_delta_y = std::max( pointy, 0 ) - epsilon;
693 else if ( ( pointy - m_nHeight ) > -epsilon ) {
694 m_chasemouse_delta_y = min_int( ( pointy - m_nHeight ), 0 ) + epsilon;
697 if ( m_chasemouse_delta_y != 0 || m_chasemouse_delta_x != 0 ) {
698 //globalOutputStream() << "chasemouse motion: x=" << pointx << " y=" << pointy << "... ";
699 m_chasemouse_current_x = pointx;
700 m_chasemouse_current_y = pointy;
701 if ( m_chasemouse_handler == 0 ) {
702 //globalOutputStream() << "chasemouse timer start... ";
703 g_chasemouse_timer.start();
704 m_chasemouse_handler = g_idle_add( xywnd_chasemouse, this );
710 if ( m_chasemouse_handler != 0 ) {
711 //globalOutputStream() << "chasemouse cancel\n";
712 g_source_remove( m_chasemouse_handler );
713 m_chasemouse_handler = 0;
719 if ( m_chasemouse_handler != 0 ) {
720 //globalOutputStream() << "chasemouse cancel\n";
721 g_source_remove( m_chasemouse_handler );
722 m_chasemouse_handler = 0;
728 // =============================================================================
730 Shader* XYWnd::m_state_selected = 0;
732 void xy_update_xor_rectangle( XYWnd& self, rect_t area ){
733 if ( GTK_WIDGET_VISIBLE( self.GetWidget() ) ) {
734 rectangle_t rect = rectangle_from_area( area.min, area.max, self.Width(), self.Height() );
735 // int nDim1 = ( self.GetViewType() == YZ ) ? 1 : 0;
736 // int nDim2 = ( self.GetViewType() == XY ) ? 1 : 2;
737 // rect.x /= self.Scale();
738 // rect.y /= self.Scale();
739 // rect.w /= self.Scale();
740 // rect.h /= self.Scale();
741 // rect.x += self.GetOrigin()[nDim1];
742 // rect.y += self.GetOrigin()[nDim2];
743 self.m_XORRectangle.set( rect );
747 gboolean xywnd_button_press( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){
748 if ( event->type == GDK_BUTTON_PRESS ) {
749 gtk_widget_grab_focus( xywnd->GetWidget() );
751 if( !xywnd->Active() ){
752 g_pParentWnd->SetActiveXY( xywnd );
755 xywnd->ButtonState_onMouseDown( buttons_for_event_button( event ) );
757 xywnd->onMouseDown( WindowVector( event->x, event->y ), button_for_button( event->button ), modifiers_for_state( event->state ) );
762 gboolean xywnd_button_release( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){
763 if ( event->type == GDK_BUTTON_RELEASE ) {
764 xywnd->XY_MouseUp( static_cast<int>( event->x ), static_cast<int>( event->y ), buttons_for_event_button( event ) );
766 xywnd->ButtonState_onMouseUp( buttons_for_event_button( event ) );
771 gboolean xywnd_focus_in( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){
772 if ( event->type == GDK_FOCUS_CHANGE ) {
774 if( !xywnd->Active() ){
775 g_pParentWnd->SetActiveXY( xywnd );
782 void xywnd_motion( gdouble x, gdouble y, guint state, void* data ){
783 if ( reinterpret_cast<XYWnd*>( data )->chaseMouseMotion( static_cast<int>( x ), static_cast<int>( y ) ) ) {
786 reinterpret_cast<XYWnd*>( data )->XY_MouseMoved( static_cast<int>( x ), static_cast<int>( y ), buttons_for_state( state ) );
789 gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xywnd ){
790 gtk_widget_grab_focus( xywnd->GetWidget() );
791 GtkWindow* window = xywnd->m_parent != 0 ? xywnd->m_parent : MainFrame_getWindow();
792 if( !gtk_window_is_active( window ) )
793 gtk_window_present( window );
795 if( !xywnd->Active() ){
796 g_pParentWnd->SetActiveXY( xywnd );
798 if ( event->direction == GDK_SCROLL_UP ) {
799 xywnd->ZoomInWithMouse( (int)event->x, (int)event->y );
801 else if ( event->direction == GDK_SCROLL_DOWN ) {
807 gboolean xywnd_size_allocate( GtkWidget* widget, GtkAllocation* allocation, XYWnd* xywnd ){
808 xywnd->m_nWidth = allocation->width;
809 xywnd->m_nHeight = allocation->height;
810 xywnd->updateProjection();
811 xywnd->m_window_observer->onSizeChanged( xywnd->Width(), xywnd->Height() );
815 gboolean xywnd_expose( GtkWidget* widget, GdkEventExpose* event, XYWnd* xywnd ){
816 if ( glwidget_make_current( xywnd->GetWidget() ) != FALSE ) {
817 if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) {
818 GlobalOpenGL_debugAssertNoErrors();
820 GlobalOpenGL_debugAssertNoErrors();
822 xywnd->m_XORRectangle.set( rectangle_t() );
824 glwidget_swap_buffers( xywnd->GetWidget() );
830 void XYWnd_CameraMoved( XYWnd& xywnd ){
831 // if ( g_xywindow_globals_private.m_bCamXYUpdate ) {
832 //XYWnd_Update( xywnd );
833 xywnd.UpdateCameraIcon();
838 m_gl_widget( glwidget_new( FALSE ) ),
839 m_deferredDraw( WidgetQueueDrawCaller( *m_gl_widget ) ),
840 m_deferred_motion( xywnd_motion, this ),
842 m_window_observer( NewWindowObserver() ),
843 m_XORRectangle( m_gl_widget ),
844 m_chasemouse_handler( 0 ){
848 m_bNewBrushDrag = false;
849 m_move_started = false;
850 m_zoom_started = false;
861 m_backgroundActivated = false;
868 m_entityCreate = false;
872 GlobalWindowObservers_add( m_window_observer );
873 GlobalWindowObservers_connectWidget( m_gl_widget );
875 m_window_observer->setRectangleDrawCallback( ReferenceCaller1<XYWnd, rect_t, xy_update_xor_rectangle>( *this ) );
876 m_window_observer->setView( m_view );
878 gtk_widget_ref( m_gl_widget );
880 gtk_widget_set_events( m_gl_widget, GDK_DESTROY | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK );
881 GTK_WIDGET_SET_FLAGS( m_gl_widget, GTK_CAN_FOCUS );
883 m_sizeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "size_allocate", G_CALLBACK( xywnd_size_allocate ), this );
884 m_exposeHandler = g_signal_connect( G_OBJECT( m_gl_widget ), "expose_event", G_CALLBACK( xywnd_expose ), this );
886 g_signal_connect( G_OBJECT( m_gl_widget ), "button_press_event", G_CALLBACK( xywnd_button_press ), this );
887 g_signal_connect( G_OBJECT( m_gl_widget ), "button_release_event", G_CALLBACK( xywnd_button_release ), this );
888 g_signal_connect( G_OBJECT( m_gl_widget ), "focus_in_event", G_CALLBACK( xywnd_focus_in ), this ); //works only in floating views layout
889 g_signal_connect( G_OBJECT( m_gl_widget ), "motion_notify_event", G_CALLBACK( DeferredMotion::gtk_motion ), &m_deferred_motion );
891 g_signal_connect( G_OBJECT( m_gl_widget ), "scroll_event", G_CALLBACK( xywnd_wheel_scroll ), this );
893 Map_addValidCallback( g_map, DeferredDrawOnMapValidChangedCaller( m_deferredDraw ) );
898 AddSceneChangeCallback( ReferenceCaller<XYWnd, &XYWnd_Update>( *this ) );
899 AddCameraMovedCallback( ReferenceCaller<XYWnd, &XYWnd_CameraMoved>( *this ) );
901 PressedButtons_connect( g_pressedButtons, m_gl_widget );
903 onMouseDown.connectLast( makeSignalHandler3( MouseDownCaller(), *this ) );
909 if ( m_mnuDrop != 0 ) {
910 gtk_widget_destroy( GTK_WIDGET( m_mnuDrop ) );
914 g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_sizeHandler );
915 g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_exposeHandler );
917 gtk_widget_unref( m_gl_widget );
919 m_window_observer->release();
922 void XYWnd::captureStates(){
923 m_state_selected = GlobalShaderCache().capture( "$XY_OVERLAY" );
926 void XYWnd::releaseStates(){
927 GlobalShaderCache().release( "$XY_OVERLAY" );
930 const Vector3& XYWnd::GetOrigin(){
934 void XYWnd::SetOrigin( const Vector3& origin ){
939 void XYWnd::Scroll( int x, int y ){
940 int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
941 int nDim2 = ( m_viewType == XY ) ? 1 : 2;
942 m_vOrigin[nDim1] += x / m_fScale;
943 m_vOrigin[nDim2] += y / m_fScale;
948 unsigned int Clipper_buttons(){
952 unsigned int Clipper_quick_buttons(){
953 return RAD_LBUTTON | RAD_CONTROL;
956 void XYWnd::DropClipPoint( int pointx, int pointy ){
959 XY_ToPoint( pointx, pointy, point );
962 Select_GetMid( mid );
963 g_clip_viewtype = static_cast<VIEWTYPE>( GetViewType() );
964 const int nDim = ( g_clip_viewtype == YZ ) ? 0 : ( ( g_clip_viewtype == XZ ) ? 1 : 2 );
965 point[nDim] = mid[nDim];
966 vector3_snap( point, GetSnapGridSize() );
967 NewClipPoint( point );
970 void XYWnd::Clipper_OnLButtonDown( int x, int y ){
971 Vector3 mousePosition;
972 XY_ToPoint( x, y, mousePosition );
973 g_pMovingClip = GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale );
974 if ( !g_pMovingClip ) {
975 DropClipPoint( x, y );
979 void XYWnd::Clipper_OnLButtonUp( int x, int y ){
980 if ( g_pMovingClip ) {
985 void XYWnd::Clipper_OnMouseMoved( int x, int y ){
986 if ( g_pMovingClip ) {
987 XY_ToPoint( x, y, g_pMovingClip->m_ptClip );
988 XY_SnapToGrid( g_pMovingClip->m_ptClip );
990 ClipperChangeNotify();
994 //#include "gtkutil/image.h"
996 /* is called on every mouse move fraction; ain't good! */
997 void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){
998 Vector3 mousePosition;
999 XY_ToPoint( x, y, mousePosition );
1001 if( GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ) != 0 ){
1003 cursor = gdk_cursor_new( GDK_CROSSHAIR );
1004 //cursor = gdk_cursor_new( GDK_FLEUR );
1005 gdk_window_set_cursor( m_gl_widget->window, cursor );
1006 gdk_cursor_unref( cursor );
1010 cursor = gdk_cursor_new( GDK_HAND2 );
1011 // GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.png" );
1012 // cursor = gdk_cursor_new_from_pixbuf( gdk_display_get_default(), pixbuf, 0, 0 );
1013 // g_object_unref( pixbuf );
1014 gdk_window_set_cursor( m_gl_widget->window, cursor );
1015 gdk_cursor_unref( cursor );
1021 gdk_window_set_cursor( m_gl_widget->window, 0 );
1025 void XYWnd::SetCustomPivotOrigin( int pointx, int pointy ){
1027 XY_ToPoint( pointx, pointy, point );
1028 VIEWTYPE viewtype = static_cast<VIEWTYPE>( GetViewType() );
1029 const int nDim = ( viewtype == YZ ) ? 0 : ( ( viewtype == XZ ) ? 1 : 2 );
1030 //vector3_snap( point, GetSnapGridSize() );
1031 point[nDim] = 999999;
1033 GlobalSelectionSystem().setCustomPivotOrigin( point );
1034 SceneChangeNotify();
1037 unsigned int MoveCamera_buttons(){
1038 // return RAD_CONTROL | ( g_glwindow_globals.m_nMouseType == ETwoButton ? RAD_RBUTTON : RAD_MBUTTON );
1039 return RAD_CONTROL | RAD_MBUTTON;
1042 void XYWnd_PositionCamera( XYWnd* xywnd, int x, int y, CamWnd& camwnd ){
1043 Vector3 origin( Camera_getOrigin( camwnd ) );
1044 xywnd->XY_ToPoint( x, y, origin );
1045 xywnd->XY_SnapToGrid( origin );
1046 Camera_setOrigin( camwnd, origin );
1049 unsigned int OrientCamera_buttons(){
1050 // if ( g_glwindow_globals.m_nMouseType == ETwoButton ) {
1051 // return RAD_RBUTTON | RAD_SHIFT | RAD_CONTROL;
1056 void XYWnd_OrientCamera( XYWnd* xywnd, int x, int y, CamWnd& camwnd ){
1057 //globalOutputStream() << Camera_getAngles( camwnd ) << " b4\n";
1058 Vector3 point = g_vector3_identity;
1059 xywnd->XY_ToPoint( x, y, point );
1060 //xywnd->XY_SnapToGrid( point );
1061 vector3_subtract( point, Camera_getOrigin( camwnd ) );
1063 int n1 = ( xywnd->GetViewType() == XY ) ? 1 : 2;
1064 int n2 = ( xywnd->GetViewType() == YZ ) ? 1 : 0;
1065 int nAngle = ( xywnd->GetViewType() == XY ) ? CAMERA_YAW : CAMERA_PITCH;
1066 if ( point[n1] || point[n2] ) {
1067 Vector3 angles( Camera_getAngles( camwnd ) );
1068 angles[nAngle] = static_cast<float>( radians_to_degrees( atan2( point[n1], point[n2] ) ) );
1069 if( angles[CAMERA_YAW] < 0 )
1070 angles[CAMERA_YAW] = angles[CAMERA_YAW] + 360;
1071 if ( nAngle == CAMERA_PITCH ){
1072 if( fabs( angles[CAMERA_PITCH] ) > 90 ){
1073 angles[CAMERA_PITCH] = ( angles[CAMERA_PITCH] > 0 ) ? ( -angles[CAMERA_PITCH] + 180 ) : ( -angles[CAMERA_PITCH] - 180 );
1074 if( xywnd->GetViewType() == YZ ){
1075 if( angles[CAMERA_YAW] < 180 ){
1076 angles[CAMERA_YAW] = 360 - angles[CAMERA_YAW];
1079 else if( angles[CAMERA_YAW] < 90 || angles[CAMERA_YAW] > 270 ){
1080 angles[CAMERA_YAW] = 180 - angles[CAMERA_YAW];
1084 if( xywnd->GetViewType() == YZ ){
1085 if( angles[CAMERA_YAW] > 180 ){
1086 angles[CAMERA_YAW] = 360 - angles[CAMERA_YAW];
1089 else if( angles[CAMERA_YAW] > 90 && angles[CAMERA_YAW] < 270 ){
1090 angles[CAMERA_YAW] = 180 - angles[CAMERA_YAW];
1094 Camera_setAngles( camwnd, angles );
1096 //globalOutputStream() << Camera_getAngles( camwnd ) << "\n";
1099 unsigned int SetCustomPivotOrigin_buttons(){
1100 return RAD_MBUTTON | RAD_SHIFT;
1108 unsigned int NewBrushDrag_buttons(){
1112 void XYWnd::NewBrushDrag_Begin( int x, int y ){
1114 m_nNewBrushPressx = x;
1115 m_nNewBrushPressy = y;
1117 m_bNewBrushDrag = true;
1120 void XYWnd::NewBrushDrag_End( int x, int y ){
1121 if ( m_NewBrushDrag != 0 ) {
1122 GlobalUndoSystem().finish( "brushDragNew" );
1126 void XYWnd::NewBrushDrag( int x, int y ){
1128 XY_ToPoint( m_nNewBrushPressx, m_nNewBrushPressy, mins );
1129 XY_SnapToGrid( mins );
1130 XY_ToPoint( x, y, maxs );
1131 XY_SnapToGrid( maxs );
1133 int nDim = ( m_viewType == XY ) ? 2 : ( m_viewType == YZ ) ? 0 : 1;
1135 mins[nDim] = float_snapped( Select_getWorkZone().d_work_min[nDim], GetSnapGridSize() );
1136 maxs[nDim] = float_snapped( Select_getWorkZone().d_work_max[nDim], GetSnapGridSize() );
1138 if ( maxs[nDim] <= mins[nDim] ) {
1139 maxs[nDim] = mins[nDim] + GetGridSize();
1142 for ( int i = 0 ; i < 3 ; i++ )
1144 if ( mins[i] == maxs[i] ) {
1145 return; // don't create a degenerate brush
1147 if ( mins[i] > maxs[i] ) {
1148 float temp = mins[i];
1154 if ( m_NewBrushDrag == 0 ) {
1155 GlobalUndoSystem().start();
1156 NodeSmartReference node( GlobalBrushCreator().createBrush() );
1157 Node_getTraversable( Map_FindOrInsertWorldspawn( g_map ) )->insert( node );
1159 scene::Path brushpath( makeReference( GlobalSceneGraph().root() ) );
1160 brushpath.push( makeReference( *Map_GetWorldspawn( g_map ) ) );
1161 brushpath.push( makeReference( node.get() ) );
1162 selectPath( brushpath, true );
1164 m_NewBrushDrag = node.get_pointer();
1168 //Scene_BrushResize_Selected(GlobalSceneGraph(), aabb_for_minmax(mins, maxs), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()));
1169 Scene_BrushResize_Selected( GlobalSceneGraph(), aabb_for_minmax( mins, maxs ),
1170 g_brush_always_caulk ?
1171 "textures/common/caulk" : TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) );
1174 void entitycreate_activated( GtkWidget* item ){
1175 scene::Node* world_node = Map_FindWorldspawn( g_map );
1176 const char* entity_name = gtk_label_get_text( GTK_LABEL( GTK_BIN( item )->child ) );
1178 if ( !( world_node && string_equal( entity_name, "worldspawn" ) ) ) {
1179 g_pParentWnd->ActiveXY()->OnEntityCreate( entity_name );
1182 GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( MainFrame_getWindow() ), "There's already a worldspawn in your map!"
1190 void EntityClassMenu_addItem( GtkMenu* menu, const char* name ){
1191 GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_label( name ) );
1192 g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( entitycreate_activated ), item );
1193 gtk_widget_show( GTK_WIDGET( item ) );
1194 menu_add_item( menu, item );
1197 class EntityClassMenuInserter : public EntityClassVisitor
1199 typedef std::pair<GtkMenu*, CopiedString> MenuPair;
1200 typedef std::vector<MenuPair> MenuStack;
1202 CopiedString m_previous;
1204 EntityClassMenuInserter( GtkMenu* menu ){
1205 m_stack.reserve( 2 );
1206 m_stack.push_back( MenuPair( menu, "" ) );
1208 ~EntityClassMenuInserter(){
1209 if ( !string_empty( m_previous.c_str() ) ) {
1210 addItem( m_previous.c_str(), "" );
1213 void visit( EntityClass* e ){
1214 ASSERT_MESSAGE( !string_empty( e->name() ), "entity-class has no name" );
1215 if ( !string_empty( m_previous.c_str() ) ) {
1216 addItem( m_previous.c_str(), e->name() );
1218 m_previous = e->name();
1220 void pushMenu( const CopiedString& name ){
1221 GtkMenuItem* item = GTK_MENU_ITEM( gtk_menu_item_new_with_label( name.c_str() ) );
1222 gtk_widget_show( GTK_WIDGET( item ) );
1223 container_add_widget( GTK_CONTAINER( m_stack.back().first ), GTK_WIDGET( item ) );
1225 GtkMenu* submenu = GTK_MENU( gtk_menu_new() );
1226 gtk_menu_item_set_submenu( item, GTK_WIDGET( submenu ) );
1228 m_stack.push_back( MenuPair( submenu, name ) );
1233 void addItem( const char* name, const char* next ){
1234 const char* underscore = strchr( name, '_' );
1236 if ( underscore != 0 && underscore != name ) {
1237 bool nextEqual = string_equal_n( name, next, ( underscore + 1 ) - name );
1238 const char* parent = m_stack.back().second.c_str();
1240 if ( !string_empty( parent )
1241 && string_length( parent ) == std::size_t( underscore - name )
1242 && string_equal_n( name, parent, underscore - name ) ) { // this is a child
1244 else if ( nextEqual ) {
1245 if ( m_stack.size() == 2 ) {
1248 pushMenu( CopiedString( StringRange( name, underscore ) ) );
1250 else if ( m_stack.size() == 2 ) {
1254 else if ( m_stack.size() == 2 ) {
1258 EntityClassMenu_addItem( m_stack.back().first, name );
1262 void XYWnd::OnContextMenu(){
1263 // if ( g_xywindow_globals.m_bRightClick == false ) {
1267 if ( m_mnuDrop == 0 ) { // first time, load it up
1268 GtkMenu* menu = m_mnuDrop = GTK_MENU( gtk_menu_new() );
1270 EntityClassMenuInserter inserter( menu );
1271 GlobalEntityClassManager().forEach( inserter );
1274 gtk_menu_popup( m_mnuDrop, 0, 0, 0, 0, 1, GDK_CURRENT_TIME );
1277 FreezePointer g_xywnd_freezePointer;
1279 unsigned int Move_buttons(){
1283 void XYWnd_moveDelta( int x, int y, unsigned int state, void* data ){
1284 reinterpret_cast<XYWnd*>( data )->EntityCreate_MouseMove( x, y );
1285 reinterpret_cast<XYWnd*>( data )->Scroll( -x, y );
1288 gboolean XYWnd_Move_focusOut( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){
1293 void XYWnd::Move_Begin(){
1294 if ( m_move_started ) {
1297 m_move_started = true;
1298 g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_moveDelta, this );
1299 m_move_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this );
1302 void XYWnd::Move_End(){
1303 m_move_started = false;
1304 g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), false );
1305 g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_move_focusOut );
1308 unsigned int Zoom_buttons(){
1309 return RAD_RBUTTON | RAD_ALT;
1316 void XYWnd_zoomDelta( int x, int y, unsigned int state, void* data ){
1319 while ( abs( g_dragZoom ) > 8 )
1321 if ( g_dragZoom > 0 ) {
1322 reinterpret_cast<XYWnd*>( data )->ZoomOut();
1327 if ( g_xywindow_globals.m_bZoomInToPointer ) {
1328 reinterpret_cast<XYWnd*>( data )->ZoomInWithMouse( g_zoom2x, g_zoom2y );
1331 reinterpret_cast<XYWnd*>( data )->ZoomIn();
1339 gboolean XYWnd_Zoom_focusOut( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){
1344 void XYWnd::Zoom_Begin( int x, int y ){
1345 if ( m_zoom_started ) {
1348 m_zoom_started = true;
1352 g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_zoomDelta, this );
1353 m_zoom_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this );
1356 void XYWnd::Zoom_End(){
1357 m_zoom_started = false;
1358 g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), false );
1359 g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_zoom_focusOut );
1362 // makes sure the selected brush or camera is in view
1363 void XYWnd::PositionView( const Vector3& position ){
1364 int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
1365 int nDim2 = ( m_viewType == XY ) ? 1 : 2;
1367 m_vOrigin[nDim1] = position[nDim1];
1368 m_vOrigin[nDim2] = position[nDim2];
1372 XYWnd_Update( *this );
1375 void XYWnd::SetViewType( VIEWTYPE viewType ){
1376 m_viewType = viewType;
1379 if ( m_parent != 0 ) {
1380 gtk_window_set_title( m_parent, ViewType_getTitle( m_viewType ) );
1385 inline WindowVector WindowVector_forInteger( int x, int y ){
1386 return WindowVector( static_cast<float>( x ), static_cast<float>( y ) );
1389 void XYWnd::mouseDown( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers ){
1390 XY_MouseDown( static_cast<int>( position.x() ), static_cast<int>( position.y() ), buttons_for_button_and_modifiers( button, modifiers ) );
1392 void XYWnd::XY_MouseDown( int x, int y, unsigned int buttons ){
1393 if ( buttons == Move_buttons() ) {
1395 EntityCreate_MouseDown( x, y );
1397 else if ( buttons == Zoom_buttons() ) {
1400 else if ( ClipMode() && ( buttons == Clipper_buttons() || buttons == Clipper_quick_buttons() ) ) {
1401 Clipper_OnLButtonDown( x, y );
1403 else if ( !ClipMode() && buttons == Clipper_quick_buttons() ) {
1405 g_quick_clipper = true;
1406 Clipper_OnLButtonDown( x, y );
1408 else if ( buttons == NewBrushDrag_buttons() && GlobalSelectionSystem().countSelected() == 0 ) {
1409 NewBrushDrag_Begin( x, y );
1411 // control mbutton = move camera
1412 else if ( buttons == MoveCamera_buttons() ) {
1413 XYWnd_PositionCamera( this, x, y, *g_pParentWnd->GetCamWnd() );
1415 // mbutton = angle camera
1416 else if ( buttons == OrientCamera_buttons() ) {
1417 XYWnd_OrientCamera( this, x, y, *g_pParentWnd->GetCamWnd() );
1419 else if ( buttons == SetCustomPivotOrigin_buttons() ) {
1420 SetCustomPivotOrigin( x, y );
1424 m_window_observer->onMouseDown( WindowVector_forInteger( x, y ), button_for_flags( buttons ), modifiers_for_flags( buttons ) );
1428 void XYWnd::XY_MouseUp( int x, int y, unsigned int buttons ){
1429 if ( m_move_started ) {
1431 EntityCreate_MouseUp( x, y );
1433 else if ( m_zoom_started ) {
1436 else if ( ClipMode() && ( buttons == Clipper_buttons() || buttons == Clipper_quick_buttons() ) ) {
1437 Clipper_OnLButtonUp( x, y );
1439 else if ( m_bNewBrushDrag ) {
1440 m_bNewBrushDrag = false;
1441 NewBrushDrag_End( x, y );
1442 if ( m_NewBrushDrag == 0 ) {
1443 //L button w/o created brush = tunnel selection
1444 m_window_observer->onMouseUp( WindowVector_forInteger( x, y ), button_for_flags( buttons ), modifiers_for_flags( buttons ) );
1449 m_window_observer->onMouseUp( WindowVector_forInteger( x, y ), button_for_flags( buttons ), modifiers_for_flags( buttons ) );
1453 void XYWnd::XY_MouseMoved( int x, int y, unsigned int buttons ){
1454 // rbutton = drag xy origin
1455 if ( m_move_started ) {
1458 else if ( m_zoom_started ) {
1461 else if ( ClipMode() && g_pMovingClip != 0 ) {
1462 Clipper_OnMouseMoved( x, y );
1464 // lbutton without selection = drag new brush
1465 else if ( m_bNewBrushDrag ) {
1466 NewBrushDrag( x, y );
1469 // control mbutton = move camera
1470 else if ( buttons == MoveCamera_buttons() ) {
1471 XYWnd_PositionCamera( this, x, y, *g_pParentWnd->GetCamWnd() );
1474 // mbutton = angle camera
1475 else if ( buttons == OrientCamera_buttons() ) {
1476 XYWnd_OrientCamera( this, x, y, *g_pParentWnd->GetCamWnd() );
1479 else if ( buttons == SetCustomPivotOrigin_buttons() ) {
1480 SetCustomPivotOrigin( x, y );
1485 m_window_observer->onMouseMotion( WindowVector_forInteger( x, y ), modifiers_for_flags( buttons ) );
1487 m_mousePosition[0] = m_mousePosition[1] = m_mousePosition[2] = 0.0;
1488 XY_ToPoint( x, y, m_mousePosition );
1489 XY_SnapToGrid( m_mousePosition );
1491 StringOutputStream status( 64 );
1492 status << "x:: " << FloatFormat( m_mousePosition[0], 6, 1 )
1493 << " y:: " << FloatFormat( m_mousePosition[1], 6, 1 )
1494 << " z:: " << FloatFormat( m_mousePosition[2], 6, 1 );
1495 g_pParentWnd->SetStatusText( g_pParentWnd->m_position_status, status.c_str() );
1497 if ( g_bCrossHairs ) {
1498 XYWnd_Update( *this );
1501 Clipper_Crosshair_OnMouseMoved( x, y );
1505 void XYWnd::EntityCreate_MouseDown( int x, int y ){
1506 m_entityCreate = true;
1507 m_entityCreate_x = x;
1508 m_entityCreate_y = y;
1511 void XYWnd::EntityCreate_MouseMove( int x, int y ){
1512 if ( m_entityCreate && ( m_entityCreate_x != x || m_entityCreate_y != y ) ) {
1513 m_entityCreate = false;
1517 void XYWnd::EntityCreate_MouseUp( int x, int y ){
1518 if ( m_entityCreate ) {
1519 m_entityCreate = false;
1524 inline float screen_normalised( int pos, unsigned int size ){
1525 return ( ( 2.0f * pos ) / size ) - 1.0f;
1528 inline float normalised_to_world( float normalised, float world_origin, float normalised2world_scale ){
1529 return world_origin + normalised * normalised2world_scale;
1533 // TTimo: watch it, this doesn't init one of the 3 coords
1534 void XYWnd::XY_ToPoint( int x, int y, Vector3& point ){
1535 float normalised2world_scale_x = m_nWidth / 2 / m_fScale;
1536 float normalised2world_scale_y = m_nHeight / 2 / m_fScale;
1537 if ( m_viewType == XY ) {
1538 point[0] = normalised_to_world( screen_normalised( x, m_nWidth ), m_vOrigin[0], normalised2world_scale_x );
1539 point[1] = normalised_to_world( -screen_normalised( y, m_nHeight ), m_vOrigin[1], normalised2world_scale_y );
1541 else if ( m_viewType == YZ ) {
1542 point[1] = normalised_to_world( screen_normalised( x, m_nWidth ), m_vOrigin[1], normalised2world_scale_x );
1543 point[2] = normalised_to_world( -screen_normalised( y, m_nHeight ), m_vOrigin[2], normalised2world_scale_y );
1547 point[0] = normalised_to_world( screen_normalised( x, m_nWidth ), m_vOrigin[0], normalised2world_scale_x );
1548 point[2] = normalised_to_world( -screen_normalised( y, m_nHeight ), m_vOrigin[2], normalised2world_scale_y );
1552 void XYWnd::XY_SnapToGrid( Vector3& point ){
1553 if ( m_viewType == XY ) {
1554 point[0] = float_snapped( point[0], GetSnapGridSize() );
1555 point[1] = float_snapped( point[1], GetSnapGridSize() );
1557 else if ( m_viewType == YZ ) {
1558 point[1] = float_snapped( point[1], GetSnapGridSize() );
1559 point[2] = float_snapped( point[2], GetSnapGridSize() );
1563 point[0] = float_snapped( point[0], GetSnapGridSize() );
1564 point[2] = float_snapped( point[2], GetSnapGridSize() );
1568 void XYWnd::XY_LoadBackgroundImage( const char *name ){
1569 const char* relative = path_make_relative( name, GlobalFileSystem().findRoot( name ) );
1570 if ( relative == name ) {
1571 globalOutputStream() << "WARNING: could not extract the relative path, using full path instead\n";
1574 char fileNameWithoutExt[512];
1575 strncpy( fileNameWithoutExt, relative, sizeof( fileNameWithoutExt ) - 1 );
1576 fileNameWithoutExt[512 - 1] = '\0';
1577 fileNameWithoutExt[strlen( fileNameWithoutExt ) - 4] = '\0';
1579 Image *image = QERApp_LoadImage( 0, fileNameWithoutExt );
1581 globalOutputStream() << "Could not load texture " << fileNameWithoutExt << "\n";
1584 g_pParentWnd->ActiveXY()->m_tex = (qtexture_t*)malloc( sizeof( qtexture_t ) );
1585 LoadTextureRGBA( g_pParentWnd->ActiveXY()->XYWnd::m_tex, image->getRGBAPixels(), image->getWidth(), image->getHeight() );
1586 globalOutputStream() << "Loaded background texture " << relative << "\n";
1587 g_pParentWnd->ActiveXY()->m_backgroundActivated = true;
1590 switch ( g_pParentWnd->ActiveXY()->m_viewType )
1607 Select_GetBounds( min, max );
1608 g_pParentWnd->ActiveXY()->m_xmin = min[m_ix];
1609 g_pParentWnd->ActiveXY()->m_ymin = min[m_iy];
1610 g_pParentWnd->ActiveXY()->m_xmax = max[m_ix];
1611 g_pParentWnd->ActiveXY()->m_ymax = max[m_iy];
1614 void XYWnd::XY_DisableBackground( void ){
1615 g_pParentWnd->ActiveXY()->m_backgroundActivated = false;
1616 if ( g_pParentWnd->ActiveXY()->m_tex ) {
1617 free( g_pParentWnd->ActiveXY()->m_tex );
1619 g_pParentWnd->ActiveXY()->m_tex = NULL;
1622 void WXY_BackgroundSelect( void ){
1623 bool brushesSelected = Scene_countSelectedBrushes( GlobalSceneGraph() ) != 0;
1624 if ( !brushesSelected ) {
1625 gtk_MessageBox( 0, "You have to select some brushes to get the bounding box for.\n",
1626 "No selection", eMB_OK, eMB_ICONERROR );
1630 const char *filename = file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, "Background Image", NULL, NULL );
1631 g_pParentWnd->ActiveXY()->XY_DisableBackground();
1633 g_pParentWnd->ActiveXY()->XY_LoadBackgroundImage( filename );
1638 ============================================================================
1642 ============================================================================
1651 double two_to_the_power( int power ){
1652 return pow( 2.0f, power );
1655 void XYWnd::XY_DrawAxis( void ){
1656 if ( g_xywindow_globals_private.show_axis ) {
1657 const char g_AxisName[3] = { 'X', 'Y', 'Z' };
1658 const int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
1659 const int nDim2 = ( m_viewType == XY ) ? 1 : 2;
1660 const int w = ( m_nWidth / 2 / m_fScale );
1661 const int h = ( m_nHeight / 2 / m_fScale );
1663 Vector3 colourX = ( m_viewType == YZ ) ? g_xywindow_globals.AxisColorY : g_xywindow_globals.AxisColorX;
1664 Vector3 colourY = ( m_viewType == XY ) ? g_xywindow_globals.AxisColorY : g_xywindow_globals.AxisColorZ;
1666 float grayX = vector3_dot( colourX, Vector3( 0.2989, 0.5870, 0.1140 ) );
1667 float grayY = vector3_dot( colourY, Vector3( 0.2989, 0.5870, 0.1140 ) );
1668 colourX[0] = colourX[1] = colourX[2] = grayX;
1669 colourY[0] = colourY[1] = colourY[2] = grayY;
1672 // draw two lines with corresponding axis colors to highlight current view
1673 // horizontal line: nDim1 color
1675 glBegin( GL_LINES );
1676 glColor3fv( vector3_to_array( colourX ) );
1677 glVertex2f( m_vOrigin[nDim1] - w + 40 / m_fScale, m_vOrigin[nDim2] + h - 45 / m_fScale );
1678 glVertex2f( m_vOrigin[nDim1] - w + 65 / m_fScale, m_vOrigin[nDim2] + h - 45 / m_fScale );
1680 glVertex2f( 32 / m_fScale, 0 );
1681 glColor3fv( vector3_to_array( colourY ) );
1682 glVertex2f( m_vOrigin[nDim1] - w + 40 / m_fScale, m_vOrigin[nDim2] + h - 45 / m_fScale );
1683 glVertex2f( m_vOrigin[nDim1] - w + 40 / m_fScale, m_vOrigin[nDim2] + h - 20 / m_fScale );
1685 glVertex2f( 0, 32 / m_fScale );
1688 // now print axis symbols
1689 glColor3fv( vector3_to_array( colourX ) );
1690 glRasterPos2f( m_vOrigin[nDim1] - w + 55 / m_fScale, m_vOrigin[nDim2] + h - 55 / m_fScale );
1691 GlobalOpenGL().drawChar( g_AxisName[nDim1] );
1692 glRasterPos2f( 28 / m_fScale, -10 / m_fScale );
1693 GlobalOpenGL().drawChar( g_AxisName[nDim1] );
1694 glColor3fv( vector3_to_array( colourY ) );
1695 glRasterPos2f( m_vOrigin[nDim1] - w + 25 / m_fScale, m_vOrigin[nDim2] + h - 30 / m_fScale );
1696 GlobalOpenGL().drawChar( g_AxisName[nDim2] );
1697 glRasterPos2f( -10 / m_fScale, 28 / m_fScale );
1698 GlobalOpenGL().drawChar( g_AxisName[nDim2] );
1702 void XYWnd::RenderActive( void ){
1703 if ( glwidget_make_current( m_gl_widget ) != FALSE ) {
1704 if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) {
1705 GlobalOpenGL_debugAssertNoErrors();
1706 glDrawBuffer( GL_FRONT );
1708 if ( g_xywindow_globals_private.show_outline ) {
1709 glMatrixMode( GL_PROJECTION );
1711 glOrtho( 0, m_nWidth, 0, m_nHeight, 0, 1 );
1713 glMatrixMode( GL_MODELVIEW );
1716 if( !Active() ){ //sorta erase
1717 glColor3fv( vector3_to_array( g_xywindow_globals.color_gridmajor ) );
1719 // four view mode doesn't colorize
1720 else if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) {
1721 glColor3fv( vector3_to_array( g_xywindow_globals.color_viewname ) );
1725 switch ( m_viewType )
1728 glColor3fv( vector3_to_array( g_xywindow_globals.AxisColorX ) );
1731 glColor3fv( vector3_to_array( g_xywindow_globals.AxisColorY ) );
1734 glColor3fv( vector3_to_array( g_xywindow_globals.AxisColorZ ) );
1738 glBegin( GL_LINE_LOOP );
1739 glVertex2f( 0.5, 0.5 );
1740 glVertex2f( m_nWidth - 0.5, 1 );
1741 glVertex2f( m_nWidth - 0.5, m_nHeight - 0.5 );
1742 glVertex2f( 0.5, m_nHeight - 0.5 );
1745 // we do this part (the old way) only if show_axis is disabled
1746 if ( !g_xywindow_globals_private.show_axis ) {
1747 glMatrixMode( GL_PROJECTION );
1749 glOrtho( 0, m_nWidth, 0, m_nHeight, 0, 1 );
1751 glMatrixMode( GL_MODELVIEW );
1755 glColor3fv( vector3_to_array( g_xywindow_globals.color_viewname ) );
1758 glColor4fv( vector4_to_array( Vector4( g_xywindow_globals.color_gridtext, 1.0f ) ) );
1761 glDisable( GL_BLEND );
1762 glRasterPos2f( 35, m_nHeight - 20 );
1764 GlobalOpenGL().drawString( ViewType_getTitle( m_viewType ) );
1768 glViewport( 0, 0, m_nWidth, m_nHeight );
1770 glMatrixMode( GL_PROJECTION );
1771 glLoadMatrixf( reinterpret_cast<const float*>( &m_projection ) );
1773 glMatrixMode( GL_MODELVIEW );
1775 glScalef( m_fScale, m_fScale, 1 );
1776 int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
1777 int nDim2 = ( m_viewType == XY ) ? 1 : 2;
1778 glTranslatef( -m_vOrigin[nDim1], -m_vOrigin[nDim2], 0 );
1780 glDisable( GL_LINE_STIPPLE );
1781 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1782 glDisableClientState( GL_NORMAL_ARRAY );
1783 glDisableClientState( GL_COLOR_ARRAY );
1784 glDisable( GL_TEXTURE_2D );
1785 glDisable( GL_LIGHTING );
1786 glDisable( GL_COLOR_MATERIAL );
1787 glDisable( GL_DEPTH_TEST );
1788 glDisable( GL_TEXTURE_1D );
1789 glDisable( GL_BLEND );
1791 XYWnd::XY_DrawAxis();
1794 glDrawBuffer( GL_BACK );
1795 GlobalOpenGL_debugAssertNoErrors();
1796 glwidget_make_current( m_gl_widget );
1801 void XYWnd::XY_DrawBackground( void ){
1802 glPushAttrib( GL_ALL_ATTRIB_BITS );
1804 glEnable( GL_TEXTURE_2D );
1805 glEnable( GL_BLEND );
1806 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
1807 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1808 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1809 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
1811 glPolygonMode( GL_FRONT, GL_FILL );
1813 glBindTexture( GL_TEXTURE_2D, m_tex->texture_number );
1814 glBegin( GL_QUADS );
1816 glColor4f( 1.0, 1.0, 1.0, m_alpha );
1817 glTexCoord2f( 0.0, 1.0 );
1818 glVertex2f( m_xmin, m_ymin );
1820 glTexCoord2f( 1.0, 1.0 );
1821 glVertex2f( m_xmax, m_ymin );
1823 glTexCoord2f( 1.0, 0.0 );
1824 glVertex2f( m_xmax, m_ymax );
1826 glTexCoord2f( 0.0, 0.0 );
1827 glVertex2f( m_xmin, m_ymax );
1830 glBindTexture( GL_TEXTURE_2D, 0 );
1835 void XYWnd::XY_DrawGrid( void ) {
1836 float x, y, xb, xe, yb, ye;
1839 float step, minor_step, stepx, stepy;
1840 step = minor_step = stepx = stepy = GetGridSize();
1842 int minor_power = Grid_getPower();
1845 while ( ( minor_step * m_fScale ) <= 4.0f ) { // make sure minor grid spacing is at least 4 pixels on the screen
1849 int power = minor_power;
1850 while ( ( power % 3 ) != 0 || ( step * m_fScale ) <= 32.0f ) { // make sure major grid spacing is at least 32 pixels on the screen
1852 step = float(two_to_the_power( power ) );
1854 mask = ( 1 << ( power - minor_power ) ) - 1;
1855 while ( ( stepx * m_fScale ) <= 32.0f ) // text step x must be at least 32
1857 while ( ( stepy * m_fScale ) <= 32.0f ) // text step y must be at least 32
1860 a = ( ( GetSnapGridSize() > 0.0f ) ? 1.0f : 0.3f );
1862 glDisable( GL_TEXTURE_2D );
1863 glDisable( GL_TEXTURE_1D );
1864 glDisable( GL_DEPTH_TEST );
1865 glDisable( GL_BLEND );
1868 w = ( m_nWidth / 2 / m_fScale );
1869 h = ( m_nHeight / 2 / m_fScale );
1871 const int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
1872 const int nDim2 = ( m_viewType == XY ) ? 1 : 2;
1874 xb = m_vOrigin[nDim1] - w;
1875 if ( xb < region_mins[nDim1] ) {
1876 xb = region_mins[nDim1];
1878 xb = step * floor( xb / step );
1880 xe = m_vOrigin[nDim1] + w;
1881 if ( xe > region_maxs[nDim1] ) {
1882 xe = region_maxs[nDim1];
1884 xe = step * ceil( xe / step );
1886 yb = m_vOrigin[nDim2] - h;
1887 if ( yb < region_mins[nDim2] ) {
1888 yb = region_mins[nDim2];
1890 yb = step * floor( yb / step );
1892 ye = m_vOrigin[nDim2] + h;
1893 if ( ye > region_maxs[nDim2] ) {
1894 ye = region_maxs[nDim2];
1896 ye = step * ceil( ye / step );
1898 #define COLORS_DIFFER( a,b ) \
1899 ( ( a )[0] != ( b )[0] || \
1900 ( a )[1] != ( b )[1] || \
1901 ( a )[2] != ( b )[2] )
1904 // draw minor blocks
1905 if ( g_xywindow_globals_private.d_showgrid || a < 1.0f ) {
1907 glEnable( GL_BLEND );
1910 if ( COLORS_DIFFER( g_xywindow_globals.color_gridminor, g_xywindow_globals.color_gridback ) ) {
1911 glColor4fv( vector4_to_array( Vector4( g_xywindow_globals.color_gridminor, a ) ) );
1913 glBegin( GL_LINES );
1915 for ( x = xb ; x < xe ; x += minor_step, ++i ) {
1916 if ( ( i & mask ) != 0 ) {
1917 glVertex2f( x, yb );
1918 glVertex2f( x, ye );
1922 for ( y = yb ; y < ye ; y += minor_step, ++i ) {
1923 if ( ( i & mask ) != 0 ) {
1924 glVertex2f( xb, y );
1925 glVertex2f( xe, y );
1931 // draw major blocks
1932 if ( COLORS_DIFFER( g_xywindow_globals.color_gridmajor, g_xywindow_globals.color_gridminor ) ) {
1933 glColor4fv( vector4_to_array( Vector4( g_xywindow_globals.color_gridmajor, a ) ) );
1935 glBegin( GL_LINES );
1936 for ( x = xb ; x <= xe ; x += step ) {
1937 glVertex2f( x, yb );
1938 glVertex2f( x, ye );
1940 for ( y = yb ; y <= ye ; y += step ) {
1941 glVertex2f( xb, y );
1942 glVertex2f( xe, y );
1948 glDisable( GL_BLEND );
1952 // draw coordinate text if needed
1953 if ( g_xywindow_globals_private.show_coordinates ) {
1954 glColor4fv( vector4_to_array( Vector4( g_xywindow_globals.color_gridtext, 1.0f ) ) );
1955 float offx = m_vOrigin[nDim2] + h - ( 4 + GlobalOpenGL().m_font->getPixelAscent() ) / m_fScale;
1956 float offy = m_vOrigin[nDim1] - w + 4 / m_fScale;
1957 for ( x = xb - fmod( xb, stepx ); x <= xe ; x += stepx ) {
1958 glRasterPos2f( x, offx );
1959 sprintf( text, "%g", x );
1960 GlobalOpenGL().drawString( text );
1962 for ( y = yb - fmod( yb, stepy ); y <= ye ; y += stepy ) {
1963 glRasterPos2f( offy, y );
1964 sprintf( text, "%g", y );
1965 GlobalOpenGL().drawString( text );
1969 // we do this part (the old way) only if show_axis is disabled
1970 if ( !g_xywindow_globals_private.show_axis ) {
1972 glColor3fv( vector3_to_array( g_xywindow_globals.color_viewname ) );
1975 glColor4fv( vector4_to_array( Vector4( g_xywindow_globals.color_gridtext, 1.0f ) ) );
1978 glRasterPos2f( m_vOrigin[nDim1] - w + 35 / m_fScale, m_vOrigin[nDim2] + h - 20 / m_fScale );
1980 GlobalOpenGL().drawString( ViewType_getTitle( m_viewType ) );
1983 XYWnd::XY_DrawAxis();
1985 // show current work zone?
1986 // the work zone is used to place dropped points and brushes
1987 if ( g_xywindow_globals_private.d_show_work ) {
1988 glColor4f( 1.0f, 0.0f, 0.0f, 1.0f );
1989 glBegin( GL_LINES );
1990 glVertex2f( xb, Select_getWorkZone().d_work_min[nDim2] );
1991 glVertex2f( xe, Select_getWorkZone().d_work_min[nDim2] );
1992 glVertex2f( xb, Select_getWorkZone().d_work_max[nDim2] );
1993 glVertex2f( xe, Select_getWorkZone().d_work_max[nDim2] );
1994 glVertex2f( Select_getWorkZone().d_work_min[nDim1], yb );
1995 glVertex2f( Select_getWorkZone().d_work_min[nDim1], ye );
1996 glVertex2f( Select_getWorkZone().d_work_max[nDim1], yb );
1997 glVertex2f( Select_getWorkZone().d_work_max[nDim1], ye );
2007 void XYWnd::XY_DrawBlockGrid(){
2008 if ( Map_FindWorldspawn( g_map ) == 0 ) {
2011 const char *value = Node_getEntity( *Map_GetWorldspawn( g_map ) )->getKeyValue( "_blocksize" );
2012 if ( strlen( value ) ) {
2013 sscanf( value, "%i", &g_xywindow_globals_private.blockSize );
2016 if ( !g_xywindow_globals_private.blockSize || g_xywindow_globals_private.blockSize > 65536 || g_xywindow_globals_private.blockSize < 1024 ) {
2017 // don't use custom blocksize if it is less than the default, or greater than the maximum world coordinate
2018 g_xywindow_globals_private.blockSize = 1024;
2021 float x, y, xb, xe, yb, ye;
2025 glDisable( GL_TEXTURE_2D );
2026 glDisable( GL_TEXTURE_1D );
2027 glDisable( GL_DEPTH_TEST );
2028 glDisable( GL_BLEND );
2030 w = ( m_nWidth / 2 / m_fScale );
2031 h = ( m_nHeight / 2 / m_fScale );
2033 int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
2034 int nDim2 = ( m_viewType == XY ) ? 1 : 2;
2036 xb = m_vOrigin[nDim1] - w;
2037 if ( xb < region_mins[nDim1] ) {
2038 xb = region_mins[nDim1];
2040 xb = static_cast<float>( g_xywindow_globals_private.blockSize * floor( xb / g_xywindow_globals_private.blockSize ) );
2042 xe = m_vOrigin[nDim1] + w;
2043 if ( xe > region_maxs[nDim1] ) {
2044 xe = region_maxs[nDim1];
2046 xe = static_cast<float>( g_xywindow_globals_private.blockSize * ceil( xe / g_xywindow_globals_private.blockSize ) );
2048 yb = m_vOrigin[nDim2] - h;
2049 if ( yb < region_mins[nDim2] ) {
2050 yb = region_mins[nDim2];
2052 yb = static_cast<float>( g_xywindow_globals_private.blockSize * floor( yb / g_xywindow_globals_private.blockSize ) );
2054 ye = m_vOrigin[nDim2] + h;
2055 if ( ye > region_maxs[nDim2] ) {
2056 ye = region_maxs[nDim2];
2058 ye = static_cast<float>( g_xywindow_globals_private.blockSize * ceil( ye / g_xywindow_globals_private.blockSize ) );
2060 // draw major blocks
2062 glColor3fv( vector3_to_array( g_xywindow_globals.color_gridblock ) );
2065 glBegin( GL_LINES );
2067 for ( x = xb ; x <= xe ; x += g_xywindow_globals_private.blockSize )
2069 glVertex2f( x, yb );
2070 glVertex2f( x, ye );
2073 if ( m_viewType == XY ) {
2074 for ( y = yb ; y <= ye ; y += g_xywindow_globals_private.blockSize )
2076 glVertex2f( xb, y );
2077 glVertex2f( xe, y );
2084 // draw coordinate text if needed
2086 if ( m_viewType == XY && m_fScale > .1 ) {
2087 for ( x = xb ; x < xe ; x += g_xywindow_globals_private.blockSize )
2088 for ( y = yb ; y < ye ; y += g_xywindow_globals_private.blockSize )
2090 glRasterPos2f( x + ( g_xywindow_globals_private.blockSize / 2 ), y + ( g_xywindow_globals_private.blockSize / 2 ) );
2091 sprintf( text, "%i,%i",(int)floor( x / g_xywindow_globals_private.blockSize ), (int)floor( y / g_xywindow_globals_private.blockSize ) );
2092 GlobalOpenGL().drawString( text );
2096 glColor4f( 0, 0, 0, 0 );
2099 void XYWnd::DrawCameraIcon( const Vector3& origin, const Vector3& angles ){
2100 Cam.fov = 48 / m_fScale;
2101 Cam.box = 16 / m_fScale;
2102 // globalOutputStream() << "pitch " << angles[CAMERA_PITCH] << " yaw " << angles[CAMERA_YAW] << "\n";
2104 if ( m_viewType == XY ) {
2107 Cam.a = degrees_to_radians( angles[CAMERA_YAW] );
2109 else if ( m_viewType == YZ ) {
2112 Cam.a = degrees_to_radians( ( angles[CAMERA_YAW] > 180 ) ? ( 180.0f - angles[CAMERA_PITCH] ) : angles[CAMERA_PITCH] );
2118 Cam.a = degrees_to_radians( ( angles[CAMERA_YAW] < 270 && angles[CAMERA_YAW] > 90 ) ? ( 180.0f - angles[CAMERA_PITCH] ) : angles[CAMERA_PITCH] );
2121 //glColor3f( 0.0, 0.0, 1.0 );
2122 glColor3f( 1.0, 1.0, 1.0 );
2123 glBegin( GL_LINE_STRIP );
2124 glVertex3f( Cam.x - Cam.box,Cam.y,0 );
2125 glVertex3f( Cam.x,Cam.y + ( Cam.box / 2 ),0 );
2126 glVertex3f( Cam.x + Cam.box,Cam.y,0 );
2127 glVertex3f( Cam.x,Cam.y - ( Cam.box / 2 ),0 );
2128 glVertex3f( Cam.x - Cam.box,Cam.y,0 );
2129 glVertex3f( Cam.x + Cam.box,Cam.y,0 );
2132 glBegin( GL_LINE_STRIP );
2133 glVertex3f( Cam.x + static_cast<float>( Cam.fov * cos( Cam.a + c_pi / 4 ) ), Cam.y + static_cast<float>( Cam.fov * sin( Cam.a + c_pi / 4 ) ), 0 );
2134 glVertex3f( Cam.x, Cam.y, 0 );
2135 glVertex3f( Cam.x + static_cast<float>( Cam.fov * cos( Cam.a - c_pi / 4 ) ), Cam.y + static_cast<float>( Cam.fov * sin( Cam.a - c_pi / 4 ) ), 0 );
2140 void XYWnd::UpdateCameraIcon( void ){
2141 if ( glwidget_make_current( m_gl_widget ) != FALSE ) {
2142 if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) {
2143 GlobalOpenGL_debugAssertNoErrors();
2144 glDrawBuffer( GL_FRONT );
2147 glViewport( 0, 0, m_nWidth, m_nHeight );
2149 glMatrixMode( GL_PROJECTION );
2150 glLoadMatrixf( reinterpret_cast<const float*>( &m_projection ) );
2152 glMatrixMode( GL_MODELVIEW );
2154 glScalef( m_fScale, m_fScale, 1 );
2155 int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
2156 int nDim2 = ( m_viewType == XY ) ? 1 : 2;
2157 glTranslatef( -m_vOrigin[nDim1], -m_vOrigin[nDim2], 0 );
2159 glDisable( GL_LINE_STIPPLE );
2160 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
2161 glDisableClientState( GL_NORMAL_ARRAY );
2162 glDisableClientState( GL_COLOR_ARRAY );
2163 glDisable( GL_TEXTURE_2D );
2164 glDisable( GL_LIGHTING );
2165 glDisable( GL_COLOR_MATERIAL );
2166 glDisable( GL_DEPTH_TEST );
2167 glDisable( GL_TEXTURE_1D );
2169 glEnable( GL_BLEND );
2170 glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
2172 //glColor3f( 0.0, 0.0, 1.0 );
2173 glColor3f( 1.0, 1.0, 1.0 );
2174 glBegin( GL_LINE_STRIP );
2175 glVertex3f( Cam.x - Cam.box,Cam.y,0 );
2176 glVertex3f( Cam.x,Cam.y + ( Cam.box / 2 ),0 );
2177 glVertex3f( Cam.x + Cam.box,Cam.y,0 );
2178 glVertex3f( Cam.x,Cam.y - ( Cam.box / 2 ),0 );
2179 glVertex3f( Cam.x - Cam.box,Cam.y,0 );
2180 glVertex3f( Cam.x + Cam.box,Cam.y,0 );
2183 glBegin( GL_LINE_STRIP );
2184 glVertex3f( Cam.x + static_cast<float>( Cam.fov * cos( Cam.a + c_pi / 4 ) ), Cam.y + static_cast<float>( Cam.fov * sin( Cam.a + c_pi / 4 ) ), 0 );
2185 glVertex3f( Cam.x, Cam.y, 0 );
2186 glVertex3f( Cam.x + static_cast<float>( Cam.fov * cos( Cam.a - c_pi / 4 ) ), Cam.y + static_cast<float>( Cam.fov * sin( Cam.a - c_pi / 4 ) ), 0 );
2189 XYWnd::DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) );
2191 glDisable( GL_BLEND );
2192 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
2195 glDrawBuffer( GL_BACK );
2196 GlobalOpenGL_debugAssertNoErrors();
2197 glwidget_make_current( m_gl_widget );
2203 float Betwixt( float f1, float f2 ){
2205 return f2 + ( ( f1 - f2 ) / 2 );
2208 return f1 + ( ( f2 - f1 ) / 2 );
2213 // can be greatly simplified but per usual i am in a hurry
2214 // which is not an excuse, just a fact
2215 void XYWnd::PaintSizeInfo( int nDim1, int nDim2, Vector3& vMinBounds, Vector3& vMaxBounds ){
2216 if ( vector3_equal( vMinBounds, vMaxBounds ) ) {
2219 const char* g_pDimStrings[] = {"x:", "y:", "z:"};
2220 typedef const char* OrgStrings[2];
2221 const OrgStrings g_pOrgStrings[] = { { "x:", "y:", }, { "x:", "z:", }, { "y:", "z:", } };
2223 Vector3 vSize( vector3_subtracted( vMaxBounds, vMinBounds ) );
2225 glColor3f( g_xywindow_globals.color_selbrushes[0] * .65f,
2226 g_xywindow_globals.color_selbrushes[1] * .65f,
2227 g_xywindow_globals.color_selbrushes[2] * .65f );
2229 StringOutputStream dimensions( 16 );
2231 if ( m_viewType == XY ) {
2232 glBegin( GL_LINES );
2234 glVertex3f( vMinBounds[nDim1], vMinBounds[nDim2] - 6.0f / m_fScale, 0.0f );
2235 glVertex3f( vMinBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale, 0.0f );
2237 glVertex3f( vMinBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale, 0.0f );
2238 glVertex3f( vMaxBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale, 0.0f );
2240 glVertex3f( vMaxBounds[nDim1], vMinBounds[nDim2] - 6.0f / m_fScale, 0.0f );
2241 glVertex3f( vMaxBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale, 0.0f );
2244 glVertex3f( vMaxBounds[nDim1] + 6.0f / m_fScale, vMinBounds[nDim2], 0.0f );
2245 glVertex3f( vMaxBounds[nDim1] + 10.0f / m_fScale, vMinBounds[nDim2], 0.0f );
2247 glVertex3f( vMaxBounds[nDim1] + 10.0f / m_fScale, vMinBounds[nDim2], 0.0f );
2248 glVertex3f( vMaxBounds[nDim1] + 10.0f / m_fScale, vMaxBounds[nDim2], 0.0f );
2250 glVertex3f( vMaxBounds[nDim1] + 6.0f / m_fScale, vMaxBounds[nDim2], 0.0f );
2251 glVertex3f( vMaxBounds[nDim1] + 10.0f / m_fScale, vMaxBounds[nDim2], 0.0f );
2255 glRasterPos3f( Betwixt( vMinBounds[nDim1], vMaxBounds[nDim1] ), vMinBounds[nDim2] - 20.0f / m_fScale, 0.0f );
2256 dimensions << g_pDimStrings[nDim1] << vSize[nDim1];
2257 GlobalOpenGL().drawString( dimensions.c_str() );
2260 glRasterPos3f( vMaxBounds[nDim1] + 16.0f / m_fScale, Betwixt( vMinBounds[nDim2], vMaxBounds[nDim2] ), 0.0f );
2261 dimensions << g_pDimStrings[nDim2] << vSize[nDim2];
2262 GlobalOpenGL().drawString( dimensions.c_str() );
2265 glRasterPos3f( vMinBounds[nDim1] + 4, vMaxBounds[nDim2] + 8 / m_fScale, 0.0f );
2266 dimensions << "(" << g_pOrgStrings[0][0] << vMinBounds[nDim1] << " " << g_pOrgStrings[0][1] << vMaxBounds[nDim2] << ")";
2267 GlobalOpenGL().drawString( dimensions.c_str() );
2269 else if ( m_viewType == XZ ) {
2270 glBegin( GL_LINES );
2272 glVertex3f( vMinBounds[nDim1], 0, vMinBounds[nDim2] - 6.0f / m_fScale );
2273 glVertex3f( vMinBounds[nDim1], 0, vMinBounds[nDim2] - 10.0f / m_fScale );
2275 glVertex3f( vMinBounds[nDim1], 0,vMinBounds[nDim2] - 10.0f / m_fScale );
2276 glVertex3f( vMaxBounds[nDim1], 0,vMinBounds[nDim2] - 10.0f / m_fScale );
2278 glVertex3f( vMaxBounds[nDim1], 0,vMinBounds[nDim2] - 6.0f / m_fScale );
2279 glVertex3f( vMaxBounds[nDim1], 0,vMinBounds[nDim2] - 10.0f / m_fScale );
2282 glVertex3f( vMaxBounds[nDim1] + 6.0f / m_fScale, 0,vMinBounds[nDim2] );
2283 glVertex3f( vMaxBounds[nDim1] + 10.0f / m_fScale, 0,vMinBounds[nDim2] );
2285 glVertex3f( vMaxBounds[nDim1] + 10.0f / m_fScale, 0,vMinBounds[nDim2] );
2286 glVertex3f( vMaxBounds[nDim1] + 10.0f / m_fScale, 0,vMaxBounds[nDim2] );
2288 glVertex3f( vMaxBounds[nDim1] + 6.0f / m_fScale, 0,vMaxBounds[nDim2] );
2289 glVertex3f( vMaxBounds[nDim1] + 10.0f / m_fScale, 0,vMaxBounds[nDim2] );
2293 glRasterPos3f( Betwixt( vMinBounds[nDim1], vMaxBounds[nDim1] ), 0, vMinBounds[nDim2] - 20.0f / m_fScale );
2294 dimensions << g_pDimStrings[nDim1] << vSize[nDim1];
2295 GlobalOpenGL().drawString( dimensions.c_str() );
2298 glRasterPos3f( vMaxBounds[nDim1] + 16.0f / m_fScale, 0, Betwixt( vMinBounds[nDim2], vMaxBounds[nDim2] ) );
2299 dimensions << g_pDimStrings[nDim2] << vSize[nDim2];
2300 GlobalOpenGL().drawString( dimensions.c_str() );
2303 glRasterPos3f( vMinBounds[nDim1] + 4, 0, vMaxBounds[nDim2] + 8 / m_fScale );
2304 dimensions << "(" << g_pOrgStrings[1][0] << vMinBounds[nDim1] << " " << g_pOrgStrings[1][1] << vMaxBounds[nDim2] << ")";
2305 GlobalOpenGL().drawString( dimensions.c_str() );
2309 glBegin( GL_LINES );
2311 glVertex3f( 0, vMinBounds[nDim1], vMinBounds[nDim2] - 6.0f / m_fScale );
2312 glVertex3f( 0, vMinBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale );
2314 glVertex3f( 0, vMinBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale );
2315 glVertex3f( 0, vMaxBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale );
2317 glVertex3f( 0, vMaxBounds[nDim1], vMinBounds[nDim2] - 6.0f / m_fScale );
2318 glVertex3f( 0, vMaxBounds[nDim1], vMinBounds[nDim2] - 10.0f / m_fScale );
2321 glVertex3f( 0, vMaxBounds[nDim1] + 6.0f / m_fScale, vMinBounds[nDim2] );
2322 glVertex3f( 0, vMaxBounds[nDim1] + 10.0f / m_fScale, vMinBounds[nDim2] );
2324 glVertex3f( 0, vMaxBounds[nDim1] + 10.0f / m_fScale, vMinBounds[nDim2] );
2325 glVertex3f( 0, vMaxBounds[nDim1] + 10.0f / m_fScale, vMaxBounds[nDim2] );
2327 glVertex3f( 0, vMaxBounds[nDim1] + 6.0f / m_fScale, vMaxBounds[nDim2] );
2328 glVertex3f( 0, vMaxBounds[nDim1] + 10.0f / m_fScale, vMaxBounds[nDim2] );
2332 glRasterPos3f( 0, Betwixt( vMinBounds[nDim1], vMaxBounds[nDim1] ), vMinBounds[nDim2] - 20.0f / m_fScale );
2333 dimensions << g_pDimStrings[nDim1] << vSize[nDim1];
2334 GlobalOpenGL().drawString( dimensions.c_str() );
2337 glRasterPos3f( 0, vMaxBounds[nDim1] + 16.0f / m_fScale, Betwixt( vMinBounds[nDim2], vMaxBounds[nDim2] ) );
2338 dimensions << g_pDimStrings[nDim2] << vSize[nDim2];
2339 GlobalOpenGL().drawString( dimensions.c_str() );
2342 glRasterPos3f( 0, vMinBounds[nDim1] + 4.0f, vMaxBounds[nDim2] + 8 / m_fScale );
2343 dimensions << "(" << g_pOrgStrings[2][0] << vMinBounds[nDim1] << " " << g_pOrgStrings[2][1] << vMaxBounds[nDim2] << ")";
2344 GlobalOpenGL().drawString( dimensions.c_str() );
2348 class XYRenderer : public Renderer
2356 unsigned int m_highlight;
2360 XYRenderer( RenderStateFlags globalstate, Shader* selected ) :
2361 m_globalstate( globalstate ),
2362 m_state_selected( selected ){
2363 ASSERT_NOTNULL( selected );
2364 m_state_stack.push_back( state_type() );
2367 void SetState( Shader* state, EStyle style ){
2368 ASSERT_NOTNULL( state );
2369 if ( style == eWireframeOnly ) {
2370 m_state_stack.back().m_state = state;
2373 const EStyle getStyle() const {
2374 return eWireframeOnly;
2377 m_state_stack.push_back( m_state_stack.back() );
2380 ASSERT_MESSAGE( !m_state_stack.empty(), "popping empty stack" );
2381 m_state_stack.pop_back();
2383 void Highlight( EHighlightMode mode, bool bEnable = true ){
2385 ? m_state_stack.back().m_highlight |= mode
2386 : m_state_stack.back().m_highlight &= ~mode;
2388 void addRenderable( const OpenGLRenderable& renderable, const Matrix4& localToWorld ){
2389 if ( m_state_stack.back().m_highlight & ePrimitive ) {
2390 m_state_selected->addRenderable( renderable, localToWorld );
2394 m_state_stack.back().m_state->addRenderable( renderable, localToWorld );
2398 void render( const Matrix4& modelview, const Matrix4& projection ){
2399 GlobalShaderCache().render( m_globalstate, modelview, projection );
2402 std::vector<state_type> m_state_stack;
2403 RenderStateFlags m_globalstate;
2404 Shader* m_state_selected;
2407 void XYWnd::updateProjection(){
2408 m_projection[0] = 1.0f / static_cast<float>( m_nWidth / 2 );
2409 m_projection[5] = 1.0f / static_cast<float>( m_nHeight / 2 );
2410 m_projection[10] = 1.0f / ( g_MaxWorldCoord * m_fScale );
2412 m_projection[12] = 0.0f;
2413 m_projection[13] = 0.0f;
2414 m_projection[14] = -1.0f;
2426 m_projection[11] = 0.0f;
2428 m_projection[15] = 1.0f;
2430 m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight );
2433 // note: modelview matrix must have a uniform scale, otherwise strange things happen when rendering the rotation manipulator.
2434 void XYWnd::updateModelview(){
2435 int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
2436 int nDim2 = ( m_viewType == XY ) ? 1 : 2;
2439 m_modelview[12] = -m_vOrigin[nDim1] * m_fScale;
2440 m_modelview[13] = -m_vOrigin[nDim2] * m_fScale;
2441 m_modelview[14] = g_MaxWorldCoord * m_fScale;
2444 switch ( m_viewType )
2447 m_modelview[0] = m_fScale;
2452 m_modelview[5] = m_fScale;
2457 m_modelview[10] = -m_fScale;
2460 m_modelview[0] = m_fScale;
2466 m_modelview[6] = m_fScale;
2469 m_modelview[9] = m_fScale;
2470 m_modelview[10] = 0;
2475 m_modelview[2] = -m_fScale;
2477 m_modelview[4] = m_fScale;
2482 m_modelview[9] = m_fScale;
2483 m_modelview[10] = 0;
2487 m_modelview[3] = m_modelview[7] = m_modelview[11] = 0;
2488 m_modelview[15] = 1;
2490 m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight );
2499 //#define DBG_SCENEDUMP
2501 void XYWnd::XY_Draw(){
2505 glViewport( 0, 0, m_nWidth, m_nHeight );
2506 glClearColor( g_xywindow_globals.color_gridback[0],
2507 g_xywindow_globals.color_gridback[1],
2508 g_xywindow_globals.color_gridback[2],0 );
2510 glClear( GL_COLOR_BUFFER_BIT );
2516 glMatrixMode( GL_PROJECTION );
2517 glLoadMatrixf( reinterpret_cast<const float*>( &m_projection ) );
2519 glMatrixMode( GL_MODELVIEW );
2521 glScalef( m_fScale, m_fScale, 1 );
2522 int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
2523 int nDim2 = ( m_viewType == XY ) ? 1 : 2;
2524 glTranslatef( -m_vOrigin[nDim1], -m_vOrigin[nDim2], 0 );
2526 glDisable( GL_LINE_STIPPLE );
2528 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
2529 glDisableClientState( GL_NORMAL_ARRAY );
2530 glDisableClientState( GL_COLOR_ARRAY );
2531 glDisable( GL_TEXTURE_2D );
2532 glDisable( GL_LIGHTING );
2533 glDisable( GL_COLOR_MATERIAL );
2534 glDisable( GL_DEPTH_TEST );
2536 if ( m_backgroundActivated ) {
2537 XY_DrawBackground();
2541 if ( g_xywindow_globals_private.show_blocks ) {
2545 glLoadMatrixf( reinterpret_cast<const float*>( &m_modelview ) );
2547 unsigned int globalstate = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_POLYGONSMOOTH | RENDER_LINESMOOTH;
2548 if ( !g_xywindow_globals.m_bNoStipple ) {
2549 globalstate |= RENDER_LINESTIPPLE;
2553 XYRenderer renderer( globalstate, m_state_selected );
2555 Scene_Render( renderer, m_view );
2557 GlobalOpenGL_debugAssertNoErrors();
2558 renderer.render( m_modelview, m_projection );
2559 GlobalOpenGL_debugAssertNoErrors();
2562 glDepthMask( GL_FALSE );
2564 GlobalOpenGL_debugAssertNoErrors();
2566 glLoadMatrixf( reinterpret_cast<const float*>( &m_modelview ) );
2568 GlobalOpenGL_debugAssertNoErrors();
2569 glDisable( GL_LINE_STIPPLE );
2570 GlobalOpenGL_debugAssertNoErrors();
2572 GlobalOpenGL_debugAssertNoErrors();
2573 if ( GlobalOpenGL().GL_1_3() ) {
2574 glActiveTexture( GL_TEXTURE0 );
2575 glClientActiveTexture( GL_TEXTURE0 );
2577 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
2578 GlobalOpenGL_debugAssertNoErrors();
2579 glDisableClientState( GL_NORMAL_ARRAY );
2580 GlobalOpenGL_debugAssertNoErrors();
2581 glDisableClientState( GL_COLOR_ARRAY );
2582 GlobalOpenGL_debugAssertNoErrors();
2583 glDisable( GL_TEXTURE_2D );
2584 GlobalOpenGL_debugAssertNoErrors();
2585 glDisable( GL_LIGHTING );
2586 GlobalOpenGL_debugAssertNoErrors();
2587 glDisable( GL_COLOR_MATERIAL );
2588 GlobalOpenGL_debugAssertNoErrors();
2590 GlobalOpenGL_debugAssertNoErrors();
2594 if ( g_xywindow_globals_private.m_bSizePaint && GlobalSelectionSystem().countSelected() != 0 ) {
2596 Select_GetBounds( min, max );
2597 PaintSizeInfo( nDim1, nDim2, min, max );
2600 if ( g_bCrossHairs ) {
2601 glColor4f( 0.2f, 0.9f, 0.2f, 0.8f );
2602 glBegin( GL_LINES );
2603 if ( m_viewType == XY ) {
2604 glVertex2f( 2.0f * g_MinWorldCoord, m_mousePosition[1] );
2605 glVertex2f( 2.0f * g_MaxWorldCoord, m_mousePosition[1] );
2606 glVertex2f( m_mousePosition[0], 2.0f * g_MinWorldCoord );
2607 glVertex2f( m_mousePosition[0], 2.0f * g_MaxWorldCoord );
2609 else if ( m_viewType == YZ ) {
2610 glVertex3f( m_mousePosition[0], 2.0f * g_MinWorldCoord, m_mousePosition[2] );
2611 glVertex3f( m_mousePosition[0], 2.0f * g_MaxWorldCoord, m_mousePosition[2] );
2612 glVertex3f( m_mousePosition[0], m_mousePosition[1], 2.0f * g_MinWorldCoord );
2613 glVertex3f( m_mousePosition[0], m_mousePosition[1], 2.0f * g_MaxWorldCoord );
2617 glVertex3f( 2.0f * g_MinWorldCoord, m_mousePosition[1], m_mousePosition[2] );
2618 glVertex3f( 2.0f * g_MaxWorldCoord, m_mousePosition[1], m_mousePosition[2] );
2619 glVertex3f( m_mousePosition[0], m_mousePosition[1], 2.0f * g_MinWorldCoord );
2620 glVertex3f( m_mousePosition[0], m_mousePosition[1], 2.0f * g_MaxWorldCoord );
2626 GlobalClipPoints_Draw( m_fScale );
2629 GlobalOpenGL_debugAssertNoErrors();
2633 glScalef( m_fScale, m_fScale, 1 );
2634 glTranslatef( -m_vOrigin[nDim1], -m_vOrigin[nDim2], 0 );
2636 glEnable( GL_BLEND );
2637 glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
2638 DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) );
2639 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
2640 glDisable( GL_BLEND );
2642 Feedback_draw2D( m_viewType );
2644 if ( g_xywindow_globals_private.show_outline ) {
2646 glMatrixMode( GL_PROJECTION );
2648 glOrtho( 0, m_nWidth, 0, m_nHeight, 0, 1 );
2650 glMatrixMode( GL_MODELVIEW );
2653 // four view mode doesn't colorize
2654 if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) {
2655 glColor3fv( vector3_to_array( g_xywindow_globals.color_viewname ) );
2659 switch ( m_viewType )
2662 glColor3fv( vector3_to_array( g_xywindow_globals.AxisColorX ) );
2665 glColor3fv( vector3_to_array( g_xywindow_globals.AxisColorY ) );
2668 glColor3fv( vector3_to_array( g_xywindow_globals.AxisColorZ ) );
2672 glBegin( GL_LINE_LOOP );
2673 glVertex2f( 0.5, 0.5 );
2674 glVertex2f( m_nWidth - 0.5, 1 );
2675 glVertex2f( m_nWidth - 0.5, m_nHeight - 0.5 );
2676 glVertex2f( 0.5, m_nHeight - 0.5 );
2681 GlobalOpenGL_debugAssertNoErrors();
2686 void XYWnd_MouseToPoint( XYWnd* xywnd, int x, int y, Vector3& point ){
2687 xywnd->XY_ToPoint( x, y, point );
2688 xywnd->XY_SnapToGrid( point );
2690 int nDim = ( xywnd->GetViewType() == XY ) ? 2 : ( xywnd->GetViewType() == YZ ) ? 0 : 1;
2691 float fWorkMid = float_mid( Select_getWorkZone().d_work_min[nDim], Select_getWorkZone().d_work_max[nDim] );
2692 point[nDim] = float_snapped( fWorkMid, GetGridSize() );
2695 void XYWnd::OnEntityCreate( const char* item ){
2696 StringOutputStream command;
2697 command << "entityCreate -class " << item;
2698 UndoableCommand undo( command.c_str() );
2700 XYWnd_MouseToPoint( this, m_entityCreate_x, m_entityCreate_y, point );
2701 Entity_createFromSelection( item, point );
2706 void GetFocusPosition( Vector3& position ){
2707 if ( GlobalSelectionSystem().countSelected() != 0 ) {
2708 Select_GetMid( position );
2712 position = Camera_getOrigin( *g_pParentWnd->GetCamWnd() );
2716 void XYWnd_Focus( XYWnd* xywnd ){
2718 GetFocusPosition( position );
2719 xywnd->PositionView( position );
2722 void XY_Split_Focus(){
2724 GetFocusPosition( position );
2725 if ( g_pParentWnd->GetXYWnd() ) {
2726 g_pParentWnd->GetXYWnd()->PositionView( position );
2728 if ( g_pParentWnd->GetXZWnd() ) {
2729 g_pParentWnd->GetXZWnd()->PositionView( position );
2731 if ( g_pParentWnd->GetYZWnd() ) {
2732 g_pParentWnd->GetYZWnd()->PositionView( position );
2737 if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) {
2738 // cannot do this in a split window
2739 // do something else that the user may want here
2744 XYWnd* xywnd = g_pParentWnd->GetXYWnd();
2745 XYWnd_Focus( xywnd );
2748 void XY_TopFrontSide( VIEWTYPE viewtype ){
2749 if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) {
2750 // cannot do this in a split window
2751 // do something else that the user may want here
2755 XYWnd* xywnd = g_pParentWnd->CurrentStyle() == MainFrame::eFloating ? g_pParentWnd->ActiveXY() : g_pParentWnd->GetXYWnd();
2756 xywnd->SetViewType( viewtype );
2757 XYWnd_Focus( xywnd );
2761 XY_TopFrontSide( XY );
2765 XY_TopFrontSide( XZ );
2769 XY_TopFrontSide( YZ );
2772 void XY_NextView( XYWnd* xywnd ){
2773 if ( xywnd->GetViewType() == XY ) {
2774 xywnd->SetViewType( XZ );
2776 else if ( xywnd->GetViewType() == XZ ) {
2777 xywnd->SetViewType( YZ );
2780 xywnd->SetViewType( XY );
2782 XYWnd_Focus( xywnd );
2786 if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) {
2787 // cannot do this in a split window
2788 // do something else that the user may want here
2792 XYWnd* xywnd = g_pParentWnd->CurrentStyle() == MainFrame::eFloating ? g_pParentWnd->ActiveXY() : g_pParentWnd->GetXYWnd();
2793 XY_NextView( xywnd );
2797 if ( g_pParentWnd->GetXYWnd() ) {
2798 g_pParentWnd->GetXYWnd()->SetScale( 1 );
2800 if ( g_pParentWnd->GetXZWnd() ) {
2801 g_pParentWnd->GetXZWnd()->SetScale( 1 );
2803 if ( g_pParentWnd->GetYZWnd() ) {
2804 g_pParentWnd->GetYZWnd()->SetScale( 1 );
2809 g_pParentWnd->ActiveXY()->ZoomIn();
2812 // NOTE: the zoom out factor is 4/5, we could think about customizing it
2813 // we don't go below a zoom factor corresponding to 10% of the max world size
2814 // (this has to be computed against the window size)
2816 g_pParentWnd->ActiveXY()->ZoomOut();
2821 ToggleShown g_xy_top_shown( true );
2823 void XY_Top_Shown_Construct( GtkWindow* parent ){
2824 g_xy_top_shown.connect( GTK_WIDGET( parent ) );
2827 ToggleShown g_yz_side_shown( false );
2829 void YZ_Side_Shown_Construct( GtkWindow* parent ){
2830 g_yz_side_shown.connect( GTK_WIDGET( parent ) );
2833 ToggleShown g_xz_front_shown( false );
2835 void XZ_Front_Shown_Construct( GtkWindow* parent ){
2836 g_xz_front_shown.connect( GTK_WIDGET( parent ) );
2840 class EntityClassMenu : public ModuleObserver
2842 std::size_t m_unrealised;
2844 EntityClassMenu() : m_unrealised( 1 ){
2847 if ( --m_unrealised == 0 ) {
2851 if ( ++m_unrealised == 1 ) {
2852 if ( XYWnd::m_mnuDrop != 0 ) {
2853 gtk_widget_destroy( GTK_WIDGET( XYWnd::m_mnuDrop ) );
2854 XYWnd::m_mnuDrop = 0;
2860 EntityClassMenu g_EntityClassMenu;
2865 void ShowNamesExport( const BoolImportCallback& importer ){
2866 importer( GlobalEntityCreator().getShowNames() );
2868 typedef FreeCaller1<const BoolImportCallback&, ShowNamesExport> ShowNamesExportCaller;
2869 ShowNamesExportCaller g_show_names_caller;
2870 ToggleItem g_show_names( g_show_names_caller );
2871 void ShowNamesToggle(){
2872 GlobalEntityCreator().setShowNames( !GlobalEntityCreator().getShowNames() );
2873 g_show_names.update();
2874 XY_UpdateAllWindows();
2877 void ShowTargetNamesExport( const BoolImportCallback& importer ){
2878 importer( GlobalEntityCreator().getShowTargetNames() );
2880 typedef FreeCaller1<const BoolImportCallback&, ShowTargetNamesExport> ShowTargetNamesExportCaller;
2881 ShowTargetNamesExportCaller g_show_targetnames_caller;
2882 ToggleItem g_show_targetnames( g_show_targetnames_caller );
2883 void ShowTargetNamesToggle(){
2884 GlobalEntityCreator().setShowTargetNames( !GlobalEntityCreator().getShowTargetNames() );
2885 g_show_targetnames.update();
2886 XY_UpdateAllWindows();
2889 void ShowAnglesExport( const BoolImportCallback& importer ){
2890 importer( GlobalEntityCreator().getShowAngles() );
2892 typedef FreeCaller1<const BoolImportCallback&, ShowAnglesExport> ShowAnglesExportCaller;
2893 ShowAnglesExportCaller g_show_angles_caller;
2894 ToggleItem g_show_angles( g_show_angles_caller );
2895 void ShowAnglesToggle(){
2896 GlobalEntityCreator().setShowAngles( !GlobalEntityCreator().getShowAngles() );
2897 g_show_angles.update();
2898 XY_UpdateAllWindows();
2901 BoolExportCaller g_show_blocks_caller( g_xywindow_globals_private.show_blocks );
2902 ToggleItem g_show_blocks( g_show_blocks_caller );
2903 void ShowBlocksToggle(){
2904 g_xywindow_globals_private.show_blocks ^= 1;
2905 g_show_blocks.update();
2906 XY_UpdateAllWindows();
2909 BoolExportCaller g_show_coordinates_caller( g_xywindow_globals_private.show_coordinates );
2910 ToggleItem g_show_coordinates( g_show_coordinates_caller );
2911 void ShowCoordinatesToggle(){
2912 g_xywindow_globals_private.show_coordinates ^= 1;
2913 g_show_coordinates.update();
2914 XY_UpdateAllWindows();
2917 BoolExportCaller g_show_outline_caller( g_xywindow_globals_private.show_outline );
2918 ToggleItem g_show_outline( g_show_outline_caller );
2919 void ShowOutlineToggle(){
2920 g_xywindow_globals_private.show_outline ^= 1;
2921 g_show_outline.update();
2922 XY_UpdateAllWindows();
2925 BoolExportCaller g_show_axes_caller( g_xywindow_globals_private.show_axis );
2926 ToggleItem g_show_axes( g_show_axes_caller );
2927 void ShowAxesToggle(){
2928 g_xywindow_globals_private.show_axis ^= 1;
2929 g_show_axes.update();
2930 XY_UpdateAllWindows();
2934 BoolExportCaller g_show_workzone_caller( g_xywindow_globals_private.d_show_work );
2935 ToggleItem g_show_workzone( g_show_workzone_caller );
2936 void ShowWorkzoneToggle(){
2937 g_xywindow_globals_private.d_show_work ^= 1;
2938 g_show_workzone.update();
2939 XY_UpdateAllWindows();
2943 void ShowAxesToggle(){
2944 g_xywindow_globals_private.show_axis ^= 1;
2945 XY_UpdateAllWindows();
2947 typedef FreeCaller<ShowAxesToggle> ShowAxesToggleCaller;
2948 void ShowAxesExport( const BoolImportCallback& importer ){
2949 importer( g_xywindow_globals_private.show_axis );
2951 typedef FreeCaller1<const BoolImportCallback&, ShowAxesExport> ShowAxesExportCaller;
2953 ShowAxesExportCaller g_show_axes_caller;
2954 BoolExportCallback g_show_axes_callback( g_show_axes_caller );
2955 ToggleItem g_show_axes( g_show_axes_callback );
2959 BoolExportCaller g_texdef_movelock_caller( g_brush_texturelock_enabled );
2960 ToggleItem g_texdef_movelock_item( g_texdef_movelock_caller );
2962 void Texdef_ToggleMoveLock(){
2963 g_brush_texturelock_enabled = !g_brush_texturelock_enabled;
2964 g_texdef_movelock_item.update();
2968 BoolExportCaller g_show_size_caller( g_xywindow_globals_private.m_bSizePaint );
2969 ToggleItem g_show_size_item( g_show_size_caller );
2970 void ToggleShowSizeInfo(){
2971 g_xywindow_globals_private.m_bSizePaint = !g_xywindow_globals_private.m_bSizePaint;
2972 g_show_size_item.update();
2973 XY_UpdateAllWindows();
2976 BoolExportCaller g_show_crosshair_caller( g_bCrossHairs );
2977 ToggleItem g_show_crosshair_item( g_show_crosshair_caller );
2978 void ToggleShowCrosshair(){
2980 g_show_crosshair_item.update();
2981 XY_UpdateAllWindows();
2984 BoolExportCaller g_show_grid_caller( g_xywindow_globals_private.d_showgrid );
2985 ToggleItem g_show_grid_item( g_show_grid_caller );
2986 void ToggleShowGrid(){
2987 g_xywindow_globals_private.d_showgrid = !g_xywindow_globals_private.d_showgrid;
2988 g_show_grid_item.update();
2989 XY_UpdateAllWindows();
2993 void XYShow_registerCommands(){
2994 GlobalToggles_insert( "ToggleSizePaint", FreeCaller<ToggleShowSizeInfo>(), ToggleItem::AddCallbackCaller( g_show_size_item ), Accelerator( 'J' ) );
2995 GlobalToggles_insert( "ToggleCrosshairs", FreeCaller<ToggleShowCrosshair>(), ToggleItem::AddCallbackCaller( g_show_crosshair_item ), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
2996 GlobalToggles_insert( "ToggleGrid", FreeCaller<ToggleShowGrid>(), ToggleItem::AddCallbackCaller( g_show_grid_item ), Accelerator( '0' ) );
2998 GlobalToggles_insert( "ShowAngles", FreeCaller<ShowAnglesToggle>(), ToggleItem::AddCallbackCaller( g_show_angles ) );
2999 GlobalToggles_insert( "ShowNames", FreeCaller<ShowNamesToggle>(), ToggleItem::AddCallbackCaller( g_show_names ) );
3000 GlobalToggles_insert( "ShowTargetNames", FreeCaller<ShowTargetNamesToggle>(), ToggleItem::AddCallbackCaller( g_show_targetnames ) );
3001 GlobalToggles_insert( "ShowBlocks", FreeCaller<ShowBlocksToggle>(), ToggleItem::AddCallbackCaller( g_show_blocks ) );
3002 GlobalToggles_insert( "ShowCoordinates", FreeCaller<ShowCoordinatesToggle>(), ToggleItem::AddCallbackCaller( g_show_coordinates ) );
3003 GlobalToggles_insert( "ShowWindowOutline", FreeCaller<ShowOutlineToggle>(), ToggleItem::AddCallbackCaller( g_show_outline ) );
3004 GlobalToggles_insert( "ShowAxes", FreeCaller<ShowAxesToggle>(), ToggleItem::AddCallbackCaller( g_show_axes ) );
3005 GlobalToggles_insert( "ShowWorkzone", FreeCaller<ShowWorkzoneToggle>(), ToggleItem::AddCallbackCaller( g_show_workzone ) );
3008 void XYWnd_registerShortcuts(){
3009 command_connect_accelerator( "ToggleCrosshairs" );
3010 command_connect_accelerator( "ToggleSizePaint" );
3015 void Orthographic_constructPreferences( PreferencesPage& page ){
3016 page.appendCheckBox( "", "Solid selection boxes ( no stipple )", g_xywindow_globals.m_bNoStipple );
3017 //page.appendCheckBox( "", "Display size info", g_xywindow_globals_private.m_bSizePaint );
3018 page.appendCheckBox( "", "Chase mouse during drags", g_xywindow_globals_private.m_bChaseMouse );
3019 // page.appendCheckBox( "", "Update views on camera move", g_xywindow_globals_private.m_bCamXYUpdate );
3020 page.appendCheckBox( "", "Zoom In to Mouse pointer", g_xywindow_globals.m_bZoomInToPointer );
3022 void Orthographic_constructPage( PreferenceGroup& group ){
3023 PreferencesPage page( group.createPage( "Orthographic", "Orthographic View Preferences" ) );
3024 Orthographic_constructPreferences( page );
3026 void Orthographic_registerPreferencesPage(){
3027 PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Orthographic_constructPage>() );
3030 void Clipper_constructPreferences( PreferencesPage& page ){
3031 page.appendCheckBox( "", "Clipper tool uses caulk", g_clip_useCaulk );
3033 void Clipper_constructPage( PreferenceGroup& group ){
3034 PreferencesPage page( group.createPage( "Clipper", "Clipper Tool Settings" ) );
3035 Clipper_constructPreferences( page );
3037 void Clipper_registerPreferencesPage(){
3038 PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Clipper_constructPage>() );
3042 #include "preferencesystem.h"
3043 #include "stringio.h"
3048 void ToggleShown_importBool( ToggleShown& self, bool value ){
3051 typedef ReferenceCaller1<ToggleShown, bool, ToggleShown_importBool> ToggleShownImportBoolCaller;
3052 void ToggleShown_exportBool( const ToggleShown& self, const BoolImportCallback& importer ){
3053 importer( self.active() );
3055 typedef ConstReferenceCaller1<ToggleShown, const BoolImportCallback&, ToggleShown_exportBool> ToggleShownExportBoolCaller;
3058 void XYWindow_Construct(){
3059 // GlobalCommands_insert( "ToggleCrosshairs", FreeCaller<ToggleShowCrosshair>(), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
3060 // GlobalCommands_insert( "ToggleSizePaint", FreeCaller<ToggleShowSizeInfo>(), Accelerator( 'J' ) );
3061 // GlobalCommands_insert( "ToggleGrid", FreeCaller<ToggleShowGrid>(), Accelerator( '0' ) );
3063 GlobalToggles_insert( "ToggleView", ToggleShown::ToggleCaller( g_xy_top_shown ), ToggleItem::AddCallbackCaller( g_xy_top_shown.m_item ), Accelerator( 'V', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
3064 GlobalToggles_insert( "ToggleSideView", ToggleShown::ToggleCaller( g_yz_side_shown ), ToggleItem::AddCallbackCaller( g_yz_side_shown.m_item ) );
3065 GlobalToggles_insert( "ToggleFrontView", ToggleShown::ToggleCaller( g_xz_front_shown ), ToggleItem::AddCallbackCaller( g_xz_front_shown.m_item ) );
3066 GlobalCommands_insert( "NextView", FreeCaller<XY_Next>(), Accelerator( GDK_Tab, (GdkModifierType)GDK_CONTROL_MASK ) );
3067 GlobalCommands_insert( "ZoomIn", FreeCaller<XY_ZoomIn>(), Accelerator( GDK_Delete ) );
3068 GlobalCommands_insert( "ZoomOut", FreeCaller<XY_ZoomOut>(), Accelerator( GDK_Insert ) );
3069 GlobalCommands_insert( "ViewTop", FreeCaller<XY_Top>(), Accelerator( GDK_KP_Home ) );
3070 GlobalCommands_insert( "ViewSide", FreeCaller<XY_Side>(), Accelerator( GDK_KP_Page_Down ) );
3071 GlobalCommands_insert( "ViewFront", FreeCaller<XY_Front>(), Accelerator( GDK_KP_End ) );
3072 GlobalCommands_insert( "Zoom100", FreeCaller<XY_Zoom100>() );
3073 GlobalCommands_insert( "CenterXYView", FreeCaller<XY_Focus>(), Accelerator( GDK_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
3075 GlobalPreferenceSystem().registerPreference( "ClipCaulk", BoolImportStringCaller( g_clip_useCaulk ), BoolExportStringCaller( g_clip_useCaulk ) );
3077 // GlobalPreferenceSystem().registerPreference( "NewRightClick", BoolImportStringCaller( g_xywindow_globals.m_bRightClick ), BoolExportStringCaller( g_xywindow_globals.m_bRightClick ) );
3078 GlobalPreferenceSystem().registerPreference( "2DZoomInToPointer", BoolImportStringCaller( g_xywindow_globals.m_bZoomInToPointer ), BoolExportStringCaller( g_xywindow_globals.m_bZoomInToPointer ) );
3079 GlobalPreferenceSystem().registerPreference( "ChaseMouse", BoolImportStringCaller( g_xywindow_globals_private.m_bChaseMouse ), BoolExportStringCaller( g_xywindow_globals_private.m_bChaseMouse ) );
3080 GlobalPreferenceSystem().registerPreference( "SizePainting", BoolImportStringCaller( g_xywindow_globals_private.m_bSizePaint ), BoolExportStringCaller( g_xywindow_globals_private.m_bSizePaint ) );
3081 GlobalPreferenceSystem().registerPreference( "ShowCrosshair", BoolImportStringCaller( g_bCrossHairs ), BoolExportStringCaller( g_bCrossHairs ) );
3082 GlobalPreferenceSystem().registerPreference( "NoStipple", BoolImportStringCaller( g_xywindow_globals.m_bNoStipple ), BoolExportStringCaller( g_xywindow_globals.m_bNoStipple ) );
3083 GlobalPreferenceSystem().registerPreference( "SI_ShowCoords", BoolImportStringCaller( g_xywindow_globals_private.show_coordinates ), BoolExportStringCaller( g_xywindow_globals_private.show_coordinates ) );
3084 GlobalPreferenceSystem().registerPreference( "SI_ShowOutlines", BoolImportStringCaller( g_xywindow_globals_private.show_outline ), BoolExportStringCaller( g_xywindow_globals_private.show_outline ) );
3085 GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", BoolImportStringCaller( g_xywindow_globals_private.show_axis ), BoolExportStringCaller( g_xywindow_globals_private.show_axis ) );
3086 // GlobalPreferenceSystem().registerPreference( "CamXYUpdate", BoolImportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ), BoolExportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ) );
3087 GlobalPreferenceSystem().registerPreference( "ShowWorkzone", BoolImportStringCaller( g_xywindow_globals_private.d_show_work ), BoolExportStringCaller( g_xywindow_globals_private.d_show_work ) );
3089 GlobalPreferenceSystem().registerPreference( "SI_AxisColors0", Vector3ImportStringCaller( g_xywindow_globals.AxisColorX ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorX ) );
3090 GlobalPreferenceSystem().registerPreference( "SI_AxisColors1", Vector3ImportStringCaller( g_xywindow_globals.AxisColorY ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorY ) );
3091 GlobalPreferenceSystem().registerPreference( "SI_AxisColors2", Vector3ImportStringCaller( g_xywindow_globals.AxisColorZ ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorZ ) );
3092 GlobalPreferenceSystem().registerPreference( "SI_Colors1", Vector3ImportStringCaller( g_xywindow_globals.color_gridback ), Vector3ExportStringCaller( g_xywindow_globals.color_gridback ) );
3093 GlobalPreferenceSystem().registerPreference( "SI_Colors2", Vector3ImportStringCaller( g_xywindow_globals.color_gridminor ), Vector3ExportStringCaller( g_xywindow_globals.color_gridminor ) );
3094 GlobalPreferenceSystem().registerPreference( "SI_Colors3", Vector3ImportStringCaller( g_xywindow_globals.color_gridmajor ), Vector3ExportStringCaller( g_xywindow_globals.color_gridmajor ) );
3095 GlobalPreferenceSystem().registerPreference( "SI_Colors6", Vector3ImportStringCaller( g_xywindow_globals.color_gridblock ), Vector3ExportStringCaller( g_xywindow_globals.color_gridblock ) );
3096 GlobalPreferenceSystem().registerPreference( "SI_Colors7", Vector3ImportStringCaller( g_xywindow_globals.color_gridtext ), Vector3ExportStringCaller( g_xywindow_globals.color_gridtext ) );
3097 GlobalPreferenceSystem().registerPreference( "SI_Colors8", Vector3ImportStringCaller( g_xywindow_globals.color_brushes ), Vector3ExportStringCaller( g_xywindow_globals.color_brushes ) );
3098 GlobalPreferenceSystem().registerPreference( "SI_Colors9", Vector3ImportStringCaller( g_xywindow_globals.color_viewname ), Vector3ExportStringCaller( g_xywindow_globals.color_viewname ) );
3099 GlobalPreferenceSystem().registerPreference( "SI_Colors10", Vector3ImportStringCaller( g_xywindow_globals.color_clipper ), Vector3ExportStringCaller( g_xywindow_globals.color_clipper ) );
3100 GlobalPreferenceSystem().registerPreference( "SI_Colors11", Vector3ImportStringCaller( g_xywindow_globals.color_selbrushes ), Vector3ExportStringCaller( g_xywindow_globals.color_selbrushes ) );
3103 GlobalPreferenceSystem().registerPreference( "XZVIS", makeBoolStringImportCallback( ToggleShownImportBoolCaller( g_xz_front_shown ) ), makeBoolStringExportCallback( ToggleShownExportBoolCaller( g_xz_front_shown ) ) );
3104 GlobalPreferenceSystem().registerPreference( "YZVIS", makeBoolStringImportCallback( ToggleShownImportBoolCaller( g_yz_side_shown ) ), makeBoolStringExportCallback( ToggleShownExportBoolCaller( g_yz_side_shown ) ) );
3106 Orthographic_registerPreferencesPage();
3107 Clipper_registerPreferencesPage();
3109 XYWnd::captureStates();
3110 GlobalEntityClassManager().attach( g_EntityClassMenu );
3113 void XYWindow_Destroy(){
3114 GlobalEntityClassManager().detach( g_EntityClassMenu );
3115 XYWnd::releaseStates();