-
Notifications
You must be signed in to change notification settings - Fork 0
/
Viewers.h
119 lines (102 loc) · 4.48 KB
/
Viewers.h
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
/* Copyright (c) 2002-2012 Croteam Ltd.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
#ifndef VIEWERS_H
#define VIEWERS_H
/*
* Definition of viewer and target placement
*/
class CMasterViewer {
friend class CSlaveViewer;
public:
CPlacement3D mv_plViewer; // placement of the viewer
FLOAT mv_fTargetDistance; // distance of virtual target from viewer
// default constructor
CMasterViewer(void);
// get placement of the viewer
inline CPlacement3D GetViewerPlacement(void) const {return mv_plViewer;};
// get placement of the virtual target
CPlacement3D GetTargetPlacement(void) const;
// set placement of the virtual target
void SetTargetPlacement(FLOAT3D f3dTarget);
// convert from slave
void operator = (const CSlaveViewer &svSlave);
};
/*
* Definition of viewing projection viewer placement
*/
class CSlaveViewer {
friend class CMasterViewer;
public:
enum ProjectionType {
PT_ILLEGAL = 0,
PT_PERSPECTIVE,
PT_ISOMETRIC_FRONT,
PT_ISOMETRIC_RIGHT,
PT_ISOMETRIC_TOP,
PT_ISOMETRIC_BACK,
PT_ISOMETRIC_LEFT,
PT_ISOMETRIC_BOTTOM,
};
CDrawPort *sv_pdpDrawPort; // drawport that this viewer was created for
CPlacement3D sv_plViewer; // placement of the viewer
CPlacement3D sv_plGrid; // grid's placement
FLOAT sv_fTargetDistance; // distance of virtual target from viewer
enum ProjectionType sv_ProjectionType; // tyoe of projection
// get orientation angles for type of isometric viewer
ANGLE3D GetAngleForIsometricType(void) const;
public:
// default constructor
CSlaveViewer( const CMasterViewer &mvMaster, enum ProjectionType ptProjectionType,
const CPlacement3D &plGrid, CDrawPort *pdpDrawPort);
// create a projection for this viewer
void MakeProjection(CAnyProjection3D &prProjection);
// create a perspective projection for this viewer
void MakePerspectiveProjection(CPerspectiveProjection3D &prPerspectiveProjection);
// get placement of the viewer
inline CPlacement3D GetViewerPlacement(void) const {return sv_plViewer;};
// test if this is perspective viewer
inline BOOL IsPerspective(void) const { ASSERT( sv_ProjectionType != PT_ILLEGAL);
return sv_ProjectionType == PT_PERSPECTIVE; };
// test if this is isometric viewer
inline BOOL IsIsometric(void) const { ASSERT( sv_ProjectionType != PT_ILLEGAL);
return sv_ProjectionType != PT_PERSPECTIVE; };
/* Get zoom factor for the viewer. */
FLOAT GetZoomFactor(void);
/* Get distance for requested zoom factor for the viewer. */
FLOAT GetDistanceForZoom(FLOAT fZoom);
// get target distance
inline FLOAT GetTargetDistance( void) const { return sv_fTargetDistance; };
// get placement of the virtual target
CPlacement3D GetTargetPlacement(void) const;
// translate slave viewer in his own system
void Translate_OwnSystem( PIX pixDI, PIX pixDJ, PIX pixDK);
void TranslatePlacement_OtherSystem(CPlacement3D &plToTranslate,CPlacement3D &plOtherSystem,
PIX pixDI, PIX pixDJ, PIX pixDK);
// scales target distance using given factor
void ScaleTargetDistance( FLOAT fFactor);
// rotate slave viewer in his own system using HPB method
void Rotate_HPB( PIX pixDI, PIX pixDJ, PIX pixDK);
// translate a placement in viewer's system
void TranslatePlacement_OwnSystem(CPlacement3D &plToTranslate,
PIX pixDI, PIX pixDJ, PIX pixDK);
// rotate a placement in viewer's system
void RotatePlacement_HPB(CPlacement3D &plToRotate,
PIX pixDI, PIX pixDJ, PIX pixDK);
// rotate a placement in viewer's system
void RotatePlacement_TrackBall(CPlacement3D &plToRotate,
PIX pixDI, PIX pixDJ, PIX pixDK);
// convert offset from pixels to meters
FLOAT PixelsToMeters(PIX pix);
void Translate_Local_OwnSystem(FLOAT fdX, FLOAT fdY, FLOAT fdZ);
void Rotate_Local_HPB( FLOAT fdX, FLOAT fdY, FLOAT fdZ);
};
#endif // VIEWERS_H