//----------------------------------------------------------------------------
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
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;
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>