]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Improvement NPAL18030 EDF 610 VISU (to be able to translate a gauss point presentation).
authorrnv <rnv@opencascade.com>
Tue, 20 May 2008 10:27:45 +0000 (10:27 +0000)
committerrnv <rnv@opencascade.com>
Tue, 20 May 2008 10:27:45 +0000 (10:27 +0000)
src/OBJECT/VISU_GaussPtsAct.cxx
src/OBJECT/VISU_GaussPtsAct.h
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_OffsetDlg.cxx
src/VISUGUI/VisuGUI_OffsetDlg.h

index c9514f44f68bbabf2156ffa6543b37c9fa653d10..b75073e39cbd353f97008f0b888f41d12a91eecf 100644 (file)
@@ -42,6 +42,7 @@
 #include <vtkCamera.h>
 #include <vtkRenderer.h>
 #include <vtkPointPicker.h>
+#include <vtkMatrix4x4.h>
 #include <vtkScalarBarWidget.h>
 #include <vtkTextMapper.h>
 #include <vtkTextProperty.h>
@@ -53,6 +54,7 @@
 #include <vtkPolyDataMapper.h>
 #include <vtkPolyData.h>
 #include <vtkActor.h>
+#include <vtkTransform.h>
 
 #include <vtkObjectFactory.h>
 #include <vtkCallbackCommand.h>
@@ -154,7 +156,10 @@ VISU_GaussPtsAct
   myEventCallbackCommand->SetClientData(this); 
   myEventCallbackCommand->SetCallback(VISU_GaussPtsAct::ProcessEvents);
 
+  vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
+
   myDeviceActor->SetProperty(GetProperty());
+  myDeviceActor->SetUserMatrix(aMatrix);
   myDeviceActor->SetVisibility(true);
   myDeviceActor->SetPickable(false);
 
@@ -174,6 +179,7 @@ VISU_GaussPtsAct
   myScalarBarCtrl->Delete();
 
   myMapper->Delete();
+  aMatrix->Delete();
 }
 
 VISU_GaussPtsAct
@@ -330,6 +336,7 @@ int
 VISU_GaussPtsAct
 ::RenderOpaqueGeometry(vtkViewport *viewport)
 {
+  GetMatrix(myDeviceActor->GetUserMatrix());
   return 1;
 }
 
@@ -337,6 +344,7 @@ int
 VISU_GaussPtsAct
 ::RenderTranslucentGeometry(vtkViewport *viewport)
 {
+  GetMatrix(myDeviceActor->GetUserMatrix());
   return 1;
 }
 
@@ -733,7 +741,23 @@ VISU_GaussPtsAct
       if(myIsPreselected){
        anIsChanged = (myLastPreHighlightObjID != anObjId);
        if(anIsChanged){
-         vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
+         vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);          
+          //Take into account translation
+          vtkFloatingPointType aLocalNodeCoord[3];
+          this->Transform->Push();
+          this->Transform->PostMultiply();
+          this->Transform->Identity();
+          
+          this->Transform->Translate(this->Position[0],
+                                     this->Position[1],
+                                     this->Position[2]);
+          double aPosition[3];
+          this->Transform->GetPosition(aPosition);
+
+          aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0]; 
+          aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
+          aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
+
          vtkDataSet* aDataSet = GetInput();
          vtkPointData* aPointData = aDataSet->GetPointData();
          if(vtkDataArray *aScalarArray = aPointData->GetScalars()){
@@ -752,10 +776,12 @@ VISU_GaussPtsAct
                                    GetRadius(anObjId,aVtkId,aScalarArray),
                                    GetMagnification(anObjId),
                                    GetClamp(anObjId),
-                                   aNodeCoord,
+                                   aLocalNodeCoord,
                                    aColor);
            }
+            
          }
+          this->Transform->Pop();
          myLastPreHighlightObjID = anObjId;
        }
        myCursorPyramid->SetVisibility(true);
@@ -903,6 +929,13 @@ VISU_GaussPtsAct
   return false;
 }
 
+
+
+void VISU_GaussPtsAct::SetPosition(double _arg[3]){
+  Superclass::SetPosition(_arg);
+  Highlight(isHighlighted());
+}
+
 //==================================================================
 // function : Highlight
 // purpose  :
@@ -971,11 +1004,28 @@ VISU_GaussPtsAct
 
   int anObjId = aMapIndex(1);
   vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
+  if ( !aNodeCoord )
+    return;
+  //Take into account translation
+  vtkFloatingPointType aLocalNodeCoord[3];
+  this->Transform->Push();
+  this->Transform->PostMultiply();
+  this->Transform->Identity();
+  this->Transform->Translate(this->Position[0],
+                             this->Position[1],
+                             this->Position[2]);
+  double aPosition[3];
+  this->Transform->GetPosition(aPosition);
+  aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0]; 
+  aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
+  aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
+  this->Transform->Pop();
+
 
   vtkFloatingPointType aFocalPnt[3];
   aCamera->GetFocalPoint(aFocalPnt);
 
