Below is an overview of Dlidgroup.pas, a Delphi unit from SWMM 5.2 that provides a form (TLidGroupDlg) to add, edit, and remove LID units (i.e., LID usage entries) within a particular subcatchment. Each subcatchment can have multiple LID units installed, each of which references a particular LID control (defined in Dlid.pas) and contains additional usage data (area, percent from impervious/pervious, etc.).
1. Purpose and Context
This dialog manages a list of LID usage entries for a chosen subcatchment. For instance, a subcatchment might have:
- 10% area as Bioretention Cells
- 5% area as Rain Barrels treating 50% of the impervious area
- etc.
The form displays these entries in a TStringGrid
and lets the user:
- Add a new LID usage entry.
- Edit the properties of an existing entry.
- Delete an entry.
Once confirmed, the updated list is stored in the subcatchment’s TSubcatch.LIDs
string list.
2. Main Form: TLidGroupDlg
2.1 UI Elements
-
StringGrid1
- Each row (except row 0) corresponds to one LID usage.
- Row 0 is the header row.
- For each LID usage row, columns 0..5 display:
- Control Name
- LID Type (in short form, e.g. “RG” for Rain Garden)
- % of Area
- % From Imperv
- % From Perv
- Report File (file name portion)
- The “true” parameter values (like area fraction, report file path, etc.) are actually stored in invisible columns (beyond column 5).
-
Add / Edit / Delete Buttons
-
OK, Cancel, Help Buttons
2.2 Relationship to TLidUsageDlg
(Dlidusage.pas)
When the user adds or edits an LID entry, TLidUsageDlg (from Dlidusage.pas) is invoked. That dialog form gathers or edits the usage data (e.g., area fraction, underdrain parameters, optional report file, etc.) for a single LID usage entry.
3. Data Flow
3.1 SetData(theSubcatch)
- Called externally to initialize the form with the LID usage data for a subcatchment:
- The subcatchment’s ID is displayed in the form caption.
- Retrieves the subcatchment’s
Lids
(aTStringList
), which may contain multiple lines, each referencing a TLidUnit object. - For each existing LID usage, create/add a row in the
StringGrid1
. - If there are any entries, enable the Edit and Delete buttons.
3.2 GetData(theSubcatch)
- After the user presses OK, data from
StringGrid1
are read back into the subcatchment’sLIDs
list:- Clear (free) any existing LIDs from the subcatchment.
- For each row with a non-empty “Control Name”, create a new TLidUnit object.
- Copy the data from each grid column into
TLidUnit.Data[]
. - Append the new
TLidUnit
object to the subcatchment’s LIDs list.
4. Core Event Handlers
4.1 BtnAddClick
- Creates and shows a TLidUsageDlg.
- If the user clicks OK, the form returns the new LID usage data.
- A new row is appended to
StringGrid1
containing these data. HasChanged := True
; enable Edit/Delete buttons if needed.
4.2 BtnEditClick
- Looks up the row in
StringGrid1
the user selected. - Extracts the existing usage data from the row’s cells.
- Calls TLidUsageDlg.SetData to populate that form with the usage’s existing properties.
- If the user changes something and presses OK, the row in the grid is updated with the revised usage.
HasChanged := True
if changes occurred.
4.3 BtnDeleteClick
- Removes the currently selected row from
StringGrid1
. - If no more usage rows remain, disable Edit/Delete.
HasChanged := True
.
4.4 OkBtnClick
- Summarizes the total subcatch area assigned to LIDs (
% of Area
), and the total fractions of impervious/pervious area each LID treats. - If any total exceeds 100%, displays an error message. Otherwise, closes with
mrOK
. - The caller then uses
GetData
to store these usage entries in the subcatchment object.
4.5 StringGrid1KeyDown
- Insert => same as BtnAddClick.
- Enter => same as BtnEditClick.
- Delete => same as BtnDeleteClick.
4.6 FillGridRow(I, Data)
- Fills row
I
inStringGrid1
with the providedData
array from a TLidUnit. - The first two cells (columns 0..1) display the LID name and a short LID Type description.
- The next columns show derived or truncated items like “% of Area,” “% From Imperv,” etc.
- The real parameters remain in the invisible columns for retrieval later.
5. Summary
Dlidgroup.pas coordinates the usage of LID controls in a subcatchment by:
- Displaying a grid of LID usage entries.
- Letting the user add/edit each usage entry’s details via Dlidusage.pas.
- Preventing invalid totals (over 100% of subcatch area).
- Storing updated usage data back into the SWMM project data structures.
This design streamlines how multiple LID units are set up in a single subcatchment, ensuring consistency and clarity in the assignment of LID controls (like permeable pavement, bioretention, etc.) to the model.
No comments:
Post a Comment