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")
37 Show all objects in the current OCC view.
40 activateOCCViewerContextMenuItem(100, 100, "Show all")
43 Hide all objects displayed in the current VTK view.
46 activateVTKContextMenuItem(100, 100, "Hide all")
49 Show all objects in the current VTK view.
52 activateVTKContextMenuItem(100, 100, "Show all")
54 #--------------------------------------------------------------------------
56 #--------------------------------------------------------------------------
57 def importBathymetry(filePath, bathName=None, isToInvert=False):
59 type(waitForObject(":SALOME_STD_TabDesktop"), "<Ctrl+B>")
61 # "Import bathymetry" panel appears
62 bath_panel = waitForObject(":SALOME *.Import bathymetry_HYDROGUI_ImportBathymetryDlg")
63 test.compare(bath_panel.windowTitle, "Import bathymetry")
65 # Click "Open file" icon
66 clickButton(waitForObject(":Import bathymetry from file_QToolButton"))
68 # "Import bathymetry from file" dialog appears
69 open_file_dlg = waitForObject(":Import bathymetry from file_SUIT_FileDlg")
70 test.compare(str(open_file_dlg.windowTitle), "Import bathymetry from file")
72 # Set bathymetry file path
73 type(waitForObject(":fileNameEdit_QLineEdit"), filePath)
76 clickButton(waitForObject(":Import bathymetry.Open_QPushButton"))
78 # Set "Invert altitude values" option
79 invertCheckBox = waitForObject(":Import bathymetry.Invert altitude values_QCheckBox")
80 setButtonChecked(invertCheckBox, isToInvert)
83 if bathName is not None:
84 type(waitForObject(":Bathymetry name.Name_QLineEdit"), "<Ctrl+A>")
85 type(waitForObject(":Bathymetry name.Name_QLineEdit"), bathName)
88 clickButton(waitForObject(":Import bathymetry.Apply_QPushButton"))
90 #--------------------------------------------------------------------------
92 #--------------------------------------------------------------------------
94 Add spline section to the polyline.
96 def addSection(isSpline, isClosed):
98 clickButton(waitForObject(":Sections.New section_QToolButton"))
101 sectionType = "Polyline"
103 sectionType = "Spline"
105 combo = waitForObject(":Add element.Type_QComboBox")
106 selectComboBoxItem(combo, sectionType)
108 # Set closed property
109 closedCheckBox = waitForObject(":Add element.Closed_QCheckBox")
110 setButtonChecked(closedCheckBox, isClosed)
113 clickButton(waitForObject(":Add element.Add_QPushButton"))
116 Add spline section to the polyline.
118 def addSplineSection(isClosed):
119 addSection(True, isClosed)
122 Add polyline (not spline) section to the polyline.
124 def addPolylineSection(isClosed):
125 addSection(False, isClosed)
128 Add points to the polyline.
129 For example: addPolylinePoints([(621, 298), (571, 347), (620, 399)])
131 def addPolylinePoints(points):
132 # Turn addition mode on
133 additionModeButton = waitForObject(":Sections.Addition mode_QToolButton")
134 setButtonChecked(additionModeButton, True)
136 # Add points by clicking in OCC viewer
137 occMouseClicks(points)
140 #--------------------------------------------------------------------------
142 #--------------------------------------------------------------------------
144 Get status bar message.
146 def getStatusMessage():
147 statusBar = waitForObject(":SALOME *_QStatusBar")
148 return str(statusBar.currentMessage())
151 Get local coordinates from the status bar as a tuple of floats (x, y).
153 def getLocalCoordinates():
157 msg = getStatusMessage()
159 if msg.find("Local") > 0:
160 lmsg = msg.split("(")[1].split(")")[0]
161 (x,y) = msg.split(",")
162 (x,y) = (float(x), float(y))
167 Get global coordinates from the status bar as a tuple of floats (x, y).
169 def getGlobalCoordinates():
173 msg = getStatusMessage()
175 if msg.find("Global") > 0:
176 lmsg = msg.split("(")[2].split(")")[0]
177 (x,y) = msg.split(",")
178 (x,y) = (float(x), float(y))