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