]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To improve animation.
authorapo <apo@opencascade.com>
Tue, 6 Dec 2005 07:18:28 +0000 (07:18 +0000)
committerapo <apo@opencascade.com>
Tue, 6 Dec 2005 07:18:28 +0000 (07:18 +0000)
Now, SetupAnimation dialog does not change current type of presentation

src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISUGUI/VisuGUI_TimeAnimation.h

index 4c848645994f52e0f61f833a39fd4640ff956b10..8d3703afeea2af3b382426ba45c542101ed4fc05 100644 (file)
@@ -435,19 +435,22 @@ void ArrangeDlg::acceptViewWindow()
 //------------------------------------------------------------------------
 //------------------------------------------------------------------------
 //------------------------------------------------------------------------
-SetupDlg::SetupDlg (VisuGUI* theModule, VISU_TimeAnimation* theAnimator)
-     : QDialog(VISU::GetDesktop(theModule), "SetupDlg", true, WStyle_Customize |
-               WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
-       myModule(theModule)
+SetupDlg::SetupDlg (QWidget* theParent,
+                   VisuGUI* theModule, 
+                   VISU_TimeAnimation* theAnimator) :
+  QDialog(theParent, 
+         "SetupDlg", 
+         true, 
+         WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
+  myAnimator(theAnimator),
+  myModule(theModule)
 {
   setCaption("Setup Animation");
   setSizeGripEnabled( TRUE );
-  myAnimator = theAnimator;
 
   QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6);
   aMainLayout->setSpacing(5);
 
-
   QFrame* aRangeGrp = new QFrame(this);
   QGridLayout* aRangeLayout = new QGridLayout( aRangeGrp );
   aRangeLayout->setSpacing( 6 );
@@ -566,66 +569,73 @@ void SetupDlg::onFieldChange (int theIndex)
 {
   FieldData& aData = myAnimator->getFieldData(theIndex);
   myTypeCombo->clear();
+  myTypeId2ComboId.clear();
   myComboId2TypeId.clear();
 
   // ATTENTION: append items in the same order like it is done in the PrsComboItem enumeration
   myTypeCombo->insertItem("Scalar Map");   // item 0
+  myTypeId2ComboId[TSCALARMAP_ITEM] = myComboId2TypeId.size();
   myComboId2TypeId.push_back(TSCALARMAP_ITEM);;
 
   myTypeCombo->insertItem("Iso Surfaces"); // item 1
+  myTypeId2ComboId[TISOSURFACE_ITEM] = myComboId2TypeId.size();
   myComboId2TypeId.push_back(TISOSURFACE_ITEM);;
 
   myTypeCombo->insertItem("Cut Planes");   // item 2
+  myTypeId2ComboId[TCUTPLANES_ITEM] = myComboId2TypeId.size();
   myComboId2TypeId.push_back(TCUTPLANES_ITEM);;
 
   myTypeCombo->insertItem("Plot 3D");      // item 3
+  myTypeId2ComboId[TPLOT3D_ITEM] = myComboId2TypeId.size();
   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
+    myTypeId2ComboId[TDEFORMEDSHAPE_ITEM] = myComboId2TypeId.size();
     myComboId2TypeId.push_back(TDEFORMEDSHAPE_ITEM);;
 
     myTypeCombo->insertItem("Vectors");        // item 5
+    myTypeId2ComboId[TVECTORS_ITEM] = myComboId2TypeId.size();
     myComboId2TypeId.push_back(TVECTORS_ITEM);;
 
     myTypeCombo->insertItem("Stream Lines");   // item 6
+    myTypeId2ComboId[TSTREAMLINES_ITEM] = myComboId2TypeId.size();
     myComboId2TypeId.push_back(TSTREAMLINES_ITEM);;
   }
 
   long anEntityId = VISU::getValue(aSObject, "myEntityId").toLong();
   if(anEntityId == VISU::CELL){
     myTypeCombo->insertItem("Gauss Points");   // item 7
+    myTypeId2ComboId[TGAUSSPOINTS_ITEM] = myComboId2TypeId.size();
     myComboId2TypeId.push_back(TGAUSSPOINTS_ITEM);;
   }
 
   switch (aData.myPrsType) {
   case VISU::TSCALARMAP: //Scalar Map
-    myTypeCombo->setCurrentItem(TSCALARMAP_ITEM);
+    myTypeCombo->setCurrentItem(myTypeId2ComboId[TSCALARMAP_ITEM]);
     break;
   case VISU::TISOSURFACE: //Iso Surfaces
-    myTypeCombo->setCurrentItem(TISOSURFACE_ITEM);
+    myTypeCombo->setCurrentItem(myTypeId2ComboId[TISOSURFACE_ITEM]);
     break;
   case VISU::TCUTPLANES: //Cut Planes
-    myTypeCombo->setCurrentItem(TCUTPLANES_ITEM);
+    myTypeCombo->setCurrentItem(myTypeId2ComboId[TCUTPLANES_ITEM]);
     break;
   case VISU::TPLOT3D: //Plot 3D
-    myTypeCombo->setCurrentItem(TPLOT3D_ITEM);
+    myTypeCombo->setCurrentItem(myTypeId2ComboId[TPLOT3D_ITEM]);
     break;
   case VISU::TDEFORMEDSHAPE: //Deformed Shape
-    myTypeCombo->setCurrentItem(TDEFORMEDSHAPE_ITEM);
+    myTypeCombo->setCurrentItem(myTypeId2ComboId[TDEFORMEDSHAPE_ITEM]);
     break;
   case VISU::TVECTORS: //Vectors
-    myTypeCombo->setCurrentItem(TVECTORS_ITEM);
+    myTypeCombo->setCurrentItem(myTypeId2ComboId[TVECTORS_ITEM]);
     break;
   case VISU::TSTREAMLINES: //Stream Lines
-    myTypeCombo->setCurrentItem(TSTREAMLINES_ITEM);
-    aData.myPrsType = VISU::TSTREAMLINES;
+    myTypeCombo->setCurrentItem(myTypeId2ComboId[TSTREAMLINES_ITEM]);
     break;
   case VISU::TGAUSSPOINTS: //Gauss Points
-    myTypeCombo->setCurrentItem(TGAUSSPOINTS_ITEM);
-    aData.myPrsType = VISU::TGAUSSPOINTS;
+    myTypeCombo->setCurrentItem(myTypeId2ComboId[TGAUSSPOINTS_ITEM]);
     break;
   }
   //myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP);
@@ -891,11 +901,14 @@ static const char * pauseIco[] = {
 static QPixmap MYpausePixmap(pauseIco);
 
 
-VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Study) theStudy)
-     : QDialog(VISU::GetDesktop(theModule), "VisuGUI_TimeAnimationDlg", false, WStyle_Customize |
-               WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
-       myModule(theModule),
-       myStudy(theStudy)
+VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Study) theStudy) :
+  QDialog(VISU::GetDesktop(theModule), 
+         "VisuGUI_TimeAnimationDlg", 
+         false, 
+         WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
+  myModule(theModule),
+  myStudy(theStudy),
+  mySetupDlg(NULL)
 {
   setCaption("Animation");
   setSizeGripEnabled( TRUE );
@@ -1172,6 +1185,12 @@ void VisuGUI_TimeAnimationDlg::clearView()
   myAnimator->clearView();
 }
 
+//------------------------------------------------------------------------
+void VisuGUI_TimeAnimationDlg::showEvent(QShowEvent* theEvent)
+{
+  mySetupDlg = new SetupDlg(this,myModule, myAnimator);
+}
+
 //------------------------------------------------------------------------
 void VisuGUI_TimeAnimationDlg::closeEvent (QCloseEvent* theEvent)
 {
@@ -1218,11 +1237,10 @@ void VisuGUI_TimeAnimationDlg::onExecution (long theNewFrame, double theTime)
 //------------------------------------------------------------------------
 void VisuGUI_TimeAnimationDlg::onSetupDlg()
 {
-  if (myAnimator->getNbFrames() > 0) myAnimator->firstFrame();
-  SetupDlg* aDlg = new SetupDlg (myModule, myAnimator);
-  aDlg->exec();
+  if (myAnimator->getNbFrames() > 0) 
+    myAnimator->firstFrame();
+  mySetupDlg->exec();
   myPlayFrame->setEnabled(false);
-  delete aDlg;
 }
 
 //------------------------------------------------------------------------
index eba6c928203f6d8119e5795abd756cf84350e6d0..cfb3401e3592864d726777065d8822f2a57efa81 100644 (file)
@@ -90,7 +90,9 @@ class SetupDlg: public QDialog {
   Q_OBJECT
 
  public:
-  SetupDlg(VisuGUI* theModule, VISU_TimeAnimation* theAnimator);
+  SetupDlg(QWidget* theParent,
+          VisuGUI* theModule, 
+          VISU_TimeAnimation* theAnimator);
   ~SetupDlg() {};
 
  private slots:
@@ -110,6 +112,7 @@ class SetupDlg: public QDialog {
   QListBox* myFieldLst;
   QComboBox* myTypeCombo;
   std::vector<int> myComboId2TypeId;
+  std::map<int,int> myTypeId2ComboId;
 
   QPushButton* myPropBtn;
   QPushButton* myArrangeBtn;
@@ -133,6 +136,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog
 
  protected:
     virtual void closeEvent(QCloseEvent* theEvent);
+    virtual void showEvent(QShowEvent* theEvent);
     void stopAnimation();
 
  private slots:
@@ -162,6 +166,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog
     QPushButton* myGenBtn;
 
     QFrame* myPlayFrame;
+    SetupDlg* mySetupDlg;
     _PTR(Study) myStudy;
     VisuGUI* myModule;