From 97409e4280ab5eb9d20ab60a241e73a339da074b Mon Sep 17 00:00:00 2001 From: mkr Date: Tue, 24 Oct 2006 08:58:38 +0000 Subject: [PATCH] Fix for bug PAL8166 : [IMP] A flag "clean memory after each frame" in visu animation : 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 | 4 ++ src/VISUGUI/VisuGUI.cxx | 58 ++++++++++++------ src/VISUGUI/VisuGUI_TimeAnimation.cxx | 4 +- src/VISU_I/VISU_TimeAnimation.cxx | 87 +++++++++++++++------------ src/VISU_I/VISU_TimeAnimation.h | 7 ++- 5 files changed, 98 insertions(+), 62 deletions(-) diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 666ff6eb..646e9430 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -54,6 +54,10 @@ + + + + diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 07efd2bc..a0b3895a 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -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" ) ); diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 85ac8918..5345c71c 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -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(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)), diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index c2974eec..a34e2052 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -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(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 + (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(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(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(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(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(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 anIndexList; - qApp->lock(); while (myIsActive) { - emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); + ProcessVoidEvent(new TVoidMemFun2ArgEvent(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(aData.myActors[myFrame], + &VISU_Actor::VisibilityOn)); } } - myView->Repaint(false); + bool repainArg = false; + ProcessVoidEvent(new TVoidMemFun1ArgEvent(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(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(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 + (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(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(this,&VISU_TimeAnimation::_emitStopped)); QThread::exit(); } diff --git a/src/VISU_I/VISU_TimeAnimation.h b/src/VISU_I/VISU_TimeAnimation.h index 22d52369..0c99f7e8 100644 --- a/src/VISU_I/VISU_TimeAnimation.h +++ b/src/VISU_I/VISU_TimeAnimation.h @@ -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); -- 2.39.2