-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathDrawingOptions.h
More file actions
295 lines (237 loc) · 7.91 KB
/
Copy pathDrawingOptions.h
File metadata and controls
295 lines (237 loc) · 7.91 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/**************************************************************************************
* File name: DrawingOptions.h
*
* Project: MapWindow Open Source (MapWinGis ActiveX control)
* Description: Declaration of CDrawingOptionsEx
*
**************************************************************************************
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at http://www.mozilla.org/mpl/
* See the License for the specific language governing rights and limitations
* under the License.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
**************************************************************************************
* Contributor(s):
* (Open source contributors should list themselves and their modifications here). */
// Sergei Leschinski (lsu) 25 june 2010 - created the file.
#pragma once
class CDrawingOptionsEx
{
public:
CDrawingOptionsEx& operator=(const CDrawingOptionsEx& opt);
public:
//OLE_COLOR selectionColor;
//unsigned short selectionTransparency;
//bool useSelectionColor;
tkSimpleShapeType _shpType;
bool visible;
bool fillVisible;
bool linesVisible;
bool fillBgTransparent;
bool alignIconByBottom; // bottom center of the icon will be placed in the specified position on the map
bool drawFrame;
double scale; // the current mapscale (for inner use only)
double minScale;
double maxScale;
double minLineWidth;
double maxLineWidth;
double scaleX;
double scaleY;
double rotation; // if rotations is initialized/length > 0 this is ignored
BSTR rotationExpression;
double fillGradientRotation;
// colors
OLE_COLOR fillColor;
OLE_COLOR fillColor2;
OLE_COLOR lineColor;
OLE_COLOR pointColor;
OLE_COLOR fillBgColor;
// stipples
tkDashStyle lineStipple;
tkGDIPlusHatchStyle fillHatchStyle;
float lineWidth;
float pointSize;
float fillTransparency; // used without stipples (GDI+) // 0 - 255
float lineTransparency;
int pointNumSides; // number of sides for a single shape
float pointShapeRatio; // shape ratio for simple shape
tkFillType fillType;
tkPointSymbolType pointSymbolType;
tkPointShapeType pointShapeType;
tkPointReflectionType pointReflectionType;
tkVectorDrawingMode drawingMode;
tkGradientBounds fillGradientBounds;
tkGradientType fillGradientType;
tkLabelFrameType frameType;
VARIANT_BOOL verticesVisible;
VARIANT_BOOL verticesFillVisible;
OLE_COLOR verticesColor;
tkVertexType verticesType;
int verticesSize;
IImage* picture;
unsigned char pointCharcter;
CString fontName;
CString tag;
ILinePattern* linePattern;
bool useLinePattern;
Gdiplus::Brush* brushPlus;
Gdiplus::Pen* penPlus;
Gdiplus::Bitmap* bitmapPlus;
Gdiplus::ImageAttributes* imgAttributes;
bool _needDeleteBitmapPlus;
bool dynamicVisibility;
double minVisibleScale;
double maxVisibleScale;
int minVisibleZoom;
int maxVisibleZoom;
CPen* pen;
CPen* penOld;
CBrush* brush;
CBrush* brushOld;
// field-based rendering
CString rotationField;
#pragma region Constructor
// constructor
CDrawingOptionsEx(void)
{
_needDeleteBitmapPlus = false;
//selectionColor = RGB(255, 255, 0);
//selectionTransparency = 180;
dynamicVisibility = false;
maxVisibleScale = 100000000.0;
minVisibleScale = 0.0;
minVisibleZoom = 0;
maxVisibleZoom = 25;
_shpType = tkSimpleShapeType::shpNone;
drawingMode = vdmGDIMixed;
scale = 0.0;
minScale = 0.0;
maxScale = 0.0;
minLineWidth = 1.0;
maxLineWidth = 1.0;
visible = true;
fillVisible = true;
linesVisible = true;
fillBgTransparent = true;
alignIconByBottom = true;
drawFrame = false;
fillColor = RGB(255,0,0);
fillColor2 = RGB(200,200,200);
lineColor = RGB(0,0,0);
fillBgColor = RGB(0,120,0);
pointColor = RGB(0,0,0);
lineWidth = 1.0;
pointSize = 8.0;
fillTransparency = 255;
lineTransparency = 255;
rotation = 0.0;
rotationExpression = SysAllocString(L"");
lineStipple = dsSolid;
fillHatchStyle = hsHorizontal;
pointSymbolType = ptSymbolStandard;
fillGradientType = gtLinear;
fillType = ftStandard;
pointShapeType = ptShapeRegular;
pointReflectionType = prtNone;
fillGradientBounds = gbPerShape;
frameType = lfRectangle;
picture = NULL;
pointCharcter = 'a';
scaleX = 1.0;
scaleY = 1.0;
pointNumSides = 4;
pointShapeRatio = 0.5;
fillGradientRotation = 0.0;
fontName = "Times New Roman";
tag = "";
verticesVisible = VARIANT_FALSE;
verticesFillVisible = VARIANT_TRUE;
verticesColor = RGB(0, 0, 255);
verticesType = vtSquare;
verticesSize = 6;
linePattern = NULL;
useLinePattern = false;
penPlus = NULL;
brushPlus = NULL;
bitmapPlus = NULL;
imgAttributes = NULL;
pen = new CPen();
brush = new CBrush();
penOld = NULL;
brushOld = NULL;
}
// Constructor 2
CDrawingOptionsEx(const CDrawingOptionsEx& opt)
{
this->picture = NULL;
this->linePattern = NULL;
this->brush = NULL;
this->pen = NULL;
this->penPlus = NULL;
this->brushPlus = NULL;
this->bitmapPlus = NULL;
this->imgAttributes = NULL;
this->penOld = NULL;
this->brushOld = NULL;
*this = opt;
picture = NULL;
}
#pragma endregion
#pragma region Destructor
~CDrawingOptionsEx()
{
if ( picture ) picture->Release();
if ( linePattern ) linePattern->Release();
this->ReleaseGdiPlusBrush();
//this->ReleaseGDIPlusPen(); // TODO: exception here ?!
if (pen) delete pen;
if (brush) delete brush;
if ( brushPlus ) delete brushPlus;
if ( penPlus ) delete penPlus;
if ( imgAttributes) delete imgAttributes;
this->ReleaseGdiPlusBitmap();
::SysFreeString(rotationExpression);
}
#pragma endregion
#pragma region Functions
Gdiplus::GraphicsPath* GetFrameForPath(Gdiplus::GraphicsPath& path);
bool CanUseLinePattern();
void DrawGraphicPath(Gdiplus::Graphics* graphics, Gdiplus::GraphicsPath* path);
void FillGraphicsPath(Gdiplus::Graphics* graphics, Gdiplus::GraphicsPath* path, Gdiplus::RectF& bounds);
void InitGdiPlusBrushAndPen(Gdiplus::RectF* bounds = NULL); // bounds for gradient
void InitGdiPlusBrush(Gdiplus::RectF* bounds = NULL);
void InitGdiPlusPen();
void InitGdiPlusPicture();
void ReleaseGdiPlusBrushAndPen();
void ReleaseGdiPlusBrush();
void ReleaseGdiPlusPen();
void ReleaseGdiPlusBitmap();
// GDI drawing
void InitGdiBrushAndPen(CDC* dc);
void InitGdiBrushAndPen(CDC* dc, bool selection, OLE_COLOR selectionColor);
void InitGdiBrush();
void InitGdiPen();
void InitGdiBrush(bool selection, OLE_COLOR selectionColor);
void InitGdiPen(bool selection, OLE_COLOR selectionColor);
void InitGdiVerticesPen(CDC* dc);
void ReleaseGdiBrushAndPen(CDC* dc);
void ReleaseGdiVerticesPen();
// utilities
Gdiplus::Bitmap* ImageToGdiPlusBitmap(IImage* img);
CPoint* GetVertex();
void DrawPointSymbol(Gdiplus::Graphics& g, CDC* dc, Gdiplus::Point* points, float* angles, int count);
int LineStippleToGDIPenStyle(tkDashStyle lineStipple);
Gdiplus::GraphicsPath* get_FontCharacterPath(CDC* dc, bool previewDrawing);
void DrawGraphicPathWithFillColor(Gdiplus::Graphics* graphics, Gdiplus::GraphicsPath* path, Gdiplus::REAL width);
void LoadIcon();
bool IsVisible(double scale, int zoom);
#pragma endregion
};