Below is a high-level summary of Ftable.pas, a Delphi unit within the EPA SWMM 5 application. This unit implements TTableForm, an MDI child form that displays tabular time series results of a SWMM simulation using a TDrawGrid component.
1. Purpose of Ftable.pas
The Ftable.pas unit defines a form (TTableForm) that provides a time series data table for SWMM's simulation results. Depending on the user’s selection (described by a TReportSelection record), the table can display:
- Table by Variable: Time series for a single variable (e.g., flow, depth, or subcatchment runoff) across multiple objects.
- Table by Object: Time series for one object (a single node, link, subcatchment, or the system) across several variables.
The table is populated with results from SWMM’s binary output file. When a new simulation is completed, calling RefreshTable re-queries the output file for the selected data and redraws the table.
2. Key Elements of TTableForm
-
TTableForm
class:- Inherits from
TForm
and acts as an MDI child window inside SWMM.
- Inherits from
-
Grid1: TDrawGrid
:- The main grid where data is displayed (time along rows; variables/objects along columns).
- Each cell is rendered in the
Grid1DrawCell
event.
-
Edit1: TEdit
(invisible at runtime):- Provides a reference for consistent row/column heights.
-
Table: TReportSelection
:- Stores the user’s selection parameters (object type, variable indices, date/time display mode, etc.).
-
ColLabel[]: array
:- Holds the string labels (headers) for each column.
-
Methods:
CreateTable(aReportSelection)
:
Receives aTReportSelection
describing what data to display, sets up column headers, and callsRefreshTable
.RefreshTable
:
Retrieves data from SWMM’s output results, populates the column headings, and sets the row count. UpdatesGrid1
display.Grid1DrawCell
:
Custom drawing of each table cell (including date/time in columns 0-1, and fetched simulation data in columns 2+).CopyTo
:
Launches the "Copy To" dialog (inDcopy.pas
) and callsCopyToString
to copy the current selection to file or clipboard.Print
:
Prints the grid across multiple pages if necessary (usingXprinter.pas
).
3. Work Flow
- Creation: When a user requests a Table by Object or Table by Variable, SWMM builds a
TReportSelection
and callsTableForm.CreateTable(ReportSelection)
. - Setup: The form uses the
TReportSelection
to configure:- The number of columns,
- Column headers (object IDs or variable names + units),
- Row count (matches number of time steps).
- Population: Each time step is placed in row 1..N, and each item (object/variable) in columns 2..M. Rows 0 or columns 0-1 are for headings.
- Interaction:
- Sorting is limited (only partial).
- Copying is done by selecting a block of cells or the entire table, then calling
CopyTo
. - Printing goes column by column to fit across multiple pages.
4. Integration with SWMM
- The table obtains results from
Uoutput.Get*ValStr
functions which read from SWMM’s binary results file. - Date/time and simulation indexing come from
Uglobals
fields likeStartDateTime
,DeltaDateTime
,ReportStep
, etc.
5. Summary
In Ftable.pas, TTableForm
is the MDI child window that displays time series data in tabular form, fetches SWMM output results for each time step and item, renders them in a TDrawGrid, and provides copying/printing functionalities. This is part of SWMM’s user interface for analyzing and exporting simulation results in tabular format.
No comments:
Post a Comment