Salome HOME
Issue #1057: Update title of property panel on operation type change
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 17 Nov 2015 15:27:11 +0000 (18:27 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 17 Nov 2015 15:27:23 +0000 (18:27 +0300)
src/FeaturesPlugin/boolean_widget.xml
src/ModuleBase/ModuleBase_WidgetChoice.cpp
src/ModuleBase/ModuleBase_WidgetChoice.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_WidgetChoice.h [new file with mode: 0644]

index cdf755b6c21010fecaf50b1413579a93c2ceea84..8e6543d09ffcf4873e03000d86115cd26e2e5856 100644 (file)
@@ -1,7 +1,7 @@
 <!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
 
 <source>
-  <choice id="bool_type"
+  <module_choice id="bool_type"
     widget_type="radiobuttons"
     buttons_dir="horizontal"
     label="Operation type" 
index 3fed3ea5f661fba5dba5b5305e58c7d6b239f96c..ea35a3f827b057d204bfb577ff6acbb33e0ac506 100644 (file)
@@ -77,6 +77,7 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent,
     }
     myButtons->button(0)->setChecked(true);
     connect(myButtons, SIGNAL(buttonClicked(int)), this, SLOT(onCurrentIndexChanged(int)));
+    connect(myButtons, SIGNAL(buttonClicked(int)), this, SIGNAL(itemSelected(int)));
   } else {
     myLabel = new QLabel(aLabelText, this);
     if (!aLabelIcon.isEmpty())
@@ -94,6 +95,7 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent,
     myCombo->addItems(aList);
 
     connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
+    connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(itemSelected(int)));
   }
 }
 
@@ -128,6 +130,7 @@ bool ModuleBase_WidgetChoice::restoreValueCustom()
       bool isBlocked = myButtons->blockSignals(true);
       myButtons->button(aIntAttr->value())->setChecked(true);
       myButtons->blockSignals(isBlocked);
+      emit itemSelected(aIntAttr->value());
     }
   }
   return true;
index fa643d44820cec7312c354a99b52912820999b20..e8db6c289487d6942d47c8688fadc26c282b7e34 100644 (file)
@@ -56,6 +56,9 @@ Q_OBJECT
   /// \return a controls list
   virtual QList<QWidget*> getControls() const;
 
+signals:
+  void itemSelected(int);
+
 protected:
   /// Saves the internal parameters to the given feature
   /// \return True in success
index 03f142b91cc28dcc8a6bd9953a87efb2950a9706..05e04db0d625f32a8408a639cb3c6e10a14c22e0 100644 (file)
@@ -29,6 +29,7 @@ SET(PROJECT_HEADERS
        PartSet_MenuMgr.h
        PartSet_WidgetSketchCreator.h
        PartSet_IconFactory.h
+       PartSet_WidgetChoice.h
 )
 
 SET(PROJECT_SOURCES
index 3346c8a75c6c0b6d236ec1ccc4049386b626c735..9b380a839de031128e1b0311af90b67a7373f389 100755 (executable)
@@ -18,6 +18,7 @@
 #include "PartSet_MenuMgr.h"
 #include "PartSet_CustomPrs.h"
 #include "PartSet_IconFactory.h"
+#include "PartSet_WidgetChoice.h"
 
 #include "PartSet_Filters.h"
 #include "PartSet_FilterInfinite.h"
@@ -543,6 +544,9 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
     aWgt = new PartSet_WidgetFileSelector(theParent, aWorkshop, theWidgetApi, theParentId);
   } else if (theType == "sketch_launcher") {
     aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi, theParentId);
+  } else if (theType == "module_choice") {
+    aWgt = new PartSet_WidgetChoice(theParent, theWidgetApi, theParentId);
+    connect(aWgt, SIGNAL(itemSelected(int)), SLOT(onBooleanOperationChange(int)));
   }
   return aWgt;
 }
@@ -1019,3 +1023,24 @@ bool PartSet_Module::processEnter(const std::string& thePreviousAttributeID)
 {
   return mySketchReentrantMgr->processEnter(thePreviousAttributeID);
 }
+
+
+//******************************************************
+void PartSet_Module::onBooleanOperationChange(int theOperation)
+{
+  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+  if (!aOperation)
+    return;
+  ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+  switch (theOperation) {
+  case 0:
+    aPanel->setWindowTitle(tr("Cut"));
+    break;
+  case 1:
+    aPanel->setWindowTitle(tr("Fuse"));
+    break;
+  case 2:
+    aPanel->setWindowTitle(tr("Common"));
+    break;
+  }
+}
index b83286bf54e5e8c40c9356dd49831d87b31d221a..470294bdb1dec44f8d84db4de4e6b31c33cbc577 100755 (executable)
@@ -255,6 +255,10 @@ protected slots:
   /// A slot called on view window creation
   void onViewCreated(ModuleBase_IViewWindow*);
 
+  /// A slot to change property panel title on change of boolean operation type
+  /// \param theOperation the operation type
+  void onBooleanOperationChange(int theOperation);
+
 protected:
   /// Register validators for this module
   virtual void registerValidators();
diff --git a/src/PartSet/PartSet_WidgetChoice.h b/src/PartSet/PartSet_WidgetChoice.h
new file mode 100644 (file)
index 0000000..6b5e965
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetChoice.h
+// Created:     17 Nov 2015
+// Author:      Vitaly Smetannikov
+
+#ifndef PartSet_WidgetChoice_H
+#define PartSet_WidgetChoice_H
+
+#include "PartSet.h"
+#include <ModuleBase_WidgetChoice.h>
+
+/**
+* \ingroup GUI
+* Implementation of a proxy of choice widget in order to geat access to it on moment 
+* of creation in module
+*/
+class PARTSET_EXPORT PartSet_WidgetChoice : public ModuleBase_WidgetChoice
+{
+Q_OBJECT
+ public:
+  /// Constructor
+  /// \param theParent the parent object
+  /// \param theData the widget configuation. The attribute of the model widget is obtained from
+  /// \param theParentId is Id of a parent of the current attribute
+  PartSet_WidgetChoice(QWidget* theParent, const Config_WidgetAPI* theData, 
+    const std::string& theParentId) 
+    : ModuleBase_WidgetChoice(theParent, theData, theParentId) {}
+};
+
+#endif
\ No newline at end of file