Author Information
The author is a Hungarian chemist, Ferenc Nagy , who moved from writing computer applications in chemistry to programming database manipulation programs and other applications. He has already contributed some programs to wiki.visual-prolog . His other published example are on this branch of his homepage.
Email: nagy.frank@citromail.hu


Ackowledgement
The author thanks the advices and explanations got from Thomas Linder Puls and Paul Cerkez, members of the Visual Prolog Support team mailed privately or using the Discussion Forum .


Goal of The Program
The TestDraw program is a standalone graphical program separating the task of the experiments with the colors, drawing modes and sizes rectangles for labels, scales and useful plot area. The program is suitable for the design of plots consisting of one or two overlayed sets of results which can be displayed as closed polygons and their diagonals, or unclose branched polylines, whose edges and vertices are labeled. The program has such a built-in database of the background and foreground routes where distinct and overlaid edges and vertices are present.
Labeled and scaled plot | Oversimplified plot

The settings selected by the user describing the properties of the figures are saved for future usage for TestDraw program itself or future programs which use the data structure of the settings.
The complete test plots and the windows explaining the drawing operations can be saved also for later inspection.

Special features of the program
1. The settings are not edited using a grid but they are displayed in small tiled forms .
2. The edges of message window of the program are located using absolute and relative displacement measured from the corresponding edges of the task window of the program.
3. The location of the message window determines the area reserved for the small tiled forms and the plain test figures.
4. The program has a complete help system. Each menu item and form is described in its proper separate help topic .
5. The program can make figures from input files created by external programs obeying the restrictions of the structure of sample data described in the topic Layout and Elements of the Drawn Samples .


Programming Environment
The development of TestDraw program was started under Microsoft Windows XP operation system in programming language Visual Prolog ( Version 7.3, Personal Edition) in 2013. IT was finished and upgraded to Version 7.4, Personal Edition under Windows 7 in 2014. The documentation was made by the VAHELP Help Maker of Vizacc (Version VII).


User Interface
The program can be handled by
1. its Task Menu appearing on the top of its task window,
2. by the buttons and menus of the Project Toolbar below the Task Menu,
3. using hot keys ,
4. reading the files containing the Saved Settings .


Menu System
The menu system of the program consists of the
· the static Task Menu and
· the dynamic Window Menu .
Their commands can be reached shortcuts using
1. some Hot Keys and the
2. the Project Toolbar .


Task Menu
The following figures show the layout of the File submenu

and the tree of the other branches of the static Task Menu.


Window Menu
The opened forms and drawing are dynamically attached to this menu.
.....

Another screenshot:


Hot Keys
Bare function keys
f1,Help,Local,
f3,Test,Plain Figure
f4,Test,Display Draw Modes
f9,Help,Hot keys
f10,Test,Save Draw Modes
f11,Help,Input
f12,Help,About

Shift+function keys
f9,Help,Menu System
f11,Help,Search

Control+function keys
f1,Help,Contents

Control+Letters
A,Compose,Areas
D,Compose,Display
E,Compose,Everything
F,Compose,Fonts
G,Options,Test Figures,FiGure Saving
I,Compose,Filter displayed settings
K,Compose,Colors
L,Compose,Locations of the Message Windows
N,File,New
O,File,Open
P,Compose,Pen styles
R,Compose,Are all Read
S,File,Save Partly as ...
T,Options,Tiled Area
Z,Options,Test Figures,SiZe conditions
W,Options,Test Figures,Allow simplificaton
V,Edit,Paste
C,Edit,Copy
X,Edit,Cut

Control+Alt+Letters
A,File,Save All as ...
Shit+Alt+Letters
O,File,Open Indirectly
S,File, Save File Names


Explanations of Individual Menu Items
This chapter contains the explanations of the individual menu items of the Task Menu and the Window Menu . The menu items are ordered as they appear on the screen: main branches from left to right, sub-menus and items from top to bottom. This order matches to the traditional arrangement of the menus but it does not matches to the order of their usage.


File Branch
The File branch of the Task Menu contains the invocations of the textual input output procedures.
The saving of the sample drawings are called from other branches.
It has the following menu items:

· New
· Open Directly
· Open Indirectly
· Save Partly as
· Save All As
· Save File Names
· Exit


Menu Item New
This menu item clears the facts read to the databases of settings statements and all user defined modifications. It need not be called before the first modification of settings. It is mainly used to start a new group of settings after a saved one from clean (default) state.

The message window of the program displays the following sentences after its execution.
Composition settings retracted from the database.
Areas settings retracted from the database.
Font settings retracted from the database.
Style settings retracted from the database.
Location settings retracted from the database.


Menu Item Open Directly
The user can select one or more saved file of setting using the common file selection dialog allowing multiple selection of files. All selected files must have different extensions because the program clears the old facts corresponding the file extensions.
The selected files are checked syntactically as described in the chapter Saved Settings and semantically wether are required facts are present and none of them are repeated.
Stored properties | File masks
Font definitions | *.savf
Locations of the message windows | *.savl
Color compositions | *.savc
Pen styles | *.savs
Areas of the pictures | *.sava

If everything is in order then the following message box is displayed.

If a selected file contains syntax errors the it is shown in a dialog box until the user confirms it and on the message window for a longer time.
Summary of Facts
Is Unicode =    false()     Total=        0,    Unique=        0,
Duplicates=        0,Unexpected=        0,   Missing=       14.
========================================================================
Consulted file rejected.
Style settings retracted from the database.
Style settings tried to read from C:\TestDraw\Exe\erroneous.savs.
*** Error during consulting ***
File »C:\TestDraw\Exe\erroneous.savs« contains invalid terms or garbage characters.
Property     File Name
Style        C:\TestDraw\Exe\erroneous.savs
Message:     Functor is not found in the domain
error code   309
ExtraInfo    "The functor 'k' is not in the domain 'pen_Style::draw_options'. The nearest context is: 'icture\",\"Frame\",\"Lin,Unexpected=        0'"
The less serious errors are shown like this.

The message window contains the detailed results of the validation of the input file. This phase uses the rows of the table shown in the chapter Layout and Elements of the Drawn Results belonging to the property determined by the extension.
Composition settings retracted from the database.
Composition settings tried to read from C:\TestDraw\Exe\duplicate.savc.
Consulting succeeded.
Qualifier   Layer       Part        Element     Property
Unique      Background  Edges       Letters     Composition
Unique      Background  Edges       Lines       Composition
Unique      Background  Identifier  Fields      Composition
Unique      Background  Identifier  Letters     Composition
Unique      Background  Label       Fields      Composition
Unique      Background  Label       Letters     Composition
Unique      Background  Places      Fields      Composition
Unique      Background  Places      Letters     Composition
Unique      Bottom ScaleAxes        Fields      Composition
Unique      Bottom ScaleAxes        Letters     Composition
Unique      Bottom ScaleAxes        Lines       Composition
Unique      Bottom ScaleGrid        Lines       Composition
Unique      Figure      Identifier  Fields      Composition
Unique      Figure      Identifier  Letters     Composition
Unique      Figure      Label       Fields      Composition
Unique      Figure      Label       Letters     Composition
Unique      Foreground  Cut Edges   Lines       Composition
Unique      Foreground  Edges       Fields      Composition
Unique      Foreground  Edges       Letters     Composition
Unique      Foreground  Edges       Lines       Composition
Unique      Foreground  Identifier  Fields      Composition
Unique      Foreground  Identifier  Letters     Composition
Unique      Foreground  Label       Fields      Composition
Unique      Foreground  Label       Letters     Composition
Unique      Foreground  Places      Fields      Composition
Unique      Foreground  Places      Letters     Composition
Unique      Left Scale  Axes        Fields      Composition
Unique      Left Scale  Axes        Letters     Composition
Unique      Left Scale  Axes        Lines       Composition
Unique      Left Scale  Grid        Lines       Composition
Unique      Picture     Canvas      Fields      Composition
Unique      Picture     Frame       Lines       Composition
Unique      Right Scale Axes        Fields      Composition
Unique      Right Scale Axes        Letters     Composition
Unique      Right Scale Axes        Lines       Composition
Unique      Right Scale Grid        Lines       Composition
Unique      Top Scale   Axes        Fields      Composition
Unique      Top Scale   Axes        Letters     Composition
Unique      Top Scale   Axes        Lines       Composition
Unique      Top Scale   Grid        Lines       Composition

Qualifier   Layer       Part        Element     Property
Duplicate   Background  Cut Edges   Lines       Composition
Duplicate   Background  Edges       Fields      Composition

Qualifier   Layer       Part        Element     Property
Missing     Plot        Frame       Lines       Composition

