]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
A fix for a bug: clear content in the shape selector by deselection it in the viewer.
authornds <natalia.donis@opencascade.com>
Wed, 20 May 2015 09:38:23 +0000 (12:38 +0300)
committernds <natalia.donis@opencascade.com>
Wed, 20 May 2015 09:38:23 +0000 (12:38 +0300)
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h

index 0608ddeae862ffc8bc5a74bbfa1d7ccf2159709e..87de31d8106ebc81a2a43bef873dc8ba74be9a14 100644 (file)
@@ -39,7 +39,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen
                                                                const Config_WidgetAPI* theData,
                                                                const std::string& theParentId)
     : ModuleBase_WidgetValidated(theParent, theData, theParentId),
-      myWorkshop(theWorkshop), myIsActive(false)
+      myWorkshop(theWorkshop)
 {
   QGridLayout* aMainLay = new QGridLayout(this);
   ModuleBase_Tools::adjustMargins(aMainLay);
@@ -94,8 +94,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen
 
 ModuleBase_WidgetMultiSelector::~ModuleBase_WidgetMultiSelector()
 {
-  myIsActive = false;
-  activateShapeSelection();
+  activateShapeSelection(false);
 }
 
 //********************************************************************
@@ -106,8 +105,7 @@ void ModuleBase_WidgetMultiSelector::activateCustom()
           this,       SLOT(onSelectionChanged()), 
           Qt::UniqueConnection);
 
-  myIsActive = true;
-  activateShapeSelection();
+  activateShapeSelection(true);
 
   QObjectPtrList anObjects;
   // Restore selection in the viewer by the attribute selection list
@@ -131,8 +129,7 @@ void ModuleBase_WidgetMultiSelector::activateCustom()
 void ModuleBase_WidgetMultiSelector::deactivate()
 {
   disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-  myIsActive = false;
-  activateShapeSelection();
+  activateShapeSelection(false);
 }
 
 //********************************************************************
@@ -318,7 +315,7 @@ bool ModuleBase_WidgetMultiSelector::eventFilter(QObject* theObj, QEvent* theEve
 //********************************************************************
 void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
 {
-  activateShapeSelection();
+  activateShapeSelection(true);
   QObjectPtrList anEmptyList;
   // This method will call Selection changed event which will call onSelectionChanged
   // To clear mySelection, myListControl and storeValue()
@@ -358,23 +355,21 @@ void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const TopAbs_ShapeEnum
     aShapeTypeName = myTypeCombo->itemText(idx);
     TopAbs_ShapeEnum aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
     if(aRefType == theShapeType && idx != myTypeCombo->currentIndex()) {
-      myIsActive = false;
-      activateShapeSelection();
+      activateShapeSelection(false);
       bool isBlocked = myTypeCombo->blockSignals(true);
       myTypeCombo->setCurrentIndex(idx);
-      myIsActive = true;
       myTypeCombo->blockSignals(isBlocked);
-      activateShapeSelection();
+      activateShapeSelection(true);
       break;
     }
   }
 }
 
-void ModuleBase_WidgetMultiSelector::activateShapeSelection()
+void ModuleBase_WidgetMultiSelector::activateShapeSelection(const bool isActivated)
 {
   ModuleBase_IViewer* aViewer = myWorkshop->viewer();
 
-  if (myIsActive) {
+  if (isActivated) {
     QString aNewType = myTypeCombo->currentText();
     QIntList aList;
     aList.append(ModuleBase_Tools::shapeType(aNewType));
@@ -383,7 +378,7 @@ void ModuleBase_WidgetMultiSelector::activateShapeSelection()
     myWorkshop->deactivateSubShapesSelection();
   }
 
-  activateFilters(myWorkshop, myIsActive);
+  activateFilters(myWorkshop, isActivated);
 }
 
 //********************************************************************
index 778755c61eef804cf8234fb61debb6882d34457f..1a98c238e5cb726e130ec62f6647f0d44cd3a162 100644 (file)
@@ -119,7 +119,8 @@ protected slots:
   void setCurrentShapeType(const TopAbs_ShapeEnum theShapeType);
 
   /// Start shape selection
-  void activateShapeSelection();
+  /// \param isActivated a state whether the shape is activated or deactivated in selection
+  void activateShapeSelection(const bool isActivated);
 
  protected:
    /// Update selection list
@@ -134,9 +135,6 @@ protected slots:
   //TODO: Move into the base of selectors
   ModuleBase_IWorkshop* myWorkshop;
 
-  /// If true then local selector has to be activated in context
-  bool myIsActive;
-
   /// Provides correspondance between Result object and its shape
   typedef QPair<ResultPtr, GeomShapePtr> GeomSelection;