-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgauge_unit.pas
More file actions
2262 lines (1745 loc) · 107 KB
/
gauge_unit.pas
File metadata and controls
2262 lines (1745 loc) · 107 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
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
(*
================================================================================
This file is part of OpenTemplot2024, a computer program for the design of model railway track.
Copyright (C) 2024 Martin Wynne. email: martin@85a.uk
This program is free software: you may redistribute it and/or modify
it under the terms of the GNU General Public Licence as published by
the Free Software Foundation, either version 3 of the Licence, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public Licence for more details.
You should have received a copy of the GNU General Public Licence
along with this program. See the file: licence.txt
Or if not, refer to the web site: https://www.gnu.org/licenses/
================================================================================
This file was saved from Delphi5
This file was derived from Templot2 version 244e
*)
unit gauge_unit;
{$MODE Delphi}
{$ALIGN OFF}
interface
uses
StdCtrls, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ComCtrls, PrintersDlgs;
//Lazarus bug-fix:
//to give a compiler error; that an enumeration is not compatible with TOwnerDrawState.
//A temporary fix is to list StdCtrls before Windows in the unit uses clause.
type
Tgauge_form = class(TForm)
ok_button: TButton;
blue_corner_panel: TPanel;
how_panel: TPanel;
chat_panel: TPanel;
exact_scale_button: TButton;
ok_large_panel: TPanel;
custom_groupbox: TGroupBox;
custom_a_button: TButton;
custom_b_button: TButton;
custom_c_button: TButton;
custom_d_button: TButton;
help_button: TButton;
colour_panel: TPanel;
colour_patch: TImage;
size_updown: TUpDown;
datestamp_label: TLabel;
gauge_panel: TPanel;
gauge_header_label: TLabel;
gauge_listbox: TListBox;
warning_panel: TPanel;
cancel_panel: TPanel;
cancel_button: TButton;
group_button: TButton;
match_original_radio_button: TRadioButton;
mint_new_radio_button: TRadioButton;
retain_length_checkbox: TCheckBox;
info_header_label: TLabel;
print_button: TButton;
bold_panel: TPanel;
info_scrollbox: TScrollBox;
info_listbox: TListBox;
copy_button: TButton;
chat_button: TButton;
ok_panel: TPanel;
procedure how_panelClick(Sender: TObject);
procedure ok_buttonClick(Sender: TObject);
procedure gauge_listboxClick(Sender: TObject);
procedure cancel_buttonClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure gauge_listboxDblClick(Sender: TObject);
procedure chat_panelClick(Sender: TObject);
procedure exact_scale_buttonClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure colour_patchClick(Sender: TObject);
procedure size_updownClick(Sender: TObject; Button: TUDBtnType);
procedure custom_a_buttonClick(Sender: TObject);
procedure custom_b_buttonClick(Sender: TObject);
procedure custom_c_buttonClick(Sender: TObject);
procedure custom_d_buttonClick(Sender: TObject);
procedure print_buttonClick(Sender: TObject);
procedure copy_buttonClick(Sender: TObject);
procedure help_buttonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure info_listboxDrawItem(Control:TWinControl; Index:Integer; Rect:TRect; State:TOwnerDrawState);
procedure group_buttonClick(Sender: TObject);
procedure match_original_radio_buttonClick(Sender: TObject);
procedure mint_new_radio_buttonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
gauge_form: Tgauge_form;
//----------------------
t_T55_i:integer=0; // index = T-55 gauge.
gauge_i:integer=0;
t_TT3_i:integer=0;
t_TTI_i:integer=0;
t_TTF_i:integer=0;
t_TMS_i:integer=0;
t_TMF_i:integer=0;
t_H0US_i:integer=0;
t_H0EU_i:integer=0;
t_00XF_i:integer=0; // 239a
t_00SF_i:integer=0;
t_00MF_i:integer=0;
t_00IF_i:integer=0; // 234a
t_00BF_i:integer=0;
t_00H0_i:integer=0;
t_00DGF_i:integer=0;
t_00DGI_i:integer=0;
t_00BRMSB_i:integer=0;
t_EM_i:integer=0;
t_S4P4_i:integer=0;
t_0SF_i:integer=0; // 0.79.a
t_GOGF_i:integer=0;
t_S7_i:integer=0;
// added in 0.93.a ...
t_N_NMRA_i:integer=0;
t_S2_i:integer=0;
t_N_UK_i:integer=0;
t_S3p5_i:integer=0;
t_S_gauge_i:integer=0;
t_0MF_i:integer=0;
t_1F_i:integer=0;
t_P32_i:integer=0; // added in 212a
// added in 227a (for 9ft sleepers)...
t_s2_irish_i:integer=0;
t_em_irish_i:integer=0;
t_s4_irish_i:integer=0;
t_s_irish_i:integer=0;
t_s7_irish_i:integer=0;
show_gauge_details:boolean=False;
procedure init_gauge_list; // fill all gauge list data
//_____________________________________________________________________________________
implementation
{$BOOLEVAL ON}
{$R *.lfm}
uses
Printers, Clipbrd, control_room, pad_unit, bgkeeps_unit, entry_sheet, help_sheet, chat_unit, math_unit, alert_unit,
colour_unit, keep_select, info_unit, print_unit, shove_timber, print_settings_unit;
const
scale_help_str:string=' Scale'
+'||Templot is optimised for model railway applications, using the hybrid scales based on millimetres per foot (mm/ft).'
+'||Track dimensions which are usually modelled exactly to scale, for example rail lengths, are normally entered in INCHES full-size on the prototype.'
+'||Track dimensions which are commonly modelled to a non-scale size, for example the track gauge, are normally entered in actual MILLIMETRES on the model.'
+'||For the purpose of printing construction templates and track plans, a printed size of 100% means 100% of this model size.'
+'||The maximum scale Templot will accept is 500 mm/ft or 1:0.6 (which is nearly twice full-size!).'
+'||The minumum acceptable scale is 0.1 mm/ft or 1:3048.'
+'||For engineering applications the scale should be entered as a ratio, for example 1:16 or 1:50.';
gauge_help_str:string=' Gauge / Scale Selection List'
+'||Scroll the list and click on your required combination of scale, track gauge and flangeway standards.'
+'||Then click the green OK bar or press the keyboard ENTER key to change the control template to the new setting.'
+'||Alternatively, double-click on the list.'
+'||To convert a selected group of background templates to the new gauge and scale setting, click the CONVERT GROUP button. This function ignores the MINT option box (see below).'
+'||Click the SHOW INFO button to see full details of the dimensions which apply to the currently selected gauge.'
+'||Click SET EXACT SCALE... if you want the track gauge, check-rail and flangeway dimensions'
+' to be scaled exactly from British full-size practice (bull-head rail).'
+' Or click one of the SET CUSTOM... buttons to enter your own custom dimensions.'
+' You can have up to 4 different custom settings available for use. These will appear at the bottom of the list.'
+'||If the gauge which you are using has not yet been implemented in this upgrade version of Templot, please'
+' enter your requirements as a custom setting instead. More information is available by clicking the chat (=) button.'
+'||If the MINT NEW option box is selected, the new control template at the new gauge and scale will be a mint template. If the MATCH ORIGINAL option box is selected,'
+' Templot will match the new control template at the new gauge and scale to the size and position of the original control template.'
+'||These option settings also apply when using the TEMPLATE > GAUGE AND SCALE menu items, and can also be changed using the TEMPLATE > GAUGE AND SCALE > MINT NEW and MATCH ORIGINAL menu options.'
+'||For an explanation of a mint template, select the TEMPLATE > QUICK SET... menu item and then click the ?HELP button on the QUICK SET window.'
+'||If you close the form or click the CANCEL button the previous gauge and scale settings'
+' will remain unchanged.'
+'||When this form first appears, it will show the gauge/scale setting corresponding to the control template on the trackpad. If there are any differences between the dimensions in use for the control template'
+' and the standard dimensions for this gauge/scale setting, a red warning label "N.B. Dimensions now in use differ" will appear above the list. Then clicking the SHOW INFO button will show the list of standard dimensions'
+' for this gauge/scale setting, and any which curently differ will be shown in RED.'
+'||These dimensions can also be checked by selecting the TEMPLATE > GAUGE AND SCALE > DETAILS... menu item.'
+'||Handy Hint:'
+'|After reloading templates from a data file which you have not saved yourself (e.g. a downloaded file or one from another Templot user) it is sensible to check for any dimension differences before continuing to use the templates'
+' for your own designs (click the TEMPLATE > GAUGE AND SCALE > DETAILS... menu item).'
+' To restore the control template to the standard dimensions for this gauge and scale setting, simply click the green OK bar. To continue using the modified dimensions, close the form or click CANCEL.';
sorry_str:string='| Sorry, the preset dimensions for this gauge have not yet| been implemented.'
+'|| Until then, please click one of the SET CUSTOM buttons| and enter your required dimensions as a custom setting.';
type
Tdiff_flags=record
flags: array[0..6] of boolean; // flag False if current value differs from list
cur_vals:array[0..6] of extended; // current value in use.
end;//record
var
gauge_select_i:integer;
no_onresize:boolean=False;
diff_flags:Tdiff_flags;
procedure gauge_list_click;forward;
procedure show_gauge_info;forward;
procedure chat_click;forward;
procedure custom_click(custom:integer);forward;
procedure init_gauge_defaults(index:integer);forward;
procedure g_defaults(scale,inscale:extended; var gs:Tgauge_scale);forward; // set all g-defaults
//______________________________________________________________________________
procedure Tgauge_form.how_panelClick(Sender: TObject);
begin
if help(-1,gauge_help_str,'chat - more information')=1 then chat_click;
end;
//____________________________________________________________________________________________
procedure group_scale_change; // change a selected group to a new scale/gauge setting.
var
saved_control:Ttemplate_info;
n,count:integer;
bgnd:integer;
save_bgnd_option:boolean;
mod_ratio:extended;
index:integer;
begin
if keeps_list.Count<1 then EXIT;
index:=gauge_form.gauge_listbox.ItemIndex; // may get changed if the form is re-activated after help or alerts.
cancel_adjusts(False);
if any_selected=0
then begin
if alert_no_group=True // alert him, and does he want all?
then EXIT
else begin
do_rollback:=False;
redraw(False); // to show newly selected all.
end;
end;
gauge_form.gauge_listbox.ItemIndex:=index; // may have been changed if the form is re-activated after help or alerts.
gauge_list_click;
if alert(7,' convert group to '+Trim(gauge_form.ok_large_panel.Caption),
'You are about to change the gauge/scale setting to '+Trim(gauge_form.ok_large_panel.Caption)+' for all the templates in the currently selected group.'
+'||If these templates may be needed again they should first be saved (cancel this and click the SAVE GROUP button in the Storage Box).'
+'||This CONVERT GROUP function does not change the control template to the new gauge/scale setting. To do that, click the OK button when this function finishes.'
+' To leave the control template unchanged, click the CANCEL button when this function finishes.'
+'||This CONVERT GROUP function ignores the MINT tickbox.'
+'||This function may take some time to complete.',
'','','','','cancel','O K - continue',0)=5 then EXIT;
gauge_form.gauge_listbox.ItemIndex:=index; // may have been changed if the form is re-activated after help or alerts.
gauge_list_click;
keep_form.Close; // (might only be behind the pad) so the store current button works without alerts.
save_bgnd_option:=show_bgnd_templates; // 237c pad_form.show_bgnd_keeps_menu_entry.Checked; // don't want a complete redraw for every template.
//pad_form.show_bgnd_keeps_menu_entry.Checked
show_bgnd_templates:=False; // 237c so switch bgnd off
count:=keeps_list.Count;
saved_control:=hold_the_control;
try
Screen.Cursor:=crHourglass;
n:=0;
while n<count do begin
if Ttemplate(keeps_list.Objects[n]).group_selected=False
then begin
INC(n);
CONTINUE; // don't change this one.
end;
bgnd:=Ttemplate(keeps_list.Objects[n]).template_info.keep_dims.box_dims1.bgnd_code_077; // remember if it's on bgnd.
list_position:=n;
copy_keep_to_current(False,False,False,False); // copy to current.
gocalc(0,0); // for notch data.
pad_form.notch_under_peg_menu_entry.Click; // so can put the new template back on it.
gauge_i:=gauge_select_i; // set new gauge index,
mod_ratio:=gauge_dims(True,True,True); // and get new dimensions.
set_y_datum; // need to change the pad datum.
gocalc(0,0); // force immediate redraw.
rescale_notch(mod_ratio);
shift_onto_notch(False,False);
store_unused(False,False); // (does a recalc) put back in.
if bgnd=1 then keep_form.copy_or_wipe_background_button.Click; // and on background.
INC(n);
end;//while
// now delete the original group...
n:=0;
while n<keeps_list.Count do begin
if Ttemplate(keeps_list.Objects[n]).group_selected=False
then begin
INC(n);
CONTINUE; // leave this one.
end;
list_position:=n;
delete_keep(False, False); // delete this one
end;//while // no need to increment n, it is now pointing to the next keep.
save_done:=False;
backup_wanted:=True;
show_bgnd_templates:=save_bgnd_option; // restore
finally
unhold_the_control(saved_control);
show_bgnd_templates:=save_bgnd_option; // restore
Screen.Cursor:=crDefault;
do_rollback:=False;
redraw(True);
end;//try
end;
//__________________________________________________________________________________________
procedure ok_click(change_group:boolean);
var
mod_ratio:extended;
custom_gauge,not_mint:boolean;
begin
with gauge_form do begin
if (gauge_select_i<(gauge_listbox.Items.Count-5) ) and (gauge[gauge_select_i].scale_glist=0)
then begin
if alert(2,' '+gauge[gauge_select_i].name_str_glist+' not yet implemented',
ok_large_panel.Caption+sorry_str,
'','','','','cancel and continue','chat - more information',0)=6 then chat_click;
EXIT;// form remains showing
end;
if ( gauge_select_i<(gauge_listbox.Items.Count-1) ) and (gauge[gauge_select_i].scale_glist=0)
then begin
if alert(2,' '+gauge[gauge_select_i].name_str_glist,
'|No dimensions for this custom setting have yet been entered.'
+'||Click below or the appropriate `0SET CUSTOM`1 button to enter your required dimensions.'
,'','','','','cancel','enter '+gauge[gauge_select_i].name_str_glist+' data',0)=6
then custom_click(gauge_select_i-(gauge_listbox.Items.Count-5));
EXIT;// form remains showing
end;
if (gauge_select_i=(gauge_listbox.Items.Count-1) ) and (gauge[gauge_select_i].scale_glist=0)
then begin
if alert(2,' exact scale',
'|No scale has yet been entered for this setting.'
+'||Click below or the `0SET EXACT SCALE`1 button to enter the required scale.'
,'','','','','cancel','enter EXACT SCALE data',0)=6
then exact_scale_button.Click;
EXIT; // form remains showing
end;
if (gauge_select_i<(gauge_listbox.Items.Count-1)) and (gauge_select_i>(gauge_listbox.Items.Count-6))
then custom_gauge:=True
else custom_gauge:=False;
end;//with form
if change_group=True
then group_scale_change
else begin
not_mint:=NOT gauge_form.mint_new_radio_button.Checked;
if not_mint=True then pad_form.notch_under_peg_menu_entry.Click; // so can put the new template back on it.
gauge_i:=gauge_select_i; // set new gauge index,
mod_ratio:=gauge_dims(True,True,not_mint); // and get new dimensions.
gauge_form.Close;
set_y_datum; // need to change the pad datum.
gocalc(0,0);
if not_mint=True
then begin
rescale_notch(mod_ratio);
shift_onto_notch(False,False);
end
else begin
if gauge_form.retain_length_checkbox.Checked=True // 208d test added, was (0)
then mint_new_current(1,True)
else mint_new_current(0,True);
end;
redraw(True);
end;
end;
//_______________________________________________________________________________________
procedure Tgauge_form.ok_buttonClick(Sender: TObject);
begin
ok_click(False);
end;
//_________________________________________________________________________________________
procedure Tgauge_form.group_buttonClick(Sender: TObject);
begin
ok_click(True);
end;
//________________________________________________________________________________________
procedure Tgauge_form.gauge_listboxClick(Sender: TObject);
begin
gauge_list_click;
end;
//_____________________________________________________________________________________
procedure gauge_list_click;
begin
with gauge_form do begin
if gauge_form.Showing=True then gauge_listbox.SetFocus; // in case come here from data entry (CUSTOM / EXACT).
gauge_select_i:=gauge_listbox.ItemIndex;
ok_panel.Caption:=' '+Copy(gauge_listbox.Items.Strings[gauge_select_i],11,200); // 215a
ok_large_panel.Caption:=gauge[gauge_select_i].name_str_glist;
if gauge_select_i<>gauge_i then warning_panel.Visible:=False;
show_gauge_info;
end;//with
end;
//________________________________________________________________________________________
procedure Tgauge_form.cancel_buttonClick(Sender: TObject);
begin
Close;
end;
//_________________________________________________________________________________________
procedure Tgauge_form.FormActivate(Sender: TObject);
var
i,n:integer;
same:boolean;
begin
// set the index into the gauge list...
// use this only to show the correct line in the list.
// actual data comes from the file.
// mods 212a - index from the gauge name part only...
gauge_i:=0; //init
for n:=0 to gauge_form.gauge_listbox.Items.Count-1 do begin
if gauge[n].name_str_glist=cpi.name_str_pi
then begin
gauge_i:=n;
BREAK;
end;
end;//next
if Tag=0 // only when first called
then begin
// compare 2 gauge settings.
// return array of True or False flags and current values for offending items if not same.
same:=True; //init.
Tag:=1;
with gauge[gauge_i] do begin
with cpi do begin
with diff_flags do begin
for i:=0 to High(flags) do begin
flags[i]:=True; // default inits.
cur_vals[i]:=0;
end;//next
if ABS(scale_pi-scale_glist)>minfp then begin flags[0]:=False; cur_vals[0]:=scale_pi; same:=False; end; // mm/ft.
if ABS(gauge_pi-gauge_glist)>minfp then begin flags[1]:=False; cur_vals[1]:=gauge_pi; same:=False; end; // mm.
if ABS(fw_pi-fw_glist)>minfp then begin flags[2]:=False; cur_vals[2]:=fw_pi; same:=False; end; // mm flangeway.
if ABS(fwe_pi-fwe_glist)>minfp then begin flags[3]:=False; cur_vals[3]:=fwe_pi; same:=False; end; // mm flangeway end (flangeway+flare).
if ABS(trtscent_pi-trtscent_glist)>minfp then begin flags[4]:=False; cur_vals[4]:=trtscent_pi; same:=False; end; // mm track centres, turnout side.
if ABS(trmscent_pi-trmscent_glist)>minfp then begin flags[5]:=False; cur_vals[5]:=trmscent_pi; same:=False; end; // mm ditto, main side.
if ABS(min_radius_pi-min_radius_glist)>minfp then begin flags[6]:=False; cur_vals[6]:=min_radius_pi; same:=False; end; // mm minimum radius for check.
end;//with diff_flags
end;//with
end;//with
if same=True
then warning_panel.Hide // same.
else warning_panel.Show; // different.
end
else warning_panel.Hide;
gauge_listbox.ItemIndex:=gauge_i; // initialise selection
gauge_list_click;
show_gauge_info;
end;
//________________________________________________________________________________________
procedure Tgauge_form.gauge_listboxDblClick(Sender: TObject);
begin // double click on list.
gauge_list_click;
gauge_form.ok_button.Click;
end;
//______________________________________________________________________________________
procedure chat_click;
const
chat_str:string=' Gauge and Scale Selection List'
+'||I have tried to make this list as comprehensive as possible, but it has not been possible to include any narrow-gauge settings because there are just too many variations.'
+' Narrow-gauge templates can be created as custom settings.'
+'||If you are using a gauge or scale combination for standard-gauge not shown here I would be pleased to know about it, and the various dimensions which you have adopted.'
+' In the meantime you can enter them as a custom setting.'
+'||If you can help to fill in any obvious gaps in this list I would be pleased to hear from you. The information needed is:'
+'|| gauge (minimum) and scale'
+'| nominal flangeway gap and check rail flare-out (end gap)'
+'| minimum double-track centres'
+'| recommended minimum radius'
+'||The gauge also needs a NAME. I have had to invent some of these because there seems to be no established name in use.'
+'||Please note that for the EXACT scale setting the track gauge is assumed to be the traditional 56.5 inches.'
+' Some tracks in recent years have been set to 1432 mm gauge (about 3 mm less) - if you need this please enter your dimensions as a custom setting.'
+'||Engineers coming across this list for the first time will no doubt be amazed'
+' at the weird scale ratios and mixture of metric and imperial dimensions that we go in for! All the gauges listed have been'
+' used by someone somewhere or referred to in print (if the internet counts as print).'
+'||Except, of course, the T-55 Templot Startup gauge which is 5.5 mm/ft on 1" gauge with EM clearances. This is intended to be'
+' 100% fictitious - unless you know different !';
begin
chat(chat_str);
end;
//_______________________________________________________________________________________
procedure Tgauge_form.chat_panelClick(Sender: TObject);
begin
chat_click;
end;
//_______________________________________________________________________________________
procedure Tgauge_form.exact_scale_buttonClick(Sender: TObject);
const
help_str:string=' Exact Scale'
+'||This scale size will be used whenever you subsequently select EXACT SCALE on the gauge list.'
+' The track gauge, flangeways and all other pointwork dimensions will then be scaled'
+' exactly from full-size British (bullhead) practice.'
+'||The figures which you enter here have no relevance if any other gauge/scale combination is subsequently selected from the list.'
+'||If you are using a dead scale gauge (e.g. S4, ScaleSeven, etc.) you should select the appropriate size from the list, as there'
+' are slight variations in the standards to accommodate manufacturing tolerances ( although these are likely to show up only if you'
+' are printing at an enlarged scale on a very-high-resolution printer ).'
+'||The maximum scale Templot will accept is 500 mm/ft or 1:0.6 (which is nearly twice full-size!). The minimum scale is 0.1 mm/ft or 1:3048.'
+'||When you save and reload EXACT SCALE templates via your storage box, the exact scale settings for each one will be preserved, but will not'
+' be reflected here in the gauge list. Once you have such an EXACT SCALE control template on the trackpad, its settings will continue to be used for'
+' any subsequent templates until you come here and select another gauge size, or copy a template from the background or storage box, so there is no need to re-enter the EXACT SCALE setting for them unless'
+' you want to change the scale, or swap between different scales. The settings from an EXACT SCALE template can also be adopted into to one of the'
+' CUSTOM slots if you are not using them for other custom settings.';
var
n, i:integer;
sc,ins:extended;
od:Toutdim;
dummy_i:integer;
begin
repeat
i:=alert(4,' exact scale ...',
'The scale size for the EXACT SCALE setting can be entered in mm/ft, or as a scale ratio.'
+'||Please select your preference.',
'','','help','scale ratio 1 : n','cancel','scale in mm / ft',3);
case i of
3: alert_help(0,scale_help_str,'');
4: begin
n:=putdim(help_str,0,'EXACT SCALE ratio 1 :',304.8/scale,True,True,True,False); // no negative, no pre-set, no zero, don't terminate on zero.
if n<>0 then EXIT;
if getdims('exact scale setting',scale_help_str,gauge_form,n,od)=True
then begin
gauge_select_i:=gauge_listbox.Items.Count-1;
gauge_i:=gauge_select_i;
init_gauge_defaults(gauge_i); // first clear any previous exact setting.
gauge[gauge_i].scale_glist:=ABS(304.8/od[0]); // 1 foot = 304.8 mm
end
else EXIT;
end;
5: EXIT;
6: begin
n:=putdim(help_str,1,'EXACT SCALE in mm / ft',scale,True,True,True,False); // no negative, no pre-set, no zero, don't terminate on zero.
if n<>0 then EXIT;
if getdims('exact scale setting',scale_help_str,gauge_form,n,od)=True
then begin
gauge_select_i:=gauge_listbox.Items.Count-1;
gauge_i:=gauge_select_i;
init_gauge_defaults(gauge_i); // first clear any previous exact setting.
gauge[gauge_i].scale_glist:=ABS(od[0]); // mm/ft
end
else EXIT;
end;
else EXIT;
end;//case
until i<>3;
gauge[gauge_i].scale_glist:=limits(0.1,500,gauge[gauge_i].scale_glist,dummy_i); // maximum scale 500 mm to the foot (nearly twice full-size).
sc:=gauge[gauge_i].scale_glist; // scale
ins:=sc/12.0; // inscale
g_defaults(sc,ins,gauge[gauge_i]); // set all the defaults.
gauge_listbox.ItemIndex:=gauge_i;
gauge_list_click;
if gauge_form.Showing=True then ok_button.SetFocus; // 0.93.a
end;
//______________________________________________________________________________________
procedure Tgauge_form.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key=VK_F10
then begin
Key:=0; // otherwise selects the menus.
end;
if Key=VK_PAUSE then Application.Minimize; // hide TEMPLOT on PAUSE key.
end;
//_________________________________________________________________________________________
procedure Tgauge_form.FormKeyPress(Sender: TObject; var Key: Char);
begin
if (Key=Chr(13)) and (gauge_listbox.Focused=True) then ok_button.Click; // ENTER key clicks OK.
end;
//______________________________________________________________________________________
procedure Tgauge_form.colour_patchClick(Sender: TObject);
begin
gauge_listbox.Color:=get_colour('choose a new colour for the gauge list',gauge_listbox.Color);
end;
//____________________________________________________________________________________________
procedure Tgauge_form.size_updownClick(Sender: TObject; Button: TUDBtnType);
begin
no_onresize:=True; // don't permit on-resize until finished.
if size_updown.Position>size_updown.Tag // ! position goes up, size goes down.
then ScaleBy(9,10); // scale the form contents down.
if size_updown.Position<size_updown.Tag
then ScaleBy(10,9); // scale the form contents up.
ClientHeight:=VertScrollBar.Range; // allow 4 pixel right margin.
ClientWidth:=HorzScrollBar.Range+4; // don't need bottom margin - datestamp label provides this.
ClientHeight:=VertScrollBar.Range; // do this twice, as each affects the other.
size_updown.Tag:=size_updown.Position; // and save for the next click.
no_onresize:=False;
Resize;
end;
//__________________________________________________________________________________________
procedure g_defaults(scale,inscale:extended; var gs:Tgauge_scale); // set all glist-defaults
begin
with gs do begin
if gauge_glist=def_req then gauge_glist:=56.5*inscale; // default 4' 8.5" gauge.
if fw_glist=def_req then fw_glist:=1.75*inscale; // default 1.75" dead-scale flangeway.
if fwe_glist=def_req then fwe_glist:=fw_glist+1.75*inscale; // default +1.75" flare.
if trtscent_glist=def_req then trtscent_glist:=134*inscale; // 11' 2" track centres turnout-side
if trmscent_glist=def_req then trmscent_glist:=134*inscale; // ditto main-side
if min_radius_glist=def_req then min_radius_glist:=152*scale; // 152 ft. minimum radius warning.
// = 608 mm (24" approx) in 4mm scale.
// = 1064 mm (42" approx) in 7 mm scale.
end;//with
end;
//________________________________________________________________________________________
procedure init_gauge_defaults(index:integer);
begin
with gauge[index] do begin
scale_glist:=0; // scale 0 means this gauge not yet implemented.
// initialise the rest of the list to defaults...
name_str_glist:='';
gauge_glist:=def_req; // mm.
fw_glist:=def_req; // mm flangeway.
fwe_glist:=def_req; // mm flangeway end gap (flangeway+flare).
old_fwe_glist:=def_req; // pre 215a modified after setting up the list
trtscent_glist:=def_req; // mm track centres, turnout side.
trmscent_glist:=def_req; // mm ditto, main side.
min_radius_glist:=def_req; // mm minimum radius for check.
end;//with
end;
//_________________________________________________________________________________________
procedure init_gauge_list; // fill all gauge list data
var
i,j:integer;
sc,ins:extended;
listbox_str:string;
temp_str:string;
begin
gauge_form.gauge_listbox.Items.Clear; // 215a
for i:=0 to gauge_indexmax_c do init_gauge_defaults(i); // first fill with defaults.
// then set specifics as reqd...
i:=0;
listbox_str:=' (n/a) (none) ';
gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' Z-NMRA 6.5 mm 1.385mm/ft 1:220 Z NMRA and Märklin ';
scale_glist:=304.8/220; // mm per ft.
gauge_glist:=6.5; // mm.
fw_glist:=0.64; // mm flangeway.
old_fwe_glist:=1.25; // mm flangeway end (flangeway+flare).
trtscent_glist:=20; // mm track centres, turnout side.
trmscent_glist:=20; // mm ditto, main side.
min_radius_glist:=225; // mm minimum radius for check (9" approx).
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' P-220 6.52 mm 1.385mm/ft 1:220 Proto-220 ';
scale_glist:=304.8/220; // mm per ft.
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' Z-UK 6.5 mm 1.5 mm/ft 1:203.2 Z UK only ';
scale_glist:=1.5; // mm per ft.
gauge_glist:=6.5; // mm.
fw_glist:=0.65; // mm flangeway.
old_fwe_glist:=1.25; // mm flangeway end (flangeway+flare).
trtscent_glist:=20; // mm track centres, turnout side.
trmscent_glist:=20; // mm ditto, main side.
min_radius_glist:=225; // mm minimum radius for check (9" approx).
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' S1.5 7.06 mm 1.5 mm/ft 1:203.2 1.5mm Fine ';
scale_glist:=1.5; // mm per ft.
gauge_glist:=7.0625; // mm.
fw_glist:=0.35; // mm flangeway.
old_fwe_glist:=0.6; // mm flangeway ends.
min_radius_glist:=375; // mm minimum radius for warning (15" approx).
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' P-160 8.97 mm 1.905mm/ft 1:160 Proto-160 ';
scale_glist:=304.8/160; // mm per ft.
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
// added 211b ...
with gauge[i] do begin
listbox_str:=' FS160 9.0 mm 1.905mm/ft 1:160 fiNe-scale ';
scale_glist:=304.8/160; // mm per ft.
gauge_glist:=9.0; // mm.
fw_glist:=0.5; // mm flangeway.
old_fwe_glist:=0.85; // mm flangeway ends.
min_radius_glist:=500; // mm minimum radius for warning (20" approx).
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' N-NMRA 9.0 mm 0.075"/ft 1:160 N USA and Europe ';
scale_glist:=1.905; // mm per ft.
gauge_glist:=9.0; // mm.
fw_glist:=0.85; // mm flangeway.
old_fwe_glist:=1.65; // mm flangeway end (flangeway+flare).
trtscent_glist:=25; // mm track centres, turnout side.
trmscent_glist:=25; // mm ditto, main side.
min_radius_glist:=300; // mm minimum radius for check (12" approx).
t_N_NMRA_i:=i; // for gauge quick-set menu.
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' 9FS 9.0 mm 2 mm/ft 1:152.4 9mm Fine S2 dims UK '; // 234e was N-FX 233c
scale_glist:=2; // mm per ft.
gauge_glist:=9.0; // mm.
fw_glist:=0.5; // mm flangeway.
old_fwe_glist:=0.85; // mm flangeway ends.
min_radius_glist:=500; // mm minimum radius for warning (20" approx).
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' S2 9.42 mm 2 mm/ft 1:152.4 2FS 2mm Fine ';
scale_glist:=2; // mm per ft.
gauge_glist:=9.42; // mm.
fw_glist:=0.5; // mm flangeway.
old_fwe_glist:=0.85; // mm flangeway ends.
min_radius_glist:=500; // mm minimum radius for warning (20" approx).
t_S2_i:=i; // for gauge quick-set menu.
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' S2(I) 10.5 mm 2 mm/ft 1:152.4 Irish 5''3" S2 dims ';
scale_glist:=2; // mm per ft.
gauge_glist:=10.5; // mm.
fw_glist:=0.5; // mm flangeway.
old_fwe_glist:=0.85; // mm flangeway ends.
trtscent_glist:=23.4167; // mm track centres, turnout side.
trmscent_glist:=23.4167; // mm ditto, main side.
min_radius_glist:=500; // mm minimum radius for warning (20" approx).
t_s2_irish_i:=i;
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' N 9.0 mm 2.06 mm/ft 1:148 N Commercial UK ';
scale_glist:=2.05946; // mm per ft.
gauge_glist:=9.0; // mm.
fw_glist:=0.85; // mm flangeway.
old_fwe_glist:=1.65; // mm flangeway end (flangeway+flare).
trtscent_glist:=25; // mm track centres, turnout side.
trmscent_glist:=25; // mm ditto, main side.
min_radius_glist:=300; // mm minimum radius for check (12" approx).
t_N_UK_i:=i; // for gauge quick-set menu.
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' HS 0.441" 3/32"/ft 1:128 HS Gauge (Half-S) ';
scale_glist:=2.3812; // mm per ft.
gauge_glist:=11.2; // mm.
fw_glist:=0.35; // mm flangeway. .014"
old_fwe_glist:=0.7; // mm flangeway end (flangeway+flare).
min_radius_glist:=600; // mm minimum radius for check (24" approx).
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' TT-120 12.0 mm 2.54 mm/ft 1:120 Table-Top-120 NEM dims';
scale_glist:=2.54; // mm per ft.
gauge_glist:=12.0; // mm.
fw_glist:=1.0; // mm flangeway. // 234e
old_fwe_glist:=1.75; // mm flangeway end (flangeway+flare).
trtscent_glist:=30; // mm track centres, turnout side.
trmscent_glist:=30; // mm ditto, main side.
min_radius_glist:=375; // mm minimum radius for check (15" approx).
end;{with} gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' TT-I 12.025mm 3 mm/ft 1:101.6 TT Intermediate TM-S dim';
scale_glist:=3; // mm per ft.
gauge_glist:=12.025; // mm.
fw_glist:=0.95; // mm flangeway.
old_fwe_glist:=1.8; // mm flangeway end (flangeway+flare).
trtscent_glist:=37.5; // mm track centres, turnout side.
trmscent_glist:=37.5; // mm ditto, main side.
min_radius_glist:=450; // mm minimum radius for check (18" approx).
end;{with}
t_TTI_i:=i; // for gauge checks.
gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' TT-F 12.025mm 3 mm/ft 1:101.6 TT Fine FM dims ';
scale_glist:=3; // mm per ft.
gauge_glist:=12.025; // mm.
fw_glist:=0.8; // mm flangeway.
old_fwe_glist:=1.5; // mm flangeway end (flangeway+flare).
trtscent_glist:=37.5; // mm track centres, turnout side.
trmscent_glist:=37.5; // mm ditto, main side.
min_radius_glist:=600; // mm minimum radius for check (34" approx).
end;{with}
t_TTF_i:=i; // for gauge checks.
gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' TT3 12.05 mm 3 mm/ft 1:101.6 TT Triang Standard ';
scale_glist:=3; // mm per ft.
gauge_glist:=12.05; // mm.
fw_glist:=1.1; // mm flangeway.
old_fwe_glist:=2.0; // mm flangeway end (flangeway+flare).
trtscent_glist:=37.5; // mm track centres, turnout side.
trmscent_glist:=37.5; // mm ditto, main side.
min_radius_glist:=450; // mm minimum radius for check (18" approx).
end;{with}
t_TT3_i:=i; // for gauge checks.
gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin
listbox_str:=' TM-S 13.525mm 3 mm/ft 1:101.6 TM Standard ';
scale_glist:=3; // mm per ft.
gauge_glist:=13.525; // mm.
fw_glist:=0.95; // mm flangeway.
old_fwe_glist:=1.8; // mm flangeway end (flangeway+flare).
trtscent_glist:=35; // mm track centres, turnout side.
trmscent_glist:=35; // mm ditto, main side.
min_radius_glist:=600; // mm minimum radius for check (24" approx).
end;{with}
t_TMS_i:=i; // for gauge checks.
gauge_form.gauge_listbox.Items.Add(listbox_str); Inc(i);if i>gauge_indexmax_c then run_error(39);
with gauge[i] do begin