Salome HOME
40f40f673edb9fd3a1010825f7c9ed3272dcec99
[modules/visu.git] / src / VISUGUI / VisuGUI_TimeAnimation.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 //  File   : VisuGUI_TimeAnimation.h
23 //  Author : Vitaly SMETANNIKOV
24 //  Module : VISU
25 //
26 #ifndef VISUGUI_TIMEANIMATION_H
27 #define VISUGUI_TIMEANIMATION_H
28
29 #include "QtxDoubleSpinBox.h"
30 #include "SALOMEDSClient_Study.hxx"
31
32 #include "VTKViewer.h"
33
34 #include <QDialog>
35 #include <QButtonGroup>
36 #include <QStackedWidget>
37 #include <QMap>
38
39 // IDL headers
40 #include "SALOMEconfig.h"
41 #include CORBA_SERVER_HEADER(VISU_Gen)
42
43 #include <vector>
44 #include <map>
45
46 class VisuGUI;
47 class SalomeApp_Module;
48 class VISU_TimeAnimation;
49
50 namespace VISU
51 {
52   class Prs3d_i;
53   class PointMap3d_i;
54 }
55
56 class SVTK_ViewWindow;
57
58 //class QtxDoubleSpinBox;
59
60 class QLabel;
61 class QSlider;
62 class QListWidget;
63 class QLineEdit;
64 class QCheckBox;
65 class QComboBox;
66 class QGroupBox;
67 class QToolButton;
68
69 /*!
70  * Auxilliary class for presentations definition
71  */
72 class ArrangeDlg: public QDialog
73 {
74   Q_OBJECT
75  public:
76   enum { AutoMode, ManualMode };
77   enum { XAxis, YAxis, ZAxis };
78
79   ArrangeDlg(QWidget* theParent,
80              VISU_TimeAnimation* theAnimator);
81
82   ArrangeDlg(QWidget* theParent,
83              const SalomeApp_Module* theModule,
84              SVTK_ViewWindow* theViewWindow);
85
86   ~ArrangeDlg() {};
87
88   int getMode() const { return  myStackWgt->indexOf(myStackWgt->currentWidget()); }
89   double getDistance() const { return myDistVal->value(); }
90   int getAxis() const { return myAxisGrp->id(myAxisGrp->checkedButton()); }
91
92  protected slots:
93   virtual void accept();
94   void onFieldChange(int);
95
96  private:
97   struct Offset {
98     vtkFloatingPointType myOffset[3];
99   };
100
101
102   void init();
103   void acceptAnimation();
104   void acceptViewWindow();
105
106   VISU_TimeAnimation* myAnimator;
107   SVTK_ViewWindow   * myViewWindow;
108
109   QStackedWidget*       myStackWgt;
110   QButtonGroup*       myAxisGrp;
111   QtxDoubleSpinBox*      myDistVal;
112   QListWidget*           myFieldLst;
113   QtxDoubleSpinBox*      myCoord[3];
114   QList<Offset>  myOffsets;
115
116   QCheckBox*          mySaveChk;
117
118   int               myCurrent;
119   QMap<VISU::Prs3d_i*, int> myPrsMap;
120   QMap<VISU::PointMap3d_i*, int> myPointMapPrsMap;
121 };
122
123
124 class SetupDlg : public QDialog
125 {
126   Q_OBJECT
127
128  class LineEdit;
129
130  public:
131   SetupDlg( QWidget* theParent, VisuGUI* theModule,
132             VISU_TimeAnimation* theAnimator );
133   ~SetupDlg() {};
134
135  public:
136   void initialize();
137
138   bool isRegenerate() const { return myIsRegenerate; }
139   void setIsRegenerate( const bool on ) { myIsRegenerate = on; }
140
141  private slots:
142   void onClose();
143   void onFieldChange(int theIndex);
144   void onTypeChanged(int theIndex);
145   //  void onScalarBarDlg();
146   void onPreferencesDlg();
147   void onRangeCheck(bool theCheck);
148   //  void onMinValue(double theVal);
149   //  void onMaxValue(double theVal);
150   void onMinValue();
151   void onMaxValue();
152   void onMinValueEdit(const QString&);
153   void onMaxValueEdit(const QString&);
154   void onSequenceCheck(bool theCheck);
155   void onIndicesChanged(const QString& theIndices);
156   void onValuesChanged();
157   void onArrangeDlg();
158
159  private:
160   VisuGUI* myModule;
161   VISU_TimeAnimation* myAnimator;
162
163   bool myIsRegenerate;
164
165   QListWidget* myFieldLst;
166   QComboBox* myTypeCombo;
167   std::vector<int> myComboId2TypeId;
168   std::map<int,int> myTypeId2ComboId;
169
170   QPushButton* myPropBtn;
171   QPushButton* myArrangeBtn;
172   QGroupBox* myUseRangeBox;
173   //  QtxDoubleSpinBox* myMinVal;
174   //  QtxDoubleSpinBox* myMaxVal;
175   QLineEdit* myMinVal;
176   QLineEdit* myMaxVal;
177
178   QGroupBox* myUseSequenceBox;
179   QLineEdit* myIndices;
180   QListWidget* myValues;
181 };
182
183 class VisuGUI_TimeAnimationDlg: public QDialog
184 {
185     Q_OBJECT
186  public:
187     VisuGUI_TimeAnimationDlg(VisuGUI* theModule,
188                              _PTR(Study) theStudy,
189                              VISU::Animation::AnimationMode theMode = VISU::Animation::PARALLEL);
190     ~VisuGUI_TimeAnimationDlg();
191
192     bool addField(_PTR(SObject) theField);
193     void clearView();
194
195     void restoreFromStudy(_PTR(SObject) theAnimation);
196
197  protected:
198     virtual void closeEvent(QCloseEvent* theEvent);
199     virtual void showEvent(QShowEvent* theEvent);
200     virtual void keyPressEvent(QKeyEvent* theEvent);
201     void stopAnimation();
202
203  private slots:
204    void onTypeChange(int index);
205    void onPlayPressed();
206    void onBackPressed();
207    void onForvardPressed();
208    void onLastPressed();
209    void onFirstPressed();
210    void onSetupDlg();
211    void onWindowChanged(int index);
212    void createFrames();
213    void onSpeedChange(double theSpeed);
214    void onExecution(long theNewFrame, double theTime);
215    void onBrowse();
216    void onBrowseAVI();
217    void onCheckDump(bool);
218    void onStop();
219    void onHelp();
220    void saveToStudy();
221    void publishToStudy();
222    /*!Sets dump format for myAnimator (setDumpFormat(...)), from myPicsFormat.*/
223    void onPicsFormatChanged();
224    /*!Sets path for myAnimator (dumpTo(...)), from myPathEdit.*/
225    void onPathChanged();
226
227  private:
228     // Data
229     VisuGUI* myModule;
230     VISU_TimeAnimation* myAnimator;
231
232     // widgets
233     QSlider* mySlider;
234     QComboBox* myTypeCombo;
235     QPushButton* myPropBtn;
236     QPushButton* myPlayBtn;
237     QLabel* myTimeLbl;
238     QPushButton* mySetupBtn;
239     QPushButton* myGenBtn;
240
241     QFrame* myPlayFrame;
242     SetupDlg* mySetupDlg;
243
244     QCheckBox* mySaveCheck;
245     QComboBox* myPicsFormat;
246     QLineEdit* myPathEdit;
247
248     QCheckBox*   mySaveAVICheck;
249     QLineEdit*   myPathAVIEdit;
250     QLabel*      myPathAVILbl;
251     QPushButton* myBrowseAVIBtn;
252
253     QPushButton* myPublishBtn;
254     QPushButton* mySaveBtn;
255 };
256
257 #endif  //VISUGUI_TIMEANIMATION_H