Summary of Facts
Is Unicode =    false()     Total=       44,    Unique=       40,
Duplicates=        2,Unexpected=        0,   Missing=        1.
========================================================================
Consulted file rejected.


Menu Item Open Indirectly
The saved files of settings can be grouped in order to simplify their simultaneous usage.
The indirect files contain only file names. Warning: They are fully qualified ones so if you move the setting files the the paths in corresponding indirect files must be corrected.
The files listed in the chosen indirect file selected files are checked syntactically as described in the chapter Saved Settings and semantically wether are required facts are present and none of them are repeated.

The indirect files look like this example. You can guess the main rules of Structure of Files Generated by The Save and Read By the Consult Statement .

clauses
saved_as("nul").
indirect("Location","D:\\Feri\\TestDraw\\Exe\\1.savl").
indirect("Style","D:\\Feri\\TestDraw\\Exe\\wide left and bottom axes on black bg.savs").
indirect("Composition","D:\\Feri\\TestDraw\\Exe\\opaque top and right scale lines on black bg.savc").
indirect("Areas","D:\\Feri\\TestDraw\\Exe\\1.sava").
indirect("Font","D:\\Feri\\TestDraw\\Exe\\1.savf").

Each listed files are checked as described in the section of the Menu Item Open Directly .


Menu Item Save Partly As
The individual settings must be saved after their modifications by the forms called from the items of the Compose Branch . The invoked common dialog counterparts to that of the menu item Open Directly . This dialog is called automatically in order to save modified settings when then forms of the corresponding compose forms are closed by the Destroy sub-menu of Window Menu.


Menu Item Save All As
All settings can be saved to a group the files sharing the root of the file name and having the proper extensions shown in table of menu item Open Directly . This dialog is called automatically in order to save modified settings at the exit from the program. You have to choose only one file name from the common dialog.


Menu Item Save File Names
The file names of the saved settings can be collected and saved into an indirect file for further usage in the menu item Open Indirectly . This menu item is enabled by the Menu Item "Are All Read" of the Compose branch of the Task Menu.

If a selected file contains syntax errors the it is shown in a dialog box until the user confirms it and on the message window for a longer time.
Summary of Facts
Is Unicode =    false()     Total=        0,    Unique=        0,
Duplicates=        0,Unexpected=        0,   Missing=       14.
========================================================================
Consulted file rejected.
Style settings retracted from the database.
Style settings tried to read from C:\TestDraw\Exe\erroneous.savs.
*** Error during consulting ***
File »C:\TestDraw\Exe\erroneous.savs« contains invalid terms or garbage characters.
Property     File Name
Style        C:\TestDraw\Exe\erroneous.savs
Message:     Functor is not found in the domain
error code   309
ExtraInfo    "The functor 'k' is not in the domain 'pen_Style::draw_options'. The nearest context is: 'icture\",\"Frame\",\"Lin,Unexpected=        0'"
The less serious errors are shown like this.

The message window contains the detailed results of the validation of the input file. This phase uses the rows of the table shown in the chapter Layout and Elements of the Drawn Results belonging to the property determined by the extension.
Composition settings retracted from the database.
Composition settings tried to read from C:\TestDraw\Exe\duplicate.savc.
Consulting succeeded.
Qualifier   Layer       Part        Element     Property
Unique      Background  Edges       Letters     Composition
Unique      Background  Edges       Lines       Composition
Unique      Background  Identifier  Fields      Composition
Unique      Background  Identifier  Letters     Composition
Unique      Background  Label       Fields      Composition
Unique      Background  Label       Letters     Composition
Unique      Background  Places      Fields      Composition
Unique      Background  Places      Letters     Composition
Unique      Bottom ScaleAxes        Fields      Composition
Unique      Bottom ScaleAxes        Letters     Composition
Unique      Bottom ScaleAxes        Lines       Composition
Unique      Bottom ScaleGrid        Lines       Composition
Unique      Figure      Identifier  Fields      Composition
Unique      Figure      Identifier  Letters     Composition
Unique      Figure      Label       Fields      Composition
Unique      Figure      Label       Letters     Composition
Unique      Foreground  Cut Edges   Lines       Composition
Unique      Foreground  Edges       Fields      Composition
Unique      Foreground  Edges       Letters     Composition
Unique      Foreground  Edges       Lines       Composition
Unique      Foreground  Identifier  Fields      Composition
Unique      Foreground  Identifier  Letters     Composition
Unique      Foreground  Label       Fields      Composition
Unique      Foreground  Label       Letters     Composition
Unique      Foreground  Places      Fields      Composition
Unique      Foreground  Places      Letters     Composition
Unique      Left Scale  Axes        Fields      Composition
Unique      Left Scale  Axes        Letters     Composition
Unique      Left Scale  Axes        Lines       Composition
Unique      Left Scale  Grid        Lines       Composition
Unique      Picture     Canvas      Fields      Composition
Unique      Picture     Frame       Lines       Composition
Unique      Right Scale Axes        Fields      Composition
Unique      Right Scale Axes        Letters     Composition
Unique      Right Scale Axes        Lines       Composition
Unique      Right Scale Grid        Lines       Composition
Unique      Top Scale   Axes        Fields      Composition
Unique      Top Scale   Axes        Letters     Composition
Unique      Top Scale   Axes        Lines       Composition
Unique      Top Scale   Grid        Lines       Composition

Qualifier   Layer       Part        Element     Property
Duplicate   Background  Cut Edges   Lines       Composition
Duplicate   Background  Edges       Fields      Composition

Qualifier   Layer       Part        Element     Property
Missing     Plot        Frame       Lines       Composition

Summary of Facts
Is Unicode =    false()     Total=       44,    Unique=       40,
Duplicates=        2,Unexpected=        0,   Missing=        1.
========================================================================
Consulted file rejected.


Options Branch
The menu items of this branch invokes the dialogs where the user can set the appearance of tiled forms of settings and the test figures.

It has the following sub-menus and menu items:

· Test Figures
· Allow Simplification
· Size Conditions
· Figure Saving
· Tiled Area


Menu Item Size Conditions
This menu item is the item of the Test Figures submenu of the Options branch of the Task menu.
It opens the Size conditions form where the user can set the size of the test figure enough big to display detailed drawing containing identifiers, labels, and scales. If the window size is smaller then only the internal plot is shown. There is a built in constant window width and height, respectively in the program when even the displaying of the simplified plot is denied.

Table of validation rules of the above dialog
Mode | Size property | Type | Minimum | Maximum
absolute | width | integer | 100 | 400
relative | width | real | 0.4 | 0.8
absolute | height | integer | 100 | 400
relative | height | real | 0.4 | 0.8


Menu Item Allow Simplification

Menu Item Size Conditions
This menu item is the item of the Test Figures submenu of the Options branch of the Task menu.
It opens the Allow Simplification form where the user can decide when the simplification of the test figures is allowed. The simplification means that only the internal plot is shown. here is a built in constant window width and height, respectively in the program when even the displaying of the simplified plot is denied.

Table of validation rules of the above dialog
Mode | Size property | Type | Minimum | Maximum
absolute | width | integer | 100 | 400
relative | width | real | 0.4 | 0.8
absolute | height | integer | 100 | 400
relative | height | real | 0.4 | 0.8


Menu Item Figure Saving
This menu item is the item of the Test Figures submenu of the Options branch of the Task menu.
It opens the Figure Saving Options form where the user can preset how many states of a test figure window may be saved. The state counter is increased when the test figure itself or its parent window is resized. The figures are saved as bitmap files and have automatically generated name including the
1. date, hour and minute of their creation;
2. part of the window,
3. name of saved settings,
4. performed simplification, counter of plot.

The conversion of this bitmaps to smaller picture formats like gif is recommended.


Menu Item Tiled Area
This menu item is standalone item Options branch of the Task menu. It opens the Tiled Area dialog which serves for limiting the many small tiled composition forms in a restricted rectangle of the task window of the program. The colored rectangle is reserved for the displayed forms. The remaining part of the client area of the task window is reserved for the message window and other windows.

Table of validation rules of the above dialog
Variable | Distance of the … | from the … | Type | Mode | Minimum | Maximum | Relation
l | left edge of the tiled area | left edge of the client area | real | relative | 0 | 1 | l < r
r | right edge of the tiled area |  |  |  |  |
t | top edge of the tiled area | top edge of the client area |  |  |  |  | t < b
b | bottom edge of the tiled area |  |  |  |  |  |


Compose Branch
The Compose branch of the Task Menu contains the invocations dialogs setting the properties of the components of the test figures.The reading and saving of the the settings are called from the File branch .
It has the following menu items:

