From: apo Date: Wed, 7 Dec 2005 14:49:00 +0000 (+0000) Subject: First step to fix Bug GVIEW10814 X-Git-Tag: TG-D5-38-2003_D2005-20-12~48 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=023903a833d6ef75958a0853f600d2db1e896c2a;p=modules%2Fvisu.git First step to fix Bug GVIEW10814 size of the cursor is not modified when changing the magnification --- diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx index 519a74da..157a6b7c 100644 --- a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx @@ -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(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 #include #include diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.h b/src/OBJECT/VISU_GaussPtsDeviceActor.h index 41f4ebd3..6f972831 100644 --- a/src/OBJECT/VISU_GaussPtsDeviceActor.h +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.h @@ -105,7 +105,7 @@ class vtkPolyDataMapper; #include -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 mySources[6]; - vtkSmartPointer myMappers[6]; vtkSmartPointer myActors[6]; // float myHeight; @@ -144,6 +148,8 @@ protected: float myPos[3]; float myColor[3]; }; + + //================================================================== // class VISU_FramedTextActor //