From 2ff69695395d934619d400eca4bf151bde32bc03 Mon Sep 17 00:00:00 2001 From: sbh Date: Mon, 22 Sep 2014 09:52:25 +0400 Subject: [PATCH] Widget selector renamed to shape selector --- src/Config/Config_Keywords.h | 2 +- src/FeaturesPlugin/boolean_widget.xml | 4 +- src/FeaturesPlugin/extrusion_widget.xml | 2 +- src/ModuleBase/CMakeLists.txt | 4 +- src/ModuleBase/ModuleBase_WidgetFactory.cpp | 81 +++++++++---------- src/ModuleBase/ModuleBase_WidgetFactory.h | 4 +- ...cpp => ModuleBase_WidgetShapeSelector.cpp} | 30 +++---- ...tor.h => ModuleBase_WidgetShapeSelector.h} | 12 +-- 8 files changed, 66 insertions(+), 73 deletions(-) rename src/ModuleBase/{ModuleBase_WidgetSelector.cpp => ModuleBase_WidgetShapeSelector.cpp} (88%) rename src/ModuleBase/{ModuleBase_WidgetSelector.h => ModuleBase_WidgetShapeSelector.h} (82%) diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index 8fbcd49a3..37acefda5 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -28,7 +28,7 @@ const static char* WDG_TOOLBOX = "toolbox"; const static char* WDG_TOOLBOX_BOX = "box"; const static char* WDG_SWITCH = "switch"; const static char* WDG_SWITCH_CASE = "case"; -const static char* WDG_SELECTOR = "selector"; +const static char* WDG_SHAPE_SELECTOR = "shape_selector"; const static char* WDG_CHOICE = "choice"; //Specific widgets diff --git a/src/FeaturesPlugin/boolean_widget.xml b/src/FeaturesPlugin/boolean_widget.xml index c80856f29..cdf8e195e 100644 --- a/src/FeaturesPlugin/boolean_widget.xml +++ b/src/FeaturesPlugin/boolean_widget.xml @@ -1,11 +1,11 @@ - - - #include #include -#include +#include #include #include #include @@ -125,8 +125,8 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType } else if (theType == WDG_INFO) { result = labelControl(theParent); - } else if (theType == WDG_SELECTOR) { - result = selectorControl(theParent); + } else if (theType == WDG_SHAPE_SELECTOR) { + result = shapeSelectorControl(theParent); } else if (theType == WDG_BOOLVALUE) { result = booleanControl(theParent); @@ -186,85 +186,65 @@ QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, Q QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent) { - ModuleBase_WidgetDoubleValue* aDblWgt = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, - myParentId); + ModuleBase_WidgetDoubleValue* aDblWgt = + new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId); myModelWidgets.append(aDblWgt); - return aDblWgt->getControl(); } QWidget* ModuleBase_WidgetFactory::pointSelectorControl(QWidget* theParent) { - ModuleBase_WidgetPoint2D* aWidget = new ModuleBase_WidgetPoint2D(theParent, myWidgetApi, - myParentId); + ModuleBase_WidgetPoint2D* aWidget = + new ModuleBase_WidgetPoint2D(theParent, myWidgetApi,myParentId); myModelWidgets.append(aWidget); return aWidget->getControl(); } QWidget* ModuleBase_WidgetFactory::featureSelectorControl(QWidget* theParent) { - ModuleBase_WidgetFeature* aWidget = new ModuleBase_WidgetFeature(theParent, myWidgetApi, - myParentId); + ModuleBase_WidgetFeature* aWidget = + new ModuleBase_WidgetFeature(theParent, myWidgetApi,myParentId); myModelWidgets.append(aWidget); return aWidget->getControl(); } QWidget* ModuleBase_WidgetFactory::featureOrAttributeSelectorControl(QWidget* theParent) { - ModuleBase_WidgetFeatureOrAttribute* aWidget = new ModuleBase_WidgetFeatureOrAttribute( - theParent, myWidgetApi, myParentId); + ModuleBase_WidgetFeatureOrAttribute* aWidget = + new ModuleBase_WidgetFeatureOrAttribute(theParent, myWidgetApi, myParentId); myModelWidgets.append(aWidget); return aWidget->getControl(); } QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent) { - ModuleBase_WidgetEditor* aWidget = new ModuleBase_WidgetEditor(theParent, myWidgetApi, - myParentId); + ModuleBase_WidgetEditor* aWidget = + new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId); myModelWidgets.append(aWidget); return aWidget->getControl(); } -QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const -{ - return QString::fromStdString(theStdString); -} - -bool ModuleBase_WidgetFactory::isInternalWidget(const std::string& theType) -{ - std::string prop = myWidgetApi->getProperty(FEATURE_INTERNAL); - - std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower); - if (prop.empty() || prop == "false" || prop == "0") { - return false; - } - return true; -} - -QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent) +QWidget* ModuleBase_WidgetFactory::shapeSelectorControl(QWidget* theParent) { - ModuleBase_WidgetSelector* aSelector = new ModuleBase_WidgetSelector(theParent, myWorkshop, - myWidgetApi, myParentId); + ModuleBase_WidgetShapeSelector* aSelector = + new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi, myParentId); myModelWidgets.append(aSelector); return aSelector->getControl(); } QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent) { - ModuleBase_WidgetBoolValue* aBoolWgt = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, - myParentId); + ModuleBase_WidgetBoolValue* aBoolWgt = + new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId); myModelWidgets.append(aBoolWgt); - return aBoolWgt->getControl(); } QWidget* ModuleBase_WidgetFactory::point2dDistanceControl(QWidget* theParent) { - ModuleBase_WidgetPoint2dDistance* aDistWgt = new ModuleBase_WidgetPoint2dDistance(theParent, - myWidgetApi, - myParentId); + ModuleBase_WidgetPoint2dDistance* aDistWgt = + new ModuleBase_WidgetPoint2dDistance(theParent, myWidgetApi, myParentId); myModelWidgets.append(aDistWgt); - return aDistWgt->getControl(); } @@ -273,16 +253,29 @@ QWidget* ModuleBase_WidgetFactory::fileSelectorControl(QWidget* theParent) ModuleBase_WidgetFileSelector* aFileSelectorWgt = new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId); myModelWidgets.append(aFileSelectorWgt); - return aFileSelectorWgt->getControl(); } QWidget* ModuleBase_WidgetFactory::choiceControl(QWidget* theParent) { - ModuleBase_WidgetChoice* aChoiceWgt = new ModuleBase_WidgetChoice(theParent, myWidgetApi, - myParentId); + ModuleBase_WidgetChoice* aChoiceWgt = + new ModuleBase_WidgetChoice(theParent, myWidgetApi,myParentId); myModelWidgets.append(aChoiceWgt); - return aChoiceWgt->getControl(); } +bool ModuleBase_WidgetFactory::isInternalWidget(const std::string& theType) +{ + std::string prop = myWidgetApi->getProperty(FEATURE_INTERNAL); + + std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower); + if (prop.empty() || prop == "false" || prop == "0") { + return false; + } + return true; +} + +QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const +{ + return QString::fromStdString(theStdString); +} diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.h b/src/ModuleBase/ModuleBase_WidgetFactory.h index 1b9e031bf..320e88f95 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.h +++ b/src/ModuleBase/ModuleBase_WidgetFactory.h @@ -36,14 +36,14 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory protected: //Widgets QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL); + QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL); QWidget* labelControl(QWidget* theParent); QWidget* doubleSpinBoxControl(QWidget* theParent); QWidget* pointSelectorControl(QWidget* theParent); QWidget* featureSelectorControl(QWidget* theParent); QWidget* featureOrAttributeSelectorControl(QWidget* theParent); QWidget* doubleValueEditor(QWidget* theParent); - QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL); - QWidget* selectorControl(QWidget* theParent); + QWidget* shapeSelectorControl(QWidget* theParent); QWidget* booleanControl(QWidget* theParent); QWidget* point2dDistanceControl(QWidget* theParent); QWidget* fileSelectorControl(QWidget* theParent); diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp similarity index 88% rename from src/ModuleBase/ModuleBase_WidgetSelector.cpp rename to src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index f5b5af3b1..3fe721135 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -1,8 +1,8 @@ -// File: ModuleBase_WidgetSelector.h +// File: ModuleBase_WidgetShapeSelector.h // Created: 2 June 2014 // Author: Vitaly Smetannikov -#include "ModuleBase_WidgetSelector.h" +#include "ModuleBase_WidgetShapeSelector.h" #include "ModuleBase_IWorkshop.h" #include @@ -34,7 +34,7 @@ typedef QMap ShapeTypes; static ShapeTypes MyShapeTypes; -TopAbs_ShapeEnum ModuleBase_WidgetSelector::shapeType(const QString& theType) +TopAbs_ShapeEnum ModuleBase_WidgetShapeSelector::shapeType(const QString& theType) { if (MyShapeTypes.count() == 0) { MyShapeTypes["face"] = TopAbs_FACE; @@ -49,7 +49,7 @@ TopAbs_ShapeEnum ModuleBase_WidgetSelector::shapeType(const QString& theType) throw std::invalid_argument("Shape type defined in XML is not implemented!"); } -ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent, +ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, const std::string& theParentId) @@ -94,12 +94,12 @@ ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent, } //******************************************************************** -ModuleBase_WidgetSelector::~ModuleBase_WidgetSelector() +ModuleBase_WidgetShapeSelector::~ModuleBase_WidgetShapeSelector() { } //******************************************************************** -bool ModuleBase_WidgetSelector::storeValue() const +bool ModuleBase_WidgetShapeSelector::storeValue() const { FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(mySelectedObject); if (aSelectedFeature == myFeature) // In order to avoid selection of the same object @@ -118,7 +118,7 @@ bool ModuleBase_WidgetSelector::storeValue() const } //******************************************************************** -bool ModuleBase_WidgetSelector::restoreValue() +bool ModuleBase_WidgetShapeSelector::restoreValue() { DataPtr aData = myFeature->data(); boost::shared_ptr aRef = aData->reference(attributeID()); @@ -132,7 +132,7 @@ bool ModuleBase_WidgetSelector::restoreValue() } //******************************************************************** -QList ModuleBase_WidgetSelector::getControls() const +QList ModuleBase_WidgetShapeSelector::getControls() const { QList aControls; aControls.append(myLabel); @@ -142,7 +142,7 @@ QList ModuleBase_WidgetSelector::getControls() const } //******************************************************************** -void ModuleBase_WidgetSelector::onSelectionChanged() +void ModuleBase_WidgetShapeSelector::onSelectionChanged() { QList aObjects = myWorkshop->selectedObjects(); if (aObjects.size() > 0) { @@ -170,7 +170,7 @@ void ModuleBase_WidgetSelector::onSelectionChanged() } //******************************************************************** -bool ModuleBase_WidgetSelector::isAccepted(const ObjectPtr theResult) const +bool ModuleBase_WidgetShapeSelector::isAccepted(const ObjectPtr theResult) const { ResultPtr aResult = boost::dynamic_pointer_cast(theResult); boost::shared_ptr aShapePtr = ModelAPI_Tools::shape(aResult); @@ -197,7 +197,7 @@ bool ModuleBase_WidgetSelector::isAccepted(const ObjectPtr theResult) const } //******************************************************************** -void ModuleBase_WidgetSelector::updateSelectionName() +void ModuleBase_WidgetShapeSelector::updateSelectionName() { if (mySelectedObject) { std::string aName = mySelectedObject->data()->name(); @@ -208,7 +208,7 @@ void ModuleBase_WidgetSelector::updateSelectionName() } //******************************************************************** -void ModuleBase_WidgetSelector::enableOthersControls(bool toEnable) const +void ModuleBase_WidgetShapeSelector::enableOthersControls(bool toEnable) const { QWidget* aParent = myContainer->parentWidget(); QList aChldList = aParent->findChildren(); @@ -221,7 +221,7 @@ void ModuleBase_WidgetSelector::enableOthersControls(bool toEnable) const } //******************************************************************** -void ModuleBase_WidgetSelector::activateSelection(bool toActivate) +void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate) { enableOthersControls(!toActivate); //myTextLine->setEnabled(toActivate); @@ -239,7 +239,7 @@ void ModuleBase_WidgetSelector::activateSelection(bool toActivate) } //******************************************************************** -void ModuleBase_WidgetSelector::raisePanel() const +void ModuleBase_WidgetShapeSelector::raisePanel() const { QWidget* aParent = myContainer->parentWidget(); QWidget* aLastPanel = 0; @@ -256,7 +256,7 @@ void ModuleBase_WidgetSelector::raisePanel() const } //******************************************************************** -bool ModuleBase_WidgetSelector::focusTo() +bool ModuleBase_WidgetShapeSelector::focusTo() { myActivateBtn->setChecked(true); return true; diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h similarity index 82% rename from src/ModuleBase/ModuleBase_WidgetSelector.h rename to src/ModuleBase/ModuleBase_WidgetShapeSelector.h index e39f97f32..ffab7c6d8 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h @@ -1,9 +1,9 @@ -// File: ModuleBase_WidgetSelector.h +// File: ModuleBase_WidgetShapeSelector.h // Created: 2 June 2014 // Author: Vitaly Smetannikov -#ifndef ModuleBase_WidgetSelector_H -#define ModuleBase_WidgetSelector_H +#ifndef ModuleBase_WidgetShapeSelector_H +#define ModuleBase_WidgetShapeSelector_H #include "ModuleBase.h" #include "ModuleBase_ModelWidget.h" @@ -22,14 +22,14 @@ class QLineEdit; class QToolButton; class ModuleBase_IWorkshop; -class MODULEBASE_EXPORT ModuleBase_WidgetSelector : public ModuleBase_ModelWidget +class MODULEBASE_EXPORT ModuleBase_WidgetShapeSelector : public ModuleBase_ModelWidget { Q_OBJECT public: - ModuleBase_WidgetSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, + ModuleBase_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, const std::string& theParentId); - virtual ~ModuleBase_WidgetSelector(); + virtual ~ModuleBase_WidgetShapeSelector(); /// Saves the internal parameters to the given feature /// \param theObject a model feature to be changed -- 2.39.2