]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
[bos #38044][EDF] (2023-T3) Support for automatic reparation. Added sub-shapes line...
authorKonstantin Leontev <Konstantin.LEONTEV@opencascade.com>
Mon, 25 Mar 2024 19:11:15 +0000 (19:11 +0000)
committerDUC ANH HOANG <dh77501n@dsp1043837>
Thu, 23 May 2024 11:58:25 +0000 (13:58 +0200)
src/RepairGUIAdv/basedlg.py
src/RepairGUIAdv/locate_subshapes.py
src/RepairGUIAdv/subshapes_basedlg.py

index 1f92af5edaf1d9731fec3d11c37016b13c5f2703..484401886f61a3061298b1b98e0301e35cf7c083 100644 (file)
@@ -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)
 
 
index 2388cfdb82f913afd356fcd4d13bfed5df19bdd3..21cc090a5cfb88f8fb9c58477a70788ca148e3d2 100644 (file)
@@ -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.
index 7608a9cc9ea6da0bea9cbde433e118f14f16612a..e309fb909e3f9aed34afadb281151b37a3a5dd1d 100644 (file)
@@ -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__(