Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
- const std::string& theLibraryName)
+ const std::string& theLibraryName,
+ const char* theEventGenerated)
: Config_XMLReader(theXmlFile),
- myLibraryName(theLibraryName)
+ myLibraryName(theLibraryName),
+ myEventGenerated(theEventGenerated ? theEventGenerated : "FeatureEvent")
{
}
void Config_FeatureReader::processNode(xmlNodePtr theNode)
{
- static Event_ID aMenuItemEvent = Event_Loop::eventByName("FeatureEvent");
+ Event_ID aMenuItemEvent = Event_Loop::eventByName(myEventGenerated);
if (isNode(theNode, NODE_FEATURE, NULL)) {
Event_Loop* aEvLoop = Event_Loop::loop();
Config_FeatureMessage aMessage(aMenuItemEvent, this);
{
public:
Config_FeatureReader(const std::string& theXmlFile,
- const std::string& theLibraryName = "");
+ const std::string& theLibraryName = "",
+ const char* theEventGenerated = 0);
virtual ~Config_FeatureReader();
protected:
std::string myLastWorkbench;
std::string myLastGroup;
std::string myLibraryName;
+ /// event generated on feature data sending, by default it is "FeatureEvent"
+ const char* myEventGenerated;
};
#endif /* CONFIG_FEATUREREADER_H_ */
-Config_ModuleReader::Config_ModuleReader()
- : Config_XMLReader("plugins.xml"), myIsAutoImport(false)
+Config_ModuleReader::Config_ModuleReader(const char* theEventGenerated)
+ : Config_XMLReader("plugins.xml"), myIsAutoImport(false), myEventGenerated(theEventGenerated)
{
}
if(thePluginLibrary.empty()) {
aReader = new Config_FeatureReader(thePluginName);
} else {
- aReader = new Config_FeatureReader(thePluginName, thePluginLibrary);
+ aReader = new Config_FeatureReader(thePluginName, thePluginLibrary, myEventGenerated);
}
aReader->readAll();
}
{
public:
- CONFIG_EXPORT Config_ModuleReader();
+ CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
CONFIG_EXPORT virtual ~Config_ModuleReader();
CONFIG_EXPORT void setAutoImport(bool enabled);
private:
bool myIsAutoImport;
std::map<std::string, std::string> myPluginsMap;
-
+ const char* myEventGenerated;
};
TDF_Label anObjLab = aGroupLab.NewChild();
std::shared_ptr<Model_Data> aData(new Model_Data);
aData->setLabel(anObjLab);
- aData->setDocument(Model_Application::getApplication()->getDocument(myID));
+ shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
+ aData->setDocument(aThis);
theFeature->setData(aData);
setUniqueName(theFeature);
theFeature->initAttributes();
// event: feature is added
static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
- ModelAPI_FeatureUpdatedMessage aMsg(theFeature, anEvent);
+ ModelAPI_FeatureUpdatedMessage aMsg(aThis, theFeature, anEvent);
Event_Loop::loop()->send(aMsg);
}
void Model_Document::synchronizeFeatures()
{
+ shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
// iterate groups labels
TDF_ChildIDIterator aGroupsIter(myDoc->Main().FindChild(TAG_OBJECTS),
TDataStd_Comment::GetID(), Standard_False);
if (aDSTag > aFeatureTag) { // feature is removed
aFIter = aFeatures.erase(aFIter);
// event: model is updated
- ModelAPI_FeatureDeletedMessage aMsg(
- Model_Application::getApplication()->getDocument(myID), aGroupName);
+ ModelAPI_FeatureDeletedMessage aMsg(aThis, aGroupName);
Event_Loop::loop()->send(aMsg);
} else if (aDSTag < aFeatureTag) { // a new feature is inserted
// create a feature
aFeature->initAttributes();
// event: model is updated
static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
- ModelAPI_FeatureUpdatedMessage aMsg(aFeature, anEvent);
+ ModelAPI_FeatureUpdatedMessage aMsg(aThis, aFeature, anEvent);
Event_Loop::loop()->send(aMsg);
if (aFIter == aFeatures.end()) {
#include <Event_Loop.h>
ModelAPI_FeatureUpdatedMessage::ModelAPI_FeatureUpdatedMessage(
+ const std::shared_ptr<ModelAPI_Document>& theDoc,
const std::shared_ptr<ModelAPI_Feature>& theFeature, const Event_ID& theEvent)
- : Event_Message(theEvent, 0), myFeature(theFeature)
+ : Event_Message(theEvent, 0), myFeature(theFeature), myDoc(theDoc)
{}
ModelAPI_FeatureDeletedMessage::ModelAPI_FeatureDeletedMessage(
/// Message that feature was changed (used for Object Browser update)
class ModelAPI_FeatureUpdatedMessage : public Event_Message {
+ std::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
std::shared_ptr<ModelAPI_Feature> myFeature; ///< which feature is changed
public:
/// sender is not important, all information is located in the feature
- ModelAPI_FeatureUpdatedMessage(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ ModelAPI_FeatureUpdatedMessage(
+ const std::shared_ptr<ModelAPI_Document>& theDoc,
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
const Event_ID& theEvent);
/// Returns the feature that has been updated
std::shared_ptr<ModelAPI_Feature> feature() {return myFeature;}
+ /// Returns the document that has been updated
+ std::shared_ptr<ModelAPI_Document> document() {return myDoc;}
};
/// Message that feature was deleted (used for Object Browser update)
{
myPluginsInfoLoaded = false;
//TODO(sbh): Implement static method to extract event id [SEID]
- static Event_ID aFeatureEvent = Event_Loop::eventByName("FeatureEvent");
+ static Event_ID aFeatureEvent = Event_Loop::eventByName("FeatureRegisterEvent");
ModelAPI_PluginManager::SetPluginManager(std::shared_ptr<ModelAPI_PluginManager>(this));
// register the configuration reading listener
return;
// Read plugins information from XML files
- Config_ModuleReader aXMLReader;
+ Config_ModuleReader aXMLReader("FeatureRegisterEvent");
aXMLReader.setAutoImport(true);
aXMLReader.readAll();
}
//******************************************************
void XGUI_Workshop::processEvent(const Event_Message* theMessage)
{
- const Config_FeatureMessage* aFeatureMsg =
- dynamic_cast<const Config_FeatureMessage*>(theMessage);
- if (aFeatureMsg) {
+ static Event_ID aFeatureId = Event_Loop::loop()->eventByName("FeatureEvent");
+ if (theMessage->eventID() == aFeatureId) {
+ const Config_FeatureMessage* aFeatureMsg =
+ dynamic_cast<const Config_FeatureMessage*>(theMessage);
addFeature(aFeatureMsg);
return;
}