static Handle_Model_Application TheApplication = new Model_Application;
-//=======================================================================
-//function : getApplication
-//purpose :
//=======================================================================
Handle(Model_Application) Model_Application::getApplication()
{
return TheApplication;
}
-//=======================================================================
-//function : getDocument
-//purpose :
//=======================================================================
const std::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
{
}
//=======================================================================
-//function : OCAFApp_Application
-//purpose :
+bool Model_Application::hasDocument(std::string theDocID)
+{
+ return myDocs.find(theDocID) != myDocs.end();
+}
+
//=======================================================================
Model_Application::Model_Application()
{
TheKeepHandle = this;
}
-//=======================================================================
-//function : Formats
-//purpose :
//=======================================================================
void Model_Application::Formats(TColStd_SequenceOfExtendedString& theFormats)
{
theFormats.Append(TCollection_ExtendedString("BinOcaf")); // standard binary schema
}
-//=======================================================================
-//function : ResourcesName
-//purpose :
//=======================================================================
Standard_CString Model_Application::ResourcesName()
{
MODEL_EXPORT static Handle_Model_Application getApplication();
//! Returns the main document (on first call creates it) by the string identifier
MODEL_EXPORT const std::shared_ptr<Model_Document>& getDocument(std::string theDocID);
+ //! Returns true if document has been created
+ MODEL_EXPORT bool hasDocument(std::string theDocID);
//! Deletes the document from the application
MODEL_EXPORT void deleteDocument(std::string theDocID);
Model_Application::getApplication()->getDocument("root"));
}
+bool Model_PluginManager::hasRootDocument()
+{
+ return Model_Application::getApplication()->hasDocument("root");
+}
+
shared_ptr<ModelAPI_Document> Model_PluginManager::currentDocument()
{
if (!myCurrentDoc)
/// Returns the root document of the application (that may contains sub-documents)
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> rootDocument();
+ /// Return true if root document has been already created
+ MODEL_EXPORT virtual bool hasRootDocument();
+
/// Returns the current document that used for current work in the application
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> currentDocument();
/// Returns the root document of the application (that may contains sub-documents)
virtual std::shared_ptr<ModelAPI_Document> rootDocument() = 0;
+ /// Return true if root document has been already created
+ virtual bool hasRootDocument() = 0;
+
/// Returns the current document that used for current work in the application
virtual std::shared_ptr<ModelAPI_Document> currentDocument() = 0;
{
std::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
myFeature = aDoc->addFeature(myOperationId.toStdString());
- myFeature->execute();
+ if (myFeature) // TODO: generate an error if feature was not created
+ myFeature->execute();
//emit callSlot();
//commit();
}
*/
void ModuleBase_Operation::commitOperation()
{
- myFeature->execute();
+ if (myFeature) myFeature->execute();
}
/*!