1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef BOX3D_H
#define BOX3D_H
#pragma once
#include "Tool3D.h"
#include "BoundBox.h"
class CMapView2D;
class CRender3D;
//
// Formats for displaying world units.
//
enum WorldUnits_t
{
Units_None,
Units_Inches,
Units_Feet_Inches,
};
class Box3D : public Tool3D, public BoundBox
{
public:
Box3D(void);
static inline void SetWorldUnits(WorldUnits_t eWorldUnits);
static inline WorldUnits_t GetWorldUnits(void);
//
// CBaseTool implementation.
//
virtual void SetEmpty();
virtual void RenderTool2D(CRender2D *pRender);
virtual void RenderTool3D(CRender3D *pRender);
virtual void UpdateStatusBar();
protected:
enum
{
expandbox = 0x01,
thicklines = 0x04,
boundstext = 0x08,
};
enum TransformMode_t
{
modeNone = 0,
modeMove,
modeScale,
modeRotate,
modeShear,
modeLast,
};
void StartNew( CMapView *pView, const Vector2D &vPoint, const Vector &vecStart, const Vector &vecSize);
inline int GetTranslateMode() { return m_TranslateMode; }
virtual void ToggleTranslateMode(void);
void EnableHandles(bool bEnable);
void SetDrawFlags(DWORD dwFlags);
DWORD GetDrawFlags() { return m_dwDrawFlags; }
void SetDrawColors(COLORREF dwHandleColor, COLORREF dwBoxColor);
virtual void GetStatusString(char *pszBuf);
unsigned long UpdateCursor(CMapView *pView, const Vector &vHandleHit, TransformMode_t eTransformMode);
void HandleToWorld( Vector &vWorld, const Vector &vHandle, const Vector *pCustomHandleBox = NULL);
const Vector NearestCorner(const Vector2D &vPoint, CMapView *pView, const Vector *pCustomHandleBox = NULL);
int GetVisibleHandles( Vector *handles, CMapView *, int nMode );
void RenderHandles2D(CRender2D *pRender, const Vector &mins, const Vector &maxs );
void RenderHandles3D(CRender3D *pRender, const Vector &mins, const Vector &maxs);
//
// Tool3D implementation.
//
public:
virtual int HitTest(CMapView *pView, const Vector2D &ptClient, bool bTestHandles = false);
// If pCustomHandleBox is non-null, it points at an array 2 vectors (min and max), and
// it will use those bounds to figure out the corners that it will align to the grid.
virtual void StartTranslation( CMapView *pView, const Vector2D &vPoint, const Vector &vHandleOrigin, const Vector *pRefPoint = NULL, const Vector *pCustomHandleBox = NULL );
virtual bool UpdateTranslation(const Vector &vUpdate, UINT uConstraints);
virtual void FinishTranslation(bool bSave);
virtual void TranslatePoint(Vector& pt);
void TranslateBox(Vector& mins, Vector& maxs);
virtual const VMatrix& GetTransformMatrix();
protected:
void UpdateTransformMatrix();
static WorldUnits_t m_eWorldUnits;
COLORREF m_clrHandle;
COLORREF m_clrBox;
TransformMode_t m_TranslateMode; // current translation mode
Vector m_TranslateHandle; // current translation handle/corner
Vector m_vTranslationFixPoint; // fix point, meaning it remains unchanged by translation, eg rotation center etc.
VMatrix m_TransformMatrix;
bool m_bEnableHandles; // check/show handles yes/no
Vector m_LastHitTestHandle; // handle hit by last HitTest call
TransformMode_t m_LastTranslateMode; // last translate mode
bool m_bPreventOverlap;
DWORD m_dwDrawFlags;
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
WorldUnits_t Box3D::GetWorldUnits(void)
{
return(m_eWorldUnits);
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void Box3D::SetWorldUnits(WorldUnits_t eWorldUnits)
{
m_eWorldUnits = eWorldUnits;
}
#endif // BOX3D_H
|