Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/gui.git] / src / SUIT / SUIT_Study.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, 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.
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 #ifndef SUIT_STUDY_H
23 #define SUIT_STUDY_H
24
25 #include "SUIT.h"
26
27 #include <QList>
28 #include <QObject>
29 #include <QListIterator>
30
31 class SUIT_DataObject;
32 class SUIT_Application;
33 class SUIT_Operation;
34
35 #ifdef WIN32
36 #pragma warning( disable:4251 )
37 #endif
38
39 class SUIT_EXPORT SUIT_Study : public QObject
40 {
41   Q_OBJECT
42   
43 public:
44   SUIT_Study( SUIT_Application* );
45   virtual ~SUIT_Study();
46
47   virtual int       id() const;
48
49   SUIT_DataObject*  root() const;
50   QString           studyName() const;
51   SUIT_Application* application() const;
52
53   virtual bool      isSaved()  const;
54   virtual bool      isModified() const;
55   virtual void      Modified();
56
57   virtual void      closeDocument( bool = true );
58   virtual bool      openDocument( const QString& );
59   virtual bool      createDocument( const QString& );
60
61   bool              saveDocument();
62   virtual bool      saveDocumentAs( const QString& );
63
64   virtual void      update();
65
66   virtual void      sendChangesNotification();
67
68   // Operation management
69   SUIT_Operation*   activeOperation() const;
70   virtual void      abortAllOperations();
71   const QList<SUIT_Operation*>& operations() const;
72   
73   virtual SUIT_Operation* blockingOperation( SUIT_Operation* ) const;
74
75   bool              start( SUIT_Operation*, const bool check = true );
76   bool              abort( SUIT_Operation* );
77   bool              commit( SUIT_Operation* );
78   bool              suspend( SUIT_Operation* );
79   bool              resume( SUIT_Operation* );
80
81   virtual void      restoreState(int savePoint);
82
83 signals:
84   void              studyModified( SUIT_Study* );
85
86 protected:
87   virtual void      setIsSaved( const bool );
88   virtual void      setIsModified( const bool );
89   virtual void      setRoot( SUIT_DataObject* );
90   virtual void      setStudyName( const QString& );
91
92   virtual void      operationStarted( SUIT_Operation* );
93   virtual void      operationAborted( SUIT_Operation* );
94   virtual void      operationStopped( SUIT_Operation* );
95   virtual void      operationCommited( SUIT_Operation* );
96
97   virtual bool      openTransaction();
98   virtual bool      abortTransaction();
99   virtual bool      hasTransaction() const;
100   virtual bool      commitTransaction( const QString& = QString() );
101
102 private:
103   typedef QList<SUIT_Operation*> Operations;
104   void              stop( SUIT_Operation* );
105
106 private:
107   int               myId;
108   SUIT_Application* myApp;
109   SUIT_DataObject*  myRoot;
110   QString           myName;
111   bool              myIsSaved;
112   bool              myIsModified;
113   Operations        myOperations;
114   bool              myBlockChangeState;
115
116   friend class SUIT_Operation;
117 };
118
119 #ifdef WIN32
120 #pragma warning( default:4251 )
121 #endif
122
123 #endif