From: sbh Date: Thu, 24 Apr 2014 07:02:10 +0000 (+0400) Subject: Search module's features in different plugins. X-Git-Tag: V_0.2~118^2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ccba9cdf320d8065830fb0740ea6cbd988740e6c;p=modules%2Fshaper.git Search module's features in different plugins. --- diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 50d72e992..b9454e04d 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -36,6 +36,11 @@ Config_FeatureReader::~Config_FeatureReader() { } +std::list Config_FeatureReader::features() const +{ + return myFeatures; +} + void Config_FeatureReader::processNode(xmlNodePtr theNode) { Event_ID aMenuItemEvent = Event_Loop::eventByName(myEventGenerated); @@ -43,6 +48,7 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) Event_Loop* aEvLoop = Event_Loop::loop(); Config_FeatureMessage aMessage(aMenuItemEvent, this); fillFeature(theNode, aMessage); + myFeatures.push_back(getProperty(theNode, _ID)); //If a feature has xml definition for it's widget: aMessage.setUseInput(hasChild(theNode)); aEvLoop->send(aMessage); diff --git a/src/Config/Config_FeatureReader.h b/src/Config/Config_FeatureReader.h index 7b5322bba..12517a5df 100644 --- a/src/Config/Config_FeatureReader.h +++ b/src/Config/Config_FeatureReader.h @@ -12,7 +12,7 @@ #include #include - +#include class Config_FeatureMessage; @@ -20,10 +20,12 @@ class Config_FeatureReader: public Config_XMLReader { public: Config_FeatureReader(const std::string& theXmlFile, - const std::string& theLibraryName = "", + const std::string& theLibraryName, const char* theEventGenerated = 0); virtual ~Config_FeatureReader(); + std::list features() const; + protected: void processNode(xmlNodePtr aNode); bool processChildren(xmlNodePtr aNode); @@ -34,6 +36,8 @@ private: std::string myLastWorkbench; std::string myLastGroup; std::string myLibraryName; + + std::list myFeatures; /// event generated on feature data sending, by default it is "FeatureEvent" const char* myEventGenerated; }; diff --git a/src/Config/Config_ModuleReader.cpp b/src/Config/Config_ModuleReader.cpp index 6153bd04d..4e67ea46d 100644 --- a/src/Config/Config_ModuleReader.cpp +++ b/src/Config/Config_ModuleReader.cpp @@ -20,7 +20,8 @@ Config_ModuleReader::Config_ModuleReader(const char* theEventGenerated) - : Config_XMLReader("plugins.xml"), myIsAutoImport(false), myEventGenerated(theEventGenerated) + : Config_XMLReader("plugins.xml"), + myEventGenerated(theEventGenerated) { } @@ -28,6 +29,11 @@ Config_ModuleReader::~Config_ModuleReader() { } +const std::map& Config_ModuleReader::featuresInFiles() const +{ + return myFeaturesInFiles; +} + /* * Get module name from plugins.xml * (property "module") @@ -46,9 +52,11 @@ void Config_ModuleReader::processNode(xmlNodePtr theNode) if (isNode(theNode, NODE_PLUGIN, NULL)) { std::string aPluginConf = getProperty(theNode, PLUGIN_CONFIG); std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY); - if (myIsAutoImport) - importPlugin(aPluginConf, aPluginLibrary); - myPluginsMap[aPluginLibrary] = aPluginConf; + std::list aFeatures = importPlugin(aPluginConf, aPluginLibrary); + std::list::iterator it = aFeatures.begin(); + for( ; it != aFeatures.end(); it++ ) { + myFeaturesInFiles[*it] = aPluginConf; + } } } @@ -57,24 +65,14 @@ bool Config_ModuleReader::processChildren(xmlNodePtr theNode) return isNode(theNode, NODE_PLUGINS, NULL); } -void Config_ModuleReader::importPlugin(const std::string& thePluginName, - const std::string& thePluginLibrary) +std::list +Config_ModuleReader::importPlugin(const std::string& thePluginFile, + const std::string& thePluginLibrary) { - Config_FeatureReader* aReader; - if(thePluginLibrary.empty()) { - aReader = new Config_FeatureReader(thePluginName); - } else { - aReader = new Config_FeatureReader(thePluginName, thePluginLibrary, myEventGenerated); - } - aReader->readAll(); + Config_FeatureReader aReader = Config_FeatureReader(thePluginFile, + thePluginLibrary, + myEventGenerated); + aReader.readAll(); + return aReader.features(); } -void Config_ModuleReader::setAutoImport(bool theEnabled) -{ - myIsAutoImport = theEnabled; -} - -const std::map& Config_ModuleReader::plugins() const -{ - return myPluginsMap; -} diff --git a/src/Config/Config_ModuleReader.h b/src/Config/Config_ModuleReader.h index 7083315b1..4f9b61a77 100644 --- a/src/Config/Config_ModuleReader.h +++ b/src/Config/Config_ModuleReader.h @@ -12,6 +12,7 @@ #include #include +#include #include @@ -22,8 +23,7 @@ public: CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0); CONFIG_EXPORT virtual ~Config_ModuleReader(); - CONFIG_EXPORT void setAutoImport(bool enabled); - CONFIG_EXPORT const std::map& plugins() const; + CONFIG_EXPORT const std::map& featuresInFiles() const; CONFIG_EXPORT std::string getModuleName(); @@ -31,12 +31,11 @@ protected: void processNode(xmlNodePtr aNode); bool processChildren(xmlNodePtr aNode); - void importPlugin(const std::string& thePluginName, - const std::string& thePluginLibrary = ""); + std::list importPlugin(const std::string& thePluginFile, + const std::string& thePluginLibrary); private: - bool myIsAutoImport; - std::map myPluginsMap; + std::map myFeaturesInFiles; const char* myEventGenerated; }; diff --git a/src/Model/Model_PluginManager.cpp b/src/Model/Model_PluginManager.cpp index eb279208a..cf18adc56 100644 --- a/src/Model/Model_PluginManager.cpp +++ b/src/Model/Model_PluginManager.cpp @@ -93,7 +93,6 @@ void Model_PluginManager::LoadPluginsInfo() // Read plugins information from XML files Config_ModuleReader aXMLReader("FeatureRegisterEvent"); - aXMLReader.setAutoImport(true); aXMLReader.readAll(); } diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 92cea614c..bbdde0c19 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -38,8 +38,8 @@ PartSet_Module::~PartSet_Module() void PartSet_Module::createFeatures() { Config_ModuleReader aXMLReader = Config_ModuleReader(); - aXMLReader.setAutoImport(true); aXMLReader.readAll(); + myFeaturesInFiles = aXMLReader.featuresInFiles(); } void PartSet_Module::featureCreated(XGUI_Command* theFeature) @@ -47,13 +47,9 @@ void PartSet_Module::featureCreated(XGUI_Command* theFeature) theFeature->connectTo(this, SLOT(onFeatureTriggered())); } -std::string PartSet_Module::modulePlugin() +std::string PartSet_Module::featureFile(const std::string& theFeatureId) { - Config_ModuleReader aModuleReader = Config_ModuleReader(); - aModuleReader.readAll(); - std::map < std::string, std::string > aPluginMap = aModuleReader.plugins(); - std::string aPluginName = aPluginMap["PartSetPlugin"]; - return aPluginName; + return myFeaturesInFiles[theFeatureId]; } /* @@ -61,13 +57,14 @@ std::string PartSet_Module::modulePlugin() */ void PartSet_Module::onFeatureTriggered() { - std::string aPluginName = modulePlugin(); - Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginName); - aWdgReader.readAll(); XGUI_Command* aCmd = dynamic_cast(sender()); QString aCmdId = aCmd->id(); - std::string aXmlCfg = aWdgReader.featureWidgetCfg(aCmdId.toStdString()); - std::string aDescription = aWdgReader.featureDescription(aCmdId.toStdString()); + std::string aStdCmdId = aCmdId.toStdString(); + std::string aPluginFileName = featureFile(aStdCmdId); + Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName); + aWdgReader.readAll(); + std::string aXmlCfg = aWdgReader.featureWidgetCfg(aStdCmdId); + std::string aDescription = aWdgReader.featureDescription(aStdCmdId); ModuleBase_PropPanelOperation* aPartSetOp; if (aCmdId == "Sketch" ) { aPartSetOp = new PartSet_OperationSketch(aCmdId, this); @@ -75,9 +72,9 @@ void PartSet_Module::onFeatureTriggered() aPartSetOp = new ModuleBase_PropPanelOperation(aCmdId, this); } PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(aPartSetOp); - if (aPreviewOp) + if (aPreviewOp) { connect(aPreviewOp, SIGNAL(visualizePreview()), this, SLOT(onVisualizePreview())); - + } aPartSetOp->setXmlRepresentation(QString::fromStdString(aXmlCfg)); aPartSetOp->setDescription(QString::fromStdString(aDescription)); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 676c1494a..7f8f9cea5 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -6,12 +6,14 @@ #include #include +#include #include +#include + class PARTSET_EXPORT PartSet_Module: public QObject, public XGUI_Module { Q_OBJECT - std::string modulePlugin(); public: PartSet_Module(XGUI_Workshop* theWshop); @@ -19,6 +21,7 @@ public: virtual void createFeatures(); virtual void featureCreated(XGUI_Command* theFeature); + std::string featureFile(const std::string&); public slots: void onFeatureTriggered(); @@ -26,6 +29,8 @@ public slots: private: XGUI_Workshop* myWorkshop; + + std::map myFeaturesInFiles; }; #endif