Sunday, December 29, 2024

SWMM5 Delphi GUI Dproplot.pas Summary

 Below is an overview of Dproplot.pas, a Delphi unit from SWMM 5.2 that provides a dialog form (TProfilePlotOptionsForm) for editing display options of a profile plot. In SWMM, profile plots show how water levels vary along a series of nodes/links; this form lets the user customize colors, fonts, axis scaling, and other aspects of the plot’s appearance.


1. Purpose and Context

A profile plot in SWMM typically shows the elevation of conduit inverts, water surface profiles, and possibly ground elevation along a chosen path of nodes. The TProfilePlotOptionsForm dialog allows the user to:

  1. Adjust chart and background colors (e.g., water color, conduit color).
  2. Control labeling options, fonts, and line thickness.
  3. Override or enable automatic y-axis scaling.
  4. Decide whether to include the Hydraulic Grade Line (HGL), ground surface, etc.
  5. Edit the main chart title, horizontal axis title, and vertical axis title.

When OK is pressed, these choices are saved back to SWMM’s data structures, which in turn update the actual profile plot in the main UI.


2. Main Form: TProfilePlotOptionsForm

2.1 Visual Components

  1. PageControl1 with multiple TabSheets:
    • TabSheet1: Colors (background, panel, conduit, water).
    • TabSheet2: Chart titles (main, horizontal axis, vertical axis) and grid line toggles.
    • TabSheet3 / TabSheet4: Labeling options, arrow length, axis scaling controls, etc.
    • TabSheet5: Additional check boxes (e.g., show ground, line width, etc.).
  2. ColorBox1..ColorBox4: TColorBoxes for picking colors.
  3. MainTitleEdit / HorizAxisEdit / VertAxisEdit: Edits for the user to type text for chart titles.
  4. FontDialog: A standard Delphi font dialog for picking fonts.
  5. Check Boxes:
    • AutoScaleCheckBox: if checked, SWMM calculates Y-axis min/max automatically.
    • LabelsOnAxisBox, LabelsOnPlotBox: whether node labels appear along the axis or on the plot.
    • CheckBox1: toggles including the HGL line.
    • CheckBox3: toggles drawing the ground line.
    • And others controlling grid lines, default usage, etc.
  6. Spin Controls (TUpDnEditBox / TNumEdit):
    • LabelSizeSpin: size of labels for node names.
    • ArrowLengthSpin: length of arrow from node label to node.
    • YminEdit, YmaxEdit, YincEdit: user-specified vertical axis minimum, maximum, and increment.

2.2 Associated Data Structures

  • TGraphOptions: Contains general plotting options (e.g., fonts, colors, whether grid lines show).
  • TProfileOptions: Contains profile-specific settings:
    • E.g., ConduitColor, WaterColor, LineWidth, LabelsOnAxis, etc.

2.3 Key Routines

  1. LoadOptions(...)

    • Called externally to populate the form’s controls from the existing graph/profile options, and main/axis titles.
    • Fills text fields (MainTitleEdit, etc.) with the current chart title.
    • Sets color pickers (ColorBox) from the TGraphOptions.PanelColor, .BackColor, etc.
    • Checks or unchecks boxes (LabelsOnAxisBox, etc.) based on TProfileOptions fields.
    • If the user previously specified a custom or default color, ColorBox1 might be set to 'Default' (meaning a special “use style default” color).
  2. UnloadOptions(...)

    • Reads user’s changes back out of the form into the passed TGraphOptions / TProfileOptions.
    • Takes color from ColorBox# and writes them to ConduitColor, WaterColor, etc.
    • Reads MainTitleEdit.Font to set TitleFontName, TitleFontSize, etc.
    • Whether the user toggled CheckBox1 to exclude HGL.
    • Whether auto-scaling is on, etc.
  3. SetLeftAxisScaling(Ymax, theChart)

    • Called to fill YminEdit, YmaxEdit, YincEdit with the chart’s current min, max, and increment, plus provides a label showing the chart’s actual min and the user-supplied Ymax.
  4. GetLeftAxisScaling(theChart)

    • Reverse of above: reads YminEdit, YmaxEdit, YincEdit, and updates theChart.LeftAxis.Minimum, .Maximum, .Increment if the user is not in auto-scale mode.
  5. MainTitleFontLabelClick / AxisFontLabelClick

    • Invokes FontDialog to let the user pick a new font for the main title or for the axes. After the user chooses, updates the form’s text fields’ Font property.
  6. AutoScaleCheckBoxClick

    • If auto-scale is checked, the user’s numeric entries for Y-min, Y-max, and Y-inc are disabled.

3. Workflow

  1. FormCreate: Minimal setup. Possibly sets the default color in ColorBox1 to 'Default' if the SWMM style theme demands it.
  2. LoadOptions: The caller passes in the existing chart/plot settings. The form updates all controls to reflect those settings, e.g. colors, fonts, checkboxes, axis labels.
  3. The user modifies any of the form’s controls (titles, colors, checkboxes).
  4. When the user presses OK, UnloadOptions is called, storing the new settings back into the appropriate structures:
    • GraphOptions: for general chart styles (background, fonts).
    • ProfileOptions: for profile-specific options (conduit color, water color, label arrow length, etc.).
    • The user can also override the vertical scale by unchecking AutoScale and entering custom Y-min, Y-max, Y-inc.
  5. The main SWMM code then redraws or reconfigures the profile chart using these new settings.

4. Summary

Dproplot.pas is a specialized form for setting the profile plot’s appearance in SWMM. It handles:

  • Chart layout (colors, fonts, grid lines)
  • Profile-specific items (water color, conduit color, label style, show/hide HGL or ground line)
  • Y-axis scaling (auto or user-defined)
  • Title and axis text

By centralizing these adjustments, SWMM provides a user-friendly way for engineers/scientists to tailor profile plots to their preferences, improving clarity and presentation in results.

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