· Filter displayed settings
· Fonts
· Areas
· Colors
· Pen styles
· Locations of the Message Windows
· Everything
· Display
· Are all Read ?

·


Menu Item Filter Displayed Settings

Menu Item Filer Displayed Settings
The filtering conditions may be switched on and off here or using the button on the left of the "ON" or "OFF" word of the Project Toolbar . When pressed the text changes from "OFF" to "ON" and back. The drop-down menu contains the keywords which must be present in the titles of the displayed property editing forms.


Menu Item Fonts
This menu item displays all font selection forms or the selected ones tiled in the rectangle defined in the menu item Tiled Area of the options branch of the Task Menu. If there are more font selection forms than the capacity of the rectangle then then some of the are hidden below the visible ones but the may be invoked by the Window Menu .

The font selection forms contains special controls and general buttons .
Their titles reflect the status of the entered values.
The following font selection forms can be displayed:
If the filtering is switched on then you can edit only those whose title contains the selected word on the Project Toolbar .
Font of | Letters of | Axes of | Bottom Scale
Font of | Letters of | Axes of | Left Scale
Font of | Letters of | Axes of | Right Scale
Font of | Letters of | Axes of | Top Scale
Font of | Letters of | Edges of | Background
Font of | Letters of | Edges of | Foreground
Font of | Letters of | Identifiers | Background
Font of | Letters of | Identifiers | Figure
Font of | Letters of | Identifiers | Foreground
Font of | Letters of | Labels | Background
Font of | Letters of | Labels | Figure
Font of | Letters of | Labels | Foreground
Font of | Letters of | Places of | Background
Font of | Letters of | Places of | Foreground

The fields of the forms are the grouped into boxes.
The Face group contains the
1. Font Name,
2. Script System Name,
3. Script System Code read only fields.
4. The Select button which invokes the common font selection dialog.
The Style and size group contains
5. Italic,
6. Bold,
7. Underlined check boxes and
8. the integer control Size.
The For sizing group serves for entering the single characters giving the height and width units of the picture areas.
9. The Unicode and
10. Selected font fields are changing simultaneously.
11. The Recommended field is read only but you can copy the requested wide character from here to the above ones.
The Multi-line sample text box must be filled by the sample texts required for the text field given by the title of the dialog
12. The changes in the left field are spreading to the
13. right side at once and back, respectively. Empty lines within the multi-line texts are refused.

The lines of the sample texts for the scales are described in the topic Layout and Elements of the Drawn Samples .

The font dialogs can be closed using the destroy sub-menu of the Window Menu .

The program asks the user whether he/she wants to save the changes into a *.savf file.

If the user chooses the default "Yes" answer the dialog shown in the Menu Item Save Partly is displayed else a message box displayed that the changed settings are abandoned.


Menu Item Areas
This menu item displays a single form sizing the areas of the figures. It is not tiled because it is a large form.
..
This form contains special controls and general buttons .
Its title reflects the status of the entered values.
Only one area form can be displayed:
If the filtering is switched on then you can edit only those whose title contains the selected word on the Project Toolbar .
Areas of
Fields of
Canvas of
Picture
Independent widths relative to the sample character
Rectangle |  | Minimum | Maximum
Identifier |  | 4 | 18
Left | Scale | 0 | 12
Right | Scale | 0 | 12
Point | Label | 0 | 6
Edge | Label | 0 | 12
Independent heights relative to the sample character
Rectangle |  | Minimum | Maximum
Figure | Label | 1 | 2.5
Background | Label | 3 | 5
Foreground | Label | 0 | 5
Top | Scale | 0 | 5
Bottom | Scale | 0 | 5
All values are real numbers. |  |  |

The necessary sizes are asked in the unit of the widths and heights of the sizing characters entered in the proper font dialogs for the rectangles. Zero values mean the the given scales or labels are not displayed.
This dialog has close box and it can be closed using the destroy sub-menu of the Window Menu .

The program asks the user whether he/she wants to save the changes into a *.sava file.


Menu Item Colors
This menu item displays all font selection forms or the selected ones tiled in the rectangle defined in the menu item Tiled Area of the options branch of the Task Menu. If there are more font selection forms than the capacity of the rectangle then then some of the are hidden below the visible ones but the may be invoked by the Window Menu .

The color selection forms contains special controls and general buttons .
Their titles reflect the status of the entered values.
The following color selection forms can be displayed:
Composition | of | Letters | of | Axes | of | Bottom Scale
Composition | of | Lines | of | Axes | of | Bottom Scale
Composition | of | Letters | of | Axes | of | Left Scale
Composition | of | Lines | of | Axes | of | Left Scale
Composition | of | Letters | of | Axes | of | Right Scale
Composition | of | Lines | of | Axes | of | Right Scale
Composition | of | Letters | of | Axes | of | Top Scale
Composition | of | Lines | of | Axes | of | Top Scale
Composition | of | Fields | of | Axes | of | Bottom Scale
Composition | of | Fields | of | Axes | of | Left Scale
Composition | of | Fields | of | Axes | of | Right Scale
Composition | of | Fields | of | Axes | of | Top Scale
Composition | of | Fields | of | Canvas | of | Picture
Composition | of | Lines | of | Cut Edges | of | Background
Composition | of | Lines | of | Cut Edges | of | Foreground
Composition | of | Fields | of | Edges | of | Background
Composition | of | Letters | of | Edges | of | Background
Composition | of | Lines | of | Edges | of | Background
Composition | of | Fields | of | Edges | of | Foreground
Composition | of | Letters | of | Edges | of | Foreground
Composition | of | Lines | of | Edges | of | Foreground
Composition | of | Lines | of | Frame | of | Picture
Composition | of | Lines | of | Frame | of | Plot
Composition | of | Lines | of | Grid | of | Bottom Scale
Composition | of | Lines | of | Grid | of | Left Scale
Composition | of | Lines | of | Grid | of | Right Scale
Composition | of | Lines | of | Grid | of | Top Scale
Composition | of | Fields | of | Identifier | of | Background
Composition | of | Letters | of | Identifier | of | Background
Composition | of | Fields | of | Identifier | of | Figure
Composition | of | Letters | of | Identifier | of | Figure
Composition | of | Fields | of | Identifier | of | Foreground
Composition | of | Letters | of | Identifier | of | Foreground
Composition | of | Fields | of | Label | of | Background
Composition | of | Letters | of | Label | of | Background
Composition | of | Fields | of | Label | of | Figure
Composition | of | Letters | of | Label | of | Figure
Composition | of | Fields | of | Label | of | Foreground
Composition | of | Letters | of | Label | of | Foreground
Composition | of | Fields | of | Places | of | Background
Composition | of | Letters | of | Places | of | Background
Composition | of | Fields | of | Places | of | Foreground
Composition | of | Letters | of | Places | of | Foreground

If the filtering is switched on then you can edit only those whose title contains the selected word on the Project Toolbar .

The special fields of the forms:
1. Radiobutton Transparent - Its checked state means that the corresponding text background field is transparent, plot or scale line is not drawn.
2. Radiobutton Opaque - Its checked state means that the corresponding text background field, plot or scale line is drawn in the given color composition, is not drawn.
3. The Factor field contains an integer power of two in the range between 0 and 7 which is used in all weights below.
4. Red_Weight = non-negative weight of the red color R. R (2P) < 256.
5. Green_Weight = non-negative weight of the green color G. G (2P) < 256.
6. Blue_Weight = non-negative weight of the blue color B. B (2P) < 256.
The font dialogs can be closed using the destroy sub-menu of the Window Menu .

Example
(4, 5, 4, 10) means Red=16×5=80, Green=16×4=64, Blue=16×10=160.

The program asks the user whether he/she wants to save the changes into a *.savc file.

If the user chooses the default "Yes" answer the dialog shown in the Menu Item Save Partly is displayed else a message box displayed that the changed settings are abandoned.


Menu Item Pen Styles
This menu item displays all pen style definitions forms or the selected ones tiled in the rectangle defined in the menu item Tiled Area of the options branch of the Task Menu. If there are more pen style setting forms than the capacity of the rectangle then then some of the are hidden below the visible ones but the may be invoked by the Window Menu .

