]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug GVIEW10884
authorapo <apo@opencascade.com>
Tue, 13 Dec 2005 07:53:54 +0000 (07:53 +0000)
committerapo <apo@opencascade.com>
Tue, 13 Dec 2005 07:53:54 +0000 (07:53 +0000)
   Specific cursor (six pyramids) is not shown and operated in Main Viewer in case ?Picking? is activated without of any type of segmentation cursor and Deformed Shape presentation is used.

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

index 40506c1e92269853de5d013a04ef24138db82522..629f8fb6b3baee0c345683159a3cb0cd2c7fdc4a 100644 (file)
@@ -114,14 +114,18 @@ VISU_GaussPtsAct
   myCurrentPL(NULL)
 {
   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::VISU_GaussPtsAct - this = "<<this);
-  
 
   myEventCallbackCommand->Delete();
   myDeviceActor->Delete();
   myTextActor->Delete();
 
   myCursorPyramid->Delete();
+  myCursorPyramid->SetPickable(0);
+  myCursorPyramid->SetVisibility(0);
+
   myCursorPyramidSelected->Delete();
+  myCursorPyramidSelected->SetPickable(0);
+  myCursorPyramidSelected->SetVisibility(0);
 
   myCellSource->Delete();
   myCellActor->Delete();
@@ -860,6 +864,9 @@ void
 VISU_GaussPtsAct
 ::UpdatePickingSettings()
 {
+  if(!myPickingSettings || myPickingSettings->GetInitial())
+    return;
+
   myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition());
   myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency());
 
index 157a6b7c9481e3324517da5c661920263aa91d60..c608b31d78fa0619577e33d861002f6347b50c88 100644 (file)
@@ -196,6 +196,7 @@ VISU_GaussPtsDeviceActor
 #include <vtkActor.h>
 #include <vtkProperty.h>
 #include <vtkConeSource.h>
+#include <vtkAppendPolyData.h>
 #include <vtkPolyDataMapper.h>
 
 
@@ -207,77 +208,62 @@ VISU_CursorPyramid
 ::VISU_CursorPyramid():
   myHeight(10.0),
   myRadius(5.0),
-  myNbCones(6)
+  myNbCones(6),
+  myAppendFilter(vtkAppendPolyData::New()),
+  myMapper(vtkPolyDataMapper::New())
 {
+  myAppendFilter->Delete();
+  myMapper->Delete();
+
+  myMapper->SetInput(myAppendFilter->GetOutput());
+
   for(int i = 0; i < myNbCones; i++){
     vtkConeSource* aConeSource = vtkConeSource::New();
+    myAppendFilter->AddInput(aConeSource->GetOutput());
     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;
+    aConeSource->Delete();
   }
 }
 
 
 //----------------------------------------------------------------------------
-int
-VISU_CursorPyramid
-::RenderOpaqueGeometry(vtkViewport *theViewport)
-{
-  if(vtkRenderer* aRenderer = dynamic_cast<vtkRenderer*>(theViewport)){
-    Render(aRenderer,GetMapper());
-    return 1;
-  }
-  return 0;
-}
-
 void
 VISU_CursorPyramid
 ::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 (this->Mapper == NULL)
+    {
+    vtkErrorMacro("No mapper for actor.");
+    return;
     }
   
-    if(vtkTexture* aTexture = anActor->GetTexture())
-      aTexture->Render(ren);
-
-    anActor->Render(ren,aMapper);  
-    this->EstimatedRenderTime += aMapper->GetTimeToDraw();
-  }
+  // render the property
+  if (!this->Property)
+    {
+    // force creation of a property
+    this->GetProperty();
+    }
+  this->Property->Render(this, ren);
+  if (this->BackfaceProperty)
+    {
+    this->BackfaceProperty->BackfaceRender(this, ren);
+    this->Device->SetBackfaceProperty(this->BackfaceProperty);
+    }
+  this->Device->SetProperty(this->Property);  
+  
+  // render the texture
+  if (this->Texture)
+    {
+    this->Texture->Render(ren);
+    }
+  
+  // make sure the device has the same matrix
+  vtkMatrix4x4 *matrix = this->Device->GetUserMatrix();
+  this->GetMatrix(matrix);
+  
+  this->Device->Render(ren,Mapper);  
+  this->EstimatedRenderTime = Mapper->GetTimeToDraw();
 }
 
 
@@ -301,7 +287,7 @@ void
 VISU_CursorPyramid
 ::SetHeight(float theHeight)
 {
-  Init(theHeight, myRadius, myPos, myColor);
+  Init(theHeight, myRadius, GetPosition(), GetProperty()->GetColor());
 }
 
 //----------------------------------------------------------------------------
