Sunday, December 29, 2024

SWMM5 Delphi GUI Uedit.pas Summary

 Extended Summary for Uedit.pas

This Delphi Pascal unit, Uedit.pas, provides a set of procedures and functions to create and edit objects in an EPA SWMM project. These objects include rain gages, subcatchments, nodes (junctions, outfalls, dividers, storage units), links (conduits, pumps, weirs, outlets, orifices), labels, and non-visual entities (pollutants, land uses, infiltration parameters, etc.). The code orchestrates calls to specialized dialog forms for editing or adding new data, and it updates the project database as well as the visual map and data browser.


1. Purpose & Scope

  • Manage object creation within the SWMM project database:

    • Subcatchments, nodes, links, labels, and some specialized node/link types.
  • Provide editor entry points to modify existing objects, typically by showing specialized dialog forms or the general property editor.

  • Integration Points:

    1. Map: If an object is visual (like a subcatchment or node), it gets drawn on the map or erased/redrawn when edited.
    2. Browser: Data items in the project’s list of objects also appear in the Browser panel; adding a new item calls BrowserAddItem, removing calls BrowserDeleteObject, etc.
    3. Dialogs: For certain object types, specialized forms or the property editor (e.g., PropEditForm) are invoked.

2. Major Functional Blocks

2.1 Adding Objects

  1. AddGage(X, Y)
    Creates a rain gage with coordinates X,Y`X, Y`. Chooses a default ID, uses default properties, and adds it to the project list Project.Lists[RAINGAGE]. Then draws it on the map.

  2. AddSubcatch(PointList, N)
    Creates a subcatchment polygon from an array of screen points (TPoint), converts to map coordinates, and stores them in the subcatchment's vertex list. The bounding center is computed, and an ID is assigned. Then draws on the map and updates the Browser.

  3. AddStorage(PointList, N)
    Creates a storage node with a polygon outline. The node's actual X,Y is set to the polygon centroid. A simpler version of AddNode(...).

  4. AddLink(Ltype, Node1, Node2, PointList, N)
    Creates a link (conduit, pump, orifice, etc.) connecting two known node objects. Intermediate points in PointList become the link’s vertex list. The object is drawn on the map and added to the Browser.

  5. AddNode(Ntype, X, Y)
    Creates a node of type (junction, outfall, divider, storage). Assigns default properties, sets X, Y, and draws it.

  6. AddLabel(X, Y, S)
    Creates a map label at (X, Y) with text S. Draws the label on the map.

  7. AddNonVisualObject(ObjType)
    If the user wants to add something like a pollutant, pattern, or curve, this calls the corresponding specialized editor. If the user completes that dialog, the new object is inserted in the relevant list.


2.2 Editing Objects

