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
22 //-----------------------------------------------------------------------------
\r
25 // a class to handle control points in a 2D view
\r
26 // TODO: this one can be placed under an interface, and provided to the editor as service
\r
28 // NOTE: the C2DView *m_p2DView is the orthogonal mapping between window and ST space
\r
29 // in Drag mode (for rotation) we need an orthonormal XY space
\r
30 // we do ST <-> XY transformations using the texture size
\r
31 // ( for translation-only moves, orthogonal is enough )
\r
32 // FIXME: is there a better way to deal between Window space <-> ST space <-> XY space ?
\r
34 // NOTE: ControlPointsManagers are a bit different between brush faces and patches
\r
35 // so there's a base virtual class, and we have two versions
\r
37 #ifndef _CONTROLPOINTSMANAGER_H_
\r
38 #define _CONTROLPOINTSMANAGER_H_
\r
40 class CControlPointsManager
\r
44 _QERQglTable *m_pQglTable;
\r
47 CControlPointsManager() { m_pQglTable = NULL; m_p2DView = NULL; }
\r
48 virtual ~CControlPointsManager() { }
\r
49 void Init( C2DView *p2DView, _QERQglTable *pQglTable ) { m_pQglTable = pQglTable; m_p2DView = p2DView; }
\r
51 virtual bool OnLButtonDown (int x, int y) = 0;
\r
52 virtual bool OnMouseMove (int x, int y) = 0;
\r
53 virtual bool OnLButtonUp (int x, int y) = 0;
\r
55 virtual void Render() = 0;
\r
56 virtual void Commit() = 0;
\r
59 // brush face manager
\r
60 class CControlPointsManagerBFace : public CControlPointsManager
\r
62 enum EManagerState { Idle, Drag } ManagerState;
\r
68 // transform matrix ( 2DView is Window <-> ST )
\r
70 // texture size for ST <-> XY
\r
72 // used when translating
\r
73 float m_TransOffset[2];
\r
74 // dragged point index
\r
76 // do we have an anchor ?
\r
78 // anchor point index
\r
80 // coordinates of Anchor
\r
83 _QERFaceData *m_pFaceData;
\r
86 // construction / init -------------------------------------------------
\r
87 CControlPointsManagerBFace() { ManagerState = Idle; }
\r
88 virtual ~CControlPointsManagerBFace() { }
\r
89 // NOTE: pQglTable is sent to CControlPointsManager::Init
\r
90 void Init(int iPts, CtrlPts_t *Pts, C2DView *p2DView, int TexSize[2], _QERFaceData* pFaceData, _QERQglTable *pQglTable);
\r
91 // CControlPointsManager interface -------------------------------------
\r
93 virtual bool OnLButtonDown (int x, int y);
\r
94 virtual bool OnMouseMove (int x, int y);
\r
95 virtual bool OnLButtonUp (int x, int y);
\r
97 virtual void Render();
\r
98 virtual void Commit();
\r
101 // internal members
\r
102 void UpdateCtrlPts();
\r
103 void ComputeTransOffset(int i);
\r
104 void XYSpaceForSTSpace( float xy[2], const float st[2] );
\r
108 class CControlPointsManagerPatch : public CControlPointsManager
\r
110 enum EManagerState { Idle, Drag } ManagerState;
\r
111 // reference data, used for commits
\r
112 patchMesh_t* m_pPatch;
\r
113 // work patch, holds current data
\r
114 patchMesh_t* m_pWorkPatch;
\r
115 int m_iDragPoint[2];
\r
118 // construction / init -------------------------------------------------
\r
119 CControlPointsManagerPatch() { ManagerState = Idle; }
\r
120 virtual ~CControlPointsManagerPatch() { }
\r
121 // NOTE: pQglTable is sent to CControlPointsManager::Init
\r
122 void Init( patchMesh_t* pWorkPatch, C2DView *p2DView, _QERQglTable *pQglTable, patchMesh_t* pPatch );
\r
123 // CControlPointsManager interface -------------------------------------
\r
125 virtual bool OnLButtonDown (int x, int y);
\r
126 virtual bool OnMouseMove (int x, int y);
\r
127 virtual bool OnLButtonUp (int x, int y);
\r
129 virtual void Render();
\r
130 virtual void Commit();
\r