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:
- Adjust chart and background colors (e.g., water color, conduit color).
- Control labeling options, fonts, and line thickness.
- Override or enable automatic y-axis scaling.
- Decide whether to include the Hydraulic Grade Line (HGL), ground surface, etc.
- 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
- 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.).
- ColorBox1..ColorBox4: TColorBoxes for picking colors.
- MainTitleEdit / HorizAxisEdit / VertAxisEdit: Edits for the user to type text for chart titles.
- FontDialog: A standard Delphi font dialog for picking fonts.
- 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.
- 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.
- E.g.,
2.3 Key Routines
-
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 theTGraphOptions.PanelColor
,.BackColor
, etc. - Checks or unchecks boxes (
LabelsOnAxisBox
, etc.) based onTProfileOptions
fields. - If the user previously specified a custom or default color, ColorBox1 might be set to
'Default'
(meaning a special “use style default” color).
-
UnloadOptions(...)
- Reads user’s changes back out of the form into the passed
TGraphOptions
/TProfileOptions
. - Takes color from
ColorBox#
and writes them toConduitColor
,WaterColor
, etc. - Reads
MainTitleEdit.Font
to setTitleFontName
,TitleFontSize
, etc. - Whether the user toggled
CheckBox1
to exclude HGL. - Whether auto-scaling is on, etc.
- Reads user’s changes back out of the form into the passed
-
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-suppliedYmax
.
- Called to fill
-
GetLeftAxisScaling(theChart)
- Reverse of above: reads
YminEdit
,YmaxEdit
,YincEdit
, and updatestheChart.LeftAxis.Minimum
,.Maximum
,.Increment
if the user is not in auto-scale mode.
- Reverse of above: reads
-
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.
- Invokes
-
AutoScaleCheckBoxClick
- If auto-scale is checked, the user’s numeric entries for Y-min, Y-max, and Y-inc are disabled.
3. Workflow
- FormCreate: Minimal setup. Possibly sets the default color in
ColorBox1
to'Default'
if the SWMM style theme demands it. - 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.
- The user modifies any of the form’s controls (titles, colors, checkboxes).
- 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.
- 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:
Post a Comment