The pen style definition forms contains special controls and general buttons .
Their titles reflect the status of the entered values.
The following pen style definition forms can be displayed:
Style | of | Lines | of | Axes | of | Bottom Scale
Style | of | Lines | of | Axes | of | Left Scale
Style | of | Lines | of | Axes | of | Right Scale
Style | of | Lines | of | Axes | of | Top Scale
Style | of | Lines | of | Cut Edges | of | Background
Style | of | Lines | of | Cut Edges | of | Foreground
Style | of | Lines | of | Edges | of | Background
Style | of | Lines | of | Edges | of | Foreground
Style | of | Lines | of | Frame | of | Picture
Style | of | Lines | of | Frame | of | Plot
Style | of | Lines | of | Grid | of | Bottom Scale
Style | of | Lines | of | Grid | of | Left Scale
Style | of | Lines | of | Grid | of | Right Scale
Style | of | Lines | of | Grid | of | Top Scale

If the filtering is switched on then you can edit only those whose title contains the selected word on the Project Toolbar .

The special fields of the forms:
1. Line width: integer between 1 and 5 .
2. Line style Î { "Solid", "Dashed", "Dotted", "Dash Dot", "Dash Dot Dot", "Hollow"}.
3. Rule: one of { "Black", "~ (Pen | Screen)", "(~Screen) & Pen)", "~Pen", "(~Pen) & Screen", "~Screen", "Pen ^ Screen", "~ (Pen & Screen)", "Pen & Screen", "~ (Pen ^ Screen)", "Screen", "(~Screen) | Pen)", "Pen", "(~Pen) | Screen)", "Pen | Screen", "White"}. The rules can be tested by the Display Draw Modes item of the Test branch of the Task Menu .
The pen style dialogs can be closed using the destroy sub-menu of the Window Menu .

The program asks the user whether he/she wants to save the changes into a *.savs file.

If the user chooses the default "Yes" answer the dialog shown in the Menu Item Save Partly is displayed else a message box displayed that the changed settings are abandoned.


Menu Item Location of the Message Windows
This menu item displays all forms positioning of the message window of the program or selected ones in cascaded order because the are large forms This kind of forms are large so they are cascaded.

The location definition forms contains special controls and general buttons .
Their titles reflect the status of the entered values.
The following location definition forms can be displayed:
Title |  |  |  |  |  |  | Recommended position
Location | of | Messages | of | Options | of | Settings | Bottom of the Task Window
Location | of | Messages | of | Figures | of | Tests | Right Side of the Task Window
a | α | b | β | c | γ | d | δ
1 | 0 | 1 | 0.75 | 1 | 0 | 1 | 0
5 | 0.75 | 1 | 0 | 3 | 0 | 1 | 0

The location dialogs can be closed using the destroy sub-menu of the Window Menu .
The dialogs have an integer control limiting the maximal number of text lines stored in the buffer of the message window between 500 and 10000 lines.
The dialogs have fields for positioning of the four edges of the message windows. Each edge can have
· a fixed shift from the corresponding edge of the client area of the task window and
· a relative shift as fraction of the width and the height of the message window.
 | absolute integer |  | relative real |
 | minimum | maximum | minimum | maximum
Message lines | 500 | 10000 |  |
Edges |  |  |  |
left | 1 | 900 | 0 | 0.9999
top | 1 | 700 | 0 | 0.9
right | 1 | 900 | 0 | 0.9999
bottom | 1 | 700 | 0 | 0.9

This dialog has an Apply button which changes the size and position of the actual message window according to the current settings. This button show an error message if the font setting have not been read yet.

The program asks the user whether he/she wants to save the changes into a *.savl file.

If the user chooses the default "Yes" answer the dialog shown in the Menu Item Save Partly is displayed else a message box displayed that the changed settings are abandoned.


General Buttons of the Composition of the Settings
The composition dialogs contain the following general buttons appearing all forms handling the setting in the Compose branch .

Button | Explanation
OK | This button invokes the validation procedures and stores internally the settings.
Reset defaults | This button resets the default values for the current form.
Undo | You can get back the values before the last confirmation by the OK button.
Redo | You can redo the undone changes with this button.
Help | This button invokes the proper topic of this help file.

The Undo and Redo buttons are initially disabled.


Status Info Characters in the Window Titles
The titles of the composition forms are extended with the following rear characters.
Character | Status
Đ | The form contains default values.
? | The form contains unconfirmed changes.
* | The changes are confirmed but they are not saved yet.


Menu Item Everything
You can modify all kinds of settings at once. The task window will be overcrowded unless you apply the filters .
The following screen shot shows the forms displayed when "Scale" filter is in effect.


Menu Item Display
This menu item tabulates all settings in effect to the message window. You can select then copy the interesting lines to the clipboard using the pop-up menu invoked by a right click in it.


Menu Item "Are All Read"
This menu item serves for checking the completeness of the read and confirmed settings. Its progress is shown in message boxes and results are written in the message window. This procedure enables the menu item Plain Figure and the menu item Save File Names .

The output of the check is a set of tables in the Message Window for each properties.

Summary of Facts
Is Unicode =    false()     Total=       16,    Unique=       16,
Duplicates=        0,Unexpected=        0,   Missing=        0.
========================================================================
Consulted file accepted.
Qualifier   Layer       Part        Element     Property
Unique      Background  Edges       Letters     Font
Unique      Background  Identifier  Letters     Font
Unique      Background  Label       Letters     Font
Unique      Background  Places      Letters     Font
Unique      Bottom ScaleAxes        Letters     Font
Unique      Figure      Identifier  Letters     Font
Unique      Figure      Label       Letters     Font
Unique      Foreground  Edges       Letters     Font
Unique      Foreground  Identifier  Letters     Font
Unique      Foreground  Label       Letters     Font
Unique      Foreground  Places      Letters     Font
Unique      Left Scale  Axes        Letters     Font
Unique      Right Scale Axes        Letters     Font
Unique      Settings    Options     Messages    Font
Unique      Tests       Figures     Messages    Font
Unique      Top Scale   Axes        Letters     Font

Summary of Facts
Is Unicode =    false()     Total=       16,    Unique=       16,
Duplicates=        0,Unexpected=        0,   Missing=        0.
========================================================================
Read internal database accepted.
Qualifier   Layer       Part        Element     Property
Unique      Picture     Canvas      Fields      Areas

Summary of Facts
Is Unicode =    false()     Total=        1,    Unique=        1,
Duplicates=        0,Unexpected=        0,   Missing=        0.
========================================================================
Read internal database accepted.
Qualifier   Layer       Part        Element     Property
Unique      Background  Cut Edges   Lines       Composition
Unique      Background  Edges       Fields      Composition
Unique      Background  Edges       Letters     Composition
Unique      Background  Edges       Lines       Composition
Unique      Background  Identifier  Fields      Composition
Unique      Background  Identifier  Letters     Composition
Unique      Background  Label       Fields      Composition
Unique      Background  Label       Letters     Composition
Unique      Background  Places      Fields      Composition
Unique      Background  Places      Letters     Composition
Unique      Bottom ScaleAxes        Fields      Composition
Unique      Bottom ScaleAxes        Letters     Composition
Unique      Bottom ScaleAxes        Lines       Composition
Unique      Bottom ScaleGrid        Lines       Composition
Unique      Figure      Identifier  Fields      Composition
Unique      Figure      Identifier  Letters     Composition
Unique      Figure      Label       Fields      Composition
Unique      Figure      Label       Letters     Composition
Unique      Foreground  Cut Edges   Lines       Composition
Unique      Foreground  Edges       Fields      Composition
Unique      Foreground  Edges       Letters     Composition
Unique      Foreground  Edges       Lines       Composition
Unique      Foreground  Identifier  Fields      Composition
Unique      Foreground  Identifier  Letters     Composition
Unique      Foreground  Label       Fields      Composition
Unique      Foreground  Label       Letters     Composition
Unique      Foreground  Places      Fields      Composition
Unique      Foreground  Places      Letters     Composition
Unique      Left Scale  Axes        Fields      Composition
Unique      Left Scale  Axes        Letters     Composition
Unique      Left Scale  Axes        Lines       Composition
Unique      Left Scale  Grid        Lines       Composition
Unique      Picture     Canvas      Fields      Composition
Unique      Picture     Frame       Lines       Composition
Unique      Plot        Frame       Lines       Composition
Unique      Right Scale Axes        Fields      Composition
Unique      Right Scale Axes        Letters     Composition
Unique      Right Scale Axes        Lines       Composition
Unique      Right Scale Grid        Lines       Composition
Unique      Top Scale   Axes        Fields      Composition
Unique      Top Scale   Axes        Letters     Composition
Unique      Top Scale   Axes        Lines       Composition
Unique      Top Scale   Grid        Lines       Composition

