X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSetPlugin%2FPartSetPlugin_Plugin.cpp;h=c4d50434636509f50168f7a0aef153dd3e96e73b;hb=1834431e0e067cbb4616f42679562d56af528f5e;hp=4ba7fa5cac1e2e1b8193232b6f06d39cd4107486;hpb=38f16bcc8fd21226cd50a3d73457c139159ea4ec;p=modules%2Fshaper.git diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.cpp b/src/PartSetPlugin/PartSetPlugin_Plugin.cpp index 4ba7fa5ca..c4d504346 100644 --- a/src/PartSetPlugin/PartSetPlugin_Plugin.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Plugin.cpp @@ -1,32 +1,69 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include "PartSetPlugin_Plugin.h" #include "PartSetPlugin_Part.h" #include "PartSetPlugin_Duplicate.h" #include "PartSetPlugin_Remove.h" -#include + +#include + +#include #include +#ifdef _DEBUG +#include +#endif + using namespace std; // the only created instance of this plugin -static PartSetPlugin_Plugin* MY_INSTANCE = new PartSetPlugin_Plugin(); +static PartSetPlugin_Plugin* MY_PARTSET_INSTANCE = new PartSetPlugin_Plugin(); -PartSetPlugin_Plugin::PartSetPlugin_Plugin() +PartSetPlugin_Plugin::PartSetPlugin_Plugin() { // register this plugin - ModelAPI_PluginManager::get()->registerPlugin(this); + ModelAPI_Session::get()->registerPlugin(this); } FeaturePtr PartSetPlugin_Plugin::createFeature(string theFeatureID) { - if (theFeatureID == PARTSET_PART_KIND) { + if (theFeatureID == PartSetPlugin_Part::ID()) { return FeaturePtr(new PartSetPlugin_Part); } - if (theFeatureID == "duplicate") { + if (theFeatureID == PartSetPlugin_Duplicate::ID()) { return FeaturePtr(new PartSetPlugin_Duplicate); } - if (theFeatureID == "remove") { + if (theFeatureID == PartSetPlugin_Remove::ID()) { return FeaturePtr(new PartSetPlugin_Remove); } - // feature of such kind is not found + // feature of such kind is not found return FeaturePtr(); } + +void PartSetPlugin_Plugin::processEvent(const std::shared_ptr& theMessage) +{ + const Events_ID kRequestEvent = + Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_REQUEST); + if (theMessage->eventID() == kRequestEvent) { + Events_Loop::loop()->send(getFeaturesState(), false); + } else if (theMessage.get()) { + #ifdef _DEBUG + std::cout << "PartSetPlugin_Plugin::processEvent: unhandled message caught: " << std::endl + << theMessage->eventID().eventText() << std::endl; + #endif + } +} + +std::shared_ptr PartSetPlugin_Plugin::getFeaturesState() +{ + const Events_ID kResponseEvent = + Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_RESPONSE); + std::shared_ptr aMsg = + std::make_shared(kResponseEvent, this); + std::string aStdDocKind = ModelAPI_Session::get()->activeDocument()->kind(); + bool aDocIsPart = (aStdDocKind == PartSetPlugin_Part::ID()); + aMsg->setState(PartSetPlugin_Part::ID(), true); + aMsg->setState(PartSetPlugin_Duplicate::ID(), aDocIsPart); + aMsg->setState(PartSetPlugin_Remove::ID(), aDocIsPart); + return aMsg; +}