]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Showing of animation, stored in study, is available now through popup-menu
authorjfa <jfa@opencascade.com>
Thu, 14 Jul 2005 06:02:00 +0000 (06:02 +0000)
committerjfa <jfa@opencascade.com>
Thu, 14 Jul 2005 06:02:00 +0000 (06:02 +0000)
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISUGUI/VisuGUI_TimeAnimation.h
src/VISU_I/VISU_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.h

index 062917c895a37fbdff4f5060745185a50bba8f6a..a2c4f76e76d8a4d02be430fea5bb7284c19f2550 100644 (file)
@@ -63,6 +63,9 @@ msgstr "Visualization Toolbar"
 msgid "VisuGUI::TOOL_REPRESENTATION"
 msgstr "Representation Toolbar"
 
+msgid "VisuGUI::MEN_SHOW_ANIMATION"
+msgstr "Show..."
+
 msgid "VisuGUI::MEN_ANIMATION"
 msgstr "Animation..."
 
@@ -99,12 +102,6 @@ msgstr "Cut Lines"
 msgid "VisuGUI::MEN_CUT_PLANES"
 msgstr "Cut Planes"
 
-#msgid "VisuGUI::MEN_DELETE_OBJ"
-#msgstr "Delete"
-
-#msgid "VisuGUI::MEN_DELETE_PRS"
-#msgstr "Delete"
-
 msgid "VisuGUI::MEN_DISPLAY"
 msgstr "Display"
 
index d6ffb0650d7cb0bc44cc404c6fbb23ed1c0ef34b..81ae90a26c87cd1519670eb2546c724c4d7a4e8b 100644 (file)
@@ -1735,25 +1735,23 @@ OnShowAnimation()
   const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
 
   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
-  SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
 
-  SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(anIO->getEntry());
-  if (aSObj->_is_nil()) return;
+  _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
+  if (!aSObj) return;
 
   VISU::Storable::TRestoringMap aMap;
-  SALOMEDS::GenericAttribute_var anAttr;
+  _PTR(GenericAttribute) anAttr;
   if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
 
-  SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
+  _PTR(AttributeComment) aComment (anAttr);
   string aComm = aComment->Value();
-  QString strIn(aComm.c_str());
-  VISU::Storable::StrToMap(strIn,aMap);
+  QString strIn (aComm.c_str());
+  VISU::Storable::StrToMap(strIn, aMap);
   bool isExist;
   VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
   if (aType != VISU::TANIMATION) return;
 
   VisuGUI_TimeAnimationDlg* aAnimationDlg =
-//    new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy);
     new VisuGUI_TimeAnimationDlg(this, aCStudy);
   aAnimationDlg->restoreFromStudy(aSObj);
   aAnimationDlg->show();
@@ -1767,7 +1765,6 @@ OnCopyPresentation()
   if (CheckLock(aCStudy))
     return;
 
-  //VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
   Handle(SALOME_InteractiveObject) anIO;
   CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
   if (CORBA::is_nil(anObject)) return;
@@ -2093,13 +2090,10 @@ createActions()
                 this, SLOT(OnCreatePlot3D()));
 
   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
-  createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap), tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
+  createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
+                tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
                this, SLOT(OnCreatePlot2dView()));
 
-  //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
-  //createAction( VISU_DELETE, tr("MEN_DELETE_OBJ"), QIconSet(), tr("MEN_DELETE_OBJ"), "", 0, aParent, false,
-  //              this, SLOT(OnDeleteObject()));
-
   createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
                 tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
                 this, SLOT(OnDeleteObjects()));
@@ -2157,10 +2151,6 @@ createActions()
   createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(), tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
                this, SLOT(OnDisplayOnlyPrs()));
 
