From 8dad8bc6399f45b5fdd61980d5804711affb2273 Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 2 Dec 2005 15:29:28 +0000 Subject: [PATCH] To extend time animation on Gauss Points presentation --- idl/VISU_Gen.idl | 20 +- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 185 +++++++++-------- src/VISUGUI/VisuGUI_TimeAnimation.h | 3 + src/VISU_I/VISU_ColoredPrs3d_i.cc | 14 ++ src/VISU_I/VISU_ColoredPrs3d_i.hh | 10 +- src/VISU_I/VISU_ScalarMap_i.cc | 14 -- src/VISU_I/VISU_ScalarMap_i.hh | 8 - src/VISU_I/VISU_TimeAnimation.cxx | 288 ++++++++++++-------------- src/VISU_I/VISU_TimeAnimation.h | 8 +- 9 files changed, 268 insertions(+), 282 deletions(-) diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 4b748780..0ee7fe63 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -385,6 +385,16 @@ module VISU { */ long GetScalarMode(); + /*! + * Gets the min boundary of the scalar bar. + */ + double GetMin(); + + /*! + * Gets the max boundary of the scalar bar. + */ + double GetMax(); + /*! \brief Position of the scalar bar. * * Sets the position of the scalar bar origin on the screen. @@ -491,16 +501,6 @@ module VISU { */ void SetRange(in double theMin, in double theMax); - /*! - * Gets the min boundary of the scalar bar. - */ - double GetMin(); - - /*! - * Gets the max boundary of the scalar bar. - */ - double GetMax(); - /*! %Orientation of the scalar bar (to provide backward compatibility). */ enum Orientation { HORIZONTAL, /*!< Horizontal orientation of the scalar bar.*/ diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 8ff2718a..4c848645 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -18,6 +18,7 @@ #include "VisuGUI_VectorsDlg.h" #include "VisuGUI_IsoSurfacesDlg.h" #include "VisuGUI_StreamLinesDlg.h" +#include "VisuGUI_GaussPointsDlg.h" #include "VISU_TimeAnimation.h" @@ -29,6 +30,7 @@ #include "VISU_CutLines_i.hh" #include "VISU_Vectors_i.hh" #include "VISU_StreamLines_i.hh" +#include "VISU_GaussPoints_i.hh" #include "VISU_ViewManager_i.hh" @@ -430,9 +432,9 @@ void ArrangeDlg::acceptViewWindow() } -//***************************************************************************************************** -//***************************************************************************************************** -//***************************************************************************************************** +//------------------------------------------------------------------------ +//------------------------------------------------------------------------ +//------------------------------------------------------------------------ SetupDlg::SetupDlg (VisuGUI* theModule, VISU_TimeAnimation* theAnimator) : QDialog(VISU::GetDesktop(theModule), "SetupDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), @@ -547,7 +549,7 @@ SetupDlg::SetupDlg (VisuGUI* theModule, VISU_TimeAnimation* theAnimator) aMainLayout->addWidget(aBtnBox); } -//************************************************************************ +//------------------------------------------------------------------------ enum PrsComboItem { TSCALARMAP_ITEM = 0, // VISU::TSCALARMAP TISOSURFACE_ITEM = 1, // VISU::TISOSURFACE @@ -555,27 +557,49 @@ enum PrsComboItem { TPLOT3D_ITEM = 3, // VISU::TPLOT3D TDEFORMEDSHAPE_ITEM = 4, // VISU::TDEFORMEDSHAPE TVECTORS_ITEM = 5, // VISU::TVECTORS - TSTREAMLINES_ITEM = 6 // VISU::TSTREAMLINES + TSTREAMLINES_ITEM = 6, // VISU::TSTREAMLINES + TGAUSSPOINTS_ITEM = 7 // VISU::TGAUSSPOINTS }; -//************************************************************************ +//------------------------------------------------------------------------ void SetupDlg::onFieldChange (int theIndex) { FieldData& aData = myAnimator->getFieldData(theIndex); myTypeCombo->clear(); + myComboId2TypeId.clear(); + // ATTENTION: append items in the same order like it is done in the PrsComboItem enumeration myTypeCombo->insertItem("Scalar Map"); // item 0 + myComboId2TypeId.push_back(TSCALARMAP_ITEM);; + myTypeCombo->insertItem("Iso Surfaces"); // item 1 + myComboId2TypeId.push_back(TISOSURFACE_ITEM);; + myTypeCombo->insertItem("Cut Planes"); // item 2 + myComboId2TypeId.push_back(TCUTPLANES_ITEM);; + myTypeCombo->insertItem("Plot 3D"); // item 3 + myComboId2TypeId.push_back(TPLOT3D_ITEM);; _PTR(SObject) aSObject = aData.myField; long aNumComp = VISU::getValue(aSObject, "myNumComponent").toLong(); if (aNumComp > 1) { myTypeCombo->insertItem("Deformed Shape"); // item 4 + myComboId2TypeId.push_back(TDEFORMEDSHAPE_ITEM);; + myTypeCombo->insertItem("Vectors"); // item 5 + myComboId2TypeId.push_back(TVECTORS_ITEM);; + myTypeCombo->insertItem("Stream Lines"); // item 6 + myComboId2TypeId.push_back(TSTREAMLINES_ITEM);; + } + + long anEntityId = VISU::getValue(aSObject, "myEntityId").toLong(); + if(anEntityId == VISU::CELL){ + myTypeCombo->insertItem("Gauss Points"); // item 7 + myComboId2TypeId.push_back(TGAUSSPOINTS_ITEM);; } + switch (aData.myPrsType) { case VISU::TSCALARMAP: //Scalar Map myTypeCombo->setCurrentItem(TSCALARMAP_ITEM); @@ -599,15 +623,20 @@ void SetupDlg::onFieldChange (int theIndex) myTypeCombo->setCurrentItem(TSTREAMLINES_ITEM); aData.myPrsType = VISU::TSTREAMLINES; break; + case VISU::TGAUSSPOINTS: //Gauss Points + myTypeCombo->setCurrentItem(TGAUSSPOINTS_ITEM); + aData.myPrsType = VISU::TGAUSSPOINTS; + break; } //myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP); } -//************************************************************************ +//------------------------------------------------------------------------ void SetupDlg::onTypeChanged (int theIndex) { FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem()); - switch (theIndex) { + int aType = myComboId2TypeId[theIndex]; + switch (aType) { case TSCALARMAP_ITEM: //Scalar Map aData.myPrsType = VISU::TSCALARMAP; break; @@ -629,30 +658,33 @@ void SetupDlg::onTypeChanged (int theIndex) case TSTREAMLINES_ITEM: //Stream Lines aData.myPrsType = VISU::TSTREAMLINES; break; + case TGAUSSPOINTS_ITEM: //Gauss Points + aData.myPrsType = VISU::TGAUSSPOINTS; + break; } myAnimator->clearData(aData); //myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP); //myAnimator->generatePresentations(myFieldLst->currentItem()); } -//************************************************************************ -/*void SetupDlg::onScalarBarDlg() { - QApplication::setOverrideCursor( Qt::waitCursor ); - FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem()); - if (aData.myPrs == 0) - myAnimator->generatePresentations(myFieldLst->currentItem()); - QApplication::restoreOverrideCursor(); - VisuGUI_ScalarBarDlg* aScalarBarDlg = new VisuGUI_ScalarBarDlg(); - aScalarBarDlg->initFromPrsObject(aData.myPrs[0]); - if (aScalarBarDlg->exec()) { - for (int i = 0; i < aData.myNbFrames; i++) - aScalarBarDlg->storeToPrsObject(aData.myPrs[i]); +//------------------------------------------------------------------------ +namespace +{ + template + void + EditPrs(VisuGUI* theModule, + FieldData& theData) + { + TDialog* aDlg = new TDialog(theModule); + aDlg->initFromPrsObject(dynamic_cast(theData.myPrs[0])); + if (aDlg->exec()) + for (int i = 0; i < theData.myNbFrames; i++) + aDlg->storeToPrsObject(dynamic_cast(theData.myPrs[i])); + delete aDlg; } } -*/ - -//************************************************************************ + void SetupDlg::onPreferencesDlg() { SUIT_OverrideCursor c; @@ -660,83 +692,52 @@ void SetupDlg::onPreferencesDlg() if (aData.myPrs.empty()) myAnimator->generatePresentations(myFieldLst->currentItem()); -// BUG VISU5725 : Compatibility gcc 2.95 -// #define EDITPRS(TYPE, DLG) \ -// { \ -// DLG* aDlg = new DLG(); \ -// aDlg->initFromPrsObject(dynamic_cast(aData.myPrs.at(0))); \ -// if (aDlg->exec()) { \ -// for (int i = 0; i < aData.myNbFrames; i++) \ -// aDlg->storeToPrsObject(dynamic_cast(aData.myPrs.at(i))); \ -// } \ -// delete aDlg; \ -// } - - -#define EDITPRS(TYPE, DLG) {\ - DLG* aDlg = new DLG (myModule);\ - aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0]));\ - if (aDlg->exec())\ - { \ - for (int i = 0; i < aData.myNbFrames; i++)\ - aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i]));\ - } \ - delete aDlg;} - - switch (myTypeCombo->currentItem()) { + int aType = myComboId2TypeId[myTypeCombo->currentItem()]; + switch (aType) { case TSCALARMAP_ITEM: //Scalar Map c.suspend(); - EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg); + EditPrs(myModule,aData); break; case TISOSURFACE_ITEM: //Iso Surfaces c.suspend(); - EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg); + EditPrs(myModule,aData); break; case TCUTPLANES_ITEM: //Cut Planes c.suspend(); - EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg); - /*{ - VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg (myModule); - //_CS_PhB :operator [] .at aDlg->initFromPrsObject(dynamic_cast(aData.myPrs.at(0))); - aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); - - if (aDlg->exec()) { - for (int i = 0; i < aData.myNbFrames; i++) - //_CS_PhB:operator [] .at aDlg->storeToPrsObject(dynamic_cast(aData.myPrs.at(i))); - aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); - } - delete aDlg; - }*/ + EditPrs(myModule,aData); break; case TPLOT3D_ITEM: //Plot 3D c.suspend(); - EDITPRS(VISU::Plot3D_i, VisuGUI_Plot3DDlg); + EditPrs(myModule,aData); break; case TDEFORMEDSHAPE_ITEM: //Deformed Shape c.suspend(); - EDITPRS(VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg); + EditPrs(myModule,aData); break; case TVECTORS_ITEM: //Vectors c.suspend(); - EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg); + EditPrs(myModule,aData); break; case TSTREAMLINES_ITEM: //Stream Lines c.suspend(); - EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg); + EditPrs(myModule,aData); + break; + case TGAUSSPOINTS_ITEM: //Gauss Points + c.suspend(); + EditPrs(myModule,aData); break; } -#undef EDITPRS } -//************************************************************************ +//------------------------------------------------------------------------ void SetupDlg::onArrangeDlg() { ArrangeDlg aDlg(this, myAnimator); aDlg.exec(); } -//************************************************************************ +//------------------------------------------------------------------------ void SetupDlg::onRangeCheck (bool theCheck) { for (int i = 0; i < myAnimator->getNbFields(); i++) @@ -757,7 +758,7 @@ void SetupDlg::onRangeCheck (bool theCheck) } } -//************************************************************************ +//------------------------------------------------------------------------ void SetupDlg::onMinValue (double theVal) { if (theVal > myAnimator->getMaxRange()) { @@ -770,7 +771,7 @@ void SetupDlg::onMinValue (double theVal) myAnimator->setAnimationRange(theVal, myAnimator->getMaxRange()); } -//************************************************************************ +//------------------------------------------------------------------------ void SetupDlg::onMaxValue (double theVal) { if (theVal < myAnimator->getMinRange()) { @@ -1064,13 +1065,13 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Stu myPlayFrame->setEnabled(false); } -//************************************************************************ +//------------------------------------------------------------------------ VisuGUI_TimeAnimationDlg::~VisuGUI_TimeAnimationDlg() { delete myAnimator; } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onTypeChange (int index) { stopAnimation(); @@ -1080,14 +1081,14 @@ void VisuGUI_TimeAnimationDlg::onTypeChange (int index) myPlayFrame->setEnabled(false); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::addField (_PTR(SObject) theSObject) { myPlayFrame->setEnabled(false); myAnimator->addField(theSObject); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::createFrames() { stopAnimation(); @@ -1120,7 +1121,7 @@ void VisuGUI_TimeAnimationDlg::createFrames() //myPlayFrame->setEnabled(true); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onPlayPressed() { if (myPlayBtn->isOn() && (!myAnimator->running())) { @@ -1140,38 +1141,38 @@ void VisuGUI_TimeAnimationDlg::onPlayPressed() } } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onBackPressed() { //stopAnimation(); myAnimator->prevFrame(); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onForvardPressed() { myAnimator->nextFrame(); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onLastPressed() { myAnimator->lastFrame(); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onFirstPressed() { myAnimator->firstFrame(); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::clearView() { myAnimator->clearView(); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::closeEvent (QCloseEvent* theEvent) { myAnimator->stopAnimation(); @@ -1184,20 +1185,20 @@ void VisuGUI_TimeAnimationDlg::closeEvent (QCloseEvent* theEvent) } } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onWindowChanged (int index) { if (myAnimator->isRunning()) return; myAnimator->gotoFrame(index); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onSpeedChange (double theSpeed) { myAnimator->setSpeed((int)theSpeed); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::stopAnimation() { myAnimator->stopAnimation(); @@ -1207,14 +1208,14 @@ void VisuGUI_TimeAnimationDlg::stopAnimation() myGenBtn->setEnabled(true); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onExecution (long theNewFrame, double theTime) { myTimeLbl->setText(QString("%1").arg(theTime)); mySlider->setValue(theNewFrame); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onSetupDlg() { if (myAnimator->getNbFrames() > 0) myAnimator->firstFrame(); @@ -1224,7 +1225,7 @@ void VisuGUI_TimeAnimationDlg::onSetupDlg() delete aDlg; } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onBrowse() { QString aPath = SUIT_FileDlg::getExistingDirectory(this, "/","Select path"); @@ -1232,7 +1233,7 @@ void VisuGUI_TimeAnimationDlg::onBrowse() myPathEdit->setText(aPath); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onStop() { if (isClosing) { @@ -1245,14 +1246,14 @@ void VisuGUI_TimeAnimationDlg::onStop() } } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::saveToStudy() { myAnimator->saveAnimation(); VISU::UpdateObjBrowser(myModule, true); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::publishToStudy() { myAnimator->publishInStudy(); @@ -1260,7 +1261,7 @@ void VisuGUI_TimeAnimationDlg::publishToStudy() mySaveBtn->setEnabled(myAnimator->isSavedInStudy()); } -//************************************************************************ +//------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::restoreFromStudy(_PTR(SObject) theAnimation) { myAnimator->restoreFromStudy(theAnimation); diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.h b/src/VISUGUI/VisuGUI_TimeAnimation.h index f9fd9743..eba6c928 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.h +++ b/src/VISUGUI/VisuGUI_TimeAnimation.h @@ -106,8 +106,11 @@ class SetupDlg: public QDialog { private: VisuGUI* myModule; VISU_TimeAnimation* myAnimator; + QListBox* myFieldLst; QComboBox* myTypeCombo; + std::vector myComboId2TypeId; + QPushButton* myPropBtn; QPushButton* myArrangeBtn; QCheckBox* myUseRangeChk; diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index a47ea458..8ae44caf 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -146,6 +146,20 @@ VISU::ColoredPrs3d_i myScalarMapPL->SetScalarMode(theScalarMode); } +CORBA::Double +VISU::ColoredPrs3d_i +::GetMin() +{ + return myScalarMapPL->GetScalarRange()[0]; +} + +CORBA::Double +VISU::ColoredPrs3d_i +::GetMax() +{ + return myScalarMapPL->GetScalarRange()[1]; +} + void VISU::ColoredPrs3d_i ::SetNbColors(CORBA::Long theNbColors) diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index cdbfaeb2..1e09eb7a 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -34,7 +34,7 @@ class VISU_ScalarMapPL; namespace VISU { //============================================================================ - class ColoredPrs3d_i : public virtual POA_VISU::ColoredPrd3d, + class ColoredPrs3d_i : public virtual POA_VISU::ColoredPrs3d, public virtual Prs3d_i { ColoredPrs3d_i(); @@ -66,6 +66,14 @@ namespace VISU void SetScalarMode(CORBA::Long theScalarMode); + virtual + CORBA::Double + GetMin(); + + virtual + CORBA::Double + GetMax(); + virtual void SetNbColors(CORBA::Long theNbColors); diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index da9ea777..39d883fc 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -243,20 +243,6 @@ VISU::ScalarMap_i myIsFixedRange = true; } -CORBA::Double -VISU::ScalarMap_i -::GetMin() -{ - return myScalarMapPL->GetScalarRange()[0]; -} - -CORBA::Double -VISU::ScalarMap_i -::GetMax() -{ - return myScalarMapPL->GetScalarRange()[1]; -} - //---------------------------------------------------------------------------- void diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index acdf7af3..9e2e0b0d 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -72,14 +72,6 @@ namespace VISU void SetRange(CORBA::Double theMin, CORBA::Double theMax); - virtual - CORBA::Double - GetMin(); - - virtual - CORBA::Double - GetMax(); - // To provide backward compatibility virtual void diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index f70ad911..ff41a959 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -21,6 +21,7 @@ #include "VISU_CutLines_i.hh" #include "VISU_Vectors_i.hh" #include "VISU_StreamLines_i.hh" +#include "VISU_GaussPoints_i.hh" #include "VISU_ViewManager_i.hh" #include "VISU_View_i.hh" @@ -46,7 +47,7 @@ using namespace std; -//************************************************************************ +//------------------------------------------------------------------------ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy, VISU::View3D_ptr theView3D) { @@ -74,7 +75,7 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy, } -//************************************************************************ +//------------------------------------------------------------------------ VISU_TimeAnimation::~VISU_TimeAnimation() { if (!myView) { @@ -88,7 +89,7 @@ VISU_TimeAnimation::~VISU_TimeAnimation() } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::addField (_PTR(SObject) theField) { FieldData aNewData; @@ -111,7 +112,7 @@ void VISU_TimeAnimation::addField (_PTR(SObject) theField) } } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField) { SALOMEDS::SObject_var theFieldDup = SALOMEDS::SObject::_duplicate(theField); @@ -120,7 +121,7 @@ void VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField) } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::clearData(FieldData& theData) { if (!myView) { MESSAGE("Viewer is not defined for animation"); @@ -148,146 +149,122 @@ void VISU_TimeAnimation::clearData(FieldData& theData) { } -//************************************************************************ +namespace +{ + //------------------------------------------------------------------------ + template + void + GeneratePresentations(_PTR(Study) theStudy, + FieldData& theData, + VISU::Result_i* theResult, + bool theIsRangeDefined, + CORBA::Double theMinVal, + CORBA::Double theMaxVal) + { + double aMin = VTK_LARGE_FLOAT, aMax = -VTK_LARGE_FLOAT; + _PTR(ChildIterator) anIter = theStudy->NewChildIterator(theData.myField); + anIter->Next(); // First is reference on support + + long aFrameId = 0; + for(; anIter->More(); anIter->Next()){ + if (aFrameId == theData.myNbTimes) { + MESSAGE("There are extra timestamps in field"); + return; + } + _PTR(SObject) aTimeStamp = anIter->Value(); + if(!aTimeStamp) + continue; + + theData.myTiming[aFrameId] = VISU_TimeAnimation::getTimeValue(aTimeStamp); + if (theIsRangeDefined) { + if (theData.myTiming[aFrameId] < theMinVal) + continue; + if (theData.myTiming[aFrameId] > theMaxVal) + break; + } + + VISU::Storable::TRestoringMap aTimeMap = VISU_TimeAnimation::getMapOfValue(aTimeStamp); + QString aMeshName = VISU::Storable::FindValue(aTimeMap,"myMeshName"); + VISU::Entity anEntity = (VISU::Entity) VISU::Storable::FindValue(aTimeMap,"myEntityId").toInt(); + QString aFieldName = VISU::Storable::FindValue(aTimeMap,"myFieldName"); + int aTimeStampId = VISU::Storable::FindValue(aTimeMap,"myTimeStampId").toInt(); + + TPrs3d* aPresent = new TPrs3d(theResult, false); + aPresent->Create(aMeshName.latin1(), anEntity, + aFieldName.latin1(), aTimeStampId); + theData.myPrs[aFrameId++] = aPresent; + + aMin = std::min(aPresent->GetMin(),aMin); + aMax = std::min(aPresent->GetMax(),aMax); + } + theData.myNbFrames = aFrameId; + + if (theData.myPrsType != VISU::TGAUSSPOINTS){ + int aRangeType = VISU::GetResourceMgr()->integerValue("VISU" , "scalar_range_type", 0); + if( aRangeType != 1 ){ + for(long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++) { + if (VISU::ScalarMap_i* aPrs = dynamic_cast(theData.myPrs[aFrameId])){ + aPrs->SetRange(aMin, aMax); + aPrs->SetOffset(theData.myOffset); + } + } + } + if (theData.myPrsType == VISU::TISOSURFACE) + for (long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++) + if (VISU::IsoSurfaces_i* aPrs = dynamic_cast(theData.myPrs[aFrameId])) + aPrs->SetSubRange(aMin, aMax); + } + } +} + void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { FieldData& aData = myFieldsLst[theFieldNum]; // Delete previous presentations clearData(aData); - VISU::Result_i* pResult = createPresent(aData.myField); + VISU::Result_i* aResult = createPresent(aData.myField); VISU::Storable::TRestoringMap aMap = getMapOfValue(aData.myField); aData.myNbFrames = aData.myNbTimes; - //VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong(); + //VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong(); aData.myPrs.resize(aData.myNbTimes,NULL); aData.myTiming.resize(aData.myNbTimes); - _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aData.myField); - _PTR(SObject) aTimeStamp; - anIter->Next(); // First is reference on support - long i = 0; - double aMin = VTK_LARGE_FLOAT, aMax = -VTK_LARGE_FLOAT; - for (; anIter->More(); anIter->Next()) { - if (i == aData.myNbTimes) { - MESSAGE("There are extra timestamps in field"); - return; - } - aTimeStamp = anIter->Value(); - if (!aTimeStamp) continue; - - aData.myTiming[i] = getTimeValue(aTimeStamp); - if (isRangeDefined()) { - if (aData.myTiming[i] < myMinVal) continue; - if (aData.myTiming[i] > myMaxVal) break; - } - - VISU::Storable::TRestoringMap aTimeMap = getMapOfValue(aTimeStamp); - QString aMeshName = VISU::Storable::FindValue(aTimeMap,"myMeshName"); - VISU::Entity anEntity = (VISU::Entity) VISU::Storable::FindValue(aTimeMap,"myEntityId").toInt(); - QString aFieldName = VISU::Storable::FindValue(aTimeMap,"myFieldName"); - int aTimeStampId = VISU::Storable::FindValue(aTimeMap,"myTimeStampId").toInt(); - - switch (aData.myPrsType) { - case VISU::TSCALARMAP: // ScalarMap - { - VISU::ScalarMap_i* aPresent = new VISU::ScalarMap_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, - aFieldName.latin1(), aTimeStampId); - //VISU::ScalarMap_var aTmp = aPresent->_this(); - //aPresent->_remove_ref(); - aData.myPrs[i] = aPresent; - } - break; - - case VISU::TISOSURFACE: // Iso Surfaces - { - VISU::IsoSurfaces_i* aPresent = new VISU::IsoSurfaces_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, - aFieldName.latin1(), aTimeStampId); - //VISU::IsoSurfaces_var aTmp = aPresent->_this(); - //aPresent->_remove_ref(); - aData.myPrs[i] = aPresent; - } - break; - - case VISU::TCUTPLANES: // Cut Planes - { - VISU::CutPlanes_i* aPresent = new VISU::CutPlanes_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, - aFieldName.latin1(), aTimeStampId); - //VISU::CutPlanes_var aTmp = aPresent->_this(); - //aPresent->_remove_ref(); - aData.myPrs[i] = aPresent; - } - break; - - case VISU::TPLOT3D: // Plot3d - { - VISU::Plot3D_i* aPresent = new VISU::Plot3D_i (pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, - aFieldName.latin1(), aTimeStampId); - aData.myPrs[i] = aPresent; - } - break; - - case VISU::TDEFORMEDSHAPE: // Deformed Shape - { - VISU::DeformedShape_i* aPresent = new VISU::DeformedShape_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, - aFieldName.latin1(), aTimeStampId); - //VISU::DeformedShape_var aTmp = aPresent->_this(); - //aPresent->_remove_ref(); - aData.myPrs[i] = aPresent; - } - break; - - case VISU::TVECTORS: // Vectors - { - VISU::Vectors_i* aPresent = new VISU::Vectors_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, - aFieldName.latin1(), aTimeStampId); - //VISU::Vectors_var aTmp = aPresent->_this(); - //aPresent->_remove_ref(); - aData.myPrs[i] = aPresent; - } - break; - - case VISU::TSTREAMLINES: // Stream Lines - { - VISU::StreamLines_i* aPresent = new VISU::StreamLines_i(pResult, false); - aPresent->Create(aMeshName.latin1(), anEntity, - aFieldName.latin1(), aTimeStampId); - //VISU::StreamLines_var aTmp = aPresent->_this(); - //aPresent->_remove_ref(); - aData.myPrs[i] = aPresent; - } - break; - default: - MESSAGE("Not implemented for this presentation type: " << aData.myPrsType); - return; - } - if (aData.myPrs[i]->GetMin() < aMin) aMin = aData.myPrs[i]->GetMin(); - if (aData.myPrs[i]->GetMax() > aMax) aMax = aData.myPrs[i]->GetMax(); - i++; - } - aData.myNbFrames = i; - - int rangeType = VISU::GetResourceMgr()->integerValue("VISU" , "scalar_range_type", 0); - if ( rangeType != 1 ) { - for (i = 0; i < aData.myNbFrames; i++) { - aData.myPrs[i]->SetRange(aMin, aMax); - aData.myPrs[i]->SetOffset(aData.myOffset); - } - if (aData.myPrsType == VISU::TISOSURFACE) - for (i = 0; i < aData.myNbFrames; i++) - if (VISU::IsoSurfaces_i* aPrs = dynamic_cast(aData.myPrs[i])) - aPrs->SetSubRange(aMin, aMax); + using namespace VISU; + switch (aData.myPrsType) { + case VISU::TSCALARMAP: // ScalarMap + GeneratePresentations(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal); + break; + case VISU::TISOSURFACE: // Iso Surfaces + GeneratePresentations(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal); + break; + case VISU::TCUTPLANES: // Cut Planes + GeneratePresentations(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal); + break; + case VISU::TPLOT3D: // Plot3d + GeneratePresentations(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal); + break; + case VISU::TDEFORMEDSHAPE: // Deformed Shape + GeneratePresentations(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal); + break; + case VISU::TVECTORS: // Vectors + GeneratePresentations(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal); + break; + case VISU::TSTREAMLINES: // Stream Lines + GeneratePresentations(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal); + break; + case VISU::TGAUSSPOINTS: // Gauss Points + GeneratePresentations(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal); + break; + default: + MESSAGE("Not implemented for this presentation type: " << aData.myPrsType); + return; } } -//************************************************************************ +//------------------------------------------------------------------------ CORBA::Boolean VISU_TimeAnimation::generateFrames() { if (!myView) { MESSAGE("Viewer is not defined for animation"); @@ -326,7 +303,7 @@ CORBA::Boolean VISU_TimeAnimation::generateFrames() { return aNoError; } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::clearView() { if (!myView) { MESSAGE("Viewer is not defined for animation"); @@ -347,12 +324,12 @@ void VISU_TimeAnimation::clearView() { VISU::RepaintView(myView); } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::stopAnimation() { myIsActive = false; } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::startAnimation() { if (!myIsActive) { myIsActive = true; @@ -360,7 +337,7 @@ void VISU_TimeAnimation::startAnimation() { } } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::nextFrame() { if (!myView) { MESSAGE("Viewer is not defined for animation"); @@ -383,7 +360,7 @@ void VISU_TimeAnimation::nextFrame() { } } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::prevFrame() { if (!myView) { MESSAGE("Viewer is not defined for animation"); @@ -406,7 +383,7 @@ void VISU_TimeAnimation::prevFrame() { } } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::firstFrame() { if (!myView) { MESSAGE("Viewer is not defined for animation"); @@ -429,7 +406,7 @@ void VISU_TimeAnimation::firstFrame() { } } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::lastFrame() { if (!myView) { MESSAGE("Viewer is not defined for animation"); @@ -451,7 +428,7 @@ void VISU_TimeAnimation::lastFrame() { } -//************************************************************************ +//------------------------------------------------------------------------ // For Batchmode using void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame) { if (!myView) { @@ -481,23 +458,23 @@ void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame) { } -//************************************************************************ -VISU::ScalarMap_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CORBA::Long theFrame) { +//------------------------------------------------------------------------ +VISU::ColoredPrs3d_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CORBA::Long theFrame) { if ((theField > getNbFields()) || (theField < 0)) - return VISU::ScalarMap::_nil(); + return VISU::ColoredPrs3d::_nil(); if ((theFrame < 0) || (theFrame > (myFieldsLst[theField].myNbFrames - 1))) - return VISU::ScalarMap::_nil(); + return VISU::ColoredPrs3d::_nil(); return myFieldsLst[theField].myPrs[theFrame]->_this(); } -//************************************************************************ +//------------------------------------------------------------------------ CORBA::Long VISU_TimeAnimation::getNbFrames() { return (getNbFields() > 0)? myFieldsLst[0].myNbFrames : 0; } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::run() { if (!myView) { @@ -578,7 +555,7 @@ void VISU_TimeAnimation::run() QThread::exit(); } -//************************************************************************ +//------------------------------------------------------------------------ VISU::Result_i* VISU_TimeAnimation::createPresent (_PTR(SObject) theField) { _PTR(SObject) aSObj = theField->GetFather(); @@ -589,7 +566,7 @@ VISU::Result_i* VISU_TimeAnimation::createPresent (_PTR(SObject) theField) return dynamic_cast(VISU::GetServant(anObject).in()); } -//************************************************************************ +//------------------------------------------------------------------------ VISU::Storable::TRestoringMap VISU_TimeAnimation::getMapOfValue (_PTR(SObject) theSObject) { VISU::Storable::TRestoringMap aMap; @@ -605,7 +582,7 @@ VISU::Storable::TRestoringMap VISU_TimeAnimation::getMapOfValue (_PTR(SObject) t return aMap; } -//************************************************************************ +//------------------------------------------------------------------------ double VISU_TimeAnimation::getTimeValue (_PTR(SObject) theTimeStamp) { _PTR(GenericAttribute) anAttr; @@ -621,20 +598,20 @@ double VISU_TimeAnimation::getTimeValue (_PTR(SObject) theTimeStamp) return -1.0; } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::setSpeed(CORBA::Long theSpeed) { mySpeed = (theSpeed<1)? 1 : theSpeed; } -//************************************************************************ +//------------------------------------------------------------------------ int VISU_TimeAnimation::myNBAnimations = 0; QString VISU_TimeAnimation::GenerateName() { return VISU::GenerateName("Animation", myNBAnimations++); } -//************************************************************************ +//------------------------------------------------------------------------ std::string GetPresentationComment (VISU::VISUType thePrsType) { std::string aPrsCmt; @@ -660,6 +637,9 @@ std::string GetPresentationComment (VISU::VISUType thePrsType) case VISU::TSTREAMLINES: aPrsCmt = VISU::StreamLines_i::myComment; break; + case VISU::TGAUSSPOINTS: + aPrsCmt = VISU::GaussPoints_i::myComment; + break; default: aPrsCmt = "Unknown presentation"; break; @@ -667,7 +647,7 @@ std::string GetPresentationComment (VISU::VISUType thePrsType) return aPrsCmt; } -//************************************************************************ +//------------------------------------------------------------------------ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy() { if (myStudy->GetProperties()->IsLocked()) @@ -707,7 +687,7 @@ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy() return VISU::GetSObject(aAnimSObject); } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::saveAnimation() { if (myStudy->GetProperties()->IsLocked()) return; @@ -768,7 +748,7 @@ void VISU_TimeAnimation::saveAnimation() aStudyBuilder->CommitCommand(); } -//************************************************************************ +//------------------------------------------------------------------------ void VISU_TimeAnimation::restoreFromStudy(SALOMEDS::SObject_ptr theField) { _PTR(SObject) aAnimSObject = VISU::GetClientSObject(theField, myStudy); @@ -824,6 +804,8 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField) aData.myPrsType = VISU::TVECTORS; else if (strName == VISU::StreamLines_i::myComment.c_str()) aData.myPrsType = VISU::TSTREAMLINES; + else if (strName == VISU::GaussPoints_i::myComment.c_str()) + aData.myPrsType = VISU::TGAUSSPOINTS; else continue; generatePresentations(getNbFields()-1); @@ -985,7 +967,7 @@ CORBA::Long VISU_TimeAnimation_i::getCurrentFrame() return myAnim->getCurrentFrame(); } -VISU::ScalarMap_ptr VISU_TimeAnimation_i::getPresentation +VISU::ColoredPrs3d_ptr VISU_TimeAnimation_i::getPresentation (CORBA::Long theField, CORBA::Long theFrame) { return myAnim->getPresentation(theField,theFrame); diff --git a/src/VISU_I/VISU_TimeAnimation.h b/src/VISU_I/VISU_TimeAnimation.h index 26cc764c..70a5d3f4 100644 --- a/src/VISU_I/VISU_TimeAnimation.h +++ b/src/VISU_I/VISU_TimeAnimation.h @@ -22,7 +22,7 @@ class VISU_Actor; namespace VISU{ class Result_i; - class ScalarMap_i; + class ColoredPrs3d_i; } struct FieldData @@ -31,7 +31,7 @@ struct FieldData _PTR(SObject) myField; // field label long myNbTimes; // number of Timestamps long myNbFrames; // number of created Frames - std::vector myPrs; // Presentations + std::vector myPrs; // Presentations std::vector myActors; // Actors std::vector myTiming; // time values float myOffset[3]; @@ -80,7 +80,7 @@ class VISU_TimeAnimation: public QObject, public QThread CORBA::Boolean isRunning() { return myIsActive; } CORBA::Long getCurrentFrame() { return myFrame; } - VISU::ScalarMap_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame); + VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame); void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType) { myFieldsLst[theFieldNum].myPrsType = theType; } @@ -183,7 +183,7 @@ public: virtual CORBA::Boolean isRunning(); virtual CORBA::Long getCurrentFrame(); - virtual VISU::ScalarMap_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame); + virtual VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame); virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType); virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum); -- 2.39.2