]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue 1299 Angle presentation: "Cut"/"Fuse"/"Common" should not be shown in the PP...
authornds <nds@opencascade.com>
Thu, 17 Mar 2016 09:00:32 +0000 (12:00 +0300)
committernds <nds@opencascade.com>
Thu, 17 Mar 2016 09:00:32 +0000 (12:00 +0300)
src/FeaturesPlugin/boolean_widget.xml
src/ModuleBase/ModuleBase_WidgetChoice.cpp
src/ModuleBase/ModuleBase_WidgetChoice.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/SketchPlugin/plugin-Sketch.xml

index 99d5ca6995b05d063fb70a3544c92911d2f159c2..e3b9b2dbbad9b56ae193527f9f4edcb82f1d39b9 100644 (file)
@@ -7,6 +7,7 @@
     label="Operation type" 
     tooltip="Type of boolean operation"
     string_list="Cut Fuse Common"
+    use_in_title="true"
     icons_list=":icons/bool_cut.png :icons/bool_fuse.png :icons/bool_common.png"
     default="0"
   />
index 6c35d6627020c2ca5089fd3f749c2153ae7c1fd2..f8b4ff5167d9c56c51f524fbf5e51c53e2c9560b 100644 (file)
@@ -33,6 +33,9 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent,
   std::string aTypes = theData->getProperty("string_list");
   QStringList aList = QString(aTypes.c_str()).split(' ');
 
+  if (theData->getBooleanAttribute("use_in_title", false))
+    myButtonTitles = QString(aTypes.c_str()).split(" ");
+
   // Widget type can be combobox or radiobuttons
   std::string aWgtType = theData->getProperty("widget_type");
   if ((aWgtType.length() > 0) && (aWgtType == "radiobuttons")) {
@@ -77,7 +80,6 @@ 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())
@@ -95,7 +97,6 @@ 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)));
   }
 }
 
@@ -130,7 +131,7 @@ bool ModuleBase_WidgetChoice::restoreValueCustom()
       bool isBlocked = myButtons->blockSignals(true);
       myButtons->button(aIntAttr->value())->setChecked(true);
       myButtons->blockSignals(isBlocked);
-      emit itemSelected(aIntAttr->value());
+      emit itemSelected(this, aIntAttr->value());
     }
   }
   return true;
@@ -158,9 +159,19 @@ QList<QWidget*> ModuleBase_WidgetChoice::getControls() const
   return aControls;
 }
 
+QString ModuleBase_WidgetChoice::getPropertyPanelTitle(int theIndex)
+{
+  QString aTitle;
+  if (myButtonTitles.length() > theIndex)
+    aTitle = tr(myButtonTitles[theIndex].toStdString().c_str());
+  return aTitle;
+}
+
 void ModuleBase_WidgetChoice::onCurrentIndexChanged(int theIndex)
 {
   emit valuesChanged();
   // Don't transfer focus
   // emit focusOutWidget(this);
+
+  emit itemSelected(this, theIndex);
 }
index 100f66f24a4833bf06a8e651b5fc5e48cfa60cdd..e5e7474c3bb864e69f794bd923baf9670a89bf80 100644 (file)
@@ -54,8 +54,13 @@ Q_OBJECT
   /// \return a controls list
   virtual QList<QWidget*> getControls() const;
 
+  /// Returns text value for the property panel title
+  /// \param theIndex a button index
+  /// \return the title value
+  QString getPropertyPanelTitle(int theIndex);
+
 signals:
-  void itemSelected(int);
+  void itemSelected(ModuleBase_ModelWidget* theWidget, int theIndex);
 
 protected:
   /// Saves the internal parameters to the given feature
@@ -75,6 +80,9 @@ private:
   /// The control
   QComboBox* myCombo;
   QButtonGroup* myButtons;
+
+  // XML definition of titles
+  QStringList myButtonTitles;
 };
 
 #endif
index 3f2ef5ed89f1bbf75327f0f165b2ed3bb73562f9..d38ee8de64d886cc9483a4c62d2fe1bcb0588ebf 100755 (executable)
@@ -683,7 +683,8 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
     aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi);
   } else if (theType == "module_choice") {
     aWgt = new PartSet_WidgetChoice(theParent, theWidgetApi);
-    connect(aWgt, SIGNAL(itemSelected(int)), SLOT(onBooleanOperationChange(int)));
+    connect(aWgt, SIGNAL(itemSelected(ModuleBase_ModelWidget*, int)),
+            this, SLOT(onChoiceChanged(ModuleBase_ModelWidget*, int)));
   }
   return aWgt;
 }
@@ -1241,22 +1242,20 @@ AttributePtr PartSet_Module::findAttribute(const ObjectPtr& theObject,
 }
 
 //******************************************************
-void PartSet_Module::onBooleanOperationChange(int theOperation)
+void PartSet_Module::onChoiceChanged(ModuleBase_ModelWidget* theWidget,
+                                     int theIndex)
 {
-  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
-  if (!aOperation)
+  PartSet_WidgetChoice* aChoiceWidget = dynamic_cast<PartSet_WidgetChoice*>(theWidget);
+  if (!aChoiceWidget)
     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;
+
+  QString aChoiceTitle = aChoiceWidget->getPropertyPanelTitle(theIndex);
+  if (!aChoiceTitle.isEmpty()) {
+    ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+    if (!aOperation)
+      return;
+    ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+    aPanel->setWindowTitle(aChoiceTitle);
   }
 }
 
index 2581d7bb2d5f4889381f56a0d5054d647d30466d..cb7d8613142fc0a937de8a2a61837af54c0f4828 100755 (executable)
@@ -315,9 +315,11 @@ 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);
+  /// A slot to change property panel title by choice type change if the title information
+  /// exists in the XML definition of this control attribute
+  /// \param theWidget a sender
+  /// \param theIndex the current choice index
+  void onChoiceChanged(ModuleBase_ModelWidget* theWidget, int theIndex);
 
 protected:
   /// Register validators for this module
index 8640c0635bbd5557f76ac99e7474cae9a35b3bda..5e1e924dbffee1e6cc511ced18b1444a31d19bd8 100644 (file)
         <module_choice id="AngleType"
           widget_type="radiobuttons"
           buttons_dir="horizontal"
-          label="Operation type"
+          label="Angle type"
           tooltip="Type of angle"
           string_list="Direct Supplementary Backward"
           icons_list=":icons/angle_direct.png :icons/angle_supplementary.png :icons/angle_backward.png"