From d608e00a418fc52c474c251f66fc0e7a4b05d15b Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 17 Nov 2015 18:27:11 +0300 Subject: [PATCH] Issue #1057: Update title of property panel on operation type change --- src/FeaturesPlugin/boolean_widget.xml | 2 +- src/ModuleBase/ModuleBase_WidgetChoice.cpp | 3 +++ src/ModuleBase/ModuleBase_WidgetChoice.h | 3 +++ src/PartSet/CMakeLists.txt | 1 + src/PartSet/PartSet_Module.cpp | 25 +++++++++++++++++ src/PartSet/PartSet_Module.h | 4 +++ src/PartSet/PartSet_WidgetChoice.h | 31 ++++++++++++++++++++++ 7 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/PartSet/PartSet_WidgetChoice.h diff --git a/src/FeaturesPlugin/boolean_widget.xml b/src/FeaturesPlugin/boolean_widget.xml index cdf755b6c..8e6543d09 100644 --- a/src/FeaturesPlugin/boolean_widget.xml +++ b/src/FeaturesPlugin/boolean_widget.xml @@ -1,7 +1,7 @@ - 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; diff --git a/src/ModuleBase/ModuleBase_WidgetChoice.h b/src/ModuleBase/ModuleBase_WidgetChoice.h index fa643d448..e8db6c289 100644 --- a/src/ModuleBase/ModuleBase_WidgetChoice.h +++ b/src/ModuleBase/ModuleBase_WidgetChoice.h @@ -56,6 +56,9 @@ Q_OBJECT /// \return a controls list virtual QList getControls() const; +signals: + void itemSelected(int); + protected: /// Saves the internal parameters to the given feature /// \return True in success diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 03f142b91..05e04db0d 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -29,6 +29,7 @@ SET(PROJECT_HEADERS PartSet_MenuMgr.h PartSet_WidgetSketchCreator.h PartSet_IconFactory.h + PartSet_WidgetChoice.h ) SET(PROJECT_SOURCES diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 3346c8a75..9b380a839 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -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; + } +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index b83286bf5..470294bdb 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -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 index 000000000..6b5e965f8 --- /dev/null +++ b/src/PartSet/PartSet_WidgetChoice.h @@ -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 + +/** +* \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 -- 2.39.2