-  if ( !aNodeCoord || CheckIsSameVector( aNodeCoord, aFocalPnt, 3 ) ) 
+  if ( CheckIsSameVector(aLocalNodeCoord, aFocalPnt, 3 ) ) 
     return;
 
   // FlyTo
@@ -985,11 +1035,11 @@ VISU_GaussPtsAct
   
   anInteractor->SetDolly(0.0);
   anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber());
-  anInteractor->FlyTo(aRenderer, aNodeCoord);
+  anInteractor->FlyTo(aRenderer, aLocalNodeCoord);
   aRenderer->ResetCameraClippingRange();
   anInteractor->SetDolly(aDollyWas);
   anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
-  anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);
+  anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aLocalNodeCoord);
   //
   std::ostringstream aStr;
   //  int anObjId = aMapIndex(1);
@@ -997,8 +1047,7 @@ VISU_GaussPtsAct
   //
   vtkIdType aVtkId = GetNodeVTKID(anObjId);
   if(aVtkId >= 0){
-    vtkFloatingPointType *aNodeCoord = GetNodeCoord(anObjId);
-    vtkFloatingPointType aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.};
+    vtkFloatingPointType aWorldCoord[4] = {aLocalNodeCoord[0], aLocalNodeCoord[1], aLocalNodeCoord[2], 1.};
     //
     vtkDataSet* aDataSet = GetInput();
     vtkPointData* aDataSetAttributes = aDataSet->GetPointData();
@@ -1017,7 +1066,7 @@ VISU_GaussPtsAct
                                    GetRadius(anObjId,aVtkId,aScalarArray),
                                    GetMagnification(anObjId),
                                    GetClamp(anObjId),
-                                   aNodeCoord,
+                                   aLocalNodeCoord,
                                    myHighlightActor->GetProperty()->GetColor());
       myCursorPyramidSelected->SetVisibility(anIsVisible && theIsHighlight);
       //
@@ -1218,13 +1267,18 @@ VISU_GaussPtsAct1
 
   myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents);
 
+  vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
+
   myInsideDeviceActor->SetVisibility(false);
   myInsideDeviceActor->SetPickable(false);
+  myInsideDeviceActor->SetUserMatrix(aMatrix);
   myInsideDeviceActor->Delete();
 
   myOutsideDeviceActor->SetVisibility(false);
   myOutsideDeviceActor->SetPickable(false);
+  myOutsideDeviceActor->SetUserMatrix(aMatrix);
   myOutsideDeviceActor->Delete();
+  aMatrix->Delete();
 }
 
 VISU_GaussPtsAct1
@@ -1281,6 +1335,28 @@ VISU_GaussPtsAct1
 }
 
 
+int
+VISU_GaussPtsAct1
+::RenderOpaqueGeometry(vtkViewport *viewport)
+{
+
+  Superclass::RenderOpaqueGeometry(viewport);
+  GetMatrix(myInsideDeviceActor->GetUserMatrix());
+  GetMatrix(myOutsideDeviceActor->GetUserMatrix());
+  return 1;
+}
+
+int
+VISU_GaussPtsAct1
+::RenderTranslucentGeometry(vtkViewport *viewport)
+{ 
+  Superclass::RenderTranslucentGeometry(viewport);
+  GetMatrix(myInsideDeviceActor->GetUserMatrix());
+  GetMatrix(myOutsideDeviceActor->GetUserMatrix());
+
+  return 1;
+}
+
 //----------------------------------------------------------------------------
 void
 VISU_GaussPtsAct1
@@ -1369,7 +1445,6 @@ VISU_GaussPtsAct1
   return aPipeLine->GetMagnification();
 }
 
-
 //----------------------------------------------------------------------------
 vtkFloatingPointType 
 VISU_GaussPtsAct1
@@ -1386,11 +1461,20 @@ VISU_GaussPtsAct1
 
 
 //----------------------------------------------------------------
+
+void 
+VISU_GaussPtsAct1::SetPosition(double _arg[3]){
+  if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetPosition - this = "<<this);              
+  Superclass::SetPosition(_arg);
+  myUpdatePositionSignal(_arg);
+}
+
 void 
 VISU_GaussPtsAct1
 ::Connect(VISU_GaussPtsAct2* theActor)
 {
   mySetVisibilitySignal.connect(boost::bind(&VISU_GaussPtsAct2::SetVisibility,theActor,_1));
+  myUpdatePositionSignal.connect(boost::bind(&VISU_GaussPtsAct2::SetPosition, theActor,_1));
 }
 
 void
