Salome HOME
Fix for the issue #19726 : Placement failed because of wrong name in face selection.
[modules/shaper.git] / src / XGUI / XGUI_PropertyPanelSelector.cpp
index 5039168365c17c3278cc8f09a083f6b881cf36eb..c5aefe89493e74fc6b5878af5cf9a31c1a2f21d3 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include <XGUI_PropertyPanelSelector.h>
@@ -25,7 +24,7 @@
 XGUI_PropertyPanelSelector::XGUI_PropertyPanelSelector(XGUI_PropertyPanel* thePanel)
 : myPanel(thePanel), myWidgetToBeActivated (NULL)
 {
-  connect(myPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this, SIGNAL(activated()));
+  connect(myPanel, SIGNAL(propertyPanelActivated()), this, SIGNAL(activated()));
   connect(myPanel, SIGNAL(propertyPanelDeactivated()), this, SIGNAL(deactivated()));
 }
 
@@ -38,21 +37,25 @@ void XGUI_PropertyPanelSelector::reset()
 //********************************************************************
 void XGUI_PropertyPanelSelector::setActive(const bool& isActive)
 {
-  if (isActive) {
-    if (myWidgetToBeActivated)
-      myPanel->activateWidget(myWidgetToBeActivated, true);
+  if (isActive && myWidgetToBeActivated) {
+    // e.g. widget sketch label
+    myPanel->activateWidget(myWidgetToBeActivated, true);
+    myWidgetToBeActivated = NULL;
     return;
   }
-  ModuleBase_ModelWidget* aWidget = myPanel->activeWidget();
-  if (aWidget && aWidget->needToBeActiated())
-  {
-    myWidgetToBeActivated = aWidget;
+
+  if (!isActive) { // on deactivating, store previous active widget
+    ModuleBase_ModelWidget* aWidget = myPanel->activeWidget();
+    if (aWidget && aWidget->needToBeActivated())
+    {
+      myWidgetToBeActivated = aWidget;
+    }
+    myPanel->activateWidget(NULL, false);
   }
-  myPanel->activateWidget(NULL, false);
 }
 
 //********************************************************************
-bool XGUI_PropertyPanelSelector::needToBeActiated() const
+bool XGUI_PropertyPanelSelector::needToBeActivated() const
 {
   return myWidgetToBeActivated != NULL;
 }