]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
New functionality: creation of Plot3d using a CutPlanes presentation with a one plane
authorvsv <vsv@opencascade.com>
Thu, 18 May 2006 08:46:10 +0000 (08:46 +0000)
committervsv <vsv@opencascade.com>
Thu, 18 May 2006 08:46:10 +0000 (08:46 +0000)
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_Plot3DDlg.cxx
src/VISUGUI/VisuGUI_Plot3DDlg.h

index 98bb59d630bb09b7339e5bc06314ce08202ca1c8..9bd0664f14a6dff1d8852abae7998ae5c1295071 100644 (file)
@@ -2279,10 +2279,10 @@ createActions()
                 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()));
+  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
@@ -2706,23 +2706,25 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q
        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;
-         //    }
-         //  }
-         //}
+         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) {
+            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);
+  if (isOneCutPlane)
+    action( VISU_PLOT3D_FROM_CUTPLANE )->addTo(theMenu);
 
   theMenu->insertSeparator();
 
@@ -3222,99 +3224,99 @@ LightApp_Displayer* VisuGUI::displayer()
 
 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"));
-//  }
+ _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 b80b5417084f02bb2b8069eca9e268d936802dd9..2662f9ff77915c863518ce96d60bf5f5fc157799 100644 (file)
@@ -500,6 +500,35 @@ bool VisuGUI_Plot3DPane::check()
   return true;
 }
 
+void VisuGUI_Plot3DPane::setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos)
+{
+  // Set plane
+  int id;
+  switch (theOrientation) {
+  case VISU::Plot3D::XY: id = 0; break;
+  case VISU::Plot3D::YZ: id = 1; break;
+  default: id = 2;
+  }
+  GBOrientation->setButton(id);
+  orientationChanged(id);
+  GBOrientation->setEnabled(false);
+
+
+  // Set rotation
+  Rot1->setValue(theXRotation * 180./PI);
+  Rot1->setEnabled(false);
+  Rot2->setValue(theYRotation * 180./PI);
+  Rot2->setEnabled(false);
+
+  // Set position
+  RelativeChkB->setChecked(false);
+  onRelativePos(false); // update range
+  PositionSpn->setValue(thePlanePos);
+  RelativeChkB->setEnabled(false);
+  PositionSpn->setEnabled(false);
+}
+
+
 //=======================================================================
 //function : Constructor
 //purpose  :
@@ -599,3 +628,12 @@ void VisuGUI_Plot3DDlg::onHelp()
                           QObject::tr("BUT_OK"));
   }
 }
+
+//=======================================================================
+//function : setPlane
+//purpose  :
+//=======================================================================
+void VisuGUI_Plot3DDlg::setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos)
+{
+  myIsoPane->setPlane(theOrientation, theXRotation, theYRotation, thePlanePos);
+}
index 325441f5bef61e32e54858af60c596aa61f927b1..04065b26ca89495e61c1e9f8d7a39e9670c1edc1 100644 (file)
@@ -61,6 +61,8 @@ class VisuGUI_Plot3DPane : public QVBox
 
   VISU::Plot3D_i* GetPrs() { return myPrs; }
 
+  void setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos);
+
  private:
   bool                 myInitFromPrs;
   SALOME_Actor*        myPreviewActor;
@@ -107,6 +109,8 @@ class VisuGUI_Plot3DDlg : public QDialog
   int storeToPrsObject (VISU::Plot3D_i* thePrs)
     { return myScalarPane->storeToPrsObject(thePrs) && myIsoPane->storeToPrsObject(thePrs); }
 
+  void setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos);
+
  protected slots:
   void accept();
   void reject();