Below is an overview of Dstreet.pas, a Delphi unit from SWMM 5.2 that provides a TStreetEditorForm dialog. This dialog is used to define or edit the street cross-section geometry for a Street object in SWMM.
1. Purpose and Context
Certain model implementations of SWMM include the concept of a Street object—essentially, a cross-section that describes how street flow is conveyed along curbs or gutters. The TStreetEditorForm allows the user to:
- Provide geometric parameters (e.g., curb height, gutter slope, street width).
- Specify whether there is 1 side or 2 sides to the street section for flow accumulation.
- Accept a name (unique ID) for the street cross-section.
Once the user finalizes this data and presses OK, the form transfers the updated parameters back into the TStreet object for use during flow routing computations in SWMM.
2. Main Form: TStreetEditorForm
2.1 Key Fields and Controls
-
NameEdit:
- A
TNumEdit
control for the Street object’s name. Must be non-empty and not duplicate an existing street name in the project.
- A
-
NumEdit0..NumEdit9:
- Numeric fields where each parameter is stored, e.g.:
- NumEdit0: Possibly the roadway cross slope.
- NumEdit1: Maybe curb height, or some other dimension.
- And so forth up through
NumEdit9
.
- Each is a
TNumEdit
ensuring numeric input.
- Numeric fields where each parameter is stored, e.g.:
-
RadioButton1 / RadioButton2:
- Indicate if the street cross-section has 1 side or 2 sides for flow.
-
OkBtn / CancelBtn / HelpBtn:
- Standard form actions.
-
Image1:
- A visual icon associated with the form (from an image list).
2.2 Data in SWMM
A TStreet object might have a Data[]
array with indices up to MAXSTREETPROPS
. Each Data[J]
corresponds to a particular street geometry parameter, such as:
STREET_SLOPE
STREET_CURB_HEIGHT
STREET_GUTTER_SLOPE
STREET_WIDTH
- Possibly up to 10 parameters total, stored in
NumEdit0..NumEdit9
. STREET_SIDES
indicating if 1 or 2 sides are present (RadioButton1
orRadioButton2
).
When the user is done editing:
- The code updates
aStreet.Data[STREET_SIDES]
to"1"
if one side, or"2"
if both sides. - Other numeric fields are read from
NumEditX.Text
.
2.3 Key Methods and Events
-
FormCreate
- Sets up the form, applying units (feet or meters) to labels and loading an icon into
Image1
.
- Sets up the form, applying units (feet or meters) to labels and loading an icon into
-
SetData(I, S, aStreet)
- Called to load the street’s data into the form:
- StreetIndex = I (the index in the project’s
STREET
list). NameEdit.Text
= S (the street’s name).- Each
NumEditX
is set to the correspondingaStreet.Data[X]
. - RadioButton1 checked if
aStreet.Data[STREET_SIDES] = '1'
otherwise RadioButton2.
- StreetIndex = I (the index in the project’s
- Called to load the street’s data into the form:
-
GetData(S, aStreet)
- Retrieves user input from
NameEdit
and the numeric edits, storing them in theaStreet.Data[]
array. - Sets
S
to the street’s name, and updates the side count inSTREET_SIDES
.
- Retrieves user input from
-
Button1Click (OKBtn)
- Validates:
- Street name is non-empty and unique.
- All required numeric fields are present and nonzero.
- If valid,
ModalResult := mrOK
, otherwise an error message is shown.
- Validates:
-
NameEditKeyPress
- Prevents the user from beginning the name with
'[ '
(ensuring it doesn’t conflict with SWMM input format sections).
- Prevents the user from beginning the name with
-
Modified Flag
- Set to
true
whenever user changes something (likeNameEditChange
). - Helps SWMM track unsaved changes.
- Set to
-
FormKeyDown
- Launches help if F1 is pressed.
-
Button3Click (HelpBtn)
- Invokes SWMM’s context help for street cross-section editing.
3. Data Flow
- SetData is called, the form loads the existing
TStreet.Data[]
properties (like slope, width, etc.) intoNumEditX
fields, sets name inNameEdit
. - The user modifies the fields and chooses either OK or Cancel.
- OKBtnClick checks for valid name, duplicates, and numeric fields.
- If valid, GetData writes back into the
TStreet
object (Street.Data[X]
), including if it has 1 or 2 sides. - The form closes with mrOK.
4. Summary
Dstreet.pas provides a specialized form (TStreetEditorForm) that ensures each Street cross-section has the correct geometry (width, curb/gutter dimensions, slope, etc.) and is named uniquely. By collecting numeric inputs in NumEditX
fields and toggling a one- vs. two-sided design, the user can properly define how water flows in the street segment. The code handles basic validation (non-empty name, no duplicates, numeric parameters not zero). The result is used by SWMM in advanced street flow modeling or gutter flow calculations.
No comments:
Post a Comment