-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCode.cpp
More file actions
546 lines (453 loc) · 14.9 KB
/
Copy pathTestCode.cpp
File metadata and controls
546 lines (453 loc) · 14.9 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
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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
#include "GUI\Input.h"
#include "GUI\Output.h"
//This is a test code to test the Input and Output classes
int main()
{
int x, y;
//Create Input and Output objects to test
Output* pOut = new Output();;
Input* pIn = pOut->CreateInput();
//Starting the test
pOut->PrintMessage("This demo is to test input and output classes, Click anywhere to start the test");
pIn->GetPointClicked(x, y); //Wait for any click
///////////////////////////////////////////////////////////////////////////////////
// TEST 1:
// Create The FULL Tool bar, the drawing area and the status bar
// This has already been done through the constrcutor of class Output
///////////////////////////////////////////////////////////////////////////////////
pOut->PrintMessage("TEST1: Drawing Tool bar and Status bar, Click anywhere to continue");
pIn->GetPointClicked(x, y); //Wait for any click
///////////////////////////////////////////////////////////////////////////////////
// TEST 2:
// Drawing all the Figures with all possible states:
// Non-filled, Filled, and highlighted in both cases
///////////////////////////////////////////////////////////////////////////////////
pOut->PrintMessage("TEST2: Now we will show that Output class can draw any figure in any state, Click anywhere to continue");
pIn->GetPointClicked(x, y); //Wait for any click
GfxInfo gfxInfo;//to be used with draw function of the class Ouput
Point P1, P2, P3;
/// 2.1- Rectangle Test ///
/// ===================
pOut->PrintMessage("Drawing a Rectangle, filled/non-filled and Highlighted filled/non-filled, Click to continue");
pIn->GetPointClicked(x, y); //Wait for any click
// 2.1.1 - Drawing non-filled rectangle
pOut->PrintMessage("Drawing a Rectangle ==> non-filled, Click two points");
pIn->GetPointClicked(P1.x, P1.y);
pIn->GetPointClicked(P2.x, P2.y);
gfxInfo.BorderWdth = 3;
gfxInfo.DrawClr = BLACK; //any color for border
gfxInfo.isFilled = false; //Figure is NOT filled
pOut->DrawRect(P1, P2, gfxInfo, false);
// 2.1.2 - Drawing highlighted non-filled rectangle
pOut->PrintMessage("Drawing a Rectangle ==> Highlighted non-filled, Click to Highlight");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->DrawRect(P1, P2, gfxInfo, true);
// 2.1.3 - Drawing a filled rectangle
pOut->PrintMessage("Drawing a Rectangle ==> filled, Click two points");
pIn->GetPointClicked(P1.x, P1.y);
pIn->GetPointClicked(P2.x, P2.y);
gfxInfo.BorderWdth = 4;
gfxInfo.DrawClr = BLUE; //any color for border
gfxInfo.FillClr = GREEN;//any color for filling
gfxInfo.isFilled = true;//Figure is filled
pOut->DrawRect(P1, P2, gfxInfo, false);
// 2.1.4 - Drawing a highlighted filled rectangle
pOut->PrintMessage("Drawing a Rectangle ==> Highlighted filled, Click to Highlight");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->DrawRect(P1, P2, gfxInfo, true);
pOut->PrintMessage("Drawing a Rectangle Test ==> OK, Click anywhere to continue");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->ClearDrawArea();
/// 2.2- Line Test ///
/// ==============
pOut->PrintMessage("Drawing a Line, normal and Highlighted, Click to continue");
pIn->GetPointClicked(x, y); //Wait for any click
///TODO: Add code to draw Line, Normal and Highlighted
// 2.2.1 - Drawing normal non-filled Line
pOut->PrintMessage("Drawing a Line ==> non-filled, Click two points");
pIn->GetPointClicked(P1.x, P1.y);
pIn->GetPointClicked(P2.x, P2.y);
gfxInfo.BorderWdth = 3;
gfxInfo.DrawClr = BLACK; //any color for border
gfxInfo.isFilled = false; //Figure is NOT filled
pOut->DrawLine(P1, P2, gfxInfo, false);
// 2.2.2 - Drawing highlighted non-filled Line
pOut->PrintMessage("Drawing a Line ==> Highlighted non-filled, Click to Highlight");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->DrawLine(P1, P2, gfxInfo, true);
pOut->PrintMessage("Drawing a Line Test ==> OK, Click anywhere to continue");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->ClearDrawArea();
/// 2.3- Triangle Test ///
/// ===================
pOut->PrintMessage("Drawing a Triangle, filled/non-filled and Highlighted filled/non-filled, Click to continue");
pIn->GetPointClicked(x, y); //Wait for any click
///TODO: Add code to draw Triangle in all possible states
// 2.3.1 - Drawing non-filled Triangle
pOut->PrintMessage("Drawing a Trinagle ==> non-filled, Click Three points");
pIn->GetPointClicked(P1.x, P1.y);
pIn->GetPointClicked(P2.x, P2.y);
pIn->GetPointClicked(P3.x, P3.y);
gfxInfo.BorderWdth = 3;
gfxInfo.DrawClr = ORANGE; //any color for border
gfxInfo.isFilled = false; //Figure is NOT filled
pOut->DrawTriangle(P1, P2, P3, gfxInfo, false);
// 2.1.2 - Drawing highlighted non-filled rectangle
pOut->PrintMessage("Drawing a Rectangle ==> Highlighted non-filled, Click to Highlight");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->DrawTriangle(P1, P2, P3, gfxInfo, true);
// 2.1.3 - Drawing a filled rectangle
pOut->PrintMessage("Drawing a Rectangle ==> filled, Click Three points");
pIn->GetPointClicked(P1.x, P1.y);
pIn->GetPointClicked(P2.x, P2.y);
pIn->GetPointClicked(P3.x, P3.y);
gfxInfo.BorderWdth = 4;
gfxInfo.DrawClr = BLUE; //any color for border
gfxInfo.FillClr = GREEN;//any color for filling
gfxInfo.isFilled = true;//Figure is filled
pOut->DrawTriangle(P1, P2, P3, gfxInfo, false);
// 2.1.4 - Drawing a highlighted filled rectangle
pOut->PrintMessage("Drawing a Rectangle ==> Highlighted filled, Click to Highlight");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->DrawTriangle(P1, P2, P3, gfxInfo, true);
pOut->PrintMessage("Drawing a Triangle Test ==> OK, Click anywhere to continue");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->ClearDrawArea();
/// 2.4- Circle Test ///
/// ===================
pOut->PrintMessage("Drawing a Circle, filled/non-filled and Highlighted filled/non-filled, Click to continue");
pIn->GetPointClicked(x, y); //Wait for any click
///TODO: Add code to draw Circle in all possible states
// 2.4.1 - Drawing non-filled circle
pOut->PrintMessage("Drawing a Circle ==> non-filled, Click on the Center");
pIn->GetPointClicked(P1.x, P1.y);
const int def_radius = 40;
gfxInfo.BorderWdth = 3;
gfxInfo.DrawClr = YELLOW; //any color for border
gfxInfo.isFilled = false; //Figure is NOT filled
pOut->DrawCircle(P1, def_radius, gfxInfo, false);
// 2.4.2 - Drawing highlighted non-filled circle
pOut->PrintMessage("Drawing a Circle ==> Highlighted non-filled, Click to Highlight");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->DrawCircle(P1, def_radius, gfxInfo, true);
// 2.4.3 - Drawing a filled circle
pOut->PrintMessage("Drawing a Circle ==> filled, Click on the Center");
pIn->GetPointClicked(P1.x, P1.y);
gfxInfo.BorderWdth = 4;
gfxInfo.DrawClr = GREEN; //any color for border
gfxInfo.FillClr = BLACK;//any color for filling
gfxInfo.isFilled = true;//Figure is filled
pOut->DrawCircle(P1, def_radius, gfxInfo, false);
// 2.4.4 - Drawing a highlighted filled circle
pOut->PrintMessage("Drawing a Circle ==> Highlighted filled, Click to Highlight");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->DrawCircle(P1, def_radius, gfxInfo, true);
pOut->PrintMessage("Drawing a Circle Test ==> OK, Click anywhere to continue");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->ClearDrawArea();
///////////////////////////////////////////////////////////////////////////////////
// TEST 3:
// Input Class: Read strings from the user
///////////////////////////////////////////////////////////////////////////////////
pOut->PrintMessage("TEST3: Now Time to test class Input, Click anywhere to continue");
pIn->GetPointClicked(x, y); //Wait for any click
pOut->PrintMessage("Testing Input ability to read strings please type any thing you want then press Return");
///TODO: Add code here to
// 1- Read a string from the user on the status bar
// 2- After reading the stirng clear the status bar
// 3- print on the status bar "You Entered" then print the string
std::string in_string = pIn->GetString(pOut);
pOut->ClearStatusBar();
pOut->PrintMessage(std::string("You Entered: " + in_string));
pIn->GetPointClicked(x, y); //Wait for any click
pOut->ClearDrawArea();
///////////////////////////////////////////////////////////////////////////////////
// TEST 4:
// Input Class : Check for the user action
///////////////////////////////////////////////////////////////////////////////////
pOut->PrintMessage("TEST4: Testing Input ability to detect User Action, click anywhere");
ActionType ActType;
ActionType PrevActType = EMPTY;
///TODO:
//You must add a case for each action (both Draw mode and Play mode actions)
//Add cases for the missing actions below
do
{
ActType = pIn->GetUserAction();
switch (ActType)
{
case DRAW_RECT:
pOut->PrintMessage("Action: Draw a Rectangle , Click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_RECT);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;//this is necessary because the user might be click on the same icon twice, in this case the item should be hilighted again
}
break;
case DRAW_LINE:
pOut->PrintMessage("Action: Draw a Line , Click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_LINE);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case DRAW_CIRC:
pOut->PrintMessage("Action: Draw a Circle , Click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_CIRC);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case DRAW_TRI:
pOut->PrintMessage("Action: Draw a Triangle , Click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_TRI);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case CHNG_DRAW_CLR:
pOut->PrintMessage("Action: Change the drawing color , Click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_DRAW_CLR);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case CHNG_FILL_CLR:
pOut->PrintMessage("Action: Change fill color , Click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_FILL_CLR);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case CHNG_BK_CLR:
pOut->PrintMessage("Action: Chang background color, click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_BK_CLR);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case SELECT:
pOut->PrintMessage("Action: Select shape, click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_SELECT);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case MOVE:
pOut->PrintMessage("Action: MOVE shape, click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_MOVE);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case DEL:
pOut->PrintMessage("Action: Delete shape, click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_DEL);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case RESIZE:
pOut->PrintMessage("Action: Resize shape, click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_RESIZE);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case ROTATE:
pOut->PrintMessage("Action: Rotate a shape, click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_ROTATE);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case SEND_BACK:
pOut->PrintMessage("Action: send back shape, click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_SEND_BACK);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case BRNG_FRNT:
pOut->PrintMessage("Action: bring forward shape, click anywhere");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_BRNG_FRNT);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case SAVE:
pOut->PrintMessage("Action: Saving data...");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_SAVE);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case LOAD:
pOut->PrintMessage("Action: Loading data...");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_LOAD);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case REDO:
pOut->PrintMessage("Action: redo previous action...");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_REDO);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case UNDO:
pOut->PrintMessage("Action: undo previous action");
if (ActType != PrevActType)
{
pOut->CreateDrawToolBar(ITM_UNDO);
PrevActType = ActType;
}
else
{
pOut->CreateDrawToolBar();
PrevActType = EMPTY;
}
break;
case STATUS:
pOut->PrintMessage("Action: a click on the Status Bar, Click anywhere");
break;
case DRAWING_AREA:
pOut->PrintMessage("Action: a click on the Drawing Area, Click anywhere");
break;
case EMPTY:
pOut->PrintMessage("Action: a click on empty area in the Design Tool Bar, Click anywhere");
break;
case TO_DRAW:
pOut->PrintMessage("Action: Switch to Draw Mode, creating simualtion tool bar");
pOut->CreateDrawToolBar();
break;
case SHAPE_ONLY:
pOut->PrintMessage("Action: Switching to shape only game mode, click anywhere ");
break;
case CLR_ONLY:
pOut->PrintMessage("Action: Switching to color only game mode, click anywhere");
break;
case SHAPE_N_CLR:
pOut->PrintMessage("Action: Switching to shape and color game mode, click anywhere");
break;
case AREA:
pOut->PrintMessage("Action: Switching to area game mode, click anywhere");
break;
case TO_PLAY:
pOut->PrintMessage("Action: Switch to Play Mode, creating Design tool bar");
pOut->CreatePlayToolBar();
break;
case EXIT:
pOut->CreateDrawToolBar(ITM_EXIT);
break;
}
} while (ActType != EXIT);
/// Exiting
pOut->PrintMessage("Action: EXIT, test is finished, click anywhere to exit");
pIn->GetPointClicked(x, y);
delete pIn;
delete pOut;
return 0;
}