void Events_Loop::flush(const Events_ID& theID)
{
+ if (!myFlushActive)
+ return;
std::map<char*, Events_MessageGroup*>::iterator aMyGroup = myGroups.find(theID.eventText());
if (aMyGroup != myGroups.end()) { // really sends
Events_MessageGroup* aGroup = aMyGroup->second;
delete aGroup;
}
}
+
+void Events_Loop::activateFlushes(const bool theActivate)
+{
+ myFlushActive = theActivate;
+}
/// map from event ID to groupped messages (accumulated on flush)
std::map<char*, Events_MessageGroup*> myGroups;
+ /// to process flushes or not
+ bool myFlushActive;
+
//! The empty constructor, will be called at startup of the application, only once
- Events_Loop()
- {
- }
- ;
+ Events_Loop() : myFlushActive(true) {}
+
public:
///! Returns the main object of the loop, one per application.
EVENTS_EXPORT static Events_Loop* loop();
//! Initializes sending of a group-message by the given ID
EVENTS_EXPORT void flush(const Events_ID& theID);
+
+ //! Allows to disable flushes: needed in synchronization of document mechanism
+ //! (to synchronize all and only then flush create, update, etc in correct order)
+ EVENTS_EXPORT void activateFlushes(const bool theActivate);
};
#endif
if (!myDoc->HasOpenCommand() && myNestedNum != -1)
boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())
->setCheckTransactions(false); // for nested transaction commit
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+ Events_Loop* aLoop = Events_Loop::loop();
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
if (!myDoc->HasOpenCommand() && myNestedNum != -1)
boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())
->setCheckTransactions(true); // for nested transaction commit
// after all updates, sends a message that groups of features were created or updated
boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())
->setCheckTransactions(false);
+ Events_Loop* aLoop = Events_Loop::loop();
+ aLoop->activateFlushes(false);
+
// update all objects by checking are they of labels or not
std::set<FeaturePtr> aNewFeatures, aKeptFeatures;
TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID());
ModelAPI_EventCreator::get()->sendDeleted(aThis, ModelAPI_Feature::group());
}
// results of this feature must be redisplayed (hided)
- static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
for (; aRIter != aResults.cend(); aRIter++) {
}
myExecuteFeatures = false;
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
- if (theMarkUpdated)
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ aLoop->activateFlushes(true);
+
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ if (theMarkUpdated) {
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ }
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+ aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())
->setCheckTransactions(true);
myExecuteFeatures = true;
#include <Model_ResultPart.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_PluginManager.h>
boost::shared_ptr<ModelAPI_Document> Model_ResultPart::partDoc()
{
data()->addAttribute(DOC_REF(), ModelAPI_AttributeDocRef::type());
}
}
+
+void Model_ResultPart::activate()
+{
+ boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->docRef(DOC_REF());
+
+ if (!aDocRef->value()) { // create (or open) a document if it is not yet created
+ boost::shared_ptr<ModelAPI_Document> aDoc = document()->subDocument(data()->name());
+ if (aDoc) {
+ aDocRef->setValue(aDoc);
+ }
+ }
+ if (aDocRef->value())
+ ModelAPI_PluginManager::get()->setCurrentDocument(aDocRef->value());
+}
/// Part has no stored feature: this method returns NULL
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> owner();
- protected:
+ /// Sets this document as current and if it is not loaded yet, loads it
+ MODEL_EXPORT virtual void activate();
+
+protected:
/// makes a result on a temporary feature (an action)
Model_ResultPart();
class ModelAPI_Object
{
boost::shared_ptr<ModelAPI_Data> myData; ///< manager of the data model of a feature
- boost::shared_ptr<ModelAPI_Document> myDoc; ///< document this feature belongs to
+ boost::shared_ptr<ModelAPI_Document> myDoc; ///< document this object belongs to
public:
/// By default object is displayed in the object browser.
virtual bool isInHistory()
/// Returns the part-document of this result
virtual boost::shared_ptr<ModelAPI_Document> partDoc() = 0;
+
+ /// Sets this document as current and if it is not loaded yet, loads it
+ virtual void activate() = 0;
};
//! Pointer on feature object
aResult = document()->createPart(data());
setResult(aResult);
}
+ /*
boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aResult->data()->docRef(
ModelAPI_ResultPart::DOC_REF());
-
+
if (!aDocRef->value()) { // create a document if not yet created
boost::shared_ptr<ModelAPI_Document> aPartSetDoc =
ModelAPI_PluginManager::get()->rootDocument();
aDocRef->setValue(aPartSetDoc->subDocument(data()->name()));
}
+ */
}
boost::shared_ptr<ModelAPI_Document> PartSetPlugin_Part::documentToAdd()