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
# 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()
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
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):
"""
"""
super().closeEvent(event)
+
+ # Clean up all selection changes
+ self._sel_manager.currentSelectionChanged.disconnect(self._sel_connection)
self.set_selection(None)
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):
"""
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.