Summary of Facts
Is Unicode =    false()     Total=       43,    Unique=       43,
Duplicates=        0,Unexpected=        0,   Missing=        0.
========================================================================
Read internal database accepted.
Qualifier   Layer       Part        Element     Property
Unique      Background  Cut Edges   Lines       Style
Unique      Background  Edges       Lines       Style
Unique      Bottom ScaleAxes        Lines       Style
Unique      Bottom ScaleGrid        Lines       Style
Unique      Foreground  Cut Edges   Lines       Style
Unique      Foreground  Edges       Lines       Style
Unique      Left Scale  Axes        Lines       Style
Unique      Left Scale  Grid        Lines       Style
Unique      Picture     Frame       Lines       Style
Unique      Plot        Frame       Lines       Style
Unique      Right Scale Axes        Lines       Style
Unique      Right Scale Grid        Lines       Style
Unique      Top Scale   Axes        Lines       Style
Unique      Top Scale   Grid        Lines       Style

Summary of Facts
Is Unicode =    false()     Total=       14,    Unique=       14,
Duplicates=        0,Unexpected=        0,   Missing=        0.
========================================================================
Read internal database accepted.
Qualifier   Layer       Part        Element     Property
Unique      Settings    Options     Messages    Location
Unique      Tests       Figures     Messages    Location

Summary of Facts
Is Unicode =    false()     Total=        2,    Unique=        2,
Duplicates=        0,Unexpected=        0,   Missing=        0.
========================================================================
Read internal database accepted.


Test Branch
The Test branch of the Task Menu contains the menu items testing graphical settings.
It has the following menu items:

· Plain Figure
· Display Draw Modes
· Save Draw Modes


Menu Item Display Draw Modes
This menu item displays all pen style definitions forms or the selected ones tiled in the rectangle defined in the menu item Tiled Area of the options branch of the Task Menu. If there are more pen style setting forms than the capacity of the rectangle then then some of the are hidden below the visible ones but the may be invoked by the Window Menu .

The pen style definition forms contains special controls and general buttons .
Their titles reflect the status of the entered values.
The following pen style definition forms can be displayed:
Style | of | Lines | of | Axes | of | Bottom Scale
Style | of | Lines | of | Axes | of | Left Scale
Style | of | Lines | of | Axes | of | Right Scale
Style | of | Lines | of | Axes | of | Top Scale
Style | of | Lines | of | Cut Edges | of | Background
Style | of | Lines | of | Cut Edges | of | Foreground
Style | of | Lines | of | Edges | of | Background
Style | of | Lines | of | Edges | of | Foreground
Style | of | Lines | of | Frame | of | Picture
Style | of | Lines | of | Frame | of | Plot
Style | of | Lines | of | Grid | of | Bottom Scale
Style | of | Lines | of | Grid | of | Left Scale
Style | of | Lines | of | Grid | of | Right Scale
Style | of | Lines | of | Grid | of | Top Scale

If the filtering is switched on then you can edit only those whose title contains the selected word on the Project Toolbar .

The special fields of the forms:
1. Line width: integer between 1 and 5 .
2. Line style Î { "Solid", "Dashed", "Dotted", "Dash Dot", "Dash Dot Dot", "Hollow"}.
3. Rule Î { "Black", "~ (Pen | Screen)", "(~Screen) & Pen)", "~Pen", "(~Pen) & Screen", "~Screen", "Pen ^ Screen", "~ (Pen & Screen)", "Pen & Screen", "~ (Pen ^ Screen)", "Screen", "(~Screen) | Pen)", "Pen", "(~Pen) | Screen)", "Pen | Screen", "White"}. The rules can be tested by the Display Draw Modes item of the Test branch of the Task Menu .
The pen style dialogs can be closed using the destroy sub-menu of the Window Menu .

The program asks the user whether he/she wants to save the changes into a *.savs file.

If the user chooses the default "Yes" answer the dialog shown in the Menu Item Save Partly is displayed else a message box displayed that the changed settings are abandoned.


Menu Item Save Draw Modes
The displayed draw mode windows can be saved to extended metafiles in the same EXE sub-folder as the executable program. The program asks the user whether he/she wants to overwrite the existing *.emf files.


Menu Item Plain Figure
The setting have to be checked bThe setting have to checked by the menu item "Are All Read" of the Compose Branch in order to enable this menu item. The layout and the size of the plain figure depends on the options set in
menu items
· Allow Simplification ,
· Size Conditions .
The figures may be automatically or manually saved as the form displayed in the
· Figure Saving
menu item sets it.

The plotted sample may be built-in or external, read from a file having *.sam extension.

The external files may be selected by the usual file selection dialog (not shown).

The figures may occupy the full task window or its part not used for the message window.

They may contain legends and scales
or may be simplified to show only the routes.

The program decides among the above forms based on the menu items of the Options branch . The saving of the plain figures in done automatically if its menu item Figure Saving allows it. Large bitmap files are saved. The author recommends to convert them to GIF type then delete the big BMP-s.


Special Branches of the Window Menu
See
1. Tiling Items of the Window Menu and
2. Destroying Items of the Window Menu .


Tiling Items of the Window Menu
The Window menu is not the standard one. It is enhanced by explicit item determining the direction of the tiling between the usual Cascade and Arrange menu items.


Destroying Items of the Window Menu
The Window menu is not the standard one. It is extended by window destroying items for each kinds of windows created by the program except the message window which cannot be closed only resized.


Help Branch
The Help branch of the Task menu contains separate menu items for the frequently asked topics of the help system.
It has the following menu items (hot keys shown on the right).

The links to its items are below.
· Contents
· Local
· Search
· Input
· Menu System
· Hot Keys
· About


Menu Item Contents
This menu item displays the default topic and the contents tab of the help file.


Menu Item Local
This menu item displays the help topic for the active form. (Same as its [Help] button invokes.) If the is no active form then explanation of the menu system is shown.


Menu Item Search
This menu item displays a menu of the already sought keywords where the user can select one or enter a new one. The confirmed selection goes into the keyword selection frame of the help file.

The user can modify the selection above. The chosen topic appears finally.


Menu Item Input
This menu item displays the topic Structure of Files Generated by The Save and Read By the Consult Statement .


Menu Item Menu System
This menu item displays the chapter Menu System .


Menu Item Hot Keys
This menu item displays the topics Hot Keys .


Menu Item About
This menu item displays the About Dialog of the Program.


Project Toolbar
This toolbar serves for quick starting of menu items by direct buttons
and for setting filtering conditions
of edited compositions.
The handled Task Menu Items are the following ones:
· File Branch
· New
· Open Directly
· Save Partly
· The Edit Branch is disabled in the current version of the program.
· Undo

· Redo
· Cut to Clipboard
· Copy to Clipboard
· Paste from Clipboard
· Compose branch
· Filter Displayed Settings

· Compose colors
· Define pen styles
· Fonts and sample texts
· Widths and heights of the plot areas
· Help Branch
· Contents

The filtering conditions may be switched on and off using the button on the left of the "OFF" word of the Project Toolbar.
When pressed the text changes from "OFF" to "ON" and back.
The drop-down menu contains the keywords which must be present in the titles of the displayed property editing forms.


Status Line
Brief status information is available in the three read-only text fields of the Status line below the task window.


Structure of Input and Output Files


