Sunday, December 29, 2024

SWMM5 Delphi GUI Dlidgroup.pas Summary

 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:

  1. Add a new LID usage entry.
  2. Edit the properties of an existing entry.
  3. 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

  1. 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:
      1. Control Name
      2. LID Type (in short form, e.g. “RG” for Rain Garden)
      3. % of Area
      4. % From Imperv
      5. % From Perv
      6. 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).
  2. Add / Edit / Delete Buttons

  3. 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:
    1. The subcatchment’s ID is displayed in the form caption.
    2. Retrieves the subcatchment’s Lids (a TStringList), which may contain multiple lines, each referencing a TLidUnit object.
    3. For each existing LID usage, create/add a row in the StringGrid1.
    4. 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’s LIDs list:
    1. Clear (free) any existing LIDs from the subcatchment.
    2. For each row with a non-empty “Control Name”, create a new TLidUnit object.
    3. Copy the data from each grid column into TLidUnit.Data[].
    4. Append the new TLidUnit object to the subcatchment’s LIDs list.

4. Core Event Handlers

4.1 BtnAddClick

  1. Creates and shows a TLidUsageDlg.
  2. If the user clicks OK, the form returns the new LID usage data.
  3. A new row is appended to StringGrid1 containing these data.
  4. HasChanged := True; enable Edit/Delete buttons if needed.

4.2 BtnEditClick

  1. Looks up the row in StringGrid1 the user selected.
  2. Extracts the existing usage data from the row’s cells.
  3. Calls TLidUsageDlg.SetData to populate that form with the usage’s existing properties.
  4. If the user changes something and presses OK, the row in the grid is updated with the revised usage.
  5. 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 in StringGrid1 with the provided Data 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:

  1. Displaying a grid of LID usage entries.
  2. Letting the user add/edit each usage entry’s details via Dlidusage.pas.
  3. Preventing invalid totals (over 100% of subcatch area).
  4. 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:

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