2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
\r
5 This file is part of GtkRadiant.
\r
7 GtkRadiant is free software; you can redistribute it and/or modify
\r
8 it under the terms of the GNU General Public License as published by
\r
9 the Free Software Foundation; either version 2 of the License, or
\r
10 (at your option) any later version.
\r
12 GtkRadiant is distributed in the hope that it will be useful,
\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 GNU General Public License for more details.
\r
17 You should have received a copy of the GNU General Public License
\r
18 along with GtkRadiant; if not, write to the Free Software
\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\r
23 Camera plugin for GtkRadiant
\r
24 Copyright (C) 2002 Splash Damage Ltd.
\r
29 CListener::CListener()
\r
35 m_bLeftMBPressed = m_bRightMBPressed = m_bMiddleMBPressed = false;
\r
42 CListener::~CListener()
\r
47 void CListener::Register()
\r
49 g_UITable.m_pfnHookWindow( this );
\r
50 g_pXYWndWrapper = g_UITable.m_pfnGetXYWndWrapper();
\r
54 void CListener::UnRegister()
\r
58 g_UITable.m_pfnUnHookWindow( this );
\r
59 g_pXYWndWrapper= NULL;
\r
64 bool CListener::OnMouseMove( guint32 nFlags, gdouble x, gdouble y )
\r
66 SetViewType( g_pXYWndWrapper->GetViewType() );
\r
68 if( m_bLeftMBPressed && oldValid && g_iEditMode == 0 ) {
\r
69 vec3_t click, delta;
\r
71 g_pXYWndWrapper->SnapToGrid( (int)x, (int)y, click );
\r
75 VectorSet( delta, click[0] - old_x, click[1] - old_y, 0 );
\r
76 old_x = click[0]; old_y = click[1];
\r
79 VectorSet( delta, click[0] - old_x, 0, click[2] - old_y );
\r
80 old_x = click[0]; old_y = click[2];
\r
83 VectorSet( delta, 0, click[1] - old_x, click[2] - old_y );
\r
84 old_x = click[1]; old_y = click[2];
\r
88 if( g_iActiveTarget < 0 )
\r
89 GetCurrentCam()->GetCam()->getPositionObj()->updateSelection( delta[0], delta[1], delta[2] );
\r
91 GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->updateSelection( delta[0], delta[1], delta[2] );
\r
93 GetCurrentCam()->HasBeenModified();
\r
95 g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
\r
103 bool CListener::OnLButtonDown( guint32 nFlags, gdouble x, gdouble y )
\r
105 SetViewType( g_pXYWndWrapper->GetViewType() );
\r
107 m_bLeftMBPressed = true;
\r
112 g_pXYWndWrapper->SnapToGrid( (int)x, (int)y, org );
\r
116 old_x = org[0]; old_y = org[1]; org[2] = 64*1024;
\r
117 VectorSet( delta, 0, 0, -1 );
\r
120 old_x = org[0]; old_y = org[2]; org[1] = 64*1024;
\r
121 VectorSet( delta, 0, -1, 0 );
\r
124 old_x = org[1]; old_y = org[2]; org[0] = 64*1024;
\r
125 VectorSet( delta, -1, 0, 0 );
\r
129 if( g_iEditMode == 0 ) {
\r
130 if( g_iActiveTarget < 0 )
\r
131 GetCurrentCam()->GetCam()->getPositionObj()->selectPointByRay( org[0], org[1], org[2], delta[0], delta[1], delta[2], true );
\r
133 GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->selectPointByRay( org[0], org[1], org[2], delta[0], delta[1], delta[2], true );
\r
134 } else if( g_iEditMode == 1 ) {
\r
136 idCameraPosition *camera;
\r
138 if( g_iActiveTarget < 0 ) {
\r
139 camera = GetCurrentCam()->GetCam()->getPositionObj();
\r
141 camera = GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget);
\r
144 if( camera->numPoints() ) {
\r
145 lastcoord = camera->getPoint( camera->numPoints() -1 );
\r
148 camera->addPoint( org[0], org[1], lastcoord->z );
\r
151 camera->addPoint( org[0], lastcoord->y, org[2] );
\r
154 camera->addPoint( lastcoord->x, org[1], org[2] );
\r
160 camera->addPoint( org[0], org[1], 0 );
\r
163 camera->addPoint( org[0], 0, org[2] );
\r
166 camera->addPoint( 0, org[1], org[2] );
\r
171 GetCurrentCam()->HasBeenModified();
\r
174 g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
\r
181 bool CListener::OnLButtonUp( guint32 nFlags, gdouble x, gdouble y )
\r
183 SetViewType( g_pXYWndWrapper->GetViewType() );
\r
185 m_bLeftMBPressed = false;
\r
188 if( g_iEditMode == 0 ) {
\r
189 if( g_iActiveTarget < 0 )
\r
190 GetCurrentCam()->GetCam()->getPositionObj()->deselectAll();
\r
192 GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->deselectAll();
\r
194 g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
\r
200 bool CListener::OnRButtonDown( guint32 nFlags, gdouble x, gdouble y )
\r
202 SetViewType( g_pXYWndWrapper->GetViewType() );
\r
204 m_bRightMBPressed = true;
\r
209 bool CListener::OnRButtonUp( guint32 nFlags, gdouble x, gdouble y )
\r
211 SetViewType( g_pXYWndWrapper->GetViewType() );
\r
213 m_bRightMBPressed = false;
\r
218 bool CListener::OnMButtonDown( guint32 nFlags, gdouble x, gdouble y )
\r
220 SetViewType( g_pXYWndWrapper->GetViewType() );
\r
222 m_bMiddleMBPressed = true;
\r
227 bool CListener::OnMButtonUp( guint32 nFlags, gdouble x, gdouble y )
\r
229 SetViewType( g_pXYWndWrapper->GetViewType() );
\r
231 m_bMiddleMBPressed = false;
\r