@@ -1582,6 +1666,12 @@ VISU_GaussPtsAct2
   Superclass::ShallowCopyPL(thePipeLine);
 }
 
+//----------------------------------------------------------------------------
+void
+VISU_GaussPtsAct2::SetPosition(double _arg[3]){
+  if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct2::SetPosition - this = "<<this);      
+  Superclass::SetPosition(_arg);
+}
 
 //----------------------------------------------------------------------------
 void
index 5cf5086f746597e2c12b61ffc52f4d49f35ed857..4685f60dc9b00464913aa8d14879ba8e96369f3e 100644 (file)
@@ -132,6 +132,10 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor
   VISU::TGaussPtsActorFactory*
   GetGaussPtsFactory();    
 
+  virtual
+  void 
+  SetPosition(double _arg[3]);
+
   //----------------------------------------------------------------------------
   //! Add actor to the renderer.
   virtual
@@ -399,6 +403,20 @@ class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct
   void
   SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
 
+  //! Redefined method of rendering the Opaque Geometry.
+  virtual
+  int
+  RenderOpaqueGeometry(vtkViewport *viewport);
+
+  //! Redefined method of rendering the Translucent Geometry.
+  virtual
+  int
+  RenderTranslucentGeometry(vtkViewport *viewport);
+                     
+  virtual
+  void 
+  SetPosition(double _arg[3]);
+
   //! Gets memory size used by the instance (bytes).
   virtual
   unsigned long int
@@ -448,6 +466,7 @@ class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct
   OnInteractorEvent(unsigned long theEvent);
 
   boost::signal1<void,int> mySetVisibilitySignal;
+  boost::signal1<void,double*> myUpdatePositionSignal;
   VISU_OutsideCursorSettings* myOutsideCursorSettings;
 
   //----------------------------------------------------------------------------
@@ -489,7 +508,11 @@ class VTKOCC_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct
   virtual
   unsigned long int
   GetMemorySize();
+                     
+  virtual
+  void 
+  SetPosition(double _arg[3]);
+  
  protected:
   //----------------------------------------------------------------------------
   VISU_GaussPtsAct2();
index 37b579c7b97c6f0b3402b80c2561e4923d3e520a..66ba70cfc88772c03067750213bf60849d2a0369 100644 (file)
@@ -2063,29 +2063,7 @@ VisuGUI
 {
   if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
   VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
-
-  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
-  SALOME_ListIO aListIO;
-  aSelectionMgr->selectedObjects(aListIO);
-
-  SalomeApp_Study* aStudy = GetAppStudy(this);
-  SALOME_ListIteratorOfListIO anIter(aListIO);
-  for (; anIter.More(); anIter.Next()) {
-    Handle(SALOME_InteractiveObject) anIO = anIter.Value();
-    if (anIO->hasEntry()) {
-      QString anEntry(anIO->getEntry());
-      VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anEntry);
-      if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase))
-       aDlg->addPresentation(aPrsObject);
-      else if (VISU::PointMap3d_i* aPrs = dynamic_cast<VISU::PointMap3d_i*>(anObjectInfo.myBase)) {
-       aDlg->addPointMapPresentation(aPrs);
-      }
-    }
-  }
-  if (aDlg->getPrsCount() > 0)
-    aDlg->show();
-  else
-    delete aDlg;
+  aDlg->exec();
 }
 
 void
@@ -2690,7 +2668,7 @@ VisuGUI
   mgr->setRule( action( VISU_DISPLAY ), aDisplayRule, true );
   mgr->setRule( action( VISU_DISPLAY_ONLY ), aDOnlyRule, true );
 
-  aRule = "selcount>0 and $type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "}";
+  aRule = "selcount>0 and $type in {'VISU::TMESH' 'VISU::TPOINTMAP3D' 'VISU::TGAUSSPOINTS'" + aPrsAll + "}";
   mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
 
   aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
index 4ae427dece0da07f78c4c449120531b108a125b6..d6af7e493a8811f428685982a4f2d3066d51cc7e 100644 (file)
@@ -27,7 +27,9 @@
 #include "VISU_Actor.h"
 
 #include "LightApp_Application.h"
+#include "SALOME_ListIteratorOfListIO.hxx"
 #include "SalomeApp_Application.h"
+#include "LightApp_SelectionMgr.h"
 #include "SVTK_ViewWindow.h"
 #include "SVTK_ViewModel.h"
 #include "SUIT_Desktop.h"
