Below is an overview of Dreport.pas, a Delphi unit from SWMM 5.2 that defines a dialog (TReportSelectForm) for specifying the contents of various types of tabular or graphical reports. These include:
- Time Series Plot
- Scatter Plot
- Table by Variable
- Table by Object
Once the user makes selections (e.g., which objects, which variables, and date ranges), the form gathers this information into a TReportSelection
record and calls MainForm.CreateReport(...)
to generate the actual report or plot.
1. Purpose and Context
In SWMM, the user can create several kinds of reports/plots:
- Time Series Plot: multiple objects vs. time.
- Scatter Plot: one variable on X-axis and another on Y-axis, for selected objects/dates.
- Table by Variable: a time series table (one variable for multiple objects).
- Table by Object: multiple variables for a single object.
TReportSelectForm is a stay-on-top form that prompts the user to choose:
- Object types (subcatchments, nodes, links, system).
- Which objects specifically (selected from the map or browser).
- Which variables to include.
- Which date/time range (start, end, possibly in elapsed or absolute time).
- Additional details (time axis style, maximum number of items, etc.).
Once user clicks OK, the form’s code packages all these choices into a TReportSelection
structure. The main UI (MainForm
) uses CreateReport(ReportSelection)
to actually build or display the requested table or plot.
2. Main Form: TReportSelectForm
2.1 Notable Controls and Tabs
- Notebook1
- A multi-page control. Depending on
ReportTypeChoice
, a specific page is shown:- Page 0: Time Series or Table-type selection (objects + variables).
- Page 1: Scatter plot selection (X-axis, Y-axis).
- A multi-page control. Depending on
- CategoryCombo (or XCategoryCombo/YCategoryCombo for scatter)
- Chooses the object class: subcatchments, nodes, links, or system.
- VariableListBox
- A check list box for variables. The user can select one or multiple.
- ItemsListBox
- A list box for the specific objects chosen. For instance, if it’s a time series plot, the user can pick multiple nodes or links.
- Date Ranges
- StartDateCombo1/2, EndDateCombo1/2: combo boxes listing simulation date/time steps.
- For time series or scatter plots, user picks a start and end date index.
- Add / Delete / MoveUp / MoveDown
- Manage which objects appear in
ItemsListBox
.
- Manage which objects appear in
- XObjectEdit/YObjectEdit
- For scatter plots, store the single X or Y object ID.
- XVariableCombo/YVariableCombo
- For scatter plots, which variable on X or Y axis.
3. Process Flow
3.1 SetReportType(aReportType)
- Configures the form for a given report type:
TIMESERIESPLOT
,SCATTERPLOT
,TABLEBYVARIABLE
, orTABLEBYOBJECT
.
- The form’s Notebook1.PageIndex is set accordingly.
- Sets
MaxObjects
(the maximum number of objects the user can select). - For tables/plots dealing with subcatchments/nodes/links, populates the relevant combos with their available variables.
- If the user is picking from system-level variables, the code also includes the “System” category.
3.2 CategoryComboClick / XCategoryComboClick / YCategoryComboClick
- When the user picks “Subcatchments,” “Nodes,” “Links,” or “System,” these routines fill the associated variable combos:
- For subcatchments, fill from
MainForm.SubcatchViewBox.Items
(skipping the “(None)” item). - For nodes, from
MainForm.NodeViewBox.Items
. - For links, from
MainForm.LinkViewBox.Items
. - For system, from
SysViewNames[]
.
- For subcatchments, fill from
- For time-series or table by variable, it also updates the
ItemsListBox
if the user is currently viewing a subcatch/node/link in the SWMM data browser.
3.3 AddToItemList
- When the user presses Add, the code retrieves the currently selected object in SWMM (
CurrentList/CurrentItem
) and appends its ID toItemsListBox
.
3.4 VariableListBoxClick
- In “Table by Variable” or “Time Series Plot,” we allow multiple variables if we’re dealing with system or “table by object,” otherwise only one.
- If multi-variable is not allowed, clicking one variable unchecks others.
3.5 BtnOKClick
- Checks constraints:
- Must have at least one variable selected (if needed).
- Must have valid date range (
StartDate <= EndDate
). - Must not exceed
MaxObjects
.
- If a scatter plot, ensures the user has valid Xobject, Yobject.
- If valid, calls CreateReport to build a
TReportSelection
record with all the info, and callsMainForm.CreateReport(ReportSelection)
.
3.6 CreateReport
- Gathers user selections:
- ReportType: determined by
ReportTypeChoice
. - ObjectType: subcatchments, nodes, links, or system.
- StartDateIndex / EndDateIndex: from combos.
- Items: from
ItemsListBox
(or if scatter, from XobjectEdit + YobjectEdit). - VariableCount / Variables[]: from
VariableListBox
orXVariableCombo
/YVariableCombo
. - Whether we use elapsed time or actual date/time.
- ReportType: determined by
- Then it calls
MainForm.CreateReport(ReportSelection)
to produce the final table or chart.
4. Special Cases
- System objects: The user can’t select multiple system “objects”—there’s only one system. Thus,
ItemsListBox
is hidden or disabled. - Table by Object: The user picks only one object in
ItemsListBox
, but can pick multiple variables inVariableListBox
.
5. Summary
Dreport.pas is the “front end” to SWMM’s tabular and plot reports. By collecting user choices about objects, variables, and date ranges, it forms a consistent approach for:
- Time series graphs (multiple objects, single or multiple variables).
- Scatter plots (two distinct objects/variables).
- Tabular reports (by variable or by object).
Finally, it invokes MainForm.CreateReport(ReportSelection)
to generate the actual result. This design ensures consistent input validation and user flow across SWMM’s various reporting tools.