/// Request for initialization of data model of the feature: adding all attributes
CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
+ /// Construction result is allways recomuted on the fly
+ CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
+
/// Use plugin manager for features creation
ConstructionPlugin_Point();
};
myDoc->SetUndoLimit(UNDO_LIMIT);
myTransactionsAfterSave = 0;
myNestedNum = -1;
+ myExecuteFeatures = true;
//myDoc->SetNestedTransactionMode();
// to have something in the document and avoid empty doc open/save problem
// in transaction for nesting correct working
// 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);
+ 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_TO_REDISPLAY));
boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())->setCheckTransactions(
true);
+ myExecuteFeatures = true;
}
void Model_Document::storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData,
//! Returns a feature by result (owner of result)
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature>
- feature(const boost::shared_ptr<ModelAPI_Result>& theResult);
+ feature(const boost::shared_ptr<ModelAPI_Result>& theResult);
+
+ ///! Returns true if parametric updater need to execute feature on recomputartion
+ ///! On abort, undo or redo it is not necessary: results in document are updated automatically
+ bool executeFeatures() {return myExecuteFeatures;}
protected:
std::set<std::string> mySubs;
/// transaction indexes (related to myTransactionsAfterSave) which were empty in this doc
std::map<int, bool> myIsEmptyTr;
+ /// If it is true, features are not executed on update (on abort, undo, redo)
+ bool myExecuteFeatures;
};
#endif
// Author: Mikhail PONIKAROV
#include <Model_Update.h>
+#include <Model_Document.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
}
// execute feature if it must be updated
if (aMustbeUpdated) {
- theFeature->execute();
+
+ if (boost::dynamic_pointer_cast<Model_Document>(theFeature->document())->executeFeatures() ||
+ !theFeature->isPersistentResult())
+ theFeature->execute();
// redisplay all results
static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
MODELAPI_EXPORT void setResult(const boost::shared_ptr<ModelAPI_Result>& theResult,
const int theIndex);
+ /// Returns true if result is persistent (stored in document) and on undo-redo, save-open
+ /// it is not needed to recompute it.
+ virtual bool isPersistentResult() {return true;}
+
/// Returns true if this feature must not be created: this is just an action
/// that is not stored in the features history and data model (like "delete part").
virtual bool isAction()
/// \param thePoint the point
virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) = 0;
- protected:
+ /// Construction result is allways recomuted on the fly
+ SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
+
+protected:
/// Sets the higher-level feature for the sub-feature (sketch for line)
void setSketch(SketchPlugin_Sketch* theSketch)
{