Salome HOME
PROJECT: POST-PROCESSOR 2005 TASK: T 1.5
[modules/kernel.git] / src / VTKViewer / VTKViewer_InteractorStyleSALOME.cxx
index c2ac9c3cc00f51623b2e2a338e27bfec587c727b..6258e573f788e8d347c1b54755a0926315510224 100644 (file)
@@ -45,6 +45,7 @@
 #include "VTKViewer_Actor.h"
 #include "SALOME_Selection.h"
 #include "SALOME_ListIteratorOfListIO.hxx"
+#include "SALOME_CubeAxesActor2D.h"
 
 #include <vtkObjectFactory.h>
 #include <vtkMath.h>
@@ -146,6 +147,7 @@ vtkStandardNewMacro(VTKViewer_InteractorStyleSALOME);
 VTKViewer_InteractorStyleSALOME::VTKViewer_InteractorStyleSALOME() 
 {
   m_Trihedron = 0;
+  m_CubeAxes = 0;
   this->MotionFactor = 10.0;
   this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE;
   this->RadianToDegree = 180.0 / vtkMath::Pi();
@@ -171,6 +173,8 @@ VTKViewer_InteractorStyleSALOME::~VTKViewer_InteractorStyleSALOME()
 void VTKViewer_InteractorStyleSALOME::setPreselectionProp(const double& theRed, const double& theGreen, 
                                                          const double& theBlue, const int& theWidth) 
 {
+  if ( myPreSelectionActor->GetProperty() == 0 )
+    return;
   myPreSelectionActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
   myPreSelectionActor->GetProperty()->SetLineWidth(theWidth);
   myPreSelectionActor->GetProperty()->SetPointSize(theWidth);
@@ -199,6 +203,10 @@ void VTKViewer_InteractorStyleSALOME::setTriedron(VTKViewer_Trihedron* theTrihed
   m_Trihedron = theTrihedron;
 }
 
+void VTKViewer_InteractorStyleSALOME::setCubeAxes(SALOME_CubeAxesActor2D* theCubeAxes){
+  m_CubeAxes = theCubeAxes;
+}
+
 //----------------------------------------------------------------------------
 void VTKViewer_InteractorStyleSALOME::RotateXY(int dx, int dy)
 {
@@ -622,20 +630,29 @@ void VTKViewer_InteractorStyleSALOME::startFitArea()
 //----------------------------------------------------------------------------
 void  VTKViewer_InteractorStyleSALOME::ViewFitAll() {
   int aTriedronWasVisible = false;
+  int aCubeAxesWasVisible = false;
   if(m_Trihedron){
     aTriedronWasVisible = m_Trihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
     if(aTriedronWasVisible) m_Trihedron->VisibilityOff();
   }
+  if(m_CubeAxes){
+    aCubeAxesWasVisible = m_CubeAxes->GetVisibility();
+    if(aCubeAxesWasVisible) m_CubeAxes->VisibilityOff();
+  }
 
   if(m_Trihedron->GetVisibleActorCount(CurrentRenderer)){
     m_Trihedron->VisibilityOff();
+    m_CubeAxes->VisibilityOff();
     ::ResetCamera(CurrentRenderer);
   }else{
     m_Trihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
+    m_CubeAxes->SetVisibility(2);
     ::ResetCamera(CurrentRenderer,true);
   }
   if(aTriedronWasVisible) m_Trihedron->VisibilityOn();
   else m_Trihedron->VisibilityOff();
+  if(aCubeAxesWasVisible) m_CubeAxes->VisibilityOn();
+  else m_CubeAxes->VisibilityOff();
   ::ResetCameraClippingRange(CurrentRenderer);
 }
 
@@ -835,7 +852,7 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation()
       rect = rect.normalize();
       if (State == VTK_INTERACTOR_STYLE_CAMERA_FIT) {
         // making fit rect opeation 
-        int w, h, x, y;
+        int w, h;
         m_Interactor->GetSize(w, h);
         int x1, y1, x2, y2;
         x1 = rect.left(); 
@@ -965,7 +982,7 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation()
          //      vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
          QRect rect(myPoint, myOtherPoint);
          rect = rect.normalize();
-         int w, h, x, y;
+         int w, h;
          m_Interactor->GetSize(w, h);
          int x1, y1, x2, y2;
          x1 = rect.left(); 
@@ -1215,6 +1232,12 @@ void VTKViewer_InteractorStyleSALOME::onCursorMove(QPoint mousePos) {
 
   SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
 
+  if (SActor && myPreSelectionActor){
+    float aPos[3];
+    SActor->GetPosition(aPos);
+    myPreSelectionActor->SetPosition(aPos);
+  }
+
   if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
     int aVtkId = picker->GetCellId();
     if ( aVtkId >= 0 ) {
@@ -1272,7 +1295,7 @@ void VTKViewer_InteractorStyleSALOME::onCursorMove(QPoint mousePos) {
       }
     }
   }
-  else if ( vtkPicker* picker = vtkPicker::SafeDownCast(aPicker) ) {
+  else if ( vtkPicker::SafeDownCast(aPicker) ) {
     if ( SActor ) {
       if ( myPreViewActor != SActor ) {
        if ( myPreViewActor != NULL ) {
@@ -1472,6 +1495,20 @@ Handle(VTKViewer_Filter) VTKViewer_InteractorStyleSALOME::GetFilter( const int t
   return IsFilterPresent( theId ) ? myFilters[ theId ] : Handle(VTKViewer_Filter)();
 }
 
+void VTKViewer_InteractorStyleSALOME::IncrementalPan( const int incrX, const int incrY )
+{
+  this->PanXY( incrX, incrY, 0, 0 );
+}
+
+void VTKViewer_InteractorStyleSALOME::IncrementalZoom( const int incr )
+{
+  this->DollyXY( incr, incr );
+}
+
+void VTKViewer_InteractorStyleSALOME::IncrementalRotate( const int incrX, const int incrY )
+{
+  this->RotateXY( incrX, -incrY );
+}