-  //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
-  //createAction( VISU_DELETE_PRS, tr("MEN_DELETE_PRS"), QIconSet(), tr("MEN_DELETE_PRS"), "", 0, aParent, false,
-  //              this, SLOT(OnDeletePrs()));
-
   //aPixmap = aResourceMgr->loadPixmap("VISU",tr(""));
   createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(), tr("MEN_COPY_PRS"), "", 0, aParent, false,
                this, SLOT(OnCopyPresentation()));
@@ -2412,9 +2402,6 @@ createPopupMenus()
   mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
 
   // delete
-  //mgr->insert( action( VISU_DELETE_OBJS ), -1, -1, -1 );
-  //mgr->insert( action( VISU_DELETE ), -1, -1, -1 ); // TODO: remove
-  //mgr->insert( action( VISU_DELETE_PRS ), -1, -1, -1 ); // TODO: remove
   mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
 
   // table commands
@@ -2457,7 +2444,6 @@ createPopupMenus()
 
   mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
   mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
-  mgr->insert( action( VISU_SHOW_ANIMATION ), -1, -1, -1 );
 
   mgr->insert( separator(), -1, -1, -1 );
 
@@ -2489,13 +2475,6 @@ createPopupMenus()
   mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
   mgr->setRule( action( VISU_PLOT2D ), aRule, true );
 
-  //aRule = aSel_One_ObjBr + " and $type in {'VISU::TRESULT' 'VISU::TTABLE' 'VISU::TCONTAINER'}";
-  //mgr->setRule( action( VISU_DELETE ), aRule, true );
-
-  //QString aDeletable ("$type in {'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER' ");
-  //aDeletable += aPrsAll + " 'VISU::TRESULT' 'VISU::TMESH'}";
-  //mgr->setRule( action( VISU_DELETE_OBJS ), aSel_Some_ObjBr + " and " + aDeletable, true );
-
   // timestamp commands
   aRule = aSel_One_ObjBr + " and type='VISU::TTIMESTAMP'";
   mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
@@ -2529,10 +2508,6 @@ createPopupMenus()
   mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
   mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
 
-  //aRule = "selcount=1 and $type in {'VISU::TTABLE' 'VISU::TCURVE' "
-  //        "'VISU::TCONTAINER' 'VISU::TMESH' " + aPrsAll + "}";
-  //mgr->setRule( action( VISU_DELETE_PRS ), aRule, true );
-
   // View parameters
   //jfa tmp:aRule = "(client='VTKViewer' and selcount=0) or (selcount=1 and type='VISU::TVIEW3D')";
   //jfa tmp:mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), aRule, true );
@@ -2618,9 +2593,6 @@ createPopupMenus()
 
   aRule = "client='ObjectBrowser' and type='MEDFIELD'";
   mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
-
-  aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TANIMATION'";
-  mgr->setRule( action( VISU_SHOW_ANIMATION ), aRule, true );
 }
 
 //***************************************************************************
