1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : VISU_TimeAnimation.cxx
21 // Author : Vitaly SMETANNIKOV
24 #include "VISU_TimeAnimation.h"
29 #include <qmessagebox.h>
32 #include "VISUConfig.hh"
34 #include "VISU_Result_i.hh"
35 #include "VISU_Prs3d_i.hh"
36 #include "VISU_Mesh_i.hh"
37 #include "VISU_IsoSurfaces_i.hh"
38 #include "VISU_DeformedShape_i.hh"
39 #include "VISU_ScalarMapOnDeformedShape_i.hh"
40 #include "VISU_CutPlanes_i.hh"
41 #include "VISU_Plot3D_i.hh"
42 #include "VISU_CutLines_i.hh"
43 #include "VISU_Vectors_i.hh"
44 #include "VISU_StreamLines_i.hh"
45 #include "VISU_GaussPoints_i.hh"
46 #include "VISU_ViewManager_i.hh"
47 #include "VISU_View_i.hh"
49 #include "VISU_ScalarBarActor.hxx"
50 #include "VISU_Actor.h"
52 #include "SalomeApp_Study.h"
54 #include "SVTK_ViewWindow.h"
56 #include "SALOME_Event.hxx"
58 #include "SUIT_ResourceMgr.h"
59 #include "SUIT_Application.h"
60 #include "SUIT_Session.h"
61 #include "SUIT_Study.h"
63 #include "SALOMEDSClient_AttributeString.hxx"
64 #include "SALOMEDSClient_AttributeName.hxx"
66 #include "Utils_ExceptHandlers.hxx"
73 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
77 #include <Standard_Failure.hxx>
80 #include <Standard_ErrorHandler.hxx>
84 //------------------------------------------------------------------------
87 //------------------------------------------------------------------------
91 QMutex myIsActiveMutex;
93 ExecutionState(bool isActive = false)
94 : myIsActive(isActive) {}
98 myIsActiveMutex.lock();
100 myIsActiveMutex.unlock();
103 bool SetActive(bool isActive) {
105 myIsActiveMutex.lock();
107 myIsActive = isActive;
108 myIsActiveMutex.unlock();
114 //------------------------------------------------------------------------
115 struct TCompositeMinMaxController : virtual TVTKMinMaxController
117 typedef ColoredPrs3d_i* TKey;
118 typedef std::map< TKey, VISU::PMinMaxController > TMinMaxContainer;
119 TMinMaxContainer myMinMaxContainer;
122 AddController(ColoredPrs3d_i* theReference,
123 VISU::PMinMaxController theMinMaxController)
125 myMinMaxContainer[ TKey( theReference ) ] = theMinMaxController;
130 UpdateReference(ColoredPrs3d_i* theFromPrs3, ColoredPrs3d_i* theToPrs3d)
132 TMinMaxContainer::iterator anIter = myMinMaxContainer.find( TKey( theFromPrs3 ) );
133 if ( anIter != myMinMaxContainer.end() ) {
134 myMinMaxContainer.erase( anIter );
135 myMinMaxContainer[ TKey( theToPrs3d ) ] = VISU::CreateDefaultMinMaxController( theToPrs3d );
141 GetComponentMin(vtkIdType theCompID)
143 vtkFloatingPointType aMin = TMinMaxController::GetComponentMin(theCompID);
144 if ( !myMinMaxContainer.empty() ) {
145 TMinMaxContainer::const_iterator anIter = myMinMaxContainer.begin();
146 for(; anIter != myMinMaxContainer.end(); anIter++){
147 VISU::PMinMaxController aMinMaxController = anIter->second;
148 aMin = std::min(aMin, aMinMaxController->GetComponentMin(theCompID));
156 GetComponentMax(vtkIdType theCompID)
158 vtkFloatingPointType aMax = TMinMaxController::GetComponentMax(theCompID);
159 if ( !myMinMaxContainer.empty() ) {
160 TMinMaxContainer::const_iterator anIter = myMinMaxContainer.begin();
161 for(; anIter != myMinMaxContainer.end(); anIter++){
162 VISU::PMinMaxController aMinMaxController = anIter->second;
163 aMax = std::max(aMax, aMinMaxController->GetComponentMax(theCompID));
170 typedef SALOME::GenericObjPtr<TCompositeMinMaxController> PCompositeMinMaxController;
173 //------------------------------------------------------------------------
174 VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
175 VISU::View3D_ptr theView3D)
178 myExecutionState = new VISU::ExecutionState(false);
180 mySpeed = VISU::GetResourceMgr()->integerValue("VISU", "speed", 1);
181 myProportional = VISU::GetResourceMgr()->booleanValue("VISU", "use_proportional_timing", false);
184 if (!CORBA::is_nil(theView3D)) {
185 VISU::View3D_i* pView = dynamic_cast<VISU::View3D_i*>(GetServant(theView3D).in());
186 SUIT_ViewWindow* aVW = pView->GetViewWindow();
187 myView = dynamic_cast<SVTK_ViewWindow*>(aVW);
188 connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) );
191 myAnimationMode = VISU::Animation::PARALLEL;
197 myCycling = VISU::GetResourceMgr()->booleanValue("VISU", "cycled_animation", false);
198 myCleaningMemoryAtEachFrame = VISU::GetResourceMgr()->booleanValue("VISU", "clean_memory_at_each_frame", false);
203 myAVIMaker = "jpeg2yuv";
207 //------------------------------------------------------------------------
208 VISU_TimeAnimation::~VISU_TimeAnimation()
211 MESSAGE("Viewer is not defined for animation");
215 if (QThread::running() && !QThread::finished()) {
216 //myExecutionState->SetActive(false);
219 if (QThread::running() && !QThread::finished()) {
220 QThread::terminate();
224 for (int i = 0; i < getNbFields(); i++) {
225 clearData(myFieldsLst[i]);
229 delete myExecutionState;
233 /* Terminates the execution of the thread.
234 * The thread may or may not be terminated immediately,
235 * depending on the operating system's scheduling policies.
237 * Use QThread::wait() after terminate() for synchronous termination.
239 * When the thread is terminated, all threads waiting for the the thread to finish will be woken up.
241 * Warning: This function is dangerous, and its use is discouraged.
242 * The thread can be terminated at any point in its code path.
243 * Threads can be terminated while modifying data.
244 * There is no chance for the thread to cleanup after itself,
245 * unlock any held mutexes, etc. In short, use this function only if absolutely necessary.
247 //QThread::wait(100);
248 //QThread::terminate();
249 //QThread::wait(400);
253 //------------------------------------------------------------------------
254 bool VISU_TimeAnimation::addField (_PTR(SObject) theField)
256 if (!theField) return false;
259 aNewData.myField = theField;
260 aNewData.myNbFrames = 0;
261 aNewData.myPrsType = VISU::TSCALARMAP;
262 aNewData.myOffset[0] = aNewData.myOffset[1] = aNewData.myOffset[2] = 0;
263 VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aNewData.myField);
264 if(VISU::Storable::FindValue(aMap,"myComment") != "FIELD")
267 aNewData.myNbTimes = VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
269 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
270 if ( aNewData.myNbTimes < 2 )
272 if ( !myFieldsLst.isEmpty() && myFieldsLst.first().myNbTimes != aNewData.myNbTimes )
274 if ( myFieldsLst.isEmpty() )
275 myFieldsAbsFrames.push_back(aNewData.myNbTimes);
277 else { // successive animation mode
278 if ( aNewData.myNbTimes < 1 )
281 long aNumCompCurr = VISU::Storable::FindValue(aMap, "myNumComponent").toLong();
282 if ( !myFieldsLst.isEmpty() ) {
283 VISU::Storable::TRestoringMap aFMap = VISU::Storable::GetStorableMap(myFieldsLst.first().myField);
284 long aNumComp = VISU::Storable::FindValue(aFMap, "myNumComponent").toLong();
285 if ( aNumCompCurr != aNumComp )
289 if ( !myFieldsLst.isEmpty() )
290 myFieldsAbsFrames.push_back(myFieldsAbsFrames.back() + aNewData.myNbTimes);
292 myFieldsAbsFrames.push_back(aNewData.myNbTimes);
295 myFieldsLst.append(aNewData);
297 //find Min/Max timestamps
298 _PTR(ChildIterator) anIter = myStudy->NewChildIterator(theField);
299 anIter->Next(); // First is reference on support
300 if ( myFieldsLst.size() == 1 ) { // the first field
301 myTimeMin = getTimeValue(anIter->Value());
302 myTimeMax = getTimeValue(anIter->Value());
304 for(; anIter->More(); anIter->Next()) {
305 if ( myTimeMin > getTimeValue(anIter->Value()) )
306 myTimeMin = getTimeValue(anIter->Value());
307 if ( myTimeMax < getTimeValue(anIter->Value()) )
308 myTimeMax = getTimeValue(anIter->Value());
314 //------------------------------------------------------------------------
315 bool VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField)
317 SALOMEDS::SObject_var theFieldDup = SALOMEDS::SObject::_duplicate(theField);
318 _PTR(SObject) aField = VISU::GetClientSObject(theFieldDup, myStudy);
319 return addField(aField);
323 //------------------------------------------------------------------------
324 void VISU_TimeAnimation::_clearData(FieldData& theData) {
326 MESSAGE("Viewer is not defined for animation");
329 theData.myTiming.clear();
330 vtkRenderer* aRen = myView->getRenderer();
331 if (!theData.myActors.empty()) {
332 for (int i = 0, iEnd = theData.myActors.size(); i < iEnd; i++) {
333 if (theData.myActors[i] != 0) {
334 theData.myActors[i]->RemoveFromRender(aRen);
337 theData.myActors.clear();
339 if (!theData.myPrs.empty()) {
340 for (int i = 0, iEnd = theData.myPrs.size(); i < iEnd; i++)
341 if (theData.myPrs[i] != 0) {
342 theData.myPrs[i]->_remove_ref();
344 theData.myPrs.clear();
346 theData.myNbFrames = 0;
350 //------------------------------------------------------------------------
351 void VISU_TimeAnimation::clearData(FieldData& theData) {
352 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,FieldData&>
353 (this,&VISU_TimeAnimation::_clearData,theData));
358 //------------------------------------------------------------------------
359 template<class TPrs3d>
361 GeneratePresentations(_PTR(Study) theStudy,
363 VISU::Result_i* theResult,
364 bool theIsRangeDefined,
365 CORBA::Double theTimeMin,
366 CORBA::Double theTimeMax,
367 QValueList<long> theSequence)
369 _PTR(ChildIterator) anIter = theStudy->NewChildIterator(theData.myField);
370 anIter->Next(); // First is reference on support
372 long aSequenceLength = theSequence.count();
373 bool isSequenceDefined = aSequenceLength > 0;
374 if (isSequenceDefined)
375 theData.myPrs.resize(aSequenceLength,NULL);
378 long aSequenceIndex = 1;
379 for(; anIter->More(); anIter->Next(), aSequenceIndex++){
380 if (aFrameId == theData.myNbTimes) {
381 MESSAGE("There are extra timestamps in field");
384 _PTR(SObject) aTimeStamp = anIter->Value();
388 long aSequenceId = -1;
390 theData.myTiming[aFrameId] = VISU_TimeAnimation::getTimeValue(aTimeStamp);
391 if (theIsRangeDefined) {
392 if (theData.myTiming[aFrameId] < theTimeMin)
394 if (theData.myTiming[aFrameId] > theTimeMax)
397 else if (isSequenceDefined) {
398 aSequenceId = theSequence.findIndex( aSequenceIndex );
399 if( aSequenceId == -1 )
403 VISU::Storable::TRestoringMap aTimeMap = VISU::Storable::GetStorableMap(aTimeStamp);
404 QString aMeshName = VISU::Storable::FindValue(aTimeMap,"myMeshName");
405 VISU::Entity anEntity = (VISU::Entity) VISU::Storable::FindValue(aTimeMap,"myEntityId").toInt();
406 QString aFieldName = VISU::Storable::FindValue(aTimeMap,"myFieldName");
407 int aTimeStampId = VISU::Storable::FindValue(aTimeMap,"myTimeStampId").toInt();
409 bool anIsCreated = false;
410 TPrs3d* aPresent = new TPrs3d(VISU::ColoredPrs3d_i::EDoNotPublish);
411 aPresent->SetCResult(theResult);
412 aPresent->SetMeshName(aMeshName.latin1());
413 aPresent->SetEntity(anEntity);
414 aPresent->SetFieldName(aFieldName.latin1());
415 aPresent->SetTimeStampNumber(aTimeStampId);
420 if(aPresent->Apply(false)){
422 if(isSequenceDefined)
424 theData.myPrs[aSequenceId] = aPresent;
429 theData.myPrs[aFrameId++] = aPresent;
432 }catch(Standard_Failure) {
433 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
434 INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
435 }catch(std::exception& exc){
436 INFOS("Follow exception was occured :\n"<<exc.what());
438 INFOS("Unknown exception was occured!");
441 aPresent->_remove_ref();
444 theData.myNbFrames = aFrameId;
446 if (theData.myPrsType != VISU::TGAUSSPOINTS) {
447 for(long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++) {
448 if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(theData.myPrs[aFrameId])){
449 aPrs->SetOffset(theData.myOffset);
456 double getMinFieldsValue( QValueList<FieldData>& theFieldsLst )
458 // for successive animation mode only
460 for (int i = 0; i < theFieldsLst.count(); i++) {
461 if ( theFieldsLst[i].myPrs[0] ) {
462 aRes = theFieldsLst[i].myPrs[0]->GetMin();
467 for (int i = 1; i < theFieldsLst.count() && theFieldsLst[i].myPrs[0]; i++) {
468 if ( aRes > theFieldsLst[i].myPrs[0]->GetMin() )
469 aRes = theFieldsLst[i].myPrs[0]->GetMin();
474 double getMaxFieldsValue( QValueList<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]->GetMax();
485 for (int i = 1; i < theFieldsLst.count() && theFieldsLst[i].myPrs[0]; i++) {
486 if ( aRes < theFieldsLst[i].myPrs[0]->GetMax() )
487 aRes = theFieldsLst[i].myPrs[0]->GetMax();
492 void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) {
493 FieldData& aData = myFieldsLst[theFieldNum];
495 // Delete previous presentations
498 VISU::Result_i* aResult = createPresent(aData.myField);
499 VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aData.myField);
500 aData.myNbFrames = aData.myNbTimes;
501 //VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
503 aData.myPrs.resize(aData.myNbTimes,NULL);
504 aData.myTiming.resize(aData.myNbTimes);
506 QValueList<long> aSequence;
507 if( isSequenceDefined() )
509 bool ok = getIndicesFromSequence( mySequence, aSequence );
514 using namespace VISU;
515 switch (aData.myPrsType) {
516 case VISU::TSCALARMAP:
517 GeneratePresentations<ScalarMap_i>(myStudy,
525 case VISU::TISOSURFACES: // Iso Surfaces
526 GeneratePresentations<IsoSurfaces_i>(myStudy,
534 case VISU::TCUTPLANES: // Cut Planes
535 GeneratePresentations<CutPlanes_i>(myStudy,
543 case VISU::TCUTLINES: // Cut Lines
544 GeneratePresentations<CutLines_i>(myStudy,
552 case VISU::TPLOT3D: // Plot3d
553 GeneratePresentations<Plot3D_i>(myStudy,
561 case VISU::TDEFORMEDSHAPE: // Deformed Shape
562 GeneratePresentations<DeformedShape_i>(myStudy,
570 case VISU::TVECTORS: // Vectors
571 GeneratePresentations<Vectors_i>(myStudy,
579 case VISU::TSTREAMLINES: // Stream Lines
580 GeneratePresentations<StreamLines_i>(myStudy,
588 case VISU::TGAUSSPOINTS: // Gauss Points
589 GeneratePresentations<GaussPoints_i>(myStudy,
597 case VISU::TSCALARMAPONDEFORMEDSHAPE: // Scalar map on deformed shape
598 GeneratePresentations<ScalarMapOnDeformedShape_i>(myStudy,
607 MESSAGE("Not implemented for this presentation type: " << aData.myPrsType);
611 if ( myAnimationMode == VISU::Animation::SUCCESSIVE ) { // successive animation mode
612 if ( myFieldsAbsFrames.size() == getNbFields() )
613 myFieldsAbsFrames.clear();
614 if ( theFieldNum > 0 )
615 myFieldsAbsFrames.push_back(myFieldsAbsFrames.back() + aData.myNbFrames);
617 myFieldsAbsFrames.push_back(aData.myNbFrames);
619 if (theFieldNum == getNbFields() - 1) {
620 if ( aData.myPrsType != VISU::TGAUSSPOINTS) {
622 // Initialize the MinMax controller
623 VISU::PCompositeMinMaxController aMinMaxController(new VISU::TCompositeMinMaxController());
624 if ( myAnimationMode == VISU::Animation::PARALLEL ) {
625 FieldData& aFieldData = getFieldData(theFieldNum);
626 VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[0];
627 aMinMaxController->AddController( aPrs3d, VISU::CreateDefaultMinMaxController( aPrs3d ) );
629 for (int aFieldId = 0; aFieldId < getNbFields(); aFieldId++) {
630 FieldData& aFieldData = getFieldData(aFieldId);
631 VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[0];
632 aMinMaxController->AddController( aPrs3d, VISU::CreateDefaultMinMaxController( aPrs3d ) );
636 double aMin = getMinFieldsValue(myFieldsLst);
637 double aMax = getMaxFieldsValue(myFieldsLst);
639 for (int aFieldId = 0; aFieldId < getNbFields(); aFieldId++) {
640 FieldData& aFieldData = getFieldData(aFieldId);
641 for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) {
642 VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[aFrameId];
643 aPrs3d->SetMinMaxController(aMinMaxController);
644 if (VISU::IsoSurfaces_i* anIsoSurfaces = dynamic_cast<VISU::IsoSurfaces_i*>(aPrs3d))
645 anIsoSurfaces->SetSubRange(aMin, aMax);
654 //------------------------------------------------------------------------
655 CORBA::Boolean VISU_TimeAnimation::_generateFrames() {
657 MESSAGE("Viewer is not defined for animation");
661 myLastError = QString("Frame(s) for ");
662 bool aNoError = true;
666 for (int i = 0; i < getNbFields(); i++) {
667 FieldData& aData = myFieldsLst[i];
668 aData.myActors.resize(aData.myNbFrames,NULL);
669 for (long j = 0; j < aData.myNbFrames; j++) {
670 VISU_Actor* aActor = NULL;
672 aData.myPrs[j]->SetOffset(aData.myOffset);
673 aActor = aData.myPrs[j]->CreateActor();
674 myView->AddActor(aActor);
675 bool condition = ( myAnimationMode == VISU::Animation::PARALLEL ) ? (j == 0) : (j == 0 && i == 0);
677 aActor->VisibilityOn();
679 aActor->VisibilityOff();
680 }catch(...){ //catch(std::runtime_error& exc){
682 myLastError += QString("%1 ").arg(aData.myTiming[j]);
684 aData.myActors[j] = aActor;
688 myLastError += QString(" timestamp(s) cannot be created.");
689 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
690 myFrame, myFieldsLst[0].myTiming[myFrame]));
695 //------------------------------------------------------------------------
696 CORBA::Boolean VISU_TimeAnimation::generateFrames()
698 return ProcessEvent(new TMemFunEvent<VISU_TimeAnimation,bool>
699 (this,&VISU_TimeAnimation::_generateFrames));
702 //------------------------------------------------------------------------
703 void VISU_TimeAnimation::_clearView() {
705 MESSAGE("Viewer is not defined for animation");
708 vtkRenderer* aRen = myView->getRenderer();
709 for (int i = 0; i < getNbFields(); i++) {
710 FieldData& aData = myFieldsLst[i];
711 if (!aData.myActors.empty()) {
712 for (int i = 0, iEnd = aData.myActors.size(); i < iEnd; i++) {
713 if (aData.myActors[i] != 0) {
714 aData.myActors[i]->RemoveFromRender(aRen);
717 aData.myActors.clear();
720 VISU::RepaintView(myView);
723 //------------------------------------------------------------------------
724 void VISU_TimeAnimation::clearView()
726 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
727 (this,&VISU_TimeAnimation::_clearView));
730 //------------------------------------------------------------------------
731 void VISU_TimeAnimation::_visibilityOff(int num_field, int num_frame) {
732 if ( num_field < 0 || num_frame < 0 ) return;
733 FieldData& aData = myFieldsLst[num_field];
734 if ( aData.myActors.empty() ) return;
735 VISU_Actor* aActor = aData.myActors[num_frame];
736 if (! myCleaningMemoryAtEachFrame) {
738 // Usual behaviour : VisibilityOff()
739 // Problem : It don't clean the memory so if there is
740 // a lot of frames, the memory grows dramatically
742 aActor->VisibilityOff();
745 // myCleaningMemoryAtEachFrame behaviour:
746 // Delete the actor and re-creation it with VisibilityOff()
747 // since it takes memory only at VisibilityOn()
750 aActor->RemoveFromRender(myView->getRenderer());
751 // Re-create the actor
752 aActor = aData.myPrs[num_frame]->CreateActor();
753 myView->AddActor(aActor);
754 aActor->VisibilityOff();
755 aData.myActors[num_frame] = aActor;
759 //------------------------------------------------------------------------
760 void VISU_TimeAnimation::visibilityOff(int num_field, int num_frame)
762 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,int,int>
763 (this,&VISU_TimeAnimation::_visibilityOff,num_field,num_frame));
766 //------------------------------------------------------------------------
767 void VISU_TimeAnimation::stopAnimation()
769 myExecutionState->SetActive(false);
772 //------------------------------------------------------------------------
773 void VISU_TimeAnimation::_startAnimation() {
774 if (!myExecutionState->IsActive()) {
775 myExecutionState->SetActive(true);
780 //------------------------------------------------------------------------
781 void VISU_TimeAnimation::startAnimation()
783 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
784 (this,&VISU_TimeAnimation::_startAnimation));
787 //------------------------------------------------------------------------
788 CORBA::Boolean VISU_TimeAnimation::isRunning()
790 return myExecutionState->IsActive();
793 //------------------------------------------------------------------------
794 void VISU_TimeAnimation::_nextFrame() {
796 MESSAGE("Viewer is not defined for animation");
800 if (myFrame < getNbFrames() - 1 ) { //(myFieldsLst[0].myNbFrames-1)) {
802 std::pair<int,long> aPair;
806 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
807 for (i = 0; i < getNbFields(); i++)
808 if (myFieldsLst[i].myActors[myFrame] != 0)
809 visibilityOff(i, myFrame);
811 else { //successive animation mode
812 aPair = getRelativeFrameNumber(myFrame);
813 aFieldId = aPair.first;
814 aFrameId = aPair.second;
815 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
816 visibilityOff(aFieldId, aFrameId);
821 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
822 for (i = 0; i < getNbFields(); i++)
823 if (myFieldsLst[i].myActors[myFrame] != 0)
824 myFieldsLst[i].myActors[myFrame]->VisibilityOn();
826 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
827 myFrame, myFieldsLst[0].myTiming[myFrame]));
829 else { //successive animation mode
830 aPair = getRelativeFrameNumber(myFrame);
831 aFieldId = aPair.first;
832 aFrameId = aPair.second;
833 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
834 myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
836 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
837 myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
843 //------------------------------------------------------------------------
844 void VISU_TimeAnimation::nextFrame()
846 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
847 (this,&VISU_TimeAnimation::_nextFrame));
850 //------------------------------------------------------------------------
851 void VISU_TimeAnimation::_prevFrame() {
853 MESSAGE("Viewer is not defined for animation");
859 std::pair<int,long> aPair;
863 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
864 for (i = 0; i < getNbFields(); i++)
865 if (myFieldsLst[i].myActors[myFrame] != 0)
866 visibilityOff(i, myFrame);
868 else { //successive animation mode
869 aPair = getRelativeFrameNumber(myFrame);
870 aFieldId = aPair.first;
871 aFrameId = aPair.second;
872 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
873 visibilityOff(aFieldId, aFrameId);
878 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
879 for (i = 0; i < getNbFields(); i++)
880 if (myFieldsLst[i].myActors[myFrame] != 0)
881 myFieldsLst[i].myActors[myFrame]->VisibilityOn();
883 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
884 myFrame, myFieldsLst[0].myTiming[myFrame]));
886 else { //successive animation mode
887 aPair = getRelativeFrameNumber(myFrame);
888 aFieldId = aPair.first;
889 aFrameId = aPair.second;
890 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
891 myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
893 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
894 myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
900 //------------------------------------------------------------------------
901 void VISU_TimeAnimation::prevFrame()
903 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
904 (this,&VISU_TimeAnimation::_prevFrame));
907 //------------------------------------------------------------------------
908 void VISU_TimeAnimation::_firstFrame() {
910 MESSAGE("Viewer is not defined for animation");
915 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
916 for (i = 0; i < getNbFields(); i++)
917 if(!myFieldsLst[i].myActors.empty())
918 if (myFieldsLst[i].myActors[myFrame] != 0)
919 visibilityOff(i, myFrame);
921 else { //successive animation mode
922 std::pair<int,long> aPair = getRelativeFrameNumber(myFrame);
923 int aFieldId = aPair.first;
924 long aFrameId = aPair.second;
925 if(!myFieldsLst[aFieldId].myActors.empty())
926 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
927 visibilityOff(aFieldId, aFrameId);
932 if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode
933 imax = getNbFields();
934 else //successive animation mode
937 for (i = 0; i < imax; i++)
938 if(!myFieldsLst[i].myActors.empty())
939 if (myFieldsLst[i].myActors[myFrame] != 0)
940 myFieldsLst[i].myActors[myFrame]->VisibilityOn();
942 if(!myFieldsLst[0].myTiming.empty()){
943 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
944 myFrame, myFieldsLst[0].myTiming[myFrame]));
949 //------------------------------------------------------------------------
950 void VISU_TimeAnimation::firstFrame()
952 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
953 (this,&VISU_TimeAnimation::_firstFrame));
956 //------------------------------------------------------------------------
957 void VISU_TimeAnimation::_lastFrame() {
959 MESSAGE("Viewer is not defined for animation");
964 std::pair<int,long> aPair;
968 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
969 for (i = 0; i < getNbFields(); i++)
970 if (myFieldsLst[i].myActors[myFrame] != 0)
971 visibilityOff(i, myFrame);
973 else { //successive animation mode
974 aPair = getRelativeFrameNumber(myFrame);
975 aFieldId = aPair.first;
976 aFrameId = aPair.second;
977 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
978 visibilityOff(aFieldId, aFrameId);
981 myFrame = getNbFrames() - 1; //myFieldsLst[0].myNbFrames-1;
983 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
984 for (i = 0; i < getNbFields(); i++)
985 if (myFieldsLst[i].myActors[myFrame] != 0)
986 myFieldsLst[i].myActors[myFrame]->VisibilityOn();
988 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
989 myFrame, myFieldsLst[0].myTiming[myFrame]));
991 else { //successive animation mode
992 aPair = getRelativeFrameNumber(myFrame);
993 aFieldId = aPair.first;
994 aFrameId = aPair.second;
995 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
996 myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
998 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
999 myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
1005 //------------------------------------------------------------------------
1006 void VISU_TimeAnimation::lastFrame()
1008 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
1009 (this,&VISU_TimeAnimation::_lastFrame));
1013 //------------------------------------------------------------------------
1014 // For Batchmode using
1015 void VISU_TimeAnimation::_gotoFrame(CORBA::Long theFrame) {
1017 MESSAGE("Viewer is not defined for animation");
1020 if ((theFrame < 0) || (theFrame > (getNbFrames()-1)))
1024 std::pair<int,long> aPair;
1028 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1029 for (i = 0; i < getNbFields(); i++)
1030 if (myFieldsLst[i].myActors[myFrame] != 0)
1031 visibilityOff(i, myFrame);
1033 else { //successive animation mode
1034 aPair = getRelativeFrameNumber(myFrame);
1035 aFieldId = aPair.first;
1036 aFrameId = aPair.second;
1037 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
1038 visibilityOff(aFieldId, aFrameId);
1043 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1044 for (i = 0; i < getNbFields(); i++)
1045 if (myFieldsLst[i].myActors[myFrame] != 0)
1046 myFieldsLst[i].myActors[myFrame]->VisibilityOn();
1048 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
1049 myFrame, myFieldsLst[0].myTiming[myFrame]));
1051 else { //successive animation mode
1052 aPair = getRelativeFrameNumber(myFrame);
1053 aFieldId = aPair.first;
1054 aFrameId = aPair.second;
1055 if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
1056 myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
1058 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
1059 myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
1065 //------------------------------------------------------------------------
1066 void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame)
1068 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,CORBA::Long>
1069 (this,&VISU_TimeAnimation::_gotoFrame,theFrame));
1072 //------------------------------------------------------------------------
1073 void VISU_TimeAnimation::_emitFrameChanged(long theNewFrame, double theTime)
1075 emit frameChanged(theNewFrame, theTime);
1078 //------------------------------------------------------------------------
1079 void VISU_TimeAnimation::_emitStopped()
1084 //------------------------------------------------------------------------
1085 VISU::ColoredPrs3d_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CORBA::Long theFrame) {
1086 if ((theField > getNbFields()) || (theField < 0))
1087 return VISU::ColoredPrs3d::_nil();
1088 if ((theFrame < 0) || (theFrame > (myFieldsLst[theField].myNbFrames - 1)))
1089 return VISU::ColoredPrs3d::_nil();
1090 return myFieldsLst[theField].myPrs[theFrame]->_this();
1094 //------------------------------------------------------------------------
1095 CORBA::Long VISU_TimeAnimation::getNbFrames() {
1096 if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode
1097 return (getNbFields() > 0)? myFieldsLst[0].myNbFrames : 0;
1098 else //successive animation mode
1099 return (getNbFields() > 0 && !myFieldsAbsFrames.empty()) ? myFieldsAbsFrames[myFieldsAbsFrames.size()-1] : 0;
1102 //------------------------------------------------------------------------
1103 long VISU_TimeAnimation::getAbsoluteFrameNumber(std::pair<int,long> theFieldTimeStamp)
1106 if ( getNbFields() > 0 ) {
1107 int aFieldId = theFieldTimeStamp.first;
1108 long aFrameNum = theFieldTimeStamp.second + 1;
1109 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1110 if ( aFrameNum <= myFieldsAbsFrames[0] )
1113 else { //successive animation mode
1114 if ( aFieldId == 0 && aFrameNum <= myFieldsAbsFrames[aFieldId] )
1116 else if ( aFieldId && aFrameNum <= myFieldsAbsFrames[aFieldId] - myFieldsAbsFrames[aFieldId-1] )
1117 aRes = myFieldsAbsFrames[aFieldId-1] + aFrameNum;
1123 //------------------------------------------------------------------------
1124 std::pair<int,long> VISU_TimeAnimation::getRelativeFrameNumber(long theFrame)
1126 std::pair<int,long> aRes;
1127 if ( getNbFields() > 0 && theFrame < getNbFrames() ) {
1128 theFrame = theFrame + 1;
1129 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1131 aRes.second = theFrame - 1;
1133 else { //successive animation mode
1134 for (int i = 0, iEnd = myFieldsAbsFrames.size(); i < iEnd; i++)
1135 if ( myFieldsAbsFrames[i] >= theFrame ) {
1138 aRes.second = theFrame - 1;
1140 aRes.second = theFrame-myFieldsAbsFrames[i-1] - 1;
1148 //------------------------------------------------------------------------
1149 void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList<int>& theIndexList )
1153 FieldData& aFirstFieldData = myFieldsLst[0];
1154 if (aFirstFieldData.myNbFrames > 2)
1155 aOneVal = ( myTimeMax - myTimeMin ) / getNbFrames();
1158 bool aHasNextFrame = aFirstFieldData.myField && aFirstFieldData.myNbFrames > 0;
1159 while (aHasNextFrame && myExecutionState->IsActive()) {
1160 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>
1161 (this, &VISU_TimeAnimation::_emitFrameChanged,
1162 myFrame, aFirstFieldData.myTiming[myFrame]));
1163 if (myExecutionState->IsActive()) {
1164 for (int i = 0; i < getNbFields(); i++) {
1165 FieldData& aData = myFieldsLst[i];
1166 if (aData.myNbFrames == 0)
1169 if (aData.myActors[myFrame-1] != 0)
1170 visibilityOff(i, myFrame-1);
1172 if (aData.myActors[aData.myNbFrames-1] != 0)
1173 visibilityOff(i, aData.myNbFrames-1);
1175 if (aData.myActors[myFrame] != 0) {
1176 ProcessVoidEvent(new TVoidMemFunEvent<VISU_Actor>(aData.myActors[myFrame],
1177 &VISU_Actor::VisibilityOn));
1180 bool repainArg = false;
1181 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
1182 &SVTK_ViewWindow::Repaint,
1187 if (myProportional) {
1192 if (aFirstFieldData.myNbFrames > 2)
1193 k = (aFirstFieldData.myTiming[myFrame+1] -
1194 aFirstFieldData.myTiming[myFrame]) / aOneVal;
1197 if (myFrame < (aFirstFieldData.myNbFrames - 1))
1198 k = (aFirstFieldData.myTiming[myFrame+1] -
1199 aFirstFieldData.myTiming[myFrame]) / aOneVal;
1202 int delay = (int)(1000. * k / mySpeed);
1203 theIsDumping = !myDumpPath.isEmpty();
1204 if (delay < 1 && theIsDumping) {
1205 // We must unlock mutex for some time before grabbing to allow view updating
1209 if (!myExecutionState->IsActive())
1213 // We must unlock mutex for some time before grabbing to allow view updating
1215 if (!myExecutionState->IsActive())
1218 if (!(aFirstFieldData.myField)) // break, if field was deleted.
1221 saveImages( 0, aOneVal, aNbFiles, theIndexList );
1224 if (!myExecutionState->IsActive())
1228 if (myFrame == aFirstFieldData.myNbFrames) {
1230 aHasNextFrame = false;
1236 } // while (aHasNextFrame && myExecutionState->IsActive())
1239 //------------------------------------------------------------------------
1240 void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QValueList<int>& theIndexList )
1242 if (myFrame >= getNbFrames() - 1)
1244 myExecutionState->SetActive(false);
1250 FieldData& aFirstFieldData = myFieldsLst[0];
1251 if (aFirstFieldData.myNbFrames > 2)
1252 aOneVal = ( myTimeMax - myTimeMin ) / getNbFrames();
1254 long aFrame = myFrame;
1256 bool aHasNextFrame = true;
1257 while (aHasNextFrame && myExecutionState->IsActive())
1259 for (int aFieldId = 0;
1260 (aFieldId < getNbFields()) && (myFieldsLst[aFieldId].myField);
1261 aFieldId++, aFrame = 0)
1263 if (!myExecutionState->IsActive()) break;
1265 FieldData& aData = myFieldsLst[aFieldId];
1266 if ( !aData.myPrs[0] ) continue;
1267 for (; aFrame < aData.myNbFrames && myExecutionState->IsActive(); aFrame++, myFrame++)
1269 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>
1270 (this, &VISU_TimeAnimation::_emitFrameChanged,
1271 myFrame, myFieldsLst[aFieldId].myTiming[aFrame]));
1273 if (myExecutionState->IsActive()) {
1275 if (aData.myActors[aFrame-1] != 0)
1276 visibilityOff(aFieldId, aFrame-1);
1277 } else if ( myFrame > 0) {
1278 if (myFieldsLst[aFieldId-1].myActors[myFieldsLst[aFieldId-1].myNbFrames-1] != 0)
1279 visibilityOff(aFieldId-1, myFieldsLst[aFieldId-1].myNbFrames-1);
1280 } else if ( myCycling ) {
1281 if (myFieldsLst[getNbFields()-1].myActors[myFieldsLst[getNbFields()-1].myNbFrames-1] != 0)
1282 visibilityOff(getNbFields()-1, myFieldsLst[getNbFields()-1].myNbFrames-1);
1284 if (aData.myActors[aData.myNbFrames-1] != 0)
1285 visibilityOff(aFieldId, aData.myNbFrames-1);
1287 if (aData.myActors[aFrame] != 0) {
1288 ProcessVoidEvent(new TVoidMemFunEvent<VISU_Actor>(aData.myActors[aFrame],
1289 &VISU_Actor::VisibilityOn));
1292 bool repainArg = false;
1293 ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
1294 &SVTK_ViewWindow::Repaint,
1299 if (myProportional) {
1304 if (aFirstFieldData.myNbFrames > 2)
1305 k = (aFirstFieldData.myTiming[aFrame+1] -
1306 aFirstFieldData.myTiming[aFrame]) / aOneVal;
1309 if (aFrame < (aFirstFieldData.myNbFrames - 1))
1310 k = (aFirstFieldData.myTiming[aFrame+1] -
1311 aFirstFieldData.myTiming[aFrame]) / aOneVal;
1314 int delay = (int)(1000. * k / mySpeed);
1315 theIsDumping = !myDumpPath.isEmpty();
1316 if (delay < 1 && theIsDumping) {
1317 // We must unlock mutex for some time before grabbing to allow view updating
1322 if (!myExecutionState->IsActive()) return;
1325 // We must unlock mutex for some time before grabbing to allow view updating
1327 if (!myExecutionState->IsActive()) return;
1329 if (!(myFieldsLst[aFieldId].myField)) // break, if field was deleted.
1332 saveImages( aFieldId, aOneVal, aNbFiles, theIndexList );
1334 } // for (; aFrame < aData.myNbFrames && myExecutionState->IsActive(); aFrame++, myFrame++)
1335 } // for (int aFieldId = 0;
1338 aHasNextFrame = false;
1345 } // while (aHasNextFrame && myExecutionState->IsActive())
1348 //------------------------------------------------------------------------
1349 void VISU_TimeAnimation::saveImages( int theFieldId,
1350 double& theOneVal, int& theNbFiles,
1351 QValueList<int>& theIndexList )
1353 if (myDumpFormat.compare("AVI") != 0) {
1354 QString aFile(myDumpPath);
1357 if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode
1358 aName = QString("%1").arg(myFieldsLst[theFieldId].myTiming[myFrame]);
1359 else // successive animation mode
1360 aName = QString("%1").arg(myFieldsLst[theFieldId].myTiming[getRelativeFrameNumber(myFrame).second]);
1363 while ((aPos = aName.find(".")) > -1 )
1364 aName.replace(aPos, 1, "_");
1367 aFile += myDumpFormat.lower();
1368 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1369 (myView,&SVTK_ViewWindow::RefreshDumpImage)); // IPAL13602
1370 ProcessEvent(new TMemFun2ArgEvent<SUIT_ViewWindow,bool,const QString&,const QString&>
1371 (myView,&SUIT_ViewWindow::dumpViewToFormat,aFile,myDumpFormat));
1373 QFileInfo aFileInfo(myDumpPath);
1374 QString aDirPath = aFileInfo.dirPath(true);
1375 QString aBaseName = aFileInfo.fileName();
1384 if (myProportional) {
1385 FieldData& aFirstFieldData = myFieldsLst[0];
1386 double p = (aFirstFieldData.myTiming[myFrame] -
1387 aFirstFieldData.myTiming[myFrame-1]) / theOneVal;
1388 myFileIndex += (long) (5*p);
1394 QString aFile = aDirPath + QDir::separator() + aBaseName;
1396 aFile += QString("%1").arg(myFileIndex).rightJustify(8, '0');
1399 /* check image size is divisable 16
1400 myView->dumpViewToFormat(aFile,"JPEG");
1402 SUIT_ViewWindow* aView = myView;
1403 ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>(myView,&SVTK_ViewWindow::RefreshDumpImage)); // IPAL13602
1404 QImage img = ProcessEvent(new TMemFunEvent<SUIT_ViewWindow,QImage>(aView,&SUIT_ViewWindow::dumpView));
1405 if (!img.isNull()) {
1406 int width = img.width(); width = (width/16)*16;
1407 int height = img.height(); height = (height/16)*16;
1408 QImage copy = img.copy(0, 0, width, height);
1409 if (copy.save(aFile, "JPEG")) {
1410 theIndexList.append(myFileIndex);
1417 //------------------------------------------------------------------------
1418 void VISU_TimeAnimation::run()
1421 MESSAGE("Viewer is not defined for animation");
1425 bool isDumping = !myDumpPath.isEmpty();
1427 QValueList<int> anIndexList;
1429 if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode
1430 parallelAnimation( isDumping, anIndexList );
1431 else //successive animation mode
1432 successiveAnimation( isDumping, anIndexList );
1434 // make AVI file if need
1435 if (isDumping && myDumpFormat.compare("AVI") == 0 && myExecutionState->IsActive()) {
1436 double aFPS = 17.3 * mySpeed;
1438 QFileInfo aFileInfo(myDumpPath);
1439 QString aDirPath = aFileInfo.dirPath(true);
1440 QString aBaseName = aFileInfo.fileName();
1442 // add missing files
1443 if (anIndexList.count() > 1) {
1444 QString aFFile = aDirPath + QDir::separator() + aBaseName;
1445 aFFile += QString("_%1.jpeg");
1446 int aStartIndex = anIndexList[0], anEndIndex;
1447 for (int i = 1; i < anIndexList.count(); i++) {
1448 anEndIndex = anIndexList[i];
1449 QString aCurFile = aFFile.arg(QString::number(aStartIndex).rightJustify(8, '0'));
1450 QStringList aCommands;
1451 for (int j = aStartIndex+1; j < anEndIndex; j++) {
1452 QString aFile = aFFile.arg(QString::number(j).rightJustify(8, '0'));
1453 aCommands.append(QString("ln -s %1 %2").arg(aCurFile).arg(aFile));
1455 system(aCommands.join(" ; \\\n").latin1());
1456 aStartIndex = anEndIndex;
1461 QString aPattern = aDirPath + QDir::separator() + aBaseName;
1462 aPattern += "_\%08d.jpeg";
1464 QString aCmd = myAVIMaker;
1467 aCmd += QString(" -f %1").arg(aFPS);
1468 // aCmd += QString(" -n %1").arg(aNbFiles);
1469 aCmd += QString(" -n %1").arg(myFileIndex+1);
1470 aCmd += QString(" -j %1").arg(aPattern);
1471 aCmd += " | yuv2lav";
1472 aCmd += QString(" -o %1").arg(myDumpPath);
1473 system(aCmd.latin1());
1475 // remove temporary jpeg files
1477 aCmd += QString("cd %1").arg(aDirPath);
1479 aCmd += QString(" | egrep '%1_[0-9]*.jpeg'").arg(aBaseName);
1480 aCmd += " | xargs rm";
1482 system(aCmd.latin1());
1485 if (myExecutionState->IsActive())
1486 ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>(this,&VISU_TimeAnimation::_emitStopped));
1487 myExecutionState->SetActive(false);
1490 //------------------------------------------------------------------------
1491 VISU::Result_i* VISU_TimeAnimation::createPresent (_PTR(SObject) theField)
1493 _PTR(SObject) aSObj = theField->GetFather();
1494 aSObj = aSObj->GetFather();
1495 aSObj = aSObj->GetFather();
1496 CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj);
1497 if (CORBA::is_nil(anObject)) return NULL;
1498 return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
1501 //------------------------------------------------------------------------
1502 double VISU_TimeAnimation::getTimeValue (_PTR(SObject) theTimeStamp)
1504 _PTR(GenericAttribute) anAttr;
1505 if (theTimeStamp->FindAttribute(anAttr, "AttributeName")) {
1506 _PTR(AttributeName) aName (anAttr);
1507 QString aNameString (aName->Value().c_str());
1508 int time_len = aNameString.find(',');
1510 return aNameString.left(time_len).toDouble();
1512 return aNameString.toDouble();
1517 //------------------------------------------------------------------------
1518 void VISU_TimeAnimation::setSpeed(CORBA::Long theSpeed)
1520 mySpeed = (theSpeed<1)? 1 : theSpeed;
1523 //------------------------------------------------------------------------
1524 void VISU_TimeAnimation::setAnimationSequence(const char* theSequence)
1526 mySequence = QString( theSequence );
1529 //------------------------------------------------------------------------
1530 char* VISU_TimeAnimation::getAnimationSequence()
1532 return (char*)mySequence.latin1();
1535 //------------------------------------------------------------------------
1536 CORBA::Boolean VISU_TimeAnimation::isSequenceDefined()
1538 return !mySequence.isEmpty();
1541 //------------------------------------------------------------------------
1542 bool VISU_TimeAnimation::getIndicesFromSequence( QString theSequence, QValueList<long>& theIndices )
1544 bool isCorrect = true;
1548 QStringList aList = QStringList::split( ",", theSequence );
1549 QStringList::iterator it = aList.begin();
1550 QStringList::iterator itEnd = aList.end();
1551 for( ; it != itEnd; ++it )
1558 QString aString = *it;
1559 if( aString.isEmpty() )
1563 int aSingleIndex = aString.toLong( &ok );
1566 theIndices.append( aSingleIndex );
1569 else if( aString.contains( '-' ) == 1 )
1571 QString aLeftIndexStr = aString.section( '-', 0, 0 );
1572 QString aRightIndexStr = aString.section( '-', -1 );
1575 int aLeftIndex = aLeftIndexStr.toLong( &ok );
1580 int aRightIndex = aRightIndexStr.toLong( &ok );
1584 if( aLeftIndex >= aRightIndex )
1587 for( int i = aLeftIndex; i <= aRightIndex; i++ )
1588 theIndices.append( i );
1597 //------------------------------------------------------------------------
1598 std::string VISU_TimeAnimation::setDumpFormat(const char* theFormat)
1600 myDumpFormat = theFormat;
1601 QStrList aDumpFormats = QImageIO::outputFormats();
1602 if (myDumpFormat.isEmpty() ||
1603 (aDumpFormats.find(theFormat) < 0 && myDumpFormat.compare("AVI") != 0)) {
1604 if (aDumpFormats.find("JPEG"))
1605 myDumpFormat = "JPEG";
1607 myDumpFormat = aDumpFormats.at(0);
1609 return myDumpFormat.latin1();
1612 //------------------------------------------------------------------------
1613 bool VISU_TimeAnimation::checkAVIMaker() const
1615 QStrList aDumpFormats = QImageIO::outputFormats();
1616 if (aDumpFormats.find("JPEG") < 0) return false;
1618 QString aCmd("which ");
1620 aCmd += " >& /dev/null";
1621 int iErr = system(aCmd.latin1());
1625 //************************************************************************
1626 int VISU_TimeAnimation::myNBAnimations = 0;
1627 QString VISU_TimeAnimation::GenerateName()
1629 return VISU::GenerateName("Animation", myNBAnimations++);
1632 //------------------------------------------------------------------------
1633 std::string GetPresentationComment (VISU::VISUType thePrsType)
1635 std::string aPrsCmt;
1636 switch (thePrsType) {
1637 case VISU::TSCALARMAP:
1638 aPrsCmt = VISU::ScalarMap_i::myComment;
1640 case VISU::TISOSURFACES:
1641 aPrsCmt = VISU::IsoSurfaces_i::myComment;
1643 case VISU::TCUTPLANES:
1644 aPrsCmt = VISU::CutPlanes_i::myComment;
1646 case VISU::TCUTLINES:
1647 aPrsCmt = VISU::CutLines_i::myComment;
1650 aPrsCmt = VISU::Plot3D_i::myComment;
1652 case VISU::TDEFORMEDSHAPE:
1653 aPrsCmt = VISU::DeformedShape_i::myComment;
1655 case VISU::TVECTORS:
1656 aPrsCmt = VISU::Vectors_i::myComment;
1658 case VISU::TSTREAMLINES:
1659 aPrsCmt = VISU::StreamLines_i::myComment;
1661 case VISU::TGAUSSPOINTS:
1662 aPrsCmt = VISU::GaussPoints_i::myComment;
1664 case VISU::TSCALARMAPONDEFORMEDSHAPE:
1665 aPrsCmt = VISU::ScalarMapOnDeformedShape_i::myComment;
1668 aPrsCmt = "Unknown presentation";
1674 //------------------------------------------------------------------------
1675 SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
1677 if (myStudy->GetProperties()->IsLocked())
1678 return SALOMEDS::SObject::_nil();
1680 _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
1681 aStudyBuilder->NewCommand(); // There is a transaction
1682 _PTR(SComponent) aSComponent = VISU::ClientFindOrCreateVisuComponent(myStudy);
1683 std::string aSComponentEntry = aSComponent->GetID();
1686 aComment.sprintf("myComment=ANIMATION;myTimeMinVal=%g;myTimeMaxVal=%g;mySequence=%s;myMode=%d",
1689 mySequence.latin1(),
1692 string anEntry = VISU::CreateAttributes(myStudy,
1693 aSComponentEntry.c_str(),
1697 VISU::NO_PERFSITENT_REF,
1700 myAnimEntry = anEntry.c_str();
1701 _PTR(SObject) aAnimSObject = myStudy->FindObjectID(anEntry.c_str());
1703 for (int i = 0; i < getNbFields(); i++) {
1704 FieldData& aData = myFieldsLst[i];
1705 if (aData.myPrs.empty()) {
1706 generatePresentations(i);
1708 if ( !aData.myPrs.empty() ) {
1709 _PTR(SObject) newObj = aStudyBuilder->NewObject(aAnimSObject);
1710 aStudyBuilder->Addreference(newObj, aData.myField);
1712 ostringstream strOut;
1713 aData.myPrs[0]->ToStream(strOut);
1714 string aPrsComment = strOut.str();
1715 string aPrsMyComment = aData.myPrs[0]->GetComment();
1716 if(aPrsMyComment == "PRSMERGER")
1717 aPrsMyComment = "SCALARMAP";
1718 VISU::CreateAttributes(myStudy,
1719 newObj->GetID().c_str(),
1722 aPrsMyComment.c_str(),
1723 VISU::NO_PERFSITENT_REF,
1724 aPrsComment.c_str(),
1728 aStudyBuilder->CommitCommand();
1730 return VISU::GetSObject(aAnimSObject);
1733 //------------------------------------------------------------------------
1734 void VISU_TimeAnimation::saveAnimation()
1736 if (myStudy->GetProperties()->IsLocked()) return;
1737 if (myAnimEntry.isEmpty()) return;
1739 _PTR(SObject) aAnimSObject = myStudy->FindObjectID(myAnimEntry.latin1());
1740 if (!aAnimSObject) return;
1742 _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
1743 aStudyBuilder->NewCommand(); // There is a transaction
1744 _PTR(SComponent) aSComponent = VISU::ClientFindOrCreateVisuComponent(myStudy);
1745 std::string aSComponentEntry = aSComponent->GetID();
1748 aComment.sprintf("myComment=ANIMATION;myTimeMinVal=%g;myTimeMaxVal=%g;mySequence=%s;myMode=%d",
1751 mySequence.latin1(),
1754 _PTR(GenericAttribute) anAttr;
1755 anAttr = aStudyBuilder->FindOrCreateAttribute(aAnimSObject, "AttributeString");
1756 _PTR(AttributeString) aCmnt (anAttr);
1757 aCmnt->SetValue(aComment.latin1());
1759 _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
1760 int i = 0, nbf = getNbFields();
1761 for (anIter->Init(); anIter->More(); anIter->Next(), i++) {
1762 if (i >= nbf) break; // it must not be
1763 FieldData& aData = myFieldsLst[i];
1765 // Get presentation name and comment
1766 if (aData.myPrs.empty()) {
1767 generatePresentations(i);
1769 ostringstream strOut;
1770 aData.myPrs[0]->ToStream(strOut);
1771 string aPrsComment = strOut.str();
1772 string aPrsNameTxt = aData.myPrs[0]->GetComment();
1773 if(aPrsNameTxt == "PRSMERGER")
1774 aPrsNameTxt = "SCALARMAP";
1776 _PTR(SObject) aRefObj = anIter->Value();
1777 _PTR(ChildIterator) anPrsIter = myStudy->NewChildIterator(aRefObj);
1780 if (anPrsIter->More()) {
1781 _PTR(SObject) aPrsObj = anPrsIter->Value();
1782 anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeString");
1783 aCmnt = _PTR(AttributeString)(anAttr);
1784 aCmnt->SetValue(aPrsComment.c_str());
1786 anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeName");
1787 _PTR(AttributeName) aPrsName (anAttr);
1788 aPrsName->SetValue(aPrsNameTxt);
1791 VISU::CreateAttributes(myStudy,
1792 aRefObj->GetID().c_str(),
1795 aPrsNameTxt.c_str(),
1796 VISU::NO_PERFSITENT_REF,
1797 aPrsComment.c_str(),
1801 aStudyBuilder->CommitCommand();
1804 //------------------------------------------------------------------------
1805 void VISU_TimeAnimation::restoreFromStudy(SALOMEDS::SObject_ptr theField)
1807 _PTR(SObject) aAnimSObject = VISU::GetClientSObject(theField, myStudy);
1808 restoreFromStudy(aAnimSObject);
1811 void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
1813 _PTR(SObject) aAnimSObject = theField;
1815 VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aAnimSObject);
1820 myTimeMinVal = VISU::Storable::FindValue(aMap,"myTimeMinVal",&isExist).toDouble();
1821 myTimeMaxVal = VISU::Storable::FindValue(aMap,"myTimeMaxVal",&isExist).toDouble();
1822 mySequence = VISU::Storable::FindValue(aMap,"mySequence",&isExist);
1823 myAnimationMode = VISU::Animation::AnimationMode(VISU::Storable::FindValue(aMap,"myMode",&isExist).toInt());
1825 _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
1826 for (anIter->Init(); anIter->More(); anIter->Next()) {
1827 _PTR(SObject) aRefObj = anIter->Value();
1828 _PTR(SObject) aFieldObj;
1829 if (!aRefObj->ReferencedObject(aFieldObj) )
1832 addField(aFieldObj);
1833 if ( isRangeDefined() || isSequenceDefined() )
1834 myFieldsAbsFrames.pop_back();
1836 FieldData& aData = getFieldData(getNbFields()-1);
1838 // Get Presentation object
1839 _PTR(ChildIterator) anPrsIter = myStudy->NewChildIterator(aRefObj);
1841 if (!anPrsIter->More())
1843 _PTR(SObject) aPrsObj = anPrsIter->Value();
1844 _PTR(GenericAttribute) anAttr;
1845 if (!aPrsObj->FindAttribute(anAttr, "AttributeName"))
1847 _PTR(AttributeName) aName (anAttr);
1848 string aStr = aName->Value();
1849 QString strName (aStr.c_str());
1851 if (strName == VISU::ScalarMap_i::myComment.c_str())
1852 aData.myPrsType = VISU::TSCALARMAP;
1853 else if (strName == VISU::IsoSurfaces_i::myComment.c_str())
1854 aData.myPrsType = VISU::TISOSURFACES;
1855 else if (strName == VISU::CutPlanes_i::myComment.c_str())
1856 aData.myPrsType = VISU::TCUTPLANES;
1857 else if (strName == VISU::CutLines_i::myComment.c_str())
1858 aData.myPrsType = VISU::TCUTLINES;
1859 else if (strName == VISU::Plot3D_i::myComment.c_str())
1860 aData.myPrsType = VISU::TPLOT3D;
1861 else if (strName == VISU::DeformedShape_i::myComment.c_str())
1862 aData.myPrsType = VISU::TDEFORMEDSHAPE;
1863 else if (strName == VISU::Vectors_i::myComment.c_str())
1864 aData.myPrsType = VISU::TVECTORS;
1865 else if (strName == VISU::StreamLines_i::myComment.c_str())
1866 aData.myPrsType = VISU::TSTREAMLINES;
1867 else if (strName == VISU::GaussPoints_i::myComment.c_str())
1868 aData.myPrsType = VISU::TGAUSSPOINTS;
1869 else if (strName == VISU::ScalarMapOnDeformedShape_i::myComment.c_str())
1870 aData.myPrsType = VISU::TSCALARMAPONDEFORMEDSHAPE;
1873 generatePresentations(getNbFields()-1);
1875 VISU::Storable::TRestoringMap aPrsMap = VISU::Storable::GetStorableMap(aPrsObj);
1876 if (aPrsMap.empty())
1878 if (aData.myPrs[0]) {
1879 aData.myPrs[0]->Restore(VISU::GetSObject(aData.myField), aPrsMap);
1880 aData.myPrs[0]->GetOffset(aData.myOffset);
1882 for (int i = 1; i < aData.myNbFrames; i++) {
1883 if (!aData.myPrs[0])
1885 bool anIsFixedRange = false;
1886 if (aData.myPrsType != VISU::TGAUSSPOINTS) {
1887 if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
1888 anIsFixedRange = aPrs->IsRangeFixed();
1890 aData.myPrs[i]->SameAs(aData.myPrs[0]);
1893 string aStr = aAnimSObject->GetID();
1894 myAnimEntry = aStr.c_str();
1897 void VISU_TimeAnimation::onViewDeleted()
1902 void VISU_TimeAnimation::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs)
1903 throw (SALOME::SALOME_Exception)
1905 Unexpect aCatch(SALOME_SalomeException);
1907 VISU::ColoredPrs3d_i* aPrs_i = dynamic_cast<VISU::ColoredPrs3d_i*>(GetServant(thePrs).in());
1910 THROW_SALOME_CORBA_EXCEPTION("Error : invalid dynamic cast of the given presentation to VISU::ColoredPrs3d_i",
1911 SALOME::INTERNAL_ERROR);
1913 if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1914 FieldData& aData = myFieldsLst[theFieldNum];
1916 if ( aData.myPrs.empty() )
1917 THROW_SALOME_CORBA_EXCEPTION("Error : presentations for the given field is not yet created!",
1918 SALOME::INTERNAL_ERROR);
1920 if ( aPrs_i->GetCResult() != aData.myPrs[0]->GetCResult() )
1921 THROW_SALOME_CORBA_EXCEPTION("Error : the MED file is not the same!",
1922 SALOME::INTERNAL_ERROR);
1924 for (int i = 0; i < aData.myNbFrames; i++) {
1925 bool anIsFixedRange = false;
1926 if (aData.myPrsType != VISU::TGAUSSPOINTS) {
1927 if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
1928 anIsFixedRange = aPrs->IsRangeFixed();
1930 aData.myPrs[i]->SameAs(aPrs_i);
1933 else if ( myAnimationMode == VISU::Animation::SUCCESSIVE ) { // successive animation mode
1934 for (int f = 0; f < getNbFields(); f++) {
1935 FieldData& aData = myFieldsLst[f];
1937 if ( aData.myPrs.empty() )
1938 THROW_SALOME_CORBA_EXCEPTION("Error : presentations for the given field is not yet created!",
1939 SALOME::INTERNAL_ERROR);
1941 for (int i = 0; i < aData.myNbFrames; i++) {
1942 aData.myPrs[i]->SameAs(aPrs_i);
1948 //========================================================================
1949 //========================================================================
1950 //========================================================================
1951 struct TNewAnimationEvent: public SALOME_Event
1953 std::string myStudyName;
1954 VISU::View3D_ptr myView3D;
1956 typedef VISU_TimeAnimation* TResult;
1959 TNewAnimationEvent (std::string theStudyName, VISU::View3D_ptr theView3D):
1960 myStudyName(theStudyName),
1961 myView3D(VISU::View3D::_duplicate(theView3D)),
1969 SUIT_Session* aSession = SUIT_Session::session();
1970 QPtrList<SUIT_Application> anApplications = aSession->applications();
1971 QPtrListIterator<SUIT_Application> anIter (anApplications);
1972 while (SUIT_Application* anApp = anIter.current()) {
1974 if (SUIT_Study* aSStudy = anApp->activeStudy()) {
1975 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1976 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
1977 if (myStudyName == aCStudy->Name()) {
1978 myResult = new VISU_TimeAnimation (aCStudy, myView3D);
1988 VISU_TimeAnimation_i::VISU_TimeAnimation_i (SALOMEDS::Study_ptr theStudy,
1989 VISU::View3D_ptr theView3D)
1991 std::string aStudyName = theStudy->Name();
1992 myAnim = ProcessEvent(new TNewAnimationEvent (aStudyName, theView3D));
1995 VISU_TimeAnimation_i::~VISU_TimeAnimation_i()
2000 bool VISU_TimeAnimation_i::addField (SALOMEDS::SObject_ptr theField)
2002 return myAnim->addField(theField);
2005 void VISU_TimeAnimation_i::clearFields ()
2007 for (int i = 0; i < myAnim->getNbFields(); i++) {
2008 myAnim->clearData(myAnim->getFieldData(i));
2010 myAnim->clearFieldData();
2013 CORBA::Boolean VISU_TimeAnimation_i::generateFrames()
2015 //return ProcessEvent(new TMemFunEvent<VISU_TimeAnimation,bool>
2016 // (myAnim,&VISU_TimeAnimation::generateFrames));
2017 return myAnim->generateFrames();
2020 void VISU_TimeAnimation_i::generatePresentations (CORBA::Long theFieldNum)
2022 myAnim->generatePresentations(theFieldNum);
2025 void VISU_TimeAnimation_i::clearView()
2027 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2028 // (myAnim,&VISU_TimeAnimation::clearView));
2029 myAnim->clearView();
2032 void VISU_TimeAnimation_i::stopAnimation()
2034 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2035 // (myAnim,&VISU_TimeAnimation::stopAnimation));
2036 myAnim->stopAnimation();
2039 void VISU_TimeAnimation_i::startAnimation()
2041 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2042 // (myAnim,&VISU_TimeAnimation::startAnimation));
2043 myAnim->startAnimation();
2046 void VISU_TimeAnimation_i::nextFrame()
2048 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2049 // (myAnim,&VISU_TimeAnimation::nextFrame));
2050 myAnim->nextFrame();
2053 void VISU_TimeAnimation_i::prevFrame()
2055 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2056 // (myAnim,&VISU_TimeAnimation::prevFrame));
2057 myAnim->prevFrame();
2060 void VISU_TimeAnimation_i::firstFrame()
2062 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2063 // (myAnim,&VISU_TimeAnimation::firstFrame));
2064 myAnim->firstFrame();
2067 void VISU_TimeAnimation_i::lastFrame()
2069 //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2070 // (myAnim,&VISU_TimeAnimation::lastFrame));
2071 myAnim->lastFrame();
2074 void VISU_TimeAnimation_i::gotoFrame(CORBA::Long theFrame)
2076 //ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,CORBA::Long>
2077 // (myAnim,&VISU_TimeAnimation::gotoFrame,theFrame));
2078 myAnim->gotoFrame(theFrame);
2081 CORBA::Long VISU_TimeAnimation_i::getNbFields()
2083 return myAnim->getNbFields();
2086 CORBA::Long VISU_TimeAnimation_i::getNbFrames()
2088 return myAnim->getNbFrames();
2091 CORBA::Boolean VISU_TimeAnimation_i::isRunning()
2093 return myAnim->isRunning();
2096 CORBA::Long VISU_TimeAnimation_i::getCurrentFrame()
2098 return myAnim->getCurrentFrame();
2101 VISU::ColoredPrs3d_ptr VISU_TimeAnimation_i::getPresentation
2102 (CORBA::Long theField, CORBA::Long theFrame)
2104 return myAnim->getPresentation(theField,theFrame);
2107 void VISU_TimeAnimation_i::setPresentationType (CORBA::Long theFieldNum,
2108 VISU::VISUType theType)
2110 myAnim->setPresentationType(theFieldNum,theType);
2113 VISU::VISUType VISU_TimeAnimation_i::getPresentationType (CORBA::Long theFieldNum)
2115 return myAnim->getPresentationType(theFieldNum);
2118 void VISU_TimeAnimation_i::setSpeed(CORBA::Long theSpeed)
2120 myAnim->setSpeed(theSpeed);
2123 CORBA::Long VISU_TimeAnimation_i::getSpeed()
2125 return myAnim->getSpeed();
2128 CORBA::Boolean VISU_TimeAnimation_i::isProportional()
2130 return myAnim->isProportional();
2133 void VISU_TimeAnimation_i::setAnimationRange (CORBA::Double theMin,
2134 CORBA::Double theMax)
2136 myAnim->setAnimationRange(theMin,theMax);
2139 CORBA::Double VISU_TimeAnimation_i::getMinRange()
2141 return myAnim->getMinRange();
2144 CORBA::Double VISU_TimeAnimation_i::getMaxRange()
2146 return myAnim->getMaxRange();
2149 CORBA::Boolean VISU_TimeAnimation_i::isRangeDefined()
2151 return myAnim->isRangeDefined();
2154 void VISU_TimeAnimation_i::setAnimationSequence (const char* theSequence)
2156 myAnim->setAnimationSequence(theSequence);
2159 char* VISU_TimeAnimation_i::getAnimationSequence()
2161 return myAnim->getAnimationSequence();
2164 CORBA::Boolean VISU_TimeAnimation_i::isSequenceDefined()
2166 return myAnim->isSequenceDefined();
2169 void VISU_TimeAnimation_i::dumpTo (const char* thePath)
2171 myAnim->dumpTo(thePath);
2174 char* VISU_TimeAnimation_i::setDumpFormat (const char* theFormat)
2176 string aDumpFormat = myAnim->setDumpFormat(theFormat);
2177 return CORBA::string_dup(aDumpFormat.c_str());
2180 CORBA::Boolean VISU_TimeAnimation_i::isCycling()
2182 return myAnim->isCycling();
2185 CORBA::Boolean VISU_TimeAnimation_i::isCleaningMemoryAtEachFrame(){
2186 return myAnim->isCleaningMemoryAtEachFrame();
2189 CORBA::Double VISU_TimeAnimation_i::getMinTime()
2191 return myAnim->getMinTime();
2194 CORBA::Double VISU_TimeAnimation_i::getMaxTime()
2196 return myAnim->getMaxTime();
2199 void VISU_TimeAnimation_i::setProportional (CORBA::Boolean theProp)
2201 myAnim->setProportional(theProp);
2204 void VISU_TimeAnimation_i::setCycling (CORBA::Boolean theCycle)
2206 myAnim->setCycling(theCycle);
2209 void VISU_TimeAnimation_i::setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle){
2210 myAnim->setCleaningMemoryAtEachFrame(theCycle);
2213 SALOMEDS::SObject_ptr VISU_TimeAnimation_i::publishInStudy()
2215 return myAnim->publishInStudy();
2218 void VISU_TimeAnimation_i::restoreFromStudy(SALOMEDS::SObject_ptr theObj)
2220 myAnim->restoreFromStudy(theObj);
2223 CORBA::Boolean VISU_TimeAnimation_i::isSavedInStudy()
2225 return myAnim->isSavedInStudy();
2228 void VISU_TimeAnimation_i::saveAnimation()
2230 myAnim->saveAnimation();
2233 void VISU_TimeAnimation_i::setAnimationMode(VISU::Animation::AnimationMode theMode)
2235 myAnim->setAnimationMode(theMode);
2238 VISU::Animation::AnimationMode VISU_TimeAnimation_i::getAnimationMode()
2240 return VISU::Animation::AnimationMode(myAnim->getAnimationMode());
2243 void VISU_TimeAnimation_i::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs)
2244 throw (SALOME::SALOME_Exception)
2246 myAnim->ApplyProperties(theFieldNum, thePrs);