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);
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:44
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:389
virtual bool hasModuleDocument()
Return true if root document has been already created.
Definition: Model_Session.cpp:282
Model_Session()
Is called only once, on startup of the application.
Definition: Model_Session.cpp:453
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:165
virtual void closeAll()
Closes all documents.
Definition: Model_Session.cpp:73
virtual bool canUndo()
Returns True if there are available Undos.
Definition: Model_Session.cpp:148
virtual std::shared_ptr< ModelAPI_Document > activeDocument()
Returns the current document that used for current work in the application.
Definition: Model_Session.cpp:287
virtual void registerPlugin(ModelAPI_Plugin *thePlugin)
Registers the plugin that creates features.
Definition: Model_Session.cpp:614
ModelAPI_Plugin * getPlugin(const std::string &thePluginName)
Get the plugin by name. If it is not loaded, load plugin.
Definition: Model_Session.cpp:193
virtual std::list< std::shared_ptr< ModelAPI_Document > > allOpenedDocuments()
Returns all the opened documents of the session (without postponed)
Definition: Model_Session.cpp:364
virtual bool isModified()
Returns true if document was modified (since creation/opening)
Definition: Model_Session.cpp:143
virtual std::shared_ptr< ModelAPI_Document > moduleDocument()
Returns the root document of the application (that may contains sub-documents)
Definition: Model_Session.cpp:252
virtual std::list< std::string > redoList()
Returns stack of rolled back operations.
Definition: Model_Session.cpp:178
FeaturePtr createFeature(std::string theFeatureID, Model_Document *theDocOwner)
Creates the feature object using plugins functionality.
Definition: Model_Session.cpp:216
virtual bool save(const char *theFileName, std::list< std::string > &theResults)
Saves the OCAF document to the file.
Definition: Model_Session.cpp:68
virtual void undo()
Undoes last operation.
Definition: Model_Session.cpp:153
virtual void startOperation(const std::string &theId="", const bool theAttachedToNested=false)
Starts a new operation (opens a transaction)
Definition: Model_Session.cpp:83
virtual void processEvent(const std::shared_ptr< Events_Message > &theMessage)
Processes the configuration file reading.
Definition: Model_Session.cpp:471
virtual bool canRedo()
Returns True if there are available Redos.
Definition: Model_Session.cpp:160
virtual bool isLoadByDemand(const std::wstring theDocID, const int theDocIndex)
Returns true if document is not loaded yet.
Definition: Model_Session.cpp:384
virtual void abortOperation()
Aborts the operation.
Definition: Model_Session.cpp:114
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:312
virtual void finishOperation()
Finishes the previously started operation (closes the transaction)
Definition: Model_Session.cpp:99
virtual bool checkLicense(const std::string &thePluginName)
Verifies the license for the plugin is valid.
Definition: Model_Session.cpp:188
void LoadPluginsInfo()
Loads (if not done yet) the information about the features and plugins.
Definition: Model_Session.cpp:598
virtual ModelAPI_ValidatorsFactory * validators()
Returns the validators factory: the only one instance per application.
Definition: Model_Session.cpp:629
virtual bool isAutoUpdateBlocked()
Returns true if auto-update in the application is blocked.
Definition: Model_Session.cpp:646
virtual std::list< std::string > undoList()
Returns stack of performed operations.
Definition: Model_Session.cpp:173
virtual ModelAPI_FiltersFactory * filters()
Returns the filters factory: the only one instance per application.
Definition: Model_Session.cpp:635
virtual void clearUndoRedo()
Clears undo and redo lists of all documents in the session.
Definition: Model_Session.cpp:183
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:276
virtual void blockAutoUpdate(const bool theBlock)
Set state of the auto-update of features result in the application.
Definition: Model_Session.cpp:654
virtual int transactionID()
Returns the global identifier of the current transaction (needed for the update algo)
Definition: Model_Session.cpp:641
virtual bool isOperation()
Returns true if operation has been started, but not yet finished or aborted.
Definition: Model_Session.cpp:138
virtual bool load(const char *theFileName)
Loads the OCAF document from the file.
Definition: Model_Session.cpp:60