@@ -2628,7 +2600,7 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q
 {
   SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
 
-  // Check multiple selection
+  // Check if some (nb > 0) removable objects selected
   if (IsRemovableSelected(this)) {
     action( VISU_DELETE_OBJS )->addTo(theMenu);
   }
@@ -2640,14 +2612,21 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q
   if (aListIO.Extent() != 1) return;
 
   Handle(SALOME_InteractiveObject) anIO;
-  CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
-  _PTR(SObject) SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
-  if (IsSObjectTable(SO)) {
+  VISU::Storable::TRestoringMap aMap;
+  CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
+
+  _PTR(SObject) SO = GetCStudy(GetAppStudy(this))->FindObjectID(anIO->getEntry());
+  bool isExist;
+  VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
+  if (aType == VISU::TANIMATION) {
+    action( VISU_SHOW_ANIMATION )->addTo(theMenu);
+
+  } else if (IsSObjectTable(SO)) {
     action( VISU_SHOW_TABLE )->addTo(theMenu);
     action( VISU_CREATE_CURVES )->addTo(theMenu);
     action( VISU_EXPORT_TABLE )->addTo(theMenu);
     theMenu->insertSeparator();
-    //action( VISU_DELETE )->addTo(theMenu);
+
   } else {
     if (!CORBA::is_nil(anObject)) {
       SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
index 0a6ea6722b0cb30ee6d662c0744bb1ac186de243..9418696fe3eca54b0d2c0f4fc109021d675dda68 100644 (file)
@@ -46,7 +46,7 @@
 #include <vtkRenderer.h>
 
 #include <qhbox.h>
-#include <qgrid.h> 
+#include <qgrid.h>
 #include <qlayout.h>
 #include <qslider.h>
 #include <qthread.h>
@@ -171,16 +171,16 @@ void ArrangeDlg::init()
   aManualPane->setSpacing(10);
 
   myFieldLst = new QListBox(aManualPane);
-  connect( myFieldLst, SIGNAL( highlighted(int) ), 
+  connect( myFieldLst, SIGNAL( highlighted(int) ),
           this, SLOT( onFieldChange(int) ) );
 
   QGrid* aCoordPane = new QGrid(2, aManualPane);
   aCoordPane->setSpacing(5);
-  
+
   new QLabel("X", aCoordPane);
   myCoord[0] = new QtxDblSpinBox(aCoordPane);
   myCoord[0]->setRange(-MAXVAL, MAXVAL);
-  
+
   new QLabel("Y", aCoordPane);
   myCoord[1] = new QtxDblSpinBox(aCoordPane);
   myCoord[1]->setRange(-MAXVAL, MAXVAL);
@@ -242,7 +242,7 @@ void ArrangeDlg::accept()
   QDialog::accept();
 }
 
-void ArrangeDlg::onFieldChange(int theCurrent) 
+void ArrangeDlg::onFieldChange(int theCurrent)
 {
   if (myCurrent != theCurrent) {
     Offset& aOffs = myOffsets[myCurrent];
@@ -265,7 +265,7 @@ void ArrangeDlg::acceptAnimation()
     aOffs.myOffset[0] = myCoord[0]->value();
     aOffs.myOffset[1] = myCoord[1]->value();
     aOffs.myOffset[2] = myCoord[2]->value();
-    
+
     for (int i = 0; i < myAnimator->getNbFields(); i++) {
       Offset aOffs = myOffsets[i];
       myAnimator->getFieldData(i).myOffset[0] = aOffs.myOffset[0];
@@ -287,7 +287,7 @@ void ArrangeDlg::acceptAnimation()
     case XAxis:
       aDist = fabs(aBounds[1] - aBounds[0]);
       break;
-    case YAxis: 
+    case YAxis:
       aDist = fabs(aBounds[3] - aBounds[2]);
       break;
     case ZAxis:
@@ -300,7 +300,7 @@ void ArrangeDlg::acceptAnimation()
       myAnimator->getFieldData(i).myOffset[2] = 0;
       myAnimator->getFieldData(i).myOffset[aAxis] = aDist * i;
     }
-    
+
     QApplication::restoreOverrideCursor();
   }
 }
@@ -320,7 +320,7 @@ void ArrangeDlg::acceptViewWindow()
       Offset& aOffs = myOffsets[it.data()];
       if (VISU_Actor* anActor = VISU::GetActor(aPrs, myViewWindow)) anActor->SetPosition(aOffs.myOffset);
       if (mySaveChk)
-       if (mySaveChk->isChecked()) 
+       if (mySaveChk->isChecked())
          aPrs->SetOffset(aOffs.myOffset);
     }
   } else {
@@ -341,7 +341,7 @@ void ArrangeDlg::acceptViewWindow()
        case XAxis:
          aDist = fabs(aBounds[1] - aBounds[0]);
          break;
-       case YAxis: 
+       case YAxis:
          aDist = fabs(aBounds[3] - aBounds[2]);
          break;
        case ZAxis:
@@ -363,8 +363,8 @@ void ArrangeDlg::acceptViewWindow()
       }
     }
   }
