Salome HOME
PR: mergefrom_PAL_OCC_21Oct04
[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
52 class QAD_EXPORT QAD_Study : public QObject
53 {
54   Q_OBJECT
55
56 public:
57   QAD_Study(QAD_Application* app,
58             SALOMEDS::Study_var aStudy,
59             const QString& title);
60   virtual void Init(); 
61   ~QAD_Study();
62
63   /* Event filter */
64   bool eventFilter( QObject* o, QEvent* e);
65
66 public:
67   /* studyframes management */
68   QAD_StudyFrame*                  createStudyFrame(const QString& name, ViewType theViewType = VIEW_TYPE_MAX);
69   void                             removeStudyFrame( QAD_StudyFrame* );
70   int                              getStudyFramesCount() const;
71   const QList<QAD_StudyFrame>&     getStudyFrames() const;
72   QAD_StudyFrame*                  getStudyFrameByName( const QString& name );
73   QAD_StudyFrame*                  getFirstStudyFrame();
74   QAD_StudyFrame*                  getLastStudyFrame();
75   QAD_StudyFrame*                  getStudyFrame( unsigned i );
76   QAD_StudyFrame*                  getActiveStudyFrame() const;
77   
78   bool             getResult();
79
80   /* document state management */
81   bool             isActive() const;
82   bool             isSaved() const;
83   bool             isModified() const;
84   bool             isReadOnly() const;
85   void             setReadOnly(bool state);
86   bool             isLocked();
87   const QString&   getTitle() const;
88   int              getStudyId();
89   const QString&   getPath() const;
90   void             setTitle( const QString& title);
91   void             updateCaptions();
92   void             close();
93   QAD_Application* getApp() const;
94
95   /* visualization */
96   void             show();
97
98   /* operation management */
99   OperationState   getOperationState() const;
100   int              getOperationsCount() const;
101   QAD_Operation*   getOperation( unsigned i );
102   QAD_Operation*   getFirstOperation();
103   QAD_Operation*   getLastOperation();
104
105   void             abortAllOperations();
106   void             resumeAllOperations();
107   void             suspendAllOperations();
108
109   bool            onOperationStarted( QAD_Operation* );
110   void            onOperationFinished( QAD_Operation* );
111   void            onOperationSuspended( QAD_Operation* );
112   void            onOperationResumed( QAD_Operation* );
113   void            onOperationAborted( QAD_Operation* );
114
115   /* standard CAF document */
116   SALOMEDS::Study_var      getStudyDocument();
117
118   bool            undo();
119   bool            redo();
120   bool            canUndo() const;
121   bool            canRedo() const;
122
123   QAD_StudyFrame* newWindow3d(QString name = "", ViewType theViewType = VIEW_TYPE_MAX, bool toShow = true);
124   void            showFrame(QAD_StudyFrame* theFrame);
125
126   void            setMessage(const char* message);
127
128   void            updateObjBrowser( bool updateSelection = true );
129   void            updateUseCaseBrowser( bool updateSelection = true );
130   void            update3dViewers();
131
132   /*  interactive object management */
133   void            highlight( const Handle(SALOME_InteractiveObject)& IObject, 
134                              bool highlight, bool immediatly=true );
135   void            unHighlightAll();
136
137   void            renameIObject( const Handle(SALOME_InteractiveObject)& IObject,
138                                  QString newName );
139   int             typeIObject( const Handle(SALOME_InteractiveObject)& IObject );
140
141   bool            isInStudy( const Handle(SALOME_InteractiveObject)& IObject );
142   bool            isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
143   bool            isInViewer(const char* anEntry,
144                              const char* StudyFrameEntry);
145
146   /* selection */
147   void            Selection( QString aSelection );
148   QString         getSelection();
149
150   /* python interpreter */
151   QAD_PyInterp*   get_PyInterp(void);
152
153   QString  getNextStudyFrameName();
154
155   /* Child widgets handling (not QAD_StudyFrame) */
156   void            addChildWidget( QWidget* child );
157   void            removeChildWidget( QWidget* child );
158
159 signals:
160   void            docClosing( QAD_Study* );
161   void            docOperationTerminated( bool );
162   void            closed();
163
164 public slots:
165   void            onStudyFrameActivated( QAD_StudyFrame* );
166   void            onStudyDeactivated();
167   void            onLastStudyFrameClosing( QAD_StudyFrame* );
168
169 private:
170   void            addStudyFrame( QAD_StudyFrame* );
171   bool            initOperation( QAD_Operation* );
172   void            clearOperation( QAD_Operation* );
173
174 private:
175   SALOMEDS::Study_var       myStudy;
176
177   QList<QAD_Operation>      myOperations;
178   OperationState            myOperationState;
179
180   QAD_Application*          myApp;
181   QList<QAD_StudyFrame>     myStudyFrames;
182   QAD_StudyFrame*           myActiveStudyFrame;
183   int                       myStudyFrameCount;
184
185   QList<QWidget>            myChildWidgets;
186
187   QString                   myPath;
188   QString                   myTitle;
189
190   QString                   mySelection;
191
192   bool                      myIsActive;
193   bool                      myIsSaved;
194   bool                      myIsModified;
195   bool                      myIsReadOnly;
196   bool                      myResult;
197
198   QMutex*                   myMutex;
199   QAD_PyInterp*             myInterp;
200   TInitStudyThread*         myInitStudyThread;
201 };
202
203 #endif
204