]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
To implement callback mechanism for Model & VTK Actor interaction
authorapo <apo@opencascade.com>
Mon, 19 Sep 2005 05:49:43 +0000 (05:49 +0000)
committerapo <apo@opencascade.com>
Mon, 19 Sep 2005 05:49:43 +0000 (05:49 +0000)
src/SVTK/SALOME_Actor.cxx
src/SVTK/SALOME_Actor.h
src/SVTK/SVTK.cxx
src/SVTK/SVTK_Renderer.cxx
src/SVTK/SVTK_View.cxx
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h

index 2e0257d44c0aa2adea37cc7475b9c8646b605305..2c427b5c898404b795d4f071ce28f9b076a7578a 100644 (file)
@@ -55,7 +55,9 @@
 #include <vtkPolyDataMapper.h>
 #include <vtkProperty.h>
 #include <vtkOutlineSource.h>
+
 #include <vtkInteractorStyle.h>
+#include <vtkRenderWindowInteractor.h>
 
 #include <TColStd_MapOfInteger.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
@@ -79,27 +81,24 @@ vtkStandardNewMacro(SALOME_Actor);
 
 //----------------------------------------------------------------------------
 SALOME_Actor
-::SALOME_Actor()
+::SALOME_Actor():
+  myRenderer(NULL),
+  myInteractor(NULL),
+  mySelectionMode(ActorSelection),
+  myIsHighlighted(false),
+  myIsPreselected(false),
+  myRepresentation(VTK_WIREFRAME),
+  myDisplayMode(0),
+  myProperty(vtkProperty::New()),
+  PreviewProperty(NULL),
+  myIsInfinite(false),
+  myIsResolveCoincidentTopology(true),
+  myStoreMapping(false),
+  myGeomFilter(VTKViewer_GeometryFilter::New()),
+  myTransformFilter(VTKViewer_TransformFilter::New())
 {
-  mySelectionMode = ActorSelection;
-  myIsHighlighted = myIsPreselected = false;
-
-  myRepresentation = 1;
-  myDisplayMode = myRepresentation - 1;
-
-  myProperty = vtkProperty::New();
-  PreviewProperty = NULL;
-
-  myIsInfinite = false;
-
-  myIsResolveCoincidentTopology = true;
-
   vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
                                                                 myPolygonOffsetUnits);
-  myStoreMapping = false;
-  myGeomFilter = VTKViewer_GeometryFilter::New();
-
-  myTransformFilter = VTKViewer_TransformFilter::New();
 
   for(int i = 0; i < 6; i++)
     myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
@@ -188,9 +187,10 @@ void
 SALOME_Actor
 ::AddToRender(vtkRenderer* theRenderer)
 {
+  myRenderer = theRenderer;
+
   theRenderer->AddActor(this);
 
-  // from VISU
   theRenderer->AddActor( myPreHighlightActor );
   theRenderer->AddActor( myHighlightActor );
   theRenderer->AddActor( myOutlineActor );
@@ -202,21 +202,33 @@ SALOME_Actor
 {
   theRenderer->RemoveActor(this);
 
-  // from VISU
   theRenderer->RemoveActor( myPreHighlightActor );
   theRenderer->RemoveActor( myHighlightActor );
   theRenderer->RemoveActor( myOutlineActor );
 }
 
+vtkRenderer*
+SALOME_Actor
+::GetRenderer()
+{
+  return myRenderer;
+}
+
+
+//----------------------------------------------------------------------------
 void
 SALOME_Actor
-::AddToInteractor(vtkRenderWindowInteractor* theInteractor)
-{}
+::SetInteractor(vtkRenderWindowInteractor* theInteractor)
+{
+  myInteractor = theInteractor;
+}
 
 void
 SALOME_Actor
-::RemoveFromInteractor(vtkRenderWindowInteractor* theInteractor)
-{}
+::Update()
+{
+  myInteractor->CreateTimer(VTKI_TIMER_UPDATE);    
+}
 
 
 //----------------------------------------------------------------------------
index ed7d6d1d28e592d59dd3864336430109457c4fd6..082c542c3a0ca1a56b11d0a790b3fb8bde41a899 100644 (file)
@@ -325,19 +325,23 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   //----------------------------------------------------------------------------
   virtual
   void
-  AddToRender( vtkRenderer* ); 
+  AddToRender(vtkRenderer* theRendere); 
 
   virtual
   void
-  RemoveFromRender( vtkRenderer* );
+  RemoveFromRender(vtkRenderer* theRendere);
 
+  vtkRenderer*
+  GetRenderer();
+
+  //----------------------------------------------------------------------------
   virtual
   void
-  AddToInteractor(vtkRenderWindowInteractor* theInteractor);
+  SetInteractor(vtkRenderWindowInteractor* theInteractor);
 
   virtual
   void
-  RemoveFromInteractor(vtkRenderWindowInteractor* theInteractor);
+  Update();
 
   //----------------------------------------------------------------------------
   virtual
@@ -391,6 +395,9 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   }
 
  protected:
