1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : VISU_TimeAnimation.cxx
24 // Author : Vitaly SMETANNIKOV
27 #include "VISU_TimeAnimation.h"
32 #include <QMessageBox>
35 #include "VISUConfig.hh"
37 #include "VISU_Result_i.hh"
38 #include "VISU_Prs3d_i.hh"
39 #include "VISU_Mesh_i.hh"
40 #include "VISU_IsoSurfaces_i.hh"
41 #include "VISU_DeformedShape_i.hh"
42 #include "VISU_DeformedShapeAndScalarMap_i.hh"
43 #include "VISU_CutPlanes_i.hh"
44 #include "VISU_Plot3D_i.hh"
45 #include "VISU_CutLines_i.hh"
46 #include "VISU_CutSegment_i.hh"
47 #include "VISU_Vectors_i.hh"
48 #include "VISU_StreamLines_i.hh"
49 #include "VISU_GaussPoints_i.hh"
50 #include "VISU_ViewManager_i.hh"
51 #include "VISU_View_i.hh"
53 #include "VISU_ScalarBarActor.hxx"
54 #include "VISU_Actor.h"
56 #include "SalomeApp_Study.h"
58 #include "SVTK_ViewWindow.h"
60 #include "SALOME_Event.h"
62 #include "SUIT_ResourceMgr.h"
63 #include "SUIT_Application.h"
64 #include "SUIT_Session.h"
65 #include "SUIT_Study.h"
66 #include "SUIT_MessageBox.h"
68 #include "SALOMEDSClient_AttributeString.hxx"
69 #include "SALOMEDSClient_AttributeName.hxx"
71 #include "Utils_ExceptHandlers.hxx"
75 #include <QImageWriter>
76 #include <QStringList>
79 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
83 #include <Standard_Failure.hxx>
86 #include <Standard_ErrorHandler.hxx>
91 //------------------------------------------------------------------------
94 //------------------------------------------------------------------------
98 QMutex myIsActiveMutex;
100 ExecutionState(bool isActive = false)
101 : myIsActive(isActive) {}
105 myIsActiveMutex.lock();
107 myIsActiveMutex.unlock();
110 bool SetActive(bool isActive) {
112 myIsActiveMutex.lock();
114 myIsActive = isActive;
115 myIsActiveMutex.unlock();
121 //------------------------------------------------------------------------
122 struct TCompositeMinMaxController : virtual TVTKMinMaxController
124 typedef ColoredPrs3d_i* TKey;
125 typedef std::map< TKey, VISU::PMinMaxController > TMinMaxContainer;
126 TMinMaxContainer myMinMaxContainer;
129 AddController(ColoredPrs3d_i* theReference,
130 VISU::PMinMaxController theMinMaxController)
132 myMinMaxContainer[ TKey( theReference ) ] = theMinMaxController;
137 UpdateReference(ColoredPrs3d_i* theFromPrs3, ColoredPrs3d_i* theToPrs3d)
139 TMinMaxContainer::iterator anIter = myMinMaxContainer.find( TKey( theFromPrs3 ) );
140 if ( anIter != myMinMaxContainer.end() ) {
141 myMinMaxContainer.erase( anIter );
142 myMinMaxContainer[ TKey( theToPrs3d ) ] = VISU::CreateDefaultMinMaxController( theToPrs3d );
148 GetComponentMin(vtkIdType theCompID)
150 vtkFloatingPointType aMin = TMinMaxController::GetComponentMin(theCompID);
151 if ( !myMinMaxContainer.empty() ) {
152 TMinMaxContainer::const_iterator anIter = myMinMaxContainer.begin();
153 for(; anIter != myMinMaxContainer.end(); anIter++){
154 VISU::PMinMaxController aMinMaxController = anIter->second;
155 aMin = std::min(aMin, aMinMaxController->GetComponentMin(theCompID));
163 GetComponentMax(vtkIdType theCompID)
165 vtkFloatingPointType aMax = TMinMaxController::GetComponentMax(theCompID);
166 if ( !myMinMaxContainer.empty() ) {
167 TMinMaxContainer::const_iterator anIter = myMinMaxContainer.begin();
168 for(; anIter != myMinMaxContainer.end(); anIter++){
169 VISU::PMinMaxController aMinMaxController = anIter->second;
170 aMax = std::max(aMax, aMinMaxController->GetComponentMax(theCompID));
177 typedef SALOME::GenericObjPtr<TCompositeMinMaxController> PCompositeMinMaxController;
180 //------------------------------------------------------------------------
181 VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
182 VISU::View3D_ptr theView3D)
185 myExecutionState = new VISU::ExecutionState(false);
187 mySpeed = VISU::GetResourceMgr()->integerValue("VISU", "speed", 1);
188 myProportional = VISU::GetResourceMgr()->booleanValue("VISU", "use_proportional_timing", false);
191 if (!CORBA::is_nil(theView3D)) {
192 VISU::View3D_i* pView = dynamic_cast<VISU::View3D_i*>(GetServant(theView3D).in());
193 SUIT_ViewWindow* aVW = pView->GetViewWindow();
194 setViewer( dynamic_cast<SVTK_ViewWindow*>(aVW) );
197 myAnimationMode = VISU::Animation::PARALLEL;
203 myCycling = VISU::GetResourceMgr()->booleanValue("VISU", "cycled_animation", false);
204 myCleaningMemoryAtEachFrame = VISU::GetResourceMgr()->booleanValue("VISU", "clean_memory_at_each_frame", false);
209 myAVIMaker = "jpeg2yuv";
211 myDumpMode = VISU::GetResourceMgr()->integerValue("VISU", "dump_mode", 0);
212 myTimeStampFrequency = VISU::GetResourceMgr()->integerValue("VISU", "time_stamp_frequency", 1);
216 //------------------------------------------------------------------------
217 VISU_TimeAnimation::~VISU_TimeAnimation()
219 if (QThread::isRunning() && !QThread::isFinished()) {
222 if (QThread::isRunning() && !QThread::isFinished()) {
223 QThread::terminate();
227 for (int i = 0; i < getNbFields() && myView; i++) {
228 clearData(myFieldsLst[i]);
232 delete myExecutionState;
236 /* Terminates the execution of the thread.
237 * The thread may or may not be terminated immediately,
238 * depending on the operating system's scheduling policies.
240 * Use QThread::wait() after terminate() for synchronous termination.
242 * When the thread is terminated, all threads waiting for the the thread to finish will be woken up.
244 * Warning: This function is dangerous, and its use is discouraged.
245 * The thread can be terminated at any point in its code path.
246 * Threads can be terminated while modifying data.
247 * There is no chance for the thread to cleanup after itself,
248 * unlock any held mutexes, etc. In short, use this function only if absolutely necessary.
250 //QThread::wait(100);
251 //QThread::terminate();
252 //QThread::wait(400);
256 //------------------------------------------------------------------------
257 void VISU_TimeAnimation::_connectView()
259 connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) );
262 //------------------------------------------------------------------------
263 bool VISU_TimeAnimation::addField (_PTR(SObject) theField)
265 if (!theField) return false;
268 aNewData.myField = theField;
269 aNewData.myNbFrames = 0;
270 aNewData.myPrsType = VISU::TSCALARMAP;
271 aNewData.myOffset[0] = aNewData.myOffset[1] = aNewData.myOffset[2] = 0;
273 // initialize myResult in aNewData
274 _PTR(SObject) aSObj = theField->GetFather();
275 aSObj = aSObj->GetFather();
276 aSObj = aSObj->GetFather();
277 CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj);
278 if (CORBA::is_nil(anObject)) return false;
279 aNewData.myResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
281 VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aNewData.myField);
282 if(VISU::Storable::FindValue(aMap,"myComment") != "FIELD")
285 aNewData.myNbTimes = VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
287 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
288 if ( aNewData.myNbTimes < 2 )
290 if ( !myFieldsLst.isEmpty() && myFieldsLst.first().myNbTimes != aNewData.myNbTimes )
292 if ( myFieldsLst.isEmpty() )
293 myFieldsAbsFrames.push_back(aNewData.myNbTimes);
295 else { // successive animation mode
296 if ( aNewData.myNbTimes < 1 )
299 long aNumCompCurr = VISU::Storable::FindValue(aMap, "myNumComponent").toLong();
300 if ( !myFieldsLst.isEmpty() ) {
301 VISU::Storable::TRestoringMap aFMap = VISU::Storable::GetStorableMap(myFieldsLst.first().myField);
302 long aNumComp = VISU::Storable::FindValue(aFMap, "myNumComponent").toLong();
303 if ( aNumCompCurr != aNumComp )
307 if ( !myFieldsLst.isEmpty() )
308 myFieldsAbsFrames.push_back(myFieldsAbsFrames.back() + aNewData.myNbTimes);
310 myFieldsAbsFrames.push_back(aNewData.myNbTimes);
313 myFieldsLst.append(aNewData);
315 //find Min/Max timestamps
316 _PTR(ChildIterator) anIter = myStudy->NewChildIterator(theField);
317 anIter->Next(); // First is reference on support
318 if ( myFieldsLst.size() == 1 ) { // the first field
319 myTimeMin = getTimeValue(anIter->Value());
320 myTimeMax = getTimeValue(anIter->Value());
322 for(; anIter->More(); anIter->Next()) {
323 if ( myTimeMin > getTimeValue(anIter->Value()) )
324 myTimeMin = getTimeValue(anIter->Value());
325 if ( myTimeMax < getTimeValue(anIter->Value()) )
326 myTimeMax = getTimeValue(anIter->Value());
332 //------------------------------------------------------------------------
333 bool VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField)
335 SALOMEDS::SObject_var theFieldDup = SALOMEDS::SObject::_duplicate(theField);
336 _PTR(SObject) aField = VISU::GetClientSObject(theFieldDup, myStudy);
337 return addField(aField);
341 //------------------------------------------------------------------------
342 void VISU_TimeAnimation::_clearData(FieldData& theData) {
344 MESSAGE("Viewer is not defined for animation");
347 theData.myTiming.clear();
348 vtkRenderer* aRen = myView->getRenderer();
349 if (!theData.myActors.empty()) {
350 for (int i = 0, iEnd = theData.myActors.size(); i < iEnd; i++) {
351 if (theData.myActors[i] != 0) {
352 theData.myActors[i]->RemoveFromRender(aRen);
355 theData.myActors.clear();
357 if (!theData.myPrs.empty()) {
358 for (int i = 0, iEnd = theData.myPrs.size(); i < iEnd; i++)
359 if (theData.myPrs[i] != 0) {
360 theData.myPrs[i]->_remove_ref();
362 theData.myPrs.clear();
364 theData.myNbFrames = 0;
368 //------------------------------------------------------------------------
369 void VISU_TimeAnimation::clearData(FieldData& theData) {
370 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,FieldData&>
371 (this,&VISU_TimeAnimation::_clearData,theData));
376 //------------------------------------------------------------------------
377 template<class TPrs3d>
379 GeneratePresentations(_PTR(Study) theStudy,
381 VISU::Result_i* theResult,
382 bool theIsRangeDefined,
383 CORBA::Double theTimeMin,
384 CORBA::Double theTimeMax,
385 QList<long> theSequence)
387 _PTR(ChildIterator) anIter = theStudy->NewChildIterator(theData.myField);
388 anIter->Next(); // First is reference on support
390 long aSequenceLength = theSequence.count();
391 bool isSequenceDefined = aSequenceLength > 0;
392 if (isSequenceDefined)
393 theData.myPrs.resize(aSequenceLength,NULL);
396 long aSequenceIndex = 1;
397 for(; anIter->More(); anIter->Next(), aSequenceIndex++){
398 if (aFrameId == theData.myNbTimes) {
399 MESSAGE("There are extra timestamps in field");
402 _PTR(SObject) aTimeStamp = anIter->Value();
406 long aSequenceId = -1;
408 theData.myTiming[aFrameId] = VISU_TimeAnimation::getTimeValue(aTimeStamp);
409 if (theIsRangeDefined) {
410 if (theData.myTiming[aFrameId] < theTimeMin)
412 if (theData.myTiming[aFrameId] > theTimeMax)
415 else if (isSequenceDefined) {
416 aSequenceId = theSequence.indexOf( aSequenceIndex );
417 if( aSequenceId == -1 )
421 VISU::Storable::TRestoringMap aTimeMap = VISU::Storable::GetStorableMap(aTimeStamp);
422 QString aMeshName = VISU::Storable::FindValue(aTimeMap,"myMeshName");
423 VISU::Entity anEntity = (VISU::Entity) VISU::Storable::FindValue(aTimeMap,"myEntityId").toInt();
424 QString aFieldName = VISU::Storable::FindValue(aTimeMap,"myFieldName");
425 int aTimeStampId = VISU::Storable::FindValue(aTimeMap,"myTimeStampId").toInt();
427 bool anIsCreated = false;
428 TPrs3d* aPresent = new TPrs3d(VISU::ColoredPrs3d_i::EDoNotPublish);
429 aPresent->SetCResult(theResult);
430 aPresent->SetMeshName(aMeshName.toLatin1().data());
431 aPresent->SetEntity(anEntity);
432 aPresent->SetFieldName(aFieldName.toLatin1().data());
433 aPresent->SetTimeStampNumber(aTimeStampId);
438 if(aPresent->Apply(false)){
440 if(isSequenceDefined)
442 theData.myPrs[aSequenceId] = aPresent;
447 theData.myPrs[aFrameId++] = aPresent;
450 }catch(Standard_Failure) {
451 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
452 INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
453 }catch(std::exception& exc){
454 INFOS("Follow exception was occured :\n"<<exc.what());
456 INFOS("Unknown exception was occured!");
459 aPresent->_remove_ref();
462 theData.myNbFrames = aFrameId;
464 if (theData.myPrsType != VISU::TGAUSSPOINTS) {
465 for(long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++) {
466 if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(theData.myPrs[aFrameId])){
467 aPrs->SetOffset(theData.myOffset);
474 double getMinFieldsValue( QList<FieldData>& theFieldsLst )
476 // for successive animation mode only
478 for (int i = 0; i < theFieldsLst.count(); i++) {
479 if ( theFieldsLst[i].myPrs[0] ) {
480 aRes = theFieldsLst[i].myPrs[0]->GetMin();
485 for (int i = 1; i < theFieldsLst.count() && theFieldsLst[i].myPrs[0]; i++) {
486 if ( aRes > theFieldsLst[i].myPrs[0]->GetMin() )
487 aRes = theFieldsLst[i].myPrs[0]->GetMin();
492 double getMaxFieldsValue( QList<FieldData>& theFieldsLst )
494 // for successive animation mode only
496 for (int i = 0; i < theFieldsLst.count(); i++) {
497 if ( theFieldsLst[i].myPrs[0] ) {
498 aRes = theFieldsLst[i].myPrs[0]->GetMax();
503 for (int i = 1; i < theFieldsLst.count() && theFieldsLst[i].myPrs[0]; i++) {
504 if ( aRes < theFieldsLst[i].myPrs[0]->GetMax() )
505 aRes = theFieldsLst[i].myPrs[0]->GetMax();
510 void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum)
512 int nbf = myFieldsLst.size();
513 if( theFieldNum<0 || theFieldNum>nbf-1 )
516 FieldData& aData = myFieldsLst[theFieldNum];
518 // Delete previous presentations
521 VISU::Result_i* aResult = createPresent(aData.myField);
522 VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aData.myField);
523 aData.myNbFrames = aData.myNbTimes;
524 //VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
526 aData.myPrs.resize(aData.myNbTimes,NULL);
527 aData.myTiming.resize(aData.myNbTimes);
529 QList<long> aSequence;
530 if( isSequenceDefined() )
532 bool ok = getIndicesFromSequence( mySequence, aSequence );
537 using namespace VISU;
538 switch (aData.myPrsType) {
539 case VISU::TSCALARMAP:
540 GeneratePresentations<ScalarMap_i>(myStudy,
548 case VISU::TISOSURFACES: // Iso Surfaces
549 GeneratePresentations<IsoSurfaces_i>(myStudy,
557 case VISU::TCUTPLANES: // Cut Planes
558 GeneratePresentations<CutPlanes_i>(myStudy,
566 case VISU::TCUTLINES: // Cut Lines
567 GeneratePresentations<CutLines_i>(myStudy,
575 case VISU::TCUTSEGMENT: // Cut Segment
576 GeneratePresentations<CutSegment_i>(myStudy,
584 case VISU::TPLOT3D: // Plot3d
585 GeneratePresentations<Plot3D_i>(myStudy,
593 case VISU::TDEFORMEDSHAPE: // Deformed Shape
594 GeneratePresentations<DeformedShape_i>(myStudy,
602 case VISU::TVECTORS: // Vectors
603 GeneratePresentations<Vectors_i>(myStudy,
611 case VISU::TSTREAMLINES: // Stream Lines
612 GeneratePresentations<StreamLines_i>(myStudy,
620 case VISU::TGAUSSPOINTS: // Gauss Points
621 GeneratePresentations<GaussPoints_i>(myStudy,
629 case VISU::TSCALARMAPONDEFORMEDSHAPE: // Scalar map on deformed shape
630 case VISU::TDEFORMEDSHAPEANDSCALARMAP:
631 GeneratePresentations<DeformedShapeAndScalarMap_i>(myStudy,
640 MESSAGE("Not implemented for this presentation type: " << aData.myPrsType);
644 if ( myAnimationMode == VISU::Animation::SUCCESSIVE ) { // successive animation mode
645 if ( myFieldsAbsFrames.size() == getNbFields() )
646 myFieldsAbsFrames.clear();
647 if ( theFieldNum > 0 )
648 myFieldsAbsFrames.push_back(myFieldsAbsFrames.back() + aData.myNbFrames);
650 myFieldsAbsFrames.push_back(aData.myNbFrames);
652 if (theFieldNum == getNbFields() - 1) {
653 if ( aData.myPrsType != VISU::TGAUSSPOINTS && aData.myPrsType != TDEFORMEDSHAPEANDSCALARMAP && aData.myPrsType != TSCALARMAPONDEFORMEDSHAPE) {
655 // Initialize the MinMax controller
656 VISU::PCompositeMinMaxController aMinMaxController(new VISU::TCompositeMinMaxController());
657 if ( myAnimationMode == VISU::Animation::PARALLEL ) {
658 FieldData& aFieldData = getFieldData(theFieldNum);
659 VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[0];
660 aMinMaxController->AddController( aPrs3d, VISU::CreateDefaultMinMaxController( aPrs3d ) );
662 for (int aFieldId = 0; aFieldId < getNbFields(); aFieldId++) {
663 FieldData& aFieldData = getFieldData(aFieldId);
664 VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[0];
665 aMinMaxController->AddController( aPrs3d, VISU::CreateDefaultMinMaxController( aPrs3d ) );
669 double aMin = getMinFieldsValue(myFieldsLst);
670 double aMax = getMaxFieldsValue(myFieldsLst);
672 for (int aFieldId = 0; aFieldId < getNbFields(); aFieldId++) {
673 FieldData& aFieldData = getFieldData(aFieldId);
674 for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) {
675 VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[aFrameId];
676 aPrs3d->SetMinMaxController(aMinMaxController);
677 if (VISU::IsoSurfaces_i* anIsoSurfaces = dynamic_cast<VISU::IsoSurfaces_i*>(aPrs3d))
678 anIsoSurfaces->SetSubRange(aMin, aMax);
687 //------------------------------------------------------------------------
688 CORBA::Boolean VISU_TimeAnimation::_generateFrames() {
690 MESSAGE("Viewer is not defined for animation");
694 myLastError = QString("Frame(s) for ");
695 bool aNoError = true;
699 for (int i = 0; i < getNbFields(); i++) {
700 FieldData& aData = myFieldsLst[i];
701 aData.myActors.resize(aData.myNbFrames,NULL);
702 for (long j = 0; j < aData.myNbFrames; j++) {
703 VISU_Actor* aActor = NULL;
705 aData.myPrs[j]->SetOffset(aData.myOffset);
706 aActor = aData.myPrs[j]->CreateActor();
707 myView->AddActor(aActor);
708 bool condition = ( myAnimationMode == VISU::Animation::PARALLEL ) ? (j == 0) : (j == 0 && i == 0);
710 aActor->VisibilityOn();
712 aActor->VisibilityOff();
713 }catch(...){ //catch(std::runtime_error& exc){
715 myLastError += QString("%1 ").arg(aData.myTiming[j]);
717 aData.myActors[j] = aActor;
721 myLastError += QString(" timestamp(s) cannot be created.");
722 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
723 myFrame, myFieldsLst[0].myTiming[myFrame]));
728 //------------------------------------------------------------------------
729 CORBA::Boolean VISU_TimeAnimation::generateFrames()
731 return ProcessEvent(new TMemFunEvent<VISU_TimeAnimation,bool>
732 (this,&VISU_TimeAnimation::_generateFrames));
735 //------------------------------------------------------------------------
736 void VISU_TimeAnimation::_clearView() {
738 MESSAGE("Viewer is not defined for animation");
741 vtkRenderer* aRen = myView->getRenderer();
742 for (int i = 0; i < getNbFields(); i++) {
743 FieldData& aData = myFieldsLst[i];
744 if (!aData.myActors.empty()) {
745 for (int i = 0, iEnd = aData.myActors.size(); i < iEnd; i++) {
746 if (aData.myActors[i] != 0) {
747 aData.myActors[i]->RemoveFromRender(aRen);
750 aData.myActors.clear();
753 VISU::RepaintView(myView);
756 //------------------------------------------------------------------------
757 void VISU_TimeAnimation::clearView()
759 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
760 (this,&VISU_TimeAnimation::_clearView));
763 //------------------------------------------------------------------------
764 void VISU_TimeAnimation::_visibilityOff(int num_field, int num_frame) {
766 MESSAGE("Viewer is not defined for animation");
769 if ( num_field < 0 || num_frame < 0 ) return;
770 FieldData& aData = myFieldsLst[num_field];
771 if ( aData.myActors.empty() ) return;
772 VISU_Actor* aActor = aData.myActors[num_frame];
773 if (! myCleaningMemoryAtEachFrame) {
775 // Usual behaviour : VisibilityOff()
776 // Problem : It don't clean the memory so if there is
777 // a lot of frames, the memory grows dramatically
779 aActor->VisibilityOff();
782 // myCleaningMemoryAtEachFrame behaviour:
783 // Delete the actor and re-creation it with VisibilityOff()
784 // since it takes memory only at VisibilityOn()
787 aActor->RemoveFromRender(myView->getRenderer());
788 // Re-create the actor
789 aActor = aData.myPrs[num_frame]->CreateActor();
790 myView->AddActor(aActor);
791 aActor->VisibilityOff();
792 aData.myActors[num_frame] = aActor;
796 //------------------------------------------------------------------------
797 void VISU_TimeAnimation::visibilityOff(int num_field, int num_frame)
799 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,int,int>
800 (this,&VISU_TimeAnimation::_visibilityOff,num_field,num_frame));
803 //------------------------------------------------------------------------
804 void VISU_TimeAnimation::stopAnimation()
806 myExecutionState->SetActive(false);
809 //------------------------------------------------------------------------
810 void VISU_TimeAnimation::_startAnimation() {
811 if (!myExecutionState->IsActive()) {
812 myExecutionState->SetActive(true);
817 //------------------------------------------------------------------------
818 void VISU_TimeAnimation::startAnimation()
820 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
821 (this,&VISU_TimeAnimation::_startAnimation));
824 //------------------------------------------------------------------------
825 void VISU_TimeAnimation::_nextFrame() {
827 MESSAGE("Viewer is not defined for animation");
831 if (myFrame < getNbFrames() - 1 ) { //(myFieldsLst[0].myNbFrames-1)) {
833 std::pair<int,long> aPair;
837 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
838 for (i = 0; i < getNbFields(); i++)
839 if (myFieldsLst[i].myActors[myFrame] != 0)
840 visibilityOff(i, myFrame);
842 else { //successive animation mode
843 aPair = getRelativeFrameNumber(myFrame);
844 aFieldId = aPair.first;
845 aFrameId = aPair.second;
846 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
847 visibilityOff(aFieldId, aFrameId);
852 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
853 for (i = 0; i < getNbFields(); i++)
854 if (myFieldsLst[i].myActors[myFrame] != 0)
855 myFieldsLst[i].myActors[myFrame]->VisibilityOn();
857 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
858 myFrame, myFieldsLst[0].myTiming[myFrame]));
860 else { //successive animation mode
861 aPair = getRelativeFrameNumber(myFrame);
862 aFieldId = aPair.first;
863 aFrameId = aPair.second;
864 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
865 myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
867 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
868 myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
874 //------------------------------------------------------------------------
875 void VISU_TimeAnimation::nextFrame()
877 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
878 (this,&VISU_TimeAnimation::_nextFrame));
881 //------------------------------------------------------------------------
882 void VISU_TimeAnimation::_prevFrame() {
884 MESSAGE("Viewer is not defined for animation");
890 std::pair<int,long> aPair;
894 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
895 for (i = 0; i < getNbFields(); i++)
896 if (myFieldsLst[i].myActors[myFrame] != 0)
897 visibilityOff(i, myFrame);
899 else { //successive animation mode
900 aPair = getRelativeFrameNumber(myFrame);
901 aFieldId = aPair.first;
902 aFrameId = aPair.second;
903 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
904 visibilityOff(aFieldId, aFrameId);
909 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
910 for (i = 0; i < getNbFields(); i++)
911 if (myFieldsLst[i].myActors[myFrame] != 0)
912 myFieldsLst[i].myActors[myFrame]->VisibilityOn();
914 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
915 myFrame, myFieldsLst[0].myTiming[myFrame]));
917 else { //successive animation mode
918 aPair = getRelativeFrameNumber(myFrame);
919 aFieldId = aPair.first;
920 aFrameId = aPair.second;
921 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
922 myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
924 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
925 myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
931 //------------------------------------------------------------------------
932 void VISU_TimeAnimation::prevFrame()
934 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
935 (this,&VISU_TimeAnimation::_prevFrame));
938 //------------------------------------------------------------------------
939 void VISU_TimeAnimation::_firstFrame() {
941 MESSAGE("Viewer is not defined for animation");
946 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
947 for (i = 0; i < getNbFields(); i++)
948 if(!myFieldsLst[i].myActors.empty())
949 if (myFieldsLst[i].myActors[myFrame] != 0)
950 visibilityOff(i, myFrame);
952 else { //successive animation mode
953 std::pair<int,long> aPair = getRelativeFrameNumber(myFrame);
954 int aFieldId = aPair.first;
955 long aFrameId = aPair.second;
956 if(!myFieldsLst[aFieldId].myActors.empty())
957 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
958 visibilityOff(aFieldId, aFrameId);
963 if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode
964 imax = getNbFields();
965 else //successive animation mode
968 for (i = 0; i < imax; i++)
969 if(!myFieldsLst[i].myActors.empty())
970 if (myFieldsLst[i].myActors[myFrame] != 0)
971 myFieldsLst[i].myActors[myFrame]->VisibilityOn();
973 if(!myFieldsLst[0].myTiming.empty()){
974 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
975 myFrame, myFieldsLst[0].myTiming[myFrame]));
980 //------------------------------------------------------------------------
981 void VISU_TimeAnimation::firstFrame()
983 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
984 (this,&VISU_TimeAnimation::_firstFrame));
987 //------------------------------------------------------------------------
988 void VISU_TimeAnimation::_lastFrame() {
990 MESSAGE("Viewer is not defined for animation");
995 std::pair<int,long> aPair;
999 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1000 for (i = 0; i < getNbFields(); i++)
1001 if (myFieldsLst[i].myActors[myFrame] != 0)
1002 visibilityOff(i, myFrame);
1004 else { //successive animation mode
1005 aPair = getRelativeFrameNumber(myFrame);
1006 aFieldId = aPair.first;
1007 aFrameId = aPair.second;
1008 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
1009 visibilityOff(aFieldId, aFrameId);
1012 myFrame = getNbFrames() - 1; //myFieldsLst[0].myNbFrames-1;
1014 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1015 for (i = 0; i < getNbFields(); i++)
1016 if (myFieldsLst[i].myActors[myFrame] != 0)
1017 myFieldsLst[i].myActors[myFrame]->VisibilityOn();
1019 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
1020 myFrame, myFieldsLst[0].myTiming[myFrame]));
1022 else { //successive animation mode
1023 aPair = getRelativeFrameNumber(myFrame);
1024 aFieldId = aPair.first;
1025 aFrameId = aPair.second;
1026 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
1027 myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
1029 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
1030 myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
1036 //------------------------------------------------------------------------
1037 void VISU_TimeAnimation::lastFrame()
1039 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
1040 (this,&VISU_TimeAnimation::_lastFrame));
1044 //------------------------------------------------------------------------
1045 // For Batchmode using
1046 void VISU_TimeAnimation::_gotoFrame(CORBA::Long theFrame) {
1048 MESSAGE("Viewer is not defined for animation");
1051 if ((theFrame < 0) || (theFrame > (getNbFrames()-1)))
1055 std::pair<int,long> aPair;
1059 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1060 for (i = 0; i < getNbFields(); i++)
1061 if (myFieldsLst[i].myActors[myFrame] != 0)
1062 visibilityOff(i, myFrame);
1064 else { //successive animation mode
1065 aPair = getRelativeFrameNumber(myFrame);
1066 aFieldId = aPair.first;
1067 aFrameId = aPair.second;
1068 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
1069 visibilityOff(aFieldId, aFrameId);
1074 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1075 for (i = 0; i < getNbFields(); i++)
1076 if (myFieldsLst[i].myActors[myFrame] != 0)
1077 myFieldsLst[i].myActors[myFrame]->VisibilityOn();
1079 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
1080 myFrame, myFieldsLst[0].myTiming[myFrame]));
1082 else { //successive animation mode
1083 aPair = getRelativeFrameNumber(myFrame);
1084 aFieldId = aPair.first;
1085 aFrameId = aPair.second;
1086 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
1087 myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
1089 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
1090 myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
1096 //------------------------------------------------------------------------
1097 void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame)
1099 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,CORBA::Long>
1100 (this,&VISU_TimeAnimation::_gotoFrame,theFrame));
1103 //------------------------------------------------------------------------
1104 void VISU_TimeAnimation::_emitFrameChanged(long theNewFrame, double theTime)
1106 emit frameChanged(theNewFrame, theTime);
1109 //------------------------------------------------------------------------
1110 void VISU_TimeAnimation::_emitStopped()
1115 //------------------------------------------------------------------------
1116 VISU::ColoredPrs3d_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CORBA::Long theFrame) {
1117 if ((theField > getNbFields()) || (theField < 0))
1118 return VISU::ColoredPrs3d::_nil();
1119 if ((theFrame < 0) || (theFrame > (myFieldsLst[theField].myNbFrames - 1)))
1120 return VISU::ColoredPrs3d::_nil();
1121 return myFieldsLst[theField].myPrs[theFrame]->_this();
1124 //------------------------------------------------------------------------
1125 void VISU_TimeAnimation::setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType) {
1126 if ( theFieldNum < 0 || theFieldNum >= myFieldsLst.size() )
1129 myFieldsLst[theFieldNum].myPrsType = theType;
1132 //------------------------------------------------------------------------
1133 VISU::VISUType VISU_TimeAnimation::getPresentationType(CORBA::Long theFieldNum) {
1134 if ( theFieldNum < 0 || theFieldNum >= myFieldsLst.size() )
1137 return myFieldsLst[theFieldNum].myPrsType;
1140 //------------------------------------------------------------------------
1141 CORBA::Long VISU_TimeAnimation::getNbFrames() {
1142 if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode
1143 return (getNbFields() > 0)? myFieldsLst[0].myNbFrames : 0;
1144 else //successive animation mode
1145 return (getNbFields() > 0 && !myFieldsAbsFrames.empty()) ? myFieldsAbsFrames[myFieldsAbsFrames.size()-1] : 0;
1148 //------------------------------------------------------------------------
1149 long VISU_TimeAnimation::getAbsoluteFrameNumber(std::pair<int,long> theFieldTimeStamp)
1152 if ( getNbFields() > 0 ) {
1153 int aFieldId = theFieldTimeStamp.first;
1154 long aFrameNum = theFieldTimeStamp.second + 1;
1155 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1156 if ( aFrameNum <= myFieldsAbsFrames[0] )
1159 else { //successive animation mode
1160 if ( aFieldId == 0 && aFrameNum <= myFieldsAbsFrames[aFieldId] )
1162 else if ( aFieldId && aFrameNum <= myFieldsAbsFrames[aFieldId] - myFieldsAbsFrames[aFieldId-1] )
1163 aRes = myFieldsAbsFrames[aFieldId-1] + aFrameNum;
1169 //------------------------------------------------------------------------
1170 std::pair<int,long> VISU_TimeAnimation::getRelativeFrameNumber(long theFrame)
1172 std::pair<int,long> aRes;
1173 if ( getNbFields() > 0 && theFrame < getNbFrames() ) {
1174 theFrame = theFrame + 1;
1175 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1177 aRes.second = theFrame - 1;
1179 else { //successive animation mode
1180 for (int i = 0, iEnd = myFieldsAbsFrames.size(); i < iEnd; i++)
1181 if ( myFieldsAbsFrames[i] >= theFrame ) {
1184 aRes.second = theFrame - 1;
1186 aRes.second = theFrame-myFieldsAbsFrames[i-1] - 1;
1194 //------------------------------------------------------------------------
1195 void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QList<int>& theIndexList )
1199 FieldData& aFirstFieldData = myFieldsLst[0];
1200 if (aFirstFieldData.myNbFrames > 2)
1201 aOneVal = ( myTimeMax - myTimeMin ) / getNbFrames();
1204 bool aHasNextFrame = aFirstFieldData.myField && aFirstFieldData.myNbFrames > 0;
1205 while (aHasNextFrame && myExecutionState->IsActive()) {
1206 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>
1207 (this, &VISU_TimeAnimation::_emitFrameChanged,
1208 myFrame, aFirstFieldData.myTiming[myFrame]));
1209 if (myExecutionState->IsActive()) {
1210 for (int i = 0; i < getNbFields(); i++) {
1211 FieldData& aData = myFieldsLst[i];
1212 if (aData.myNbFrames == 0)
1215 if (aData.myActors[myFrame-1] != 0)
1216 visibilityOff(i, myFrame-1);
1218 if (aData.myActors[aData.myNbFrames-1] != 0)
1219 visibilityOff(i, aData.myNbFrames-1);
1221 if (aData.myActors[myFrame] != 0 && myView) {
1222 ProcessVoidEvent(new TVoidMemFunEvent<VISU_Actor>(aData.myActors[myFrame],
1223 &VISU_Actor::VisibilityOn));
1228 bool repainArg = false;
1229 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
1230 &SVTK_ViewWindow::Repaint,
1235 if (myProportional) {
1240 if (aFirstFieldData.myNbFrames > 2)
1241 k = (aFirstFieldData.myTiming[myFrame+1] -
1242 aFirstFieldData.myTiming[myFrame]) / aOneVal;
1245 if (myFrame < (aFirstFieldData.myNbFrames - 1))
1246 k = (aFirstFieldData.myTiming[myFrame+1] -
1247 aFirstFieldData.myTiming[myFrame]) / aOneVal;
1250 int delay = (int)(1000. * k / mySpeed);
1251 theIsDumping = !myDumpPath.isEmpty();
1252 if (delay < 1 && theIsDumping) {
1253 // We must unlock mutex for some time before grabbing to allow view updating
1257 if (!myExecutionState->IsActive())
1261 // We must unlock mutex for some time before grabbing to allow view updating
1263 if (!myExecutionState->IsActive())
1266 if (!(aFirstFieldData.myField)) // break, if field was deleted.
1269 saveImages( 0, aOneVal, aNbFiles, theIndexList );
1272 if (!myExecutionState->IsActive())
1276 if (myFrame == aFirstFieldData.myNbFrames) {
1278 aHasNextFrame = false;
1284 } // while (aHasNextFrame && myExecutionState->IsActive())
1287 //------------------------------------------------------------------------
1288 void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QList<int>& theIndexList )
1290 if (myFrame >= getNbFrames() - 1)
1292 myExecutionState->SetActive(false);
1298 FieldData& aFirstFieldData = myFieldsLst[0];
1299 if (aFirstFieldData.myNbFrames > 2)
1300 aOneVal = ( myTimeMax - myTimeMin ) / getNbFrames();
1302 long aFrame = myFrame;
1304 bool aHasNextFrame = true;
1305 while (aHasNextFrame && myExecutionState->IsActive())
1307 for (int aFieldId = 0;
1308 (aFieldId < getNbFields()) && (myFieldsLst[aFieldId].myField);
1309 aFieldId++, aFrame = 0)
1311 if (!myExecutionState->IsActive()) break;
1313 FieldData& aData = myFieldsLst[aFieldId];
1314 if ( !aData.myPrs[0] ) continue;
1315 for (; aFrame < aData.myNbFrames && myExecutionState->IsActive(); aFrame++, myFrame++)
1317 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>
1318 (this, &VISU_TimeAnimation::_emitFrameChanged,
1319 myFrame, myFieldsLst[aFieldId].myTiming[aFrame]));
1321 if (myExecutionState->IsActive()) {
1323 if (aData.myActors[aFrame-1] != 0)
1324 visibilityOff(aFieldId, aFrame-1);
1325 } else if ( myFrame > 0) {
1326 if (myFieldsLst[aFieldId-1].myActors[myFieldsLst[aFieldId-1].myNbFrames-1] != 0)
1327 visibilityOff(aFieldId-1, myFieldsLst[aFieldId-1].myNbFrames-1);
1328 } else if ( myCycling ) {
1329 if (myFieldsLst[getNbFields()-1].myActors[myFieldsLst[getNbFields()-1].myNbFrames-1] != 0)
1330 visibilityOff(getNbFields()-1, myFieldsLst[getNbFields()-1].myNbFrames-1);
1332 if (aData.myActors[aData.myNbFrames-1] != 0)
1333 visibilityOff(aFieldId, aData.myNbFrames-1);
1335 if (aData.myActors[aFrame] != 0 && myView) {
1336 ProcessVoidEvent(new TVoidMemFunEvent<VISU_Actor>(aData.myActors[aFrame],
1337 &VISU_Actor::VisibilityOn));
1342 bool repainArg = false;
1343 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
1344 &SVTK_ViewWindow::Repaint,
1349 if (myProportional) {
1354 if (aFirstFieldData.myNbFrames > 2)
1355 k = (aFirstFieldData.myTiming[aFrame+1] -
1356 aFirstFieldData.myTiming[aFrame]) / aOneVal;
1359 if (aFrame < (aFirstFieldData.myNbFrames - 1))
1360 k = (aFirstFieldData.myTiming[aFrame+1] -
1361 aFirstFieldData.myTiming[aFrame]) / aOneVal;
1364 int delay = (int)(1000. * k / mySpeed);
1365 theIsDumping = !myDumpPath.isEmpty();
1366 if (delay < 1 && theIsDumping) {
1367 // We must unlock mutex for some time before grabbing to allow view updating
1372 if (!myExecutionState->IsActive()) return;
1375 // We must unlock mutex for some time before grabbing to allow view updating
1377 if (!myExecutionState->IsActive()) return;
1379 if (!(myFieldsLst[aFieldId].myField)) // break, if field was deleted.
1382 saveImages( aFieldId, aOneVal, aNbFiles, theIndexList );
1384 } // for (; aFrame < aData.myNbFrames && myExecutionState->IsActive(); aFrame++, myFrame++)
1385 } // for (int aFieldId = 0;
1388 aHasNextFrame = false;
1395 } // while (aHasNextFrame && myExecutionState->IsActive())
1398 //------------------------------------------------------------------------
1399 void VISU_TimeAnimation::saveImages( int theFieldId,
1400 double& theOneVal, int& theNbFiles,
1401 QList<int>& theIndexList )
1403 if (myDumpFormat.compare("AVI") != 0) {
1404 QString aFile(myDumpPath);
1406 int aFrameNb = myFrame; // parallel animation mode
1407 if ( myAnimationMode == VISU::Animation::SUCCESSIVE ) // successive animation mode
1408 aFrameNb = getRelativeFrameNumber(myFrame).second;
1410 int aMaxNb = myFieldsLst[theFieldId].myTiming.size();
1411 int nbDigits = QString("%1").arg(aMaxNb).length();
1412 QString aFormat = QString("%.%1d_").arg(nbDigits);
1415 aName.sprintf(aFormat.toLatin1().data(), aFrameNb);
1416 aName += QString("%1").arg(myFieldsLst[theFieldId].myTiming[aFrameNb]);
1419 while ((aPos = aName.indexOf(".")) > -1 )
1420 aName.replace(aPos, 1, "_");
1423 aFile += myDumpFormat.toLower();
1424 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1425 (myView,&SVTK_ViewWindow::RefreshDumpImage)); // IPAL13602
1426 ProcessEvent(new TMemFun2ArgEvent<SUIT_ViewWindow,bool,const QString&,const QString&>
1427 (myView,&SUIT_ViewWindow::dumpViewToFormat,aFile,myDumpFormat));
1429 QFileInfo aFileInfo(myDumpPath);
1430 QString aDirPath = aFileInfo.absolutePath();
1431 QString aBaseName = aFileInfo.fileName();
1433 if( myTimeStampFrequency > 1 && myFrame % myTimeStampFrequency != 0 )
1443 if (myProportional) {
1444 FieldData& aFirstFieldData = myFieldsLst[0];
1445 double p = (aFirstFieldData.myTiming[myFrame] -
1446 aFirstFieldData.myTiming[myFrame-1]) / theOneVal;
1447 myFileIndex += (long) (5*p);
1453 QString aFile = aDirPath + QDir::separator() + aBaseName;
1455 aFile += QString("%1").arg(myFileIndex).rightJustified(8, '0');
1458 /* check image size is divisable 16
1459 myView->dumpViewToFormat(aFile,"JPEG");
1461 SUIT_ViewWindow* aView = myView;
1462 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>(myView,&SVTK_ViewWindow::RefreshDumpImage)); // IPAL13602
1463 QImage img = ProcessEvent(new TMemFunEvent<SUIT_ViewWindow,QImage>(aView,&SUIT_ViewWindow::dumpView));
1464 if (!img.isNull()) {
1465 int width = img.width(); width = (width/16)*16;
1466 int height = img.height(); height = (height/16)*16;
1467 QImage copy = img.copy(0, 0, width, height);
1468 if (copy.save(aFile, "JPEG")) {
1469 theIndexList.append(myFileIndex);
1476 //------------------------------------------------------------------------
1477 void VISU_TimeAnimation::run()
1480 MESSAGE("Viewer is not defined for animation");
1484 bool isDumping = !myDumpPath.isEmpty();
1486 QList<int> anIndexList;
1488 if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode
1489 parallelAnimation( isDumping, anIndexList );
1490 else //successive animation mode
1491 successiveAnimation( isDumping, anIndexList );
1493 // make AVI file if need
1494 if (isDumping && myDumpFormat.compare("AVI") == 0 && myExecutionState->IsActive()) {
1495 double aFPS = 17.3 * mySpeed / myTimeStampFrequency;
1497 QFileInfo aFileInfo(myDumpPath);
1498 QString aDirPath = aFileInfo.absolutePath();
1499 QString aBaseName = aFileInfo.fileName();
1501 // add missing files
1502 if (anIndexList.count() > 1) {
1503 QString aFFile = aDirPath + "/" + aBaseName;
1504 aFFile += QString("_%1.jpeg");
1505 int aStartIndex = anIndexList[0], anEndIndex;
1506 for (int i = 1; i < anIndexList.count(); i++) {
1507 anEndIndex = anIndexList[i];
1508 QString aCurFile = aFFile.arg(QString::number(aStartIndex).rightJustified(8, '0'));
1509 QStringList aCommands;
1511 for (int j = aStartIndex+1; j < anEndIndex; j++) {
1512 QString aFile = aFFile.arg(QString::number(j).rightJustified(8, '0'));
1514 aCommands.append(QString("ln -s %1 %2").arg(aCurFile).arg(aFile));
1515 aSeparator = QString(" ; \\\n");
1517 aCommands.append(QString("COPY /Y %1 %2 > NUL").arg(QString(aCurFile).replace("/","\\\\")).arg(QString(aFile).replace("/","\\\\")));
1518 aSeparator = QString(" & ");
1521 system(aCommands.join(aSeparator).toLatin1().data());
1522 aStartIndex = anEndIndex;
1527 QString aPattern = aDirPath + "/" + aBaseName;
1528 aPattern += "_\%08d.jpeg";
1530 QString aCmd = myAVIMaker;
1533 aCmd += QString(" -f %1").arg(aFPS);
1534 // aCmd += QString(" -n %1").arg(aNbFiles);
1535 aCmd += QString(" -n %1").arg(myFileIndex+1);
1536 aCmd += QString(" -j \"%1\"").arg(aPattern);
1537 aCmd += " | yuv2lav";
1538 aCmd += QString(" -o \"%1\"").arg(myDumpPath);
1542 system(aCmd.toLatin1().data());
1544 // remove temporary jpeg files
1547 aCmd += QString("cd %1").arg(aDirPath);
1549 aCmd += QString(" | egrep '%1_[0-9]*.jpeg'").arg(aBaseName);
1550 aCmd += " | xargs rm";
1553 QString tmpFile = QString("_") + aBaseName + "_tempfile";
1554 QString diskName = aDirPath.split("/")[0];
1555 aCmd = diskName + " && (cd " + aDirPath.replace("/","\\\\") +
1556 " && ((dir /b | findstr " + aBaseName + "_[0-9]*.jpeg > " + tmpFile +
1557 ") & (for /f %i in (" + tmpFile + ") do (del \"%i\")) & (del " + tmpFile + "))) > NUL";
1559 system(aCmd.toLatin1().data());
1562 if (myExecutionState->IsActive())
1563 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>(this,&VISU_TimeAnimation::_emitStopped));
1564 myExecutionState->SetActive(false);
1567 //------------------------------------------------------------------------
1568 VISU::Result_i* VISU_TimeAnimation::createPresent (_PTR(SObject) theField)
1570 _PTR(SObject) aSObj = theField->GetFather();
1571 aSObj = aSObj->GetFather();
1572 aSObj = aSObj->GetFather();
1573 CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj);
1574 if (CORBA::is_nil(anObject)) return NULL;
1575 return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
1578 //------------------------------------------------------------------------
1579 double VISU_TimeAnimation::getTimeValue (_PTR(SObject) theTimeStamp)
1581 _PTR(GenericAttribute) anAttr;
1582 if (theTimeStamp->FindAttribute(anAttr, "AttributeName")) {
1583 _PTR(AttributeName) aName (anAttr);
1584 QString aNameString (aName->Value().c_str());
1585 int time_len = aNameString.indexOf(',');
1587 return aNameString.left(time_len).toDouble();
1589 return aNameString.toDouble();
1594 //------------------------------------------------------------------------
1595 void VISU_TimeAnimation::setSpeed(CORBA::Long theSpeed)
1597 mySpeed = (theSpeed<1)? 1 : theSpeed;
1600 //------------------------------------------------------------------------
1601 void VISU_TimeAnimation::setAnimationSequence(const char* theSequence)
1603 mySequence = QString( theSequence );
1606 //------------------------------------------------------------------------
1607 char* VISU_TimeAnimation::getAnimationSequence()
1609 return strdup( mySequence.toLatin1().data() );
1612 //------------------------------------------------------------------------
1613 CORBA::Boolean VISU_TimeAnimation::isSequenceDefined()
1615 return !mySequence.isEmpty();
1618 //------------------------------------------------------------------------
1619 bool VISU_TimeAnimation::getIndicesFromSequence( QString theSequence, QList<long>& theIndices )
1621 bool isCorrect = true;
1625 QStringList aList = theSequence.split( ",", QString::SkipEmptyParts );
1626 QStringList::iterator it = aList.begin();
1627 QStringList::iterator itEnd = aList.end();
1628 for( ; it != itEnd; ++it )
1635 QString aString = *it;
1636 if( aString.isEmpty() )
1640 int aSingleIndex = aString.toLong( &ok );
1643 theIndices.append( aSingleIndex );
1646 else if( aString.contains( '-' ) == 1 )
1648 QString aLeftIndexStr = aString.section( '-', 0, 0 );
1649 QString aRightIndexStr = aString.section( '-', -1 );
1652 int aLeftIndex = aLeftIndexStr.toLong( &ok );
1657 int aRightIndex = aRightIndexStr.toLong( &ok );
1661 if( aLeftIndex >= aRightIndex )
1664 for( int i = aLeftIndex; i <= aRightIndex; i++ )
1665 theIndices.append( i );
1674 //------------------------------------------------------------------------
1675 std::string VISU_TimeAnimation::setDumpFormat(const char* theFormat)
1677 myDumpFormat = theFormat;
1678 QList<QByteArray> aDumpFormats = QImageWriter::supportedImageFormats();
1679 if (myDumpFormat.isEmpty() ||
1680 (aDumpFormats.indexOf(theFormat) < 0 && myDumpFormat.compare("AVI") != 0)) {
1681 if (aDumpFormats.indexOf("JPEG") >= 0 ||
1682 aDumpFormats.indexOf("jpeg") >= 0)
1683 myDumpFormat = "JPEG";
1685 myDumpFormat = aDumpFormats.at(0);
1687 return myDumpFormat.toLatin1().data();
1690 //------------------------------------------------------------------------
1691 void VISU_TimeAnimation::setTimeStampFrequency(CORBA::Long theFrequency)
1693 myTimeStampFrequency = theFrequency;
1696 //------------------------------------------------------------------------
1697 bool VISU_TimeAnimation::checkAVIMaker() const
1699 QList<QByteArray> aDumpFormats = QImageWriter::supportedImageFormats();
1700 if (aDumpFormats.indexOf("JPEG") < 0 &&
1701 aDumpFormats.indexOf("jpeg") < 0)
1706 aCmd = "which " + myAVIMaker + " 2> /dev/null";
1708 aCmd = "setlocal & set P2=.;%PATH% & (for %e in (%PATHEXT%) do @for %i in (" + myAVIMaker + "%e) do @if NOT \"%~$P2:i\"==\"\" exit /b 0) & exit /b 1";
1710 int iErr = system(aCmd.toLatin1().data());
1714 //************************************************************************
1715 int VISU_TimeAnimation::myNBAnimations = 0;
1716 QString VISU_TimeAnimation::GenerateName()
1718 return VISU::GenerateName("Animation", myNBAnimations++);
1721 //------------------------------------------------------------------------
1722 std::string GetPresentationComment (VISU::VISUType thePrsType)
1724 std::string aPrsCmt;
1725 switch (thePrsType) {
1726 case VISU::TSCALARMAP:
1727 aPrsCmt = VISU::ScalarMap_i::myComment;
1729 case VISU::TISOSURFACES:
1730 aPrsCmt = VISU::IsoSurfaces_i::myComment;
1732 case VISU::TCUTPLANES:
1733 aPrsCmt = VISU::CutPlanes_i::myComment;
1735 case VISU::TCUTLINES:
1736 aPrsCmt = VISU::CutLines_i::myComment;
1738 case VISU::TCUTSEGMENT:
1739 aPrsCmt = VISU::CutSegment_i::myComment;
1742 aPrsCmt = VISU::Plot3D_i::myComment;
1744 case VISU::TDEFORMEDSHAPE:
1745 aPrsCmt = VISU::DeformedShape_i::myComment;
1747 case VISU::TVECTORS:
1748 aPrsCmt = VISU::Vectors_i::myComment;
1750 case VISU::TSTREAMLINES:
1751 aPrsCmt = VISU::StreamLines_i::myComment;
1753 case VISU::TGAUSSPOINTS:
1754 aPrsCmt = VISU::GaussPoints_i::myComment;
1756 case VISU::TSCALARMAPONDEFORMEDSHAPE:
1757 case VISU::TDEFORMEDSHAPEANDSCALARMAP:
1758 aPrsCmt = VISU::DeformedShapeAndScalarMap_i::myComment;
1761 aPrsCmt = "Unknown presentation";
1767 //------------------------------------------------------------------------
1768 SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
1770 if (myStudy->GetProperties()->IsLocked()) {
1771 SUIT_MessageBox::warning(0,
1772 QObject::tr("WRN_VISU_WARNING"),
1773 QObject::tr("WRN_STUDY_LOCKED"),
1774 QObject::tr("BUT_OK"));
1775 return SALOMEDS::SObject::_nil();
1778 _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
1779 aStudyBuilder->NewCommand(); // There is a transaction
1780 _PTR(SComponent) aSComponent = VISU::ClientFindOrCreateVisuComponent(myStudy);
1781 std::string aSComponentEntry = aSComponent->GetID();
1784 aComment.sprintf("myComment=ANIMATION;myTimeMinVal=%g;myTimeMaxVal=%g;mySequence=%s;myMode=%d",
1787 mySequence.toLatin1().data(),
1790 string anEntry = VISU::CreateAttributes(myStudy,
1791 aSComponentEntry.c_str(),
1794 GenerateName().toLatin1().data(),
1795 VISU::NO_PERFSITENT_REF,
1796 aComment.toLatin1().data(),
1798 myAnimEntry = anEntry.c_str();
1799 _PTR(SObject) aAnimSObject = myStudy->FindObjectID(anEntry.c_str());
1801 for (int i = 0; i < getNbFields(); i++) {
1802 FieldData& aData = myFieldsLst[i];
1803 if (aData.myPrs.empty()) {
1804 generatePresentations(i);
1806 if ( !aData.myPrs.empty() ) {
1807 _PTR(SObject) newObj = aStudyBuilder->NewObject(aAnimSObject);
1808 aStudyBuilder->Addreference(newObj, aData.myField);
1810 ostringstream strOut;
1811 aData.myPrs[0]->ToStream(strOut);
1812 string aPrsComment = strOut.str();
1813 string aPrsMyComment = aData.myPrs[0]->GetComment();
1814 if(aPrsMyComment == "PRSMERGER")
1815 aPrsMyComment = "SCALARMAP";
1816 VISU::CreateAttributes(myStudy,
1817 newObj->GetID().c_str(),
1820 aPrsMyComment.c_str(),
1821 VISU::NO_PERFSITENT_REF,
1822 aPrsComment.c_str(),
1826 aStudyBuilder->CommitCommand();
1828 return VISU::GetSObject(aAnimSObject)._retn();
1831 //------------------------------------------------------------------------
1832 void VISU_TimeAnimation::saveAnimation()
1834 if (myStudy->GetProperties()->IsLocked()) return;
1835 if (myAnimEntry.isEmpty()) return;
1837 _PTR(SObject) aAnimSObject = myStudy->FindObjectID(myAnimEntry.toLatin1().data());
1838 if (!aAnimSObject) return;
1840 _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
1841 aStudyBuilder->NewCommand(); // There is a transaction
1842 _PTR(SComponent) aSComponent = VISU::ClientFindOrCreateVisuComponent(myStudy);
1843 std::string aSComponentEntry = aSComponent->GetID();
1846 aComment.sprintf("myComment=ANIMATION;myTimeMinVal=%g;myTimeMaxVal=%g;mySequence=%s;myMode=%d",
1849 mySequence.toLatin1().data(),
1852 _PTR(GenericAttribute) anAttr;
1853 anAttr = aStudyBuilder->FindOrCreateAttribute(aAnimSObject, "AttributeString");
1854 _PTR(AttributeString) aCmnt (anAttr);
1855 aCmnt->SetValue(aComment.toLatin1().data());
1857 _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
1858 int i = 0, nbf = getNbFields();
1859 for (anIter->Init(); anIter->More(); anIter->Next(), i++) {
1860 if (i >= nbf) break; // it must not be
1861 FieldData& aData = myFieldsLst[i];
1863 // Get presentation name and comment
1864 if (aData.myPrs.empty()) {
1865 generatePresentations(i);
1867 ostringstream strOut;
1868 aData.myPrs[0]->ToStream(strOut);
1869 string aPrsComment = strOut.str();
1870 string aPrsNameTxt = aData.myPrs[0]->GetComment();
1871 if(aPrsNameTxt == "PRSMERGER")
1872 aPrsNameTxt = "SCALARMAP";
1874 _PTR(SObject) aRefObj = anIter->Value();
1875 _PTR(ChildIterator) anPrsIter = myStudy->NewChildIterator(aRefObj);
1878 if (anPrsIter->More()) {
1879 _PTR(SObject) aPrsObj = anPrsIter->Value();
1880 anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeString");
1881 aCmnt = _PTR(AttributeString)(anAttr);
1882 aCmnt->SetValue(aPrsComment.c_str());
1884 anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeName");
1885 _PTR(AttributeName) aPrsName (anAttr);
1886 aPrsName->SetValue(aPrsNameTxt);
1889 VISU::CreateAttributes(myStudy,
1890 aRefObj->GetID().c_str(),
1893 aPrsNameTxt.c_str(),
1894 VISU::NO_PERFSITENT_REF,
1895 aPrsComment.c_str(),
1899 aStudyBuilder->CommitCommand();
1902 //------------------------------------------------------------------------
1903 void VISU_TimeAnimation::restoreFromStudy(SALOMEDS::SObject_ptr theField)
1905 _PTR(SObject) aAnimSObject = VISU::GetClientSObject(theField, myStudy);
1906 restoreFromStudy(aAnimSObject);
1909 void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
1911 _PTR(SObject) aAnimSObject = theField;
1913 VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aAnimSObject);
1918 myTimeMinVal = VISU::Storable::FindValue(aMap,"myTimeMinVal",&isExist).toDouble();
1919 myTimeMaxVal = VISU::Storable::FindValue(aMap,"myTimeMaxVal",&isExist).toDouble();
1920 mySequence = VISU::Storable::FindValue(aMap,"mySequence",&isExist);
1921 myAnimationMode = VISU::Animation::AnimationMode(VISU::Storable::FindValue(aMap,"myMode",&isExist).toInt());
1923 _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
1924 for (anIter->Init(); anIter->More(); anIter->Next()) {
1925 _PTR(SObject) aRefObj = anIter->Value();
1926 _PTR(SObject) aFieldObj;
1928 if (!aRefObj->ReferencedObject(aFieldObj) )
1931 int nbAttr = aFieldObj->GetAllAttributes().size();
1932 //std::string name1 = aFieldObj->GetName();
1936 addField(aFieldObj);
1937 if ( isRangeDefined() || isSequenceDefined() )
1938 myFieldsAbsFrames.pop_back();
1940 FieldData& aData = getFieldData(getNbFields()-1);
1942 // Get Presentation object
1943 _PTR(ChildIterator) anPrsIter = myStudy->NewChildIterator(aRefObj);
1945 if (!anPrsIter->More())
1947 _PTR(SObject) aPrsObj = anPrsIter->Value();
1948 _PTR(GenericAttribute) anAttr;
1949 if (!aPrsObj->FindAttribute(anAttr, "AttributeName"))
1951 _PTR(AttributeName) aName (anAttr);
1952 string aStr = aName->Value();
1953 QString strName (aStr.c_str());
1955 if (strName == VISU::ScalarMap_i::myComment.c_str())
1956 aData.myPrsType = VISU::TSCALARMAP;
1957 else if (strName == VISU::IsoSurfaces_i::myComment.c_str())
1958 aData.myPrsType = VISU::TISOSURFACES;
1959 else if (strName == VISU::CutPlanes_i::myComment.c_str())
1960 aData.myPrsType = VISU::TCUTPLANES;
1961 else if (strName == VISU::CutLines_i::myComment.c_str())
1962 aData.myPrsType = VISU::TCUTLINES;
1963 else if (strName == VISU::CutSegment_i::myComment.c_str())
1964 aData.myPrsType = VISU::TCUTSEGMENT;
1965 else if (strName == VISU::Plot3D_i::myComment.c_str())
1966 aData.myPrsType = VISU::TPLOT3D;
1967 else if (strName == VISU::DeformedShape_i::myComment.c_str())
1968 aData.myPrsType = VISU::TDEFORMEDSHAPE;
1969 else if (strName == VISU::Vectors_i::myComment.c_str())
1970 aData.myPrsType = VISU::TVECTORS;
1971 else if (strName == VISU::StreamLines_i::myComment.c_str())
1972 aData.myPrsType = VISU::TSTREAMLINES;
1973 else if (strName == VISU::GaussPoints_i::myComment.c_str())
1974 aData.myPrsType = VISU::TGAUSSPOINTS;
1975 else if (strName == VISU::DeformedShapeAndScalarMap_i::myComment.c_str())
1976 aData.myPrsType = VISU::TDEFORMEDSHAPEANDSCALARMAP;
1979 generatePresentations(getNbFields()-1);
1981 VISU::Storable::TRestoringMap aPrsMap = VISU::Storable::GetStorableMap(aPrsObj);
1982 if (aPrsMap.empty())
1984 if (aData.myPrs[0]) {
1985 aData.myPrs[0]->Restore(VISU::GetSObject(aData.myField), aPrsMap);
1986 aData.myPrs[0]->GetOffset(aData.myOffset);
1988 for (int i = 1; i < aData.myNbFrames; i++) {
1989 if (!aData.myPrs[0])
1991 bool anIsFixedRange = false;
1992 if (aData.myPrsType != VISU::TGAUSSPOINTS) {
1993 if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
1994 anIsFixedRange = aPrs->IsRangeFixed();
1996 if (aData.myPrsType == VISU::TDEFORMEDSHAPEANDSCALARMAP) {
1997 if (VISU::DeformedShapeAndScalarMap_i* aDeformedPrs =
1998 dynamic_cast<VISU::DeformedShapeAndScalarMap_i*>(aData.myPrs[i])) {
1999 //Set correct time stamp number
2000 int aTimeStampNum = aDeformedPrs->GetScalarTimeStampNumber();
2001 aDeformedPrs->SameAs(aData.myPrs[0]);
2002 aDeformedPrs->SetScalarField(aDeformedPrs->GetScalarEntity(),
2003 aDeformedPrs->GetScalarFieldName(),
2008 aData.myPrs[i]->SameAs(aData.myPrs[0]);
2011 string aStr = aAnimSObject->GetID();
2012 myAnimEntry = aStr.c_str();
2015 void VISU_TimeAnimation::onViewDeleted()
2021 void VISU_TimeAnimation::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs)
2022 throw (SALOME::SALOME_Exception)
2024 Unexpect aCatch(SALOME_SalomeException);
2026 VISU::ColoredPrs3d_i* aPrs_i = dynamic_cast<VISU::ColoredPrs3d_i*>(GetServant(thePrs).in());
2029 THROW_SALOME_CORBA_EXCEPTION("Error : invalid dynamic cast of the given presentation to VISU::ColoredPrs3d_i",
2030 SALOME::INTERNAL_ERROR);
2032 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
2033 FieldData& aData = myFieldsLst[theFieldNum];
2035 if ( aData.myPrs.empty() )
2036 THROW_SALOME_CORBA_EXCEPTION("Error : presentations for the given field is not yet created!",
2037 SALOME::INTERNAL_ERROR);
2039 if ( aPrs_i->GetCResult() != aData.myPrs[0]->GetCResult() )
2040 THROW_SALOME_CORBA_EXCEPTION("Error : the MED file is not the same!",
2041 SALOME::INTERNAL_ERROR);
2043 for (int i = 0; i < aData.myNbFrames; i++) {
2044 bool anIsFixedRange = false;
2045 if (aData.myPrsType != VISU::TGAUSSPOINTS) {
2046 if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
2047 anIsFixedRange = aPrs->IsRangeFixed();
2049 aData.myPrs[i]->SameAs(aPrs_i);
2052 else if ( myAnimationMode == VISU::Animation::SUCCESSIVE ) { // successive animation mode
2053 for (int f = 0; f < getNbFields(); f++) {
2054 FieldData& aData = myFieldsLst[f];
2056 if ( aData.myPrs.empty() )
2057 THROW_SALOME_CORBA_EXCEPTION("Error : presentations for the given field is not yet created!",
2058 SALOME::INTERNAL_ERROR);
2060 for (int i = 0; i < aData.myNbFrames; i++) {
2061 aData.myPrs[i]->SameAs(aPrs_i);
2067 //========================================================================
2068 //========================================================================
2069 //========================================================================
2070 struct TNewAnimationEvent: public SALOME_Event
2072 std::string myStudyName;
2073 VISU::View3D_ptr myView3D;
2075 typedef VISU_TimeAnimation* TResult;
2078 TNewAnimationEvent (std::string theStudyName, VISU::View3D_ptr theView3D):
2079 myStudyName(theStudyName),
2080 myView3D(VISU::View3D::_duplicate(theView3D)),
2088 SUIT_Session* aSession = SUIT_Session::session();
2089 QList<SUIT_Application*> anApplications = aSession->applications();
2090 QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
2091 while ( anIter != anApplications.end() ) {
2092 SUIT_Application* anApp = *anIter;
2093 if (SUIT_Study* aSStudy = anApp->activeStudy()) {
2094 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
2095 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
2096 if (myStudyName == aCStudy->Name()) {
2097 myResult = new VISU_TimeAnimation (aCStudy, myView3D);
2108 VISU_TimeAnimation_i::VISU_TimeAnimation_i (SALOMEDS::Study_ptr theStudy,
2109 VISU::View3D_ptr theView3D)
2111 std::string aStudyName = theStudy->Name();
2112 myAnim = ProcessEvent(new TNewAnimationEvent (aStudyName, theView3D));
2115 VISU_TimeAnimation_i::~VISU_TimeAnimation_i()
2120 bool VISU_TimeAnimation_i::addField (SALOMEDS::SObject_ptr theField)
2122 return myAnim->addField(theField);
2125 void VISU_TimeAnimation_i::clearFields ()
2127 for (int i = 0; i < myAnim->getNbFields(); i++) {
2128 myAnim->clearData(myAnim->getFieldData(i));
2130 myAnim->clearFieldData();
2133 CORBA::Boolean VISU_TimeAnimation_i::generateFrames()
2135 //return ProcessEvent(new TMemFunEvent<VISU_TimeAnimation,bool>
2136 // (myAnim,&VISU_TimeAnimation::generateFrames));
2137 return myAnim->generateFrames();
2140 void VISU_TimeAnimation_i::generatePresentations (CORBA::Long theFieldNum)
2142 myAnim->generatePresentations(theFieldNum);
2145 void VISU_TimeAnimation_i::clearView()
2147 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2148 // (myAnim,&VISU_TimeAnimation::clearView));
2149 myAnim->clearView();
2152 void VISU_TimeAnimation_i::stopAnimation()
2154 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2155 // (myAnim,&VISU_TimeAnimation::stopAnimation));
2156 myAnim->stopAnimation();
2159 void VISU_TimeAnimation_i::startAnimation()
2161 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2162 // (myAnim,&VISU_TimeAnimation::startAnimation));
2163 myAnim->startAnimation();
2166 void VISU_TimeAnimation_i::nextFrame()
2168 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2169 // (myAnim,&VISU_TimeAnimation::nextFrame));
2170 myAnim->nextFrame();
2173 void VISU_TimeAnimation_i::prevFrame()
2175 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2176 // (myAnim,&VISU_TimeAnimation::prevFrame));
2177 myAnim->prevFrame();
2180 void VISU_TimeAnimation_i::firstFrame()
2182 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2183 // (myAnim,&VISU_TimeAnimation::firstFrame));
2184 myAnim->firstFrame();
2187 void VISU_TimeAnimation_i::lastFrame()
2189 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2190 // (myAnim,&VISU_TimeAnimation::lastFrame));
2191 myAnim->lastFrame();
2194 void VISU_TimeAnimation_i::gotoFrame(CORBA::Long theFrame)
2196 //ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,CORBA::Long>
2197 // (myAnim,&VISU_TimeAnimation::gotoFrame,theFrame));
2198 myAnim->gotoFrame(theFrame);
2201 CORBA::Long VISU_TimeAnimation_i::getNbFields()
2203 return myAnim->getNbFields();
2206 CORBA::Long VISU_TimeAnimation_i::getNbFrames()
2208 return myAnim->getNbFrames();
2211 CORBA::Boolean VISU_TimeAnimation_i::isRunning()
2213 return myAnim->isRunning();
2216 CORBA::Long VISU_TimeAnimation_i::getCurrentFrame()
2218 return myAnim->getCurrentFrame();
2221 VISU::ColoredPrs3d_ptr VISU_TimeAnimation_i::getPresentation
2222 (CORBA::Long theField, CORBA::Long theFrame)
2224 return myAnim->getPresentation(theField,theFrame);
2227 void VISU_TimeAnimation_i::setPresentationType (CORBA::Long theFieldNum,
2228 VISU::VISUType theType)
2230 myAnim->setPresentationType(theFieldNum,theType);
2233 VISU::VISUType VISU_TimeAnimation_i::getPresentationType (CORBA::Long theFieldNum)
2235 return myAnim->getPresentationType(theFieldNum);
2238 void VISU_TimeAnimation_i::setSpeed(CORBA::Long theSpeed)
2240 myAnim->setSpeed(theSpeed);
2243 CORBA::Long VISU_TimeAnimation_i::getSpeed()
2245 return myAnim->getSpeed();
2248 CORBA::Boolean VISU_TimeAnimation_i::isProportional()
2250 return myAnim->isProportional();
2253 void VISU_TimeAnimation_i::setAnimationRange (CORBA::Double theMin,
2254 CORBA::Double theMax)
2256 myAnim->setAnimationRange(theMin,theMax);
2259 CORBA::Double VISU_TimeAnimation_i::getMinRange()
2261 return myAnim->getMinRange();
2264 CORBA::Double VISU_TimeAnimation_i::getMaxRange()
2266 return myAnim->getMaxRange();
2269 CORBA::Boolean VISU_TimeAnimation_i::isRangeDefined()
2271 return myAnim->isRangeDefined();
2274 void VISU_TimeAnimation_i::setAnimationSequence (const char* theSequence)
2276 myAnim->setAnimationSequence(theSequence);
2279 char* VISU_TimeAnimation_i::getAnimationSequence()
2281 return myAnim->getAnimationSequence();
2284 CORBA::Boolean VISU_TimeAnimation_i::isSequenceDefined()
2286 return myAnim->isSequenceDefined();
2289 void VISU_TimeAnimation_i::dumpTo (const char* thePath)
2291 myAnim->dumpTo(thePath);
2294 char* VISU_TimeAnimation_i::setDumpFormat (const char* theFormat)
2296 string aDumpFormat = myAnim->setDumpFormat(theFormat);
2297 return CORBA::string_dup(aDumpFormat.c_str());
2300 void VISU_TimeAnimation_i::setTimeStampFrequency(CORBA::Long theFrequency)
2302 myAnim->setTimeStampFrequency(theFrequency);
2305 CORBA::Long VISU_TimeAnimation_i::getTimeStampFrequency()
2307 return myAnim->getTimeStampFrequency();
2310 CORBA::Boolean VISU_TimeAnimation_i::isCycling()
2312 return myAnim->isCycling();
2315 CORBA::Boolean VISU_TimeAnimation_i::isCleaningMemoryAtEachFrame(){
2316 return myAnim->isCleaningMemoryAtEachFrame();
2319 CORBA::Double VISU_TimeAnimation_i::getMinTime()
2321 return myAnim->getMinTime();
2324 CORBA::Double VISU_TimeAnimation_i::getMaxTime()
2326 return myAnim->getMaxTime();
2329 void VISU_TimeAnimation_i::setProportional (CORBA::Boolean theProp)
2331 myAnim->setProportional(theProp);
2334 void VISU_TimeAnimation_i::setCycling (CORBA::Boolean theCycle)
2336 myAnim->setCycling(theCycle);
2339 void VISU_TimeAnimation_i::setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle){
2340 myAnim->setCleaningMemoryAtEachFrame(theCycle);
2343 SALOMEDS::SObject_ptr VISU_TimeAnimation_i::publishInStudy()
2345 return myAnim->publishInStudy();
2348 void VISU_TimeAnimation_i::restoreFromStudy(SALOMEDS::SObject_ptr theObj)
2350 myAnim->restoreFromStudy(theObj);
2353 CORBA::Boolean VISU_TimeAnimation_i::isSavedInStudy()
2355 return myAnim->isSavedInStudy();
2358 void VISU_TimeAnimation_i::saveAnimation()
2360 myAnim->saveAnimation();
2363 void VISU_TimeAnimation_i::setAnimationMode(VISU::Animation::AnimationMode theMode)
2365 myAnim->setAnimationMode(theMode);
2368 VISU::Animation::AnimationMode VISU_TimeAnimation_i::getAnimationMode()
2370 return VISU::Animation::AnimationMode(myAnim->getAnimationMode());
2373 void VISU_TimeAnimation_i::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs)
2374 throw (SALOME::SALOME_Exception)
2376 myAnim->ApplyProperties(theFieldNum, thePrs);