]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for bug PAL8166 : [IMP] A flag "clean memory after each frame" in visu animation :
authormkr <mkr@opencascade.com>
Tue, 24 Oct 2006 08:58:38 +0000 (08:58 +0000)
committermkr <mkr@opencascade.com>
Tue, 24 Oct 2006 08:58:38 +0000 (08:58 +0000)
1. now we use ProcessEvent mechanism from SALOME_Event instead of
qApp->lock() and qApp->unlock();
2. add fix for bug IPAL12899 from WP_DEV branch;
3. the following characteristics from "Animation" dialog are
available now from Post-Pro preferences too
-- Speed
-- Cycled animation
-- Use proportional timing
-- Clean memory at each frame
4. the tab order in Post-Pro preferences was changed: now it looks like
"MED import"-"Scalar Bar"-"CutLines"-"Sweep,Animation"-"Representation"-...

resources/SalomeApp.xml
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.h

index 666ff6ebf6b8e6f990013cc53358b7be19450299..646e94300b623d42c7ef0f4e4e8130a953ed625a 100644 (file)
     <parameter name="sweeping_number_cycles" value="1"   />
     <parameter name="sweeping_number_steps"  value="20"  />
     <parameter name="sweeping_time_step"     value="0.2" />
+    <parameter name="speed"                     value="1"/>
+    <parameter name="cycled_animation"          value="false"/>
+    <parameter name="use_proportional_timing"   value="false"/>
+    <parameter name="clean_memory_at_each_frame" value="false"/>
     <parameter name="mouse_behaviour"        value="0"   />
     <parameter name="speed_increment"        value="10"  />
     <parameter name="spacemouse_func1_btn"   value="1"   />
