-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmint_unit.pas
More file actions
385 lines (278 loc) · 13.7 KB
/
mint_unit.pas
File metadata and controls
385 lines (278 loc) · 13.7 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
(*
================================================================================
This file is part of OpenTemplot2024, a computer program for the design of model railway track.
Copyright (C) 2024 Martin Wynne. email: martin@85a.uk
This program is free software: you may redistribute it and/or modify
it under the terms of the GNU General Public Licence as published by
the Free Software Foundation, either version 3 of the Licence, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public Licence for more details.
You should have received a copy of the GNU General Public Licence
along with this program. See the file: licence.txt
Or if not, refer to the web site: https://www.gnu.org/licenses/
================================================================================
This file was saved from Delphi5
This file was derived from Templot2 version 244e
*)
unit mint_unit;
{$MODE Delphi}
{$ALIGN OFF}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, ComCtrls, Htmlview, Grids, Outline, HtmlGlobals;
type
{ Tmint_form }
Tmint_form = class(TForm)
size_groupbox: TGroupBox;
curving_groupbox: TGroupBox;
left_hand_radio_button: TRadioButton;
right_hand_radio_button: TRadioButton;
posrad_radio_button: TRadioButton;
negrad_radio_button: TRadioButton;
radius_combo: TComboBox;
blue_corner_panel: TPanel;
size_updown: TUpDown;
colour_panel: TPanel;
colour_patch: TImage;
datestamp_label: TLabel;
ok_panel: TPanel;
ok_button: TButton;
turnout_combo: TComboBox;
cancel_panel: TPanel;
cancel_button: TButton;
rad_label: TLabel;
model_rad_label: TLabel;
joggled_rails_checkbox: TCheckBox;
help_button: TButton;
try_button: TButton;
plain_track_button: TButton;
straight_button: TButton;
mint_html_view: THTMLViewer;
mint_current_button: TButton;
zoom_fit_button: TButton;
reset_button: TButton;
draw_instead_button: TButton;
Shape1: TShape;
chairing_checkbox: TCheckBox;
procedure HotSpotClick(Sender: TObject; const SRC: ThtString; var Handled: Boolean);
procedure size_updownClick(Sender: TObject; Button: TUDBtnType);
procedure colour_panelClick(Sender: TObject);
procedure cancel_panelClick(Sender: TObject);
procedure ok_panelClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure radius_comboChange(Sender: TObject);
procedure FormKeyDown(Sender:TObject; var Key:Word; Shift:TShiftState);
procedure FormCreate(Sender: TObject);
procedure help_buttonClick(Sender: TObject);
procedure plain_track_buttonClick(Sender: TObject);
procedure straight_buttonClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure zoom_fit_buttonClick(Sender: TObject);
procedure try_buttonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
mint_form: Tmint_form;
//------------------------
function quick_set_radius(var radius:extended):boolean;
//____________________________________________________________________________________________
implementation
{$BOOLEVAL ON}
uses
pad_unit, colour_unit, help_sheet, math_unit, control_room, StyleUn;
{$R *.lfm}
const
radii:array[0..13] of integer = (0,200,250,300,400,500,600,750,1000,1500,2000,330,660,1320);
//__________________________________________________________________________________________
procedure Tmint_form.colour_panelClick(Sender: TObject);
begin
Color:=get_colour('choose a new colour for the mint template dialog',Color);
end;
//_________________________________________________________________________________________
procedure Tmint_form.size_updownClick(Sender: TObject; Button: TUDBtnType);
begin
if size_updown.Position>size_updown.Tag // ! position goes up, size goes down.
then ScaleBy(9,10); // scale the form contents down.
if size_updown.Position<size_updown.Tag
then ScaleBy(10,9); // scale the form contents up.
ClientHeight:=VertScrollBar.Range; // allow 4 pixel right margin.
ClientWidth:=HorzScrollBar.Range+4; // don't need bottom margin - datestamp label provides this.
ClientHeight:=VertScrollBar.Range; // do this twice, as each affects the other.
size_updown.Tag:=size_updown.Position; // and save for the next click.
end;
procedure Tmint_form.HotSpotClick(Sender: TObject; const SRC: ThtString; var Handled: Boolean);
begin
do_html_hotspot(SRC);
end;
//___________________________________________________________________________________________
procedure Tmint_form.help_buttonClick(Sender: TObject);
const
mint_str:string=' `0New Template Quick - Set Panel`9'
+'||Use the controls on this panel to set a new mint control template matching the most common UK-pattern bullhead turnout sizes.'
+'||For an explanation of what is meant by the control template, please click <A HREF="go_to_templot_explained.85a">Templot Explained</A> .'
+'||A `0mint`3 template is a new control template with the following settings:'
+'|| small_bullet regular-pattern V-crossing'
+'| small_bullet auto-fit V-crossing-entry straight'
+'| small_bullet normal length turnout road'
+'| small_bullet no approach track'
+'| small_bullet 2 sleepers of exit track'
+'| small_bullet no slewing or transition curving'
+'| small_bullet no blanking'
+'| small_bullet no gaunt turnout'
+'| small_bullet rails on'
+'| small_bullet timbering on'
+'| small_bullet no shoved timbers'
+'| small_bullet no bonus timbers'
+'| small_bullet no timber randomizing'
+'| small_bullet normal plain-track rail joints'
+'| small_bullet fixing peg in the CTRL-0 reset position'
+'| small_bullet normal centre-lines'
+'| small_bullet no template name'
+'| small_bullet memo notes cleared'
+'|| small_bullet A plain track template will be set to 2 chains (132ft) scale length.'
+'|| small_bullet If an REA switch size is current, any customizing of the V-crossing will be cancelled and returned to the pre-set REA bullhead dimensions.'
+'|| small_bullet If the existing control template is a half-diamond, it will be converted to a turnout template. It can be converted back to a half-diamond by clicking the `0TEMPLATE > CONVERT TURNOUT TO HALF-DIAMOND`1 menu item.'
+'||If the `0MINT FROM CURRENT`1 button is clicked, other settings remain unchanged from your previous control template.'
+'||Otherwise use the option buttons and drop-down lists to select the new turnout size and curving radius for the control template.'
+'||The turnout sizes shown are based on the REA-pattern* switches (A,B,C, etc.) which are familiar to UK modellers from published pointwork plans and commercially available components.'
+' You can choose to have the stock rails joggled for straight-cut switch planing by ticking the `0JOGGLED STOCK RAILS`1 option box.'
+'||Setting a `0positive`3 radius causes the main road to curve in the same direction as the hand. A `0negative`3 radius curves in the opposite direction (Y-turnout).'
+' The radii shown in the list are full-size prototype dimensions. The equivalent model radius at your current scale is shown above it.'
+'||When you click `0OK`z the new control template will appear in the centre of the trackpad, ready for you to print (`0F11`2), adjust as required, or incorporate into your background track plan drawing.'
+'||If the existing control template is on the datum (green dot), the new template will also be located on the datum and the trackpad view will zoom in or out as necessary to just fit the new template.'
+'||Otherwise the zoom settings will remain unchanged.'
+'||tree.gif `0handy hints:`4'
+'||A much wider range of settings, including flat-bottom, loose-heel, and GWR-pattern switches, and different types of V-crossing, is available by clicking the'
+'||`0TEMPLATE > SWITCH SETTINGS...`1'
+'|`0template > V-crossing settings...`z'
+'|`0GEOMETRY > RADIUS AND CURVING DATA...`1'
+'||and other menu items, or the corresponding links on this panel.'
+'||If plain track is set, the above turnout settings will apply if the `0TEMPLATE > INSERT TURNOUT IN PLAIN TRACK`1 menu item is clicked subsequently.'
+'||* `0REA - Railway Engineers Association. The REA designs were used for bullhead renewals on all non-GWR and non-BR(W) lines from about 1925 on. Earlier designs remained in use for many years and can be set by clicking the above menu items.`7';
var
str:string;
begin
str:=StringReplace(mint_str,'tree.gif','<img src="'+exe_str+'internal\hlp\tree_symbol.gif">',[rfReplaceAll,rfIgnoreCase]);
help(0,str,'');
end;
//_____________________________________________________________________________________________
procedure Tmint_form.cancel_panelClick(Sender: TObject);
begin
ModalResult:=mrCancel;
end;
//________________________________________________________________________________________
procedure Tmint_form.ok_panelClick(Sender: TObject);
begin
ModalResult:=mrOk;
end;
//__________________________________________________________________________________________
procedure update_model_radius;
var
i:integer;
begin
with mint_form do begin
i:=radius_combo.ItemIndex;
case i of
0: model_rad_label.Caption:='straight';
1..13: model_rad_label.Caption:=round_str(radii[i]*scale,0)+' mm ( '+round_str(radii[i]*scale/25.4,1)+' ins )';
else model_rad_label.Caption:=''; // ?? 0..13 hard-coded for array and combo-box.
end;//case
end;//with
end;
//________________________________________________________________________________
procedure Tmint_form.FormActivate(Sender: TObject);
begin
update_model_radius;
end;
//_____________________________________________________________________________________
procedure Tmint_form.radius_comboChange(Sender: TObject);
begin
update_model_radius;
end;
//_____________________________________________________________________________________
function quick_set_radius(var radius:extended):boolean;
var
rad_index:integer;
rad_sgn:extended;
begin
RESULT:=False; // defaults init..
radius:=0; // straight
rad_index:=mint_form.radius_combo.ItemIndex;
if mint_form.posrad_radio_button.Checked=True then rad_sgn:=1
else rad_sgn:=-1;
case rad_index of
0..13: radius:=radii[rad_index]*scale*rad_sgn;
else EXIT;
end;//case
RESULT:=True;
end;
//_________________________________________________________________________________________
procedure Tmint_form.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key=VK_F10
then begin
Key:=0; // otherwise selects the menus.
end;
if Key=VK_PAUSE then Application.Minimize; // hide TEMPLOT on PAUSE key.
end;
//__________________________________________________________________________________________
procedure Tmint_form.FormCreate(Sender: TObject);
begin
ClientWidth:=682;
ClientHeight:=330;
AutoScroll:=True;
end;
//______________________________________________________________________________
procedure Tmint_form.plain_track_buttonClick(Sender: TObject);
begin
turnout_combo.ItemIndex:=0;
ok_button.SetFocus;
end;
//______________________________________________________________________________
procedure Tmint_form.straight_buttonClick(Sender: TObject);
begin
radius_combo.ItemIndex:=0;
model_rad_label.Caption:='straight';
ok_button.SetFocus;
end;
//______________________________________________________________________________
procedure Tmint_form.FormShow(Sender: TObject);
var
html_str:string;
save_ppi:integer;
begin
html_str:='<TABLE STYLE="font-family:'''+arial_str+'''"><TR><TD STYLE="padding-left:22px; padding-bottom:16px; font-size:13px; color:#000000; line-height:125%;">'
+'Use the quick controls on the right to set a new mint control template which matches the most common UK-pattern bullhead turnout sizes.'
+'<BR><BR>A mint turnout template has no approach track, and 2 sleepers of exit track.</TD></TR>'
+'<TR><TD STYLE="border:solid 1px #C0C0C0; padding:2px 0px 6px 6px; color:#800000; font-size:13px; background-color:#FFF0D0;">'
+'<img src="'+exe_str+'internal\hlp\tree_symbol.gif"> Alternatively, for a much wider range of sizes, including GWR and flat-bottom switches, click:'
+'<SPAN STYLE="font-size:12px; font-weight:bold;"><BR><BR><A HREF="switch_options.85a">switch options</A>'
+' <A HREF="crossing_options.85a">V-crossing options</A>'
+' <A HREF="curving_radius.85a">curving radius</A><BR><BR></SPAN>'
+'In addition Templot can create turnouts of almost any size or prototype using the custom settings.'
+'</TD><TD> </TD></TR></TABLE>';
mint_html_view.LoadFromString(html_str);
//load_string_to_htmlviewer(html_str, mint_form.mint_html_view);
end;
//______________________________________________________________________________
procedure Tmint_form.zoom_fit_buttonClick(Sender: TObject);
begin
pad_form.fit_current_only_menu_entry.Click;
zoom_fit_button.Enabled:=False;
ok_button.SetFocus;
end;
//______________________________________________________________________________
procedure Tmint_form.try_buttonClick(Sender: TObject);
begin
zoom_fit_button.Enabled:=True;
mint_current_button.Enabled:=False;
end;
//______________________________________________________________________________
end.