-
Notifications
You must be signed in to change notification settings - Fork 10
/
652_graph3DMainUnit2.pas
1315 lines (1228 loc) · 34.7 KB
/
652_graph3DMainUnit2.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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit MainUnit3DGraph;
{Demonstrates the functionality of the Graph3D-component.
Basically, you gotta create a set of TGraphline, which consist of arrays of
single. The points on these lines are assumed to be equally spaced between
StartPoint and StopPoint (see graph3D.pas).
These lines are then given to the Graph3D with AddLine(). Graph3D handles their
memory managment from here, so you should not free them yourself.
The procedure FillPlotSquare() initializes a Set of Graphlines (in the form
of a TList) and fills them with values.
adapt to maXbox script engine by mX4
#sign:Max: MAXBOX10: 15/10/2016 10:17:26
//TODO: check the free of the objectlist mem leak!
Use rgMouse to decide how the Plot reacts to mouse-dragging, Right-click into
plot to start/stop scrolling the lines. cbIncScroll influences how the scrolling
takes place. #locs:908
}
interface
{uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Spin, Grids, ExtCtrls, ComCtrls, Menus, Graph3D;
}
//type
var
//TForm1 = class(TForm)
Panel1: TPanel;
btnCopy: TButton;
cmdClear: TButton;
GroupBox1: TGroupBox;
ColorDialog1: TColorDialog;
cmdDcolor: TPanel;
cmdCentre: TButton;
Mess: TMemo;
cbAxes: TCheckBox;
cmdAxesColor: TPanel;
cbIncScroll: TCheckBox;
cmdRead: TButton;
p0: TPanel;
p1: TPanel;
p2: TPanel;
p3: TPanel;
p4: TPanel;
p5: TPanel;
p6: TPanel;
p7: TPanel;
p8: TPanel;
p9: TPanel;
Button2: TButton;
rgWaterlevel: TRadioGroup;
edWater: TSpinEdit;
Button3: TButton;
cbUseColours: TCheckBox;
cbHiddenLines: TCheckBox;
cbInWhite: TCheckBox;
PopupMenu1: TPopupMenu;
Stop1: TMenuItem;
rgMouse: TRadioGroup;
edPercent: TSpinEdit;
Label1: TLabel;
procedure TForm1_btnCopyClick(Sender: TObject);
procedure TForm1_FormDestroy(Sender: TObject);
procedure TForm1_FormCreate(Sender: TObject);
procedure TForm1_cmdClearClick(Sender: TObject);
procedure TForm1_cmdDcolorClick(Sender: TObject);
procedure TForm1_cmdCentreClick(Sender: TObject);
procedure TForm1_cmdAxesColorClick(Sender: TObject);
procedure TForm1_cmdReadClick(Sender: TObject);
procedure TForm1_FormClose(Sender: TObject; var Action: TCloseAction);
procedure TForm1_p0Click(Sender: TObject);
procedure TForm1_p1Click(Sender: TObject);
procedure TForm1_p2Click(Sender: TObject);
procedure TForm1_p3Click(Sender: TObject);
procedure TForm1_p4Click(Sender: TObject);
procedure TForm1_p5Click(Sender: TObject);
procedure TForm1_p6Click(Sender: TObject);
procedure TForm1_p7Click(Sender: TObject);
procedure TForm1_p8Click(Sender: TObject);
procedure TForm1_p9Click(Sender: TObject);
procedure TForm1_Button2Click(Sender: TObject);
procedure TForm1_rgWaterlevelClick(Sender: TObject);
procedure TForm1_cbAxesClick(Sender: TObject);
procedure TForm1_cbIncScrollClick(Sender: TObject);
procedure TForm1_Button3Click(Sender: TObject);
procedure TForm1_rgMouseClick(Sender: TObject);
procedure TForm1_cbUseColoursClick(Sender: TObject);
procedure TForm1_cbHiddenLinesClick(Sender: TObject);
procedure TForm1_PlotAfterDraw(Sender: TObject);
procedure TForm1_PlotScroll(Sender: TObject);
procedure TForm1_Stop1Click(Sender: TObject);
procedure TForm1_PlotStopScrolling(Sender: TObject);
procedure TForm1_FormShow(Sender: TObject);
procedure TForm1_edPercentChange(Sender: TObject);
//private
var
//Array2D : TIntegerList; //of TGraphLines
Array2D : TObjectList; //of TGraphLines
Zmax: single; // = 1.1; //*(Sqr(NoOfPointsInLine div 2)+Sqr(NoOfLines div 2));
Plot: TGraph3D;
//end;
var
Form1: TForm;
implementation
//uses Unit2;
const NoOfLines = 88;
NoOfPointsInLine = 88;
// Zmax = 1.1; //*(Sqr(NoOfPointsInLine div 2)+Sqr(NoOfLines div 2));
//{$R *.DFM}
{------------------------------------------------------------------------------}
procedure FillPlotSquare;
var i,j : LongInt;
a : TGraphLine;
f,g : Single;
ptX, ptY : Single;
begin
ptX := NoOfPointsInLine*0.25;
ptY := NoOfLines*0.75;
g := Sqr((NoOfPointsInLine / 4)) + Sqr((NoOfLines / 4)); //Sqr(radius of circle)
For j := 0 to NoOfLines-1 do begin
a := TGraphLine.Create(NoOfPointsInLine);
a.StartPoint := Point3D3(0,j,0);
a.StopPoint := Point3D3(NoOfPointsInLine,j,0);
For i := 0 to NoOfPointsInLine-1 do begin
//basic square-func:
a[i] := Zmax - Sqr(i-(NoOfPointsInLine div 2)) - Sqr(j-(NoOfLines div 2));
//basic square-func.
//add cone in one quadrant:
f := Sqr(i-ptX) + Sqr(j-ptY); //Sqr(distance from quad.-centre)
If f <= g then a[i] := a[i] + 5*(g-f);
end;
Array2D.Add(a);
end;
end;
//form-stuff:------------------------------------------------------------------}
procedure TForm1_FormCreate(Sender: TObject);
begin
Zmax:= 1.1*(Sqr(NoOfPointsInLine div 2)+Sqr(NoOfLines div 2));
Plot := TGraph3D.Create(Form1);
Plot.Parent := Form1;
Plot.Align := alClient;
Plot.AfterDraw := @TForm1_PlotAfterDraw;
Plot.onScroll := @TForm1_PlotScroll;
//plot.onclick
Plot.OnStopScrolling := @TForm1_PlotStopScrolling;
TForm1_cmdReadClick(Self); //read options of the Graph3D
//create and fill Array2D:
//Array2D := TIntegerList.Create;
Array2D := TObjectList.Create;
FillPlotSquare; //puts cute values into Array2D
For it:= 0 to Array2D.Count-1 do
Plot.AddLine(TGraphLine(Array2D[it]));
end;
procedure letBuildTestForm;
var RS : TResourceStream;
image1, image2: TImage;
chk1, chk2: TCheckbox;
begin
Form1:= TForm.create(self)
with form1 do begin
setBounds(192,333,740,510)
Caption:= 'Dice Simulation 2016'
FormStyle:= fsstayonTop;
Color:= clGreen; //clBtnFace
Font.Charset:= DEFAULT_CHARSET; Font.Color:= clWindowText;
Font.Height:= -11; Font.Name:= 'MS Sans Serif';
Font.Style:= []
OldCreateOrder:= False
Position:= poScreenCenter
//OnActivate:= @TForm1_FormActivate;
PixelsPerInch:= 96
//TextHeight(13)
Show;
end;
Image1:= TImage.create(form1)
with image1 do begin
parent:= form1;
transparent:= true;
setBounds(580,228,249,113)
Picture.Bitmap.LoadFromResourcename(HInstance,'JV_DICE5');
end;
Image2:= TImage.create(form1)
with image2 do begin
parent:= form1;
transparent:= true;
//RS:= TResourceStream.Create(HInstance,'Splashscreen_Background', RT_RCDATA);
setBounds(580,50,249,113)
Picture.Bitmap.LoadFromResourcename(HInstance,'JV_DICE6');
end;
with TGraph3D.create(self) do begin
parent:= form1;
//transparent:= true;
//RS:= TResourceStream.Create(HInstance,'Splashscreen_Background', RT_RCDATA);
setBounds(80,50,480,400)
//Picture.Bitmap.LoadFromResourcename(HInstance,'JV_DICE6');
end;
{DrawDiceBtn:= TBitBtn.create(form1);
with DrawDiceBtn do begin
parent:= form1;
font.size:= 12; //font.style:= [fsbold]
setBounds(80,15,220,36)
Caption:= '&Draw pair random dice'
glyph.LoadFromResourceName(getHINSTANCE,'LED_GREEN_ON');
TabOrder:= 0
// OnClick:= @TForm1_DrawDiceBtnClick;
// onMouseDown:= @TForm1_MouseDownClick;
// onMouseUp:= @TForm1_MouseUpClick;
end;
SimuDiceBtn:= TBitBtn.create(form1);
with SimuDiceBtn do begin
parent:= form1;
font.size:= 12; //font.style:= [fsbold]
setBounds(80,65,220,36)
Caption:= '&Run same pair of dice'
glyph.LoadFromResourceName(getHINSTANCE,'AQUA');
TabOrder:= 1
OnClick:= @TForm1_MouseClickSim
end;
end; }
chk1:= TCheckbox.create(form1);
with chk1 do begin
parent:= form1;
caption:= 'P(n)=6/36';
font.color:= clRed;
setBounds(8,65,70,22)
end;
chk2:= TCheckbox.create(form1);
with chk2 do begin
parent:= form1;
caption:= 'P(n)=1/36';
font.color:= clRed;
setBounds(8,115,70,22)
end;
end;
procedure TForm1_FormDestroy(Sender: TObject);
begin
{for it:= 0 to Array2D.Count-1 do
TGraphLine(Array2D[it]).Free; }
//NONSENSE, Plot3D takes care of this}
Plot.Free;
Array2D.Free;
writeln('plot frame and object graph line list freeed')
end;
{Unit 2}
var ScrollBox1: TScrollBox;
Image1: TImage;
frmcopy: TForm;
procedure TfrmCopy_FormShow(Sender: TObject);
begin
Image1.Width := Image1.Picture.Bitmap.Width;
Image1.Height := Image1.Picture.Bitmap.Height;
end;
procedure build_Frmcopy;
begin
frmCopy:= TForm.create(self)
Image1:= TImage.create(self)
with frmcopy do begin
setbounds(200, 108, 696,593)
Caption:= 'frmCopy'
Font.Charset:= DEFAULT_CHARSET
Font.Color:= clWindowText
Font.Height:= -11
Font.Name:= 'MS Sans Serif'
Font.Style:= []
Position:= poScreenCenter
OnShow:= @TfrmCopy_FormShow
PixelsPerInch:= 96
//TextHeight:= 13
end;
ScrollBox1:= TScrollBox.create(self)
with scrollbox1 do begin
parent:= frmCopy;
setBounds(0,0,688,566)
Align:= alClient
TabOrder:= 0
end;
Image1:= TImage.create(self)
with image1 do begin
parent:= scrollbox1
setbounds(0,0,429,341)
end;
//end
end;
procedure TForm1_btnCopyClick(Sender: TObject);
begin
//Image1:= TImage.create(self)
build_Frmcopy;
with frmCopy do begin
Image1.Picture.Bitmap.Assign(Plot.AsBitmap(cbInWhite.Checked));
ShowModal;
end;
frmCopy.Free;
end;
procedure TForm1_cmdClearClick(Sender: TObject);
begin
Plot.ClearPicture;
end;
procedure TForm1_cmdDcolorClick(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
cmddcolor.ParentBackground:= false;
cmdDcolor.Color := ColorDialog1.Color;
Plot.DataColor := cmdDcolor.Color;
Plot.Invalidate;
end;
procedure TForm1_cmdAxesColorClick(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
cmdAxescolor.Color := ColorDialog1.Color;
Plot.AxesColor := cmdAxescolor.Color;
Plot.Invalidate;
end;
procedure TForm1_cmdReadClick(Sender: TObject);
begin
cmdDcolor.Color := Plot.DataColor;
cmdAxesColor.Color := Plot.AxesColor;
cbAxes.Checked := Plot.DrawAxes;
cbHiddenLines.Checked := Plot.drawHiddenLines;
cbUseColours.Checked := Plot.UseColors;
cbIncScroll.Checked := Plot.IncrementalScroll;
rgWaterLevel.ItemIndex := Ord(Plot.WaterLevelType);
edWater.Value := Round(Plot.Waterlevel);
edpercent.Value := Plot.ViewPercentage;
end;
procedure TForm1_cmdCentreClick(Sender: TObject);
begin
Plot.CenterPlot;
Plot.Invalidate;
end;
procedure TForm1_FormClose(Sender: TObject; var Action: TCloseAction);
begin
Plot.StopScrolling;
writeln('form plot close...')
//TForm1_FormDestroy(self);
//action:= cafree;
Plot.Free;
form1.Free;
end;
procedure TForm1_p0Click(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
p0.Color := ColorDialog1.Color;
Plot.SetIsodose(0,5,p0.Color);
end;
procedure TForm1_p1Click(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
p1.Color := ColorDialog1.Color;
Plot.SetIsodose(0,15,p1.Color);
end;
procedure TForm1_p2Click(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
p2.Color := ColorDialog1.Color;
Plot.SetIsodose(0,25,p2.Color);
end;
procedure TForm1_p3Click(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
p3.Color := ColorDialog1.Color;
writeln('debug color isodose: '+itoa(p3.color))
Plot.SetIsodose(0,35,p3.Color);
end;
procedure TForm1_p4Click(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
p4.Color := ColorDialog1.Color;
Plot.SetIsodose(0,45,p4.Color);
end;
procedure TForm1_p5Click(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
p5.Color := ColorDialog1.Color;
Plot.SetIsodose(0,55,p5.Color);
end;
procedure TForm1_p6Click(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
p6.Color := ColorDialog1.Color;
Plot.SetIsodose(0,65,p6.Color);
end;
procedure TForm1_p7Click(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
p7.Color := ColorDialog1.Color;
Plot.SetIsodose(0,75,p7.Color);
end;
procedure TForm1_p8Click(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
p8.Color := ColorDialog1.Color;
Plot.SetIsodose(0,85,p8.Color);
end;
procedure TForm1_p9Click(Sender: TObject);
begin
If not ColorDialog1.Execute then Exit;
p9.Color := ColorDialog1.Color;
Plot.SetIsodose(0,95,p9.Color);
end;
procedure TForm1_Button2Click(Sender: TObject);
begin
plot.ParentBackground:= false;
Plot.SetIsodose(0,5,p0.Color);
Plot.SetIsodose(1,15,p1.Color);
Plot.SetIsodose(2,25,p2.Color);
Plot.SetIsodose(3,35,p3.Color);
Plot.SetIsodose(4,45,p4.Color);
Plot.SetIsodose(5,55,p5.Color);
Plot.SetIsodose(6,65,p6.Color);
Plot.SetIsodose(7,75,p7.Color);
Plot.SetIsodose(8,85,p8.Color);
Plot.SetIsodose(9,95,p9.Color);
Plot.Invalidate;
end;
procedure TForm1_rgWaterlevelClick(Sender: TObject);
begin
case rgWaterlevel.ItemIndex of
0 : Plot.SetWaterlevel(wlNone,edWater.Value);
1 : Plot.SetWaterlevel(wlAbove,edWater.Value);
2 : Plot.SetWaterlevel(wlBelow,edWater.Value);
end;
case rgWaterlevel.ItemIndex of
1 : Plot.SetIsodose(9,edWater.Value,clNone);
2 : Plot.SetIsodose(9,edWater.Value,clNone);
end;
end;
procedure TForm1_cbAxesClick(Sender: TObject);
begin
Plot.DrawAxes := cbAxes.Checked;
end;
procedure TForm1_cbIncScrollClick(Sender: TObject);
begin
Plot.IncrementalScroll := cbIncScroll.Checked;
end;
procedure TForm1_Button3Click(Sender: TObject);
var border : Single;
i : Byte;
begin
case rgWaterlevel.ItemIndex of
0 : Exit;
1 : Border := edwater.Value+0.5;
2 : Border := edwater.Value-0.5;
end;
For i := 0 to 9 do
Plot.SetIsodose(i,Border,clWhite);
Plot.SetIsodose(9,Border,clBlack);
end;
procedure TForm1_rgMouseClick(Sender: TObject);
begin
case rgMouse.ItemIndex of
0 : Plot.MouseControl := mcNone;
1 : Plot.MouseControl := mcRotate;
2 : Plot.MouseControl := mcMove;
3 : Plot.MouseControl := mcZoom;
end;
end;
procedure TForm1_cbUseColoursClick(Sender: TObject);
begin
Plot.UseColors := cbUseColours.Checked;
end;
procedure TForm1_cbHiddenLinesClick(Sender: TObject);
begin
plot.DrawHiddenLines := cbHiddenLines.Checked;
end;
procedure TForm1_PlotAfterDraw(Sender: TObject);
begin
If mess.lines.Count > 100 then mess.Clear;
Mess.Lines.Add(IntToStr(Mess.Lines.Count)+': AfterDraw');
end;
procedure TForm1_PlotScroll(Sender: TObject);
begin
If mess.lines.Count > 100 then mess.Clear;
Mess.Lines.Add(IntToStr(Mess.Lines.Count)+': Scrolled line '+IntToStr(Plot.ScrollIndex));
end;
procedure TForm1_Stop1Click(Sender: TObject);
begin
If Plot.IsScrolling
then plot.stopscrolling
else plot.ScrollLines;
end;
procedure TForm1_PlotStopScrolling(Sender: TObject);
begin
If mess.lines.Count > 100 then mess.Clear;
Mess.Lines.Add(IntToStr(Mess.Lines.Count)+': AfterScroll');
end;
procedure TForm1_FormShow(Sender: TObject);
begin
TForm1_cmdReadClick(Self);
end;
procedure TForm1_edPercentChange(Sender: TObject);
begin
Plot.ViewPercentage := edPercent.value;
Plot.Invalidate;
end;
procedure Tform1_btnsaveclick(Sender: TObject);
//Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
//if( ssRight in Shift ) then begin
// Image1.Picture.Bitmap.Assign(Plot.AsBitmap(cbInWhite.Checked));
with TImage.create(self) do begin
setbounds(0,0,429,341)
Picture.Bitmap.Assign(Plot.AsBitmap(cbInWhite.Checked));
//form1.canvas.Assign(Plot.AsBitmap(cbInWhite.Checked));
SaveCanvas2(Canvas, Exepath+'3d_processingimage.png');
Free;
end;
opendoc(Exepath+'3d_processingimage.png');
end;
Procedure PanelFactory(a,b,c,d: byte; title: shortstring; acolor: TColor;
tord: byte; var apan: TPanel; anevent: TNotifyEvent);
begin
apan:= TPanel.create(self)
with apan do begin
parent:= groupbox1;
if length(title) < 4 then
ParentBackground:= false;
SetBounds(a,b,c,d)
Caption:= title;
color:= acolor
taborder:= tord;
OnClick:= anevent as TNotifyEvent;
end;
end;
procedure main3DGraphForm;
begin
Form1:= TForm.create(self)
with form1 do begin
setBounds(306,115,780,543)
Caption:= 'maXbox TGraph3D 2016 V2'
Font.Charset:= DEFAULT_CHARSET
Font.Color:= clWindowText
Font.Height:= -11
Font.Name:= 'MS Sans Serif'
Font.Style:= []
Position:= poScreenCenter
OnClose:= @TForm1_FormClose
OnCreate:= @TForm1_FormCreate
OnDestroy:= @TForm1_FormDestroy
OnShow:= @TForm1_FormShow
PixelsPerInch:= 96
//TextHeight:= 13
//Show;
end;
//TForm1_FormCreate(Self);
Panel1:= TPanel.create(form1)
with panel1 do begin
parent:= form1
setBounds(0,0,650,37)
Align:= alTop
TabOrder:= 0
end;
btnCopy:= TButton.create(form1)
with btncopy do begin
parent:= panel1
setBounds(476,8,75,25)
Caption:= 'copy plot'
TabOrder:= 0
OnClick:= @Tform1_btnCopyClick
end;
cmdClear:= TButton.create(form1)
with cmdclear do begin
parent:= panel1
setbounds(8,8,75,25)
Caption:= 'Clear plot'
TabOrder:= 1
OnClick:= @tform1_cmdClearClick
end;
cmdCentre:= TButton.create(form1)
with cmdCentre do begin
parent:= panel1
setbounds(88,8,81,25)
Caption:= 'Centre'
TabOrder:= 2
OnClick:= @tform1_cmdCentreClick
end;
cbInWhite:= TCheckBox.create(form1)
with cbInWhite do begin
parent:= panel1
setbounds(556,12,77,17)
Caption:= 'cbInWhite'
TabOrder:= 3
end;
with TButton.create(form1) do begin
parent:= panel1
setBounds(650,8,75,25)
Caption:= 'save plot'
TabOrder:= 0
OnClick:= @Tform1_btnsaveClick
end;
rgMouse:= TRadioGroup.create(form1)
with rgmouse do begin
parent:= panel1
setbounds(180,0,289,33)
Caption:= 'rgMouse'
Columns:= 4
Items.add('none'); Items.add('rotate');
Items.add('pan'); Items.add('zoom');
ItemIndex:= 1
TabOrder:= 4
OnClick:= @tform1_rgMouseClick
//tform1_rgMouseClick(self);
end;
//end panel1
GroupBox1:= TGroupBox.create(form1)
with groupbox1 do begin
parent:= form1
setbounds(0,37,153,479)
Align:= alLeft
Caption:= 'Options'
TabOrder:= 1
end;
// writeln('dome')
Label1:= TLabel.create(form1)
with label1 do begin
parent:= groupbox1
setbounds(104,240,34,13)
Caption:= 'View-%'
end;
Mess:= TMemo.create(self)
with mess do begin
parent:= groupbox1
setbounds(2,284,149,189)
Lines.add('Mess')
ScrollBars:= ssVertical
TabOrder:= 1
end;
cbAxes:= TCheckBox.create(form1)
with cbaxes do begin
parent:= groupbox1
setbounds(4,248,61,17)
Caption:= 'cbAxes'
State:= cbChecked
TabOrder:= 2
OnClick:= @tform1_cbAxesClick
end;
cmdAxesColor:= TPanel.create(form1)
with cmdaxescolor do begin
parent:= groupbox1
setbounds(4,44,75,25)
Caption:= 'cmdAxesColor'
Color:= clRed
TabOrder:= 3
OnClick:= @tform1_cmdAxesColorClick
end;
cbIncScroll:= TCheckBox.create(form1)
with cbincscroll do begin
parent:= groupbox1
setbounds(4,264,77,17)
Caption:= 'cbIncScroll'
State:= cbChecked
TabOrder:= 4
OnClick:= @tform1_cbIncScrollClick
end;
cmdRead:= TButton.create(self)
with cmdread do begin
parent:= groupbox1
setbounds(108,12,41,21)
Caption:= 'Read'
TabOrder:= 5
OnClick:= @tform1_cmdReadClick
end;
PanelFactory(4,16,75,25,'cmdDcolor',clred,0,cmddcolor,
@tform1_cmdDcolorClick);
//cmddcolor.color:= clred;
// TForm1_FormCreate(Self);
//Procedure PanelFactory(a,b,c,d: byte; title: shortstring; acolor: TColor;
// tord: byte; var apan: TPanel; anevent: TNotifyEvent);
//ParentBackground:= false;
PanelFactory(4,72,25,25,'p0',clred,6,p0, @tform1_p0Click);
PanelFactory(28,72,25,25,'p1',clyellow,7,p1, @tform1_p1Click);
PanelFactory(52,72,25,25,'p2',clMaroon,8,p2, @tform1_p2Click);
PanelFactory(4,96,25,25,'p3',clYellow,9,p3, @tform1_p3Click);
PanelFactory(28,96,25,25,'p4',clMaroon,10,p4, @tform1_p4Click);
PanelFactory(52,96,25,25,'p5',clyellow,11,p5, @tform1_p5Click);
PanelFactory(4,120,25,25,'p6',clmaroon,12,p6, @tform1_p6Click);
PanelFactory(28,120,25,25,'p7',clYellow,13,p7, @tform1_p7Click);
PanelFactory(52,120,25,25,'p8',clYellow,14,p8, @tform1_p8Click);
PanelFactory(76,120,25,25,'p9',10485760,15,p9, @tform1_p9Click);
Button2:= TButton.create(form1);
with button2 do begin
parent:= groupbox1
setbounds(80,72,69,25)
Caption:= 'set colors'
TabOrder:= 16
OnClick:= @tform1_Button2Click
end;
rgWaterlevel:= TRadioGroup.create(form1)
with rgWaterlevel do begin
parent:= groupbox1
setbounds(4,152,77,61)
Caption:= 'rgWaterlevel'
ItemIndex:= 0
Items.add('none')
items.add('above')
items.add('below')
TabOrder:= 17
OnClick:= @tform1_rgWaterlevelClick
end;
edWater:= TSpinEdit.create(form1)
with edwater do begin
parent:= groupbox1
setbounds(84,180,41,22)
MaxValue:= 100
MinValue:= 0
TabOrder:= 18
Value:= 95
end;
Button3:= TButton.create(form1)
with button3 do begin
parent:= groupbox1
setbounds(84,156,61,25)
Caption:= 'opt. colors'
TabOrder:= 19
OnClick:= @tform1_Button3Click
end;
cbUseColours:= TCheckBox.create(form1)
with cbusecolours do begin
parent:= groupbox1
setbounds(4,216,97,17)
Caption:= 'cbUseColours'
State:= cbChecked
TabOrder:= 20
OnClick:= @tform1_cbUseColoursClick
end;
cbHiddenLines:= TCheckBox.create(form1)
with cbhiddenlines do begin
parent:= groupbox1
setbounds(4,232,97,17)
Caption:= 'cbHiddenLines'
State:= cbChecked
TabOrder:= 21
OnClick:= @tform1_cbHiddenLinesClick
end;
edPercent:= TSpinEdit.create(form1)
with edpercent do begin
parent:= groupbox1
setbounds(104,256,41,22)
MaxValue:= 100
MinValue:= 0
TabOrder:= 22
Value:= 95
OnChange:= @tform1_edPercentChange
end;
//end groupbox1
TForm1_FormCreate(Self);
form1.show
ColorDialog1:= TColorDialog.create(form1);
with colordialog1 do begin
//parent:= form1
Ctl3D:= True
//Left:= 112
//Top:= 141
end;
Stop1:= TMenuItem.create(form1)
with stop1 do begin
Caption:= 'Start/Stop'
OnClick:= @tform1_Stop1Click
end;
popupMenu1:= TPopupMenu.create(form1)
with popupmenu1 do begin
Items.Add(stop1);
//Top:= 184
end;
//form1.popupmenu:= popupmenu1;
groupbox1.popupmenu:= popupmenu1;
{selected1:= TMenuItem.Create(popupmenu1)
with selected1 do begin
popupmenu1.Items.Add(selected1);
Caption:= 'Selected / RSelected';
OnClick:= @TDBFrm_Selected1Click;
end;
N1:= TMenuItem.Create(popupmenu1)
with N1 do begin
popupmenu1.Items.Add(N1);
Caption:= '-';
end;}
//end
end;
procedure TestGraphline;
{example: }
var Line : TGraphLine;
i : LongInt;
begin
Line:= TGraphLine.Create(10);
//init values:
For i := 0 to 9 do
Line[i] := Sqr(i-5);
//set direction of this line: (here in X-dir at Y=12.1)
Line.StartPoint := Point3D3(0, 12.1, 0); //Z anyway gets ignored
Line.StopPoint := Point3D3(100, 12.1, 0);
//now display all values as 3D-points:
For i := 0 to Line.NoOfValues-1 do
//ShowMessage('x,y '+FormatFloat('0.0',Line.X[i])+' '+
// FormatFloat('0.0', Line.Y[i]));
writeln('x,y,z: '+FormatFloat('0.0',Line.X[i])+
', '+FormatFloat('0.0', Line.Y[i])+
', '+FormatFloat('0.0', Line.x[i]));
line.Free;
end;
//end;
procedure preparechessBoard;
var kt: byte;
line: string;
begin
line:= 'ABCDEFGH';
for it:= 8 downto 1 do
for kt:= 1 to 8 do begin
write(line[kt]+itoa(it))
if kt=8 then writeln('')
end;
end;
procedure preparechessBoard2;
var kt: byte;
line: string;
begin
line:= 'ABCDEFGH'+CRLF;
for it:= 8 downto 1 do
for kt:= 1 to 9 do
write(line[kt]+itoa(it))
end;
begin //main
//letBuildForm;
TestGraphline;
main3DGraphForm;
tform1_rgMouseClick(self);
//TForm1_FormCreate(Self);
//preparechessBoard;
//preparechessBoard2;
End.
{//Possible values for TGraph3D.WaterLevel
TWaterlevel = (wlNone, wlAbove, wlBelow);
//Basic class for one line of a 2D-array of values.
//Defined in this way to allow both dimensions to be set at runtime.
TGraphLine = Class(TObject)
Private
fNoOfValues : LongInt;
fValues : PSingleArray; //assumption: equally spaced
procedure SetVal(Index: Integer; V:Single);
function GetVal(Index: Integer) : Single;
function GetX(Index: Integer) : Single;
function GetY(Index: Integer) : Single;
Public
//Each line can start and stop anywhere on the XY-plane.
//The X/Y-values are interpolated linearly between StartPoint and StopPoint.
//Z-coord gets ignored here.
StartPoint : T3DPoint;
//Each line can start and stop anywhere on the XY-plane.
//The X/Y-values are interpolated linearly between StartPoint and StopPoint.
//V-coord gets ignored here.
StopPoint : T3DPoint;
//Read-only property to see how many values are are in this line.
//Gets set in Create
property NoOfValues : LongInt read fNoOfValues;
//Reads/writes the Z values of the points in the line.
//See also: X,Y
{example:
var Line : TGraphLine;
i : LongInt;
begin
Line := TGraphLine.Create(10);
//init values:
For i := 0 to 9 do
Line[i] := Sqr(i-5);
//set direction of this line: (here in X-dir at Y=12.1)
Line.StartPoint := Point3D(0, 12.1, 0); //Z anyway gets ignored
Line.StopPoint := Point3D(100, 12.1, 0);
//now display all values as 3D-points:
For i := 0 to Line.NoOfValues-1 do
ShowMessage('x,y,z: '+FormatFloat('0.0',Line.X[i])+
', '+FormatFloat('0.0', Line.Y[i]+
ForamtFloat('0.0', Line[i]));
end;
}
(* property Vals[Index: Integer]: Single read GetVal write SetVal; default;
//Reads/writes the X-values of the points in the line
//See also: Y, Vals (which contains an example of how to use these properties)
property X[Index: Integer]: Single read GetX;
//Reads/writes the Y-values of the points in the line
//See also: X, Vals (which contains an example of how to use these properties)
property Y[Index: Integer]: Single read GetY;
//Standard constructor for a TGraphLine.
//Once and for all sets the NoOfValues
constructor Create(Nvals : LongInt);
//Frees the line and all points in it
destructor Destroy; override;
end;
type
{A component for displaying arrays of values as a net.
*)
// LoadDFMFile2Strings('C:\Program Files (x86)\maxbox3\Import\grph3d01\MainUnit.dfm', dfmlist,wastext);
(*
object Form1: TForm1
Left = 306
Top = 115
Width = 658
Height = 543
Caption = 'Form1'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
Position = poScreenCenter
>
>
>
>
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 0
Width = 650
Height = 37
Align = alTop
TabOrder = 0
You can’t perform that action at this time.