Salome HOME
updated copyright message
[modules/gui.git] / src / SUIT / SUIT_Study.h
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef SUIT_STUDY_H
24 #define SUIT_STUDY_H
25
26 #include "SUIT.h"
27
28 #include <QList>
29 #include <QObject>
30 #include <QListIterator>
31
32 class SUIT_DataObject;
33 class SUIT_Application;
34 class SUIT_Operation;
35
36 #ifdef WIN32
37 #pragma warning( disable:4251 )
38 #endif
39
40 class SUIT_EXPORT SUIT_Study : public QObject
41 {
42   Q_OBJECT
43   
44 public:
45   SUIT_Study( SUIT_Application* );
46   virtual ~SUIT_Study();
47
48   virtual int       id() const;
49
50   SUIT_DataObject*  root() const;
51   virtual QString   studyName() const;
52   SUIT_Application* application() const;
53
54   virtual bool      isSaved()  const;
55   virtual bool      isModified() const;
56   virtual void      Modified();
57
58   virtual void      closeDocument( bool = true );
59   virtual bool      openDocument( const QString& );
60   virtual bool      createDocument( const QString& );
61
62   bool              saveDocument();
63   virtual bool      saveDocumentAs( const QString& );
64
65   virtual void      update();
66
67   virtual void      sendChangesNotification();
68
69   // Operation management
70   SUIT_Operation*   activeOperation() const;
71   virtual void      abortAllOperations();
72   const QList<SUIT_Operation*>& operations() const;
73   
74   virtual SUIT_Operation* blockingOperation( SUIT_Operation* ) const;
75
76   bool              start( SUIT_Operation*, const bool check = true );
77   bool              abort( SUIT_Operation* );
78   bool              commit( SUIT_Operation* );
79   bool              suspend( SUIT_Operation* );
80   bool              resume( SUIT_Operation* );
81
82   virtual void      restoreState(int savePoint);
83
84 signals:
85   void              studyModified( SUIT_Study* );
86
87 protected:
88   virtual void      setIsSaved( const bool );
89   virtual void      setIsModified( const bool );
90   virtual void      setRoot( SUIT_DataObject* );
91   virtual void      setStudyName( const QString& );
92
93   virtual void      operationStarted( SUIT_Operation* );
94   virtual void      operationAborted( SUIT_Operation* );
95   virtual void      operationStopped( SUIT_Operation* );
96   virtual void      operationCommited( SUIT_Operation* );
97
98   virtual bool      openTransaction();
99   virtual bool      abortTransaction();
100   virtual bool      hasTransaction() const;
101   virtual bool      commitTransaction( const QString& = QString() );
102
103 private:
104   typedef QList<SUIT_Operation*> Operations;
105   void              stop( SUIT_Operation* );
106
107 private:
108   int               myId;
109   SUIT_Application* myApp;
110   SUIT_DataObject*  myRoot;
111   QString           myName;
112   bool              myIsSaved;
113   bool              myIsModified;
114   Operations        myOperations;
115   bool              myBlockChangeState;
116
117   friend class SUIT_Operation;
118 };
119
120 #ifdef WIN32
121 #pragma warning( default:4251 )
122 #endif
123
124 #endif