index 07efd2bc8937710f8ef01c7fc06fbc0a49d982b4..a0b3895a6acaf7d540d53f0d9a233753b2b9742b 100644 (file)
@@ -2892,6 +2892,20 @@ extern "C" {
 
 void VisuGUI::createPreferences()
 {
+  // TAB: "MED import"
+  int importTab = addPreference( tr( "MED import" ) );
+  
+  // group: "MED files import"
+  int importGr = addPreference( tr( "MED files import" ), importTab );
+  setPreferenceProperty( importGr, "columns", 1 );
+  addPreference( tr( "Use build progress" ), importGr, LightApp_Preferences::Bool, "VISU", "use_build_progress" );
+  addPreference( tr( "Full MED loading" ), importGr, LightApp_Preferences::Bool, "VISU", "full_med_loading" );
+  addPreference( tr( "Build at once" ), importGr, LightApp_Preferences::Bool, "VISU", "build_at_once" );
+  addPreference( tr( "Build fields" ), importGr, LightApp_Preferences::Bool, "VISU", "build_fields" );
+  addPreference( tr( "Build min/max" ), importGr, LightApp_Preferences::Bool, "VISU", "build_min_max" );
+  addPreference( tr( "Build groups" ), importGr, LightApp_Preferences::Bool, "VISU", "build_groups" );
+  addPreference( tr( "Close dialog at finish" ), importGr, LightApp_Preferences::Bool, "VISU", "close_at_finish" );
+
   // TAB: "Scalar Bar"
   int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
 
@@ -3033,8 +3047,21 @@ void VisuGUI::createPreferences()
   int scalarBarGr = addPreference( tr( "Scalar bars default position" ), sbarTab );
   addPreference( tr( "Arrange Scalar Bars" ), scalarBarGr, LightApp_Preferences::Bool, "VISU", "scalar_bars_default_position" );
 
-  int srangeTab = addPreference( tr( "Sweep, MED import" ) );
+  // TAB: "CutLines"
+  int cutLineTab = addPreference( tr( "CutLines" ) );
+
+  // group: "CutLines preferences"
+  int cutLineGr = addPreference( tr( "VISU_CUTLINE_PREF" ), cutLineTab );
+  setPreferenceProperty( cutLineGr, "columns", 1 );
+  addPreference( tr( "Show preview" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "show_preview" );
+  addPreference( tr( "Invert all curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "invert_all_curves" );
+  addPreference( tr( "Use absolute length" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "use_absolute_length" );
+  addPreference( tr( "Generate data table" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_data_table" );
+  addPreference( tr( "Generate curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_curves" );
 
+  // TAB: "Sweep, Animation"
+  int srangeTab = addPreference( tr( "Sweep, Animation" ) );
+  
   // group: "Sweeping preferences"
   int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab );
   setPreferenceProperty( sweepGr, "columns", 1 );
@@ -3071,26 +3098,17 @@ void VisuGUI::createPreferences()
   setPreferenceProperty( nbcycles, "max",  100  );
   setPreferenceProperty( nbsteps,  "max",  200  );  
 
-  // group: "CutLines preferences"
-  int cutLineTab = addPreference( tr( "CutLines" ) );
-  int cutLineGr = addPreference( tr( "VISU_CUTLINE_PREF" ), cutLineTab );
-  setPreferenceProperty( cutLineGr, "columns", 1 );
-  addPreference( tr( "Show preview" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "show_preview" );
-  addPreference( tr( "Invert all curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "invert_all_curves" );
-  addPreference( tr( "Use absolute length" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "use_absolute_length" );
-  addPreference( tr( "Generate data table" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_data_table" );
-  addPreference( tr( "Generate curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_curves" );
+  // group: "Animation preferences"
+  int animationGr = addPreference( tr( "Animation preferences" ), srangeTab );
+  setPreferenceProperty( animationGr, "columns", 1 );
 
-  // group: "MED files import"
-  int importGr = addPreference( tr( "MED files import" ), srangeTab );
-  setPreferenceProperty( importGr, "columns", 1 );
-  addPreference( tr( "Use build progress" ), importGr, LightApp_Preferences::Bool, "VISU", "use_build_progress" );
-  addPreference( tr( "Full MED loading" ), importGr, LightApp_Preferences::Bool, "VISU", "full_med_loading" );
-  addPreference( tr( "Build at once" ), importGr, LightApp_Preferences::Bool, "VISU", "build_at_once" );
-  addPreference( tr( "Build fields" ), importGr, LightApp_Preferences::Bool, "VISU", "build_fields" );
-  addPreference( tr( "Build min/max" ), importGr, LightApp_Preferences::Bool, "VISU", "build_min_max" );
-  addPreference( tr( "Build groups" ), importGr, LightApp_Preferences::Bool, "VISU", "build_groups" );
-  addPreference( tr( "Close dialog at finish" ), importGr, LightApp_Preferences::Bool, "VISU", "close_at_finish" );
+  int speed = addPreference( tr( "Speed" ), animationGr, LightApp_Preferences::IntSpin, "VISU", "speed" );
+  addPreference( tr( "Cycled animation" ), animationGr, LightApp_Preferences::Bool, "VISU", "cycled_animation" );
+  addPreference( tr( "Use proportional timing" ), animationGr, LightApp_Preferences::Bool, "VISU", "use_proportional_timing" );
+  addPreference( tr( "Clean memory at each frame" ), animationGr, LightApp_Preferences::Bool, "VISU", "clean_memory_at_each_frame" );
+  
+  setPreferenceProperty( speed, "min", 1 );
+  setPreferenceProperty( speed, "max", 99 );
 
   // TAB: Representation ; group: "Representation properties"
   int representationTab = addPreference( tr( "Representation" ) );
index 85ac8918c337e4daa27d7b22d902659bda2dae51..5345c71c05b5689b05d13b6fc3b2f35cdb74dbe4 100644 (file)
@@ -999,7 +999,6 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Stu
   isClosing = false;
 
   myAnimator = new VISU_TimeAnimation (theStudy);
-  myAnimator->setSpeed(1);
   myAnimator->setViewer(VISU::GetActiveViewWindow<SVTK_ViewWindow>(theModule));
   connect(myAnimator, SIGNAL(frameChanged(long, double)), this, SLOT(onExecution(long, double)));
   connect(myAnimator, SIGNAL(stopped()),                 this, SLOT(onStop()));
@@ -1076,12 +1075,13 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Stu
 
   QLCDNumber* aSpeedNum  = new QLCDNumber( 2, myPlayFrame );
   aSpeedNum->setSegmentStyle(QLCDNumber::Flat);
-  aSpeedNum->display(1);
+  aSpeedNum->display((int)myAnimator->getSpeed());
   TopLayout->addWidget(aSpeedNum, 4, 3);
 
   QwtWheel* aWheel = new QwtWheel(myPlayFrame);
   aWheel->setOrientation(Qt::Vertical);
   aWheel->setRange(1, 99, 1);
+  aWheel->setValue((int)myAnimator->getSpeed());
   connect( aWheel, SIGNAL(valueChanged(double)),
           aSpeedNum, SLOT(display(double)) );
   connect( aWheel, SIGNAL(valueChanged(double)),
index c2974eecdde87d84b377393b91a20ab6afa2ff8b..a34e20521f3f4537ad5bbb369f6b6f4aed32fb67 100644 (file)
@@ -85,8 +85,8 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
   myStudy = theStudy;
   myIsActive = false;
   myFrame = 0;
-  mySpeed = 1;
-  myProportional = false;
+  mySpeed = VISU::GetResourceMgr()->integerValue("VISU", "speed", 1);
+  myProportional = VISU::GetResourceMgr()->booleanValue("VISU", "use_proportional_timing", false);
   myView = 0;
 
   if (!CORBA::is_nil(theView3D)) {
@@ -101,8 +101,8 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
   myTimeMin = 0;
   myTimeMax = 0;
   myLastError = "";
-  myCycling = false;
-  myCleaningMemoryAtEachFrame = false;
+  myCycling = VISU::GetResourceMgr()->booleanValue("VISU", "cycled_animation", false);
+  myCleaningMemoryAtEachFrame = VISU::GetResourceMgr()->booleanValue("VISU", "clean_memory_at_each_frame", false);
 
   myAnimEntry = "";
 
@@ -439,7 +439,8 @@ CORBA::Boolean VISU_TimeAnimation::_generateFrames() {
   }
   myFrame = 0;
   myLastError += QString(" timestamp(s) cannot be created.");
-  emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
+  ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                           myFrame, myFieldsLst[0].myTiming[myFrame]));
   myView->Repaint();
   return aNoError;
 }
@@ -480,7 +481,7 @@ void VISU_TimeAnimation::clearView()
 }
 
 //------------------------------------------------------------------------
-void VISU_TimeAnimation::visibilityOff(int num_field, int num_frame) {
+void VISU_TimeAnimation::_visibilityOff(int num_field, int num_frame) {
   FieldData& aData = myFieldsLst[num_field];
   VISU_Actor* aActor = aData.myActors[num_frame];
   if (! myCleaningMemoryAtEachFrame) {
@@ -498,7 +499,6 @@ void VISU_TimeAnimation::visibilityOff(int num_field, int num_frame) {
     //
     // Delete the actor
     aActor->RemoveFromRender(myView->getRenderer());
-    //aActor->Delete();
     // Re-create the actor
     aActor = aData.myPrs[num_frame]->CreateActor();
     myView->AddActor(aActor);
@@ -507,6 +507,13 @@ void VISU_TimeAnimation::visibilityOff(int num_field, int num_frame) {
   }
 }
 
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::visibilityOff(int num_field, int num_frame)
+{
+  ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,int,int>
+                   (this,&VISU_TimeAnimation::_visibilityOff,num_field,num_frame));
+}
+
 //------------------------------------------------------------------------
 void VISU_TimeAnimation::_stopAnimation() {
   myIsActive = false;
@@ -546,7 +553,6 @@ void VISU_TimeAnimation::_nextFrame() {
     int i;
     for (i = 0; i < getNbFields(); i++)
       if (myFieldsLst[i].myActors[myFrame] != 0)
-       //myFieldsLst[i].myActors[myFrame]->VisibilityOff();
        visibilityOff(i, myFrame);
 
     myFrame++;
@@ -554,7 +560,8 @@ void VISU_TimeAnimation::_nextFrame() {
       if (myFieldsLst[i].myActors[myFrame] != 0)
        myFieldsLst[i].myActors[myFrame]->VisibilityOn();
 
-    emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
+    ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
     myView->Repaint();
   }
 }
@@ -577,7 +584,6 @@ void VISU_TimeAnimation::_prevFrame() {
     int i;
     for (i = 0; i < getNbFields(); i++)
       if (myFieldsLst[i].myActors[myFrame] != 0)
-       //myFieldsLst[i].myActors[myFrame]->VisibilityOff();
        visibilityOff(i, myFrame);
 
     myFrame--;
@@ -585,7 +591,8 @@ void VISU_TimeAnimation::_prevFrame() {
       if (myFieldsLst[i].myActors[myFrame] != 0)
        myFieldsLst[i].myActors[myFrame]->VisibilityOn();
 
-    emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
+    ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
     myView->Repaint();
   }
 }
@@ -608,7 +615,6 @@ void VISU_TimeAnimation::_firstFrame() {
   for (i = 0; i < getNbFields(); i++)
     if(!myFieldsLst[i].myActors.empty())
       if (myFieldsLst[i].myActors[myFrame] != 0)
-       //myFieldsLst[i].myActors[myFrame]->VisibilityOff();
        visibilityOff(i, myFrame);
   myFrame = 0;
   for (i = 0; i < getNbFields(); i++)
@@ -616,7 +622,8 @@ void VISU_TimeAnimation::_firstFrame() {
       if (myFieldsLst[i].myActors[myFrame] != 0)
        myFieldsLst[i].myActors[myFrame]->VisibilityOn();
   if(!myFieldsLst[0].myTiming.empty()){
-    emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
+    ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
     myView->Repaint();
   }
 }
@@ -638,7 +645,6 @@ void VISU_TimeAnimation::_lastFrame() {
   int i;
   for (i = 0; i < getNbFields(); i++)
    if (myFieldsLst[i].myActors[myFrame] != 0)
-     //myFieldsLst[i].myActors[myFrame]->VisibilityOff();
      visibilityOff(i, myFrame);
 
   myFrame = myFieldsLst[0].myNbFrames-1;
@@ -646,7 +652,8 @@ void VISU_TimeAnimation::_lastFrame() {
     if (myFieldsLst[i].myActors[myFrame] != 0)
       myFieldsLst[i].myActors[myFrame]->VisibilityOn();
 
-  emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
+  ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                           myFrame, myFieldsLst[0].myTiming[myFrame]));
   myView->Repaint();
 }
 
@@ -668,12 +675,9 @@ void VISU_TimeAnimation::_gotoFrame(CORBA::Long theFrame) {
   if ((theFrame < 0) || (theFrame > (getNbFrames()-1)))
     return;
   stopAnimation();
-  //qApp->lock();
-  //qApp->syncX();
   int i;
   for (i = 0; i < getNbFields(); i++)
     if (myFieldsLst[i].myActors[myFrame] != 0)
-      //myFieldsLst[i].myActors[myFrame]->VisibilityOff();
       visibilityOff(i, myFrame);
 
   myFrame = theFrame;
@@ -681,11 +685,9 @@ void VISU_TimeAnimation::_gotoFrame(CORBA::Long theFrame) {
     if (myFieldsLst[i].myActors[myFrame] != 0)
       myFieldsLst[i].myActors[myFrame]->VisibilityOn();
 
-  emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
+  ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                           myFrame, myFieldsLst[0].myTiming[myFrame]));
   myView->Repaint();
-  //qApp->flushX();
-  //qApp->processEvents(3);
-  //qApp->unlock();
 }
 
 //------------------------------------------------------------------------
@@ -695,6 +697,17 @@ void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame)
                    (this,&VISU_TimeAnimation::_gotoFrame,theFrame));
 }
 
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::_emitFrameChanged(long theNewFrame, double theTime)
+{
+  emit frameChanged(theNewFrame, theTime);
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::_emitStopped()
+{
+  emit stopped();
+}
 
 //------------------------------------------------------------------------
 VISU::ColoredPrs3d_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CORBA::Long theFrame) {
@@ -728,27 +741,29 @@ void VISU_TimeAnimation::run()
   int aNbFiles = 0;
   QValueList<int> anIndexList;
 
-  qApp->lock();
   while (myIsActive) {
-    emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
+    ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
     if(!(myFieldsLst[0].myField))
       break;
     for (int i = 0; i < getNbFields(); i++) {
       FieldData& aData = myFieldsLst[i];
       if (myFrame > 0) {
        if (aData.myActors[myFrame-1] != 0)
-         //aData.myActors[myFrame-1]->VisibilityOff();
          visibilityOff(i, myFrame-1);
       } else {
        if (aData.myActors[aData.myNbFrames-1] != 0)
-         //aData.myActors[aData.myNbFrames-1]->VisibilityOff();
          visibilityOff(i, aData.myNbFrames-1);
       }
       if (aData.myActors[myFrame] != 0) {
-       aData.myActors[myFrame]->VisibilityOn();
+       ProcessVoidEvent(new TVoidMemFunEvent<VISU_Actor>(aData.myActors[myFrame],
+                                                         &VISU_Actor::VisibilityOn));
       }
     }
-    myView->Repaint(false);
+    bool repainArg = false;
+    ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
+                                                                   &SVTK_ViewWindow::Repaint,
+                                                                   repainArg));
 
     k = 1;
     if (myProportional) {
@@ -772,23 +787,19 @@ void VISU_TimeAnimation::run()
       // We must unlock mutex for some time before grabbing to allow view updating
       delay = 1;
     }
-    qApp->unlock();
     msleep(delay);
     if (!myIsActive) {
-      emit stopped();
+      ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>(this,&VISU_TimeAnimation::_emitStopped));
       return;
     }
-    qApp->lock();
 
     if (isDumping) {
       // We must unlock mutex for some time before grabbing to allow view updating
-      qApp->unlock();
       msleep(delay);
       if (!myIsActive) { // this check was taken from WP_DEB branch
-       emit stopped();
+       ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>(this,&VISU_TimeAnimation::_emitStopped));
        return;
       }
-      qApp->lock();
       if(!(myFieldsLst[0].myField)) // break, if field was deleted.
        break;
       if (myDumpFormat.compare("AVI") != 0) {
@@ -800,7 +811,8 @@ void VISU_TimeAnimation::run()
        aFile += aName;
        aFile += ".";
        aFile += myDumpFormat.lower();
-       myView->dumpViewToFormat(aFile,myDumpFormat);
+       ProcessEvent(new TMemFun2ArgEvent<SVTK_ViewWindow,bool,const QString&,const QString&>
+                    (myView,&SVTK_ViewWindow::dumpViewToFormat,aFile,myDumpFormat));
       } else {
        QFileInfo aFileInfo(myDumpPath);
        QString aDirPath = aFileInfo.dirPath(true);
@@ -831,7 +843,7 @@ void VISU_TimeAnimation::run()
        myView->dumpViewToFormat(aFile,"JPEG");
        */
        SUIT_ViewWindow* aView = myView;
-       QImage img = aView->dumpView();
+       QImage img = ProcessEvent(new TMemFunEvent<SUIT_ViewWindow,QImage>(aView,&SUIT_ViewWindow::dumpView));
        if (!img.isNull()) {
          int width = img.width(); width = (width/16)*16;
          int height = img.height(); height = (height/16)*16;
@@ -908,8 +920,7 @@ void VISU_TimeAnimation::run()
     system(aCmd.latin1());
   }
 
-  emit stopped();
-  qApp->unlock();
+  ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>(this,&VISU_TimeAnimation::_emitStopped));
   QThread::exit();
 }
 
index 22d523698ccb43b8d1954cff15ac67bfed33142c..0c99f7e81b4646a9cecc10e7fb890a28352ce6e4 100644 (file)
@@ -58,9 +58,9 @@ class VISU_TimeAnimation: public QObject, public QThread
 {
   Q_OBJECT;
 
- private:
-  // PAL8166
+ protected:
   CORBA::Boolean _generateFrames();
+  void _visibilityOff(int num_field, int num_frame);
   void _clearView();
   void _stopAnimation();
   void _startAnimation();
@@ -70,6 +70,9 @@ class VISU_TimeAnimation: public QObject, public QThread
   void _lastFrame();
   void _gotoFrame(CORBA::Long theFrame);
 
+  void _emitFrameChanged(long theNewFrame, double theTime);
+  void _emitStopped();
+
  public:
   //static VISU::Result_i* createPresent (SALOMEDS::SObject_var theField);
   //static VISU::Storable::TRestoringMap getMapOfValue (SALOMEDS::SObject_var theSObject);