Salome HOME
Plot3d on CutPlane
authorvsv <vsv@opencascade.com>
Tue, 18 Apr 2006 09:16:47 +0000 (09:16 +0000)
committervsv <vsv@opencascade.com>
Tue, 18 Apr 2006 09:16:47 +0000 (09:16 +0000)
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h

index 4ba765cb3aae00ab7d6eb89b6e450a835766be1c..0511fa4f56f8abd51fe28d6b94f0729df8e59791 100644 (file)
@@ -385,6 +385,9 @@ msgstr "Use Field Range"
 msgid "VisuGUI::MEN_ARRANGE_ACTORS"
 msgstr "Arrange Actors"
 
+msgid "VisuGUI::MEN_PLOT3D_FROM_CUTPLANE"
+msgstr "Plot3d"
+
 
 msgid "VisuGUI::ERR_ERROR_DURING_EXPORT"
 msgstr "Error has been occured during exporting to file"
index 3c2ad86737b9aaf2a87f8df20288fd1f937663c3..46a5fef9542a3fe5818b001be8dcc43048f0de79 100644 (file)
@@ -2213,6 +2213,11 @@ createActions()
   createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
                 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
                 this, SLOT(OnShowAnimation()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
+  createAction( VISU_PLOT3D_FROM_CUTPLANE, tr("MEN_PLOT3D_FROM_CUTPLANE"), QIconSet(aPixmap),
+                tr("MEN_PLOT3D_FROM_CUTPLANE"), "", 0, aParent, false,
+                this, SLOT(OnPlot3dFromCutPlane()));
 }
 
 void
@@ -2602,22 +2607,15 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q
       }
     }
   }
-
   if (nbPrs > 1) {
     theMenu->insertSeparator();
     action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu);
     action( VISU_FREE_SCALAR_BARS  )->addTo(theMenu);
   }
 
-  theMenu->insertSeparator();
-
-  // Check if some (nb > 0) removable objects selected
-  if (isOBClient && IsRemovableSelected(this)) {
-    action( VISU_DELETE_OBJS )->addTo(theMenu);
-  }
-
   // Check if some curves selected (for bug PAL10611)
   bool isCurves = false;
+  bool isOneCutPlane = false;
   SALOME_ListIteratorOfListIO It1 (aListIO);
   for (; It1.More() && !isCurves; It1.Next()) {
     Handle(SALOME_InteractiveObject)& anIO = It1.Value();
@@ -2635,12 +2633,33 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q
         VISU::Storable::StrToMap(strIn, pMap);
         bool isExist;
         VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
-        if (isExist && aType == VISU::TCURVE) {
+       if (isExist && aType == VISU::TCURVE) {
           isCurves = true;
-        }
+        }  else {
+         CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
+         if (!CORBA::is_nil(anObject)) {
+           VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
+           if (aPrsObject->GetType() == VISU::TCUTPLANES) {
+             VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
+             if (aCutPrs) {
+               isOneCutPlane = aCutPrs->GetNbPlanes() == 1;
+             }
+           }
+         }
+       }
       }
     }
   }
+
+  if (isOneCutPlane)
+    action( VISU_PLOT3D_FROM_CUTPLANE )->addTo(theMenu);
+
+  theMenu->insertSeparator();
+
+  // Check if some (nb > 0) removable objects selected
+  if (isOBClient && IsRemovableSelected(this)) {
+    action( VISU_DELETE_OBJS )->addTo(theMenu);
+  }
   if (isCurves) {
     action( myDisplay     )->removeFrom(theMenu);
     action( myErase       )->removeFrom(theMenu);
@@ -3043,3 +3062,103 @@ LightApp_Displayer* VisuGUI::displayer()
     
   return myDisplayer;
 }
