Salome HOME
Merge with PAL/SALOME 2.1.0d
[modules/kernel.git] / src / SALOMEGUI / QAD_Study.h
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : QAD_Study.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef QAD_STUDY_H
30 #define QAD_STUDY_H
31
32 #include "QAD_Operation.h"
33 #include "QAD_StudyFrame.h"
34
35 #include "SALOME_InteractiveObject.hxx"
36
37 // IDL Headers
38 #include <SALOMEconfig.h>
39 #include CORBA_SERVER_HEADER(SALOMEDS)
40
41 // QT Includes
42 #include <qdict.h>
43 #include <qobject.h>
44 #include <qstring.h>
45
46 class QAD_Application;
47
48 class QMutex;
49 class QAD_PyInterp;
50 class TInitStudyThread;
51 class QAD_ViewFrame;
52
53 class QAD_EXPORT QAD_Study : public QObject
54 {
55   Q_OBJECT
56
57 public:
58   QAD_Study(QAD_Application* app,
59             SALOMEDS::Study_var aStudy,
60             const QString& title);
61   virtual void Init(); 
62   ~QAD_Study();
63
64   /* Event filter */
65   bool eventFilter( QObject* o, QEvent* e);
66
67 public:
68   /* studyframes management */
69   QAD_StudyFrame*                  createStudyFrame(const QString& name, ViewType theViewType = VIEW_TYPE_MAX);
70   void                             removeStudyFrame( QAD_StudyFrame* );
71   int                              getStudyFramesCount() const;
72   const QList<QAD_StudyFrame>&     getStudyFrames() const;
73   QAD_StudyFrame*                  getStudyFrameByName( const QString& name );
74   QAD_StudyFrame*                  getFirstStudyFrame();
75   QAD_StudyFrame*                  getLastStudyFrame();
76   QAD_StudyFrame*                  getStudyFrame( unsigned i );
77   QAD_StudyFrame*                  getActiveStudyFrame() const;
78   
79   bool             getResult();
80
81   /* document state management */
82   bool             isActive() const;
83   bool             isSaved() const;
84   bool             isModified() const;
85   bool             isReadOnly() const;
86   void             setReadOnly(bool state);
87   bool             isLocked();
88   const QString&   getTitle() const;
89   int              getStudyId();
90   const QString&   getPath() const;
91   void             setTitle( const QString& title);
92   void             updateCaptions();
93   void             close();
94   QAD_Application* getApp() const;
95
96   /* visualization */
97   void             show();
98
99   /* operation management */
100   OperationState   getOperationState() const;
101   int              getOperationsCount() const;
102   QAD_Operation*   getOperation( unsigned i );
103   QAD_Operation*   getFirstOperation();
104   QAD_Operation*   getLastOperation();
105
106   void             abortAllOperations();
107   void             resumeAllOperations();
108   void             suspendAllOperations();
109
110   bool            onOperationStarted( QAD_Operation* );
111   void            onOperationFinished( QAD_Operation* );
112   void            onOperationSuspended( QAD_Operation* );
113   void            onOperationResumed( QAD_Operation* );
114   void            onOperationAborted( QAD_Operation* );
115
116   /* standard CAF document */
117   SALOMEDS::Study_var      getStudyDocument();
118
119   bool            undo();
120   bool            redo();
121   bool            canUndo() const;
122   bool            canRedo() const;
123
124   QAD_StudyFrame* newWindow3d(QString name = "", ViewType theViewType = VIEW_TYPE_MAX, bool toShow = true);
125   void            showFrame(QAD_StudyFrame* theFrame);
126
127   void            setMessage(const char* message);
128
129   void            updateObjBrowser( bool updateSelection = true );
130   void            updateUseCaseBrowser( bool updateSelection = true );
131   void            update3dViewers();
132
133   /*  interactive object management */
134   void            highlight( const Handle(SALOME_InteractiveObject)& IObject, 
135                              bool highlight, bool immediatly=true );
136   void            unHighlightAll();
137
138   void            renameIObject( const Handle(SALOME_InteractiveObject)& IObject,
139                                  QString newName );
140   int             typeIObject( const Handle(SALOME_InteractiveObject)& IObject );
141
142   bool            isInStudy( const Handle(SALOME_InteractiveObject)& IObject );
143   bool            isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
144   bool            isInViewer(const char* anEntry,
145                              const char* StudyFrameEntry);
146
147   /* selection */
148   void            Selection( QString aSelection );
149   QString         getSelection() const;
150
151   /* python interpreter */
152   QAD_PyInterp*   get_PyInterp(void);
153
154   QString  getNextStudyFrameName();
155
156   /* Child widgets handling (not QAD_StudyFrame) */
157   void            addChildWidget( QWidget* child );
158   void            removeChildWidget( QWidget* child );
159
160 signals:
161   void            docClosing( QAD_Study* );
162   void            docOperationTerminated( bool );
163   void            closed();
164   void            supervStudyFrameClosing( QAD_ViewFrame* );
165
166 public slots:
167   void            onStudyFrameActivated( QAD_StudyFrame* );
168   void            onStudyDeactivated();
169   void            onLastStudyFrameClosing( QAD_StudyFrame* );
170
171 private:
172   void            addStudyFrame( QAD_StudyFrame* );
173   bool            initOperation( QAD_Operation* );
174   void            clearOperation( QAD_Operation* );
175
176 private:
177   SALOMEDS::Study_var       myStudy;
178
179   QList<QAD_Operation>      myOperations;
180   OperationState            myOperationState;
181
182   QAD_Application*          myApp;
183   QList<QAD_StudyFrame>     myStudyFrames;
184   QAD_StudyFrame*           myActiveStudyFrame;
185   int                       myStudyFrameCount;
186
187   QList<QWidget>            myChildWidgets;
188
189   QString                   myPath;
190   QString                   myTitle;
191
192   QString                   mySelection;
193
194   bool                      myIsActive;
195   bool                      myIsSaved;
196   bool                      myIsModified;
197   bool                      myIsReadOnly;
198   bool                      myResult;
199
200   QMutex*                   myMutex;
201   QAD_PyInterp*             myInterp;
202   TInitStudyThread*         myInitStudyThread;
203 };
204
205 #endif
206