1 """Common functions for HYDRO module"""
5 source(os.path.join(os.getenv("COMMON_SCRIPT_DIR"), "common.py"))
8 #--------------------------------------------------------------------------
9 # HYDRO module activation
10 #--------------------------------------------------------------------------
12 Activate HYDRO module via toolbar and check that OB, Graphics viewer and OCC Viewer are created
15 clickButton(waitForObject(":SALOME *.HYDRO_QToolButton"))
16 waitFor("object.exists(':Object Browser_QtxTreeView')", 20000)
17 test.compare(findObject(":Object Browser_QtxTreeView").visible, True)
18 waitFor("object.exists(':SALOME *.3D View Operations_OCCViewer_ViewPort3d')", 20000)
19 test.compare(findObject(":SALOME *.3D View Operations_OCCViewer_ViewPort3d").visible, True)
20 waitForObject(":SALOME_STD_TabDesktop").resize(1916, 930)
21 waitForObject(":SALOME *.3D View Operations_OCCViewer_ViewPort3d").resize(1527, 601)
22 clickTab(waitForObject(":SALOME *_QtxWorkstackTabBar"), "Graphics scene:1 - viewer:1")
23 waitFor("object.exists(':SALOME *_GraphicsView_ViewPort')", 20000)
24 test.compare(findObject(":SALOME *_GraphicsView_ViewPort").visible, True)
25 clickTab(waitForObject(":SALOME *_QtxWorkstackTabBar"), "OCC scene:1 - viewer:1")
27 #--------------------------------------------------------------------------
29 #--------------------------------------------------------------------------
31 Hide all objects displayed in the current OCC view.
34 activateOCCViewerContextMenuItem(100, 100, "Hide all")
36 #--------------------------------------------------------------------------
38 #--------------------------------------------------------------------------
39 def importBathymetry(filePath, bathName=None, isToInvert=False):
40 # Call "Import bathymetry" panel
41 type(waitForObject(":SALOME_STD_TabDesktop"), "<Ctrl+B>")
44 bath_panel = waitForObject(":SALOME *.Import bathymetry_HYDROGUI_ImportBathymetryDlg")
45 test.compare(bath_panel.windowTitle, "Import bathymetry")
48 clickButton(waitForObject(":Import bathymetry from file_QToolButton"))
49 type(waitForObject(":fileNameEdit_QLineEdit"), filePath)
50 clickButton(waitForObject(":Import bathymetry.Open_QPushButton"))
52 # Set "Invert altitude values" option
53 invertCheckBox = waitForObject(":Import bathymetry.Invert altitude values_QCheckBox")
54 setButtonChecked(invertCheckBox, isToInvert)
57 if bathName is not None:
58 type(waitForObject(":Bathymetry name.Name_QLineEdit"), "<Ctrl+A>")
59 type(waitForObject(":Bathymetry name.Name_QLineEdit"), bathName)
62 clickButton(waitForObject(":Import bathymetry.Apply_QPushButton"))
64 #--------------------------------------------------------------------------
66 #--------------------------------------------------------------------------
68 Add spline section to the polyline.
70 def addSection(isSpline, isClosed):
72 clickButton(waitForObject(":Sections.New section_QToolButton"))
75 sectionType = "Polyline"
77 sectionType = "Spline"
79 combo = waitForObject(":Add element.Type_QComboBox")
80 selectComboBoxItem(combo, sectionType)
83 closedCheckBox = waitForObject(":Add element.Closed_QCheckBox")
84 setButtonChecked(closedCheckBox, isClosed)
87 clickButton(waitForObject(":Add element.Add_QPushButton"))
90 Add spline section to the polyline.
92 def addSplineSection(isClosed):
93 addSection(True, isClosed)
96 Add polyline (not spline) section to the polyline.
98 def addPolylineSection(isClosed):
99 addSection(False, isClosed)
102 Add points to the polyline.
103 For example: addPolylinePoints([(621, 298), (571, 347), (620, 399)])
105 def addPolylinePoints(points):
106 # Turn addition mode on
107 additionModeButton = waitForObject(":Sections.Addition mode_QToolButton")
108 setButtonChecked(additionModeButton, True)
110 # Add points by clicking in OCC viewer
111 occViewer = waitForObject(":SALOME *.3D View Operations_OCCViewer_ViewPort3d")
113 mouseClick(occViewer, pnt[0], pnt[1], 0, Qt.LeftButton)