@@ -312,44 +298,44 @@ VISU_CursorPyramid
        float thePos[3],
        float theColor[3])
 {
-  int i;
-  myHeight=theHeight;
-  myRadius=theRadius;
-  for (i=0; i<3; ++i){
-    myPos[i]=thePos[i];
-    myColor[i]=theColor[i];
-  }
-  for(i = 0; i < myNbCones; ++i){
+  SetPosition(thePos[0],thePos[1],thePos[2]);
+  GetProperty()->SetColor(theColor);
+  SetMapper(myMapper.GetPointer());
+
+  myHeight = theHeight;
+  myRadius = theRadius;
+
+  for(int i = 0; i < myNbCones; ++i){
     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.
     aSource->SetAngle(20.0);
-    
-    vtkActor* anActor = myActors[i].GetPointer();
-    anActor->SetPosition(thePos[0],thePos[1],thePos[2]);
-    anActor->GetProperty()->SetColor(theColor);
   }
   
-  float aD = -0.5*theHeight - theRadius;
+  float aDisplacement = -0.5*theHeight - theRadius;
   
   // X
-  mySources[0]->SetCenter(aD, 0.,0.);
-  mySources[1]->SetCenter(aD, 0.,0.);
+  mySources[0]->SetDirection(1.0, 0.0, 0.0);
+  mySources[0]->SetCenter(aDisplacement, 0.0, 0.0);
+
+  // It is impossible to inverse direction around X axis (VTK bug)
+  mySources[1]->SetDirection(-VTK_LARGE_FLOAT, 1.0, 0.0); // A workaround
+  mySources[1]->SetCenter(-aDisplacement, 0.0, 0.0);
   
   // Y
-  mySources[2]->SetDirection(0., 1., 0.);
-  mySources[2]->SetCenter(0, aD, 0.);
+  mySources[2]->SetDirection(0.0, 1.0, 0.0);
+  mySources[2]->SetCenter(0.0, aDisplacement, 0.0);
   
-  mySources[3]->SetDirection(0., 1., 0.); 
-  mySources[3]->SetCenter(0., aD, 0.);
+  mySources[3]->SetDirection(0.0, -1.0, 0.0); 
+  mySources[3]->SetCenter(0.0, -aDisplacement, 0.0);
   
   // Z
-  mySources[4]->SetDirection(0., 0., 1.); 
-  mySources[4]->SetCenter(0, 0., aD);
+  mySources[4]->SetDirection(0.0, 0.0, 1.0); 
+  mySources[4]->SetCenter(0.0, 0.0, aDisplacement);
   
-  mySources[5]->SetDirection(0., 0., 1.); 
-  mySources[5]->SetCenter(0., 0., aD);
+  mySources[5]->SetDirection(0.0, 0.0, -1.0); 
+  mySources[5]->SetCenter(0.0, 0.0, -aDisplacement);
 }
 
 
index 6f97283186c41ea4c77fd4c4cef115c3dd34fc06..b2df8621c8c87411f44b249c465ca157352f6d81 100644 (file)
@@ -92,18 +92,19 @@ class VISU_GaussPtsDeviceActor: public vtkLODActor
   VISU_GaussPtsDeviceActor();
   ~VISU_GaussPtsDeviceActor();
 
+ private:
   VISU_GaussPtsDeviceActor(const VISU_GaussPtsDeviceActor&); // Not implemented
   void operator=(const VISU_GaussPtsDeviceActor&); // Not implemented
-
 };
 
 
 //============================================================================
 class vtkActor;
 class vtkConeSource;
+class vtkAppendPolyData;
 class vtkPolyDataMapper;
 
-#include <vtkObject.h>
+#include <vtkLODActor.h>
 
 class VISU_CursorPyramid : public vtkLODActor 
 {
@@ -114,10 +115,6 @@ public:
   VISU_CursorPyramid* 
   New();
 
-  virtual
-  int
-  RenderOpaqueGeometry(vtkViewport *ren);
-
   virtual
   void
   Render(vtkRenderer *, vtkMapper *);
@@ -141,12 +138,15 @@ protected:
 
   int myNbCones;
   vtkSmartPointer<vtkConeSource> mySources[6];
-  vtkSmartPointer<vtkActor> myActors[6];
+  vtkSmartPointer<vtkAppendPolyData> myAppendFilter;
+  vtkSmartPointer<vtkPolyDataMapper> myMapper;
   //
   float myHeight;
   float myRadius;
-  float myPos[3];
-  float myColor[3];
+
+ private:
+  VISU_CursorPyramid(const VISU_CursorPyramid&); // Not implemented
+  void operator=(const VISU_CursorPyramid&); // Not implemented
 };