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
151
152
153
154
155
156
157
158
159
160
161
162
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef SELECTION3D_H
#define SELECTION3D_H
#ifdef _WIN32
#pragma once
#endif
#include "Box3D.h"
#include "MapClass.h" // For CMapObjectList
#include "ToolInterface.h"
#include "utlvector.h"
class CMapWorld;
class CMapView;
class CMapView2D;
class CMapView3D;
class GDinputvariable;
class CRender2D;
class Selection3D : public Box3D
{
public:
Selection3D();
~Selection3D();
void Init( CMapDoc *pDocument );
inline bool IsBoxSelecting();
inline bool IsLogicalBoxSelecting();
void EndBoxSelection();
// Start, end logical selection
void StartLogicalBoxSelection( CMapViewLogical *pView, const Vector &vStart );
void EndLogicalBoxSelection( );
// Tool3D implementation.
virtual void SetEmpty();
virtual bool IsEmpty();
//
// CBaseTool implementation.
//
virtual void OnActivate();
virtual void OnDeactivate();
virtual ToolID_t GetToolID() { return TOOL_POINTER; }
virtual bool OnContextMenu2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
virtual bool OnKeyDown2D(CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
virtual bool OnLMouseDown2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
virtual bool OnLMouseUp2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
virtual bool OnMouseMove2D(CMapView2D *pView, UINT nFlags, const Vector2D &vPoint);
virtual bool OnKeyDown3D(CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
virtual bool OnLMouseDblClk3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
virtual bool OnLMouseDown3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
virtual bool OnLMouseUp3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
virtual bool OnMouseMove3D(CMapView3D *pView, UINT nFlags, const Vector2D &vPoint);
virtual void RenderTool2D(CRender2D *pRender);
virtual void RenderToolLogical(CRender2D *pRender);
virtual void RenderTool3D(CRender3D *pRender);
virtual bool OnContextMenuLogical(CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint);
virtual bool OnKeyDownLogical(CMapViewLogical *pView, UINT nChar, UINT nRepCnt, UINT nFlags);
virtual bool OnLMouseDownLogical(CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint);
virtual bool OnLMouseUpLogical(CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint);
virtual bool OnMouseMoveLogical(CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint);
virtual bool OnLMouseDblClkLogical(CMapViewLogical *pView, UINT nFlags, const Vector2D &vPoint);
void UpdateSelectionBounds();
bool m_bBoxSelection;
protected:
void TransformSelection();
void TransformLogicalSelection( const Vector2D &vecTranslation );
void FinishTranslation(bool bSave, bool bClone );
void StartTranslation(CMapView *pView, const Vector2D &vPoint, const Vector &vHandleOrigin );
bool StartBoxSelection( CMapView *pView, const Vector2D &vPoint, const Vector &vStart);
void UpdateHandleState();
virtual unsigned int GetConstraints(unsigned int nKeyFlags);
void NudgeObjects(CMapView *pView, int nChar, bool bSnap, bool bClone);
GDinputvariable *ChooseEyedropperVar(CMapView *pView, CUtlVector<GDinputvariable *> &VarList);
CMapEntity *FindEntityInTree(CMapClass *pObject);
void SelectInBox(CMapDoc *pDoc, bool bInsideOnly);
CBaseTool *GetToolObject( CMapView2D *pView, const Vector2D &ptScreen, bool bAttach );
CBaseTool *GetToolObjectLogical( CMapViewLogical *pView, const Vector2D &vPoint, bool bAttach );
void SetEyedropperCursor();
void EyedropperPick2D(CMapView2D *pView, const Vector2D &vPoint);
void EyedropperPick3D(CMapView3D *pView, const Vector2D &vPoint);
void EyedropperPick(CMapView *pView, CMapClass *pObject);
void OnEscape(CMapDoc *pDoc);
//
// Tool3D implementation.
//
virtual int HitTest(CMapView *pView, const Vector2D &pt, bool bTestHandles = false);
// Methods related to logical operations
void EyedropperPickLogical( CMapViewLogical *pView, const Vector2D &vPoint );
bool HitTestLogical( CMapView *pView, const Vector2D &ptClient );
void SelectInLogicalBox(CMapDoc *pDoc, bool bInsideOnly);
CSelection *m_pSelection; // the documents selection opject
bool m_bEyedropper; // True if we are holding down the eyedropper hotkey.
bool m_bSelected; // Did we select an object on left button down?
bool m_b3DEditMode; // editing mode in 3D on/off
bool m_bDrawAsSolidBox; // sometimes we want to render the tool bbox solid
// These are fields related to manipulation in logical views
Vector2D m_vLDownLogicalClient; // Logical client pos at which lbutton was pressed.
Vector2D m_vecLogicalSelBoxMins;
Vector2D m_vecLogicalSelBoxMaxs;
bool m_bInLogicalBoxSelection; // Are we doing box selection in the logical mode?
COLORREF m_clrLogicalBox; // The color of the logical box
Vector2D m_vLastLogicalDragPoint; // Last point at which we dragged (world coords)
Vector2D m_vLogicalTranslation;
bool m_bIsLogicalTranslating; // true while translation in logical view
bool m_bLButtonDown;
bool m_bLeftDragged;
};
//-----------------------------------------------------------------------------
// Are we in box selection?
//-----------------------------------------------------------------------------
inline bool Selection3D::IsBoxSelecting()
{
return m_bBoxSelection;
}
inline bool Selection3D::IsLogicalBoxSelecting()
{
return m_bInLogicalBoxSelection;
}
#endif // SELECTION3D_H
|