@@ -55,7 +57,8 @@
 VisuGUI_OffsetDlg::VisuGUI_OffsetDlg (VisuGUI* theModule)
 : QDialog(VISU::GetDesktop(theModule), 0, false, WStyle_Customize |
           WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
-myModule(theModule)
+  myModule(theModule),
+  mySelectionMgr(VISU::GetSelectionMgr(theModule))
 {
   myPrsList.setAutoDelete(false);
   myPointMapList.setAutoDelete(false);
@@ -132,6 +135,49 @@ myModule(theModule)
   connect(buttonApply,  SIGNAL(clicked()), this, SLOT(onApply()));
   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(onHelp()));
+  connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged()));
+  
+  onSelectionChanged();
+  show();
+}
+
+
+void VisuGUI_OffsetDlg::show(){
+  if(getPrsCount() > 0 )
+    QDialog::show();
+}
+
+void VisuGUI_OffsetDlg::onSelectionChanged(){
+  if(!mySelectionMgr)
+    return;
+  
+  //Clear old selection
+  clearPresentations();
+
+  SALOME_ListIO aListIO;
+  mySelectionMgr->selectedObjects(aListIO);
+
+  SalomeApp_Study* aStudy = VISU::GetAppStudy(myModule);
+  SALOME_ListIteratorOfListIO anIter(aListIO);
+  for (; anIter.More(); anIter.Next()) {
+    Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+    if (anIO->hasEntry()) {
+      QString anEntry(anIO->getEntry());
+      VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anEntry);
+      if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase))
+       addPresentation(aPrsObject);
+      else if (VISU::PointMap3d_i* aPrs = dynamic_cast<VISU::PointMap3d_i*>(anObjectInfo.myBase)) {
+       addPointMapPresentation(aPrs);
+      }
+    }
+  }
+}
+
+void VisuGUI_OffsetDlg::clearPresentations(){
+  myPrsList.clear();
+  myPointMapList.clear();
+  myOldOffsets.clear();
+  myOldPointMapOffsets.clear();
 }
 
 void VisuGUI_OffsetDlg::addPresentation (VISU::Prs3d_i* thePrs)
@@ -199,8 +245,11 @@ void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointTyp
   if (myPrsList.count() == 0) 
     return;
 
-  if (isToSave())
+  if (isToSave()) {
     thePrs->SetOffset(theOffset[0],theOffset[1],theOffset[2]);
+    thePrs->UpdateActors();
+    return;
+  }
 
   ViewManagerList aViewManagerList;
   SalomeApp_Application* anApp = myModule->getApp();
@@ -212,11 +261,10 @@ void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointTyp
     for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
       if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
         if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
-         vw->onAdjustTrihedron();
 
           if (VISU_Actor* anActor = VISU::FindActor(vw, thePrs)) {
-            anActor->SetPosition(theOffset);
-           vw->highlight(thePrs->GetIO(), 1);
+               anActor->SetPosition(theOffset);
+            vw->onAdjustTrihedron();
             vw->getRenderer()->ResetCameraClippingRange();
             vw->Repaint();
           }
@@ -286,6 +334,7 @@ void VisuGUI_OffsetDlg::onApply()
 {
   vtkFloatingPointType anOffset[3];
   getOffset(anOffset);
+
   for (int i = 0; i < myPrsList.count(); i++) {
     updateOffset(myPrsList.at(i), anOffset);
   }
index 901365ca6bacea64ade7dd61560f038986ee4883..1c02b80bde5b28195469b0b6bf5631dc2792a672 100644 (file)
@@ -32,6 +32,7 @@
 class QCheckBox;
 class QtxDblSpinBox;
 class VisuGUI;
+class LightApp_SelectionMgr;
 
 struct OffsetStruct
 {
@@ -59,9 +60,12 @@ class VisuGUI_OffsetDlg: public QDialog
   VisuGUI_OffsetDlg (VisuGUI* theModule);
   ~VisuGUI_OffsetDlg() {};
 
+  virtual void show ();
+
   void addPresentation (VISU::Prs3d_i* thePrs);
   void addPointMapPresentation (VISU::PointMap3d_i* thePrs);
   int getPrsCount() const { return myPrsList.count() + myPointMapList.count(); }
+  void clearPresentations();
 
   void setOffset (const vtkFloatingPointType* theOffset);
   void getOffset (vtkFloatingPointType* theOffset) const;
@@ -78,12 +82,15 @@ class VisuGUI_OffsetDlg: public QDialog
   virtual void reject();
   void onApply();
   void onHelp();
+  void onSelectionChanged();
+
 
  private:
   void updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointType* theOffset);
   void updatePointMapOffset (VISU::PointMap3d_i* thePrs, vtkFloatingPointType* theOffset);
 
   VisuGUI * myModule;
+  LightApp_SelectionMgr*  mySelectionMgr;
 
   QtxDblSpinBox * myDxEdt;
   QtxDblSpinBox * myDyEdt;