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:
- Map: If an object is visual (like a subcatchment or node), it gets drawn on the map or erased/redrawn when edited.
- Browser: Data items in the project’s list of objects also appear in the Browser panel; adding a new item calls
BrowserAddItem
, removing callsBrowserDeleteObject
, etc. - Dialogs: For certain object types, specialized forms or the property editor (e.g.,
PropEditForm
) are invoked.
2. Major Functional Blocks
2.1 Adding Objects
-
AddGage(X, Y)
Creates a rain gage with coordinates . Chooses a default ID, uses default properties, and adds it to the project listProject.Lists[RAINGAGE]
. Then draws it on the map. -
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. -
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 ofAddNode(...)
. -
AddLink(Ltype, Node1, Node2, PointList, N)
Creates a link (conduit, pump, orifice, etc.) connecting two known node objects. Intermediate points inPointList
become the link’s vertex list. The object is drawn on the map and added to the Browser. -
AddNode(Ntype, X, Y)
Creates a node of type (junction, outfall, divider, storage). Assigns default properties, setsX, Y
, and draws it. -
AddLabel(X, Y, S)
Creates a map label at(X, Y)
with textS
. Draws the label on the map. -
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.
-
EditRaingage(Index)
- Loads the raingage data into
PropList
. - Presents them in
PropEditForm
withRaingageProps
.
- Loads the raingage data into
-
EditSubcatch(Index)
- Loads subcatchment data (area, width, outlet, infiltration, etc.) into
PropList
. - Uses
SubcatchProps
inPropEditForm
.
- Loads subcatchment data (area, width, outlet, infiltration, etc.) into
-
EditNode(Ntype, Index)
- For a junction, outfall, divider, or storage node, populates
PropList
with the relevant data, sets up the property editor withJunctionProps
,OutfallProps
, etc.
- For a junction, outfall, divider, or storage node, populates
-
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.
- For a conduit, pump, orifice, weir, or outlet link, populates
-
EditLabel(Index)
- Shows label’s text, position, anchor node, etc., in
PropList
.
- Shows label’s text, position, anchor node, etc., in
-
EditNodalInflows(ObjType, Index, S, Modified)
- Creates a specialized
TInflowsForm
to handle dry-weather, direct, and RDII inflows to a node.
- Creates a specialized
-
EditTreatment(ObjType, Index, S, Modified)
- Creates a specialized
TTreatmentForm
to define pollutant removal equations at a node.
- Creates a specialized
-
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
.
- For a link’s cross section geometry. If the shape is “Street” or “Irregular,” the user must switch to a different form. Typically calls
-
EditStorageInfil(Index, S, Modified)
- A storage node’s infiltration parameters. Uses
TInfilForm
with fewer fields.
- A storage node’s infiltration parameters. Uses
-
EditLoadings(Index, S, Modified)
- Edits initial pollutant loads on a subcatchment. Uses
TInitLoadingsForm
.
- Edits initial pollutant loads on a subcatchment. Uses
-
EditSubLanduses(Index, S, Modified)
- Subcatchment land uses & percentages. If no land uses exist, an info message is shown.
-
EditGroundwater(Index, S, Modified)
- Subsurface flow parameters for a subcatchment. Calls
TGroundWaterForm
.
- Subsurface flow parameters for a subcatchment. Calls
-
EditComment(Title, S, Modified)
- General comment field editor.
-
EditRainFileName(Index, S, Modified)
- Opens a file open dialog for selecting a rain data file. Replaces the path in the raingage’s property.
-
EditCurve(ObjType, Index)
- Edits a curve object (pump curve, rating curve, etc.). If
Index<0
, it’s a new curve.
- Edits a curve object (pump curve, rating curve, etc.). If
-
EditTimeseries(Index)
- Edits a time series object. If
Index<0
, creates a new one.
- Edits a time series object. If
-
EditHydrograph(Index)
- Edits an RDII unit hydrograph. If new,
Index<0
.
- Edits an RDII unit hydrograph. If new,
-
EditStreet(Index)
- Edits a street cross section shape definition.
-
EditInletDesign(Index)
- Edits a street inlet definition.
-
EditInletUsage(Index, S, Modified)
- Edits how a link’s inlet is used (in the code, it references
DinletUsage
).
- Edits how a link’s inlet is used (in the code, it references
-
EditTransect(Index)
- Channel cross-section shapes. If new,
Index<0
.
- Channel cross-section shapes. If new,
-
EditPattern(Index)
- Time patterns (daily, monthly, hourly, etc.).
-
EditOptions
- Edits global simulation options with
TAnalysisOptionsForm
.
- Edits global simulation options with
-
EditNotes
- Edits the global “Title/Notes” with
TNotesEditorForm
.
- Edits the global “Title/Notes” with
-
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
-
TNode
: For junctions, outfalls, etc.- Has
Data[...]
array for properties,X, Y
coordinates, infiltration, etc.
- Has
-
TLink
: For conduit/pump/weir/outlet.- Has
Data[...]
array, references toNode1
&Node2
, a vertex list, etc.
- Has
-
TSubcatch
:- Has
Data[...]
array, infiltration properties, polygons inVlist
.
- Has
-
TRaingage
:Data[...]
for gauge definition, plusX, Y
.
-
Project.Lists[...]:
- The database for each object category. E.g.,
Project.Lists[RAINGAGE]
,Project.Lists[CONDUIT]
.
- The database for each object category. E.g.,
-
PropList
:- A shared string list that the property editor uses.
4. Workflow Examples
Adding a Subcatchment
- User draws polygon.
- Code calls
AddSubcatch(PointList, N)
. - A
TSubcatch
object is created, given a new ID, polygon vertex coords, then added toProject.Lists[SUBCATCH]
. MapForm.DrawObject(SUBCATCH, I)
draws it, andUbrowser.BrowserAddItem(SUBCATCH, I)
updates the Browser.
Editing a Conduit
- User selects a conduit in the Browser or on the map, calls
EditLink(CONDUIT, Index)
. PropEditForm
is loaded with conduit properties, including its shape, max depth, length, etc.- If the user changes shape to “Street,” the code sets certain fields read-only and updates geometry from the street object.
- 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:
Post a Comment