]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
First step to fix Bug GVIEW10814
authorapo <apo@opencascade.com>
Wed, 7 Dec 2005 14:49:00 +0000 (14:49 +0000)
committerapo <apo@opencascade.com>
Wed, 7 Dec 2005 14:49:00 +0000 (14:49 +0000)
   size of the cursor is not modified when changing the magnification

src/OBJECT/VISU_GaussPtsDeviceActor.cxx
src/OBJECT/VISU_GaussPtsDeviceActor.h

index 519a74da5ebfcfb88287aaf4e6c4ea7f1399362b..157a6b7c9481e3324517da5c661920263aa91d60 100644 (file)
@@ -202,36 +202,108 @@ VISU_GaussPtsDeviceActor
 //----------------------------------------------------------------------------
 vtkStandardNewMacro(VISU_CursorPyramid);
 
+//----------------------------------------------------------------------------
+VISU_CursorPyramid
+::VISU_CursorPyramid():
+  myHeight(10.0),
+  myRadius(5.0),
+  myNbCones(6)
+{
+  for(int i = 0; i < myNbCones; i++){
+    vtkConeSource* aConeSource = vtkConeSource::New();
+    aConeSource->SetResolution(4);
+    
+    vtkPolyDataMapper* aPolyDataMapper = vtkPolyDataMapper::New();
+    aPolyDataMapper->SetInput(aConeSource->GetOutput());
+    aConeSource->Delete();
+    
+    vtkActor* anActor = vtkActor::New();
+    anActor->SetMapper(aPolyDataMapper);
+    anActor->SetVisibility(0);
+    anActor->SetPickable(0);
+    aPolyDataMapper->Delete();
+    
+    mySources[i] = aConeSource;
+    myActors[i] = anActor; 
+    anActor->Delete();
+  }
+  
+  myActors[1]->SetOrientation(0.0, 180.0, 0.0);
+  myActors[3]->SetOrientation(0.0, 0.0, 180.0);
+  myActors[5]->SetOrientation(180.0, 0.0, 0.0);
+
+  for(int i = 0; i < 3; i++){
+    myColor[i] = 1.0;
+    myPos[i] = 0.0;
+  }
+}
+
 
 //----------------------------------------------------------------------------
+int
+VISU_CursorPyramid
+::RenderOpaqueGeometry(vtkViewport *theViewport)
+{
+  if(vtkRenderer* aRenderer = dynamic_cast<vtkRenderer*>(theViewport)){
+    Render(aRenderer,GetMapper());
+    return 1;
+  }
+  return 0;
+}
+
 void
 VISU_CursorPyramid
-::AddToRender(vtkRenderer* theRenderer)
-{ 
-  for(int i = 0; i < myNbCones; ++i)
-    theRenderer->AddActor(myActors[i].GetPointer());
+::Render(vtkRenderer *ren, vtkMapper *vtkNotUsed(m))
+{
+  this->EstimatedRenderTime = 0.0;
+  for(int i = 0; i < myNbCones; i++){
+    vtkActor* anActor = myActors[i].GetPointer();
+    vtkMapper* aMapper = anActor->GetMapper();
+
+    if(!aMapper)
+      continue;
+    
+    vtkProperty* aProperty = anActor->GetProperty();
+    aProperty->Render(this, ren);
+    
+    if(vtkProperty* aBackfaceProperty = anActor->GetBackfaceProperty()){
+      aBackfaceProperty->Render(this, ren);
+      anActor->SetBackfaceProperty(aBackfaceProperty);
+      anActor->SetProperty(aProperty);  
+    }
+  
+    if(vtkTexture* aTexture = anActor->GetTexture())
+      aTexture->Render(ren);
+
+    anActor->Render(ren,aMapper);  
+    this->EstimatedRenderTime += aMapper->GetTimeToDraw();
+  }
 }
 
+
+//----------------------------------------------------------------------------
 void
 VISU_CursorPyramid
-::RemoveFromRender(vtkRenderer* theRenderer)
+::AddToRender(vtkRenderer* theRenderer)
 { 
-  for(int i = 0; i < myNbCones; ++i)
-    theRenderer->RemoveActor(myActors[i].GetPointer());
+  theRenderer->AddActor(this);
 }
 
 void
 VISU_CursorPyramid
-::SetVisibility(int theVisibility)
-{
-  for(int i = 0; i < myNbCones; ++i)
-    myActors[i]->SetVisibility(theVisibility);
+::RemoveFromRender(vtkRenderer* theRenderer)
+{ 
+  theRenderer->RemoveActor(this);
 }
+
 //----------------------------------------------------------------------------
-void VISU_CursorPyramid::SetHeight(float theHeight)
+void 
+VISU_CursorPyramid
+::SetHeight(float theHeight)
 {
   Init(theHeight, myRadius, myPos, myColor);
 }
+
 //----------------------------------------------------------------------------
 void
 VISU_CursorPyramid
@@ -248,13 +320,15 @@ VISU_CursorPyramid
     myColor[i]=theColor[i];
   }
   for(i = 0; i < myNbCones; ++i){
-    mySources[i]->SetHeight(theHeight);
+    vtkConeSource* aSource = mySources[i].GetPointer();
+    aSource->SetHeight(theHeight);
     // Set the angle of the cone. As a side effect, the angle plus height sets 
     // the base radius of the cone.
-    mySources[i]->SetAngle(20.0);
+    aSource->SetAngle(20.0);
     
-    myActors[i]->SetPosition(thePos[0],thePos[1],thePos[2]);
-    myActors[i]->GetProperty()->SetColor(theColor);
+    vtkActor* anActor = myActors[i].GetPointer();
+    anActor->SetPosition(thePos[0],thePos[1],thePos[2]);
+    anActor->GetProperty()->SetColor(theColor);
   }
   
   float aD = -0.5*theHeight - theRadius;
@@ -278,44 +352,8 @@ VISU_CursorPyramid
   mySources[5]->SetCenter(0., 0., aD);
 }
 
