Extended Summary of the Uinifile.pas
Unit
The Uinifile.pas
unit provides functionality for reading and writing initialization data for the SWMM application. This data includes various preferences, default property values, layout settings, and map/legend configurations. The module handles two main categories of INI files:
- The global EPASWMM5.INI file (located in a folder typically called
epaswmm5.ini
). - A project-specific INI file (which can store or retrieve settings relevant to a particular SWMM project).
Below is a detailed summary of the principal components and routines within the unit.
1. Main Responsibilities
- Reading and writing user-interface style and program preferences to the global
epaswmm5.ini
. - Reading and saving default property values (e.g., default conduit roughness, subcatchment infiltration options, ID label prefixes, etc.).
- Remembering the size and position of the Main Form and the Property Editor form.
- Managing the map legend defaults (colors, intervals).
- Managing MRU (Most Recently Used) project file lists.
- Handling calibration data file references, print page setup details, and date/time format preferences.
2. Key Data & Structures
-
TIniFile
objects:- Created for reading/writing from/to
epaswmm5.ini
(the main SWMM INI file). - Also used for project-specific
.ini
files that store per-project settings.
- Created for reading/writing from/to
-
Project Default Properties:
- The global
Project
object (inUglobals
) has arraysDefProp[ ]
for default properties of each SWMM object type (e.g.,SUBCATCH
,JUNCTION
,CONDUIT
, etc.). - The unit reads these from
[Defaults]
sections in an INI file or writes them back.
- The global
-
Window Layout:
- The top, left, width, and height of the Main Form (
MainForm
) and the Property Editor (PropEditForm
) are read and stored in the INI file.
- The top, left, width, and height of the Main Form (
-
Graph and Profile Plot Options:
- The module writes/reads
GraphOptions
andProfileOptions
to/from the INI file to remember user customizations regarding line styles, colors, grid lines, legend properties, etc.
- The module writes/reads
-
Map Legends:
- For subcatchment, node, and link view variables, the user can have color intervals that get loaded/saved.
- Color arrays, like
MapSubcatchColor[]
,MapNodeColor[]
,MapLinkColor[]
, get stored in[Legends]
sections.
-
Calibration:
- The array
CalibData[]
(defined inUglobals
) references up to 12 calibration data file paths. These can be saved or retrieved from[Calibration]
in the INI file.
- The array
3. Major Procedures & Functions
3.1 Reading and Writing the Main SWMM INI File
-
ReadStyleName
- Reads the currently used VCL UI style from
[Preferences]
→StyleName
. - Ensures the style name matches a recognized style in
TStyleManager.StyleNames
.
- Reads the currently used VCL UI style from
-
ReadIniFile
- Creates a
TIniFile
object forepaswmm5.ini
. - Reads:
- Graph options: 3D display, color settings, axis grids, line/point styles, etc.
- Profile plot options.
- Directories: e.g.,
DataDir
andTempDir
. - Preferences: fonts, blinking highlight, confirm delete, auto-backup, etc.
- MRU file list.
- Property Editor form placement.
- Display precision for subcatch/node/link output variables.
- Creates a
-
SaveIniFile
- Writes back to
epaswmm5.ini
:- Graph & ProfilePlot options.
- Directories & preferences.
- MRU list.
- Property Editor coordinates & size.
- Display precision for model variables.
- Writes back to
-
ReadMainFormSize
/SaveMainFormSize
- Manage the position, size, and window state of the main SWMM form.
3.2 Handling Program Defaults
-
ReadDefaults
- Initializes default property data for objects like subcatchments, junctions, etc. from factory definitions in
Uproject
(likeDefSubcatch
,DefJunction
, etc.). - Then loads any overrides from
epaswmm5.ini
using the functionLoadDefaultsFromFile
.
- Initializes default property data for objects like subcatchments, junctions, etc. from factory definitions in
-
SaveDefaults
- Uses
SaveDefaultsToFile
to store the default properties (prefixes, infiltration default, etc.) toepaswmm5.ini
.
- Uses
-
LoadDefaultsFromFile(theIniFile: TIniFile)
- A local procedure reading
Labels
(ID prefixes & increments) and[Defaults]
from theTIniFile
. - Also sets infiltration parameter arrays (Horton, Green-Ampt, etc.) if user changed infiltration in
[Defaults]
.
- A local procedure reading
-
SaveDefaultsToFile(theIniFile: TIniFile)
- Writes these default properties back to the given INI file.
3.3 Project-Specific INI Handling
-
ReadProjIniFile(const Fname: String)
- If a user has a separate project INI (e.g.,
myproject.ini
), this routine reads map display options (like whether subcatch IDs appear or subcatch polygons are visible), legend color intervals, default infiltration parameters, page layout info (for printing), calibration file references, and more from that file.
- If a user has a separate project INI (e.g.,
-
SaveProjIniFile(const Fname: String)
- Saves the same sets of information above into a
.ini
file next to the project file. This includes:[Map]
display settings,[Backdrop]
flags,[Legends]
,[Labels]
,[Page]
layout,[Calibration]
,[Graph]
date/time format,[Results]
saved status, etc.
- Saves the same sets of information above into a
4. Additional Implementation Details
InitMapLegends
: Called upon reading defaults, assigns factory defaults to color intervals and color arrays for subcatch/node/link legend displays.CheckGraphSeriesOptions
: Ensures user-specified line styles or point sizes stay in valid ranges.ExtractValues
: Helper that tokenizes a string of numbers (with commas) into floats, storing them in an array. Used for reading the[Legends]
intervals.
5. Summary of the Workflow
- On startup or closing, the main SWMM form calls
ReadIniFile
andSaveIniFile
to handle global preferences. - When opening a new SWMM project, the user’s project
.ini
file might be read withReadProjIniFile
. - When saving or closing the project,
SaveProjIniFile
writes out all current settings for map views, defaults, page layout, etc. - When the user modifies defaults or style in the main UI, the updated settings get stored to the correct place (either the global or project
.ini
file) so that changes persist between sessions.
Therefore, Uinifile.pas
is essentially the preference manager for both the general SWMM environment (the main INI) and for the current project’s specialized settings (the project-level INI).
No comments:
Post a Comment