+
+
+void VisuGUI::OnPlot3dFromCutPlane()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy, GetDesktop(this)))
+    return;
+
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects(aListIO);
+
+  if (aListIO.Extent() < 1) return;
+
+
+  VISU::CutPlanes_i* aCutPrs = 0;
+  Handle(SALOME_InteractiveObject) anIO;
+  _PTR(SObject) aSObject;
+  SALOME_ListIteratorOfListIO It (aListIO);
+  for (; It.More(); It.Next()) {
+    anIO = It.Value();
+
+    if (!anIO.IsNull() && anIO->hasEntry()) {
+      aSObject = aCStudy->FindObjectID(anIO->getEntry());
+      if ( !aSObject )
+       continue;
+      CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
+      if (!CORBA::is_nil(anObject)) {
+       VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
+       if (aPrsObject->GetType() == VISU::TCUTPLANES) {
+         aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
+         if (aCutPrs) 
+           break;
+       }
+      }
+    }
+  }
+
+  if (aCutPrs) {
+    _PTR(SObject) aTimeStampSObj = aSObject->GetFather();
+    if (SUIT_ViewManager* aViewManager = getApp()->activeViewManager()) {
+      QString aType = aViewManager->getType();
+      bool isVVTK = aType == VVTK_Viewer::Type();
+
+      Storable::TRestoringMap aMap = getMapOfValue(aTimeStampSObj);
+      bool isExist;
+      aType = Storable::FindValue(aMap,"myType",&isExist);
+      if (!isExist || aType.toInt() != TTIMESTAMP )
+       return;
+      
+      QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
+      QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
+      QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
+      QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
+
+      int aPos;
+      SUIT_ViewWindow* aViewWindow = 0;
+      if (isVVTK) {
+       aViewWindow = GetViewWindow<VVTK_Viewer>(this);
+       aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast<VVTK_ViewWindow*>(aViewWindow));
+      } else {
+       aViewWindow = GetViewWindow<SVTK_Viewer>(this);
+       aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast<SVTK_ViewWindow*>(GetViewWindow<SVTK_Viewer>(this)));
+      }
+      GetResourceMgr()->setValue("VISU", "scalar_bar_position_num", aPos);
+      
+      VISU::Plot3D_i* aPrs3d = CreatePrs3d<VISU::Plot3D_i>(this, aTimeStampSObj, aMeshName.latin1(), (Entity)anEntity.toInt(),
+                                                          aFieldName.latin1(), aTimeStampId.toInt());
+      if (aPrs3d) {
+       SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
+       int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0);
+       if (!aValue) {
+         VisuGUI_Plot3DDlg* aDlg = new VisuGUI_Plot3DDlg(this);
+         aDlg->initFromPrsObject(aPrs3d);
+         int    aOrient = aCutPrs->GetOrientationType(); // Plot3d has the same orientation type
+         double aRotX = aCutPrs->GetRotateX();
+         double aRotY = aCutPrs->GetRotateY();
+         double aPlanePos = aCutPrs->GetPlanePosition(0);
+         aDlg->setPlane(aOrient, aRotX, aRotY, aPlanePos);
+           
+         if (!(runAndWait(aDlg, 0) && (aDlg->storeToPrsObject(aPrs3d)))) {
+           DeletePrs3d(this, aPrs3d, anIO);
+           delete aDlg;
+           return;
+         }
+         delete aDlg;
+         UpdateObjBrowser(this, true, aTimeStampSObj);
+       }
+       SVTK_ViewWindow* aSVtkWindow = dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
+       if ( aSVtkWindow ) {
+         PublishInView(this, aPrs3d, aSVtkWindow, /*highlight = */true);
+         aSVtkWindow->onFitAll();
+         
+         AddScalarBarPosition(this, aSVtkWindow, aPrs3d, aPos);
+       }
+      }
+    }
+    application()->putInfo(QObject::tr("INF_DONE"));
+  }
+}
index cec1e4c2ef98d53d1e59067e99b7e29ce265b8c4..32dc989b3ea04107b8501d31daaf472b0f38a911 100644 (file)
@@ -154,6 +154,7 @@ protected slots:
 
   void OnTranslatePrs();
   void OnArrangeActors();
+  void OnPlot3dFromCutPlane();
 
 protected:
   virtual LightApp_Selection* createSelection() const;
index 681a9d131f1500d577b5665346e44b3eda43893f..58abbd0671e069a322f45c155fb77c57f57c8520 100644 (file)
 #define VISU_FREE_SCALAR_BARS       4081
 #define VISU_SHOW_ANIMATION         4082
 
+#define VISU_PLOT3D_FROM_CUTPLANE   4083
+
 #endif