-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathMapRotate.h
More file actions
92 lines (73 loc) · 2.26 KB
/
MapRotate.h
File metadata and controls
92 lines (73 loc) · 2.26 KB
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
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "stdafx.h"
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;
#define pi_ 3.1415926535897932384626433832795
class Rotate
{
public:
float degAngle; // Angle in degrees to rotate map
RECT curExtent; // left and top not = 0
LONG rotatedHeight;
LONG rotatedWidth;
float xAxisDiff, yAxisDiff;
float _cosine;
float _sine;
Rotate(void);
~Rotate(void);
bool setupRotateBackbuffer(HDC rotateBuffer, HDC controlDC, OLE_COLOR backColor);
bool resetWorldTransform(HDC rotateBuffer);
bool cleanupRotation(HDC rotateBuffer);
void calcRotatedExtent(long width, long height);
void drawCenter(HDC tmpBuffer, COLORREF color);
void displayError(DWORD dw);
void calcRotatedPoint(float ptX, float ptY, float minX, float minY, float *rotPtX, float *rotPtY);
void getOriginalPixelPoint(long rotatedX, long rotatedY, long *origX, long *origY);
void getNewPixelPoint(long origX, long origY, long *rotatedX, long *rotatedY);
void AdjustRect(CRect& rect);
void setRotateAngle(float angle)
{
degAngle = angle;
_cosine = (float) cos((angle * pi_) / 180);
_sine = (float) sin((angle * pi_) / 180);
}
float getRotateAngle()
{
return(degAngle);
}
void setSize(RECT curExt)
{
curExtent = curExt;
_curHeight = curExtent.bottom - curExtent.top;
_curWidth = curExtent.right - curExtent.left;
}
void getSize(int *ret_width, int *ret_height)
{
*ret_width = _curWidth;
*ret_height = _curHeight;
}
RECT getSize()
{
return(curExtent);
}
void setLastError(DWORD lastError)
{
_lastError = lastError;
}
DWORD getLastError()
{
return _lastError;
}
private:
HBITMAP _hBMBuffer;
LONG _curHeight; // Current view height in pixels
LONG _curWidth; // Current viewing width in pixels
DWORD _lastError;
XFORM _savedXform, _curXform;
int _saveGraphicsMode;
void setupWorldTransform(long bufWidth, long bufHeight);
inline long Round(float val);
};