-//----------------------------------------------------------------------------
-VISU_CursorPyramid
-::VISU_CursorPyramid():
-  myNbCones(6)
-{
-  int i;
-  for(i = 0; i < myNbCones; i++){
-    vtkConeSource* aConeSource = vtkConeSource::New();
-    aConeSource->SetResolution(4);
-    
-    vtkPolyDataMapper* aPolyDataMapper = vtkPolyDataMapper::New();
-    aPolyDataMapper->SetInput(aConeSource->GetOutput());
-    aConeSource->Delete();
-    
-    vtkActor* anActor = vtkActor::New();
-    anActor->SetMapper(aPolyDataMapper);
-    anActor->SetVisibility(0);
-    anActor->SetPickable(0);
-    aPolyDataMapper->Delete();
-    
-    mySources[i] = aConeSource;
-    myMappers[i] = aPolyDataMapper;
-    myActors[i] = anActor; 
-    anActor->Delete();
-  }
-  
-  myActors[1]->SetOrientation(0.  ,180.,0.);
-  myActors[3]->SetOrientation(0.  , 0. ,180.);
-  myActors[5]->SetOrientation(180., 0. ,0.);
-  //
-  myHeight=10.;
-  myRadius=5.;
-  for(i = 0; i < 3; ++i){ 
-    myPos[i]=0.;
-    myColor[i]=1.;
-  }
-}
 
+//----------------------------------------------------------------------------
 #include <vtkViewport.h>
 #include <vtkWindow.h>
 #include <vtkProp.h>
index 41f4ebd3b375cd9ee8c1e646caaabb1404f7547e..6f97283186c41ea4c77fd4c4cef115c3dd34fc06 100644 (file)
@@ -105,7 +105,7 @@ class vtkPolyDataMapper;
 
 #include <vtkObject.h>
 
-class VISU_CursorPyramid : public vtkObject 
+class VISU_CursorPyramid : public vtkLODActor 
 {
 public:
   vtkTypeMacro(VISU_CursorPyramid, vtkObject);
@@ -114,14 +114,19 @@ public:
   VISU_CursorPyramid* 
   New();
 
+  virtual
+  int
+  RenderOpaqueGeometry(vtkViewport *ren);
+
+  virtual
   void
-  AddToRender(vtkRenderer* theRenderer);
+  Render(vtkRenderer *, vtkMapper *);
 
   void
-  RemoveFromRender(vtkRenderer* theRenderer);
+  AddToRender(vtkRenderer* theRenderer);
 
   void
-  SetVisibility(int theVisibility);
+  RemoveFromRender(vtkRenderer* theRenderer);
 
   void
   Init(float theHeight,
@@ -136,7 +141,6 @@ protected:
 
   int myNbCones;
   vtkSmartPointer<vtkConeSource> mySources[6];
-  vtkSmartPointer<vtkPolyDataMapper> myMappers[6];
   vtkSmartPointer<vtkActor> myActors[6];
   //
   float myHeight;
@@ -144,6 +148,8 @@ protected:
   float myPos[3];
   float myColor[3];
 };
+
+
 //==================================================================
 // class VISU_FramedTextActor
 //