From 91dadfbad133cfb02e4a09adce80ec915d1fc6bd Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 4 Jun 2014 15:07:56 +0400 Subject: [PATCH] It replaces direct names of construction and partset features to the specific kind. --- src/ConstructionPlugin/ConstructionPlugin_Extrusion.h | 5 ++++- src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp | 4 ++-- src/ConstructionPlugin/ConstructionPlugin_Point.h | 5 ++++- src/PartSetPlugin/PartSetPlugin_Part.h | 5 ++++- src/PartSetPlugin/PartSetPlugin_Plugin.cpp | 2 +- src/PartSetPlugin/PartSetPlugin_Remove.cpp | 2 +- src/PartSetPlugin/PartSetPlugin_Remove.h | 5 ++++- src/XGUI/XGUI_ContextMenuMgr.cpp | 2 +- src/XGUI/XGUI_Workshop.cpp | 4 ++-- 9 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h index b7db8e011..5270d2d89 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h +++ b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h @@ -8,6 +8,9 @@ #include "ConstructionPlugin.h" #include +/// Extrusion kind +const std::string CONSTRUCTION_EXTRUSION_KIND("Extrusion"); + /// attribute name of referenced face const std::string EXTRUSION_FACE = "extrusion_face"; @@ -23,7 +26,7 @@ class ConstructionPlugin_Extrusion: public ModelAPI_Feature public: /// Returns the kind of a feature CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind() - { static std::string MY_KIND = "Extrusion"; return MY_KIND; } + { static std::string MY_KIND = CONSTRUCTION_EXTRUSION_KIND; return MY_KIND; } /// Returns to which group in the document must be added feature CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getGroup() diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp index 4e1bfd19c..d420b2110 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp @@ -18,9 +18,9 @@ ConstructionPlugin_Plugin::ConstructionPlugin_Plugin() FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID) { - if (theFeatureID == "Point") { + if (theFeatureID == CONSTRUCTION_POINT_KIND) { return FeaturePtr(new ConstructionPlugin_Point); - } else if (theFeatureID == "Extrusion") { + } else if (theFeatureID == CONSTRUCTION_EXTRUSION_KIND) { return FeaturePtr(new ConstructionPlugin_Extrusion); } // feature of such kind is not found diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.h b/src/ConstructionPlugin/ConstructionPlugin_Point.h index 2b71b50fe..a0dda28dd 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.h +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.h @@ -8,6 +8,9 @@ #include "ConstructionPlugin.h" #include +/// Point kind +const std::string CONSTRUCTION_POINT_KIND("Point"); + /// attribute name for X coordinate const std::string POINT_ATTR_X = "x"; /// attribute name for Y coordinate @@ -24,7 +27,7 @@ class ConstructionPlugin_Point: public ModelAPI_Feature public: /// Returns the kind of a feature CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "Point"; return MY_KIND;} + {static std::string MY_KIND = CONSTRUCTION_POINT_KIND; return MY_KIND;} /// Returns to which group in the document must be added feature CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getGroup() diff --git a/src/PartSetPlugin/PartSetPlugin_Part.h b/src/PartSetPlugin/PartSetPlugin_Part.h index eaae463ad..0f9217271 100644 --- a/src/PartSetPlugin/PartSetPlugin_Part.h +++ b/src/PartSetPlugin/PartSetPlugin_Part.h @@ -8,6 +8,9 @@ #include "PartSetPlugin.h" #include +/// Part kind +const std::string PARTSET_PART_KIND("Part"); + /// part reference attribute const std::string PART_ATTR_DOC_REF = "PartDocument"; @@ -20,7 +23,7 @@ class PartSetPlugin_Part: public ModelAPI_Feature public: /// Returns the kind of a feature PARTSETPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "Part"; return MY_KIND;} + {static std::string MY_KIND = PARTSET_PART_KIND; return MY_KIND;} /// Returns to which group in the document must be added feature PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.cpp b/src/PartSetPlugin/PartSetPlugin_Plugin.cpp index 435cc1efc..4ba7fa5ca 100644 --- a/src/PartSetPlugin/PartSetPlugin_Plugin.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Plugin.cpp @@ -18,7 +18,7 @@ PartSetPlugin_Plugin::PartSetPlugin_Plugin() FeaturePtr PartSetPlugin_Plugin::createFeature(string theFeatureID) { - if (theFeatureID == "Part") { + if (theFeatureID == PARTSET_PART_KIND) { return FeaturePtr(new PartSetPlugin_Part); } if (theFeatureID == "duplicate") { diff --git a/src/PartSetPlugin/PartSetPlugin_Remove.cpp b/src/PartSetPlugin/PartSetPlugin_Remove.cpp index 6c56d01f1..0e09f3a60 100644 --- a/src/PartSetPlugin/PartSetPlugin_Remove.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Remove.cpp @@ -16,7 +16,7 @@ void PartSetPlugin_Remove::execute() boost::shared_ptr a; for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) { FeaturePtr aFeature = aRoot->feature(getGroup(), a, true); - if (aFeature->getKind() == "Part") { + if (aFeature->getKind() == PARTSET_PART_KIND) { boost::shared_ptr aPart = boost::static_pointer_cast(aFeature); if (aPart->data()->docRef(PART_ATTR_DOC_REF)->value() == aPManager->currentDocument()) { diff --git a/src/PartSetPlugin/PartSetPlugin_Remove.h b/src/PartSetPlugin/PartSetPlugin_Remove.h index f12066c3e..87b7e258c 100644 --- a/src/PartSetPlugin/PartSetPlugin_Remove.h +++ b/src/PartSetPlugin/PartSetPlugin_Remove.h @@ -8,6 +8,9 @@ #include "PartSetPlugin.h" #include +/// Extrusion kind +const std::string PARTSET_REMOVE_KIND("Remove"); + /**\class PartSetPlugin_Remove * \ingroup DataModel * \brief Feature for creation of the new part in PartSet. @@ -17,7 +20,7 @@ class PartSetPlugin_Remove: public ModelAPI_Feature public: /// Returns the kind of a feature PARTSETPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = "Remove"; return MY_KIND;} + {static std::string MY_KIND = PARTSET_REMOVE_KIND; return MY_KIND;} /// Returns to which group in the document must be added feature PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 32c961026..86a5d03e8 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -96,7 +96,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const FeaturePtr aFeature = aFeatures.first(); //Process Feature if (aFeature) { - if (aFeature->getKind() == "Part") { + if (aFeature->getKind() == PARTSET_PART_KIND) { ObjectPtr aObject = boost::dynamic_pointer_cast(aFeature); DocumentPtr aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value(); if (aMgr->currentDocument() == aFeaDoc) diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index dfe77c6f8..4847cd62d 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -228,7 +228,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) bool aHasPart = false; for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) { FeaturePtr aFeature = (*aIt); - if (aFeature->getKind() == "Part") { + if (aFeature->getKind() == PARTSET_PART_KIND) { aHasPart = true; break; } @@ -809,7 +809,7 @@ void XGUI_Workshop::deleteFeatures(QFeatureList theList) PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); aMgr->rootDocument()->startOperation(); foreach (FeaturePtr aFeature, theList) { - if (aFeature->getKind() == "Part") { + if (aFeature->getKind() == PARTSET_PART_KIND) { DocumentPtr aDoc; if (!XGUI_Tools::isModelObject(aFeature)) { aDoc = aFeature->data()->docRef("PartDocument")->value(); -- 2.39.2