mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-13 10:10:34 +05:00
[bos #38044][EDF] (2023-T3) Support for automatic reparation. User friendly selection.
This commit is contained in:
parent
8833db2ff1
commit
3515468630
@ -29,6 +29,7 @@ from salome.kernel.studyedit import EDITOR
|
||||
from salome.kernel.services import IDToObject
|
||||
from salome.geom import geomBuilder
|
||||
from libGEOM_Swig import GEOM_Swig
|
||||
import SalomePyQt
|
||||
|
||||
from .basedlg_ui import Ui_BaseDlg
|
||||
from .geomrepairadv_execute import execute
|
||||
@ -124,6 +125,14 @@ class BaseDlg(Ui_BaseDlg, QWidget):
|
||||
|
||||
# Default selection level
|
||||
self._selection_level = selection_level
|
||||
self._is_level_changed = False
|
||||
self._is_local_selection = False
|
||||
|
||||
# Connect selection manager
|
||||
salome_pyqt = SalomePyQt.SalomePyQt()
|
||||
self._sel_manager = salome_pyqt.getSelection()
|
||||
self._sel_connection = \
|
||||
self._sel_manager.currentSelectionChanged.connect(self.on_select_object)
|
||||
|
||||
# Check if we already have selected object
|
||||
self.on_select_object()
|
||||
@ -248,6 +257,12 @@ class BaseDlg(Ui_BaseDlg, QWidget):
|
||||
None.
|
||||
"""
|
||||
|
||||
# Set the flag to process local selection properly
|
||||
if self._selection_level == selection_level:
|
||||
self._is_level_changed = False
|
||||
else:
|
||||
self._is_level_changed = True
|
||||
|
||||
self._selection_level = selection_level
|
||||
|
||||
# Update selection for current object
|
||||
@ -270,14 +285,27 @@ class BaseDlg(Ui_BaseDlg, QWidget):
|
||||
|
||||
geom_swig = GEOM_Swig()
|
||||
|
||||
# Resets selection level
|
||||
geom_swig.closeLocalSelection()
|
||||
|
||||
# Set level of selection for specific entry
|
||||
if entry:
|
||||
sel_level = geomBuilder.EnumToLong(self._selection_level)
|
||||
geom_swig.initLocalSelection(entry, sel_level)
|
||||
# Init it again if the level was changed
|
||||
if self._is_level_changed:
|
||||
geom_swig.closeLocalSelection()
|
||||
self._is_local_selection = False
|
||||
|
||||
# We need to init a local selection only once
|
||||
if not self._is_local_selection:
|
||||
# Init it here
|
||||
sel_level = geomBuilder.EnumToLong(self._selection_level)
|
||||
geom_swig.initLocalSelection(entry, sel_level)
|
||||
|
||||
self._is_local_selection = True
|
||||
else:
|
||||
# No entry - no local selection
|
||||
geom_swig.closeLocalSelection()
|
||||
self._is_local_selection = False
|
||||
|
||||
# We don't need the flag after selection was set
|
||||
self._is_level_changed = False
|
||||
|
||||
def on_select_object(self):
|
||||
"""
|
||||
@ -356,6 +384,9 @@ class BaseDlg(Ui_BaseDlg, QWidget):
|
||||
"""
|
||||
|
||||
super().closeEvent(event)
|
||||
|
||||
# Clean up all selection changes
|
||||
self._sel_manager.currentSelectionChanged.disconnect(self._sel_connection)
|
||||
self.set_selection(None)
|
||||
|
||||
|
||||
|
@ -80,6 +80,10 @@ 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):
|
||||
"""
|
||||
@ -214,6 +218,17 @@ 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.
|
||||
|
Loading…
Reference in New Issue
Block a user