Below is an overview of Dnotes.pas, a Delphi unit from SWMM 5.2 that defines a dialog (TNotesEditorForm) for editing either:
- A project’s Title/Notes text (the lines that appear as descriptive “header” text for the project), or
- The Comment property of any individual SWMM object (e.g., a node, link, subcatchment, etc.).
1. Purpose and Context
Many SWMM objects (and the project overall) can store descriptive notes or comments. This dialog provides a text-editing interface so users can:
- Edit and store multiline comments for a specific object.
- Modify the SWMM project’s Title/Notes (including an option to treat the title as a header in printed reports).
Because it’s used for two different but related tasks (object comments vs. project notes), some controls (like CheckHeader
) may appear only for project-wide notes editing.
2. Main Components: TNotesEditorForm
- Memo1 (
TMemo
):- A multiline text box where the user types or views the text.
- CheckHeader (
TCheckBox
):- Visible only when editing the project’s Title/Notes.
- Toggled on/off to indicate whether the project’s Title lines should be used as a report header (
TitleAsHeader
).
- OK and Cancel buttons:
- Standard dialog acceptance or dismissal.
- HasChanged (boolean):
- Tracks whether the text was modified by the user (or if
CheckHeader
changed).
- Tracks whether the text was modified by the user (or if
3. Data Flow and Methods
3.1 Editing Comments for an Object
-
SetComment(Title, S):
- Sets
Caption := Title
so the dialog’s top bar text might say something like “Comment for Node X”. - Places the existing comment (
S
) intoMemo1.Lines
and resets the cursor to the start.
- Sets
-
GetComment(var S):
- Reads all lines from
Memo1.Lines
and combines them with CR (carriage return, #13) separators into the stringS
. - Notes if the user typed anything by checking
Memo1.Modified
.
- Reads all lines from
3.2 Editing the Project Title/Notes
-
SetProjectNotes(Slist):
- Makes
CheckHeader.Visible := True
(so the user can choose if the first line is used as a header in reports). - Copies the multiline text from
Slist
intoMemo1.Lines
. - Moves the caret to the start.
- Makes
-
GetProjectNotes(Slist):
- Saves the user’s choice of
CheckHeader.Checked
intoUglobals.TitleAsHeader
. - Copies the lines from
Memo1.Lines
back intoSlist
.
- Saves the user’s choice of
3.3 Additional Details
- FormCreate:
CheckHeader.Visible := False;
by default, since it’s only shown for project-level notes, not for object comments.
- CheckHeaderClick:
- If the user toggles the checkbox,
HasChanged := True;
- If the user toggles the checkbox,
- The text editor (
Memo1
) can handle multiple lines. If the user hits OK, the text is committed back to whichever storage is relevant (project notes or object comment).
4. Typical Usage
-
Editing an object’s comment:
- The main application calls
SetComment("Link Comment", linkCommentString)
. - The user modifies text in
Memo1
. - On OK,
GetComment(linkCommentString)
is called. The updated text is saved into the link object’sComment
property.
- The main application calls
-
Editing the project’s Title/Notes:
- The main application calls
SetProjectNotes(NotesList)
, passing aTStringList
of lines. - The user can check/uncheck
CheckHeader
to specify whether the first line is a “report header.” - On OK,
GetProjectNotes(NotesList)
is called; the updated lines and header-setting are captured in the project data structures.
- The main application calls
Because SWMM uses these free-text fields in many places (reports, user documentation, object definitions), Dnotes.pas is a straightforward but essential piece of the UI for effectively documenting models.
No comments:
Post a Comment