-
Notifications
You must be signed in to change notification settings - Fork 4
/
utools.pas
759 lines (649 loc) · 19 KB
/
utools.pas
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
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
unit UTools;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Controls, UFigures, UToolParams, UTransform, Graphics,
Math, UAppState, UHistory;
type
{ TTool }
TTool = class
private
FFigure: TFigure;
FMButton: TMouseButton;
FStartPoint: TPoint;
public
constructor Create; virtual; abstract;
property Figure: TFigure read FFigure;
procedure MouseDown(X, Y: integer; Button: TMouseButton); virtual;
procedure MouseMove(X, Y: integer; Shift: TShiftState); virtual; abstract;
function MouseUp(X, Y: integer): TFigure; virtual; abstract;
function GetParams: TToolParamList; virtual; abstract;
end;
TToolClass = class of TTool;
TToolList = array of TTool;
TToolClassList = array of TToolClass;
{ TDrawableTool }
TDrawableTool = class(TTool)
private
FLineWidth: TIntegerParam;
FLineColor: TColorParam;
FLineStyle: TLineStyleParam;
public
constructor Create; override;
destructor Destroy; override;
procedure MouseDown(X, Y: integer; Button: TMouseButton); override;
procedure MouseMove(X, Y: integer; Shift: TShiftState); override;
function MouseUp(X, Y: integer): TFigure; override;
function GetParams: TToolParamList; override;
end;
{ TFillableTool }
TFillableTool = class(TDrawableTool)
private
FFillColor: TColorParam;
FFillStyle: TFillStyleParam;
public
constructor Create; override;
destructor Destroy; override;
procedure MouseMove(X, Y: integer; Shift: TShiftState); override;
function GetParams: TToolParamList; override;
end;
{ THandTool }
THandTool = class(TTool)
private
WorldStartCoord: TDoublePoint;
public
constructor Create; override;
procedure MouseDown(X, Y: integer; Button: TMouseButton); override;
procedure MouseMove(X, Y: integer; Shift: TShiftState); override;
function MouseUp(X, Y: integer): TFigure; override;
function GetParams: TToolParamList; override;
end;
{ TPolylineTool }
TPolylineTool = class(TDrawableTool)
procedure MouseDown(X, Y: integer; Button: TMouseButton); override;
end;
{ TLineTool }
TLineTool = class(TDrawableTool)
procedure MouseDown(X, Y: integer; Button: TMouseButton); override;
end;
{ TMagnifierTool }
TMagnifierTool = class(TTool)
public
constructor Create; override;
procedure MouseDown(X, Y: integer; Button: TMouseButton); override;
procedure MouseMove(X, Y: integer; Shift: TShiftState); override;
function MouseUp(X, Y: integer): TFigure; override;
function GetParams: TToolParamList; override;
end;
{ TRectangleTool }
TRectangleTool = class(TFillableTool)
procedure MouseDown(X, Y: integer; Button: TMouseButton); override;
end;
{ TEllipseTool }
TEllipseTool = class(TFillableTool)
procedure MouseDown(X, Y: integer; Button: TMouseButton); override;
end;
{ TRoundRectTool }
TRoundRectTool = class(TFillableTool)
private
FRoundRadiusX: TIntegerParam;
FRoundRadiusY: TIntegerParam;
public
constructor Create; override;
destructor Destroy; override;
procedure MouseDown(X, Y: integer; Button: TMouseButton); override;
function GetParams: TToolParamList; override;
end;
{ TPolygonTool }
TPolygonTool = class(TFillableTool)
private
FVertexCount: TIntegerParam;
public
constructor Create; override;
destructor Destroy; override;
procedure MouseDown(X, Y: integer; Button: TMouseButton); override;
procedure MouseMove(X, Y: integer; Shift: TShiftState); override;
function GetParams: TToolParamList; override;
end;
{ TSelectionTool }
TSelectionTool = class(TTool)
public
constructor Create; override;
procedure MouseDown(X, Y: integer; Button: TMouseButton); override;
procedure MouseMove(X, Y: integer; Shift: TShiftState); override;
function MouseUp(X, Y: integer): TFigure; override;
function GetParams: TToolParamList; override;
end;
{ TModifierTool }
TModifierTool = class(TTool)
private
SelectedFigures: TFigureList;
IsFigureDraggable: boolean;
SelectionVertexDrag: boolean;
DragFigurePrevPoint: TDoublePoint;
DraggingVertexFigure: TFigure;
DraggingVertexIndex: integer;
FigureModified: boolean;
public
constructor Create; override;
procedure MouseDown(X, Y: integer; Button: TMouseButton); override;
procedure MouseMove(X, Y: integer; Shift: TShiftState); override;
function MouseUp(X, Y: integer): TFigure; override;
function GetParams: TToolParamList; override;
end;
var
ToolsBase: TToolList;
implementation
{ TModifierTool }
constructor TModifierTool.Create;
begin
SetLength(SelectedFigures, 0);
FMButton := mbExtra2;
DraggingVertexIndex := -1;
IsFigureDraggable := False;
SelectionVertexDrag := False;
DraggingVertexFigure := nil;
DragFigurePrevPoint := DoublePoint(0, 0);
FigureModified := false;
end;
procedure TModifierTool.MouseDown(X, Y: integer; Button: TMouseButton);
var
WorldStartCoord: TDoublePoint;
SelectionTL, SelectionBR: TDoublePoint;
i: integer;
f: TFigure;
HasSelectionOnTop: boolean;
begin
inherited MouseDown(X, Y, Button);
FigureModified := false;
WorldStartCoord := CanvasToWorld(FStartPoint);
IsFigureDraggable := False;
if (FMButton = mbLeft) and (Length(CanvasItems) > 0) then
begin
for i := High(CanvasItems) downto Low(CanvasItems) do
begin
f := CanvasItems[i];
if (not f.Selected) and (f.UnderPoint(WorldStartCoord)) then
begin
HasSelectionOnTop := false;
if Length(SelectedFigures) > 0 then
begin
SelectionTL := GetSelectionTopLeft;
SelectionBR := GetSelectionBottomRight;
DraggingVertexIndex := GetSelectionVertexIndexAtPos(FStartPoint);
if DraggingVertexIndex <> -1 then
begin
SelectionVertexDrag := true;
exit;
end;
if (SelectionTL.x - PADDING <= WorldStartCoord.x) and
(SelectionTL.y - PADDING <= WorldStartCoord.y) and
(SelectionBR.x + PADDING >= WorldStartCoord.x) and
(SelectionBR.y + PADDING >= WorldStartCoord.y) then
begin
HasSelectionOnTop := true;
break;
end;
end;
if not HasSelectionOnTop then
begin
RemoveSelection;
f.Selected := True;
SetLength(SelectedFigures, 1);
SelectedFigures[0] := f;
break;
end;
end;
if f.Selected then
begin
SetLength(SelectedFigures, Length(SelectedFigures) + 1);
SelectedFigures[High(SelectedFigures)] := f;
end;
end;
if Length(SelectedFigures) > 0 then
begin
SelectionTL := GetSelectionTopLeft;
SelectionBR := GetSelectionBottomRight;
for i := High(SelectedFigures) downto Low(SelectedFigures) do
begin
DraggingVertexIndex := GetSelectionVertexIndexAtPos(FStartPoint);
if DraggingVertexIndex <> -1 then
begin
SelectionVertexDrag := true;
exit;
end;
DraggingVertexIndex := SelectedFigures[i].GetVertexIndexAtPos(FStartPoint);
if DraggingVertexIndex <> -1 then
begin
DraggingVertexFigure := SelectedFigures[i];
exit;
end;
end;
if (WorldStartCoord.x >= SelectionTL.x) and
(WorldStartCoord.x <= SelectionBR.x) and
(WorldStartCoord.y >= SelectionTL.y) and
(WorldStartCoord.y <= SelectionBR.y) then
begin
DraggingVertexIndex := -1;
IsFigureDraggable := True;
DragFigurePrevPoint := WorldStartCoord;
end;
end;
end;
end;
procedure TModifierTool.MouseMove(X, Y: integer; Shift: TShiftState);
var
dx, dy: double;
WorldCurrPoint: TDoublePoint;
f: TFigure;
begin
if (FMButton = mbLeft) and (Length(SelectedFigures) > 0) then
begin
WorldCurrPoint := CanvasToWorld(X, Y);
if DraggingVertexIndex <> -1 then
begin
if SelectionVertexDrag then
begin
ResizeSelection(DraggingVertexIndex, WorldCurrPoint);
DraggingVertexIndex := GetSelectionVertexIndexAtPos(Point(X, Y));
end
else
DraggingVertexFigure.MoveVertex(DraggingVertexIndex, WorldCurrPoint);
FigureModified := true;
end
else
if IsFigureDraggable then
begin
dx := WorldCurrPoint.x - DragFigurePrevPoint.x;
dy := WorldCurrPoint.y - DragFigurePrevPoint.y;
for f in SelectedFigures do
begin
f.MoveFigure(dx, dy);
FigureModified := true;
DragFigurePrevPoint := WorldCurrPoint;
end;
end;
end;
end;
function TModifierTool.MouseUp(X, Y: integer): TFigure;
begin
SetLength(SelectedFigures, 0);
FMButton := mbExtra2;
IsFigureDraggable := False;
SelectionVertexDrag := False;
DraggingVertexFigure := nil;
if FigureModified then
begin
Modified := true;
FigureModified := false;
History.PushState;
end;
Result := nil;
end;
function TModifierTool.GetParams: TToolParamList;
begin
Result := nil;
end;
{ TSelectionTool }
constructor TSelectionTool.Create;
begin
FMButton := mbExtra2;
end;
procedure TSelectionTool.MouseDown(X, Y: integer; Button: TMouseButton);
var
WorldStartCoord: TDoublePoint;
begin
inherited MouseDown(X, Y, Button);
WorldStartCoord := CanvasToWorld(FStartPoint);
FFigure := nil;
if Button <> mbLeft then
exit;
FMButton := Button;
FFigure := TRegionSelection.Create(WorldStartCoord.x, WorldStartCoord.y);
end;
procedure TSelectionTool.MouseMove(X, Y: integer; Shift: TShiftState);
begin
if FFigure <> nil then
FFigure.MouseMove(X, Y);
end;
function TSelectionTool.MouseUp(X, Y: integer): TFigure;
const
eps = 16;
var
WorldStartCoord, WorldEndCoord: TDoublePoint;
TopLeft, BottomRight: TDoublePoint;
i: integer;
begin
if FFigure = nil then
exit(nil);
WorldStartCoord := CanvasToWorld(FStartPoint);
WorldEndCoord := CanvasToWorld(X, Y);
TopLeft := DoublePoint(Min(WorldStartCoord.x, WorldEndCoord.x),
Min(WorldStartCoord.y, WorldEndCoord.y));
BottomRight := DoublePoint(Max(WorldStartCoord.x, WorldEndCoord.x),
Max(WorldStartCoord.y, WorldEndCoord.y));
RemoveSelection;
if Dist(FStartPoint, Point(X, Y)) < eps then
begin
for i := High(CanvasItems) downto Low(CanvasItems) do
if CanvasItems[i] <> nil then
begin
CanvasItems[i].Selected := CanvasItems[i].UnderPoint(WorldStartCoord);
if CanvasItems[i].Selected then
break;
end;
end
else
for i := Low(CanvasItems) to High(CanvasItems) do
if CanvasItems[i] <> nil then
CanvasItems[i].Selected := CanvasItems[i].InRect(TopLeft, BottomRight);
Result := nil;
FreeAndNil(FFigure);
FMButton := mbExtra2;
end;
function TSelectionTool.GetParams: TToolParamList;
begin
Result := nil;
end;
{ TTool }
procedure TTool.MouseDown(X, Y: integer; Button: TMouseButton);
begin
FStartPoint := Point(X, Y);
FMButton := Button;
end;
{ TFillableTool }
constructor TFillableTool.Create;
begin
inherited Create;
FFillColor := TColorParam.Create('Fill color', clWhite);
FFillStyle := TFillStyleParam.Create;
end;
destructor TFillableTool.Destroy;
begin
inherited Destroy;
FreeAndNil(FFillStyle);
FreeAndNil(FFillColor);
end;
procedure TFillableTool.MouseMove(X, Y: integer; Shift: TShiftState);
var
Diff: TPoint;
MinDist: integer;
begin
if FFigure <> nil then
begin
Diff := Point(X - FStartPoint.x, Y - FStartPoint.y);
MinDist := Min(Diff.x, Diff.y);
if ssShift in Shift then
FFigure.MouseMove(FStartPoint.x + MinDist, FStartPoint.y + MinDist)
else
FFigure.MouseMove(X, Y);
end;
end;
function TFillableTool.GetParams: TToolParamList;
begin
Result := TToolParamList.Create(FLineWidth, FLineStyle, FLineColor,
FFillStyle, FFillColor);
end;
{ TDrawableTool }
constructor TDrawableTool.Create;
begin
FFigure := nil;
FLineWidth := TIntegerParam.Create('Line width', 1, 100, 1);
FLineColor := TColorParam.Create('Line color', clBlack);
FLineStyle := TLineStyleParam.Create;
end;
destructor TDrawableTool.Destroy;
begin
inherited Destroy;
//they aren't being destroyed without this. is it a bug or a feature?
FreeAndNil(FLineWidth);
FreeAndNil(FLineColor);
FreeAndNil(FLineStyle);
end;
procedure TDrawableTool.MouseDown(X, Y: integer; Button: TMouseButton);
begin
inherited MouseDown(X, Y, Button);
RemoveSelection;
end;
procedure TDrawableTool.MouseMove(X, Y: integer; Shift: TShiftState);
begin
if FFigure <> nil then
FFigure.MouseMove(X, Y);
end;
function TDrawableTool.MouseUp(X, Y: integer): TFigure;
begin
Result := FFigure;
Modified := true;
FFigure := nil;
end;
function TDrawableTool.GetParams: TToolParamList;
begin
Result := TToolParamList.Create(FLineWidth, FLineStyle, FLineColor);
end;
{ TPolygonTool }
constructor TPolygonTool.Create;
begin
inherited Create;
FVertexCount := TIntegerParam.Create('Vertexes count', 3, 50, 3);
end;
destructor TPolygonTool.Destroy;
begin
inherited Destroy;
FreeAndNil(FVertexCount);
end;
procedure TPolygonTool.MouseDown(X, Y: integer; Button: TMouseButton);
var
WorldCoords: TDoublePoint;
begin
inherited MouseDown(X, Y, Button);
WorldCoords := CanvasToWorld(X, Y);
if Button = mbLeft then
begin
FFigure := TPolygon.Create(WorldCoords.x, WorldCoords.y, FLineWidth,
FLineColor, FLineStyle, FFillColor, FFillStyle, FVertexCount);
end;
end;
procedure TPolygonTool.MouseMove(X, Y: integer; Shift: TShiftState);
var
Diff: TPoint;
MinDist: integer;
DistSign: TValueSign;
begin
if FFigure <> nil then
begin
Diff := Point(X - FStartPoint.x, Y - FStartPoint.y);
MinDist := Min(abs(Diff.x), abs(Diff.y));
DistSign := Sign(Max(Diff.x, Diff.y));
if ssShift in Shift then
FFigure.MouseMove(FStartPoint.x, FStartPoint.y - MinDist * DistSign)
else
FFigure.MouseMove(X, Y);
end;
end;
function TPolygonTool.GetParams: TToolParamList;
begin
Result := TToolParamList.Create(FVertexCount, FLineWidth, FLineStyle,
FLineColor, FFillStyle, FFillColor);
end;
{ TRoundRectTool }
constructor TRoundRectTool.Create;
begin
inherited Create;
FRoundRadiusX := TIntegerParam.Create('Rounding radius (X)', 0, 1000, 30);
FRoundRadiusY := TIntegerParam.Create('Rounding radius (Y)', 0, 1000, 30);
end;
destructor TRoundRectTool.Destroy;
begin
inherited Destroy;
FreeAndNil(FRoundRadiusX);
FreeAndNil(FRoundRadiusY);
end;
procedure TRoundRectTool.MouseDown(X, Y: integer; Button: TMouseButton);
var
WorldCoords: TDoublePoint;
begin
inherited MouseDown(X, Y, Button);
WorldCoords := CanvasToWorld(X, Y);
if Button = mbLeft then
begin
FFigure := TRoundRect.Create(WorldCoords.x, WorldCoords.y,
FLineWidth, FLineColor, FLineStyle, FFillColor, FFillStyle, FRoundRadiusX,
FRoundRadiusY);
end;
end;
function TRoundRectTool.GetParams: TToolParamList;
begin
Result := TToolParamList.Create(FLineWidth, FLineStyle, FRoundRadiusX,
FRoundRadiusY, FLineColor, FFillStyle, FFillColor);
end;
{ TEllipseTool }
procedure TEllipseTool.MouseDown(X, Y: integer; Button: TMouseButton);
var
WorldCoords: TDoublePoint;
begin
inherited MouseDown(X, Y, Button);
WorldCoords := CanvasToWorld(X, Y);
if Button = mbLeft then
begin
FFigure := TEllipse.Create(WorldCoords.x, WorldCoords.y, FLineWidth,
FLineColor, FLineStyle, FFillColor, FFillStyle);
end;
end;
{ TRectangleTool }
procedure TRectangleTool.MouseDown(X, Y: integer; Button: TMouseButton);
var
WorldCoords: TDoublePoint;
begin
inherited MouseDown(X, Y, Button);
WorldCoords := CanvasToWorld(X, Y);
if Button = mbLeft then
begin
FFigure := TRectangle.Create(WorldCoords.x, WorldCoords.y,
FLineWidth, FLineColor, FLineStyle, FFillColor, FFillStyle);
end;
end;
{ TMagnifierTool }
constructor TMagnifierTool.Create;
begin
FMButton := mbExtra2;
end;
procedure TMagnifierTool.MouseDown(X, Y: integer; Button: TMouseButton);
var
WorldStartCoord: TDoublePoint;
begin
inherited MouseDown(X, Y, Button);
WorldStartCoord := CanvasToWorld(FStartPoint);
FFigure := nil;
if (Button <> mbLeft) and (Button <> mbRight) then
exit;
FMButton := Button;
FFigure := TRegionSelection.Create(WorldStartCoord.x, WorldStartCoord.y);
end;
procedure TMagnifierTool.MouseMove(X, Y: integer; Shift: TShiftState);
begin
if FFigure <> nil then
FFigure.MouseMove(X, Y);
end;
function TMagnifierTool.MouseUp(X, Y: integer): TFigure;
const
eps = 16;
var
WorldStartCoord, WorldEndCoord: TDoublePoint;
TopLeft, BottomRight: TDoublePoint;
NewScale: double;
begin
if FFigure = nil then
exit(nil);
WorldStartCoord := CanvasToWorld(FStartPoint);
WorldEndCoord := CanvasToWorld(X, Y);
TopLeft := DoublePoint(Min(WorldStartCoord.x, WorldEndCoord.x),
Min(WorldStartCoord.y, WorldEndCoord.y));
BottomRight := DoublePoint(Max(WorldStartCoord.x, WorldEndCoord.x),
Max(WorldStartCoord.y, WorldEndCoord.y));
case FMButton of
mbLeft:
begin
if Dist(FStartPoint, Point(X, Y)) < eps then
ZoomPoint(WorldEndCoord, Scale * 2)
else
begin
NewScale := Max(CanvasWidth / (BottomRight.x - TopLeft.x),
CanvasHeight / (BottomRight.y - TopLeft.y));
if NewScale > Scale then
ZoomRect(TopLeft, BottomRight, NewScale);
end;
end;
mbRight:
if Dist(FStartPoint, Point(X, Y)) < eps then
ZoomPoint(WorldEndCoord, Scale / 2);
end;
Result := nil;
FreeAndNil(FFigure);
FMButton := mbExtra2;
end;
function TMagnifierTool.GetParams: TToolParamList;
begin
Result := nil;
end;
{ TLineTool }
procedure TLineTool.MouseDown(X, Y: integer; Button: TMouseButton);
var
WorldCoords: TDoublePoint;
begin
inherited MouseDown(X, Y, Button);
WorldCoords := CanvasToWorld(X, Y);
if Button = mbLeft then
begin
FFigure := TLine.Create(WorldCoords.x, WorldCoords.y, FLineWidth,
FLineColor, FLineStyle);
end;
end;
{ THandTool }
constructor THandTool.Create;
begin
FMButton := mbExtra2;
end;
procedure THandTool.MouseDown(X, Y: integer; Button: TMouseButton);
begin
inherited MouseDown(X, Y, Button);
WorldStartCoord := CanvasToWorld(X, Y);
end;
procedure THandTool.MouseMove(X, Y: integer; Shift: TShiftState);
var
WorldEndCoord: TDoublePoint;
begin
if FMButton = mbLeft then
begin
WorldEndCoord := CanvasToWorld(X, Y);
CanvasOffset.x := CanvasOffset.x + WorldStartCoord.x - WorldEndCoord.x;
CanvasOffset.y := CanvasOffset.y + WorldStartCoord.y - WorldEndCoord.y;
end;
end;
function THandTool.MouseUp(X, Y: integer): TFigure;
begin
Result := nil;
FMButton := mbExtra2;
end;
function THandTool.GetParams: TToolParamList;
begin
Result := nil;
end;
{ TPolylineTool }
procedure TPolylineTool.MouseDown(X, Y: integer; Button: TMouseButton);
var
WorldCoords: TDoublePoint;
begin
inherited MouseDown(X, Y, Button);
WorldCoords := CanvasToWorld(X, Y);
if Button = mbLeft then
begin
FFigure := TPolyLine.Create(WorldCoords.x, WorldCoords.y, FLineWidth,
FLineColor, FLineStyle);
end;
end;
initialization
ToolsBase := TToolList.Create(TModifierTool.Create, THandTool.Create,
TSelectionTool.Create, TMagnifierTool.Create, TPolylineTool.Create,
TLineTool.Create, TRectangleTool.Create, TEllipseTool.Create,
TRoundRectTool.Create, TPolygonTool.Create);
end.