mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-11 16:19:17 +05:00
[bos #35148][EDF] (2023-T1) Evaluation of PySide. Update t_shape dialog and uic file compilation for testing SalomePyQt methods.
This commit is contained in:
parent
f7a34e7081
commit
7808f71cac
@ -66,6 +66,7 @@ OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
|
|||||||
|
|
||||||
# Advanced options:
|
# Advanced options:
|
||||||
OPTION(SALOME_BUILD_GUI "Enable GUI" ON)
|
OPTION(SALOME_BUILD_GUI "Enable GUI" ON)
|
||||||
|
OPTION(SALOME_USE_PYSIDE "Use PySide2 to create Python bindings for Qt" ON)
|
||||||
CMAKE_DEPENDENT_OPTION(SALOME_GEOM_USE_OPENCV "Enable shape recognition from picture" OFF
|
CMAKE_DEPENDENT_OPTION(SALOME_GEOM_USE_OPENCV "Enable shape recognition from picture" OFF
|
||||||
"SALOME_BUILD_GUI" OFF)
|
"SALOME_BUILD_GUI" OFF)
|
||||||
CMAKE_DEPENDENT_OPTION(SALOME_GEOM_USE_VTK "Enable VTK-dependent functionality" ON
|
CMAKE_DEPENDENT_OPTION(SALOME_GEOM_USE_VTK "Enable VTK-dependent functionality" ON
|
||||||
|
@ -43,7 +43,77 @@ IF(SALOME_BUILD_GUI)
|
|||||||
)
|
)
|
||||||
|
|
||||||
# scripts / pyuic wrappings
|
# scripts / pyuic wrappings
|
||||||
|
IF(SALOME_USE_PYSIDE)
|
||||||
|
|
||||||
|
MESSAGE(STATUS "SALOME_USE_PYSIDE is defined. Start compilation with PySide2.")
|
||||||
|
|
||||||
|
# ========================== Find PySide2 uic compiler =================
|
||||||
|
|
||||||
|
# In Qt for Python 5.14.0 pyside2-uic/pyside2-rcc was replaced by uic/rcc
|
||||||
|
# which now have an option to generate Python.
|
||||||
|
# So, the stuff below will work only with Qt for Python >= 5.14.0
|
||||||
|
SET(uic_compiler_names
|
||||||
|
uic
|
||||||
|
)
|
||||||
|
|
||||||
|
SET(uic_compiler_hints
|
||||||
|
/usr/bin/uic
|
||||||
|
)
|
||||||
|
|
||||||
|
FIND_PROGRAM(uic_compiler NAMES ${uic_compiler_names} HINTS ${uic_compiler_hints})
|
||||||
|
IF(uic_compiler)
|
||||||
|
MESSAGE(STATUS "Found PySide2 uic tool: ${uic_compiler}")
|
||||||
|
ELSE()
|
||||||
|
MESSAGE(FATAL_ERROR "Couldn't find PySide2 uic tool!")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
# ========================== Generate Python class for each uic file =================
|
||||||
|
|
||||||
|
SET(_pyuic_SCRIPTS)
|
||||||
|
SET(_target_name_pyuic)
|
||||||
|
SET(uic_options -g python)
|
||||||
|
|
||||||
|
FOREACH(uic_infile ${_pyuic_FILES})
|
||||||
|
|
||||||
|
# Make a file name
|
||||||
|
GET_FILENAME_COMPONENT(uic_outfile ${uic_infile} NAME)
|
||||||
|
STRING(REPLACE ".ui" "_ui.py" uic_outfile ${uic_outfile})
|
||||||
|
SET(uic_outfile ${CMAKE_CURRENT_BINARY_DIR}/${uic_outfile})
|
||||||
|
|
||||||
|
# We need to use absolute path for a command
|
||||||
|
SET(uic_infile ${CMAKE_CURRENT_SOURCE_DIR}/${uic_infile})
|
||||||
|
|
||||||
|
SET(uic_command_options ${uic_options} -o ${uic_outfile} ${uic_infile})
|
||||||
|
MESSAGE(STATUS "uic_command_options: ${uic_command_options}")
|
||||||
|
|
||||||
|
# Create a command to call uic
|
||||||
|
ADD_CUSTOM_COMMAND(
|
||||||
|
OUTPUT ${uic_outfile}
|
||||||
|
COMMAND ${uic_compiler} ${uic_command_options}
|
||||||
|
MAIN_DEPENDENCY ${uic_infile}
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set additional properties
|
||||||
|
SET_SOURCE_FILES_PROPERTIES(${uic_infile} PROPERTIES SKIP_AUTOUIC ON)
|
||||||
|
SET_SOURCE_FILES_PROPERTIES(${uic_outfile} PROPERTIES SKIP_AUTOMOC ON)
|
||||||
|
SET_SOURCE_FILES_PROPERTIES(${uic_outfile} PROPERTIES SKIP_AUTOUIC ON)
|
||||||
|
|
||||||
|
# Save the result
|
||||||
|
LIST(APPEND _pyuic_SCRIPTS ${uic_outfile})
|
||||||
|
MESSAGE(STATUS "_pyuic_SCRIPTS: ${_pyuic_SCRIPTS}")
|
||||||
|
|
||||||
|
# Make target name the same way as for PyQt
|
||||||
|
_PYQT_WRAP_GET_UNIQUE_TARGET_NAME(BUILD_UI_PY_FILES _target_name_pyuic_cur)
|
||||||
|
ADD_CUSTOM_TARGET(${_target_name_pyuic_cur} ALL DEPENDS ${${_pyuic_SCRIPTS}})
|
||||||
|
|
||||||
|
LIST(APPEND _target_name_pyuic ${_target_name_pyuic_cur})
|
||||||
|
|
||||||
|
ENDFOREACH()
|
||||||
|
|
||||||
|
ELSE()
|
||||||
PYQT_WRAP_UIC(_pyuic_SCRIPTS ${_pyuic_FILES} TARGET_NAME _target_name_pyuic)
|
PYQT_WRAP_UIC(_pyuic_SCRIPTS ${_pyuic_FILES} TARGET_NAME _target_name_pyuic)
|
||||||
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# --- rules ---
|
# --- rules ---
|
||||||
|
@ -20,7 +20,18 @@
|
|||||||
# Author : Renaud Nédélec (OpenCascade S.A.S)
|
# Author : Renaud Nédélec (OpenCascade S.A.S)
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from qtsalome import *
|
import os
|
||||||
|
|
||||||
|
# PySide testing
|
||||||
|
import SalomePyQt
|
||||||
|
|
||||||
|
# Check if SalomePyQt uses PySide2
|
||||||
|
use_pyside = False
|
||||||
|
if hasattr(SalomePyQt, 'use_pyside'):
|
||||||
|
from PySide2.QtWidgets import QWidget, QApplication
|
||||||
|
use_pyside = True
|
||||||
|
else:
|
||||||
|
from qtsalome import *
|
||||||
|
|
||||||
from salome.geom.t_shape.t_shape_dialog_ui import Ui_Dialog
|
from salome.geom.t_shape.t_shape_dialog_ui import Ui_Dialog
|
||||||
|
|
||||||
@ -40,6 +51,31 @@ class TShapeDialog(Ui_Dialog,QWidget):
|
|||||||
self.dsb_bigHeight.setValue(80.0)
|
self.dsb_bigHeight.setValue(80.0)
|
||||||
self.dsb_smallHeight.setValue(80.0)
|
self.dsb_smallHeight.setValue(80.0)
|
||||||
|
|
||||||
|
# PySide testing
|
||||||
|
self.dsb_getFileNameBtn.clicked.connect(self.get_file_name)
|
||||||
|
self.set_qt_bindings()
|
||||||
|
|
||||||
|
def get_file_name(self):
|
||||||
|
"""
|
||||||
|
Updates displayed file name for testing PySide integration.
|
||||||
|
"""
|
||||||
|
|
||||||
|
salome_py_qt = SalomePyQt.SalomePyQt()
|
||||||
|
filename = salome_py_qt.getFileName(self, os.path.expanduser("~"), [], self.tr("Testing getting a file name with PySide"), True)
|
||||||
|
if not filename:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.dsb_fileName.setText(filename)
|
||||||
|
|
||||||
|
def set_qt_bindings(self):
|
||||||
|
"""
|
||||||
|
Returns a name of packaged that used for Qt bindings.
|
||||||
|
This function is only for testing PySide integration.
|
||||||
|
"""
|
||||||
|
|
||||||
|
qt_bindings = 'PySide2' if use_pyside else 'PyQt5'
|
||||||
|
self.dsb_qt_bindings_value.setText(qt_bindings)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
from salome.geom.t_shape import t_shape_progress
|
from salome.geom.t_shape import t_shape_progress
|
||||||
import xalome
|
import xalome
|
||||||
@ -72,6 +108,21 @@ class TShapeDialog(Ui_Dialog,QWidget):
|
|||||||
return self._wasOk
|
return self._wasOk
|
||||||
|
|
||||||
__dialog=None
|
__dialog=None
|
||||||
|
|
||||||
|
def update_pyside(dialog):
|
||||||
|
"""
|
||||||
|
This function updates displayed data for testing PySide integration.
|
||||||
|
"""
|
||||||
|
salome_py_qt = SalomePyQt.SalomePyQt()
|
||||||
|
|
||||||
|
# Main frame width
|
||||||
|
main_frame_width = salome_py_qt.getMainFrame().width()
|
||||||
|
dialog.dsb_widthMainFrameValue.setText(str(main_frame_width))
|
||||||
|
|
||||||
|
# Components
|
||||||
|
components = salome_py_qt.getComponents()
|
||||||
|
dialog.dsb_components.addItems(components)
|
||||||
|
|
||||||
def getDialog():
|
def getDialog():
|
||||||
"""
|
"""
|
||||||
This function returns a singleton instance of the plugin dialog.
|
This function returns a singleton instance of the plugin dialog.
|
||||||
@ -80,6 +131,8 @@ def getDialog():
|
|||||||
global __dialog
|
global __dialog
|
||||||
if __dialog is None:
|
if __dialog is None:
|
||||||
__dialog = TShapeDialog()
|
__dialog = TShapeDialog()
|
||||||
|
|
||||||
|
update_pyside(__dialog)
|
||||||
return __dialog
|
return __dialog
|
||||||
|
|
||||||
# ================
|
# ================
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>349</width>
|
<width>349</width>
|
||||||
<height>283</height>
|
<height>524</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -98,15 +98,18 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="3" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<item row="0" column="0">
|
<property name="orientation">
|
||||||
<widget class="QCheckBox" name="cb_buildSolid">
|
<enum>Qt::Horizontal</enum>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Build solid part</string>
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -127,18 +130,103 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QCheckBox" name="cb_buildSolid">
|
||||||
|
<property name="text">
|
||||||
|
<string>Build solid part</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<layout class="QGridLayout" name="gridLayout_PySide">
|
||||||
|
<item row="5" column="0" colspan="2">
|
||||||
|
<widget class="QListWidget" name="dsb_components"/>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="dsb_fileName">
|
||||||
|
<property name="text">
|
||||||
|
<string>Initial value</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0" colspan="2">
|
||||||
|
<widget class="QPushButton" name="dsb_getFileNameBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Get File Name</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="SalomePyQt_title">
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">SalomePyQt testing</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
</widget>
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="widthMainFrameTitle">
|
||||||
|
<property name="text">
|
||||||
|
<string>Width main frame (px):</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLabel" name="dsb_widthMainFrameValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>Initial value</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="qt_bindings_title">
|
||||||
|
<property name="text">
|
||||||
|
<string>Qt bindings package:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="dsb_qt_bindings_value">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
Loading…
Reference in New Issue
Block a user