From: ouv Date: Mon, 5 Apr 2010 11:55:39 +0000 (+0000) Subject: 0020713: [CEA 396] VISU frame rate X-Git-Tag: V5_1_main_20100406~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4b2ca1722150fa6f0fece8e7791350a0648ffa20;p=modules%2Fvisu.git 0020713: [CEA 396] VISU frame rate --- diff --git a/doc/salome/gui/VISU/images/animation.png b/doc/salome/gui/VISU/images/animation.png index 24518926..95965a24 100644 Binary files a/doc/salome/gui/VISU/images/animation.png and b/doc/salome/gui/VISU/images/animation.png differ diff --git a/doc/salome/gui/VISU/input/animating.doc b/doc/salome/gui/VISU/input/animating.doc index 09afa84c..e9fcb996 100644 --- a/doc/salome/gui/VISU/input/animating.doc +++ b/doc/salome/gui/VISU/input/animating.doc @@ -112,6 +112,11 @@ cycled animation of your presentation. your animation with proportional periods of time between every frame (not depending on the time stamps).

+Time stamp frequency spin box: this option is available if +Save animation to AVI file mode is turned on. It provides a +possibility to capture only timestamps with indices divisable by the +specified frequency, that allows to generate less voluminous films. +

Clean memory at each frame - this option allows to optimize the performance of the operation. diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 544dad9b..7ed8c91a 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -2008,6 +2008,16 @@ module VISU { */ string setDumpFormat(in string theFormat); + /*! Set frequency of timestamps used to generate AVI file. + * \param theFrequency The frequency of timestamps to use. + */ + void setTimeStampFrequency(in long theFrequency); + + /*! Get frequency of timestamps used to generate AVI file. + * \return The frequency of timestamps to use. + */ + long getTimeStampFrequency(); + /*! Returns True, if the playback of the animation is cycling. */ boolean isCycling(); diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 12a3641d..4eb9f200 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -122,6 +122,8 @@ + + diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 3fcd3a9b..84bdd1e2 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -165,6 +165,18 @@ number of time stamps or number of components is not the same! VISU_DISP_ONLY Display only on creation + + VISU_DUMP_MODE + Dump mode + + + VISU_DUMP_PICTURES + Save pictures to directory + + + VISU_DUMP_VIDEO + Save animation to AVI file + VISU_EDGE_COLOR Edge Color @@ -317,6 +329,10 @@ number of time stamps or number of components is not the same! VISU_NB_STEPS Number of steps + + VISU_NO_DUMP + No dump + VISU_ORIENTATION Orientation @@ -405,6 +421,10 @@ number of time stamps or number of components is not the same! VISU_SWEEPING_PREF Sweeping preferences + + VISU_TIME_STAMP_FREQUENCY + Time stamp frequency (for AVI generation) + VISU_TIME_STEP Time step(second) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 6229236e..b36302cd 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -4028,7 +4028,7 @@ void VisuGUI::createPreferences() // group: "Animation preferences" { int animationGroup = addPreference( tr( "VISU_ANIMATION_PREFERENCES" ), animationTab ); - setPreferenceProperty( animationGroup, "columns", 3 ); + setPreferenceProperty( animationGroup, "columns", 1 ); int speed = addPreference( tr( "Speed" ), animationGroup, LightApp_Preferences::IntSpin, "VISU", "speed" ); @@ -4041,6 +4041,26 @@ void VisuGUI::createPreferences() setPreferenceProperty( speed, "min", 1 ); setPreferenceProperty( speed, "max", 99 ); + + int dump_mode = addPreference( tr( "VISU_DUMP_MODE" ), animationGroup, + LightApp_Preferences::Selector, "VISU", "dump_mode" ); + + modes.clear(); + modes.append( tr( "VISU_NO_DUMP" ) ); + modes.append( tr( "VISU_DUMP_PICTURES" ) ); + modes.append( tr( "VISU_DUMP_VIDEO" ) ); + setPreferenceProperty( dump_mode, "strings", modes ); + + indices.clear(); + indices.append( 0 ); + indices.append( 1 ); + indices.append( 2 ); + setPreferenceProperty( dump_mode, "indexes", indices ); + + int time_stamp_frequency = addPreference( tr( "VISU_TIME_STAMP_FREQUENCY" ), animationGroup, + LightApp_Preferences::IntSpin, "VISU", "time_stamp_frequency" ); + setPreferenceProperty( time_stamp_frequency, "min", 1 ); + setPreferenceProperty( time_stamp_frequency, "max", 100 ); } // group: "Sweeping preferences" diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index c768f973..7198e984 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -95,6 +95,7 @@ #include #include #include +#include #include @@ -1775,9 +1776,25 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, this, SLOT( onBrowseAVI() )); aSaveLay->addWidget(myBrowseAVIBtn, 4, 2); + myFrequencyLbl = new QLabel("Time stamp frequency:", aSaveBox); + myFrequencyLbl->setEnabled(false); + aSaveLay->addWidget(myFrequencyLbl, 5, 0, 1, 2); + + myFrequencySpin = new QSpinBox(aSaveBox); + myFrequencySpin->setRange(1, 100); + myFrequencySpin->setValue(myAnimator->getTimeStampFrequency()); + myFrequencySpin->setEnabled(false); + aSaveLay->addWidget(myFrequencySpin, 5, 2); + mySaveAVICheck->setChecked(false); //mySaveAVICheck->setEnabled(myAnimator->checkAVIMaker()); + int aDumpMode = myAnimator->getDumpMode(); + if(aDumpMode == VISU_TimeAnimation::DM_Picture) + mySaveCheck->setChecked(true); + else if(aDumpMode == VISU_TimeAnimation::DM_Video && myAnimator->checkAVIMaker()) + mySaveAVICheck->setChecked(true); + TopLayout->addWidget(aSaveBox, 7, 0, 1, 4); QCheckBox* aCleanMemCheck = new QCheckBox("Clean memory at each frame",myPlayFrame); @@ -1936,6 +1953,7 @@ void VisuGUI_TimeAnimationDlg::onPlayPressed() } else if (mySaveAVICheck->isChecked()) { myAnimator->setDumpFormat("AVI"); myAnimator->dumpTo(myPathAVIEdit->text().toLatin1().data()); + myAnimator->setTimeStampFrequency(myFrequencySpin->value()); } else { myAnimator->dumpTo(""); } @@ -2112,6 +2130,8 @@ void VisuGUI_TimeAnimationDlg::onCheckDump(bool) myPathAVILbl->setEnabled(true); myPathAVIEdit->setEnabled(true); myBrowseAVIBtn->setEnabled(true); + myFrequencyLbl->setEnabled(true); + myFrequencySpin->setEnabled(true); } } else { @@ -2122,6 +2142,8 @@ void VisuGUI_TimeAnimationDlg::onCheckDump(bool) myPathAVILbl->setEnabled(false); myPathAVIEdit->setEnabled(false); myBrowseAVIBtn->setEnabled(false); + myFrequencyLbl->setEnabled(false); + myFrequencySpin->setEnabled(false); } mySaveCheck->setEnabled(!mySaveAVICheck->isChecked()); } diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.h b/src/VISUGUI/VisuGUI_TimeAnimation.h index 16216afa..8c4514a0 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.h +++ b/src/VISUGUI/VisuGUI_TimeAnimation.h @@ -63,6 +63,7 @@ class QCheckBox; class QComboBox; class QGroupBox; class QToolButton; +class QSpinBox; /*! * Auxilliary class for presentations definition @@ -247,6 +248,8 @@ class VisuGUI_TimeAnimationDlg: public QDialog QLineEdit* myPathAVIEdit; QLabel* myPathAVILbl; QPushButton* myBrowseAVIBtn; + QLabel* myFrequencyLbl; + QSpinBox* myFrequencySpin; QPushButton* myPublishBtn; QPushButton* mySaveBtn; diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index c2b29a68..3ad6231b 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -206,6 +206,9 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy, myDumpPath = ""; myAVIMaker = "jpeg2yuv"; + + myDumpMode = VISU::GetResourceMgr()->integerValue("VISU", "dump_mode", 0); + myTimeStampFrequency = VISU::GetResourceMgr()->integerValue("VISU", "time_stamp_frequency", 1); } @@ -1426,6 +1429,9 @@ void VISU_TimeAnimation::saveImages( int theFieldId, QString aDirPath = aFileInfo.absolutePath(); QString aBaseName = aFileInfo.fileName(); + if( myTimeStampFrequency > 1 && myFrame % myTimeStampFrequency != 0 ) + return; + switch (myFrame) { case 0: break; @@ -1485,7 +1491,7 @@ void VISU_TimeAnimation::run() // make AVI file if need if (isDumping && myDumpFormat.compare("AVI") == 0 && myExecutionState->IsActive()) { - double aFPS = 17.3 * mySpeed; + double aFPS = 17.3 * mySpeed / myTimeStampFrequency; QFileInfo aFileInfo(myDumpPath); QString aDirPath = aFileInfo.absolutePath(); @@ -1661,6 +1667,12 @@ std::string VISU_TimeAnimation::setDumpFormat(const char* theFormat) return myDumpFormat.toLatin1().data(); } +//------------------------------------------------------------------------ +void VISU_TimeAnimation::setTimeStampFrequency(CORBA::Long theFrequency) +{ + myTimeStampFrequency = theFrequency; +} + //------------------------------------------------------------------------ bool VISU_TimeAnimation::checkAVIMaker() const { @@ -2260,6 +2272,16 @@ char* VISU_TimeAnimation_i::setDumpFormat (const char* theFormat) return CORBA::string_dup(aDumpFormat.c_str()); } +void VISU_TimeAnimation_i::setTimeStampFrequency(CORBA::Long theFrequency) +{ + myAnim->setTimeStampFrequency(theFrequency); +} + +CORBA::Long VISU_TimeAnimation_i::getTimeStampFrequency() +{ + return myAnim->getTimeStampFrequency(); +} + CORBA::Boolean VISU_TimeAnimation_i::isCycling() { return myAnim->isCycling(); diff --git a/src/VISU_I/VISU_TimeAnimation.h b/src/VISU_I/VISU_TimeAnimation.h index cb485fc0..c23ce541 100644 --- a/src/VISU_I/VISU_TimeAnimation.h +++ b/src/VISU_I/VISU_TimeAnimation.h @@ -66,6 +66,9 @@ class VISU_I_EXPORT VISU_TimeAnimation: public QThread { Q_OBJECT; + public: + enum DumpMode { DM_None = 0, DM_Picture, DM_Video }; + protected: CORBA::Boolean _generateFrames(); void _connectView(); @@ -153,6 +156,12 @@ class VISU_I_EXPORT VISU_TimeAnimation: public QThread void dumpTo(const char* thePath) { myDumpPath = thePath; } std::string setDumpFormat(const char* theFormat); + + void setTimeStampFrequency(CORBA::Long theFrequency); + CORBA::Long getTimeStampFrequency() { return myTimeStampFrequency; } + + int getDumpMode() const { return myDumpMode; } + bool checkAVIMaker() const; QString getLastErrorMsg() { return myLastError; } @@ -218,6 +227,9 @@ class VISU_I_EXPORT VISU_TimeAnimation: public QThread long myFileIndex; SVTK_ViewWindow* myView; + int myDumpMode; + int myTimeStampFrequency; + QString myAnimEntry; static int myNBAnimations; @@ -280,6 +292,9 @@ public: virtual void dumpTo(const char* thePath); virtual char* setDumpFormat(const char* theFormat); + virtual void setTimeStampFrequency(CORBA::Long theFrequency); + virtual CORBA::Long getTimeStampFrequency(); + virtual CORBA::Boolean isCycling(); virtual CORBA::Boolean isCleaningMemoryAtEachFrame();