]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To extend time animation on Gauss Points presentation
authorapo <apo@opencascade.com>
Fri, 2 Dec 2005 15:29:28 +0000 (15:29 +0000)
committerapo <apo@opencascade.com>
Fri, 2 Dec 2005 15:29:28 +0000 (15:29 +0000)
idl/VISU_Gen.idl
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISUGUI/VisuGUI_TimeAnimation.h
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_ScalarMap_i.cc
src/VISU_I/VISU_ScalarMap_i.hh
src/VISU_I/VISU_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.h

index 4b748780ef4c9aa0ddb1dc2d36dd763f1e972c9a..0ee7fe63ff10d3f481c08c55e1c2e30e57b2ad5b 100644 (file)
@@ -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.*/
index 8ff2718a3da2a5307879a8a00f18c7dcc57329f2..4c848645994f52e0f61f833a39fd4640ff956b10 100644 (file)
@@ -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<class TPrs3d, class TDialog>
+  void
+  EditPrs(VisuGUI* theModule,
+         FieldData& theData)
+  {
+    TDialog* aDlg = new TDialog(theModule);
+    aDlg->initFromPrsObject(dynamic_cast<TPrs3d*>(theData.myPrs[0]));
+    if (aDlg->exec())
+      for (int i = 0; i < theData.myNbFrames; i++)
+       aDlg->storeToPrsObject(dynamic_cast<TPrs3d*>(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<TYPE*>(aData.myPrs.at(0))); \
-//       if (aDlg->exec()) { \
-//     for (int i = 0; i < aData.myNbFrames; i++) \
-//       aDlg->storeToPrsObject(dynamic_cast<TYPE*>(aData.myPrs.at(i))); \
-//       } \
-//       delete aDlg; \
-//     }
-
-
-#define EDITPRS(TYPE, DLG) {\
-        DLG* aDlg = new DLG (myModule);\
-        aDlg->initFromPrsObject(dynamic_cast<TYPE*>(aData.myPrs[0]));\
-        if (aDlg->exec())\
-        { \
-         for (int i = 0; i < aData.myNbFrames; i++)\
-          aDlg->storeToPrsObject(dynamic_cast<TYPE*>(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<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg>(myModule,aData);
     break;
   case TISOSURFACE_ITEM: //Iso Surfaces
     c.suspend();
-    EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
+    EditPrs<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg>(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<VISU::CutPlanes_i*>(aData.myPrs.at(0)));
-      aDlg->initFromPrsObject(dynamic_cast<VISU::CutPlanes_i*>(aData.myPrs[0]));
-
-      if (aDlg->exec()) {
-       for (int i = 0; i < aData.myNbFrames; i++)
-      //_CS_PhB:operator [] .at          aDlg->storeToPrsObject(dynamic_cast<VISU::CutPlanes_i*>(aData.myPrs.at(i)));
-         aDlg->storeToPrsObject(dynamic_cast<VISU::CutPlanes_i*>(aData.myPrs[i]));
-      }
-      delete aDlg;
-    }*/
+    EditPrs<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg>(myModule,aData);
     break;
   case TPLOT3D_ITEM: //Plot 3D
     c.suspend();
-    EDITPRS(VISU::Plot3D_i, VisuGUI_Plot3DDlg);
+    EditPrs<VISU::Plot3D_i,VisuGUI_Plot3DDlg>(myModule,aData);
     break;
   case TDEFORMEDSHAPE_ITEM: //Deformed Shape
     c.suspend();
-    EDITPRS(VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg);
+    EditPrs<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg>(myModule,aData);
     break;
   case TVECTORS_ITEM: //Vectors
     c.suspend();
-    EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
+    EditPrs<VISU::Vectors_i,VisuGUI_VectorsDlg>(myModule,aData);
     break;
   case TSTREAMLINES_ITEM: //Stream Lines
     c.suspend();
-    EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
+    EditPrs<VISU::StreamLines_i,VisuGUI_StreamLinesDlg>(myModule,aData);
+    break;
+  case TGAUSSPOINTS_ITEM: //Gauss Points
+    c.suspend();
+    EditPrs<VISU::GaussPoints_i,VisuGUI_GaussPointsDlg>(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);
index f9fd9743058340b6a5788d1e88b0101301d74786..eba6c928203f6d8119e5795abd756cf84350e6d0 100644 (file)
@@ -106,8 +106,11 @@ class SetupDlg: public QDialog {
  private:
   VisuGUI* myModule;
   VISU_TimeAnimation* myAnimator;
+
   QListBox* myFieldLst;
   QComboBox* myTypeCombo;
+  std::vector<int> myComboId2TypeId;
+
   QPushButton* myPropBtn;
   QPushButton* myArrangeBtn;
   QCheckBox* myUseRangeChk;
index a47ea458f7807be5e5f0e5739f2f364b499551e8..8ae44caf5c240f5967be11b5e7622d075dd27789 100644 (file)
@@ -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)
index cdbfaeb29846cb753bab90c39f36c77ade06a357..1e09eb7aab94582ae96de9adbfe8ad13f4fe073d 100644 (file)
@@ -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);
index da9ea7773f3d947eb23a4be7d849d93c0ee5aec3..39d883fcdfc96167e05b7eadb6276febd304b9b7 100644 (file)
@@ -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 
index acdf7af3c46aff37e496479d2fbd4a79ed18ec46..9e2e0b0d4cef0235ca8995199a7db47a42d09208 100644 (file)
@@ -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
index f70ad911f3d51e137c430155ec40542ec809748b..ff41a959c4e05630afe8ba85e0f5aeedb1074ced 100644 (file)
@@ -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<class TPrs3d>
+  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<VISU::ScalarMap_i*>(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<VISU::IsoSurfaces_i*>(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<VISU::IsoSurfaces_i*>(aData.myPrs[i]))
-          aPrs->SetSubRange(aMin, aMax);
+  using namespace VISU;
+  switch (aData.myPrsType) {
+  case VISU::TSCALARMAP: // ScalarMap
+    GeneratePresentations<ScalarMap_i>(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal);
+    break;
+  case VISU::TISOSURFACE: // Iso Surfaces
+    GeneratePresentations<IsoSurfaces_i>(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal);
+    break;
+  case VISU::TCUTPLANES: // Cut Planes
+    GeneratePresentations<CutPlanes_i>(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal);
+    break;
+  case VISU::TPLOT3D: // Plot3d
+    GeneratePresentations<Plot3D_i>(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal);
+    break;
+  case VISU::TDEFORMEDSHAPE: // Deformed Shape
+    GeneratePresentations<DeformedShape_i>(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal);
+    break;
+  case VISU::TVECTORS: // Vectors
+    GeneratePresentations<Vectors_i>(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal);
+    break;
+  case VISU::TSTREAMLINES: // Stream Lines
+    GeneratePresentations<StreamLines_i>(myStudy,aData,aResult,isRangeDefined(),myMinVal,myMaxVal);
+    break;
+  case VISU::TGAUSSPOINTS: // Gauss Points
+    GeneratePresentations<GaussPoints_i>(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::Result_i*>(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);
index 26cc764c2a5daf1b5a015571184d1824553019e3..70a5d3f4a391f5d4e36b23c567fd34233294b9a6 100644 (file)
@@ -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<VISU::ScalarMap_i*> myPrs;     // Presentations
+  std::vector<VISU::ColoredPrs3d_i*> myPrs;     // Presentations
   std::vector<VISU_Actor*> myActors;         // Actors
   std::vector<double> 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);