+  vtkRenderWindowInteractor* myInteractor;
+  vtkRenderer* myRenderer;
+
   bool myIsResolveCoincidentTopology;
   float myPolygonOffsetFactor;
   float myPolygonOffsetUnits;
@@ -401,7 +408,7 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
   vtkProperty *PreviewProperty;
   bool myIsPreselected;
   bool myIsHighlighted;
-  int mySelectionMode;
+  Selection_Mode mySelectionMode;
 
   float myOpacity;
   int myDisplayMode;
index df2b3e9cfde1450bb91bd88748176eaeda3d6971..d1b3ec18461a48cf74614e208c4aadffdd228133 100644 (file)
 //  Module :
 //  $Header$
 
+#include "SVTK.h"
+#include "SVTK_Prs.h"
+#include "SVTK_Actor.h"
+#include "SALOME_Actor.h"
+#include "SVTK_CubeAxesActor2D.h"
+#include "SVTK_Functor.h"
+#include "SVTK_View.h"
+#include "SVTK_ViewManager.h"
+#include "SVTK_ViewModel.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_Renderer.h"
+#include "SVTK_InteractorStyle.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
+#include "SVTK_Selector.h"
+#include "SVTK_Selection.h"
+#include "SVTK_SelectionEvent.h"
+#include "SVTK_SpaceMouse.h"
+#include "SVTK_Event.h"
+#include "SVTK_ViewModelBase.h"
+
 int
 main(int argc, char** argv)
 {
index 0f09f1935670b0425f9297582f7cb15e2314926a..eba1a739091b7c1ae00c5934e3fac4053dca8103 100644 (file)
@@ -166,7 +166,7 @@ SVTK_Renderer
 ::AddActor(VTKViewer_Actor* theActor)
 {
   if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor))
-    anActor->AddToInteractor(myInteractor);
+    anActor->SetInteractor(myInteractor);
   theActor->SetTransform(GetTransform());
   theActor->AddToRender(GetDevice());
   AdjustActors();
@@ -176,8 +176,6 @@ void
 SVTK_Renderer
 ::RemoveActor(VTKViewer_Actor* theActor)
 {
-  if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor))
-    anActor->RemoveFromInteractor(myInteractor);
   theActor->SetTransform(NULL);
   theActor->RemoveFromRender(GetDevice());
   AdjustActors();
index bc2dc2c752cea0ec674b78b714b22c7462b7dc1f..014ff3834c2eaaa8727ae7f031d3aa6bb93c5632 100644 (file)
@@ -1091,14 +1091,15 @@ SVTK_View
 ::Display(SALOME_Actor* theActor, 
          bool theIsUpdate)
 {
-  GetRenderer()->AddActor(theActor);
+  if(!isInViewer(theActor->getIO()))
+    GetRenderer()->AddActor(theActor);
+
   theActor->SetVisibility(true);
 
   if(theIsUpdate)
     Repaint();
 }
 
-
 void
 SVTK_View
 ::Display(const Handle(SALOME_InteractiveObject)& theIObject, 
@@ -1113,6 +1114,15 @@ SVTK_View
     Repaint();
 }
 
+void
+SVTK_View
+::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject)
+{
+  EraseAll();
+  Display(theIObject);
+}
+
+
 //----------------------------------------------------------------------------
 struct TRemoveAction
 {
index 6e97aef2050ff3a9cf03659910a3da85095bd254..180a53a66c02f241b2f6f7279ef44e446612e509 100755 (executable)
@@ -232,9 +232,9 @@ SVTK_ViewWindow
 //----------------------------------------------------------------
 void
 SVTK_ViewWindow
-::highlight( const Handle(SALOME_InteractiveObject)& theIO, 
-            bool theIsHighlight, 
-            bool theIsUpdate ) 
+::highlight(const Handle(SALOME_InteractiveObject)& theIO, 
+           bool theIsHighlight, 
+           bool theIsUpdate ) 
 {
   myView->highlight( theIO, theIsHighlight, theIsUpdate );
 }
@@ -248,11 +248,41 @@ SVTK_ViewWindow
 }
 
 //----------------------------------------------------------------
-bool
+void
+SVTK_ViewWindow
+::Display(const Handle(SALOME_InteractiveObject)& theIO,
+         bool theImmediatly) 
+{
+  myView->Display(theIO,theImmediatly);
+}
+
+void
+SVTK_ViewWindow
+::Erase(const Handle(SALOME_InteractiveObject)& theIO,
+         bool theImmediatly) 
+{
+  myView->Erase(theIO,theImmediatly);
+}
+
+void
+SVTK_ViewWindow
+::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO) 
+{
+  myView->DisplayOnly(theIO);
+}
+
+void 
+SVTK_ViewWindow
+::DisplayAll() 
+{
+  myView->DisplayAll();
+}
+
+void 
 SVTK_ViewWindow
