-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcontrol_room.pas
More file actions
5001 lines (3896 loc) · 225 KB
/
control_room.pas
File metadata and controls
5001 lines (3896 loc) · 225 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 244d
*)
unit control_room;
{$MODE Delphi}
{$ALIGN OFF}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Menus, ExtCtrls, ComCtrls, FileCtrl;
type
Tcontrol_room_form = class(TForm)
control_room_menu_bar: TMainMenu;
help_menu: TMenuItem;
about_templot_version_menu_entry: TMenuItem;
open_panel: TPanel;
open_button: TButton;
pad_button: TButton;
storage_box_button: TButton;
session_menu: TMenuItem;
quit_menu_entry: TMenuItem;
N1: TMenuItem;
printersetup1: TMenuItem;
project_title_menu_entry: TMenuItem;
printer_calibration_menu_entry: TMenuItem;
new_gauge_menu_entry: TMenuItem;
program_menu: TMenuItem;
step_size_menu_entry: TMenuItem;
re_org_menu_entry: TMenuItem;
data_distortions_menu_entry: TMenuItem;
aspect_distortion_menu_entry: TMenuItem;
x_skewing_menu_entry: TMenuItem;
x_coning_menu_entry: TMenuItem;
distortion_help_menu_entry: TMenuItem;
N3: TMenuItem;
curvingmethod1: TMenuItem;
standard_wrap_menu_entry: TMenuItem;
draw_curved_menu_entry: TMenuItem;
transitionmaths1: TMenuItem;
auto_terms_menu_entry: TMenuItem;
custom_terms_menu_entry: TMenuItem;
expert1: TMenuItem;
N8: TMenuItem;
cancel_all_distortions_menu_entry: TMenuItem;
blue_corner_panel: TPanel;
how_panel: TPanel;
chat_panel: TPanel;
size_updown: TUpDown;
colour_panel: TPanel;
colour_patch: TImage;
test_menu_entry: TMenuItem;
number_format_menu_entry: TMenuItem;
unitangles1: TMenuItem;
ram1: TMenuItem;
CLM1: TMenuItem;
IM1: TMenuItem;
SM1: TMenuItem;
x_scaling_menu_entry: TMenuItem;
y_scaling_menu_entry: TMenuItem;
background_menu: TMenuItem;
shapes_menu_entry: TMenuItem;
y_coning_menu_entry: TMenuItem;
y_skewing_menu_entry: TMenuItem;
mirror_x_menu_entry: TMenuItem;
mirror_y_menu_entry: TMenuItem;
reorigination1: TMenuItem;
cancel_re_org_menu_entry: TMenuItem;
N9: TMenuItem;
printer_font_menu_entry: TMenuItem;
auto_mouse_dir_menu_entry: TMenuItem;
clm_help_menu_entry: TMenuItem;
N10: TMenuItem;
logo_bumf_label: TLabel;
peg_arm_menu_entry: TMenuItem;
max_explode_menu_entry: TMenuItem;
custom_input_factors_menu_entry: TMenuItem;
run_slow_menu_entry: TMenuItem;
N4: TMenuItem;
reload_button: TButton;
reload_menu_entry: TMenuItem;
clear_templates_menu_entry: TMenuItem;
clear_shapes_menu_entry: TMenuItem;
N12: TMenuItem;
shapes_button: TButton;
control_sketchboard_button: TButton;
mouse_action_menu_entry: TMenuItem;
click_move_click_menu_entry: TMenuItem;
button_down_menu_entry: TMenuItem;
either_action_menu_entry: TMenuItem;
N13: TMenuItem;
storage_box_menu_entry: TMenuItem;
N7: TMenuItem;
max_spiral_menu_entry: TMenuItem;
cpuusage1: TMenuItem;
fast_100_menu_entry: TMenuItem;
allow_full_idle_menu_entry: TMenuItem;
N15: TMenuItem;
allow_idle_help_menu_entry: TMenuItem;
mouse_100_menu_entry: TMenuItem;
version_label: TLabel;
please_read_first_menu_entry: TMenuItem;
program_panel_help_menu_entry: TMenuItem;
graphics_limits_menu_entry: TMenuItem;
graphics_16_bit_limits_menu_entry: TMenuItem;
graphics_no_limits_menu_entry: TMenuItem;
file_menu: TMenuItem;
save_all_menu_entry: TMenuItem;
N18: TMenuItem;
open_storage_box_menu_entry: TMenuItem;
exports_menu_entry: TMenuItem;
N11: TMenuItem;
sliding_wrap_menu_entry: TMenuItem;
N2: TMenuItem;
graphics_24_bit_limits_menu_entry: TMenuItem;
graphics_32_bit_limits_menu_entry: TMenuItem;
graphics_limits_help_menu_entry: TMenuItem;
logo_panel: TPanel;
logo_image: TImage;
recent_button: TButton;
recent_menu_entry: TMenuItem;
templatenamelabels1: TMenuItem;
very_random_labels_menu_entry: TMenuItem;
fixed_labels_menu_entry: TMenuItem;
random_labels_menu_entry: TMenuItem;
statusbar_panel: TPanel;
tm_label: TLabel;
go_prefs_button: TButton;
saved_preferences_setup_menu_entry: TMenuItem;
N5: TMenuItem;
startup_label: TLabel;
reminder_label: TLabel;
reminder_menu_entry: TMenuItem;
delete_reminder_menu_entry: TMenuItem;
preferences_menu: TMenuItem;
prefs_include_gen_settings_menu_entry: TMenuItem;
update_prefs_on_quit_menu_entry: TMenuItem;
N17: TMenuItem;
prefs_exclude_gen_settings_menu_entry: TMenuItem;
N6: TMenuItem;
abandon_prefs_menu_entry: TMenuItem;
N20: TMenuItem;
N16: TMenuItem;
data_panel_font_menu_entry: TMenuItem;
N14: TMenuItem;
N21: TMenuItem;
N22: TMenuItem;
N23: TMenuItem;
N24: TMenuItem;
wraphelp1: TMenuItem;
labelshelp1: TMenuItem;
make_donation_menu_entry: TMenuItem;
N25: TMenuItem;
first_time_here_label: TLabel;
internet_label: TLabel;
click_mode_options_menu_entry: TMenuItem;
click_mode_help_menu_entry: TMenuItem;
N27: TMenuItem;
make_on_click_mode_menu_entry: TMenuItem;
classic_templot_mode_menu_entry: TMenuItem;
room_file_viewer_menu_entry: TMenuItem;
filevieweroptions1: TMenuItem;
viewer_bitmaps_menu_entry: TMenuItem;
viewer_png_menu_entry: TMenuItem;
N28: TMenuItem;
file_viewer_help_menu_entry: TMenuItem;
viewer_button: TButton;
about_label: TLabel;
N29: TMenuItem;
sketchboard_menu_entry: TMenuItem;
previous_labels_menu_entry: TMenuItem;
Label1: TLabel;
screen_scaling_menu_entry: TMenuItem;
use_wine_fonts_menu_entry: TMenuItem;
popup_menu_position_menu_entry: TMenuItem;
blank_spaces_in_menus_menu_entry: TMenuItem;
watchavideo1: TMenuItem;
video1: TMenuItem;
TemplotCompanionUserGuide1: TMenuItem;
pleaseclickthehelpmenuonthetrackpadwindow1: TMenuItem;
jpg_menu_entry: TMenuItem;
trackpad_position_menu_entry: TMenuItem;
show_time_ticker_menu_entry: TMenuItem;
restore_t55_startup_menu_entry: TMenuItem;
BGS3readable1: TMenuItem;
bgs3_compact_menu_entry: TMenuItem;
bgs3_readable_menu_entry: TMenuItem;
maps_button: TButton;
datestamp_label: TLabel;
trackpad_groupbox: TGroupBox;
pad_maximized_radio: TRadioButton;
pad_downsized_radio: TRadioButton;
getfile_from_code_menu_entry: TMenuItem;
search_site_for_menu_entry: TMenuItem;
enableDXFexportedfillerbelowkey1: TMenuItem;
Label2: TLabel;
top_bar_shape: TShape;
procedure open_buttonClick(Sender: TObject);
procedure about_templot_version_menu_entryClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure quit_menu_entryClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure chat_panelClick(Sender: TObject);
procedure how_panelClick(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure project_title_menu_entryClick(Sender: TObject);
procedure printer_setup_menu_entryClick(Sender: TObject);
procedure pad_buttonClick(Sender: TObject);
procedure AppActivate(Sender:TObject);
procedure AppIdle(Sender: TObject; var Done: Boolean);
procedure AppRestore(Sender: TObject); // 0.91.b
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDeactivate(Sender: TObject);
procedure printer_calibration_menu_entryClick(Sender: TObject);
procedure colour_buttonClick(Sender: TObject);
procedure new_gauge_menu_entryClick(Sender: TObject);
procedure aspect_distortion_menu_entryClick(Sender: TObject);
procedure auto_terms_menu_entryClick(Sender: TObject);
procedure custom_terms_menu_entryClick(Sender: TObject);
procedure step_size_menu_entryClick(Sender: TObject);
procedure cancel_all_distortions_menu_entryClick(Sender: TObject);
procedure re_org_menu_entryClick(Sender: TObject);
procedure size_updownClick(Sender: TObject; Button: TUDBtnType);
procedure number_format_menu_entryClick(Sender: TObject);
procedure test_menu_entryClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure distortion_help_menu_entryClick(Sender: TObject);
procedure x_scaling_menu_entryClick(Sender: TObject);
procedure y_scaling_menu_entryClick(Sender: TObject);
procedure mirror_x_menu_entryClick(Sender: TObject);
procedure mirror_y_menu_entryClick(Sender: TObject);
procedure x_coning_menu_entryClick(Sender: TObject);
procedure y_coning_menu_entryClick(Sender: TObject);
procedure cancel_re_org_menu_entryClick(Sender: TObject);
procedure x_skewing_menu_entryClick(Sender: TObject);
procedure y_skewing_menu_entryClick(Sender: TObject);
procedure printer_font_menu_entryClick(Sender: TObject);
procedure shapes_menu_entryClick(Sender: TObject);
procedure auto_mouse_dir_menu_entryClick(Sender: TObject);
procedure clm_help_menu_entryClick(Sender: TObject);
procedure peg_arm_menu_entryClick(Sender: TObject);
procedure max_explode_menu_entryClick(Sender: TObject);
procedure custom_input_factors_menu_entryClick(Sender: TObject);
procedure run_slow_menu_entryClick(Sender: TObject);
procedure reload_buttonClick(Sender: TObject);
procedure clear_templates_menu_entryClick(Sender: TObject);
procedure clear_shapes_menu_entryClick(Sender: TObject);
procedure keeps_list_change(Sender: TObject);
procedure click_move_click_menu_entryClick(Sender: TObject);
procedure button_down_menu_entryClick(Sender: TObject);
procedure either_action_menu_entryClick(Sender: TObject);
procedure storage_box_menu_entryClick(Sender: TObject);
procedure program_menuClick(Sender: TObject);
procedure max_spiral_menu_entryClick(Sender: TObject);
procedure fast_100_menu_entryClick(Sender: TObject);
procedure allow_full_idle_menu_entryClick(Sender: TObject);
procedure allow_idle_help_menu_entryClick(Sender: TObject);
procedure mouse_100_menu_entryClick(Sender: TObject);
procedure please_read_first_menu_entryClick(Sender: TObject);
procedure graphics_16_bit_limits_menu_entryClick(Sender: TObject);
procedure graphics_no_limits_menu_entryClick(Sender: TObject);
procedure save_all_menu_entryClick(Sender: TObject);
procedure standard_wrap_menu_entryClick(Sender: TObject);
procedure control_sketchboard_buttonClick(Sender: TObject);
procedure graphics_24_bit_limits_menu_entryClick(Sender: TObject);
procedure graphics_32_bit_limits_menu_entryClick(Sender: TObject);
procedure graphics_limits_help_menu_entryClick(Sender: TObject);
procedure com_labelClick(Sender: TObject);
procedure recent_buttonClick(Sender: TObject);
procedure very_random_labels_menu_entryClick(Sender: TObject);
procedure fixed_labels_menu_entryClick(Sender: TObject);
procedure random_labels_menu_entryClick(Sender: TObject);
procedure go_prefs_buttonClick(Sender: TObject);
procedure saved_preferences_setup_menu_entryClick(Sender: TObject);
procedure reminder_menu_entryClick(Sender: TObject);
procedure delete_reminder_menu_entryClick(Sender: TObject);
procedure update_prefs_on_quit_menu_entryClick(Sender: TObject);
procedure prefs_include_gen_settings_menu_entryClick(Sender: TObject);
procedure prefs_exclude_gen_settings_menu_entryClick(Sender: TObject);
procedure preferences_menuClick(Sender: TObject);
procedure abandon_prefs_menu_entryClick(Sender: TObject);
procedure mouse_action_menu_entryClick(Sender: TObject);
procedure session_menuClick(Sender: TObject);
procedure data_panel_font_menu_entryClick(Sender: TObject);
procedure exports_menu_entryClick(Sender: TObject);
procedure make_donation_menu_entryClick(Sender: TObject);
procedure classic_templot_mode_menu_entryClick(Sender: TObject);
procedure make_on_click_mode_menu_entryClick(Sender: TObject);
procedure click_mode_options_menu_entryClick(Sender: TObject);
// OT2024 procedure room_file_viewer_menu_entryClick(Sender: TObject);
// OT2024 procedure viewer_bitmaps_menu_entryClick(Sender: TObject);
// OT2024 procedure viewer_png_menu_entryClick(Sender: TObject);
// OT2024 procedure file_viewer_help_menu_entryClick(Sender: TObject);
procedure previous_labels_menu_entryClick(Sender: TObject);
procedure screen_scaling_menu_entryClick(Sender: TObject);
procedure use_wine_fonts_menu_entryClick(Sender: TObject);
procedure popup_menu_position_menu_entryClick(Sender: TObject);
procedure blank_spaces_in_menus_menu_entryClick(Sender: TObject);
procedure jpg_menu_entryClick(Sender: TObject);
procedure trackpad_position_menu_entryClick(Sender: TObject);
procedure show_time_ticker_menu_entryClick(Sender: TObject);
procedure restore_t55_startup_menu_entryClick(Sender: TObject);
procedure bgs3_compact_menu_entryClick(Sender: TObject);
procedure bgs3_readable_menu_entryClick(Sender: TObject);
procedure maps_buttonClick(Sender: TObject);
procedure shapes_buttonClick(Sender: TObject);
procedure pad_maximized_radioMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure pad_downsized_radioMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure search_site_for_menu_entryClick(Sender: TObject);
procedure enableDXFexportedfillerbelowkey1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;//class
var
control_room_form: Tcontrol_room_form;
//-----------------------------------------
const
templot_program:integer=1; // 0=Templot2 1=Templot5
distortion_help_str:string=' Expert Help - Data Distortions'
+'||These data distortion functions are intended primarily for use when exporting templates in DXF file format for transfer to CAD software.'
+'||There should normally be no need to distort (modify) the drawing data when printing templates directly from Templot.'
+' Any necessary corrections for your printer are intended to be made using the PRINTER CALIBRATION function, and the ENLARGE / REDUCE print scaling function'
+' is available to change the size of the printed template. These functions are accessed from the OUTPUT menu on the TRACKPAD. You should have a good'
+' reason therefore for using these distortions instead and be aware that your printed templates may become inaccurate or unusable if you do so.'
+'||Any data-distortions or re-origination should be made BEFORE copying templates to the background. It is not possible to make changes to the data-distortion or re-origination settings'
+' while background templates are currently being drawn.'
+'||Because the DXF files from Templot ignore the printer calibration and output scaling functions, these data distortions are provided instead as a means of making'
+' similar adjustments for templates exported to a CAD program. You will need to do some trial-and-error printing from your CAD software to establish the required distortion factors.'
+'||This is best done by printing a short length of straight plain track which has very long sleepers (say 500 inches) so that the effect of the distortions'
+' can be more easily seen and measured (GEOMETRY > STRAIGHT and REAL > TIMBERING > TIMBERING DATA... menu items). If printing direct from Templot, remember that the printed'
+' grid lines remain undistorted, and thus aid comparison between the distorted and undistorted pages.'
+' Unless you are using a flat-panel display it is difficult to judge the distortion effects on the curved screen.'
+'||All these distortions apply globally for as long as they remain in force, so all templates drawn on the trackpad or in the storage box will be'
+' distorted but will return to normal when distortion is cancelled. The distortion data is not included in the template files'
+' when they are saved from the box, and must be re-entered as required for each working session. All distortions are cancelled when you'
+' do a B-6 TURNOUT RESET (CTRL-Z).'
+'||( Handy hint - make a note of your distortion settings in your memo text. They can then be quickly copied and pasted back into the data entry form after reloading.)'
+'||These distortion functions are listed under the EXPERT menu item, which means that there is little error-checking. It might be posssible to hang or crash Templot'
+' by entering silly figures, so be sure to save your work before experimenting.'
+'||These distortions do not apply to the grid lines or printed trim margins, which are not included in DXF files. If you are using these'
+' distortions when printing directly from Templot the grid will therefore be inaccurate and should be turned off.'
+'||If multiple distortions and/or re-origination are used, they are applied to the drawing data in the following order:'
+'||Scaling and Aspect-distortions'
+'|Coning'
+'|Skewing'
+'|Mirroring'
+'|Re-origination'
+'||Take care with your calculation of the various factors when making multiple distortions. If for some weird reason you choose to use multiple'
+' negative factors you will need a clear head to keep track of your template''s position and the direction of the mouse actions.'
+'||The X coning and skewing distortions are intended for use when printing in upright (portrait) format and the Y coning and skewing distortions'
+' are intended for use when printing in sideways (landscape) format. Templot does NOT check this however and will distort both ways at once if you'
+' set factors for both. It is difficult to imagine a reason to do this !'
+'||Unlike the normal shift functions, re-origination takes place after all distortions and so is unaffected by them. This allows you to position the'
+' distorted template relative to the zero datum to suit the requirements of your CAD application.'
+'||The pre-sets for these distortion factors correspond to the cancelled condition in each case and are as follows:'
+'||X-scaling factor = 100 %'
+'|Y-scaling factor = 100 %'
+'|Aspect-distortion factor = 100 %'
+'|X-Coning factor = 0'
+'|Y-Coning factor = 0'
+'|X-Skewing factor = 0'
+'|Y-Skewing factor = 0'
+'||For more information about each of the above, click the help flags for each on the data entry form.'
+'||Mirroring requires no factor and is toggled on-off on the menu as required. X-Mirroring mirrors the drawing leftwards about the data origin.'
+' Y-Mirroring mirrors the drawing downwards about the data origin.'
+'||Bear in mind that if you use mirroring or negative distortion factors, what appears to be a left-hand turnout may have been calculated as a right-hand one'
+' and be labelled as such in the information panel and storage box (or vice-versa).'
+'||Even if distortions, mirroring or re-origination shift your template completely off-screen, the DXF file will still contain it. ( This is the opposite of the behaviour when'
+' printing directly from Templot, where any part of the drawing to the left of or below the page outlines is cropped.)';
coning_help_str:string=' Coning Distortions'
+'||Coning distortion is an attempt to correct for a worn printer in which the paper roller has become slightly tapered.'
+'||A correction shift forwards or backwards is applied to one dimension which is proportional to the product of both dimensions.'
+'||Coning takes place after any scaling distortions, so for X-coning for example, the basic equation is:-'
+'||x-coned = x-scaled + ( x-coning-factor * x-scaled * y-scaled )'
+'||and setting a coning-factor of zero cancels any effect.'
+'||It will be necessary to establish the coning factor by trial and error for the individual printer being used.'
+' This is best done by printing a short length of straight plain track which has very long sleepers (say 500 inches) so that the effect of the distortions'
+' can be more easily seen and measured (GEOMETRY > STRAIGHT and REAL > TIMBERING > TIMBERING DATA... menu items). If printing direct from Templot, remember that the printed'
+' grid lines remain undistorted, and thus aid comparison between the distorted and undistorted pages.'
+'||The coning factor is always extremely small. For convenience it is internally scaled so that the figures to be entered are'
+' positive or negative and in the range from 0 to perhaps 100. Factors greater than this will produce significant distortion'
+' which is unlikely to print correctly on any printer. A typical setting might be, say, +16.7 or -9.4 which will produce a measurable effect on'
+' a full printed page but not be very evident on the screen.'
+'||( It can be amusing to enter a figure such as -5000 and then experiment with'
+' the mouse actions. This will give you an appreciation of the effect of coning distortion, but it won''t progress your railway very much.)'
+'||Coning distortion applies only to the template drawing, so the grid lines will be inaccurate and should be turned off.'
+'||Coning is cancelled on a B-6 TURNOUT RESET, but otherwise remains in force until you come back here and change it.'
+'||Coning distortions apply globally for as long as they remain in force, so all templates drawn on the trackpad or in the storage box will be'
+' distorted but will return to normal when the distortion is cancelled. The distortion data is not included in the template files'
+' when they are saved from the box, and must be re-entered as required for each working session.'
+'||Please read the F1 general help notes below and the help notes for the other distortions before using coning for the first time.';
skewing_help_str:string=' Skewing Distortions'
+'||Skewing distortion is an attempt to correct for a worn printer in which movement of the print head is not exactly square across the direction of paper feed.'
+'||A correction shift forwards or backwards is applied to one dimension which is proportional to the other dimension.'
+'||Skewing takes place after any coning distortions, so for Y-skewing for example, the basic equation is:-'
+'||y-skewed = y-coned + ( y-skewing-factor * x-coned )'
+'||and setting a skewing-factor of zero cancels any effect.'
+'||It will be necessary to establish the skewing factor by trial and error for the individual printer being used.'
+' This is best done by printing a short length of straight plain track which has very long sleepers (say 500 inches) so that the effect of the distortions'
+' can be more easily seen and measured (GEOMETRY > STRAIGHT and REAL > TIMBERING > TIMBERING DATA... menu items). If printing direct from Templot, remember that the printed'
+' grid lines remain undistorted, and thus aid comparison between the distorted and undistorted pages.'
+'||The skewing factor is always very small. For convenience it is internally scaled so that the figures to be entered are'
+' positive or negative and in the range from 0 to perhaps 100. Factors greater than this will produce very significant distortion'
+' which is unlikely to print correctly on any printer. A typical setting might be, say, +16.7 or -9.4 which will produce a measurable effect on'
+' a full printed page but not be very evident on the screen.'
+'||( It can be amusing to enter a figure such as -5000 and then experiment with'
+' the mouse actions. This will give you an appreciation of the effect of skewing distortion, but it won''t progress your railway very much.)'
+'||Skewing distortion applies only to the template drawing, so the grid lines will be inaccurate and should be turned off.'
+'||Skewing is cancelled on a B-6 TURNOUT RESET, but otherwise remains in force until you come back here and change it.'
+'||Skewing distortions apply globally for as long as they remain in force, so all templates drawn on the trackpad or in the storage box will be'
+' skewed but will return to normal when the distortion is cancelled. The distortion data is not included in the template files'
+' when they are saved from the box, and must be re-entered as required for each working session.'
+'||Please read the F1 general help notes below and the help notes for the other distortions before using skewing for the first time.';
// custom cursor constants..
adjust_ne_cursor_invert=1; // F7 shift.
adjust_corners_cursor_invert=2; // both mouse action.
adjust_ns_cursor_invert=3; // F6 curving, F8 rotate, slew amount.
adjust_we_cursor_invert=4; // F3, F4, F5
mouse_action_cursor=5; // mouse actions.
cross_size_cursor=6; // CTRL-F4 pad move.
target_rings_cursor=7;
open_slider_cursor=8;
zoom_rectangle_cursor=9; // added 13-1-01.
cross_hairs_cursor=10; // added 13-1-01.
group_rectangle_cursor=11; // added 22-2-01.
maxfp:extended=1.0E12; // max float value for our calcs.
minfp:extended=1.0E-12; // min float value for our calcs
// (less than this is regarded as zero to avoid rounding errors).
max_single:single=1.0E10; // used for sketchboard calcs. 212a
minfp_big:extended=1.0E-6; // min float value for rounding and tolerancing.
max_rad:extended=1.0E8-5000; // maximum radius="straight", -5000 to allow for offsets without exceeding 1E8 max_rad_limit.
max_rad_test:extended=1.0E8-10000; // used for testing maximum radius (approx 62 miles rad).
max_rad_limit:extended=1.0E8;
def_req:extended=0-1.0E20; // this value in a float requests a default to be used instead.
def_req_i:integer=Integer($80000001); // this value in an integer ditto.
def_req_single:single=0-1.0E10; // 212a for jt_slwide
maxint:extended=Integer($7FFFFFFF); // these are floats - max 32-bit value for range checks.
minint:extended=Integer($80000000); // ditto - min 32-bit value.
h_maxint:extended=Integer($3FFFFFFF); // maxint/2 these are floats. 31-bit range to leave room for some arithmetic on the values.
h_minint:extended=Integer($C0000000); // minint/2
fname_trunc:integer=50; // 229c file name truncation character count was 20
// defaults for Win 95/98/ME graphics limits
var
max_draw_int:integer=16000; // these are less than 15-bit integers for screen drawing limits...
min_draw_int:integer=-16000; // (divide 16-bit by 2 and a bit as safety margin).
// 0.93.a initial defaults for export limits..
max_export_x:integer=16000;
min_export_x:integer=-16000;
max_export_y:integer=16000;
min_export_y:integer=-16000;
program_version:integer=555; // this program version number (*100, e.g Templot v:1.3 = 130).
version_build:string='.a'; // sub-build letter for this version.
loaded_version:integer=50000; // init the loaded data file versions..
later_file:boolean=False;
he_wants_multiple_monitors:boolean=False; // 0.91.b
ebk1_str:string=''; // 1st emergency backup file name.
ebk2_str:string=''; // 2nd emergency backup file name.
pb_str:string=''; // renamed previous data backup file.
pbo_str:string=''; // renamed prior-previous backup file.
html_path_str:string=''; // for html viewer. 0.91
keeps_list:TStringList; // 8-2-99
memo_list:TStringList;
tag_list:TStringList; // 206b
printer_list:TStringList;
timb_len_list:TStringList; // 227a
box_timber_lengths_list:TStringList; // 227a
info_text_list:TStringList; // 0.78.a 15-11-02.
custom_colour_list:TStringList; // 0.91
pad_view_list:TStringList; // 0.91.c
html_help_list:TStringList; // 0.91
html_printheader_list:TStringList;
html_printfooter_list:TStringList;
boxmru_list:TStringList; // 0.82.a 22-08-06
bgsmru_list:TStringList; // 0.82.a 22-08-06
// 0.91.d pref_options...
user_prefs_list:TStringList; // 0.91.d
user_prefs_in_use:boolean=False;
prefs_existed_on_startup:boolean=False;
prefs_available:boolean=False;
//-----
initdone_flag:boolean=False; // flag no init done.
quit_code:integer=0; // instant abandon if he wants on startup.
under_way:boolean=False; // pad repaints, etc not yet permitted.
prog_running:boolean=True; // for run_error no repaints.
slow_run:extended=0; // for slow running.
quit_alert_done:boolean=False;
allow_idle:boolean=True; // 0.73.a 17-9-01.
graphics_limits:boolean=True; // 0.76.a 25-5-02.
export_limits:boolean=False; // 0.93.a
pad_form_window_state:TWindowState=wsMaximized; // 0.91.b
on_idle_can_run:boolean=False; // not yet ready for on_idle to do saves and redraws. 0.73.a 16-9-01.
box_project_title_str:string='untitled project'; // 225a
current_name_str:string='';
exe_str:string=''; // execution file path.
hi_color:boolean=False;
start_colours:integer=0;
distortions:word; // flag bits. LSB 0 x-scaling
// 1 y-scaling
// 2 aspect
// 3 unused
// 4 x-coning
// 5 y-coning
// 6 x-skewing
// 7 y-skewing
// 8 mirror-x
// 9 mirror-y
// 10.. unused
aspect_distortion_factor, re_org_x, re_org_y :extended;
x_distortion_factor,y_distortion_factor :extended;
x_coning_distortion_factor, y_coning_distortion_factor :extended;
x_skewing_distortion_factor, y_skewing_distortion_factor :extended;
mirror_x, mirror_y :extended;
auto_dir:boolean=True;
backup_wanted:boolean=False;
external_window_showing:boolean=False; // 0.93.a for files showing containing folder
mouse_click_action:integer=-1; // either click-move-click or drag allowed.
printer_text_left_margin:extended=10; // 10mm page margins when printing.
printer_text_right_margin:extended=10;
jpg_quality:integer=100; // 214a
// alert message preferences... 0.91.d
res_msg_pref: boolean=False;
ppi_msg_pref: boolean=False;
start_scheme_msg_pref: boolean=False;
multi_monitors_msg_pref: boolean=False;
refresh_msg_pref: boolean=False;
quit_confirm_msg_pref: boolean=False;
prefs_warn_msg_pref: boolean=False;
wine_warn_msg_pref: boolean=False; // 212b
delete_to_current_msg_pref: boolean=False;
k180_message_msg_pref: boolean=False;
k_notch_msg_pref: boolean=False;
mirrory_msg_pref: boolean=False;
mirrorx_msg_pref: boolean=False;
dupg_msg_pref: boolean=False;
small_print_msg_pref: boolean=False;
spiral_mouse_msg_pref: boolean=True; // not used
group_colour_msg_pref: boolean=False;
b6_msg_pref: boolean=False;
no_delete_msg_pref: boolean=False;
no_unused_msg_pref: boolean=False;
no_library_msg_pref: boolean=False;
no_undo_clear_msg_pref: boolean=False;
no_cut_msg_pref: boolean=False;
trans_msg_pref: boolean=False;
cancel_entries_msg_pref: boolean=False;
no_extra_colours_msg_pref: boolean=False;
omit_all_msg_pref: boolean=False;
drop_msg_pref: boolean=False;
yellow_msg_pref: boolean=False;
auto_fit_msg_pref: boolean=False;
screenshot_msg_pref: boolean=False; // 215a
confirm_detail_mode_1_msg_pref:boolean=False;
confirm_detail_mode_2_msg_pref:boolean=False;
full_draw_trans_pref: boolean=False; // not used
startup_full_draw_pref: boolean=True;
startup_offscreen_pref: boolean=True;
irreg_crossings_msg_pref: boolean=False;
sb_rvf_add_msg_pref:boolean=False; // 0.97.a
sb_no_select_msg_pref:boolean=False; // 0.98.b
too_many_files_msg_pref:boolean=False; // 208e
retain_prefix_msg_pref:boolean=False; // 213b
retain_prefix_pref:boolean=False; // 213b
diagram_partial_msg_pref:boolean=False; // 226c
diagram_partials_omitted:boolean=False; // 226a
running_under_wine:boolean=False; // 205a
arial_str:string='Arial'; // 205a modified for Wine
using_native_colours:boolean=False; // 212a
current_scaling_position:integer=4; // 214c 4=medium
old_scaling_position:integer=4; // 214c
scaling_done_at_least_once:boolean=False; // 214c
//companion_viewer_str:string=''; // 214a set dpi aware in startup_unit
got_file:integer=0; // 227a
procedure run_error(code:integer);
procedure set_printer_font_margins(calling_form:TForm; set_font:boolean); // 0.91
procedure go_to_templot_com; // 0.93.a
procedure go_to_templot_club;
procedure go_to_templot_companion;
procedure go_to_templot_companion_page(dest_page_str:string); // 214a
procedure go_to_zoom_meeting; // 237c
procedure go_to_donation; // 0.96.a Templot2
procedure go_to_upgrade; // 0.96.a Templot2
procedure go_to_video_list; // 211b Templot2
procedure go_to_url(url:string); // 212a
procedure show_pdf_result(path_str,note_str:string); // 205a
procedure wine_modal_warning(str:string); // 206d
function change_jpeg_filename(in_str:string):string; // 214a
function get_path_to_Windows_folder(folder_id:integer):string; // 214a
procedure open_MyPictures; // 214a
procedure open_MyDocuments; // 214a
procedure do_open_source_bang(str:string); // OT2024
//______________________________________________________________________________
implementation
{$BOOLEVAL ON}
uses
ShellAPI, Math, Clipbrd, Printers,
ActiveX, // IMalloc
ShlObj, // Needed for the CSIDL constants
alert_unit, help_sheet, math_unit, pad_unit, info_unit,
gauge_unit, chat_unit, entry_sheet, print_unit, keep_select,
switch_select, metric_unit, colour_unit, xing_select,
plain_track_unit, calibration_unit, startup_unit,
dxf_unit, bgnd_unit, bgkeeps_unit, panning_unit, grid_unit,
shove_timber, stay_visible_unit, action_unit, mint_unit, jotter_unit, print_settings_unit,
prefs_unit, edit_memo_unit, platform_unit,
data_memo_unit, check_diffs_unit, rail_options_unit,
export_unit, { OT2024 file_viewer,} wait_message, trackbed_unit, make_slip_unit, create_tandem,
map_loader_unit, gaps_unit, lib_unit, intersect_unit, brick_unit,
heave_chairs;
{$R *.lfm}
{$R custom_cursors.res}
var
w_len:integer=0;
legal_agree:boolean=False;
welcome_done:boolean=False;
room_scaling:boolean=False; // flag - otherwise statusbar ScrollInView on resize prevents form rescaling properly.
closing_flag:boolean;
open_button_clicked:boolean=False; // 205d
md5_str:string=''; // 217a
procedure check_colours;forward;
procedure create_backup_file(final:boolean);forward;
function cleared_bgnd:boolean;forward;
//__________________________________________________________________________________________
procedure startup_modal_warning(over_ride:boolean);
// over_ride True when called from data-entry form
begin
if (wine_warn_msg_pref=False) or (over_ride=True)
then begin
if over_ride=False
then begin
alert_box.preferences_checkbox.Checked:=False;
alert_box.preferences_checkbox.Show;
end;
alert(2,' Running on Linux / Wine / CrossOver',
'`0important information - please read`9'
+'||This program is running on Linux / Wine / CrossOver.'
+'||In the event the active window becomes hidden behind other windows, the program may stop responding to mouse clicks.'
+'||If this happens, press the `0ESC`2 key on the keyboard (top left) to restore normal working.'
+'||If that doesn''t work, you must drag the topmost window(s) out of the way to reveal the active window or dialog. Or try pressing `0ALT+F7`2.'
+'||To prevent these problems, take care to avoid clicking anywhere other than on the topmost window, dialog or message box.'
+'||(These problems do not arise when running on Windows.)'
+'||<HR STYLE="COLOR:GRAY; HEIGHT:3px; NOSHADE">'
+'|By default this program uses Windows native fonts.'
+'||If these do not display properly you can try changing to Wine open-source fonts.'
+'||On the `0program panel`1 window click the `0program > use Wine fonts`z menu item.'
+'||To return to using Windows native fonts it will be necessary to restart Templot.',
'','','','','','OK',0);
if over_ride=False
then begin
wine_warn_msg_pref:=alert_box.preferences_checkbox.Checked;
alert_box.preferences_checkbox.Hide;
end;
end;
end;
//______________________________________________________________________________
procedure wine_modal_warning(str:string);
begin
if alert(1,'php/990 running under Linux / Wine / CrossOver',
'You are running Templot under Linux/Wine/CrossOver.'
+'||The '+str+' dialog is required to be modal, which means that it must be completed before Templot can continue.'
+'||Modal dialogs are not fully supported under Wine, so while the dialog window is showing you must click on the dialog window ONLY.'
+'||If you click elsewhere on the screen the dialog may become hidden behind other windows, after which Templot will not be able to continue until you find the dialog again and complete it.'
+'||If you cannot do that, you can press the `0ESC`2 key (top-left) on the keyboard to cancel the operation and try again.'
+'||The same applies to this message dialog, while it is showing you must not click anywhere else.'
+'||This is a feature of Wine beyond Templot''s control.'
+'||If you have problems with this, please post a message on the <A HREF="go_to_templot_club.85a"><SPAN STYLE="color:#0000FF;"><U>Templot Club</U></SPAN></A> user forum.',
'','','','more information','','continue',0)=4
then startup_modal_warning(True); // true=over-ride msg prefs
end;
//______________________________________________________________________________
procedure run_error(code:integer);
begin
prog_running:=False; // prevent pad repaints, etc.
wipe_pad; // blank it all.
alert(5,' fatal error',
'||Sorry, Templot has suffered a fatal internal error and cannot continue.'
+'||Please report fail code '+IntToStr(code)
+'||If you save your work on quitting, please use a fresh file name as a precaution against corrupting your existing file.'
+'||Please quit and restart Templot.'
+'||If the problem recurs, please post a message at 85a.uk/templot/club quoting the above fail code.',
'','','','','','quit Templot',0);
quit_code:=2; // flag no cancel possible, and delete backups.
control_room_form.Close; // this is the main form,
// so the application closes (via the quit query alert).
//Application.Terminate; // redundant line - in case I change the main form.
RUNERROR(99); // mustn't return from this routine.
end;
//_______________________________________________________________________________________
function quit_alert:Boolean; // he wants to quit...
// returns True if quit permitted.
const
quit_help:string=' Saving your work between sessions.'
+'||"Storing" a template in your STORAGE BOX is not the same thing as "saving" it to a file on a disk drive.'
+' "Stored" templates are held only in Templot''s memory, so that each template is instantly available without the need to access files.'
+'||Templot can automatically restore the contents of your storage box and your background track plan (if any) between sessions, but it can only "remember" one set of box contents at any one time.'
+'||For future reference and reloading whenever you need them, you may also want to save the current box contents in a separate named data file before quitting Templot.'
+'||For more information about saving data files, click the ? HELP button in the storage box.'
+'|---------------------------------'
+'||If you want to prevent an automatic restore on the next startup, change the OPTIONS > RESTORE ON STARTUP menu options in the storage box menus.'
+'||To restore the previous box contents at any time after startup, click the FILES > RESTORE PREVIOUS menu item in the storage box menus.'
+' This works independently of the option settings for automatic restore on startup. You can click RESTORE PREVIOUS as often as you wish, the data from your previous Templot session remains available throughout the current session.'
+'||Likewise, the FILES > RESTORE PRIOR-PREVIOUS menu item restores the box contents from the Templot session prior to the previous one, i.e. from two sessions back.'
+'||The restore feature works independently of your own saved data files, and makes no changes to them.'
+'||The restore feature works correctly even if your previous session terminated abnormally as a result of a power failure or system malfunction, so there is no need to perform repeated saves as a precaution against these events.'
+'||N.B. Background Shapes are not included in the automatic restore feature, and must always be saved separately.'
+'||N.B. If you run two instances of Templot concurrently (not recommended for Windows 95/98/ME) from the same TEMPLOT folder,'
+' the restore data will be held in common between the two. To prevent this happening, create and run the second instance from a different folder (directory).';
var
i:integer;
save_str, no_save_str, spacer_str, backup_str:string;
begin
if quit_alert_done=True // been here once and he already quit. (in case duplicate call on Windows terminate message).
then begin
RESULT:=True;
EXIT;
end;
RESULT:=False; // default init, don't quit.
case quit_code of
0: RESULT:=True; // instant abandon.
2: begin
RESULT:=True; // code 2 - run_error - don't permit cancel.
DeleteFile(ebk1_str); // and clear backup files - might be corrupted..
DeleteFile(ebk2_str);
if save_done=False
then begin
repeat
i:=alert(1,' session must finish - save templates ?',
'|An error has occurred and Templot is about to quit.'
+'||To avoid corrupted data, the storage box contents will not be restored next time.'
+'||Your storage box contains one or more templates which you wanted to keep, but which have not yet been saved.'
+'||Do you want to save your work ?',
'','','? help','no - abandon templates and quit ','',
'yes - save all templates and quit ',3);
if i=3 then alert_help(0,quit_help,'');
until i<>3;
case i of
6: save_box(0,0,0,''); // go do the save.
end;//case
end;
if shapes_saved=False
then begin
i:=alert(7,' session must finish - save shapes ?',
'||Templot is about to quit.'
+'||You have one or more background shapes which have not been saved.'
+'||Do you want to save your background shapes ?',
'','','','no - abandon shapes and quit ','',
'yes - save all shapes and quit ',0);
case i of
6: bgnd_form.save_all_menu_entry.Click;
end;//case
end;
end;
3: begin // code 3 - normal quit..
create_backup_file(True); // one last time.
if shapes_saved=False
then begin
i:=alert(7,' session finished ? - save shapes ?',
'||Templot is about to quit.'
+'||You have one or more background shapes which have not been saved.'
+'||Do you want to save your background shapes ?',
'','','','no - abandon shapes and quit ','cancel quit - continue running ',
'yes - save all shapes and quit ',0);
case i of
4: RESULT:=True;
5: begin
RESULT:=False;
EXIT;
end;
6: begin
bgnd_form.save_all_menu_entry.Click;
RESULT:=shapes_saved;
if RESULT=False then EXIT; // he cancelled the save.
end;
end;//case
end;
if (keeps_list.Count=0) and (RESULT=True) // nothing else to save.
then EXIT // so don't alert him again, just quit.
else begin
spacer_str:='||||| '; // defaults..
save_str:='QUIT ';
no_save_str:='';
backup_str:='';
if keeps_list.Count>0
then begin
if save_done=False
then begin
save_str:='save all templates in a named file and QUIT ';
no_save_str:='QUIT ';
spacer_str:='| ';
backup_str:='||Your storage box contains one or more templates which have not yet been saved in a named data file.'
+'||These and your background track plan can be restored when you next run Templot,'
+' but you may also want to save them in a named data file before quitting.';
end;
end;
if (quit_confirm_msg_pref=False) or (no_save_str<>'') // pref by-passed if nothing to save.
then begin
if no_save_str='' // nothing to save, but pref is to show dialog (default).
then begin
alert_box.preferences_checkbox.Checked:=False; //%%%%
if user_prefs_in_use=True then alert_box.preferences_checkbox.Show;
end;
repeat
i:=alert(7,' session finished ?',
spacer_str+'Templot is about to QUIT.'+backup_str,
'','','important information ',no_save_str,'cancel quit - continue running ',save_str,3);
if i=3 then alert_help(0,quit_help,'');
until i<>3;
if no_save_str=''
then begin
quit_confirm_msg_pref:=alert_box.preferences_checkbox.Checked; //%%%%
alert_box.preferences_checkbox.Hide;