20 #ifndef Model_Session_H_
21 #define Model_Session_H_
24 #include <ModelAPI_Session.h>
25 #include <ModelAPI_Feature.h>
27 #include <Events_Listener.h>
31 #include <TDocStd_Application.hxx>
44 bool myPluginsInfoLoaded;
46 std::map<std::string, std::pair<std::string, std::string> > myPlugins;
47 std::map<std::string, ModelAPI_Plugin*> myPluginObjs;
48 std::string myCurrentPluginName;
49 std::shared_ptr<ModelAPI_Document> myCurrentDoc;
51 std::map<std::string, std::string> myUsePlugins;
54 bool myCheckTransactions;
57 std::list<bool> myOperationAttachedToNext;
63 MODEL_EXPORT
virtual bool load(
const char* theFileName);
69 MODEL_EXPORT
virtual bool save(
const char* theFileName, std::list<std::string>& theResults,
bool doBackup=
false);
72 MODEL_EXPORT
virtual void closeAll();
80 const std::string& theId =
"",
const bool theAttachedToNested =
false);
91 MODEL_EXPORT
virtual bool canUndo();
93 MODEL_EXPORT
virtual void undo();
95 MODEL_EXPORT
virtual bool canRedo();
97 MODEL_EXPORT
virtual void redo();
99 MODEL_EXPORT
virtual std::list<std::string>
undoList();
101 MODEL_EXPORT
virtual std::list<std::string>
redoList();
106 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_Document>
moduleDocument();
109 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_Document>
document(
int theDocID);
115 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_Document>
activeDocument();
119 std::shared_ptr<ModelAPI_Document> theDoc,
bool theSendSignal =
true);
122 MODEL_EXPORT
virtual std::list<std::shared_ptr<ModelAPI_Document> >
allOpenedDocuments();
125 MODEL_EXPORT
virtual bool isLoadByDemand(
const std::wstring theDocID,
const int theDocIndex);
133 MODEL_EXPORT
virtual bool checkLicense(
const std::string& thePluginName);
136 MODEL_EXPORT
virtual void processEvent(
const std::shared_ptr<Events_Message>& theMessage);
139 MODEL_EXPORT
virtual std::shared_ptr<ModelAPI_Document>
copy(
140 std::shared_ptr<ModelAPI_Document> theSource,
const int theDestID);
151 myCheckTransactions = theCheck;
Base interface for any event listener.
Definition: Events_Listener.h:37
Manages registering of filters.
Definition: ModelAPI_FiltersFactory.h:35
Interface common for any plugin: allows to use plugin by the plugins manager.
Definition: ModelAPI_Plugin.h:34
Object that knows (from the initial XML file) which plugin contains which feature,...
Definition: ModelAPI_Session.h:42
Manages the registered validators.
Definition: ModelAPI_Validator.h:66
Document for internal data structure of any object storage.
Definition: Model_Document.h:45
Manager of objects of the document.
Definition: Model_Objects.h:46
Object that knows (from the initial XML file) which plugin contains which feature,...
Definition: Model_Session.h:43
virtual std::shared_ptr< ModelAPI_Document > copy(std::shared_ptr< ModelAPI_Document > theSource, const int theDestID)
Copies the document to the new one.
Definition: Model_Session.cpp:390
virtual bool hasModuleDocument()
Return true if root document has been already created.
Definition: Model_Session.cpp:283
Model_Session()
Is called only once, on startup of the application.
Definition: Model_Session.cpp:454
void setCheckTransactions(const bool theCheck)
Sets the flag to check modifications outside the transaction or not.
Definition: Model_Session.h:149
virtual void redo()
Redoes last operation.
Definition: Model_Session.cpp:166
virtual void closeAll()
Closes all documents.
Definition: Model_Session.cpp:74
virtual bool canUndo()
Returns True if there are available Undos.
Definition: Model_Session.cpp:149
virtual std::shared_ptr< ModelAPI_Document > activeDocument()
Returns the current document that used for current work in the application.
Definition: Model_Session.cpp:288
virtual void registerPlugin(ModelAPI_Plugin *thePlugin)
Registers the plugin that creates features.
Definition: Model_Session.cpp:615
ModelAPI_Plugin * getPlugin(const std::string &thePluginName)
Get the plugin by name. If it is not loaded, load plugin.
Definition: Model_Session.cpp:194
virtual std::list< std::shared_ptr< ModelAPI_Document > > allOpenedDocuments()
Returns all the opened documents of the session (without postponed)
Definition: Model_Session.cpp:365
virtual bool isModified()
Returns true if document was modified (since creation/opening)
Definition: Model_Session.cpp:144
virtual std::shared_ptr< ModelAPI_Document > moduleDocument()
Returns the root document of the application (that may contains sub-documents)
Definition: Model_Session.cpp:253
virtual std::list< std::string > redoList()
Returns stack of rolled back operations.
Definition: Model_Session.cpp:179
virtual bool save(const char *theFileName, std::list< std::string > &theResults, bool doBackup=false)
Saves the OCAF document to the file.
Definition: Model_Session.cpp:69
FeaturePtr createFeature(std::string theFeatureID, Model_Document *theDocOwner)
Creates the feature object using plugins functionality.
Definition: Model_Session.cpp:217
virtual void undo()
Undoes last operation.
Definition: Model_Session.cpp:154
virtual void startOperation(const std::string &theId="", const bool theAttachedToNested=false)
Starts a new operation (opens a transaction)
Definition: Model_Session.cpp:84
virtual void processEvent(const std::shared_ptr< Events_Message > &theMessage)
Processes the configuration file reading.
Definition: Model_Session.cpp:472
virtual bool canRedo()
Returns True if there are available Redos.
Definition: Model_Session.cpp:161
virtual bool isLoadByDemand(const std::wstring theDocID, const int theDocIndex)
Returns true if document is not loaded yet.
Definition: Model_Session.cpp:385
virtual void abortOperation()
Aborts the operation.
Definition: Model_Session.cpp:115
virtual void setActiveDocument(std::shared_ptr< ModelAPI_Document > theDoc, bool theSendSignal=true)
Defines the current document that used for current work in the application.
Definition: Model_Session.cpp:313
virtual void finishOperation()
Finishes the previously started operation (closes the transaction)
Definition: Model_Session.cpp:100
virtual bool checkLicense(const std::string &thePluginName)
Verifies the license for the plugin is valid.
Definition: Model_Session.cpp:189
void LoadPluginsInfo()
Loads (if not done yet) the information about the features and plugins.
Definition: Model_Session.cpp:599
virtual ModelAPI_ValidatorsFactory * validators()
Returns the validators factory: the only one instance per application.
Definition: Model_Session.cpp:630
virtual bool isAutoUpdateBlocked()
Returns true if auto-update in the application is blocked.
Definition: Model_Session.cpp:647
virtual std::list< std::string > undoList()
Returns stack of performed operations.
Definition: Model_Session.cpp:174
virtual ModelAPI_FiltersFactory * filters()
Returns the filters factory: the only one instance per application.
Definition: Model_Session.cpp:636
virtual void clearUndoRedo()
Clears undo and redo lists of all documents in the session.
Definition: Model_Session.cpp:184
virtual std::shared_ptr< ModelAPI_Document > document(int theDocID)
Returns the document by ID, loads if not loaded yet. Returns null if no such document.
Definition: Model_Session.cpp:277
virtual void blockAutoUpdate(const bool theBlock)
Set state of the auto-update of features result in the application.
Definition: Model_Session.cpp:655
virtual int transactionID()
Returns the global identifier of the current transaction (needed for the update algo)
Definition: Model_Session.cpp:642
virtual bool isOperation()
Returns true if operation has been started, but not yet finished or aborted.
Definition: Model_Session.cpp:139
virtual bool load(const char *theFileName)
Loads the OCAF document from the file.
Definition: Model_Session.cpp:61