(* This file is part of Templot1, a computer program for the design of model railway track. Copyright (C) 2018, 2021 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 227d *) unit export_unit; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls, ExtDlgs; type Texport_form = class(TForm) include_groupbox: TGroupBox; export_all_radiobutton: TRadioButton; export_group_only_radiobutton: TRadioButton; export_control_template_radiobutton: TRadioButton; pdf_groupbox: TGroupBox; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; pdf_long_mm_edit: TEdit; pdf_short_mm_edit: TEdit; pdf_dpi_edit: TEdit; create_pdf_button: TButton; pdf_help_button: TButton; Label9: TLabel; image_groupbox: TGroupBox; export_metafile_groupbox: TGroupBox; emf_dpi_label: TLabel; dpi_label: TLabel; wmf_radiobutton: TRadioButton; emf_radiobutton: TRadioButton; metafile_dpi_edit: TEdit; create_metafile_button: TButton; metafiles_help_button: TButton; png_groupbox: TGroupBox; image_width_edit: TEdit; create_image_file_button: TButton; png_help_button: TButton; help_button: TButton; Label14: TLabel; save_static_label: TStaticText; datestamp_label: TLabel; dxf_groupbox: TGroupBox; Label2: TLabel; export_dxf_button: TButton; Label15: TLabel; sketchboard_static_label: TStaticText; style_groupbox: TGroupBox; Label17: TLabel; transparent_gif_checkbox: TCheckBox; blue_corner_panel: TPanel; size_updown: TUpDown; hide_panel: TPanel; hide_button: TButton; Shape1: TShape; Label18: TLabel; boundary_groupbox: TGroupBox; fit_all_radiobutton: TRadioButton; use_current_rectangle_radiobutton: TRadioButton; save_emf_dialog: TSavePictureDialog; image_rectangle_groupbox: TGroupBox; draw_export_rectangle_button: TButton; rectangle_clear_button: TButton; dummy_button: TButton; pdf_end_run_radiobutton: TRadioButton; pdf_side_run_radiobutton: TRadioButton; rectangle_set_button: TButton; save_imagefile_dialog: TSavePictureDialog; export_include_grid_checkbox: TCheckBox; export_include_grid_labels_checkbox: TCheckBox; export_include_picture_shapes_checkbox: TCheckBox; fit_shapes_radiobutton: TRadioButton; export_colour_radiobutton: TRadioButton; export_grey_radiobutton: TRadioButton; export_black_radiobutton: TRadioButton; Label10: TLabel; Label1: TLabel; Label11: TLabel; export_include_picture_borders_checkbox: TCheckBox; pdf_size_inside_trim_margins_checkbox: TCheckBox; export_track_background_checkbox: TCheckBox; img_bgnd_colour_panel: TPanel; img_bgnd_button: TButton; Label12: TLabel; Label13: TLabel; procedure save_static_labelClick(Sender: TObject); procedure sketchboard_static_labelClick(Sender: TObject); procedure size_updownClick(Sender: TObject; Button: TUDBtnType); procedure FormResize(Sender: TObject); procedure FormCreate(Sender: TObject); procedure hide_panelClick(Sender: TObject); procedure export_dxf_buttonClick(Sender: TObject); procedure create_pdf_buttonClick(Sender: TObject); procedure create_metafile_buttonClick(Sender: TObject); procedure draw_export_rectangle_buttonClick(Sender: TObject); procedure rectangle_clear_buttonClick(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure create_image_file_buttonClick(Sender: TObject); procedure rectangle_set_buttonClick(Sender: TObject); procedure export_include_grid_checkboxClick(Sender: TObject); procedure FormActivate(Sender: TObject); procedure png_help_buttonClick(Sender: TObject); procedure export_include_picture_shapes_checkboxClick(Sender: TObject); procedure img_bgnd_buttonClick(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } public { Public declarations } end; var export_form: Texport_form; export_form_was_showing:boolean=False; output_rectangle_x1:extended=0; // export image rectangle mm... output_rectangle_y1:extended=0; output_rectangle_x2:extended=1200; // arbitrary default 1200mm x 600mm (4ft x 2ft) output_rectangle_y2:extended=600; output_rectangle_width:extended=1200; output_rectangle_height:extended=600; his_image_file_name:string=''; his_emf_file_name:string=''; export_black_white:boolean=False; export_grey_shade:boolean=False; metafile_stream:TMemoryStream; // 226e metafile_rect_str:string=''; emf_streamed:boolean=False; procedure set_boundary_rectangle_dims(calling_form:TForm); implementation uses ShellAPI, control_room, pad_unit, keep_select, math_unit, preview_unit, entry_sheet, help_sheet, dtp_unit, dtp_settings_unit, alert_unit, grid_unit, pdf_unit, print_settings_unit,colour_unit, Jpeg, GIFImage, PNGImage, bgnd_unit, dxf_unit, image_viewer_unit; {$R *.DFM} var no_onresize:boolean=False; //______________________________________________________________________________ procedure Texport_form.save_static_labelClick(Sender: TObject); begin pad_form.pad_save_all_menu_entry.Click; end; //______________________________________________________________________________ procedure Texport_form.sketchboard_static_labelClick(Sender: TObject); begin pad_form.sketchboard_button.Click; end; //______________________________________________________________________________ procedure Texport_form.size_updownClick(Sender:TObject; Button:TUDBtnType); begin no_onresize:=True; // don't permit on-resize until finished. if size_updown.Position>size_updown.Tag // ! position goes up, size goes down. then ScaleBy(9,10); // scale the form contents down. if size_updown.Position4; if i=5 then EXIT; pad_form.output_detail_mode_menu_entry.Click; end; if export_control_template_radiobutton.Checked=False then begin if any_bgnd<1 then begin alert_no_bgnd; EXIT; // no background templates end; end; if export_group_only_radiobutton.Checked=True then begin if any_selected=0 then begin if alert_no_group=True // alert him, and does he want all? then EXIT; end; end; if sb_check_valid_float(metafile_dpi_edit,50,4800,box_value)=False // input limits 50dpi to 4800dpi then begin ShowMessage('Error: The DPI setting must be a valid number in the range 50 to 4800.'); EXIT; end; try metafile_dpi:=box_value; except ShowMessage('Invalid data for metafile DPI'); // ??? should have been found in sb_check_valid_ earlier EXIT; end;//try if wmf_radiobutton.Checked=True then begin i:=alert(7,' WMF file format', 'You have selected the WMF file format which is an old Windows 16-bit metafile image format.' +'||WMF images are limited to low-resolution 1600 x 1600 dots and may not display properly in versions of Windows later than Windows XP.' +'||Create a WMF file only if you need it for legacy applications. Otherwise use EMF format instead.', '','','','change to EMF format','cancel','continue - create WMF metafile',0); if i=4 then emf_radiobutton.Checked:=True; if i=5 then EXIT; end; // 226e ... i:=alert(4,' metafile destination ?', 'Do you want to save the metafile in memory (for use on the sketchboard, or in background picture shapes).||Or export it to a file ?', '','','','save in memory','cancel metafile','export to a file',0); if i=5 then EXIT; emf_streaming:=(i=4); export_black_white:=export_black_radiobutton.Checked; export_grey_shade:=export_grey_radiobutton.Checked; print_entire_pad_flag:= NOT export_control_template_radiobutton.Checked; print_group_only_flag:=export_group_only_radiobutton.Checked; save_print_pages_top_origin:=print_pages_top_origin; save_print_pages_left_origin:=print_pages_left_origin; save_out_factor:=out_factor; out_factor:=1.0; // always 100% for image files // get boundary rectangle... if fit_all_radiobutton.Checked=True then begin emf_extents:=get_fit_all_templates_size_mm(export_control_template_radiobutton.Checked,print_entire_pad_flag,print_group_only_flag); print_pages_top_origin:=0-10*scale; // mm 10ft scale margin print_pages_left_origin:=0-10*scale; img_width_mm:=emf_extents.x+20*scale; // 2 10ft margins img_height_mm:=emf_extents.y+20*scale; end else begin if fit_shapes_radiobutton.Checked=True // extent of background shapes then begin shape_extents:=get_fit_all_shapes_size_mm(False,True); // True = ignore any shapes hidden on output print_pages_top_origin:=shape_extents.min.x-10*scale; // 10ft scale margin print_pages_left_origin:=shape_extents.min.y-10*scale; img_width_mm:=shape_extents.max.x-shape_extents.min.x+20*scale; // 2 10ft margins img_height_mm:=shape_extents.max.y-shape_extents.min.y+20*scale; end else begin // drawn image boundary rectangle if output_rectangle_x1'' then InitialDir:=ExtractFilePath(his_emf_file_name) else InitialDir:=exe_str+'EMF-FILES\'; if wmf_radiobutton.Checked=True then begin FileName:=file_name_str+'.wmf'; DefaultExt:='wmf'; Filter:='WMF metafile ( .wmf)|*.wmf'; Title:=' create WMF metafile ...'; end else begin FileName:=file_name_str+'.emf'; DefaultExt:='emf'; Filter:='EMF metafile ( .emf)|*.emf'; Title:=' create EMF metafile ...'; end; if Execute=False then EXIT; his_emf_file_name:=FileName; // so we can use the same folder next time. emf_radiobutton.Checked:=(LowerCase(ExtractFileExt(FileName))='.emf'); // 0.95.a did he change the extension... ? wmf_radiobutton.Checked:=(LowerCase(ExtractFileExt(FileName))='.wmf'); // invalid entered chars removed by dialog file_str:=ExtractFilePath(FileName)+lower_case_filename(ExtractFileName(FileName)); // to underscores and lower case end;//with end; Screen.Cursor:=crHourGlass; // needed for large images or slow systems metafile_width:=Round(img_width_mm*metafile_dpi/25.4); // dots metafile_height:=Round(img_height_mm*metafile_dpi/25.4); if wmf_radiobutton.Checked=True then begin wmf_factor1:=1.0; // init wmf_factor2:=1.0; if metafile_width>1600 then begin wmf_factor1:=1600/metafile_width; // (no zero div, it's over 1600) metafile_width:=Round(metafile_width*wmf_factor1); metafile_height:=Round(metafile_height*wmf_factor1); end; if metafile_height>1600 // still too big? then begin wmf_factor2:=1600/metafile_height; // (no zero div, it's over 1600) metafile_width:=Round(metafile_width*wmf_factor2); metafile_height:=Round(metafile_height*wmf_factor2); end; metafile_dpi:=metafile_dpi*wmf_factor1*wmf_factor2; // reduce dpi accordingly end; emf_metafile:=TMetafile.Create; emf_metafile.Width:=metafile_width; // dots emf_metafile.Height:=metafile_height; emf_metafile.Enhanced:= emf_radiobutton.Checked; // emf or wmf format // generate the metafile data... try try if emf_streaming=True then source_str:='streamed from memory' else source_str:=file_str; created_by_str:='Templot '+round_str(program_version/100,2)+version_build+' '+FormatDateTime('hh:mm dd/mm/yyyy',Date+Time); description_str:='source: '+source_str +#13+'templates '+Trim(keep_form.box_file_label.Caption) +#13+'export rectangle (mm):' +#13+'X1= '+round_str(print_pages_top_origin/x_distortion_factor,2) +#13+'Y1= '+round_str(print_pages_left_origin/y_distortion_factor,2) +#13+'X2= '+round_str((print_pages_top_origin+img_width_mm)/x_distortion_factor,2) +#13+'Y2= '+round_str((print_pages_left_origin+img_height_mm)/y_distortion_factor,2) +#13+'X-scaling= '+round_str(x_distortion_factor*100,2)+' %' +#13+'Y-scaling= '+round_str(y_distortion_factor*100,2)+' %'; emf_canvas:=TMetaFileCanvas.CreateWithComment(emf_metafile,pad_form.Canvas.Handle,created_by_str,description_str); // 227a sb_draw(emf_canvas,metafile_width,metafile_height,4); // 4= create metafile emf_canvas.Free; // creates the metafile record when the metafile canvas is freed. if emf_streaming=True // 226e wanted in memory then begin emf_streamed:=False; // init metafile_stream.Position:=0; emf_metafile.SaveToStream(metafile_stream); emf_streamed:=True; metafile_rect_str:=description_str; // 227a save description data in memory too show_modal_message('The metafile was successfully created,'+#13+'and saved in memory.'+#13+#13+'From grid rectangle (mm):'+#13+metafile_rect_str); end else begin emf_metafile.SaveToFile(file_str); if alert(2,' metafile created', ' |The metafile was successfully created:||'+file_str+'| ', '','','','open the containing folder','','continue',0)=4 then begin folder_str:=ExtractFilePath(file_str); if ShellExecute(0,'explore',PChar(folder_str),nil,nil,SW_SHOWNORMAL)<=32 then ShowMessage('Sorry, unable to open the folder.') else external_window_showing:=True; end; end; except show_modal_message('Sorry, an error occurred in creating the metafile.'); end;//try finally emf_metafile.Free; end;//try // restore for user print_pages_top_origin:=save_print_pages_top_origin; print_pages_left_origin:=save_print_pages_left_origin; out_factor:=save_out_factor; Screen.Cursor:=crDefault; end; //______________________________________________________________________________ procedure Texport_form.draw_export_rectangle_buttonClick(Sender: TObject); begin use_current_rectangle_radiobutton.Checked:=True; Close; // while drawing rectangle export_form_was_showing:=True; pad_form.draw_boundary_rectangle_menu_entry.Click; end; //______________________________________________________________________________ procedure Texport_form.rectangle_clear_buttonClick(Sender: TObject); begin if use_current_rectangle_radiobutton.Checked=True then fit_all_radiobutton.Checked:=True; // no rectangle to use. pad_form.clear_boundary_rectangle_menu_entry.Click; end; //______________________________________________________________________________ procedure Texport_form.FormKeyDown(Sender:TObject; var Key:Word; Shift:TShiftState); begin if Key=VK_RETURN // exit from edit boxes then begin dummy_button.SetFocus; Key:=VK_SPACE; end; if Key=VK_PAUSE then Application.Minimize; // hide TEMPLOT on PAUSE key. end; //______________________________________________________________________________ procedure Texport_form.create_image_file_buttonClick(Sender: TObject); var image_extents:Tpex; // mm shape_extents:Textents; // mm create_bitmap:TBitmap; create_jpg:TJpegImage; create_gif:TGIFImage; create_png:TPNGObject; folder_str:string; file_name_str:string; // name part file_str:string; // including path save_print_pages_top_origin:extended; save_print_pages_left_origin:extended; save_out_factor:extended; i:integer; img_width_mm:extended; img_height_mm:extended; box_value:integer; // 205e ... file_x1_str,file_y1_str,file_x2_str,file_y2_str:string; // 227a rectangle in file name 1/100ths mm begin if fit_shapes_radiobutton.Checked=True // extent of background shapes then begin if bgnd_form.bgnd_shapes_listbox.Items.Count<1 then begin alert(6,' fit image boundary to background shapes', 'Fit image boundary to background shapes.' +'||No background shapes are currently defined.', '','','','','cancel','',0); EXIT; end; end; if (use_current_rectangle_radiobutton.Checked=True) and (draw_export_rectangle_flag=False) then begin alert(6,'php/210 create image file from boundary rectangle', 'Create image file from boundary rectangle.' +'||There is not currently an image rectangle on the trackpad to mark the image file boundary.' +'||Click the `0DRAW NEW RECTANGLE`1 button to create one.' +'||Or alternatively select the `0FIT ALL TEMPLATES`1 option instead.', '','','','','cancel','',0); EXIT; end; if (export_control_template_radiobutton.Checked=True) and (output_diagram_mode=True) then begin repeat i:=alert(2,'php/220 export control template', '||The output is currently set for diagram mode.' +'||The control template can not be output in diagram mode.' +'||Diagram mode is intended for background templates only, to display a track plan.| ', '','','','? output mode - help','cancel','change to detail mode and continue',4); if i=4 then alert_help(-300,output_mode_help_str,''); until i<>4; if i=5 then EXIT; pad_form.output_detail_mode_menu_entry.Click; end; if export_control_template_radiobutton.Checked=False then begin if any_bgnd<1 then begin alert_no_bgnd; EXIT; // no background templates end; end; if export_group_only_radiobutton.Checked=True then begin if any_selected=0 then begin if alert_no_group=True // alert him, and does he want all? then EXIT; end; end; if sb_check_valid_int(image_width_edit,60,12000,box_value)=False // input limits 60 dots to 12000 dots (20" @ 600dpi) then begin ShowMessage('Error: The image width setting must be a valid whole number in the range 60 dots to 12000 dots.'); EXIT; end; if (output_diagram_mode=False) and (confirm_detail_mode_1_msg_pref=False) then begin alert_box.preferences_checkbox.Checked:=False; //%%%% alert_box.preferences_checkbox.Show; i:=alert(3,'php/230 create an image file ...', 'Templot is currently set for detail-mode output. This mode is intended for track construction templates.' +'||For an image file you may prefer to change to diagram-mode output, which is more suitable for track plan illustrations, signal box diagrams, control panels, and similar purposes.' +'||You can change the setting, with some additional options, by clicking the `0OUTPUT > OUTPUT MODE OPTIONS >`1 menu items.|| ', '','','','change to diagram mode','cancel','continue - create image file in detail mode ...',0); confirm_detail_mode_1_msg_pref:=alert_box.preferences_checkbox.Checked; //%%%% alert_box.preferences_checkbox.Hide; if i=4 then pad_form.output_diagram_mode_menu_entry.Click; if i=5 then EXIT; end; if (output_diagram_mode=False) and (confirm_detail_mode_2_msg_pref=False) then begin alert_box.preferences_checkbox.Checked:=False; alert_box.preferences_checkbox.Show; i:=alert(7,'php/230 create an image file in detail mode ...', 'Image files in detail mode can be used to illustrate your track plan but should not be used as track construction templates.' +' They are difficult to print to an exact size and unlikely to be sufficiently accurate.' +'||To create track construction templates you can do any of these instead:' +'||1. print them directly from Templot.' +'||2. create a PDF file, and print it using a PDF Reader program with page scaling set to "none" (important).' +'||3. export a DXF file and print it via a CAD program.| ', '','','','','cancel','continue - create image file in detail mode ...',0); confirm_detail_mode_2_msg_pref:=alert_box.preferences_checkbox.Checked; //%%%% alert_box.preferences_checkbox.Hide; if i=5 then EXIT; end; try create_image_width_dots:=box_value; except ShowMessage('Invalid data for image width.'); // ??? should have been found in sb_check_valid_ earlier EXIT; end;//try export_black_white:=export_black_radiobutton.Checked; export_grey_shade:=export_grey_radiobutton.Checked; print_entire_pad_flag:= NOT export_control_template_radiobutton.Checked; print_group_only_flag:=export_group_only_radiobutton.Checked; if (classic_templot=False) and (print_entire_pad_flag=True) then store_and_background(False,True); // 0.93.a Quick mode - first store existing control template save_print_pages_top_origin:=print_pages_top_origin; save_print_pages_left_origin:=print_pages_left_origin; save_out_factor:=out_factor; out_factor:=1.0; // always 100% for image files // output rectangle ... if fit_all_radiobutton.Checked=True then begin image_extents:=get_fit_all_templates_size_mm(export_control_template_radiobutton.Checked, print_entire_pad_flag, print_group_only_flag); print_pages_top_origin:=0-10*scale; // mm 10ft scale margin print_pages_left_origin:=0-10*scale; img_width_mm:=image_extents.x+20*scale; // 2 10ft margins img_height_mm:=image_extents.y+20*scale; end else begin if fit_shapes_radiobutton.Checked=True // extent of background shapes then begin shape_extents:=get_fit_all_shapes_size_mm(False,True); // True = ignore any shapes hidden on output print_pages_top_origin:=shape_extents.min.x-10*scale; // 10ft scale margin print_pages_left_origin:=shape_extents.min.y-10*scale; img_width_mm:=shape_extents.max.x-shape_extents.min.x+20*scale; // 2 10ft margins img_height_mm:=shape_extents.max.y-shape_extents.min.y+20*scale; end else begin // drawn image boundary rectangle if output_rectangle_x1'' then InitialDir:=ExtractFilePath(his_image_file_name) else InitialDir:=exe_str+'IMAGE-FILES\'; if transparent_gif_checkbox.Checked=True then begin DefaultExt:='gif'; FileName:=file_name_str+'.gif'; FilterIndex:=2; end else begin DefaultExt:='png'; FileName:=file_name_str+'.png'; FilterIndex:=1; end; if Execute=False then EXIT; his_image_file_name:=FileName; // so we can use the same folder next time. // invalid entered chars removed by dialog file_str:=ExtractFilePath(FileName)+lower_case_filename(ExtractFileName(FileName)); // to underscores and lower case end;//with Screen.Cursor:=crHourGlass; // needed for large images or slow systems create_image_dpi:=create_image_width_dots*25.4/img_width_mm; create_image_height_dots:=Round(create_image_width_dots*img_height_mm/img_width_mm); create_bitmap:=TBitmap.Create; create_jpg:=TJpegImage.Create; create_gif:=TGIFImage.Create; create_png:=TPNGObject.Create; try create_bitmap.Width:=create_image_width_dots; create_bitmap.Height:=create_image_height_dots; try // draw templates on a bitmap, output_code 1=sketchbook bitmap, 2=sketchbook metafile, 3=create image file bitmap, 4=create EMF metafile sb_draw(create_bitmap.Canvas,create_image_width_dots,create_image_height_dots,3); if (LowerCase(ExtractFileExt(file_str))='.jpg') or (LowerCase(ExtractFileExt(file_str))='.jpeg') then begin create_jpg.Assign(create_bitmap); create_jpg.CompressionQuality:=jpg_quality; // global on control_room create_jpg.JPEGNeeded; create_jpg.SaveToFile(file_str); end; if LowerCase(ExtractFileExt(file_str))='.gif' then begin create_bitmap.TransparentColor:=clWhite; create_bitmap.Transparent:=transparent_gif_checkbox.Checked; create_gif.Assign(create_bitmap); create_gif.SaveToFile(file_str); end; if LowerCase(ExtractFileExt(file_str))='.png' then begin create_png.Assign(create_bitmap); create_png.SaveToFile(file_str); end; if LowerCase(ExtractFileExt(file_str))='.bmp' then create_bitmap.SaveToFile(file_str); repeat i:=alert(2,' image file created', 'The image file was created successfully:||`0'+file_str+'`f' +'||Click view image in Templot to see it.', '','view image in Templot','view image in your usual image viewer','open the containing folder','','continue',0); if i=2 then show_an_image_file(file_str); if i=3 then begin folder_str:=file_str; if ShellExecute(0,'open',PChar(folder_str),nil,nil,SW_SHOWNORMAL)<=32 then ShowMessage('Sorry, unable to display the image.') else external_window_showing:=True; end; if i=4 then begin folder_str:=ExtractFilePath(file_str); if ShellExecute(0,'explore',PChar(folder_str),nil,nil,SW_SHOWNORMAL)<=32 then ShowMessage('Sorry, unable to open the folder.') else external_window_showing:=True; end; until ((i<>2) or (FileExists(file_str)=False)); // may be deleted in image viewer except ShowMessage('Sorry, an error occurred in creating the image file.'); end;//try finally create_gif.Free; create_png.Free; create_jpg.Free; create_bitmap.Free; end;//try // restore for user print_pages_top_origin:=save_print_pages_top_origin; print_pages_left_origin:=save_print_pages_left_origin; out_factor:=save_out_factor; Screen.Cursor:=crDefault; end; //______________________________________________________________________________ procedure set_boundary_rectangle_dims(calling_form:TForm); const x_str:string=' `0X dimensions`9' +'||Enter the X dimension to a corner of the desired image boundary rectangle.' +'||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.' +'||Note that unless you use conversion factors the dimension should be entered in `0mm`3. To avoid confusion, set the grid spacing in mm (click the `0trackpad > trackpad grid options >`1 menu items).' +'||For more information about using conversion factors click the|`0? HELP`1 button.'; y_str:string=' `0Y dimensions`9' +'||Enter the Y dimension to a corner of the desired image boundary rectangle.' +'||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.' +'||Note that unless you use conversion factors the dimension should be entered in `0mm`3. To avoid confusion, set the grid spacing in mm (click the `0trackpad > trackpad grid options >`1 menu items).' +'||For more information about using conversion factors click the|`0? HELP`1 button.'; var i:integer; od:Toutdim; begin putdim(x_str,1, 'image rectangle first corner dimension X1',output_rectangle_x1,False,True,False,False); // neg ok, no preset, allow zero, don't terminate on zero. putdim(y_str,1, 'image rectangle first corner dimension Y1',output_rectangle_y1,False,True,False,False); // ditto. putdim(x_str,1,'image rectangle opposite corner dimension X2',output_rectangle_x2,False,True,False,False); // ditto. i:=putdim(y_str,1,'image rectangle opposite corner dimension Y2',output_rectangle_y2,False,True,False,False); // ditto. if i<>3 then EXIT; if getdims('image boundary rectangle','',calling_form,i,od)=True then begin output_rectangle_x1:=od[0]; output_rectangle_y1:=od[1]; output_rectangle_x2:=od[2]; output_rectangle_y2:=od[3]; draw_export_rectangle_flag:=True; // available for calcs redraw(True); end; end; //______________________________________________________________________________ procedure Texport_form.rectangle_set_buttonClick(Sender:TObject); begin set_boundary_rectangle_dims(export_form); end; //______________________________________________________________________________ procedure Texport_form.export_include_grid_checkboxClick(Sender: TObject); begin export_include_grid_labels_checkbox.Enabled:=export_include_grid_checkbox.Checked; end; //______________________________________________________________________________ procedure Texport_form.FormActivate(Sender: TObject); begin if draw_export_rectangle_flag=True then use_current_rectangle_radiobutton.Checked:=True; print_now_bang:=False; end; //______________________________________________________________________________ procedure Texport_form.png_help_buttonClick(Sender: TObject); const img_help_str:string=' `0Exporting Image Files`9' +'||Please export image files in PNG format rather than JPG format.' +'||green_panel_begin tree.gif PNG format will create a smaller file size with 100% image quality.' +'||JPG format is unsuitable for computer-generated graphics such as Templot templates. The JPG format is intended only for photographic images from a camera or a scanner.' +'||If you prefer to use JPG format, you can change the setting for file size and image quality by clicking the `0set JPG image quality`z button below.green_panel_end'; begin if help(0,img_help_str,'set JPG image quality')=1 then control_room_form.jpg_menu_entry.Click; end; //______________________________________________________________________________ procedure Texport_form.export_include_picture_shapes_checkboxClick(Sender:TObject); begin export_include_picture_borders_checkbox.Enabled:=export_include_picture_shapes_checkbox.Checked; end; //______________________________________________________________________________ procedure Texport_form.img_bgnd_buttonClick(Sender: TObject); begin img_bgnd_colour_panel.Color:=get_colour('choose a background colour for the image',img_bgnd_colour_panel.Color); end; //______________________________________________________________________________ procedure Texport_form.FormDestroy(Sender: TObject); begin metafile_stream.Free; // 226e end; //______________________________________________________________________________ end.