mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-11 16:19:17 +05:00
[bos #38044][EDF] (2023-T3) Support for automatic reparation. Added sub-shapes line edit to a base dialog.
This commit is contained in:
parent
8691b29f7c
commit
b50c37ed81
@ -35,7 +35,7 @@ from .basedlg_ui import Ui_BaseDlg
|
||||
from .geomrepairadv_execute import execute
|
||||
from .geomrepairadv_logger import logger
|
||||
from .geomrepairadv_common import DlgRef_1Sel_QTD, \
|
||||
GEOM_RESULT_NAME_GRP, NAME_LBL, GEOM_SELECTED_LBL, GEOM_SELECTED_SHAPE
|
||||
GEOM_RESULT_NAME_GRP, NAME_LBL, GEOM_SELECTED_LBL, GEOM_SELECTED_SHAPE, GEOM_SELECTED_SUBSHAPE
|
||||
import GEOM
|
||||
|
||||
class BaseDlg(Ui_BaseDlg, QWidget):
|
||||
@ -94,6 +94,9 @@ class BaseDlg(Ui_BaseDlg, QWidget):
|
||||
self._selected_widget.TextLabel1.setText(GEOM_SELECTED_SHAPE)
|
||||
self._selected_widget.PushButton1.clicked.connect(self.on_select_object)
|
||||
|
||||
# A widget to show selected sub-shapes
|
||||
self._sel_subshape_widget = self.create_sel_subshape_widget()
|
||||
|
||||
# Keep references to selected object and its temporary copy
|
||||
# that we need to pass for execution instead of original one.
|
||||
# TODO: decide if we really need to pass a copy.
|
||||
@ -105,8 +108,9 @@ class BaseDlg(Ui_BaseDlg, QWidget):
|
||||
self.child_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.child_layout.addWidget(self._result_widget, 0, 0)
|
||||
self.child_layout.addWidget(self._selected_widget, 1, 0)
|
||||
self.child_layout.addWidget(self._sel_subshape_widget, 2, 0)
|
||||
if child_widget:
|
||||
self.child_layout.addWidget(child_widget, 2, 0)
|
||||
self.child_layout.addWidget(child_widget, 3, 0)
|
||||
|
||||
# Set basic button's actions
|
||||
self.buttonOk.clicked.connect(self.on_apply_close)
|
||||
@ -133,6 +137,8 @@ class BaseDlg(Ui_BaseDlg, QWidget):
|
||||
self._sel_manager = salome_pyqt.getSelection()
|
||||
self._sel_connection = \
|
||||
self._sel_manager.currentSelectionChanged.connect(self.on_select_object)
|
||||
self._sel_subshape_connection = \
|
||||
self._sel_manager.currentSelectionChanged.connect(self.on_select_subshape)
|
||||
|
||||
# Check if we already have selected object
|
||||
self.on_select_object()
|
||||
@ -386,6 +392,40 @@ class BaseDlg(Ui_BaseDlg, QWidget):
|
||||
return True
|
||||
|
||||
|
||||
def create_sel_subshape_widget(self):
|
||||
"""
|
||||
Returns a widget that lists preliminarily selected for processing sub_shapes.
|
||||
|
||||
Args:
|
||||
None.
|
||||
|
||||
Returns:
|
||||
A new widget.
|
||||
"""
|
||||
|
||||
sel_subshape_widget = DlgRef_1Sel_QTD()
|
||||
sel_subshape_widget.TextLabel1.setText(GEOM_SELECTED_SUBSHAPE)
|
||||
sel_subshape_widget.PushButton1.clicked.connect(self.on_select_subshape)
|
||||
|
||||
return sel_subshape_widget
|
||||
|
||||
|
||||
def on_select_subshape(self):
|
||||
"""
|
||||
Updates pre selected widget.
|
||||
|
||||
Args:
|
||||
None.
|
||||
|
||||
Returns:
|
||||
None.
|
||||
"""
|
||||
|
||||
selected_ids = self.get_local_selection()
|
||||
selected_ids_str = ', '.join(str(id) for id in selected_ids)
|
||||
self._sel_subshape_widget.LineEdit1.setText(selected_ids_str)
|
||||
|
||||
|
||||
def closeEvent(self, event):
|
||||
"""
|
||||
Overrides default close envent to reset selection level.
|
||||
@ -395,6 +435,7 @@ class BaseDlg(Ui_BaseDlg, QWidget):
|
||||
|
||||
# Clean up all selection changes
|
||||
self._sel_manager.currentSelectionChanged.disconnect(self._sel_connection)
|
||||
self._sel_manager.currentSelectionChanged.disconnect(self._sel_subshape_connection)
|
||||
self.set_selection(None)
|
||||
|
||||
|
||||
|
@ -26,8 +26,7 @@ from qtsalome import QGridLayout, QFrame, QApplication, \
|
||||
|
||||
from salome.geom.geomrepairadv.basedlg import BaseDlg
|
||||
|
||||
from .geomrepairadv_common import DlgRef_1Spin_QTD, DlgRef_1Sel_QTD, \
|
||||
GEOM_SELECTED_SUBSHAPE
|
||||
from .geomrepairadv_common import DlgRef_1Spin_QTD
|
||||
import GEOM
|
||||
|
||||
class LocateSubShapesDlg(BaseDlg):
|
||||
@ -49,9 +48,6 @@ class LocateSubShapesDlg(BaseDlg):
|
||||
self._type_widget.setToolTip('Select a type of shape measurement')
|
||||
self._type_widget.currentIndexChanged.connect(self.on_measurment_type_changed)
|
||||
|
||||
# A widget to show preliminarily selected sub-shapes
|
||||
self._pre_selected_widget = self.create_pre_selected_widget()
|
||||
|
||||
# Min/max values widgets
|
||||
decimals = 2
|
||||
max_value = sys.float_info.max
|
||||
@ -65,10 +61,9 @@ class LocateSubShapesDlg(BaseDlg):
|
||||
# Add the widgets to layout
|
||||
layout.addWidget(type_label, 0, 0)
|
||||
layout.addWidget(self._type_widget, 1, 0)
|
||||
layout.addWidget(self._pre_selected_widget, 2, 0)
|
||||
layout.addWidget(self._min_widget, 3, 0)
|
||||
layout.addWidget(self._max_widget, 4, 0)
|
||||
layout.addWidget(self._select_button, 5, 0)
|
||||
layout.addWidget(self._min_widget, 2, 0)
|
||||
layout.addWidget(self._max_widget, 3, 0)
|
||||
layout.addWidget(self._select_button, 4, 0)
|
||||
|
||||
# Init base dialog
|
||||
BaseDlg.__init__(
|
||||
@ -80,45 +75,6 @@ class LocateSubShapesDlg(BaseDlg):
|
||||
selection_level
|
||||
)
|
||||
|
||||
# Connect selection manager from a base class
|
||||
self._sel_subshape_connection = \
|
||||
self._sel_manager.currentSelectionChanged.connect(self.on_select_subshape)
|
||||
|
||||
|
||||
def create_pre_selected_widget(self):
|
||||
"""
|
||||
Returns a widget that lists preliminarily selected for processing sub_shapes.
|
||||
|
||||
Args:
|
||||
None.
|
||||
|
||||
Returns:
|
||||
A new widget.
|
||||
"""
|
||||
|
||||
pre_sel_widget = DlgRef_1Sel_QTD()
|
||||
pre_sel_widget.TextLabel1.setText(GEOM_SELECTED_SUBSHAPE)
|
||||
pre_sel_widget.PushButton1.clicked.connect(self.on_select_subshape)
|
||||
|
||||
return pre_sel_widget
|
||||
|
||||
|
||||
def on_select_subshape(self):
|
||||
"""
|
||||
Updates pre selected widget.
|
||||
|
||||
Args:
|
||||
None.
|
||||
|
||||
Returns:
|
||||
None.
|
||||
"""
|
||||
|
||||
selected_ids = self.get_local_selection()
|
||||
selected_ids_str = ', '.join(str(id) for id in selected_ids)
|
||||
self._pre_selected_widget.LineEdit1.setText(selected_ids_str)
|
||||
|
||||
|
||||
|
||||
def get_limits(self):
|
||||
"""
|
||||
@ -218,17 +174,6 @@ class LocateSubShapesDlg(BaseDlg):
|
||||
return None
|
||||
|
||||
|
||||
def closeEvent(self, event):
|
||||
"""
|
||||
Overrides default close envent to reset selection level.
|
||||
"""
|
||||
|
||||
super().closeEvent(event)
|
||||
|
||||
# Clean up all selection changes
|
||||
self._sel_manager.currentSelectionChanged.disconnect(self._sel_subshape_connection)
|
||||
|
||||
|
||||
# For testing run as a module from geomrepairadv parent directory in
|
||||
# Salome INSTALL, because the dialog needs a generated Ui_BaseDlg class
|
||||
# that we don't have in the SOURCE.
|
||||
|
@ -43,6 +43,8 @@ class SubShapesBaseDlg(BaseDlg):
|
||||
|
||||
# Precision widget
|
||||
self._precision_widget = DlgRef_1Spin_QTD('Precision', 0, 2, 100)
|
||||
|
||||
# Add the widgets to layout
|
||||
layout.addWidget(self._precision_widget, 0, 0)
|
||||
|
||||
BaseDlg.__init__(
|
||||
|
Loading…
Reference in New Issue
Block a user