Salome HOME
Merge branch 'BR_v14_rc' of ssh://git.salome-platform.org/modules/hydro into BR_v14_rc
[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 hideAll():
34     activateOCCViewerContextMenuItem(100, 100, "Hide all")
35
36 #--------------------------------------------------------------------------
37 # Bathymetry
38 #--------------------------------------------------------------------------
39 def importBathymetry(filePath, bathName=None, isToInvert=False):
40     # Call "Import bathymetry" panel
41     type(waitForObject(":SALOME_STD_TabDesktop"), "<Ctrl+B>")
42     
43     # Check panel
44     bath_panel = waitForObject(":SALOME *.Import bathymetry_HYDROGUI_ImportBathymetryDlg")
45     test.compare(bath_panel.windowTitle, "Import bathymetry")
46     
47     # Set file name
48     clickButton(waitForObject(":Import bathymetry from file_QToolButton"))
49     type(waitForObject(":fileNameEdit_QLineEdit"), filePath)
50     clickButton(waitForObject(":Import bathymetry.Open_QPushButton"))
51
52     # Set "Invert altitude values" option
53     invertCheckBox = waitForObject(":Import bathymetry.Invert altitude values_QCheckBox")
54     setButtonChecked(invertCheckBox, isToInvert)
55     
56     # Set bathymetry name
57     if bathName is not None:
58         type(waitForObject(":Bathymetry name.Name_QLineEdit"), "<Ctrl+A>")
59         type(waitForObject(":Bathymetry name.Name_QLineEdit"), bathName)
60
61     # Click Apply
62     clickButton(waitForObject(":Import bathymetry.Apply_QPushButton"))
63
64 #--------------------------------------------------------------------------
65 # Polyline
66 #--------------------------------------------------------------------------   
67 """
68 Add spline section to the polyline.
69 """
70 def addSection(isSpline, isClosed):
71     # New section
72     clickButton(waitForObject(":Sections.New section_QToolButton"))
73     
74     # Choose type
75     sectionType = "Polyline"
76     if isSpline:
77         sectionType = "Spline"   
78     
79     combo = waitForObject(":Add element.Type_QComboBox")
80     selectComboBoxItem(combo, sectionType)
81
82     # Set closed property
83     closedCheckBox = waitForObject(":Add element.Closed_QCheckBox")
84     setButtonChecked(closedCheckBox, isClosed)
85     
86     # Click add button
87     clickButton(waitForObject(":Add element.Add_QPushButton"))
88
89 """
90 Add spline section to the polyline.
91 """
92 def addSplineSection(isClosed):
93     addSection(True, isClosed)
94
95 """
96 Add polyline (not spline) section to the polyline.
97 """
98 def addPolylineSection(isClosed):
99     addSection(False, isClosed)
100
101 """
102 Add points to the polyline.
103 For example: addPolylinePoints([(621, 298), (571, 347), (620, 399)])
104 """    
105 def addPolylinePoints(points):
106     # Turn addition mode on
107     additionModeButton = waitForObject(":Sections.Addition mode_QToolButton")
108     setButtonChecked(additionModeButton, True)
109     
110     # Add points by clicking in OCC viewer
111     occViewer = waitForObject(":SALOME *.3D View Operations_OCCViewer_ViewPort3d")
112     for pnt in points:
113         mouseClick(occViewer, pnt[0], pnt[1], 0, Qt.LeftButton)
114