-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbgnd_unit.pas
More file actions
11913 lines (8563 loc) · 440 KB
/
bgnd_unit.pas
File metadata and controls
11913 lines (8563 loc) · 440 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 bgnd_unit;
{$MODE Delphi}
{$ALIGN OFF}
interface
uses
StdCtrls, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ComCtrls, Menus, ExtDlgs, Buttons, pad_unit;
type
Tbgnd_form = class(TForm)
datestamp_label: TLabel;
blue_corner_panel: TPanel;
how_panel: TPanel;
size_updown: TUpDown;
colour_panel: TPanel;
colour_patch: TImage;
close_panel: TPanel;
close_button: TButton;
p1_label: TLabel;
p2_label: TLabel;
empty_label: TLabel;
type_label: TLabel;
filesave_dialog: TSaveDialog;
bgs_file_label: TLabel;
fileload_dialog: TOpenDialog;
bgnd_shapes_listbox: TListBox;
count_label: TLabel;
tab_panel: TPanel;
shapes_pages: TPageControl;
modify_all_sheet: TTabSheet;
shift_all_by_button: TButton;
mirror_groupbox: TGroupBox;
mirror_x_button: TButton;
mirror_y_button: TButton;
scale_all_by_button: TButton;
rotate_all_by_button: TButton;
dxf_sheet: TTabSheet;
import_dxf_button: TButton;
dxf_units_groupbox: TGroupBox;
dxf_mm_radio: TRadioButton;
dxf_inches_radio: TRadioButton;
modify_on_import_groupbox: TGroupBox;
scale_by_label: TLabel;
shift_x_label: TLabel;
shift_y_label: TLabel;
dxf_set_button: TButton;
dxf_limits_checkbox: TCheckBox;
font_sheet: TTabSheet;
label_font_button: TButton;
colour_groupbox: TGroupBox;
pad_colour_button: TButton;
print_colour_button: TButton;
options_sheet: TTabSheet;
close_checkbox: TCheckBox;
reload_limits_checkbox: TCheckBox;
trackpad_grid_in_front_checkbox: TCheckBox;
mm_grid_button: TButton;
dxf_file_dialog: TOpenDialog;
picture_borders_checkbox: TCheckBox;
line_width_groupbox: TGroupBox;
pad_shapes_linewidth_1_radiobutton: TRadioButton;
pad_shapes_linewidth_2_radiobutton: TRadioButton;
pad_shapes_linewidth_3_radiobutton: TRadioButton;
use_notch_fixed_marker_checkbox: TCheckBox;
recent_popup_menu: TPopupMenu;
recent_1_popup_entry: TMenuItem;
recent_2_popup_entry: TMenuItem;
recent_3_popup_entry: TMenuItem;
recent_4_popup_entry: TMenuItem;
recent_5_popup_entry: TMenuItem;
recent_6_popup_entry: TMenuItem;
N1: TMenuItem;
recent_bgsfiles_caption_popup_entry: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
clear_recent_bgs_popup_entry: TMenuItem;
N4: TMenuItem;
bgsmru_cancel_popup_entry: TMenuItem;
picture_load_dialog: TOpenPictureDialog;
picture_save_dialog: TSavePictureDialog;
move_up_button: TSpeedButton;
move_down_button: TSpeedButton;
move_to_top_button: TSpeedButton;
move_to_bottom_button: TSpeedButton;
shape_page_control: TPageControl;
new_tab_sheet: TTabSheet;
modify_tab_sheet: TTabSheet;
Label3: TLabel;
modify_panel: TPanel;
modify_button: TButton;
mouse_action_groupbox: TGroupBox;
corner1_button: TButton;
mouse_shift_one_button: TButton;
corner2_button: TButton;
mouse_scale_one_button: TButton;
scale_one_by_button: TButton;
picture_groupbox: TGroupBox;
reload_picture_button: TButton;
twist_picture_button: TButton;
save_picture_button: TButton;
marker_line_fixed_button: TButton;
marker_line_twist_button: TButton;
trans_checkbox: TCheckBox;
wrap_picture_button: TButton;
straighten_picture_button: TButton;
rotate_one_by_button: TButton;
new_panel: TPanel;
name_label: TLabel;
Label1: TLabel;
name_editbox: TEdit;
shape_groupbox: TGroupBox;
line_radio_button: TRadioButton;
rect_radio_button: TRadioButton;
circle_radio_button: TRadioButton;
label_radio_button: TRadioButton;
target_radio_button: TRadioButton;
picture_radio_button: TRadioButton;
style_groupbox: TGroupBox;
clear_radio_button: TRadioButton;
solid_infill_radio_button: TRadioButton;
hatched_radio_button: TRadioButton;
line_groupbox: TGroupBox;
solid_radio_button: TRadioButton;
dotted_radio_button: TRadioButton;
shift_one_by_button: TButton;
all_mouse_groupbox: TGroupBox;
mouse_shift_all_button: TButton;
mouse_rotate_all_button: TButton;
mouse_scale_all_button: TButton;
TabSheet1: TTabSheet;
delete_25_button: TButton;
delete_50_button: TButton;
Label4: TLabel;
Label5: TLabel;
lock_groupbox: TGroupBox;
picture_lock_to_origin_radiobutton: TRadioButton;
picture_lock_to_notch_radiobutton: TRadioButton;
picture_lock_to_ring_radiobutton: TRadioButton;
output_grid_in_front_checkbox: TCheckBox;
Label6: TLabel;
output_shapes_in_front_of_sb_checkbox: TCheckBox;
paste_button: TButton;
all_90degs_groupbox: TGroupBox;
all_90degs_acw_button: TButton;
all_90degs_cw_button: TButton;
crop_rectangle_button: TButton;
bgnd_shapes_menu: TMainMenu;
bgnd_files_menu: TMenuItem;
bgnd_edit_menu: TMenuItem;
rename_menu_entry: TMenuItem;
reload_menu_entry: TMenuItem;
add_file_menu_entry: TMenuItem;
N5: TMenuItem;
save_all_menu_entry: TMenuItem;
N6: TMenuItem;
hide_menu_entry: TMenuItem;
N7: TMenuItem;
delete_menu_entry: TMenuItem;
N8: TMenuItem;
delete_all_menu_entry: TMenuItem;
bgnd_draw_menu: TMenuItem;
draw_mouse_menu_entry: TMenuItem;
N9: TMenuItem;
bgnd_help_menu: TMenuItem;
background_shapes_help_menu_entry: TMenuItem;
N10: TMenuItem;
picture_shapes_help_menu_entry: TMenuItem;
draw_spacing_ring_menu_entry: TMenuItem;
recent_files_menu_entry: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
N19: TMenuItem;
dimensions_menu_entry: TMenuItem;
Label24: TLabel;
bgnd_zoom_menu: TMenuItem;
zoom_fit_shape_menu_entry: TMenuItem;
N20: TMenuItem;
zoom_fit_all_shapes_menu_entry: TMenuItem;
N21: TMenuItem;
N22: TMenuItem;
N23: TMenuItem;
Label7: TLabel;
Label8: TLabel;
N24: TMenuItem;
N25: TMenuItem;
N26: TMenuItem;
break_rectangle_menu_entry: TMenuItem;
combine_pictures_menu_entry: TMenuItem;
N29: TMenuItem;
N30: TMenuItem;
N28: TMenuItem;
scan_button: TButton;
Label9: TLabel;
copy_image_button: TButton;
auto_fit_picture_button: TButton;
buttons_panel: TPanel;
Label2: TLabel;
shapes_help_label: TLabel;
add_shape_button: TButton;
enter_dims_radiobutton: TRadioButton;
clicked_locs_radiobutton: TRadioButton;
by_drawing_radiobutton: TRadioButton;
add_picture_shape_button: TButton;
Label10: TLabel;
Label11: TLabel;
new_picture_shape1: TShape;
new_picture_shape2: TShape;
bgsfilescanalsobe1: TMenuItem;
draggedontothetrackpad1: TMenuItem;
go_to_my_documents_menu_entry: TMenuItem;
N32: TMenuItem;
Label46: TLabel;
open_mystuff_button: TButton;
Label12: TLabel;
shift_one_to_button: TButton;
scale_one_to_button: TButton;
new_picture_shape3: TShape;
show_tick_image: TImage;
hide_tick_image: TImage;
show_output_tick_image: TImage;
hide_output_tick_image: TImage;
show_on_trackpad_static: TStaticText;
show_on_output_static: TStaticText;
bgnd_show_menu: TMenuItem;
N33: TMenuItem;
show_on_trackpad_menu_entry: TMenuItem;
N34: TMenuItem;
show_on_output_menu_entry: TMenuItem;
N35: TMenuItem;
N36: TMenuItem;
bgnd_recent_menu: TMenuItem;
saved_jpg_quality_menu_entry: TMenuItem;
N37: TMenuItem;
N38: TMenuItem;
calculate_map_size_menu_entry: TMenuItem;
bgnd_map_menu: TMenuItem;
N39: TMenuItem;
N40: TMenuItem;
N41: TMenuItem;
N42: TMenuItem;
convert_24bit_button: TButton;
convert_24bit_menu_entry: TMenuItem;
N43: TMenuItem;
N27: TMenuItem;
bgnd_all_menu: TMenuItem;
break_all_rectangles_menu_entry: TMenuItem;
N44: TMenuItem;
N45: TMenuItem;
rotate_around_groupbox: TGroupBox;
lock_grid_radiobutton: TRadioButton;
lock_notch_radiobutton: TRadioButton;
lock_ring_radiobutton: TRadioButton;
twist_groupbox: TGroupBox;
twist_centre_radiobutton: TRadioButton;
twist_as_all_radiobutton: TRadioButton;
Label13: TLabel;
all_pictures_transparent_menu_entry: TMenuItem;
no_pictures_transparent_menu_entry: TMenuItem;
N46: TMenuItem;
N47: TMenuItem;
N48: TMenuItem;
allow_sync_checkbox: TCheckBox;
N49: TMenuItem;
map_clarity_button: TButton;
rename_button: TButton;
allow_shape_sync_checkbox: TCheckBox;
stop_lines_button: TButton;
size_label: TLabel;
improve_map_clarity_menu_entry: TMenuItem;
save_map_tiles_menu_entry: TMenuItem;
Label14: TLabel;
target_clip_menu: TMenuItem;
clip_adjust_size_menu_entry: TMenuItem;
clip_adjust_angle_menu_entry: TMenuItem;
N50: TMenuItem;
clip_swap_direction_menu_entry: TMenuItem;
N51: TMenuItem;
add_new_clip_menu_entry: TMenuItem;
N52: TMenuItem;
shift_clip_menu_entry: TMenuItem;
N53: TMenuItem;
N54: TMenuItem;
N55: TMenuItem;
clip_colour_menu_entry: TMenuItem;
N56: TMenuItem;
clip_colour_as_marker_menu_entry: TMenuItem;
tommy_bar_menu_entry: TMenuItem;
tommy_claws_menu_entry: TMenuItem;
N60: TMenuItem;
N61: TMenuItem;
N62: TMenuItem;
bgnd_splint_menu: TMenuItem;
N57: TMenuItem;
splint_colour_as_marker_menu_entry: TMenuItem;
splint_colour_menu_entry: TMenuItem;
N58: TMenuItem;
alowsyncwithtemplatemoves1: TMenuItem;
N59: TMenuItem;
N63: TMenuItem;
pictureshapes1: TMenuItem;
lineshapessplints1: TMenuItem;
targetmarksclips1: TMenuItem;
rectanglesandcircles1: TMenuItem;
labels_sync_menu_entry: TMenuItem;
all_pictures_sync_menu_entry: TMenuItem;
none_pictures_sync_menu_entry: TMenuItem;
all_lines_sync_menu_entry: TMenuItem;
none_lines_sync_menu_entry: TMenuItem;
all_targets_sync_menu_entry: TMenuItem;
none_targets_sync_menu_entry: TMenuItem;
all_rectangles_sync_menu_entry: TMenuItem;
none_rectangles_sync_menu_entry: TMenuItem;
all_labels_sync_menu_entry: TMenuItem;
none_labels_sync_menu_entry: TMenuItem;
allshapes1: TMenuItem;
N64: TMenuItem;
all_sync_menu_entry: TMenuItem;
none_sync_menu_entry: TMenuItem;
N65: TMenuItem;
circles1: TMenuItem;
all_circles_sync_menu_entry: TMenuItem;
none_circles_sync_menu_entry: TMenuItem;
bgnd_options_menu: TMenuItem;
twist_corner_colour_menu_entry: TMenuItem;
N66: TMenuItem;
combined_patch_colour_menu_entry: TMenuItem;
N68: TMenuItem;
N69: TMenuItem;
mouse_move_ring_menu_entry: TMenuItem;
add_clip_at_ring_menu_entry: TMenuItem;
N70: TMenuItem;
add_new_clip_at_notch_menu_entry: TMenuItem;
N71: TMenuItem;
N67: TMenuItem;
label_text_as_RGB_menu_entry: TMenuItem;
Label15: TLabel;
brick_label_checkbox: TCheckBox;
slab_adjust_angle_menu_entry: TMenuItem;
N72: TMenuItem;
thismenuisexperimentalfor3Dexports1: TMenuItem;
thismenuisexperimentalfor3Dexports2: TMenuItem;
add_brick_checkbox: TCheckBox;
set_as_brick_checkbox: TCheckBox;
apply_button: TButton;
save_all_brick_shapes_menu_entry: TMenuItem;
N73: TMenuItem;
add_paired_clip_menu_entry: TMenuItem;
N74: TMenuItem;
N75: TMenuItem;
N31: TMenuItem;
remove_pairing_menu_entry: TMenuItem;
save_current_brick_shapes_menu_entry: TMenuItem;
go_to_paired_clip_menu_entry: TMenuItem;
twist_rectangle_button: TButton;
twist_one_by_button: TButton;
twist_one_to_button: TButton;
brick_boundary_groupbox: TGroupBox;
pad_brick_boundary_1_radio: TRadioButton;
pad_brick_boundary_2_radio: TRadioButton;
pad_brick_boundary_3_radio: TRadioButton;
pad_brick_boundary_4_radio: TRadioButton;
pad_brick_boundary_5_radio: TRadioButton;
pad_brick_boundary_6_radio: TRadioButton;
pad_shapes_linewidth_4_radiobutton: TRadioButton;
bgnd_boundary_menu: TMenuItem;
thismenuisexperimentalfor3Dexports3: TMenuItem;
N76: TMenuItem;
boundary_colour_as_marker_menu_entry: TMenuItem;
boundary_colour_menu_entry: TMenuItem;
N77: TMenuItem;
boundary_dimensions_menu_entry: TMenuItem;
N78: TMenuItem;
add_new_boundary_menu_entry: TMenuItem;
N79: TMenuItem;
N80: TMenuItem;
show_pre_sets_menu_entry: TMenuItem;
Label16: TLabel;
brick_wall_checkbox: TCheckBox;
N81: TMenuItem;
brick_wall_dims_menu_entry: TMenuItem;
show_hide_brick_shapes_colour_menu_entry: TMenuItem;
show_all_brick_shapes_menu_entry: TMenuItem;
brick_label_scaling_menu_entry: TMenuItem;
create_array_menu_entry: TMenuItem;
doclips1: TMenuItem;
add_kerf_lines_checkbox: TCheckBox;
procedure size_updownClick(Sender: TObject; Button: TUDBtnType);
procedure colour_panelClick(Sender: TObject);
procedure close_buttonClick(Sender: TObject);
procedure how_panelClick(Sender: TObject);
procedure line_radio_buttonClick(Sender: TObject);
procedure rect_radio_buttonClick(Sender: TObject);
procedure add_shape_buttonClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure modify_buttonClick(Sender: TObject);
procedure bgnd_shapes_listboxClick(Sender: TObject);
procedure label_font_buttonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure label_radio_buttonClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormActivate(Sender: TObject);
procedure pad_colour_buttonClick(Sender: TObject);
procedure shift_all_by_buttonClick(Sender: TObject);
procedure corner1_buttonClick(Sender: TObject);
procedure corner2_buttonClick(Sender: TObject);
procedure mouse_shift_one_buttonClick(Sender: TObject);
procedure mouse_shift_all_buttonClick(Sender: TObject);
procedure scale_all_by_buttonClick(Sender: TObject);
procedure mirror_x_buttonClick(Sender: TObject);
procedure mirror_y_buttonClick(Sender: TObject);
procedure print_colour_buttonClick(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure target_radio_buttonClick(Sender: TObject);
procedure rotate_all_by_buttonClick(Sender: TObject);
procedure mm_grid_buttonClick(Sender: TObject);
procedure mouse_scale_all_buttonClick(Sender: TObject);
procedure mouse_rotate_all_buttonClick(Sender: TObject);
procedure dxf_set_buttonClick(Sender: TObject);
procedure import_dxf_buttonClick(Sender: TObject);
procedure mouse_scale_one_buttonClick(Sender: TObject);
procedure picture_radio_buttonClick(Sender: TObject);
procedure reload_picture_buttonClick(Sender: TObject);
procedure scale_one_by_buttonClick(Sender: TObject);
procedure delete_50_buttonClick(Sender: TObject);
procedure delete_25_buttonClick(Sender: TObject);
procedure twist_picture_buttonClick(Sender: TObject);
procedure save_picture_buttonClick(Sender: TObject);
procedure marker_line_fixed_buttonClick(Sender: TObject);
procedure marker_line_twist_buttonClick(Sender: TObject);
procedure trackpad_grid_in_front_checkboxClick(Sender: TObject);
procedure trans_checkboxMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure use_notch_fixed_marker_checkboxClick(Sender: TObject);
procedure lock_grid_radiobuttonClick(Sender: TObject);
procedure lock_notch_radiobuttonClick(Sender: TObject);
procedure lock_ring_radiobuttonClick(Sender: TObject);
procedure recent_buttonClick(Sender: TObject);
procedure recent_1_popup_entryClick(Sender: TObject);
procedure recent_2_popup_entryClick(Sender: TObject);
procedure recent_3_popup_entryClick(Sender: TObject);
procedure recent_4_popup_entryClick(Sender: TObject);
procedure recent_5_popup_entryClick(Sender: TObject);
procedure recent_6_popup_entryClick(Sender: TObject);
procedure clear_recent_bgs_popup_entryClick(Sender: TObject);
procedure wrap_picture_buttonClick(Sender: TObject);
procedure move_to_top_buttonClick(Sender: TObject);
procedure move_to_bottom_buttonClick(Sender: TObject);
procedure move_up_buttonMouseDown(Sender:TObject; Button:TMouseButton; Shift:TShiftState; X,Y:Integer);
procedure move_up_buttonMouseUp(Sender:TObject; Button:TMouseButton; Shift:TShiftState; X,Y:Integer);
procedure move_down_buttonMouseDown(Sender:TObject; Button:TMouseButton; Shift:TShiftState; X,Y:Integer);
procedure move_down_buttonMouseUp(Sender:TObject; Button:TMouseButton; Shift:TShiftState; X,Y:Integer);
procedure straighten_picture_buttonClick(Sender: TObject);
procedure shift_one_by_buttonClick(Sender: TObject);
procedure rotate_one_by_buttonClick(Sender: TObject);
procedure paste_buttonClick(Sender: TObject);
procedure all_90degs_acw_buttonClick(Sender: TObject);
procedure all_90degs_cw_buttonClick(Sender: TObject);
procedure reload_menu_entryClick(Sender: TObject);
procedure add_file_menu_entryClick(Sender: TObject);
procedure recent_files_menu_entryClick(Sender: TObject);
procedure save_all_menu_entryClick(Sender: TObject);
procedure delete_menu_entryClick(Sender: TObject);
procedure delete_all_menu_entryClick(Sender: TObject);
procedure background_shapes_help_menu_entryClick(Sender: TObject);
procedure draw_mouse_menu_entryClick(Sender: TObject);
procedure picture_shapes_help_menu_entryClick(Sender: TObject);
procedure rename_menu_entryClick(Sender: TObject);
procedure zoom_fit_all_shapes_menu_entryClick(Sender: TObject);
procedure zoom_fit_shape_menu_entryClick(Sender: TObject);
procedure draw_spacing_ring_menu_entryClick(Sender: TObject);
procedure enter_dims_radiobuttonClick(Sender: TObject);
procedure clicked_locs_radiobuttonClick(Sender: TObject);
procedure by_drawing_radiobuttonClick(Sender: TObject);
procedure break_rectangle_menu_entryClick(Sender: TObject);
procedure combine_pictures_menu_entryClick(Sender: TObject);
procedure shapes_help_labelMouseMove(Sender:TObject; Shift:TShiftState; X,Y:Integer);
procedure new_panelMouseMove(Sender:TObject; Shift:TShiftState; X,Y:Integer);
procedure shapes_help_labelClick(Sender: TObject);
procedure scan_buttonClick(Sender: TObject);
procedure copy_image_buttonClick(Sender: TObject);
procedure auto_fit_picture_buttonClick(Sender: TObject);
procedure apply_buttonClick(Sender: TObject);
procedure add_picture_shape_buttonClick(Sender: TObject);
procedure go_to_my_documents_menu_entryClick(Sender: TObject);
procedure open_mystuff_buttonClick(Sender: TObject);
procedure shift_one_to_buttonClick(Sender: TObject);
procedure bgnd_shapes_listboxDblClick(Sender: TObject);
procedure hide_tick_imageClick(Sender: TObject);
procedure show_tick_imageClick(Sender: TObject);
procedure show_output_tick_imageClick(Sender: TObject);
procedure hide_output_tick_imageClick(Sender: TObject);
procedure bgnd_shapes_listboxDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure show_on_trackpad_staticClick(Sender: TObject);
procedure show_on_output_staticClick(Sender: TObject);
procedure scale_one_to_buttonClick(Sender: TObject);
procedure saved_jpg_quality_menu_entryClick(Sender: TObject);
procedure calculate_map_size_menu_entryClick(Sender: TObject);
procedure bgnd_map_menuClick(Sender: TObject);
procedure convert_24bit_menu_entryClick(Sender: TObject);
procedure break_all_rectangles_menu_entryClick(Sender: TObject);
procedure all_pictures_transparent_menu_entryClick(Sender: TObject);
procedure no_pictures_transparent_menu_entryClick(Sender: TObject);
procedure allow_shape_sync_checkboxMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure stop_lines_buttonClick(Sender: TObject);
procedure improve_map_clarity_menu_entryClick(Sender: TObject);
procedure save_map_tiles_menu_entryClick(Sender: TObject);
procedure map_clarity_buttonClick(Sender: TObject);
procedure modified_3d_checkboxClick(Sender: TObject);
procedure clip_adjust_size_menu_entryClick(Sender: TObject);
procedure clip_adjust_angle_menu_entryClick(Sender: TObject);
procedure clip_swap_direction_menu_entryClick(Sender: TObject);
procedure add_new_clip_menu_entryClick(Sender: TObject);
procedure shift_clip_menu_entryClick(Sender: TObject);
procedure clip_colour_menu_entryClick(Sender: TObject);
procedure clip_colour_as_marker_menu_entryClick(Sender: TObject);
procedure target_clip_menuClick(Sender: TObject);
procedure tommy_bar_menu_entryClick(Sender: TObject);
procedure tommy_claws_menu_entryClick(Sender: TObject);
procedure splint_colour_as_marker_menu_entryClick(Sender: TObject);
procedure splint_colour_menu_entryClick(Sender: TObject);
procedure all_sync_menu_entryClick(Sender: TObject);
procedure none_sync_menu_entryClick(Sender: TObject);
procedure all_pictures_sync_menu_entryClick(Sender: TObject);
procedure none_pictures_sync_menu_entryClick(Sender: TObject);
procedure all_lines_sync_menu_entryClick(Sender: TObject);
procedure none_lines_sync_menu_entryClick(Sender: TObject);
procedure all_rectangles_sync_menu_entryClick(Sender: TObject);
procedure none_rectangles_sync_menu_entryClick(Sender: TObject);
procedure all_labels_sync_menu_entryClick(Sender: TObject);
procedure none_labels_sync_menu_entryClick(Sender: TObject);
procedure all_targets_sync_menu_entryClick(Sender: TObject);
procedure none_targets_sync_menu_entryClick(Sender: TObject);
procedure all_circles_sync_menu_entryClick(Sender: TObject);
procedure none_circles_sync_menu_entryClick(Sender: TObject);
procedure twist_corner_colour_menu_entryClick(Sender: TObject);
procedure combined_patch_colour_menu_entryClick(Sender: TObject);
procedure mouse_move_ring_menu_entryClick(Sender: TObject);
procedure add_clip_at_ring_menu_entryClick(Sender: TObject);
procedure add_new_clip_at_notch_menu_entryClick(Sender: TObject);
procedure label_text_as_RGB_menu_entryClick(Sender: TObject);
procedure brick_label_checkboxMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure slab_adjust_angle_menu_entryClick(Sender: TObject);
procedure set_as_brick_checkboxMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure add_paired_clip_menu_entryClick(Sender: TObject);
procedure remove_pairing_menu_entryClick(Sender: TObject);
procedure go_to_paired_clip_menu_entryClick(Sender: TObject);
procedure twist_rectangle_buttonClick(Sender: TObject);
procedure twist_one_by_buttonClick(Sender: TObject);
procedure twist_one_to_buttonClick(Sender: TObject);
procedure boundary_dimensions_menu_entryClick(Sender: TObject);
procedure bgnd_boundary_menuClick(Sender: TObject);
procedure add_new_boundary_menu_entryClick(Sender: TObject);
procedure boundary_colour_as_marker_menu_entryClick(Sender: TObject);
procedure boundary_colour_menu_entryClick(Sender: TObject);
procedure brick_wall_checkboxMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure brick_wall_dims_menu_entryClick(Sender: TObject);
procedure show_hide_brick_shapes_colour_menu_entryClick(
Sender: TObject);
procedure show_all_brick_shapes_menu_entryClick(Sender: TObject);
procedure brick_label_scaling_menu_entryClick(Sender: TObject);
procedure create_array_menu_entryClick(Sender: TObject);
procedure doclips1Click(Sender: TObject);
procedure add_brick_checkboxMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure add_kerf_lines_checkboxMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
bgnd_form: Tbgnd_form;
//-----------------------------
shapes_label_font:TFont;
shapes_saved:boolean=True; // nothing there yet to be saved.
bgnd_no_update:boolean=False;
// 214a for drawn shapes...
shape_rectangle_x1:extended=0; // export image rectangle mm...
shape_rectangle_y1:extended=0;
shape_rectangle_x2:extended=600; // arbitrary default 600mm x 300mm (2ft x 1ft)
shape_rectangle_y2:extended=300;
clip_size:extended=3; // mm 229a
clip_angle:extended=0; // 229a
rotate_centre_code:integer=3; // 1:notch 2:spacing-ring 3:grid 219a rotate all
empty_picture_str:string='(empty picture)';
twist_corner_colour:TColor=clWhite; // 232a
combined_patch_colour:TColor=clWhite; // 232a
brick_boundary_rectangle_x:extended=0; // 234d ...
brick_boundary_rectangle_y:extended=0;
brick_boundary_rectangle_w:extended=210; // pre-sets arbitrary
brick_boundary_rectangle_h:extended=180;
brick_boundary_rectangle_k:extended=0;
//adjusting_bgshapes:boolean=False;
procedure do_bgnd(modify:boolean);
procedure scale_all_shapes(xfactor,yfactor:extended);
procedure shift_all_shapes(sync:boolean; xshift,yshift:extended); // sync 226b
procedure rotate_all_shapes(sync,pictures:boolean; rot_k:extended);
procedure scale_this_shape(xfactor,yfactor:extended);
procedure shift_this_shape(xshift,yshift:extended; corners:integer);
procedure shapes_current_state;
procedure load_shapes(file_str:string; append,mru,dropped:boolean);
procedure bgnd_move_up_button_click; // 205a
procedure bgnd_move_down_button_click; // 205a
procedure normalize_line(var p1,p2:Tpex); //214a
procedure normalize_rectangle(var p1,p2:Tpex); //214a
function do_twain(var img_bmp:TBitmap):boolean; // 213b
procedure add_shape(add_option:integer);
procedure add_picture_expert; // 214a
procedure free_shape_object(n:integer); // moved here 215a
procedure show_bgs3_progress; // 227a called from dtpNativeXml at TXmlNode.ReadFromStream(S:TStream);
function check_if_tile(n:integer; map_str:string):boolean; // 227a
function get_rgb_text(col:integer):string; // 234a brick label colour RGB
function get_rgb_hex(col:integer):string; // colour in hex
function init_bgnd_shape:Tbgnd_shape; // 234b
function find_paired_clip(i:integer):integer; // 234c
procedure size_this_clip(size:extended); // 229a
procedure rotate_this_clip_slab(angle:extended); // 229a
procedure ensure_selected_clip_pairs_match; // 234c
procedure add_any_line_shape(line_ends:Tlinepex); // 237b utility
//______________________________________________________________________________
implementation
{$BOOLEVAL ON}
{$R *.lfm}
uses
ShellAPI, Math, Clipbrd, control_room, grid_unit, colour_unit, help_sheet, chat_unit, alert_unit, keep_select,
entry_sheet, math_unit, wait_message, image_viewer_unit, export_unit, xml_unit, // 227a
map_loader_unit, action_unit, map_clarity_unit,
brick_unit;
//______________________________________________________________________________
const
bgs_help1_str:string=' `0Background Shapes`9'
+'||These simple background drawing functions allow the addition to the track plan of such features as baseboard edges and joint lines,'
+' or other fixed obstructions such as a control panel space or turntable well.'
+'||Simple outline drawings of buildings and structures such as a signal box or goods shed can also be added,'
+' but to create more detailed and colourful layout drawings of structures and scenic features, see instead the `0sketchboard`3 function.'
+'||In addition to the geometrical background shapes, a "picture shape" is a rectangle which can contain an image, map or drawing.'
+'||Scanned images of maps, published track plans, hand-drawn sketches and tracings can in this way be used as a background guide to your track design.'
+'||Alternatively, Templot can obtain prototype maps directly from the internet and scale them automatically to match your model scale. Click the `0maps`1 menu for more details.'
+'||In addition, scanned images of printed track templates, rail-rubbings or even scanned items of actual trackwork can be displayed full-size and'
+' incorporated into your track plan.'
+'||Please remember that scanning published material may require the permission of the copyright owner.'
+'||You can also add short labels to identify different parts of the drawing. "Short" means not more than 46 characters. If you want to'
+' make detailed notes about the drawing you can enter these in the `0memo`3 text for each template.'
+'||It is also possible to add target mark shapes (small cross-hairs symbols) to the drawing as alignment and reference markers.'
+'||rp.gif These background shapes will not actually appear on the trackpad unless the `0TRACKPAD > TRACKPAD BACKGROUND OPTIONS > SHOW BACKGROUND SHAPES`1 menu is selected.'
+'||rp.gif Background shapes can be quickly toggled on and off by pressing the `0SHIFT+HOME`2 keys on the keyboard. This is very useful when working over picture shapes.'
+'||Your collection of background shapes and labels can be saved (in a BGS3 file) and reloaded again whenever needed.'
+' It is saved separately from your track template data files (BOX files), so that you can easily re-use the baseboard outlines with different track plans.'
+'||Shapes and labels can be created in several different ways:||';
add_options_help_str:string='green_panel_begin tree.gif Before adding shapes you may want to zoom out on the trackpad enough to see where you want to place the shape, clear of the dialog window.green_panel_end'
+'| `0Adding Background Shapes`9'
+'||First select the type of background shape in the lists on the `0NEW SHAPE`1 tab, and the required appearance. For a label shape, enter the required text in the box. For other shapes you can enter an optional name for the shape.'
+'||After selecting a `0picture shape`3, the option buttons will change. Click the `0ADD PICTURE SHAPE`1 button and follow the dialogs which appear.'
+'||For all other shapes, you have 3 options when adding the new shape:'
+'||1. `0by drawing`1 After selecting this option, click the `0add shape`1 button. You can then draw on the trackpad with the mouse or pen to create the new shape.'
+'||If you are drawing `0line`1 shapes, you can draw as many lines as needed. To finish drawing lines click the `0STOP drawing lines`z button, or press the `0ESC`2 key on the keyboard.'
+'||For all other shapes drag a rectangle to contain it.'
+'||2. `0by entering dimensions`1 After selecting this option, click the `0add shape`1 button. You can then enter the required dimensions for the shape.'
+'||3. `0at the clicked locations`1 If this option is selected, you must first click two locations on the trackpad <u>before</u> clicking the `0add shape`1 button.'
+' The new shape will be created between these two locations when you click the button.'
+'||If you make a mistake in clicking locations, you can keep clicking new ones. Only the final two clicked locations will be used.'
+'||If you wish you can click locations on the trackpad before going to this background shapes dialog. By this means you can zoom and pan the trackpad as needed to create large shapes accurately.'
+' However such clicked locations will not be visible on the trackpad until the shape is created.'
+'||green_panel_begin tree.gif Any background shape can be adjusted for size and position after it has been added. Click the `0modify shape`1 tab to do that.green_panel_end'
+'|green_panel_begin tree.gif The shapes are drawn on the trackpad in the order shown in the list, and later ones in the list will obscure earlier ones.'
+'||You can re-arrange the order later by clicking the brown up-down buttons which appear alongside the list when there is more than one shape listed. The buttons repeat if held down.'
+'||The shapes will always be overdrawn by any overlapping part of the track drawing.'
+'||rp.gif When a shape is clicked in the list, it is temporarily drawn in front of all the others and outlined in red. It returns to its place in the order when you use the brown up-down buttons.green_panel_end';
inv_shape_help:string=' Invalid Shape Data'
+'||Make sure when entering shapes that the data is valid.'
+'||For a LINE :'
+'|If X1 = X2 , the line will be vertical.'
+'|If Y1 = Y2 , the line will be horizontal.'
+'|But if X1 = X2 AND Y1 = Y2 the line will have zero length and cannot be drawn.'
+'||For a RECTANGLE or CIRCLE or PICTURE :'
+'|If X1 = X2 OR Y1 = Y2 the shape will have zero width or zero height and cannot be drawn.';
x_str:string=' X Dimensions'
+'||X dimensions are measured across the screen from the left, and read on the bottom grid scale.'
+'||Dimensions measured forwards to the right from the origin (0 mark) are positive; dimensions measured backwards to the left from the origin are negative.'
+'||The figures which appear here initially represent the most recently clicked location(s) on the trackpad. If you want your shape or label to be at this location, just press the ENTER key for each dimension.'
+'||Note that unless you use conversion factors the dimension should be entered in mm. To avoid confusion, set the grid spacing in mm before adding background shapes (click the GENERAL OPTIONS tab > GRID... button).'
+'||For more information about using conversion factors click the ? HELP button.';
y_str:string=' Y Dimensions'
+'||Y dimensions are measured up the screen from the bottom, and read on the left grid scale.'
+'||Dimensions measured upwards from the origin (0 mark) are positive; dimensions measured downwards from the origin are negative.'
+'||The figures which appear here initially represent the most recently clicked location(s) on the trackpad. If you want your shape or label to be at this location, just press the ENTER key for each dimension.'
+'||Note that unless you use conversion factors the dimension should be entered in mm. To avoid confusion, set the grid spacing in mm before adding background shapes (click the GENERAL OPTIONS tab > GRID... button).'
+'||For more information about using conversion factors click the ? HELP button.';
w_str:string=' Width Dimensions'
+'||Width dimensions are measured across the screen, representing the distance between the left and right edges of the background shape.'
+'||Width dimensions are always positive. Negative or zero width dimensions are invalid.'
+'||The figures which appear here initially represent the current width of the selected background shape, or the suggested width for a new background shape.'
+'||For a new picture shape, you can enter an approximate width initially or leave the suggested width. There are subsequent functions to scale a picture shape to the exact size required after the image has been loaded into it.';
get_str:string=' Data for Background Shapes'
+'||Shapes are defined by entering the X,Y co-ordinate dimensions for 2 separate points as follows:'
+'||For a LINE, enter the dimensions to the 2 end points of the line, (X1,Y1) and (X2,Y2).'
+'||For a RECTANGLE, enter the dimensions to the bottom-left corner (X1,Y1) and the top-right corner (X2,Y2).'
+'||For a CIRCLE, enter the dimensions to the bottom-left corner (X1,Y1) and the top-right corner (X2,Y2) of an imaginary enclosing rectangle. If this enclosing rectangle is not a square,'
+' (with all sides of equal length), the circle will become an ellipse.'
+'||( When exported in DXF file format, an ellipse will be "averaged" to a circle. There are few elliptical features on a model railway.)'
+'||For a LABEL, enter the dimensions to the top-left corner (X,Y).'
+'||For a TARGET MARK, enter the dimensions to the centre (X,Y), and the length (each way) of the horizontal and vertical arms.'
+'||For a PICTURE SHAPE enter the requested dimensions according to the source of the image.'
+'||Note that unless you use conversion factors all dimensions should be entered in mm. To avoid confusion, set the grid spacing in mm before adding background shapes (click the GRID... button).'
+'||For more information about using conversion factors click the ? HELP button.'
+'||Handy Hint :'
+'||The figures which appear initially represent the most recently clicked location(s) on the trackpad. If you want your shape or label to be at this location, just press the ENTER key for each dimension.'
+'||An easier way to do this is simply to click the ADD CLICKED SHAPE button.'
+' Click the two ends or opposite corners of the required location first.'
+' For a LABEL, just click the top-left corner. For a TARGET MARK, click the centre location.'
+'||If you request a pre-set dimension by entering a slash "/" the relevant dimension will be taken from the positions of the most recent copies of the spacing-ring tool.'
+' This is useful if you need a shape which is a specified distance from the rails, for example. Set the size of the ring accordingly.'
+'||If there are insufficient ring copies the current spacing-ring position will be used instead.'
+' It is not necessary to request the pre-set for all four dimensions, any figures entered will be used instead, which might be useful occasionally.'
+'||Select the UTILS > DUMMY VEHICLE SPACING-RING menu item and click the ? HELP button for more information about using the spacing-ring and making ring copies.';
twist_help_str:string=' Twist Bitmap Image'
+'||This function will twist (rotate) the bitmap image contained in a picture shape.'
+'||There are 4 options for the rotation centre point around which the image will be twisted:'
+'||a) the centre of the picture shape.'
+'|b) the zero origin of the trackpad grid.'
+'|c) the current position of the notch.'
+'|d) the current position of the spacing-ring tool.'
+'||These options are selected in the `0PICTURE OPTIONS tab > TWIST SELECT PICTURE AROUND:`1 panel and the `0MODIFY ALL tab > ROTATE ALL AROUND:`1 panel.'
+'||If necessary the picture shape outline will be enlarged to accommodate the twisted image. The `0crop/combine`3 function can be used to reduce its size subsequently.'
+'||If you need to re-position the picture shape subsequently - click the `0MODIFY SHAPE tab > SHIFT BY...`1 button or the `0MODIFY SHAPE tab > MOUSE ACTIONS: > SHIFT`1 button.'
+'||Remember to save a new BGS3 data file containing the new positions of the picture shape outlines and the new image.'
+'||The primary purpose of this twist function for bitmap images is to align the sections of scanned maps and track plans which cannot be scanned in one piece, the angle of twist needed in each case being relatively small.'
+'||If you know the exact twist angle required, this can be entered directly.'
+'||Usually the angle is not known. In this case you can add "marker lines" to the trackpad which Templot will use to calculate the required twist angle.'
+' This is what to do to align two bitmap images:'
+'||1. Scan the sections with plenty of overlap, so that there is some chosen feature which appears on both of them.'
+'||2. Create picture shapes to contain the images and load the image files into them. Click the `0HELP`1 menu items for more information about how to do this.'
+'||If images overlap, remember that picture shapes are displayed in the order listed. When a new shape is added to the list it is inserted immediately below the one currently selected in the list.'
+' In this way you can arrange the images to overlap in the desired order.'
+'||3. It is usually helpful to display one of the images transparently. Select it in the list and then tick the MODIFY SHAPE tab > PICTURE SHAPE IMAGE : > TRANSPARENT tickbox.'
+' You may need to set a lighter trackpad "paper" colour for this to be effective.'
+'||4. Using any of the normal LINE SHAPE functions add a marker line along the chosen feature on the image which is to remain fixed (DRAW WITH MOUSE or click the end points and then ADD CLICKED SHAPE button).'
+' The marker line can be adjusted in the usual way using the MODIFY SHAPE tab > MOUSE ACTIONS: > CORNER 1 and CORNER 2 mouse actions.'
+'||5. Make sure this marker line is shown selected in the list, and then click the MODIFY SHAPE tab > PICTURE SHAPE IMAGE :: > MARKER LINE - FIXED button.'
+'||6. Repeat the process to mark the same chosen feature on the image which is to be twisted. Then click the MODIFY SHAPE tab > PICTURE SHAPE IMAGE :: > MARKER LINE - TWIST button.'
+'||7. Click to select the picture shape which is to be twisted in the list.'
+'||8. Click the MODIFY SHAPE tab > PICTURE SHAPE IMAGE : > TWIST... button. Choose the USE MARKER LINES option (and make a note of the calculated angle between them which is shown).'
+'||For a large image, this process may take several minutes to complete. The picture shape outline will be enlarged to accommodate the twisted image.'
+'||9. You will now need to re-position the twisted picture shape to bring the chosen feature into alignment with the fixed image - click the MODIFY SHAPE tab > MOUSE ACTIONS: > SHIFT button.'
+' It may be helpful to add additional marker lines over the fixed image to aid alignment.'
+'||If you do not set a FIXED marker line, Templot will assume a horizontal one, or use the current angle of the pegging notch if the PICTURE OPTIONS tab > TWIST USING NOTCH-ANGLE AS FIXED-MARKER tickbox is ticked.'
+' This is useful if you have already aligned track to an existing picture shape, and wish to align another picture shape to that track.'
+' You must set a TWIST marker line on the image to be twisted.'
+'||Handy Hints:'
+'|Twisting images makes great demands on your system''s memory and resources. Don''t have more picture shapes on the trackpad than you need, and keep image files as small as possible.'
+' There is seldom any need to scan at resolutions greater than 300 dpi.'
+'||If lengthy disk drive activity takes place - please be patient, remember that you have to align your images only once. If you experience problems, quit Templot, free up some disk space by deleting unwanted files,'
+' restart Templot and try again. If problems persist, restart Templot and do not use this function.'
+'||If your system fails to twist the bitmap image here in Templot, you may have other graphics software which is able to do it when Templot is not running.'
+' If you have made a note of the calculated angle between the marker lines, you can enter the angle in that software. It may be necessary to change the sign of the angle (to the opposite direction).'
+' The twisted bitmap file can then be reloaded into a new picture shape.'
+'||When drawing marker lines on zoomed-in images, it can be helpful to use wider lines - click the FONTS / COLOURS tab > TRACKPAD SHAPES LINE WIDTH options.'
+'||If you can bear to do it, it is very useful to draw a thin straight line in pencil down the full length of your original track plan before scanning it in sections, as a guide for the marker lines.'
+'||Every time an image is twisted, the enclosing picture shape outline is enlarged by the addition of blank triangles in the corners. If the same image is repeatedly twisted, it will soon become very large.'
+' If a twist is not successful it is better to delete the picture shape, and then reload the original image into a new one for another try.'
+' The colour used for the corner triangles can be set by clicking the `0options > twisted picture corner colour...`1 menu item. The default colour is white.'
+'||When you have successfully twisted a bitmap image to the correct angle, the `0crop/combine`3 function can be used to reduce its size.'
+'||If the FONTS / COLOURS tab > TRACKPAD SHAPES LINE WIDTH option is set to 1, any border lines are entirely within the image area, not around the outside of it.'
+' This means that when aligning two images side-by-side with the mouse action, the border lines should also be side-by-side, not overlapping.'
+' (If the line width is set to more than 1, the border lines should overlap by half the additional width.)'
+' When aligning images it may be helpful to de-select the borders (PICTURE SHAPES tab).'
+'||N.B. Please bear in mind that Templot is not fully-fledged graphics imaging software - this "bare-bones" twist function is intended primarily to permit the alignment of scanned track plans.'
+' Some degradation of the image quality is inevitable if twist angles exceed a few degrees.';
var
cursor_saved:TCursor;
form_scaling:boolean=False; // flag - otherwise ScrollInView on resize prevents form rescaling properly.
bgs_save_hide:boolean=False;
user_save_shapes_path:string=''; // 0.93.a ...
user_load_shapes_path:string='';
user_save_img_path:string='';
user_load_img_path:string='';
target_arm:extended=10.0; // default arm length on the target marks (10mm each way).
circle_dia:extended=250; // default circle diameter 250mm.
input_factor:extended=1.0;
dxf_file:TextFile; // for import
code_str:string='';
value_str:string='';
comma_dp:boolean=False; // 0.94.a True = system is using comma as decimal point
shape_count:integer=0;
his_dxf_file_name:string='';
input_scale_factor:extended=1.0;
input_shift_x:extended=0;
input_shift_y:extended=0;
xmax:extended=1000; // default drawing limits.
ymax:extended=1000;
xmin:extended=-25;
ymin:extended=-25;
marker_angle_fixed:extended=0;
marker_angle_twist:extended=0;
marker_angle_twist_is_defined:boolean=False;
count_limit:integer=32000; // max number of loaded shapes allowed (leaving 768 spaces for additional drawing).
procedure bgfile_error(str:string);forward;
procedure import_dxf;forward;
function reload_picture_image(scanning,pasting,meta,dropped,adjust_aspect:boolean):boolean;forward;
procedure twist_picture(i:integer; krot:extended; do_container,all,sync:boolean);forward; // rotate bitmap supplied krot clockwise.
function any_bricks:integer;forward; // 234b
function any_current_brick:integer;forward; // 234d
//_______________________________________________________________________________________
procedure normalize_line(var p1,p2:Tpex); //214a
// adjust line ends p1,p2, so that p1.x is left of p2.x
var
temp:extended;
begin
if p2.x<p1.x // make sure p2 end is on right.
then begin
temp:=p1.x;
p1.x:=p2.x;
p2.x:=temp;
temp:=p1.y;
p1.y:=p2.y;
p2.y:=temp;
end;
end;
//______________________________________________________________________________
procedure normalize_rectangle(var p1,p2:Tpex); //214a
// adjust rectangle corners p1,p2, so that p1 is bottom-left, p2 is top-right
var
in_p1,in_p2:Tpex;
begin
in_p1:=p1;
in_p2:=p2;