Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
frmMainSWMM.py - new function to add default cross section with new c…
Browse files Browse the repository at this point in the history
…onduit, weir, or orifice

frmMain.py - call new function for xsections
  • Loading branch information
PaulDudaATC committed Oct 18, 2019
1 parent 197128b commit dcbfb5e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/ui/SWMM/frmMainSWMM.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
from core.swmm.hydraulics.link import Weir
from core.swmm.hydraulics.link import Transect
from core.swmm.hydraulics.link import CrossSection
from core.swmm.hydraulics.link import CrossSectionShape
from core.swmm.quality import Landuse
from core.swmm.curves import Curve
from core.swmm.curves import CurveType
Expand Down Expand Up @@ -1694,6 +1695,23 @@ def set_project_map_extent(self):
rect.xMaximum() + x_setback,
rect.yMaximum() + y_setback)

def add_cross_section(self, new_item):
# add cross section for new conduit, orifice, weir as needed
if isinstance(new_item, Conduit) or isinstance(new_item, Weir) or isinstance(new_item, Orifice):
# create new xsection
xsection = CrossSection()
if self.project_settings and \
self.project_settings.xsection:
self.project_settings.apply_default_attributes(xsection)
xsection.link = new_item.name
if isinstance(new_item, Weir):
# weirs have different defaults
xsection.shape = CrossSectionShape.RECT_OPEN
xsection.geometry1 = 1
xsection.geometry2 = 1
if self.project:
self.project.xsections.value.append(xsection)


class ModelLayersSWMM(ModelLayers):
"""
Expand Down
2 changes: 2 additions & 0 deletions src/ui/frmMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,8 @@ def undo(self):

def add_item(self, new_item):
self.undo_stack.push(self._AddItem(self, new_item))
if self.model == "SWMM":
self.add_cross_section(new_item)
self.mark_project_as_unsaved()

class _DeleteItem(QUndoCommand):
Expand Down

0 comments on commit dcbfb5e

Please sign in to comment.