Structure of Files Generated by the Save and Read by the Consult Statement
The Prolog facts are stored as lines of terms ending with periods. looking like
functor(value,internal_functor,"quoted string value",'char").
The special characters are preceded by a backslash.
clauses
saved_as("nul").
indirect("Font","D:\\Feri\\TestDraw\\Exe\\1.savf").
indirect("Areas","D:\\Feri\\TestDraw\\Exe\\1.sava").
indirect("Composition","D:\\Feri\\TestDraw\\Exe\\opaque top and right scale lines on black bg.savc").
indirect("Style","D:\\Feri\\TestDraw\\Exe\\wide left and bottom axes on black bg.savs").
indirect("Location","D:\\Feri\\TestDraw\\Exe\\1.savl").
clauses
compose(p("Picture","Canvas","Fields","Areas"),a(12,8,8,2,6,2,4,4,3,3)).

They are preceded a
clauses
line.

The elevated versions of Visual Prolog allow user commands
· on the end of line % comment
· encapsulated
/* comment
second line
third line
...
final line */

Ealier versions prohibited the extra whitespaces and newlines between and within terms but the current syntax allows them.


Saved Settings
This chapter describes the structure of the files storing the information of the setting, in general are for each properties.
Contents | Extension
Saved areas | *.sava
Saved color compositions | *.savc
Saved font definitions and sample texts, names, units and value on the scales | *.savf
Saved locations of the message windows | *.savl
Saved pen styles and draw modes | *.savs


General Layout of Saved Settings
The saved setting are identified a purpose term consisting of the compose term having a p functor holding four string fields in parentheses then a special term described the following help topics.
compose(p("Picture","Canvas","Fields","Areas"),a(12,8,8,2,6,2,4,4,3,3)).

Their common part is the purpose term .
Their special part is described in the sub-topics of the special terms .


The Common Purpose Term
The strings of common purpose term are:
Layer
Part
Element
Property

Their possible values are shown in a table of topic Layout and Elements of the Drawn Results .


Layout and Elements of the Settings
The figures have to contain one or two sets of places connected by one or two sets of edges.
The edges may be normal and cut ones.
These are the background places and edges.
The places and edges may be labeled.
Another set, the foreground set may be drawn over the background set.
The plot rectangle has a frame.
The rectangular plot area where the above components are placed may be
surrounded by four scales, namely bottom, left, right and top scales.
Each scale has one name and one unit, and more values.
Grid lines may cross the plot area.

The figures can be identified by short identifier and a long label.
The drawn background and foreground routes have short identifier and long labels too.
The route identifiers and label may spread to more than one lines.
Areas of the Picture Canvas

The above picture shows the relative position of elements of the drawn results.

The following table contains the elements of the drawings whose color, font, and pen styles can be set in the program.
Usage | Layer | Part | Element | Property
On pictures | Picture | Canvas | Fields | Composition
 | Picture | Frame | Lines | Composition
 | Picture | Frame | Lines | Style
 | Figure | Identifier | Fields | Composition
 | Figure | Identifier | Letters | Composition
 | Figure | Identifier | Letters | Font
 | Figure | Label | Fields | Composition
 | Figure | Label | Letters | Composition
 | Figure | Label | Letters | Font
 | Background | Identifier | Fields | Composition
 | Background | Identifier | Letters | Composition
 | Background | Identifier | Letters | Font
 | Background | Label | Fields | Composition
 | Background | Label | Letters | Composition
 | Background | Label | Letters | Font
 | Foreground | Identifier | Fields | Composition
 | Foreground | Identifier | Letters | Composition
 | Foreground | Identifier | Letters | Font
 | Foreground | Label | Fields | Composition
 | Foreground | Label | Letters | Composition
 | Foreground | Label | Letters | Font
 | Background | Cut Edges | Lines | Composition
 | Background | Cut Edges | Lines | Style
 | Background | Edges | Fields | Composition
 | Background | Edges | Letters | Composition
 | Background | Edges | Letters | Font
 | Background | Edges | Lines | Composition
 | Background | Edges | Lines | Style
 | Background | Places | Fields | Composition
 | Background | Places | Letters | Composition
 | Background | Places | Letters | Font
 | Foreground | Cut Edges | Lines | Composition
 | Foreground | Cut Edges | Lines | Style
 | Foreground | Edges | Fields | Composition
 | Foreground | Edges | Letters | Composition
 | Foreground | Edges | Letters | Font
 | Foreground | Edges | Lines | Composition
 | Foreground | Edges | Lines | Style
 | Foreground | Places | Fields | Composition
 | Foreground | Places | Letters | Composition
 | Foreground | Places | Letters | Font
 | Plot | Frame | Fields | Composition
 | Plot | Frame | Lines | Composition
 | Plot | Frame | Lines | Style
 | Left Scale | Axes | Fields | Composition
 | Left Scale | Axes | Letters | Composition
 | Left Scale | Axes | Letters | Font
 | Left Scale | Axes | Lines | Composition
 | Left Scale | Axes | Lines | Style
 | Left Scale | Grid | Lines | Composition
 | Left Scale | Grid | Lines | Style
 | Bottom Scale | Axes | Fields | Composition
 | Bottom Scale | Axes | Letters | Composition
 | Bottom Scale | Axes | Letters | Font
 | Bottom Scale | Axes | Lines | Composition
 | Bottom Scale | Axes | Lines | Style
 | Bottom Scale | Grid | Lines | Composition
 | Bottom Scale | Grid | Lines | Style
 | Right Scale | Axes | Fields | Composition
 | Right Scale | Axes | Letters | Composition
 | Right Scale | Axes | Letters | Font
 | Right Scale | Axes | Lines | Composition
 | Right Scale | Axes | Lines | Style
 | Right Scale | Grid | Lines | Composition
 | Right Scale | Grid | Lines | Style
 | Top Scale | Axes | Fields | Composition
 | Top Scale | Axes | Letters | Composition
 | Top Scale | Axes | Letters | Font
 | Top Scale | Axes | Lines | Composition
 | Top Scale | Axes | Lines | Style
 | Top Scale | Grid | Lines | Composition
 | Top Scale | Grid | Lines | Style
 | Picture | Canvas | Fields | Areas
Around them | Settings | Options | Messages | Location
 | Settings | Options | Messages | Font
 | Tests | Figures | Messages | Location
 | Tests | Figures | Messages | Font


Special Terms within the Saved Settings
The special terms may be
Contents | Functor | Saved in files having extension
Area | a | sava
Color Composition | c | savc
Fonts and Sample Texts | f | savf
Location of the Message Windows | l | savl
Line and Draw Mode | s | savs


Area Terms
The definition of the area term is in the source file ..\Sample\Figure_Areas.i .

areas=a(
        % 2013.11.30. Redefined fields.
      % Independent widths relative to sample character.
      real Identifier_Width,
      real Left_Scale_Width,
      real Right_Scale_Width,
        real Point_Label_Width,
        real Edge_Label_Width,
        % Independent heights relative to sample character.
        real Figure_Label_Height,
        real Background_Label_Height,     % 2013.11.30. Added.
        real Foreground_Label_Height,   % 2013.11.30. Added.
        real Top_Scale_Height,
        real Bottom_Scale_Height
        ).


Color Composition Terms
The definition of the color composition term is in the source file ..\Palette\Compose_Color.i .

domains
    composition=c(boolean Visibility, integer Power, integer Red_Weight, integer Green_Weight, integer Blue_Weight).

The fields of the terms:
1. Visibility - Its false state means that the corresponding text background field is transparent, plot or scale line is not drawn.
2. Power = P is the common integer power of two of the weights in the range between 0 and 7.
3. Red_Weight = non-negative weight of the red color R. R (2P) < 256.
4. Green_Weight = non-negative weight of the green color G. G (2P) < 256.
5. Blue_Weight = non-negative weight of the blue color B. B (2P) < 256.

Example
(4, 5, 4, 10) means Red=16×5=80, Green=16×4=64, Blue=16×10=160.


Fonts and Sample Texts
The definitions of the font and sample text terms are in the source file ..\FontHandler\FontCoder.i .

font_descriptor=f(string FontName, string ScriptSystemName, string Adjectives, positive Size, char SizingChar, string SampleText).

The Adjectives string is a the space-separated list of words selected from the set {"normal","plain", "standing", "underlined", "italic", "bold"}.

The ScriptSystemName is one of the strings defined in the source file FontCoder.pro within the source sub-folder FontHandler. The ScriptSystemName is the name appearint in the common font selection dialog. The following link gives a good list of them.

The Size is the selected font size. The SizingCharacter is the character used for measuring field widths and heights of the areas of the figure .

The SampleText strings appear in the Plain Figures as identifiers, labels or scale names, units, and values, respectively.


Location of the Message Windows
The definitions of the location of the message window terms are in the source file ..\Message_Window_NF\Message_Form_Location_NF.i .

domains
    displacement = d(integer Fixed, rectPlus::between_01 Proportional).
    displacement_list = displacement*.
    location= l (positive Max_Num_Lines, displacement Left, displacement Top, displacement Right, displacement Bottom).

The oldest lines displayed in the message window are lost when the count of written lines are reaches the maximal number of lines Max_Num_Lines.
The edges of the message windows maintain their distances from the corresponding edge of the client area of the task window. Each displacement is given as a sum of a fixed number of pixels and a fraction of the width or the height of the client area of the task window. The fraction has to be in the real range [0.0 .. 1.0].


Line and Draw Mode Terms
The definitions of the line and draw mode terms are in the source file ..\Palette\Pen_Style.i.

domains
    % 2013.10.20. String and numeric pen styles.
    style=s(integer Width, string Type, string Rule).
    style_mode=m(integer Width, penStyle, drawMode).

The Type is one of
    {"Solid",
    "Dashed",
    "Dotted",
    "Dash Dot",
    "Dash Dot Dot",
    "Hollow"}.

Draw Modes |  |  | Truth table |  |  |
Rule | Raster operation |  | (SCREEN; | PEN) | VALUE | PAIRS
In Prolog notation | In Microsoft notation | Friendly definition | (0; 0) | (0; 1) | (1; 0) | (1; 1)
Black | BLACK | 0 | 0 | 0 | 0 | 0
Pen | COPYPEN | PEN | 0 | 1 | 0 | 1
(~Pen) & Screen | MASKNOTPEN | (NOT PEN) AND SCREEN | 0 | 0 | 1 | 0
Pen & Screen | MASKPEN | PEN AND SCREEN | 0 | 0 | 0 | 1
(~Screen) & Pen | MASKPENNOT | PEN AND (NOT SCREEN) | 0 | 1 | 0 | 0
(~Pen) | Screen | MERGENOTPEN | (NOT PEN) OR SCREEN | 1 | 0 | 1 | 1
Pen | Screen | MERGEPEN | SCREEN OR PEN | 0 | 1 | 1 | 1
(~Screen) | Pen) | MERGEPENNOT | (NOT SCREEN) OR PEN | 1 | 1 | 0 | 1
Screen | NOP | SCREEN | 0 | 0 | 1 | 1
~Pen | NOT | NOT PEN | 1 | 0 | 1 | 0
~Screen | NOTCOPYPEN | NOT SCREEN | 1 | 1 | 0 | 0
~ (Pen & Screen) | NOTMASKPEN | NOT(PEN AND SCREEN) | 1 | 1 | 1 | 0
~ (Pen | Screen) | NOTMERGEPEN | NOT (SCREEN OR PEN) | 1 | 0 | 0 | 0
~ (Pen ^ Screen) | NOTXORPEN | NOT (SCREEN XOR PEN) | 1 | 0 | 0 | 1
White | WHITE | 1 | 1 | 1 | 1 | 1
Pen ^ Screen | XORPEN | SCREEN XOR PEN | 0 | 1 | 1 | 0