Most objects can be edited through either the property editor or specialized forms.

  1. EditRaingage(Index)

    • Loads the raingage data into PropList.
    • Presents them in PropEditForm with RaingageProps.
  2. EditSubcatch(Index)

    • Loads subcatchment data (area, width, outlet, infiltration, etc.) into PropList.
    • Uses SubcatchProps in PropEditForm.
  3. EditNode(Ntype, Index)

    • For a junction, outfall, divider, or storage node, populates PropList with the relevant data, sets up the property editor with JunctionProps, OutfallProps, etc.
  4. EditLink(Ltype, Index)

    • For a conduit, pump, orifice, weir, or outlet link, populates PropList.
    • Some fields (like max. depth or roughness) may be disabled (esReadOnly) depending on shape or cross-section type.
  5. EditLabel(Index)

    • Shows label’s text, position, anchor node, etc., in PropList.
  6. EditNodalInflows(ObjType, Index, S, Modified)

    • Creates a specialized TInflowsForm to handle dry-weather, direct, and RDII inflows to a node.
  7. EditTreatment(ObjType, Index, S, Modified)

    • Creates a specialized TTreatmentForm to define pollutant removal equations at a node.
  8. EditXsection(ObjType, Index, S, Modified)

    • For a link’s cross section geometry. If the shape is “Street” or “Irregular,” the user must switch to a different form. Typically calls TXsectionForm.
  9. EditStorageInfil(Index, S, Modified)

    • A storage node’s infiltration parameters. Uses TInfilForm with fewer fields.
  10. EditLoadings(Index, S, Modified)

    • Edits initial pollutant loads on a subcatchment. Uses TInitLoadingsForm.
  11. EditSubLanduses(Index, S, Modified)

    • Subcatchment land uses & percentages. If no land uses exist, an info message is shown.
  12. EditGroundwater(Index, S, Modified)

    • Subsurface flow parameters for a subcatchment. Calls TGroundWaterForm.
  13. EditComment(Title, S, Modified)

    • General comment field editor.
  14. EditRainFileName(Index, S, Modified)

    • Opens a file open dialog for selecting a rain data file. Replaces the path in the raingage’s property.
  15. EditCurve(ObjType, Index)

    • Edits a curve object (pump curve, rating curve, etc.). If Index<0, it’s a new curve.
  16. EditTimeseries(Index)

    • Edits a time series object. If Index<0, creates a new one.
  17. EditHydrograph(Index)

    • Edits an RDII unit hydrograph. If new, Index<0.
  18. EditStreet(Index)

    • Edits a street cross section shape definition.
  19. EditInletDesign(Index)

    • Edits a street inlet definition.
  20. EditInletUsage(Index, S, Modified)

    • Edits how a link’s inlet is used (in the code, it references DinletUsage).
  21. EditTransect(Index)

    • Channel cross-section shapes. If new, Index<0.
  22. EditPattern(Index)

    • Time patterns (daily, monthly, hourly, etc.).
  23. EditOptions

    • Edits global simulation options with TAnalysisOptionsForm.
  24. EditNotes

    • Edits the global “Title/Notes” with TNotesEditorForm.
  25. EditControls(Index)

    • Rule-based control statements (open the “ControlsForm”).

2.3 Updating Editor & Map

  • UpdateEditor(ObjType, Index):
    Re-loads the property editor contents for a specific object. If the property editor is visible, calls the relevant “EditXxxx(...)” routine.
  • SetConduitDepthField & SetConduitRoughnessField:
    For a conduit link, sometimes the geometry is from a Street or Irregular shape. Those fields become read-only. The geometry’s depth or roughness is derived from the street or transect object.

3. Key Data Structures

  1. TNode: For junctions, outfalls, etc.

    • Has Data[...] array for properties, X, Y coordinates, infiltration, etc.
  2. TLink: For conduit/pump/weir/outlet.

    • Has Data[...] array, references to Node1 & Node2, a vertex list, etc.
  3. TSubcatch:

    • Has Data[...] array, infiltration properties, polygons in Vlist.
  4. TRaingage:

    • Data[...] for gauge definition, plus X, Y.
  5. Project.Lists[...]:

    • The database for each object category. E.g., Project.Lists[RAINGAGE], Project.Lists[CONDUIT].
  6. PropList:

    • A shared string list that the property editor uses.

4. Workflow Examples

Adding a Subcatchment

  1. User draws polygon.
  2. Code calls AddSubcatch(PointList, N).
  3. A TSubcatch object is created, given a new ID, polygon vertex coords, then added to Project.Lists[SUBCATCH].
  4. MapForm.DrawObject(SUBCATCH, I) draws it, and Ubrowser.BrowserAddItem(SUBCATCH, I) updates the Browser.

Editing a Conduit

  1. User selects a conduit in the Browser or on the map, calls EditLink(CONDUIT, Index).
  2. PropEditForm is loaded with conduit properties, including its shape, max depth, length, etc.
  3. If the user changes shape to “Street,” the code sets certain fields read-only and updates geometry from the street object.
  4. If user hits OK, changes are validated & saved, the map is redrawn if necessary, and HasChanged is set.

5. Conclusion

Uedit.pas is central to enabling both the addition and modification of all objects in an EPA SWMM project. It either opens a specialized dialog (if one is required) or uses the universal property editor for simpler objects. After changes, it ensures that the map and Browser remain in sync, and that the underlying SWMM data structure is updated properly.

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