]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
0020713: [CEA 396] VISU frame rate
authorouv <ouv@opencascade.com>
Mon, 5 Apr 2010 11:55:39 +0000 (11:55 +0000)
committerouv <ouv@opencascade.com>
Mon, 5 Apr 2010 11:55:39 +0000 (11:55 +0000)
doc/salome/gui/VISU/images/animation.png
doc/salome/gui/VISU/input/animating.doc
idl/VISU_Gen.idl
resources/SalomeApp.xml
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISUGUI/VisuGUI_TimeAnimation.h
src/VISU_I/VISU_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.h

index 24518926f9da71a47c9022928aa6abb32395d1f3..95965a24d8cac4f2206d1798aa6599bf11186f83 100644 (file)
Binary files a/doc/salome/gui/VISU/images/animation.png and b/doc/salome/gui/VISU/images/animation.png differ
index 09afa84ce6ad2dc2105d96ba8ea50efc90b2f728..e9fcb996d63a9f13bd188e6d490b6928de156ef7 100644 (file)
@@ -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).
 <br><br>
+<b>Time stamp frequency</b> spin box: this option is available if
+<b>Save animation to AVI file</b> 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.
+<br><br>
 <b>Clean memory at each frame</b> - this option allows to optimize the
 performance of the operation.
 
index 544dad9b402d430a24b836801c5ee6d4aac5bdbc..7ed8c91a1512acc215d9de2ecc249b5b8bb2d5a3 100644 (file)
@@ -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();
index 12a3641d0b2777650d830a5506a00cd390af6562..4eb9f2001c23eebfc9d72b6b64fa9cc320bc23b2 100644 (file)
     <parameter name="cycled_animation"           value="false"/>
     <parameter name="use_proportional_timing"    value="false"/>
     <parameter name="clean_memory_at_each_frame" value="false"/>
+    <parameter name="dump_mode"                  value="0"/>
+    <parameter name="time_stamp_frequency"       value="1"/>
     <parameter name="mouse_behaviour"        value="0"   />
     <parameter name="speed_increment"        value="10"  />
     <parameter name="spacemouse_func1_btn"   value="1"   />
index 3fcd3a9be84350bf3409bb1401a504a967ac0ee0..84bdd1e2abaac79e55c23acac9a9f52a45ea6905 100644 (file)
@@ -165,6 +165,18 @@ number of time stamps or number of components is not the same!</translation>
             <source>VISU_DISP_ONLY</source>
             <translation>Display only on creation</translation>
         </message>
+        <message>
+            <source>VISU_DUMP_MODE</source>
+            <translation>Dump mode</translation>
+        </message>
+        <message>
+            <source>VISU_DUMP_PICTURES</source>
+            <translation>Save pictures to directory</translation>
+        </message>
+        <message>
+            <source>VISU_DUMP_VIDEO</source>
+            <translation>Save animation to AVI file</translation>
+        </message>
         <message>
             <source>VISU_EDGE_COLOR</source>
             <translation>Edge Color</translation>
@@ -317,6 +329,10 @@ number of time stamps or number of components is not the same!</translation>
             <source>VISU_NB_STEPS</source>
             <translation>Number of steps</translation>
         </message>
+        <message>
+            <source>VISU_NO_DUMP</source>
+            <translation>No dump</translation>
+        </message>
         <message>
             <source>VISU_ORIENTATION</source>
             <translation>Orientation</translation>
@@ -405,6 +421,10 @@ number of time stamps or number of components is not the same!</translation>
             <source>VISU_SWEEPING_PREF</source>
             <translation>Sweeping preferences</translation>
         </message>
+        <message>
+            <source>VISU_TIME_STAMP_FREQUENCY</source>
+            <translation>Time stamp frequency (for AVI generation)</translation>
+        </message>
         <message>
             <source>VISU_TIME_STEP</source>
             <translation>Time step(second)</translation>
index 6229236ed2d00e2a1fd5f111f6ad7bdc338b2467..b36302cdf0c13402ad8ec5ea8c0f15e3a98ce261 100644 (file)
@@ -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"
index c768f973f23acf6027cbd2927f6ceaceeee85b13..7198e984573300c9eb16cba99f40f347efedfad1 100644 (file)
@@ -95,6 +95,7 @@
 #include <QGroupBox>
 #include <QPushButton>
 #include <QLabel>
+#include <QSpinBox>
 
 #include <qwt_wheel.h>
 
@@ -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());
   }
index 16216afa405dae5eeef3ce2f5eb0e6ba62788a52..8c4514a03bc74db592fe46d31b37338d5b0078dc 100644 (file)
@@ -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;
index c2b29a6858ab4084fd4471b03e950231d14714ec..3ad6231b0e3d9f27bc0c217947cf5486dda7f5db 100644 (file)
@@ -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();
index cb485fc075b35c1d8afc50796253bedd495afe77..c23ce541451a03017252740f6a43a049809b2f6f 100644 (file)
@@ -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();