myTimeMax = 0;
myLastError = "";
myCycling = false;
+ myCleaningMemoryAtEachFrame = false;
myAnimEntry = "";
myView->update();
}
-
namespace
{
//------------------------------------------------------------------------
//------------------------------------------------------------------------
-CORBA::Boolean VISU_TimeAnimation::generateFrames() {
+CORBA::Boolean VISU_TimeAnimation::_generateFrames() {
if (!myView) {
MESSAGE("Viewer is not defined for animation");
return false;
}
//------------------------------------------------------------------------
-void VISU_TimeAnimation::clearView() {
+CORBA::Boolean VISU_TimeAnimation::generateFrames()
+{
+ return ProcessEvent(new TMemFunEvent<VISU_TimeAnimation,bool>
+ (this,&VISU_TimeAnimation::_generateFrames));
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::_clearView() {
if (!myView) {
MESSAGE("Viewer is not defined for animation");
return;
}
//------------------------------------------------------------------------
-void VISU_TimeAnimation::stopAnimation() {
+void VISU_TimeAnimation::clearView()
+{
+ ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ (this,&VISU_TimeAnimation::_clearView));
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::visibilityOff(int num_field, int num_frame) {
+ FieldData& aData = myFieldsLst[num_field];
+ VISU_Actor* aActor = aData.myActors[num_frame];
+ if (! myCleaningMemoryAtEachFrame) {
+ //
+ // Usual behaviour : VisibilityOff()
+ // Problem : It don't clean the memory so if there is
+ // a lot of frames, the memory grows dramatically
+ //
+ aActor->VisibilityOff();
+ } else {
+ //
+ // myCleaningMemoryAtEachFrame behaviour:
+ // Delete the actor and re-creation it with VisibilityOff()
+ // since it takes memory only at VisibilityOn()
+ //
+ // Delete the actor
+ aActor->RemoveFromRender(myView->getRenderer());
+ //aActor->Delete();
+ // Re-create the actor
+ aActor = aData.myPrs[num_frame]->CreateActor();
+ myView->AddActor(aActor);
+ aActor->VisibilityOff();
+ aData.myActors[num_frame] = aActor;
+ }
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::_stopAnimation() {
myIsActive = false;
}
//------------------------------------------------------------------------
-void VISU_TimeAnimation::startAnimation() {
+void VISU_TimeAnimation::stopAnimation()
+{
+ ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ (this,&VISU_TimeAnimation::_stopAnimation));
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::_startAnimation() {
if (!myIsActive) {
myIsActive = true;
QThread::start();
}
//------------------------------------------------------------------------
-void VISU_TimeAnimation::nextFrame() {
+void VISU_TimeAnimation::startAnimation()
+{
+ ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ (this,&VISU_TimeAnimation::_startAnimation));
+}
+
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::_nextFrame() {
if (!myView) {
MESSAGE("Viewer is not defined for animation");
return;
int i;
for (i = 0; i < getNbFields(); i++)
if (myFieldsLst[i].myActors[myFrame] != 0)
- myFieldsLst[i].myActors[myFrame]->VisibilityOff();
+ //myFieldsLst[i].myActors[myFrame]->VisibilityOff();
+ visibilityOff(i, myFrame);
myFrame++;
for (i = 0; i < getNbFields(); i++)
}
//------------------------------------------------------------------------
-void VISU_TimeAnimation::prevFrame() {
+void VISU_TimeAnimation::nextFrame()
+{
+ ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ (this,&VISU_TimeAnimation::_nextFrame));
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::_prevFrame() {
if (!myView) {
MESSAGE("Viewer is not defined for animation");
return;
int i;
for (i = 0; i < getNbFields(); i++)
if (myFieldsLst[i].myActors[myFrame] != 0)
- myFieldsLst[i].myActors[myFrame]->VisibilityOff();
+ //myFieldsLst[i].myActors[myFrame]->VisibilityOff();
+ visibilityOff(i, myFrame);
myFrame--;
for (i = 0; i < getNbFields(); i++)
}
//------------------------------------------------------------------------
-void VISU_TimeAnimation::firstFrame() {
+void VISU_TimeAnimation::prevFrame()
+{
+ ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ (this,&VISU_TimeAnimation::_prevFrame));
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::_firstFrame() {
if (!myView) {
MESSAGE("Viewer is not defined for animation");
return;
for (i = 0; i < getNbFields(); i++)
if(!myFieldsLst[i].myActors.empty())
if (myFieldsLst[i].myActors[myFrame] != 0)
- myFieldsLst[i].myActors[myFrame]->VisibilityOff();
+ //myFieldsLst[i].myActors[myFrame]->VisibilityOff();
+ visibilityOff(i, myFrame);
myFrame = 0;
for (i = 0; i < getNbFields(); i++)
if(!myFieldsLst[i].myActors.empty())
}
//------------------------------------------------------------------------
-void VISU_TimeAnimation::lastFrame() {
+void VISU_TimeAnimation::firstFrame()
+{
+ ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ (this,&VISU_TimeAnimation::_firstFrame));
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::_lastFrame() {
if (!myView) {
MESSAGE("Viewer is not defined for animation");
return;
int i;
for (i = 0; i < getNbFields(); i++)
if (myFieldsLst[i].myActors[myFrame] != 0)
- myFieldsLst[i].myActors[myFrame]->VisibilityOff();
+ //myFieldsLst[i].myActors[myFrame]->VisibilityOff();
+ visibilityOff(i, myFrame);
myFrame = myFieldsLst[0].myNbFrames-1;
for (i = 0; i < getNbFields(); i++)
myView->Repaint();
}
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::lastFrame()
+{
+ ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ (this,&VISU_TimeAnimation::_lastFrame));
+}
+
//------------------------------------------------------------------------
// For Batchmode using
-void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame) {
+void VISU_TimeAnimation::_gotoFrame(CORBA::Long theFrame) {
if (!myView) {
MESSAGE("Viewer is not defined for animation");
return;
if ((theFrame < 0) || (theFrame > (getNbFrames()-1)))
return;
stopAnimation();
- qApp->lock();
- qApp->syncX();
+ //qApp->lock();
+ //qApp->syncX();
int i;
for (i = 0; i < getNbFields(); i++)
if (myFieldsLst[i].myActors[myFrame] != 0)
- myFieldsLst[i].myActors[myFrame]->VisibilityOff();
+ //myFieldsLst[i].myActors[myFrame]->VisibilityOff();
+ visibilityOff(i, myFrame);
myFrame = theFrame;
for (i = 0; i < getNbFields(); i++)
emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
myView->Repaint();
- qApp->flushX();
- qApp->processEvents(3);
- qApp->unlock();
+ //qApp->flushX();
+ //qApp->processEvents(3);
+ //qApp->unlock();
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame)
+{
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,CORBA::Long>
+ (this,&VISU_TimeAnimation::_gotoFrame,theFrame));
}
FieldData& aData = myFieldsLst[i];
if (myFrame > 0) {
if (aData.myActors[myFrame-1] != 0)
- aData.myActors[myFrame-1]->VisibilityOff();
+ //aData.myActors[myFrame-1]->VisibilityOff();
+ visibilityOff(i, myFrame-1);
} else {
if (aData.myActors[aData.myNbFrames-1] != 0)
- aData.myActors[aData.myNbFrames-1]->VisibilityOff();
+ //aData.myActors[aData.myNbFrames-1]->VisibilityOff();
+ visibilityOff(i, aData.myNbFrames-1);
}
if (aData.myActors[myFrame] != 0) {
aData.myActors[myFrame]->VisibilityOn();
}
qApp->unlock();
msleep(delay);
+ if (!myIsActive) {
+ emit stopped();
+ 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();
+ return;
+ }
qApp->lock();
if(!(myFieldsLst[0].myField)) // break, if field was deleted.
break;
CORBA::Boolean VISU_TimeAnimation_i::generateFrames()
{
- return ProcessEvent(new TMemFunEvent<VISU_TimeAnimation,bool>
- (myAnim,&VISU_TimeAnimation::generateFrames));
+ //return ProcessEvent(new TMemFunEvent<VISU_TimeAnimation,bool>
+ // (myAnim,&VISU_TimeAnimation::generateFrames));
+ return myAnim->generateFrames();
}
void VISU_TimeAnimation_i::generatePresentations (CORBA::Long theFieldNum)
void VISU_TimeAnimation_i::clearView()
{
- ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
- (myAnim,&VISU_TimeAnimation::clearView));
+ //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ // (myAnim,&VISU_TimeAnimation::clearView));
+ myAnim->clearView();
}
void VISU_TimeAnimation_i::stopAnimation()
{
- ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
- (myAnim,&VISU_TimeAnimation::stopAnimation));
+ //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ // (myAnim,&VISU_TimeAnimation::stopAnimation));
+ myAnim->stopAnimation();
}
void VISU_TimeAnimation_i::startAnimation()
{
- ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
- (myAnim,&VISU_TimeAnimation::startAnimation));
+ //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ // (myAnim,&VISU_TimeAnimation::startAnimation));
+ myAnim->startAnimation();
}
void VISU_TimeAnimation_i::nextFrame()
{
- ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
- (myAnim,&VISU_TimeAnimation::nextFrame));
+ //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ // (myAnim,&VISU_TimeAnimation::nextFrame));
+ myAnim->nextFrame();
}
void VISU_TimeAnimation_i::prevFrame()
{
- ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
- (myAnim,&VISU_TimeAnimation::prevFrame));
+ //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ // (myAnim,&VISU_TimeAnimation::prevFrame));
+ myAnim->prevFrame();
}
void VISU_TimeAnimation_i::firstFrame()
{
- ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
- (myAnim,&VISU_TimeAnimation::firstFrame));
+ //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ // (myAnim,&VISU_TimeAnimation::firstFrame));
+ myAnim->firstFrame();
}
void VISU_TimeAnimation_i::lastFrame()
{
- ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
- (myAnim,&VISU_TimeAnimation::lastFrame));
+ //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
+ // (myAnim,&VISU_TimeAnimation::lastFrame));
+ myAnim->lastFrame();
}
void VISU_TimeAnimation_i::gotoFrame(CORBA::Long theFrame)
{
- ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,CORBA::Long>
- (myAnim,&VISU_TimeAnimation::gotoFrame,theFrame));
+ //ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,CORBA::Long>
+ // (myAnim,&VISU_TimeAnimation::gotoFrame,theFrame));
+ myAnim->gotoFrame(theFrame);
}
CORBA::Long VISU_TimeAnimation_i::getNbFields()
return myAnim->isCycling();
}
+CORBA::Boolean VISU_TimeAnimation_i::isCleaningMemoryAtEachFrame(){
+ return myAnim->isCleaningMemoryAtEachFrame();
+}
+
CORBA::Double VISU_TimeAnimation_i::getMinTime()
{
return myAnim->getMinTime();
myAnim->setCycling(theCycle);
}
+void VISU_TimeAnimation_i::setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle){
+ myAnim->setCleaningMemoryAtEachFrame(theCycle);
+}
+
SALOMEDS::SObject_ptr VISU_TimeAnimation_i::publishInStudy()
{
return myAnim->publishInStudy();