Below is an overview of Dinlet.pas, a Delphi unit from SWMM 5.2 that provides a form (TInletEditorForm) for specifying a particular street inlet design. SWMM uses inlets to model surface flow interception (capture) from gutters into the drainage network.
1. Purpose and Context
This unit defines the Inlet Editor dialog, which lets the user create or modify the design details of a street inlet. SWMM supports several types of inlets (grate, curb opening, etc.), each with its own set of parameters determining how flows are intercepted from street gutters.
2. TInletEditorForm at a Glance
TInletEditorForm
is the main form class that contains:
- A Combo Box (
InletTypeCombo
) listing inlet types (e.g., Grate, Curb, Combo, Slotted Drain, Custom). - Pages (
TPageControl
with multipleTTabSheet
s) to display different inlet parameter sets, depending on the type:- TabSheet1: Grate Inlet
- TabSheet2: Curb Opening Inlet
- TabSheet3: Slotted Drain Inlet
- TabSheet4: Custom Inlet
- Several TNumEdit Controls (
NumEdit1
,NumEdit2
, etc.) for numeric input:- E.g., grate length/width, curb opening length, depths, and other geometrical or capacity parameters.
- Combo Boxes for sub-type selection:
- GrateTypeCombo: e.g., “Vane,” “Generic,” “Herringbone,” etc.
- ThroatTypeCombo: e.g., “Depressed,” “Setback,” etc.
- CurveCombo: reference to a Custom Inlet’s rating or diversion curve name.
- Radio Buttons (
DiversionRB
,RatingRB
) to specify which type of custom capture curve is used (Diversion curve vs. Rating curve). - An Image (
Image1
), updated dynamically to show an icon representing the chosen inlet type.
When the user picks an inlet type in InletTypeCombo
, the form displays the relevant tab pages and hides the others.
3. Key Data Structures and Properties
3.1 TInlet
Object
SWMM organizes inlets under a special object class TInlet. Each TInlet:
- Has an integer InletType index (matching the order in
InletTypes[]
, e.g.GRATE_INLET = 0
,CURB_INLET = 1
, etc.). - Stores parameters in an array of strings,
Data[ ]
, indexed by symbolic constants (e.g.,GRATE_INLET_TYPE
,CURB_INLET_THROAT
, etc.). - For a Custom inlet type, the relevant capture curve name is placed into the string array at a specific index (e.g.,
CUSTOM_INLET_DIVRSN_CURVE
orCUSTOM_INLET_RATING_CURVE
).
3.2 Controls and Indices
NameEdit
: The unique name of the inlet.InletTypeCombo
: Index corresponds to the inlet’s type.NumEdit#
: Each numeric edit (1..9) updatesaInlet.Data[#]
. For example:NumEdit1
might be Grate WidthNumEdit2
might be Grate Length- … etc.
GrateTypeCombo
andThroatTypeCombo
: Stored as strings inaInlet.Data[GRATE_INLET_TYPE]
or[CURB_INLET_THROAT]
.
4. Form Lifecycle and Event Handlers
4.1 FormCreate
- Initializes unit labels (feet or meters) based on
Uglobals.UnitSystem
. - Populates
InletTypeCombo
with the strings inInletTypes[]
. - Populates
GrateTypeCombo
andThroatTypeCombo
with strings fromGrateTypes[]
andThroatTypes[]
. - Sets default content for
CurveCombo
(e.g., all diversion curves). - Assigns a glyph (icon) to the
CurveBtn
from the main form’s image list.
4.2 SetData
procedure SetData(const I: Integer; const S: String; aInlet: TInlet);
- Stores local references (
InletName
,InletIndex
, andInletType
) from the passed-inaInlet
. - Fills the form controls from
aInlet.Data
.GrateTypeCombo.Text := aInlet.Data[GRATE_INLET_TYPE]
NumEdit#
controls get numeric values fromaInlet.Data[#]
ThroatTypeCombo.Text := aInlet.Data[CURB_INLET_THROAT]
- If it’s a Custom inlet, picks which radio button (Diversion vs. Rating) based on the known curve type in the project data.
- Shows/hides the relevant tab sheets via
InletTypeComboClick
. - Sets
Modified := False
.
4.3 GetData
procedure GetData(var S: String; aInlet: TInlet);
- Retrieves the edited name into
S
. - Sets
aInlet.InletType := InletTypeCombo.ItemIndex
. - Copies each
NumEdit#
control back intoaInlet.Data[#]
. - If it’s a Custom inlet, stores the curve name in either
CUSTOM_INLET_DIVRSN_CURVE
orCUSTOM_INLET_RATING_CURVE
based on which radio button is selected. - Checks if anything has changed compared to the original inlet data. If so, sets
Modified := True
.
4.4 InletTypeComboClick
When the user picks an inlet type:
- Updates the displayed image (
Image1.Picture.Icon
) to match the chosen type. - Shows or hides the tab sheets (
TabSheet1..TabSheet4
) relevant to that inlet type. For example:- Grate => TabSheet1
- Curb => TabSheet2
- Combo => TabSheet1 + TabSheet2
- Slotted => TabSheet3
- Drop Grate => TabSheet1 (again, different style)
- Drop Curb => TabSheet2 (no throat combo)
- Custom => TabSheet4
- Labels each tab appropriately (e.g., “Grate Inlet,” “Curb Opening Inlet,” etc.).
4.5 GrateTypeComboChange
If the user selects a “GENERIC” grate, additional controls become visible (NumEdit3
, NumEdit4
) for e.g. grate coefficient data.
4.6 OkBtnClick
- Checks that
NameEdit
is not empty. - Verifies that no other inlet shares this name (unless editing the same inlet).
- If Custom inlet type, checks that a valid curve name was supplied in
CurveCombo
(either Diversion or Rating).- If the project already has a curve of the correct type, fine; if not, the user can still provide a new name (which might be defined later).
- If these validations pass, the form ends with
ModalResult := mrOK
.
4.7 CurveBtnClick
- Edits or adds a curve in the Diversion or Rating curve list, as chosen by the user.
- Upon returning from the curve editor, updates
CurveCombo
text if a new or renamed curve was created.
4.8 HelpBtnClick
Opens a help topic. The code picks a help context ID depending on which tab is active.
5. Summary of Operation
-
Initialization
The form is created, populating combos and setting up the user interface based on the SWMM unit system (US or SI). -
Data Loading
SetData
populates the form from an existing TInlet object. It also determines which tabs to show or hide. -
User Editing
The user modifies the inlet type, geometry (length, width, opening dimensions), optionally picks or edits a capture curve for a Custom inlet, etc. -
Validation
When the user clicks OK, the form ensures the inlet name is valid and unique, and checks for a valid curve name (when needed). -
Data Saving
GetData
copies values back into the TInlet object. The calling code can then store it in the SWMM project database.
By controlling which tabs and fields appear for each inlet type, Dinlet.pas provides an organized approach to editing potentially complex inlet geometry and capture properties. This modular design allows SWMM to handle everything from simple grates to custom rating-curve-based inlets in a single dialog.
No comments:
Post a Comment