From 698ddbf907627a8f8ebd4abb6f32b34a3015e950 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 13 Dec 2005 07:53:54 +0000 Subject: [PATCH] Fix for Bug GVIEW10884 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 | 9 +- src/OBJECT/VISU_GaussPtsDeviceActor.cxx | 144 +++++++++++------------- src/OBJECT/VISU_GaussPtsDeviceActor.h | 18 +-- 3 files changed, 82 insertions(+), 89 deletions(-) diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 40506c1e..629f8fb6 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -114,14 +114,18 @@ VISU_GaussPtsAct myCurrentPL(NULL) { if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::VISU_GaussPtsAct - this = "<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()); diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx index 157a6b7c..c608b31d 100644 --- a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx @@ -196,6 +196,7 @@ VISU_GaussPtsDeviceActor #include #include #include +#include #include @@ -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(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); } diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.h b/src/OBJECT/VISU_GaussPtsDeviceActor.h index 6f972831..b2df8621 100644 --- a/src/OBJECT/VISU_GaussPtsDeviceActor.h +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.h @@ -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 +#include 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 mySources[6]; - vtkSmartPointer myActors[6]; + vtkSmartPointer myAppendFilter; + vtkSmartPointer 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 }; -- 2.39.2