-  myViewWindow->getRenderer()->ResetCameraClippingRange(); 
-  myViewWindow->Repaint(); 
+  myViewWindow->getRenderer()->ResetCameraClippingRange();
+  myViewWindow->Repaint();
 }
 
 
@@ -452,7 +452,7 @@ SetupDlg::SetupDlg (QWidget* theParent, VISU_TimeAnimation* theAnimator)
   QVBox* aSetupBox = new QVBox(aPropFrame);
   aSetupBox->setSpacing(5);
 
-  QVGroupBox* aPropBox = new QVGroupBox("Properties", aSetupBox);  
+  QVGroupBox* aPropBox = new QVGroupBox("Properties", aSetupBox);
   //QVGroupBox* aPropBox = new QVGroupBox("Properties", aPropFrame);
   myTypeCombo = new QComboBox(aPropBox);
   connect( myTypeCombo, SIGNAL( activated(int) ),
@@ -646,7 +646,7 @@ void SetupDlg::onPreferencesDlg()
 
 
 //************************************************************************
-void SetupDlg::onArrangeDlg() 
+void SetupDlg::onArrangeDlg()
 {
   ArrangeDlg aDlg(this, myAnimator);
   aDlg.exec();
@@ -1162,7 +1162,7 @@ void VisuGUI_TimeAnimationDlg::onStop()
 }
 
 //************************************************************************
-void VisuGUI_TimeAnimationDlg::saveToStudy() 
+void VisuGUI_TimeAnimationDlg::saveToStudy()
 {
   myAnimator->saveAnimation();
   myModule->updateObjBrowser( true );
@@ -1177,7 +1177,7 @@ void VisuGUI_TimeAnimationDlg::publishToStudy()
 }
 
 //************************************************************************
-void VisuGUI_TimeAnimationDlg::restoreFromStudy(SALOMEDS::SObject_var theAnimation)
+void VisuGUI_TimeAnimationDlg::restoreFromStudy(_PTR(SObject) theAnimation)
 {
   myAnimator->restoreFromStudy(theAnimation);
   mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
index a28532e39d6537ce23371bdb4069485612286f31..709d341ab4fad839d925a435b30b80ccbf9d77c9 100644 (file)
 
 #include "SALOMEDSClient_Study.hxx"
 
-#include "SALOMEconfig.h"
-#include CORBA_SERVER_HEADER(SALOMEDS)
-
 #include <qdialog.h>
-#include <qbuttongroup.h> 
-#include <qwidgetstack.h> 
+#include <qbuttongroup.h>
+#include <qwidgetstack.h>
 
 class VisuGUI;
 class VISU_TimeAnimation;
@@ -95,10 +92,10 @@ class SetupDlg: public QDialog {
  public:
   SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator);
   ~SetupDlg() {};
-  
+
  private slots:
   void onFieldChange(int theIndex);
-  void onTypeChanged(int theIndex); 
+  void onTypeChanged(int theIndex);
   //  void onScalarBarDlg();
   void onPreferencesDlg();
   void onRangeCheck(bool theCheck);
@@ -119,17 +116,16 @@ class SetupDlg: public QDialog {
 
 
 class VisuGUI_TimeAnimationDlg: public QDialog
-{ 
+{
     Q_OBJECT
  public:
-    //VisuGUI_TimeAnimationDlg(QWidget* parent, _PTR(Study) theStudy);
     VisuGUI_TimeAnimationDlg(VisuGUI* theModule, _PTR(Study) theStudy);
     ~VisuGUI_TimeAnimationDlg();
 
     void addField(_PTR(SObject) theField);
     void clearView();
 
-    void restoreFromStudy(SALOMEDS::SObject_var theAnimation);
+    void restoreFromStudy(_PTR(SObject) theAnimation);
 
  protected:
     virtual void closeEvent(QCloseEvent* theEvent);
index 2c7ba0ee5572a52ed122cd9bddb050f35fc75355..9b19847e56bf9774e749005049c597e70f02216b 100644 (file)
@@ -695,8 +695,13 @@ void VISU_TimeAnimation::saveAnimation()
 //************************************************************************
 void VISU_TimeAnimation::restoreFromStudy(SALOMEDS::SObject_ptr theField)
 {
-  //SALOMEDS::SObject_var aAnimSObject = SALOMEDS::SObject::_duplicate(theField);
   _PTR(SObject) aAnimSObject = VISU::GetClientSObject(theField, myStudy);
+  restoreFromStudy(aAnimSObject);
+}
+
+void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
+{
+  _PTR(SObject) aAnimSObject = theField;
 
   VISU::Storable::TRestoringMap aMap;
   _PTR(GenericAttribute) anAttr;
@@ -766,28 +771,48 @@ void VISU_TimeAnimation::restoreFromStudy(SALOMEDS::SObject_ptr theField)
 //========================================================================
 //========================================================================
 //========================================================================
-VISU_TimeAnimation_i::VISU_TimeAnimation_i (SALOMEDS::Study_ptr theStudy,
-                                            VISU::View3D_ptr theView3D)
-{
-  //myAnim = new VISU_TimeAnimation (theStudy,theView3D);
-
-  std::string aStudyName = theStudy->Name();
-  SUIT_Session* aSession = SUIT_Session::session();
-  QPtrList<SUIT_Application> anApplications = aSession->applications();
-  QPtrListIterator<SUIT_Application> anIter (anApplications);
-  while (SUIT_Application* anApp = anIter.current()) {
-    ++anIter;
-    if (SUIT_Study* aSStudy = anApp->activeStudy()) {
-      if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
-        if (_PTR(Study) aCStudy = aStudy->studyDS()) {
-          if (aStudyName == aCStudy->Name()) {
-            myAnim = new VISU_TimeAnimation (aCStudy, theView3D);
-            break;
+struct TNewAnimationEvent: public SALOME_Event
+{
+  std::string myStudyName;
+  VISU::View3D_ptr myView3D;
+
+  typedef VISU_TimeAnimation* TResult;
+  TResult myResult;
+
+  TNewAnimationEvent (std::string theStudyName, VISU::View3D_ptr theView3D):
+    myStudyName(theStudyName),
+    myView3D(VISU::View3D::_duplicate(theView3D)),
+    myResult(NULL)
+  {}
+
+  virtual
+  void
+  Execute()
+  {
+    SUIT_Session* aSession = SUIT_Session::session();
+    QPtrList<SUIT_Application> anApplications = aSession->applications();
+    QPtrListIterator<SUIT_Application> anIter (anApplications);
+    while (SUIT_Application* anApp = anIter.current()) {
+      ++anIter;
+      if (SUIT_Study* aSStudy = anApp->activeStudy()) {
+        if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+          if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+            if (myStudyName == aCStudy->Name()) {
+              myResult = new VISU_TimeAnimation (aCStudy, myView3D);
+              break;
+            }
           }
         }
       }
     }
   }
+};
+
+VISU_TimeAnimation_i::VISU_TimeAnimation_i (SALOMEDS::Study_ptr theStudy,
+                                            VISU::View3D_ptr theView3D)
+{
+  std::string aStudyName = theStudy->Name();
+  myAnim = ProcessEvent(new TNewAnimationEvent (aStudyName, theView3D));
 }
 
 VISU_TimeAnimation_i::~VISU_TimeAnimation_i()
index 43f2667ebce20f75c11036ea77bde33d113849f0..26cc764c2a5daf1b5a015571184d1824553019e3 100644 (file)
@@ -113,6 +113,7 @@ class VISU_TimeAnimation: public QObject, public QThread
 
   SALOMEDS::SObject_ptr publishInStudy();
   void restoreFromStudy(SALOMEDS::SObject_ptr theField);
+  void restoreFromStudy(_PTR(SObject) theField);
   void saveAnimation();
   bool isSavedInStudy() const { return !myAnimEntry.isEmpty(); }