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
23 Camera plugin for GtkRadiant
24 Copyright (C) 2002 Splash Damage Ltd.
29 CListener::CListener()
35 m_bLeftMBPressed = m_bRightMBPressed = m_bMiddleMBPressed = false;
42 CListener::~CListener()
47 void CListener::Register()
49 g_UITable.m_pfnHookWindow(this);
50 g_pXYWndWrapper = g_UITable.m_pfnGetXYWndWrapper();
54 void CListener::UnRegister()
57 g_UITable.m_pfnUnHookWindow(this);
58 g_pXYWndWrapper = NULL;
63 bool CListener::OnMouseMove(unsigned int nFlags, double x, double y)
65 SetViewType(g_pXYWndWrapper->GetViewType());
67 if (m_bLeftMBPressed && oldValid && g_iEditMode == 0) {
70 g_pXYWndWrapper->SnapToGrid((int) x, (int) y, click);
74 VectorSet(delta, click[0] - old_x, click[1] - old_y, 0);
79 VectorSet(delta, click[0] - old_x, 0, click[2] - old_y);
84 VectorSet(delta, 0, click[1] - old_x, click[2] - old_y);
90 if (g_iActiveTarget < 0) {
91 GetCurrentCam()->GetCam()->getPositionObj()->updateSelection(delta[0], delta[1], delta[2]);
93 GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->updateSelection(delta[0], delta[1], delta[2]);
96 GetCurrentCam()->HasBeenModified();
98 g_FuncTable.m_pfnSysUpdateWindows(W_XY_OVERLAY | W_CAMERA);
106 bool CListener::OnLButtonDown(unsigned int nFlags, double x, double y)
108 SetViewType(g_pXYWndWrapper->GetViewType());
110 m_bLeftMBPressed = true;
115 g_pXYWndWrapper->SnapToGrid((int) x, (int) y, org);
122 VectorSet(delta, 0, 0, -1);
128 VectorSet(delta, 0, -1, 0);
134 VectorSet(delta, -1, 0, 0);
138 if (g_iEditMode == 0) {
139 if (g_iActiveTarget < 0) {
140 GetCurrentCam()->GetCam()->getPositionObj()->selectPointByRay(org[0], org[1], org[2], delta[0], delta[1],
143 GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->selectPointByRay(org[0], org[1], org[2],
144 delta[0], delta[1], delta[2],
147 } else if (g_iEditMode == 1) {
149 idCameraPosition *camera;
151 if (g_iActiveTarget < 0) {
152 camera = GetCurrentCam()->GetCam()->getPositionObj();
154 camera = GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget);
157 if (camera->numPoints()) {
158 lastcoord = camera->getPoint(camera->numPoints() - 1);
161 camera->addPoint(org[0], org[1], lastcoord->z);
164 camera->addPoint(org[0], lastcoord->y, org[2]);
167 camera->addPoint(lastcoord->x, org[1], org[2]);
173 camera->addPoint(org[0], org[1], 0);
176 camera->addPoint(org[0], 0, org[2]);
179 camera->addPoint(0, org[1], org[2]);
184 GetCurrentCam()->HasBeenModified();
187 g_FuncTable.m_pfnSysUpdateWindows(W_XY_OVERLAY | W_CAMERA);
194 bool CListener::OnLButtonUp(unsigned int nFlags, double x, double y)
196 SetViewType(g_pXYWndWrapper->GetViewType());
198 m_bLeftMBPressed = false;
201 if (g_iEditMode == 0) {
202 if (g_iActiveTarget < 0) {
203 GetCurrentCam()->GetCam()->getPositionObj()->deselectAll();
205 GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->deselectAll();
208 g_FuncTable.m_pfnSysUpdateWindows(W_XY_OVERLAY | W_CAMERA);
214 bool CListener::OnRButtonDown(unsigned int nFlags, double x, double y)
216 SetViewType(g_pXYWndWrapper->GetViewType());
218 m_bRightMBPressed = true;
223 bool CListener::OnRButtonUp(unsigned int nFlags, double x, double y)
225 SetViewType(g_pXYWndWrapper->GetViewType());
227 m_bRightMBPressed = false;
232 bool CListener::OnMButtonDown(unsigned int nFlags, double x, double y)
234 SetViewType(g_pXYWndWrapper->GetViewType());
236 m_bMiddleMBPressed = true;
241 bool CListener::OnMButtonUp(unsigned int nFlags, double x, double y)
243 SetViewType(g_pXYWndWrapper->GetViewType());
245 m_bMiddleMBPressed = false;