]> SALOME platform Git repositories - modules/hydro.git/blob - squish.suite/shared/scripts/common_hydro.py
Salome HOME
Corrections of examples path after install with scbi
[modules/hydro.git] / squish.suite / shared / scripts / common_hydro.py
1 """Common functions for HYDRO module"""
2 import os
3 import datetime, time
4
5 source(os.path.join(os.getenv("COMMON_SCRIPT_DIR"), "common.py"))
6
7
8 #--------------------------------------------------------------------------
9 # HYDRO module activation
10 #--------------------------------------------------------------------------
11 """
12 Activate HYDRO module via toolbar and check that OB, Graphics viewer and OCC Viewer are created
13 """  
14 def activateHYDRO():
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")
26
27 #--------------------------------------------------------------------------
28 # Show/hide
29 #--------------------------------------------------------------------------
30 """
31 Hide all objects displayed in the current OCC view.
32 """
33 def occHideAll():
34     activateOCCViewerContextMenuItem(100, 100, "Hide all")
35     
36 """
37 Show all objects in the current OCC view.
38 """
39 def occShowAll():
40     activateOCCViewerContextMenuItem(100, 100, "Show all")
41     
42 """
43 Hide all objects displayed in the current VTK view.
44 """
45 def vtkHideAll():
46     activateVTKContextMenuItem(100, 100, "Hide all")
47     
48 """
49 Show all objects in the current VTK view.
50 """
51 def vtkShowAll():
52     activateVTKContextMenuItem(100, 100, "Show all")
53
54 #--------------------------------------------------------------------------
55 # Bathymetry
56 #--------------------------------------------------------------------------
57 def importBathymetry(filePath, bathName=None, isToInvert=False):
58     # Click Ctrl+B
59     type(waitForObject(":SALOME_STD_TabDesktop"), "<Ctrl+B>")
60     
61     # "Import bathymetry" panel appears
62     bath_panel = waitForObject(":SALOME *.Import bathymetry_HYDROGUI_ImportBathymetryDlg")
63     test.compare(bath_panel.windowTitle, "Import bathymetry")
64     
65     # Click "Open file" icon 
66     clickButton(waitForObject(":Import bathymetry from file_QToolButton"))
67     
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")
71     
72     # Set bathymetry file path
73     type(waitForObject(":fileNameEdit_QLineEdit"), filePath)
74     
75     # Click "Open" button
76     clickButton(waitForObject(":Import bathymetry.Open_QPushButton"))
77
78     # Set "Invert altitude values" option
79     invertCheckBox = waitForObject(":Import bathymetry.Invert altitude values_QCheckBox")
80     setButtonChecked(invertCheckBox, isToInvert)
81     
82     # Set bathymetry name
83     if bathName is not None:
84         type(waitForObject(":Bathymetry name.Name_QLineEdit"), "<Ctrl+A>")
85         type(waitForObject(":Bathymetry name.Name_QLineEdit"), bathName)
86
87     # Click Apply
88     clickButton(waitForObject(":Import bathymetry.Apply_QPushButton"))
89
90 #--------------------------------------------------------------------------
91 # Polyline
92 #--------------------------------------------------------------------------   
93 """
94 Add spline section to the polyline.
95 """
96 def addSection(isSpline, isClosed):
97     # New section
98     clickButton(waitForObject(":Sections.New section_QToolButton"))
99     
100     # Choose type
101     sectionType = "Polyline"
102     if isSpline:
103         sectionType = "Spline"   
104     
105     combo = waitForObject(":Add element.Type_QComboBox")
106     selectComboBoxItem(combo, sectionType)
107
108     # Set closed property
109     closedCheckBox = waitForObject(":Add element.Closed_QCheckBox")
110     setButtonChecked(closedCheckBox, isClosed)
111     
112     # Click add button
113     clickButton(waitForObject(":Add element.Add_QPushButton"))
114
115 """
116 Add spline section to the polyline.
117 """
118 def addSplineSection(isClosed):
119     addSection(True, isClosed)
120
121 """
122 Add polyline (not spline) section to the polyline.
123 """
124 def addPolylineSection(isClosed):
125     addSection(False, isClosed)
126
127 """
128 Add points to the polyline.
129 For example: addPolylinePoints([(621, 298), (571, 347), (620, 399)])
130 """    
131 def addPolylinePoints(points):
132     # Turn addition mode on
133     additionModeButton = waitForObject(":Sections.Addition mode_QToolButton")
134     setButtonChecked(additionModeButton, True)
135     
136     # Add points by clicking in OCC viewer
137     occMouseClicks(points)
138
139     
140 #--------------------------------------------------------------------------
141 # Coordinate system
142 #--------------------------------------------------------------------------
143 """
144 Get status bar message.
145 """
146 def getStatusMessage():
147     statusBar = waitForObject(":SALOME *_QStatusBar")
148     return str(statusBar.currentMessage())
149    
150 """
151 Get local coordinates from the status bar as a tuple of floats (x, y).
152 """
153 def getLocalCoordinates():
154     x = None
155     y = None
156     
157     msg = getStatusMessage()
158     
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))
163         
164     return (x, y)
165
166 """
167 Get global coordinates from the status bar as a tuple of floats (x, y).
168 """
169 def getGlobalCoordinates():
170     x = None
171     y = None
172     
173     msg = getStatusMessage()
174     
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))
179         
180     return (x, y)
181         
182     
183