-::isVisible( const Handle(SALOME_InteractiveObject)& theIO 
+::EraseAll(
 {
-  return myView->isVisible( theIO );
+  myView->EraseAll();
 }
 
 //----------------------------------------------------------------------------
index 02a563f9fc07d0e623acb51aeb64f2cd706ce3c6..0cc14a104b9c853ff60fdfda3797f7b6d551c157 100755 (executable)
@@ -65,37 +65,73 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
   Selection_Mode
   SelectionMode() const;
   
+  virtual
   void
   SetSelectionMode(Selection_Mode theMode);
 
-  void setBackgroundColor( const QColor& );
-  QColor backgroundColor() const;
+  virtual
+  void
+  setBackgroundColor( const QColor& );
+
+  QColor
+  backgroundColor() const;
+
+  bool
+  isTrihedronDisplayed();
 
-  bool isTrihedronDisplayed();
-  bool isCubeAxesDisplayed();
+  bool
+  isCubeAxesDisplayed();
  
   /*  interactive object management */
-  void highlight( const Handle(SALOME_InteractiveObject)& IObject, 
-                  bool highlight, bool immediatly = true );
-  void unHighlightAll();
-  bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
-  bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
+  virtual
+  void
+  highlight(const Handle(SALOME_InteractiveObject)& theIO, 
+           bool theIsHighlight = true, 
+           bool theIsUpdate = true);
+  virtual
+  void
+  unHighlightAll();
+
+  bool
+  isInViewer(const Handle(SALOME_InteractiveObject)& theIObject);
+
+  bool
+  isVisible(const Handle(SALOME_InteractiveObject)& theIObject);
 
   /* selection */
-  Handle(SALOME_InteractiveObject) FindIObject(const char* Entry);
+  //----------------------------------------------------------------------------
+  Handle(SALOME_InteractiveObject) 
+  FindIObject(const char* theEntry);
   
   /* display */                
-  void Display( const Handle(SALOME_InteractiveObject)& IObject,
-                bool immediatly = true );
-  void DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject );
-  void Erase( const Handle(SALOME_InteractiveObject)& IObject,
-              bool immediatly = true );
-  void DisplayAll();
-  void EraseAll();
-  void Repaint( bool theUpdateTrihedron );
-  void Repaint() { Repaint(true); }
-
-  //apply existing transformation on adding SALOME_Actor
+  //----------------------------------------------------------------------------
+  virtual
+  void
+  Display(const Handle(SALOME_InteractiveObject)& theIObject,
+         bool theImmediatly = true);
+
+  virtual
+  void
+  DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject);
+
+  virtual
+  void
+  Erase(const Handle(SALOME_InteractiveObject)& theIObject,
+       bool theImmediatly = true);
+
+  virtual
+  void 
+  DisplayAll();
+
+  virtual
+  void 
+  EraseAll();
+
+  virtual
+  void
+  Repaint(bool theUpdateTrihedron = true);
+
+  //----------------------------------------------------------------------------
   virtual
   void 
   SetScale( double theScale[3] );
@@ -114,7 +150,10 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
   RemoveActor(VTKViewer_Actor* theActor,
              bool theIsUpdate = false);
 
-  void AdjustTrihedrons( const bool forced );
+  //----------------------------------------------------------------------------
+  virtual
+  void
+  AdjustTrihedrons(const bool theIsForced);
 
   VTKViewer_Trihedron*  
   GetTrihedron();
@@ -125,29 +164,54 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
   int  
   GetTrihedronSize() const;
 
+  virtual
   void 
   SetTrihedronSize( const int );
 
-  void SetSelectionProp(const double& theRed = 1, 
-                       const double& theGreen = 1,
-                       const double& theBlue = 0
-                       const int& theWidth = 5);
-  void SetSelectionTolerance(const double& theTolNodes = 0.025
-                            const double& theTolCell = 0.001);
+  virtual
+  void
+  SetSelectionProp(const double& theRed = 1
+                  const double& theGreen = 1,
+                  const double& theBlue = 0
+                  const int& theWidth = 5);
 
+  virtual
+  void
+  SetSelectionTolerance(const double& theTolNodes = 0.025, 
+                       const double& theTolCell = 0.001);
+  
 public slots:
-  void onSelectionChanged();
+  virtual
+  void
+  onSelectionChanged();
 
 signals:
  void selectionChanged();
 
 public slots:
-  void onFrontView(); 
-  void onBackView(); 
-  void onTopView();
-  void onBottomView();
-  void onRightView(); 
-  void onLeftView();     
+  virtual
+  void
+  onFrontView(); 
+
+  virtual
+  void
+  onBackView(); 
+
+  virtual
+  void
+  onTopView();
+
+  virtual
+  void
+  onBottomView();
+
+  virtual
+  void 
+  onRightView(); 
+
+  virtual
+  void 
+  onLeftView();     
 
   virtual
   void
@@ -157,11 +221,21 @@ public slots:
   void 
   onFitAll();
 
-  void onViewTrihedron(); 
-  void onViewCubeAxes();
+  virtual
+  void
+  onViewTrihedron(); 
+
+  virtual
+  void
+  onViewCubeAxes();
+
+  virtual
+  void
+  onAdjustTrihedron();
 
-  void onAdjustTrihedron();
-  void onAdjustCubeAxes();
+  virtual
+  void 
+  onAdjustCubeAxes();
 
 protected slots:
   void onKeyPressed(QKeyEvent* event);