-
Notifications
You must be signed in to change notification settings - Fork 0
/
ElementFactory.cpp
441 lines (404 loc) · 11.9 KB
/
ElementFactory.cpp
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
#include "StdAfx.h"
#include "ElementFactory.h"
#include "Element.h"
#include "DrawingElements.h"
CElementFactory::CElementFactory(void)
{
}
CElementFactory::~CElementFactory(void)
{
}
//
// CFactory Class
//
int CFactory::g_counter = 0;
std::shared_ptr<CElement> CFactory::CreateElementOfType(ElementType type, ShapeType shapeType)
{
// Inc counter of created objects
CFactory::g_counter++;
//std::shared_ptr<CElement> pNewElement = new CElement();
std::shared_ptr<CElement> pNewElement;
//pNewElement = make_shared<CElement>();
/*
#ifdef USE_BOOST
std::shared_ptr<CElement> pNewElement(new CElement());
#else
std::shared_ptr<CElement> pNewElement = make_shared<CElement>();
#endif
*/
if( type == ElementType::type_shapes_simple )
{
switch( shapeType )
{
case line:
case line2:
case line_right:
case line_right2:
case line_left_right:
{
std::shared_ptr<CElement> apNewElement(new CLineElement());
pNewElement = apNewElement;
break;
}
case rectangle:
case rectangle_round:
{
std::shared_ptr<CElement> apNewElement(new CRectangleElement());
pNewElement = apNewElement;
break;
}
case triangle:
{
std::shared_ptr<CElement> apNewElement(new CTriangleElement());
pNewElement = apNewElement;
break;
}
case arrow_right:
{
std::shared_ptr<CElement> apNewElement(new CArrowRightElement());
pNewElement = apNewElement;
break;
}
case arrow_down:
{
std::shared_ptr<CElement> apNewElement(new CArrowDownElement());
pNewElement = apNewElement;
break;
}
case ellipse:
{
std::shared_ptr<CElement> apNewElement(new CEllipseElement());
pNewElement = apNewElement;
break;
}
case parenthese_left:
{
std::shared_ptr<CElement> apNewElement(new CParentheseLeftElement());
pNewElement = apNewElement;
break;
}
case parenthese_right:
{
std::shared_ptr<CElement> apNewElement(new CParentheseRightElement());
pNewElement = apNewElement;
break;
}
case star:
{
std::shared_ptr<CElement> apNewElement(new CStarElement());
pNewElement = apNewElement;
break;
}
case line_broken:
case line_broken_right:
{
std::shared_ptr<CElement> apNewElement(new CLineBrokenElement());
pNewElement = apNewElement;
break;
}
case notimp_igloo:
case notimpl_multi_line:
default:
{
//std::shared_ptr<CElement> apNewElement(new CNotImplementedElement());
//// Not implemented yet !
//pNewElement->m_type = ElementType::type_unknown;
//pNewElement = apNewElement;
std::shared_ptr<CElement> apNewElement(new CRectangleElement());
pNewElement = apNewElement;
break;
}
}
}
if( type == ElementType::type_image )
{
switch( shapeType )
{
case image_fixed:
case image_scaled:
{
std::shared_ptr<CElement> apNewElement(new CImageElement());
pNewElement = apNewElement;
break;
}
default:
{
std::shared_ptr<CElement> apNewElement(new CNotImplementedElement());
pNewElement = apNewElement;
// Not implemented yet !
pNewElement->m_type = ElementType::type_unknown;
break;
}
}
}
if( type == ElementType::type_shapes_infrastructure )
{
std::shared_ptr<CElement> apNewElement(new CImageElement());
pNewElement = apNewElement;
// No line around the object
pNewElement->m_bColorLine = FALSE;
switch( shapeType )
{
case ShapeType::infrastructure_server_ad:
pNewElement->m_image = L"ServerAD.png";
break;
case ShapeType::infrastructure_server:
pNewElement->m_image = L"Server.png";
break;
case ShapeType::infrastructure_server_web:
pNewElement->m_image = L"ServerWeb.png";
break;
case ShapeType::infrastructure_server_database:
pNewElement->m_image = L"ServerDatabase.png";
break;
case ShapeType::infrastructure_workstation:
pNewElement->m_image = L"Workstation.png";
break;
case ShapeType::infrastructure_laptop:
pNewElement->m_image = L"Laptop.png";
break;
case ShapeType::infrastructure_firewall:
pNewElement->m_image = L"Firewall.png";
break;
case ShapeType::infrastructure_network:
pNewElement->m_image = L"network.png";
break;
case infrastructure_virtual_server:
pNewElement->m_image = L"Server_VM.png";
break;
case infrastructure_virtual_server_web:
pNewElement->m_image = L"ServerWeb_VM.png";
break;
case infrastructure_virtual_server_database:
pNewElement->m_image = L"ServerDatabase_VM.png";
break;
case infrastructure_virtualization_server:
pNewElement->m_image = L"Virtualization_Server.png";
break;
case infrastructure_server_ad_grey:
pNewElement->m_image = L"ServerAD_grey.png";
break;
case infrastructure_server_grey:
pNewElement->m_image = L"Server_grey.png";
break;
case infrastructure_server_database_grey:
pNewElement->m_image = L"ServerDatabase_grey.png";
break;
case infrastructure_server_farm:
pNewElement->m_image = L"Server_Farm.png";
break;
case infrastructure_workstation_grey:
pNewElement->m_image = L"Workstation_grey.png";
break;
case infrastructure_laptop_grey:
pNewElement->m_image = L"Laptop_grey.png";
break;
default:
// Not implemented yet !
pNewElement->m_type = ElementType::type_unknown;
break;
}
}
if( type == ElementType::type_shapes_development )
{
std::shared_ptr<CElement> apNewElement(new CDevelopmentElement());
pNewElement = apNewElement;
pNewElement->m_bColorLine = true;
pNewElement->m_bColorFill = true;
pNewElement->m_bSolidColorFill = true;
// Set colors for development shapes
Color colorLineClass(255, 52, 101, 164);
Color colorFillClass(255, 200, 210, 233);
Color colorLineInterface(255, 176, 167, 129);
Color colorFillInterface(255, 217, 230, 203);
Color colorLineEnumeration(255, 112, 88, 41);
Color colorFillEnumeration(255, 175, 165, 120);
Color colorLinePackage(255, 191, 161, 132);
Color colorFillPackage(255, 255, 251, 240);
Color colorLineComment(255, 202, 178, 45);
Color colorFillComment(255, 251, 247, 200);
Color colorLineComponent(255, 83, 134, 191);
Color colorFillComponent(255, 181, 210, 237);
switch( shapeType )
{
case development_class:
pNewElement->m_text = L"Class";
pNewElement->m_colorFill = colorFillClass.ToCOLORREF();
pNewElement->m_colorLine = colorLineClass.ToCOLORREF();
break;
case development_interface:
pNewElement->m_text = L"Interface";
pNewElement->m_colorFill = colorFillInterface.ToCOLORREF();
pNewElement->m_colorLine = colorLineInterface.ToCOLORREF();
break;
case development_enumeration:
pNewElement->m_text = L"Enumeration";
pNewElement->m_colorFill = colorFillEnumeration.ToCOLORREF();
pNewElement->m_colorLine = colorLineEnumeration.ToCOLORREF();
break;
case development_package:
pNewElement->m_text = L"Package";
pNewElement->m_colorFill = colorFillPackage.ToCOLORREF();
pNewElement->m_colorLine = colorLinePackage.ToCOLORREF();
break;
case development_comment:
pNewElement->m_text = L"Comment";
pNewElement->m_colorFill = colorFillComment.ToCOLORREF();
pNewElement->m_colorLine = colorLineComment.ToCOLORREF();
break;
case development_component:
pNewElement->m_text = L"Component";
pNewElement->m_colorFill = colorFillComponent.ToCOLORREF();
pNewElement->m_colorLine = colorLineComponent.ToCOLORREF();
break;
case development_association:
case development_aggregation:
case development_composition:
case development_dependency:
case development_inheritance:
case development_package_import:
case development_connector:
break;
}
}
if (type == ElementType::type_shapes_import)
{
std::shared_ptr<CElement> apNewElement = make_shared<CImportElement>();
pNewElement = apNewElement;
pNewElement->m_bColorLine = true;
pNewElement->m_bColorFill = true;
pNewElement->m_bSolidColorFill = true;
// Set same colors like development shapes
Color colorLineClass(255, 52, 101, 164);
Color colorFillClass(255, 200, 210, 233);
switch (shapeType)
{
case import_class :
pNewElement->m_text = L"";
pNewElement->m_colorFill = colorFillClass.ToCOLORREF();
pNewElement->m_colorLine = colorLineClass.ToCOLORREF();
break;
}
}
if( type == ElementType::type_text )
{
std::shared_ptr<CElement> apNewElement(new CTextElement());
pNewElement = apNewElement;
pNewElement->m_bColorLine = true;
pNewElement->m_bColorFill = false;
pNewElement->m_bSolidColorFill = true;
pNewElement->m_text = L"<type text>";
//pNewElement->m_textAlign = L"Left";
if (shapeType == ShapeType::text_left)
{
pNewElement->m_textAlign = L"Left";
}
if (shapeType == ShapeType::text_center)
{
pNewElement->m_textAlign = L"Center";
}
if (shapeType == ShapeType::text_right)
{
pNewElement->m_textAlign = L"Right";
}
}
if( type == ElementType::type_image )
{
std::shared_ptr<CElement> apNewElement(new CImageElement());
pNewElement = apNewElement;
// No line around the object
pNewElement->m_bColorLine = FALSE;
}
if (shapeType == ShapeType::selection)
{
std::shared_ptr<CElement> apNewElement(new CSelectionElement());
pNewElement = apNewElement;
pNewElement->m_bColorFill = false;
}
/*if (shapeType == ShapeType::connection)
{
std::shared_ptr<CElement> apNewElement(new CLineElement());
pNewElement = apNewElement;
pNewElement->m_bColorFill = false;
}*/
if (type == ElementType::type_shapes_planning)
{
std::shared_ptr<CElement> apNewElement(new CPlanningElement());
pNewElement = apNewElement;
pNewElement->m_bColorLine = true;
pNewElement->m_bColorFill = true;
pNewElement->m_bSolidColorFill = true;
// Set colors for development shapes
Color colorLineClass(255, 52, 101, 164);
Color colorFillClass(255, 200, 210, 233);
Color colorLineComment(255, 202, 178, 45);
Color colorFillComment(255, 251, 247, 200);
switch (shapeType)
{
case planning_month:
pNewElement->m_text = L"Month";
pNewElement->m_colorFill = colorFillClass.ToCOLORREF();
pNewElement->m_colorLine = colorLineClass.ToCOLORREF();
break;
case planning_task:
pNewElement->m_text = L"Task";
pNewElement->m_colorFill = colorFillComment.ToCOLORREF();
pNewElement->m_colorLine = colorLineComment.ToCOLORREF();
break;
}
}
if (type == ElementType::type_file)
{
std::shared_ptr<CElement> apNewElement(new CDiagramElement());
pNewElement = apNewElement;
pNewElement->m_bColorLine = true;
pNewElement->m_bColorFill = true;
pNewElement->m_bSolidColorFill = true;
pNewElement->m_documentType = DocumentType::document_diagram;
pNewElement->m_documentTypeText = _T("Diagram");
// Set colors for development shapes
Color colorLineClass(255, 52, 101, 164);
Color colorFillClass(255, 200, 210, 233);
Color colorLineComment(255, 202, 178, 45);
Color colorFillComment(255, 251, 247, 200);
switch (shapeType)
{
case ShapeType::diagram:
pNewElement->m_text = L"Diagram";
pNewElement->m_colorFill = colorFillClass.ToCOLORREF();
pNewElement->m_colorLine = colorLineClass.ToCOLORREF();
break;
}
}
//
// Initialize default members for the element
//
pNewElement->m_type = type;
pNewElement->m_shapeType = shapeType;
pNewElement->m_bGrouping = false;
return pNewElement;
}
//
// CGuid Class
//
CGuid::CGuid()
{
#ifdef GUID_TRUE
::UuidCreateSequential(&m_uuid);
#endif
}
CGuid::~CGuid(void)
{
}
CString CGuid::ToString()
{
#ifdef GUID_TRUE
unsigned char * sz;
::UuidToStringA(&m_uuid, &sz);
CString str((const unsigned char *)sz);
RpcStringFree(&sz);
return str;
#else
return _T("");
#endif
}