Sunday, December 29, 2024

SWMM5 Delphi GUI Dstreet.pas Summary

 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:

  1. Provide geometric parameters (e.g., curb height, gutter slope, street width).
  2. Specify whether there is 1 side or 2 sides to the street section for flow accumulation.
  3. 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

  1. NameEdit:

    • A TNumEdit control for the Street object’s name. Must be non-empty and not duplicate an existing street name in the project.
  2. 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.
  3. RadioButton1 / RadioButton2:

    • Indicate if the street cross-section has 1 side or 2 sides for flow.
  4. OkBtn / CancelBtn / HelpBtn:

    • Standard form actions.
  5. 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 or RadioButton2).

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

  1. FormCreate

    • Sets up the form, applying units (feet or meters) to labels and loading an icon into Image1.
  2. 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 corresponding aStreet.Data[X].
      • RadioButton1 checked if aStreet.Data[STREET_SIDES] = '1' otherwise RadioButton2.
  3. GetData(S, aStreet)

    • Retrieves user input from NameEdit and the numeric edits, storing them in the aStreet.Data[] array.
    • Sets S to the street’s name, and updates the side count in STREET_SIDES.
  4. 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.
  5. NameEditKeyPress

    • Prevents the user from beginning the name with '[ ' (ensuring it doesn’t conflict with SWMM input format sections).
  6. Modified Flag

    • Set to true whenever user changes something (like NameEditChange).
    • Helps SWMM track unsaved changes.
  7. FormKeyDown

    • Launches help if F1 is pressed.
  8. Button3Click (HelpBtn)

    • Invokes SWMM’s context help for street cross-section editing.

3. Data Flow

  1. SetData is called, the form loads the existing TStreet.Data[] properties (like slope, width, etc.) into NumEditX fields, sets name in NameEdit.
  2. The user modifies the fields and chooses either OK or Cancel.
  3. OKBtnClick checks for valid name, duplicates, and numeric fields.
  4. If valid, GetData writes back into the TStreet object (Street.Data[X]), including if it has 1 or 2 sides.
  5. 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:

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...