Below is an overview of Dpollut.pas, a Delphi unit from SWMM 5.2 that provides a dialog (TPollutantForm) to create or edit the properties of a pollutant. A pollutant object in SWMM contains several parameters defining its concentration in various inflow streams, its first-order decay rate, and more.
1. Purpose and Context
In SWMM, pollutants represent chemical or biological constituents transported in runoff and sanitary flows. The TPollutantForm allows the user to edit:
- Pollutant Name and Units
- Concentrations in rainfall, groundwater, infiltration/inflow (I&I), dry weather flow, and the initial system concentration
- Decay Coefficient for a first-order decay process
- Whether buildup occurs only during snowfall
- Co-pollutant relationships (where pollutant concentration can be derived as a fraction of another pollutant’s concentration)
These properties are then used by SWMM’s water quality analysis routines.
2. Main Form: TPollutantForm
2.1 Visual Components
-
Property Editor (
TPropEdit
, referenced asPropEdit1
):- Displays each pollutant parameter in a name/value grid.
- Allows the user to edit numeric or text values.
- Provides events for validation (
OnValidate
) and hint messages (OnRowSelect
).
-
Panels and Buttons:
- OK, Cancel, Help at the bottom.
- A
HintLabel
inPanel3
that shows context-sensitive help when the user highlights a property row in the property editor.
2.2 Pollutant Properties and Hints
PollutProps (an array of TPropRecord
) enumerates each pollutant property’s editing style, input mask, default text, etc.:
- Name (string, no spaces)
- Units (combo list: mg/L, µg/L, #/L, etc.)
- Rain Concen.
- GW Concen. (groundwater)
- I&I Concen.
- DWF Concen. (dry weather flow)
- Init. Concen. (initial system concentration)
- Decay Coeff.
- Snow Only (combo: NO/YES)
- Co-Pollutant
- Co-Fraction (fraction relating current pollutant to co-pollutant’s runoff concentration)
These are matched with a set of hints (PollutHint[]
) explaining each property, displayed in HintLabel
upon row selection.
3. Data Flow
3.1 SetData(Index, Pollut: TPollutant)
- Called by the main application to load data from an existing pollutant (or a new one) into the form:
PollutIndex
records which item ofProject.Lists[POLLUTANT]
we’re editing (or -1 if new).- If
Index < 0
, uses DefaultProps as the property values. - Otherwise:
- Property 0 is the pollutant’s name from
Project.Lists[POLLUTANT].Strings[Index]
. - Properties 1..10 come from
Pollut.Data[]
.
- Property 0 is the pollutant’s name from
- Copies these values into
PropList
, which thePropEdit1
control will display.
3.2 FormShow
- Calls
PropEdit1.SetProps(PollutProps, PropList)
, linking theTPropRecord
definitions to the string list of values. - Calls
PropEdit1.Edit
to enter interactive editing mode in the property grid.
3.3 User Edits
- The user modifies each property in the property editor.
- If the user changes rows,
OnRowSelect -> ShowPropertyHint
updatesHintLabel.Caption
. OnValidate -> ValidateEntry
ensures certain fields are not left blank (e.g., concentration fields).
3.4 OKBtnClick and Validation
- OKBtnClick triggers:
PropEdit1.IsValid
: ensures each property passesOnValidate
.ValidateName
: ensures the pollutant name is not blank or duplicated inProject.Lists[POLLUTANT]
.- If any check fails, the form remains open and displays an error message.
- If all checks pass, the form sets
ModalResult := mrOK
.
3.5 GetData(var S: String; Pollut: TPollutant)
- Called after OK, storing the user’s final entries:
S := PropList[0]
for the pollutant’s name.- For properties 1..10,
Pollut.Data[k-1] := PropList[k]
.
- The main calling code then uses the new name (
S
) and updatedPollut.Data[]
to overwrite the old pollutant object inProject.Lists[POLLUTANT]
.
4. Validation Methods
- ValidateEntry (OnValidate): For properties #2..#6, ensures the field cannot be empty. Displays an error message if blank.
- ValidateName: Checks that PropList[0] (the name) is neither empty nor duplicated among existing pollutants.
5. Summary
Dpollut.pas defines a user-friendly form for editing pollutant properties in SWMM. By combining a property editor grid with validation logic, it ensures every pollutant has a unique name, valid numeric concentrations, optional co-pollutant relationships, and correct decay and “snow only” settings. Once the user confirms, these changes are transferred back into the SWMM project’s pollutant database for use in water quality modeling.