Salome HOME
Copyrights update
[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/
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 signals:
79   void              studyModified( SUIT_Study* );
80
81 protected:
82   virtual void      setIsSaved( const bool );
83   virtual void      setIsModified( const bool );
84   virtual void      setRoot( SUIT_DataObject* );
85   virtual void      setStudyName( const QString& );
86
87         virtual void      operationStarted( SUIT_Operation* );
88         virtual void      operationAborted( SUIT_Operation* );
89         virtual void      operationStopped( SUIT_Operation* );
90         virtual void      operationCommited( SUIT_Operation* );
91
92   virtual bool      openTransaction();
93   virtual bool      abortTransaction();
94   virtual bool      hasTransaction() const;
95   virtual bool      commitTransaction( const QString& = QString::null );
96
97 private:
98   typedef QPtrList<SUIT_Operation> Operations;
99   void              stop( SUIT_Operation* );
100
101 private:
102   int               myId;
103   SUIT_Application* myApp;
104   SUIT_DataObject*  myRoot;
105   QString           myName;
106   bool              myIsSaved;
107   bool              myIsModified;
108   Operations        myOperations;
109   bool              myBlockChangeState;
110
111   friend class SUIT_Operation;
112 };
113
114 #ifdef WIN32
115 #pragma warning( default:4251 )
116 #endif
117
118 #endif