Layout and Elements of the Drawn Samples
The figures have to contain one or two sets of places connected by one or two sets of edges.
The places may be normal and cut ones: "Edges" and "Cut Edges", respectively.
These are the "Background" places and edges.
The labels of the places are their non-negative [in Prolog syntax having domain positive ] Identifiers.
The two coordinates of the places are real numbers between 0.0 and 1.0.
The labels of the edges are their non-negative [in Prolog syntax having domain positive ] Orders.
The places connected by the edges are identified by the identifiers stored in the Start  and End fields.
Another set, the "Foreground" set may be drawn over the background set.
The drawn sample may be
1) built-in,
2) external.

The fixed built-in sample is the following
domains
between_01 = digits  ::maxFloatDigits [ 0.0..1.0].

facts - sample
    % 2013.10.23. Places of sample routes.
    place:(string Layer, positive Identifier, between_01 X, between_01 Y) nondeterm.

    % 2013.10.23. Edges of sample routes.
    edge:(string Layer, string Part, positive Order, positive Start, positive End) nondeterm.

clauses % 2013.10.23. Places of sample routes.
    place("Background",1,0.05,0.05).
    place("Background",2,0.05,0.65).
    place("Background",3,0.35,0.95).
    place("Background",4,0.65,0.65).
    place("Background",5,0.95,0.65).
    place("Foreground",1,0.05,0.65).
    place("Foreground",2,0.65,0.65).
    place("Foreground",3,0.95,0.35).
    place("Foreground",4,0.65,0.05).
    place("Foreground",5,0.05,0.05).

    % 2013.10.23. Edges of sample routes.
    edge("Background","Edges",1,1,2).
    edge("Background","Edges",2,2,3).
    edge("Background","Edges",5,3,4).
    edge("Background","Edges",6,4,5).
    edge("Background","Edges",7,5,1).
    edge("Background","Cut Edges",3,2,4).
    edge("Background","Cut Edges",4,4,1).
    edge("Foreground","Edges",1,1,2).
    edge("Foreground","Edges",2,2,3).
    edge("Foreground","Edges",5,3,4).
    edge("Foreground","Edges",6,4,5).
    edge("Foreground","Edges",7,5,1).
    edge("Foreground","Cut Edges",3,2,4).
    edge("Foreground","Cut Edges",4,4,1).

Samples read from external files.
The external samples must obey the rules described above.
The coordinates of external samples must be normalized to the rectangle [(0,0);(1,1)] before writing them into *.sam files. The original range of their coordinates must be included in the *.savf files or entered in the font dialogs for the scales in the proper place of the sample texts.
The first line of the sample text is the name of the axis, the second is its unit, the third contains the value mapped to 0 follows, the last is the value mapped to 1. The intermediate ones are mapped to the grid lines, from left to right on the top and down scales, and from down to to on the left and right scales.
See Examples of Valid and Invalid Samples .


Examples of Valid and Invalid Samples

Validity | Filename within the prolgram folder | Illegal term | Message
Valid | drawable.sam | - none - | string::format("The »%« file contains places and edges.",FileName)
Invalid | Illegal X coordinate.sam | place("Background",1, -10.0,0.0). | string::format("File »%« contains invalid terms or garbage characters.")
Valid | no valid edges.sam | edge("X","Edges",1,1,2). edge("Y","Edges",2,2,3). | string::format("The »%« file contains only places.",FileName)
Invalid | no valid places.sam | place("Back",5,0.5,0.5). place("Fore",1,0.05,0.05). | string::format("The »%« file contains only places.",FileName)


Summary of the Programming Tricks
The educational goal of this program is the publication of some programming tricks, namely
· Object Oriented Rectangle Handling ,
· Tiled Arrangement of the Forms in their Original Size ,
· Inherited Handling of the Analogous Buttons of the Forms , Invocation of the Online Help ,
· Extensions of the Standard Window Menu ,
· Enhancements of the Creation and Destruction of the Message Window,
· The Size and Location of the Message Window Follows the Changes of the Task Window .
· Invocation of the Online Help ,


Object Oriented Rectangle Handling
The program contains the class rectPlus which allows object oriented rectangle handling. The source files RectPlus.cl, RectPlus.i, and RectPlus.pro are in the Auxiliary sub-folder of the project.

The instances can be created using three ways.
1. Try to construct enhanced rectangle object from fixed corner point and size. The corner point is an important point of an already existing rectPlus object:
fix:(pnt Fixed, corner, integer Width, integer Height) -> rectPlus determ.
2. Construct enhanced rectangle object from plain rectangle rct(...) as defined in vipDomains:
new:(rct).
3.    Construct enhanced rectangle object from midpoint and size:
mid:(pnt Midpoint, integer Width, integer Height).

The object declares the following domains:
    side_number=positive [0..3].
    line_number= integer [4..9].
    corner=corner(line_number,line_number).
    corner_list=corner*.
    between_01 = digits  ::maxFloatDigits [ 0.0..1.0].

The object has the following properties:
    whole: rct.
    left: integer (o).
    top: integer (o).
    right: integer (o).
    bottom: integer (o).
    width: integer (o).
    height: integer (o).
    vertical_center: integer (o).
    horizontal_center: integer (o).
    midpoint: pnt (o).

The object has the following public predicates:
% Counting basic values
    perimeter:() -> integer procedure.
    area:() -> integer procedure.
    squarity:() -> between_01 procedure.
      squarity()= 4.0*area()/math::sqr(perimeter()).

% Getting individual corner and other main points
   getCornerPnt_det:(corner) -> pnt determ (i).
    getCornerPnt_nd:(corner) -> pnt nondeterm (o).
    getCornerPnt_nd:(corner) -> pnt nondeterm (corner(o,o)).

% Get corner points of a given sid.
    get2SidePointN:(side_number [in], pnt StartPoint [out],
      pnt EndPoint [out]) determ.
    get2SidePointS:(string SideName [in], pnt StartPoint [out],
      pnt EndPoint [out]) determ.

% Get list of corner points.
getCornerPolygon:() ->pntlist determ.

% Get weighed sum of coordinates.
getWeighedSum:(real_list Ratio, corner_list) -> pnt determ.

% Shrink rectangle in a given ratio leaving its midpoint in its original position.
% If the absolute value of ratio is greater than 1.0 then the rectangle is stretched.
shrinkRatio:(real Ratio) -> rct procedure.

% Format main properties
formatMainProperties:() -> string procedure.

% Format area, perimeter and squarity.
formatAreaProperties:() -> string procedure.


