Below is a high-level summary of Fresults.pas, the Delphi unit that implements the TResultsForm in SWMM. This MDI child form displays summary results after a simulation run.
1. Purpose
Fresults.pas defines TResultsForm, an MDI child form that:
- Retrieves and displays summary information (from SWMM’s report file) on a variety of topics (e.g., subcatchment runoff, node flooding, link flow classification, etc.).
- Allows the user to view the summary in a grid, sort by different columns, copy the table to the clipboard/file, or print it.
2. Key Elements and Behaviors
-
Topics and Data Loading:
- SWMM’s engine produces a text report file. The form, upon refresh, checks for the presence of specific topics (like “Subcatchment Runoff,” “Node Depth,” etc.) in that file.
- Each valid topic is listed in the TopicsListBox combo box (e.g., Subcatchment Runoff, Node Flooding, etc.).
- When a topic is chosen, RefreshTopic is called: it calculates row/column counts, sets up multi-line column headers, and then uses Uresults.PopulateGrid to fill TheGrid from the results stored in memory.
-
Grid Appearance:
- TheGrid is a TStringGrid showing one row per object (e.g., subcatchment or conduit) and columns with summary metrics (e.g., total inflow, max flow, hours surcharged).
- The top row of headers in TheGrid can contain multiple lines per column (drawn in
TheGridDrawCell
with calls toDrawText
). - Clicking a column header (top row) sorts the table by that column, numeric vs. text sorting determined by
ColumnIsText
.
-
Topic-Specific Column Headings:
- Each topic (e.g. rtRunoff, rtNodeDepth, rtLinkFlow, etc.) has a dedicated set of multi-line column headings built in SetColHeaders, typically parsed from the header lines found in TopicHeaderLines.
-
Copying Data:
- A CopyTo method launches a TCopyToForm dialog where format is pinned to text.
- If a file is specified, it writes the table to that file (via
Slist.SaveToFile
); otherwise, it copies text to clipboard.
-
Printing:
- The Print routine uses SWMM’s custom Printer object. It:
- Prints a heading,
- Repeats columns chunk by chunk (since some topics have many columns),
- Then prints row by row.
- The Print routine uses SWMM’s custom Printer object. It:
-
Sorting:
- The user can click a column header to sort rows by that column.
- The form keeps track of the currently sorted column, and toggles ascending vs descending each click.
-
Details:
- The TopicsListBoxClickCheck event changes the displayed topic, reloading TheGrid.
- The user can also click on the object name in the table (the first column) to locate that object in the main SWMM database and update the browser.
3. Summary
Fresults.pas provides the TResultsForm used to display summary results from the SWMM engine’s .rpt file. It supports multiple summary topics, multi-line column headers, column sorting, copying to the clipboard, and printing. This allows SWMM users to quickly browse, sort, and export the various summary metrics (runoff, infiltration, node inflow, link flow classification, etc.) produced by a SWMM run.
No comments:
Post a Comment