Below is an overview of Dtsect.pas, a Delphi unit from SWMM 5.2 that provides a form (TTransectForm) for editing the geometry of a natural channel cross-section (a “transect”). In SWMM, a transect is a set of station-elevation data plus related parameters (roughness, bank stations, scale factors) that define how water flows in an irregular open channel.
1. Purpose and Context
A transect in SWMM is typically used to model natural channels or irregular open channels. The TTransectForm lets a user:
- Enter a unique name for the transect.
- Provide descriptive text (an optional comment).
- Specify Manning’s roughness for the left bank, right bank, and channel.
- Provide station values for the left and right banks, plus scale factors for horizontal and vertical dimensions.
- Input the station-elevation data pairs that define the cross section shape.
Once the user is done, the form stores these parameters into a TTransect
object, which SWMM uses to compute flow-area relationships during hydraulic routing.
2. Main Form: TTransectForm
2.1 Key Controls
-
NameEdit / CommentEdit:
- The user can set the transect’s ID and an optional comment describing it.
-
PropEdit1 (
TPropEdit
):- A custom property editor on the right side of the form that displays a list of property labels (e.g., “Roughness,” “Bank Stations,” “Modifiers”) and their values.
- Specifically, these are arranged in headings and numeric fields for:
- Left Bank N / Right Bank N / Channel N
- Left Bank Station / Right Bank Station
- Station Factor / Elevation Factor / Meander Factor (if any).
-
GridEdit:
- A
TGridEditFrame
that allows the user to enter station-elevation pairs describing the cross-section shape. - Each row has columns: row index, station (horizontal coordinate), elevation (vertical coordinate).
- The user can insert or delete rows. Typically the data must be in ascending order of station.
- A
-
Buttons:
- OK: Finalizes changes (closing the form with
mrOK
) if the data passes validation. - Cancel: Closes form, discarding changes.
- View: Opens a preview plot of the transect using
TPreviewPlotForm
. - Help: Opens context help for transects.
- Edit: Launches a comment editor for the transect’s textual description.
- OK: Finalizes changes (closing the form with
3. Data Flow
3.1 SetData(I, S, Tsect)
- Called to populate the form with an existing transect (index
I
, nameS
inProject.Lists[TRANSECT]
). - Copies the transect’s parameters (roughness, bank stations, scale factors) into the
PropList
string list, displayed byPropEdit1
. - Copies the station-elevation data from the transect’s
Xdata
andYdata
lists into theGridEdit.Grid
rows.
3.2 GetData(S, Tsect)
- After the user presses OK, extracts:
- The new
NameEdit.Text
intoS
. - The parameters from
PropList
back intoTsect.Data[]
. - The station-elevation data from
GridEdit.Grid
intoTsect.Xdata
andTsect.Ydata
.
- The new
- Calls
Tsect.SetMaxDepth
, which recomputes the cross-section’s maximum depth from the input data. - If the name changed or the max depth changed, SWMM updates the
TRANSECT
object and any conduits using that transect.
3.3 Validation
- ValidateData checks:
- Transect name is non-empty.
- The name is unique in
Project.Lists[TRANSECT]
. - The main channel roughness is not empty.
- The station-elevation data in the grid are valid numeric values and in ascending station order.
- If any check fails, the form does not close and displays an error message.
3.4 Station-Elevation Grid
- The user can input up to 1500 points in ascending station order. SWMM uses these points to define the shape of the cross section.
- The grid has 3 columns: row index (hidden or just numbering?), station, elevation. The first row is a header row, so data starts at row 1.
3.5 View button
- Creates a
TPreviewPlotForm
and callsPlotTransectData
to show a quick preview of the cross-section shape. The function uses the station, elevation data plus the left and right bank station scale factors to produce a 2D chart.
4. Summary
Dtsect.pas implements the TTransectForm for editing a natural channel cross-section in SWMM. It includes:
- Text fields for name and comment.
- A property editor (
PropEdit1
) to configure roughness values, bank station definitions, and scale factors. - A grid (
GridEdit
) to input the station-elevation pairs describing the channel shape. - A View button to preview the cross-section shape in a separate plotting form.
- Basic validation of user inputs (non-empty name, unique ID, correct station ordering).
The final data is stored into a TTransect
object, used by SWMM’s hydraulic engine to compute flow area, top width, etc., in the irregular channel.
No comments:
Post a Comment