Sunday, December 29, 2024

SWMM5 Delphi GUI Ftable.pas Summary

 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:

  1. Table by Variable: Time series for a single variable (e.g., flow, depth, or subcatchment runoff) across multiple objects.
  2. 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

  1. TTableForm class:

    • Inherits from TForm and acts as an MDI child window inside SWMM.
  2. Grid1: TDrawGrid:

    • The main grid where data is displayed (time along rows; variables/objects along columns).
    • Each cell is rendered in the Grid1DrawCell event.
  3. Edit1: TEdit (invisible at runtime):

    • Provides a reference for consistent row/column heights.
  4. Table: TReportSelection:

    • Stores the user’s selection parameters (object type, variable indices, date/time display mode, etc.).
  5. ColLabel[]: array:

    • Holds the string labels (headers) for each column.
  6. Methods:

    • CreateTable(aReportSelection):
      Receives a TReportSelection describing what data to display, sets up column headers, and calls RefreshTable.
    • RefreshTable:
      Retrieves data from SWMM’s output results, populates the column headings, and sets the row count. Updates Grid1 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 (in Dcopy.pas) and calls CopyToString to copy the current selection to file or clipboard.
    • Print:
      Prints the grid across multiple pages if necessary (using Xprinter.pas).

3. Work Flow

  1. Creation: When a user requests a Table by Object or Table by Variable, SWMM builds a TReportSelection and calls TableForm.CreateTable(ReportSelection).
  2. 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).
  3. 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.
  4. 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 like StartDateTime, 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:

A comprehensive explanation of how minimum travel distance relates to link length in InfoSewer

In hydraulic modeling of sewer networks, the minimum travel distance is a fundamental parameter that affects how accurately the model can si...