Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef VISU_TIMEANIMATION_H
00028 #define VISU_TIMEANIMATION_H
00029
00030 #include "VISUConfig.hh"
00031
00032 #include "VISU_Result_i.hh"
00033 #include "SALOME_GenericObjPointer.hh"
00034
00035 #include <vector>
00036
00037 #include <QObject>
00038 #include <QList>
00039 #include <QThread>
00040
00041 class SVTK_ViewWindow;
00042 class VISU_Actor;
00043
00044 namespace VISU
00045 {
00046
00047 class ColoredPrs3d_i;
00048 class ExecutionState;
00049 class DumpPath;
00050 }
00051
00052 struct FieldData
00053 {
00054 VISU::VISUType myPrsType;
00055 _PTR(SObject) myField;
00056 long myNbTimes;
00057 long myNbFrames;
00058 std::vector<VISU::ColoredPrs3d_i*> myPrs;
00059 std::vector<VISU_Actor*> myActors;
00060 std::vector<double> myTiming;
00061 CORBA::Float myOffset[3];
00062 typedef SALOME::GenericObjPtr<VISU::Result_i> TResultPtr;
00063 TResultPtr myResult;
00064 };
00065
00066
00067 class VISU_I_EXPORT VISU_TimeAnimation: public QThread
00068 {
00069 Q_OBJECT;
00070
00071 public:
00072 enum DumpMode { DM_None = 0, DM_Picture, DM_Video };
00073
00074 protected:
00075 CORBA::Boolean _generateFrames();
00076 void _connectView();
00077 void _visibilityOff(int num_field, int num_frame);
00078 void _clearView();
00079 void _clearData(FieldData& theData);
00080 void _startAnimation();
00081 void _nextFrame();
00082 void _prevFrame();
00083 void _firstFrame();
00084 void _lastFrame();
00085 void _gotoFrame(CORBA::Long theFrame);
00086
00087 void _emitFrameChanged(long theNewFrame, double theTime);
00088 void _emitStopped();
00089
00090 void parallelAnimation( bool& theIsDumping, QList<int>& theIndexList );
00091 void successiveAnimation( bool& theIsDumping, QList<int>& theIndexList );
00092 void saveImages( int theFieldId, double& theOneVal, int& theNbFiles, QList<int>& theIndexList );
00093
00094 public:
00095
00096
00097
00098
00099 static VISU::Result_i* createPresent (_PTR(SObject) theField);
00100 static double getTimeValue (_PTR(SObject) theTimestamp);
00101
00102 VISU_TimeAnimation(_PTR(Study) theStudy,
00103 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
00104 ~VISU_TimeAnimation();
00105
00106 virtual VISU::VISUType GetType() { return VISU::TNONE;};
00107
00108 bool addField (_PTR(SObject) theField);
00109 bool addField (SALOMEDS::SObject_ptr theField);
00110 FieldData& getFieldData (int theNum) { return myFieldsLst[theNum]; }
00111
00112 CORBA::Boolean generateFrames();
00113 void generatePresentations(CORBA::Long theFieldNum);
00114 void setViewer(SVTK_ViewWindow* theView) { myView = theView; _connectView(); }
00115 SVTK_ViewWindow* getViewer() { return myView; }
00116 void clearView();
00117 void clearData(FieldData& theData);
00118 void clearFieldData() { myFieldsLst.clear();};
00119
00120 void visibilityOff(int num_field, int num_frame);
00121 void stopAnimation();
00122 void startAnimation();
00123 void nextFrame();
00124 void prevFrame();
00125 void firstFrame();
00126 void lastFrame();
00127 void gotoFrame(CORBA::Long theFrame);
00128
00129 CORBA::Long getNbFields() { return myFieldsLst.size(); }
00130 CORBA::Long getNbFrames();
00131 CORBA::Long getCurrentFrame() { return myFrame; }
00132
00133 long getAbsoluteFrameNumber(std::pair<int,long> theFieldTimeStamp);
00134 std::pair<int,long> getRelativeFrameNumber(long theFrame);
00135
00136 VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
00137
00138 void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
00139 VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
00140
00141 void setSpeed(CORBA::Long theSpeed);
00142 CORBA::Long getSpeed() { return mySpeed; }
00143
00144 CORBA::Boolean isProportional() { return myProportional; }
00145
00146 void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax)
00147 { myTimeMinVal = theMin; myTimeMaxVal = theMax; }
00148
00149 CORBA::Double getMinRange() { return myTimeMinVal; }
00150 CORBA::Double getMaxRange() { return myTimeMaxVal; }
00151 CORBA::Boolean isRangeDefined() { return !((myTimeMaxVal == 0) && (myTimeMinVal == myTimeMaxVal)); }
00152
00153 void setAnimationSequence(const char* theSequence);
00154 char* getAnimationSequence();
00155 CORBA::Boolean isSequenceDefined();
00156
00157 bool getIndicesFromSequence( QString theSequence, QList<long>& theIndices );
00158
00159 void dumpTo(const char* thePath);
00160 std::string setDumpFormat(const char* theFormat);
00161
00162 void setTimeStampFrequency(CORBA::Long theFrequency);
00163 CORBA::Long getTimeStampFrequency() { return myTimeStampFrequency; }
00164
00165 int getDumpMode() const { return myDumpMode; }
00166
00167 bool checkAVIMaker() const;
00168
00169 QString getLastErrorMsg() { return myLastError; }
00170
00171 CORBA::Boolean isCycling() { return myCycling; }
00172 CORBA::Boolean isCleaningMemoryAtEachFrame() { return myCleaningMemoryAtEachFrame; }
00173
00174 CORBA::Double getMinTime() { return myTimeMin;}
00175 CORBA::Double getMaxTime() { return myTimeMax;}
00176
00177 void setProportional(CORBA::Boolean theProp) { myProportional = theProp; }
00178 void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; }
00179 void setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle) { myCleaningMemoryAtEachFrame = theCycle; }
00180
00181 SALOMEDS::SObject_ptr publishInStudy();
00182 void restoreFromStudy(SALOMEDS::SObject_ptr theField);
00183 void restoreFromStudy(_PTR(SObject) theField);
00184 void saveAnimation();
00185 bool isSavedInStudy() const { return !myAnimEntry.isEmpty(); }
00186 _PTR(Study) getStudy() const { return myStudy; }
00187
00188 void setAnimationMode(VISU::Animation::AnimationMode theMode) { myAnimationMode = theMode; }
00189 VISU::Animation::AnimationMode getAnimationMode() { return myAnimationMode; }
00190
00191 void ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) throw (SALOME::SALOME_Exception);
00192
00193 public slots:
00194 void setProportionalSlot(bool theProp) { myProportional = theProp; }
00195 void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
00196 void setCleaningMemoryAtEachFrameSlot(bool theCycle) { myCleaningMemoryAtEachFrame = theCycle; }
00197
00198 signals:
00199 void frameChanged(long theNewFrame, double theTime);
00200 void stopped();
00201
00202 protected:
00203 void run();
00204 QString GenerateName();
00205
00206 private slots:
00207 void onViewDeleted();
00208
00209 private:
00210 QString myLastError;
00211
00212 QList<FieldData> myFieldsLst;
00213 VISU::ExecutionState* myExecutionState;
00214 long myFrame;
00215 std::vector<long> myFieldsAbsFrames;
00216 int mySpeed;
00217 bool myProportional;
00218 bool myCycling;
00219 bool myCleaningMemoryAtEachFrame;
00220 _PTR(Study) myStudy;
00221
00222 VISU::DumpPath* myDumpPath;
00223
00224 VISU::Animation::AnimationMode myAnimationMode;
00225 double myTimeMinVal, myTimeMaxVal;
00226 double myTimeMin , myTimeMax ;
00227 QString mySequence;
00228 QString myDumpFormat;
00229 QString myAVIMaker;
00230 long myFileIndex;
00231 SVTK_ViewWindow* myView;
00232
00233 int myDumpMode;
00234 int myTimeStampFrequency;
00235
00236 QString myAnimEntry;
00237
00238 static int myNBAnimations;
00239 };
00240
00241
00242 class VISU_I_EXPORT VISU_TimeAnimation_i: public virtual POA_VISU::Animation,
00243 public virtual VISU::Base_i
00244 {
00245 VISU_TimeAnimation* myAnim;
00246 public:
00247 VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy,
00248 VISU::View3D_ptr theView3D = VISU::View3D::_nil());
00249 ~VISU_TimeAnimation_i();
00250
00251 virtual VISU::VISUType GetType() { return VISU::TANIMATION; }
00252
00253
00254 virtual bool addField(SALOMEDS::SObject_ptr theField);
00255 virtual void clearFields();
00256
00257 virtual CORBA::Boolean generateFrames();
00258 virtual void generatePresentations(CORBA::Long theFieldNum);
00259
00260 virtual void clearView();
00261
00262 virtual void stopAnimation();
00263 virtual void startAnimation();
00264 virtual void nextFrame();
00265 virtual void prevFrame();
00266 virtual void firstFrame();
00267 virtual void lastFrame();
00268 virtual void gotoFrame(CORBA::Long theFrame);
00269
00270 virtual CORBA::Long getNbFields();
00271 virtual CORBA::Long getNbFrames();
00272 virtual CORBA::Boolean isRunning();
00273 virtual CORBA::Long getCurrentFrame();
00274
00275 virtual VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
00276
00277 virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType);
00278 virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum);
00279
00280 virtual void setSpeed(CORBA::Long theSpeed);
00281 virtual CORBA::Long getSpeed();
00282
00283 virtual CORBA::Boolean isProportional();
00284
00285 virtual void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax);
00286
00287 virtual CORBA::Double getMinRange();
00288 virtual CORBA::Double getMaxRange();
00289 virtual CORBA::Boolean isRangeDefined();
00290
00291 virtual void setAnimationSequence(const char* theSequence);
00292 virtual char* getAnimationSequence();
00293 virtual CORBA::Boolean isSequenceDefined();
00294
00295 virtual void dumpTo(const char* thePath);
00296 virtual char* setDumpFormat(const char* theFormat);
00297
00298 virtual void setTimeStampFrequency(CORBA::Long theFrequency);
00299 virtual CORBA::Long getTimeStampFrequency();
00300
00301 virtual CORBA::Boolean isCycling();
00302 virtual CORBA::Boolean isCleaningMemoryAtEachFrame();
00303
00304 virtual CORBA::Double getMinTime();
00305 virtual CORBA::Double getMaxTime();
00306
00307 virtual void setProportional(CORBA::Boolean theProp);
00308 virtual void setCycling(CORBA::Boolean theCycle);
00309 virtual void setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle);
00310
00311 virtual SALOMEDS::SObject_ptr publishInStudy();
00312 virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
00313 virtual CORBA::Boolean isSavedInStudy();
00314 virtual void saveAnimation();
00315
00316 virtual void setAnimationMode(VISU::Animation::AnimationMode theMode);
00317 virtual VISU::Animation::AnimationMode getAnimationMode();
00318
00319 virtual void ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) throw (SALOME::SALOME_Exception);
00320 };
00321
00322 #endif //VISU_TIMEANIMATION_H