Tiled Arrangement of the Forms in their Original Size
The settings of the program are stored in facts containing tens of similar terms. Their handling in large data-entry grids is cumbersome and makes impossible the usage of smart groups and synchronized list boxes. The author decided to display separate instances of the forms for the editing of individual terms of the settings . The native tiling of the windows results hidden or distorted controls, and too small forms. This program leaves the program in their original size and arranges the in the rectangular part of the task window preset in the Menu item Tiled area of the Options branch of the Task Menu.
The procedure reads the widths of the forms subject to tile and moves them in the leftmost column of the preset area below each other. When the last form would loll out from the preset part then it starts a new column on the right of the already placed windows if it is possible. If the preset area is full then a new layer is started over the the existing tiled forms.
1 21 | 5 | 9 | 13 | 17
2 22 | 6 | 10 | 14 | 18
3 | 7 | 11 | 15 | 19
4 | 8 | 12 | 16 | 20

The covered forms can be reached using the Window Menu by their title.

The task is performed by class tile whose source files Tile.cl, TilePlus.i, and TilePlus.pro are in the MyWin sub-folder of the project. The setting of the tiled area of the task window is done by the Tiled_area.frm.
The tile class has two constructors: one based on user defined parameters the other based on preset by the form and read from the class properties.

% Create with preset area.
new1:(window Holder).

% Create with user defined area.
new5:(window Holder,
    % Relative coordinates of the rectangle where the the tiled windows will be arranged
    % expressed in percents of the width and the height of the client area of the holder window.
    real RL, % Left edge.
    real RT, % Top edge.
    real RR, % Right edge.
    real RB). % Bottom edge.

The limits of the bounding rectangle are stored as class properties:
    rl : real. % Left edge.
    rt : real. % Top edge.
    rr : real. % Right edge.
    rb : real. % Bottom edge.

It has only one one public procedure in its interface which moves the given window to the proper position and returns the kind of its found place: fit=below_previous_window;
start_new_column(positive);
restart_at_upper_left_corner(positive).
The other modules can read the state and the free place from the properties defined in the interface like the lower right corner of the last window and the number of overlays.
holder: window. % holder window embedding the small windows.
    whole: vpiDomains::rct. % Original client rectangle of the holder window.
    part: vpiDomains::rct. % Part of holder window embedding the small windows.
    last_outer_pnt: vpiDomains::pnt. % The left bottom corner of the last placed window.
    max_right: integer. % The maximal position of the right edges.
    max_bottom: integer. % The maximal position of the bottom edges.
    column: positive. % The count of columns of small windows.
    overlay: positive. % The count of overlaid layers of small windows.
    counter:positive. % The count of moved windows.


Handling of the Analogous Buttons of the Forms
The forms of the user interface have general buttons of the composition of the settings and other common tasks and the concatenation of the status info characters in the window titles , reading and saving the facts, passing them among the forms fact variables and the global data bases. These handlers are either located in the interfaces of the individual form or inherited from the class collect_Settings.


Enhancements of the Creation and Destruction of the Message Window
The message window creation has extended parameter list
new:(window Parent,
frameDecoration::decoration Buttons, % Buttons on the title bar.
frameDecoration::closeResponder CloseMode,
string Title, font,  boolean RedirectStdio,
location).

· The programs have usually only one message window which must not be closed.
· The omission of the close button from the title bar results a runtime error but the closeResponder may deny the close requests.
· The easiest way to display the messages is the using the redirected standard output.
· The size and location of the message window follows the changes of the task window . It is given by the location parameter.

domains
    displacement = d(integer Fixed, rectPlus::between_01 Proportional).
    displacement_list = displacement*.
    location= l (positive Max_Num_Lines, displacement Left,
       displacement Top, displacement Right, displacement Bottom).

This task is performed by the class message_Form_NF in the sub-folder message_Window_NF.


The Size and Location of the Message Window Follows the Changes of the Task Window
The message windows in the version 7.3 of the Visual Prolog could be stuck to the lower edge of the client area of the task window and only their height could be sized to a fixed pixel value or as a relative vertical size of their parent window.
This program contains the Message_Window_NF.pack which allows
1. to locate the message windows relative to all sides of their parent window and
2. to size them both in horizontal and vertical directions.

Fragment of file Message_Form_Location_NF.i
domains
    displacement = d(integer Fixed, rectPlus::between_01 Proportional).
    displacement_list = displacement*.
    location= l (positive Max_Num_Lines,
      displacement Left, displacement Top,
      displacement Right, displacement Bottom).

constants
    default_location:location= l (1000,
      d(1,0.0), d(1,0.75), d(1,0.0), d(1,0.0)).

The defined absolute and relative positions of the sides of the message windows are set by the procedure setDisplacement:(displacement Left, displacement Top, displacement Right, displacement Bottom) determ (i,i,i,i) defined in Message_Form_NF.i which is called from the implementation of the form Message_Form_Location_NF.frm invoked by its [Apply] button.

The event handlers using the setting are in Message_Form_NF.pro are followParentResize, onParentResize, onUserParentResize, so on.


Invocation of the Online Help
The TestDraw program calls the general module handling the online help files. This program uses the chm type help but the class myhelp in the Help source sub-folder can handle pdf help files, too. The most frequently asked help topics are handled from separate menu items of Help branch of the task window.
·
· Handling of CHM Help Files
· Handling of PDF Help Files


Handling of CHM Help Files
The assumed help file is in in this case in the program folder. Its root is the same as that of the program file. The program cheks needs not only the *.chm file but the *.h files generated by the help compiler.
Type | Current name | Contents
chm | testdraw.chm | Main help text
h | testdraw.h | Numeric and symbolic help topic identifiers
cnt | testdraw.cnt | Contents tree
chw | testdraw.chw | Auxiliary files used by the chm file
css | hm.css

Some numeric help topic identifiers (help context identifiers) are fixed in order to their proper handling the items of the Help branch of the task menu. Others are fixed in order to display the correct topic when the user presses the [Help] button of the forms of Options and the Compose Branch, respectively.

constants % For help
    % The help context identifier must be equal to the identifier of the dialog in the help file.
    context_identifier = 240.
    % The help context identifier must be equal to the identifier of the menu system in the help file.
    menu_system=240.
    hot_keys=250.
    % 2014.01.01. Help->Input
    structure_of_consultable_files=650.

Help context identifiers belonging to forms
  C:\TestDraw\auxiliary\Message_Options.i (1 hit)
      Line 11:     context_identifier = 6000.
  C:\TestDraw\FontHandler\FontSelector.i (1 hit)
      Line 36:     context_identifier = 1000.
  C:\TestDraw\Message_Window_NF\Message_Form_Location_NF.i (1 hit)
      Line 18:     context_identifier = 6000.
  C:\TestDraw\MyWin\Tiled_Area.i (1 hit)
      Line 12:     context_identifier = 5000.
  C:\TestDraw\Palette\Compose_Color.i (1 hit)
      Line 24:     context_identifier = 2000.
  C:\TestDraw\Palette\Pen_Style.i (1 hit)
      Line 29:     context_identifier = 3000.
  C:\TestDraw\Sample\Allow_Simplification.i (1 hit)
      Line 12:     context_identifier = 8000.
  C:\TestDraw\Sample\Figure_Areas.i (1 hit)
      Line 49:     context_identifier = 4000.
  C:\TestDraw\Sample\Figure_Saving_Options.i (1 hit)
      Line 13:     context_identifier = 9000.
  C:\TestDraw\Sample\Simplification.i (1 hit)
      Line 11:     context_identifier = 7000.
  C:\TestDraw\TaskWindow\TaskWindow.i (1 hit)
      Line 12:     context_identifier = 240.

% Menu item resource identifiers
    id_help_contents = 10052.
    id_help_local = 10053.
    id_help_search = 10054.
    id_help_input = 10055.
    id_help_menu_system = 10056.
    id_help_hot_keys = 10057.
    id_help_about = 10058.


Handling of PDF Help Files
The following batch files stored in the folder of the executable program are used to find a keyword in the PDF document, and jump to a page of it, respectively:
openfind.bat,
OPENPAGE.BAT.


Extensions of the Standard Window Menu
The predicates within TaskWindow.pro corresponding the above menu items of the Window Menu are:
  onWindowTileVertically : window::menuItemListener.
    onWindowTileHorizontally : window::menuItemListener.
    onWindowTileBoth : window::menuItemListener.
    onWindowArrange : window::menuItemListener.
    onWindowCascade : window::menuItemListener.
    onWindowDestroyAll : window::menuItemListener.
    % Forms of the same class may be selectively destroyed.
    onWindowDestroyColorForms : window::menuItemListener.
    onWindowDestroyFontForms : window::menuItemListener.
    onWindowDestroyLocationForms : window::menuItemListener.
    onWindowDestroyPenStyleForms : window::menuItemListener.
    onWindowDestroyAreaForms : window::menuItemListener.
    onWindowDestroyDrawModeTests : window::menuItemListener.
    onWindowDestroyPlainFigures  : window::menuItemListener.