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