#include "VISU_GaussPtsAct.h"
#include "VISU_GaussPointsPL.hxx"
+#include "VISU_GaussPtsDeviceActor.h"
+#include "VISU_ImplicitFunctionWidget.h"
#include "VISU_OpenGLPointSpriteMapper.hxx"
#include "SVTK_Actor.h"
#include <vtkCell.h>
#include <vtkMath.h>
+#include <vtkActor.h>
+#include <vtkConeSource.h>
+#include <vtkPolyDataMapper.h>
+
+#include <vtkViewport.h>
+
#include "utilities.h"
#ifdef _DEBUG_
static int MYDEBUG = 0;
#endif
-//
-///////////////////////////////////////////////////////////////////////////
-//
-// class: VISU_CursorPyramid
-//
-class vtkConeSource;
-class vtkRenderer;
-class vtkPolyDataMapper;
-class vtkActor;
-
-class VISU_CursorPyramid : public vtkObject {
-
+//----------------------------------------------------------------
+class VISU_CursorPyramid : public vtkObject
+{
public:
- void SetColor(const float theColor[3]);
-
- void SetColor(const float theR,
- const float theG,
- const float theB);
-
- float* Color();
-
- void SetRadius(const float theR);
-
- float Radius()const;
-
- void SetResolution(const int theResolution);
-
- int Resolution()const;
-
- void SetAngle(const float theAngle);
-
- float Angle()const;
-
- void SetHeight(const float theHeight);
-
- float Height()const;
-
- void AddToRender(vtkRenderer* theRenderer);
+ vtkTypeMacro(VISU_CursorPyramid, vtkObject);
- void RemoveFromRender(vtkRenderer* theRenderer);
+ static
+ VISU_CursorPyramid*
+ New();
- void SetVisibility (int);
+ void
+ AddToRender(vtkRenderer* theRenderer)
+ {
+ for(int i = 0; i < myNbCones; ++i)
+ theRenderer->AddActor(myActors[i].GetPointer());
+ }
- int GetVisibility () const;
+ void
+ RemoveFromRender(vtkRenderer* theRenderer)
+ {
+ for(int i = 0; i < myNbCones; ++i)
+ theRenderer->RemoveActor(myActors[i].GetPointer());
+ }
- void SetPosition(float theX, float theY, float theZ);
+ void
+ SetVisibility(int theVisibility)
+ {
+ for(int i = 0; i < myNbCones; ++i)
+ myActors[i]->SetVisibility(theVisibility);
+ }
- void SetPosition(float thePosition[3]);
+ void
+ Init(float theHeight,
+ float theRadius,
+ float thePos[3],
+ float theColor[3])
+ {
+ for(int i = 0; i < myNbCones; ++i){
+ mySources[i]->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);
+
+ myActors[i]->SetPosition(thePos[0],thePos[1],thePos[2]);
+ myActors[i]->GetProperty()->SetColor(theColor);
+ }
+
+ float aD = -0.5*theHeight - theRadius;
- void Init();
- //
- vtkTypeMacro(VISU_CursorPyramid, vtkObject);
+ // X
+ mySources[0]->SetCenter(aD, 0.,0.);
+ mySources[1]->SetCenter(aD, 0.,0.);
- static VISU_CursorPyramid* New();
- //
+ // Y
+ mySources[2]->SetDirection(0., 1., 0.);
+ mySources[2]->SetCenter(0, aD, 0.);
-protected:
- VISU_CursorPyramid();
+ mySources[3]->SetDirection(0., 1., 0.);
+ mySources[3]->SetCenter(0., aD, 0.);
- virtual ~VISU_CursorPyramid();
+ // Z
+ mySources[4]->SetDirection(0., 0., 1.);
+ mySources[4]->SetCenter(0, 0., aD);
+ mySources[5]->SetDirection(0., 0., 1.);
+ mySources[5]->SetCenter(0., 0., aD);
+ }
protected:
- // sphere parameters
- float myRadius;
- // cone parameters
- int myResolution;
- float myAngle;
- float myHeight;
- //
+ VISU_CursorPyramid():
+ 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;
+ 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.);
+ }
+
int myNbCones;
- float myColor[3];
vtkSmartPointer<vtkConeSource> mySources[6];
vtkSmartPointer<vtkPolyDataMapper> myMappers[6];
vtkSmartPointer<vtkActor> myActors[6];
};
-//
-///////////////////////////////////////////////////////////////////////////
-//
-// class: VISU_GPTextActor
-//
-class vtkViewport;
+vtkStandardNewMacro(VISU_CursorPyramid);
+
+
+//----------------------------------------------------------------
class VISU_GPTextActor : public vtkTextActor
{
-protected:
- VISU_GPTextActor();
- virtual ~VISU_GPTextActor();
-
public:
vtkTypeMacro(VISU_GPTextActor, vtkTextActor);
- static VISU_GPTextActor* New();
- //
- void SetWorldPoint(const float theCoord[4]);
-
- float* WorldPoint();
- virtual int RenderOpaqueGeometry(vtkViewport *theViewport);
+ static
+ VISU_GPTextActor*
+ New();
+
+ void
+ Init(const float theWorldPoint[4],
+ const float theDistance = 10.0)
+ {
+ for(int i = 0; i < 4; i++)
+ myWorldPoint[i] = theWorldPoint[i];
+ }
+
+ virtual
+ int
+ RenderOpaqueGeometry(vtkViewport *theViewport)
+ {
+ float aSelectionPoint[3];
+ theViewport->SetWorldPoint(myWorldPoint);
+ theViewport->WorldToDisplay();
+ theViewport->GetDisplayPoint(aSelectionPoint);
+
+ aSelectionPoint[0] += myDistance;
+ aSelectionPoint[1] += myDistance;
+
+ SetPosition(aSelectionPoint);
+ Superclass::RenderOpaqueGeometry(theViewport);
+ }
protected:
- float myWorldPoint[4];
+ float myWorldPoint[4];
+ float myDistance;
};
-//
-///////////////////////////////////////////////////////////////////////////
-//
-// class: VISU_CursorPyramid
-//
-#include <vtkViewport.h>
-vtkStandardNewMacro(VISU_GPTextActor);// <- static VISU_GPTextActor* New()
+vtkStandardNewMacro(VISU_GPTextActor);
-//==================================================================
-// function : Constructor
-// purpose :
-//==================================================================
-VISU_GPTextActor::VISU_GPTextActor()
-{
- float aCoord[]={0.,0.,0.,1};
- //
- SetWorldPoint(aCoord);
-}
-//==================================================================
-// function : ~
-// purpose :
-//==================================================================
-VISU_GPTextActor::~VISU_GPTextActor()
-{
-}
-//==================================================================
-// function : SetWorldPoint
-// purpose :
-//==================================================================
-void VISU_GPTextActor::SetWorldPoint(const float theCoord[4])
-{
- int i;
- //
- for (i=0; i<4; ++i){
- myWorldPoint[i]=theCoord[i];
- }
-}
-//==================================================================
-// function : WorldPoint
-// purpose :
-//==================================================================
-float* VISU_GPTextActor::WorldPoint()
-{
- return myWorldPoint;
-}
-//==================================================================
-// function : RenderOpaqueGeometry
-// purpose :
-//==================================================================
-int VISU_GPTextActor::RenderOpaqueGeometry(vtkViewport *theViewport)
+
+//----------------------------------------------------------------
+VISU_GaussPtsAct*
+VISU_GaussPtsAct
+::New(bool theIsSegmented)
{
- float aSelectionPoint[3];
- //
- theViewport->SetWorldPoint(myWorldPoint);
- theViewport->WorldToDisplay();
- theViewport->GetDisplayPoint(aSelectionPoint);
- SetPosition(aSelectionPoint);
- //
- Superclass::RenderOpaqueGeometry(theViewport);
+ return new VISU_GaussPtsAct(theIsSegmented);
}
-
-//
-//VISU_GaussPtsAct
//----------------------------------------------------------------
-vtkStandardNewMacro(VISU_GaussPtsAct);
-
VISU_GaussPtsAct
-::VISU_GaussPtsAct():
+::VISU_GaussPtsAct(bool theIsSegmented):
myEventCallbackCommand(vtkCallbackCommand::New()),
- myPSMapper(VISU_OpenGLPointSpriteMapper::New()),
+ myIsSegmented(theIsSegmented),
+ myWidget(NULL),
myGaussPointsPL(NULL),
myTextMapper(vtkTextMapper::New()),
myTextActor(VISU_GPTextActor::New()),
myEventCallbackCommand->SetClientData(this);
myEventCallbackCommand->SetCallback(VISU_GaussPtsAct::ProcessEvents);
+ if(!theIsSegmented){
+ myDeviceActor = VISU_GaussPtsDeviceActor::New();
+ myDeviceActor->SetProperty(GetProperty());
+ myDeviceActor->SetVisibility(true);
+ myDeviceActor->SetPickable(false);
+ myDeviceActor->Delete();
+
+ myOutsideDeviceActor = VISU_GaussPtsDeviceActor::New();
+ myOutsideDeviceActor->SetProperty(GetProperty());
+ myOutsideDeviceActor->SetVisibility(false);
+ myOutsideDeviceActor->SetPickable(false);
+ myOutsideDeviceActor->Delete();
+ }
+ myInsideDeviceActor = VISU_GaussPtsDeviceActor::New();
+ myInsideDeviceActor->SetProperty(GetProperty());
+ myInsideDeviceActor->SetVisibility(theIsSegmented);
+ myInsideDeviceActor->SetPickable(false);
+ myInsideDeviceActor->Delete();
+
myTextMapper->Delete();
myTextActor->Delete();
- myPSMapper->Delete();
vtkTextProperty* aTextProperty = myTextMapper->GetTextProperty();
aTextProperty->SetVerticalJustification(VTK_TEXT_BOTTOM);
//
myCursorPyramid->Delete();
//
- mySphereSourceSelected=vtkSphereSource::New();
- mySphereMapperSelected=vtkPolyDataMapper::New();
- mySphereActorSelected=vtkActor::New();
- //
+ mySphereSourceSelected = vtkSphereSource::New();
mySphereSourceSelected->Delete();
+
+ mySphereMapperSelected = vtkPolyDataMapper::New();
mySphereMapperSelected->Delete();
- mySphereActorSelected->Delete();
- //
mySphereMapperSelected->SetInput(mySphereSourceSelected->GetOutput());
+
+ mySphereActorSelected = vtkActor::New();
+ mySphereActorSelected->Delete();
mySphereActorSelected->SetMapper(mySphereMapperSelected.GetPointer());
mySphereActorSelected->SetVisibility(false);
mySphereActorSelected->SetPickable(false);
- float aColorSelected[3]={1.,1.,1.};
+ float aColorSelected[3] = {1.,1.,1.};
mySphereActorSelected->GetProperty()->SetColor(aColorSelected);
//
// Cell
myCellSource = vtkUnstructuredGrid::New();
- myCellSource->Allocate();
myCellSource->Delete();
+ myCellSource->Allocate();
//
myCellMapper = vtkDataSetMapper::New();
myCellMapper->Delete();
+ myCellMapper->SetInput(myCellSource.GetPointer());
//
myCellActor = vtkActor::New();
myCellActor->Delete();
- //
- myCellMapper->SetInput(myCellSource.GetPointer());
myCellActor->SetMapper(myCellMapper.GetPointer());
myCellActor->SetVisibility(0);
myCellActor->SetPickable(0);
- //
myCellActor->GetProperty()->SetAmbient(1.0);
myCellActor->GetProperty()->SetDiffuse(0.0);
myCellActor->GetProperty()->SetRepresentationToWireframe();
VISU_GaussPtsAct
::~VISU_GaussPtsAct()
-{}
+{
+ if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::~VISU_GaussPtsAct - this = "<<this);
+}
//----------------------------------------------------------------
VISU_OpenGLPointSpriteMapper*
VISU_GaussPtsAct
::GetPSMapper()
{
- return myPSMapper.GetPointer();
+ if(!myIsSegmented)
+ return myDeviceActor->GetPSMapper();
+ else
+ return myInsideDeviceActor->GetPSMapper();
+}
+
+void
+VISU_GaussPtsAct
+::ShallowCopyPL(VISU_PipeLine* thePipeLine)
+{
+ Superclass::ShallowCopyPL(thePipeLine);
+
+ vtkPolyData* aDatsSet = GetPSMapper()->GetInput();
+ GetPSMapper()->ShallowCopy(thePipeLine->GetMapper());
+
+ // To restore mapper input from pipeline
+ GetPSMapper()->SetInput(aDatsSet);
+
+ if(VISU_GaussPointsPL* aPipeLine = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine)){
+ if(!myIsSegmented){
+ myDeviceActor->ShallowCopyPL(aPipeLine);
+ myOutsideDeviceActor->ShallowCopyPL(aPipeLine);
+ }
+ myInsideDeviceActor->ShallowCopyPL(aPipeLine);
+
+ // Restore implicit function
+ if(myWidget){
+ vtkImplicitFunction* aFunction = myWidget->ImplicitFunction();
+ if(!myIsSegmented){
+ myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(aFunction);
+ myOutsideDeviceActor->GetPipeLine()->SetExtractInside(true);
+ myOutsideDeviceActor->GetMapper()->ScalarVisibilityOff();
+ }
+ myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(aFunction);
+ }
+ }
+}
+
+vtkDataSet*
+VISU_GaussPtsAct
+::GetInput()
+{
+ vtkDataSet* aDataSet = GetMapper()->GetInput();
+ aDataSet->Update();
+ return aDataSet;
}
//----------------------------------------------------------------
::AddToRender(vtkRenderer* theRenderer)
{
Superclass::AddToRender(theRenderer);
+
+ if(!myIsSegmented){
+ myDeviceActor->AddToRender(theRenderer);
+ myOutsideDeviceActor->AddToRender(theRenderer);
+ }
+ myInsideDeviceActor->AddToRender(theRenderer);
+
theRenderer->AddActor(myTextActor.GetPointer());
theRenderer->AddActor(mySphereActor.GetPointer());
theRenderer->AddActor(mySphereActorSelected.GetPointer());
- myCursorPyramid->AddToRender(theRenderer);
theRenderer->AddActor(myCellActor.GetPointer());
+
+ myCursorPyramid->AddToRender(theRenderer);
}
void
VISU_GaussPtsAct
::RemoveFromRender(vtkRenderer* theRenderer)
{
- myCursorPyramid->RemoveFromRender(theRenderer);
+ Superclass::RemoveFromRender(theRenderer);
+
+ if(!myIsSegmented){
+ myDeviceActor->RemoveFromRender(theRenderer);
+ myOutsideDeviceActor->RemoveFromRender(theRenderer);
+ }
+ myInsideDeviceActor->RemoveFromRender(theRenderer);
+
theRenderer->RemoveActor(mySphereActor.GetPointer());
theRenderer->RemoveActor(myTextActor.GetPointer());
theRenderer->RemoveActor(mySphereActorSelected.GetPointer());
- Superclass::RemoveFromRender(theRenderer);
theRenderer->RemoveActor(myCellActor.GetPointer());
+
+ myCursorPyramid->RemoveFromRender(theRenderer);
+}
+
+void
+VISU_GaussPtsAct
+::SetTransform(VTKViewer_Transform* theTransform)
+{
+ if(!myIsSegmented){
+ myDeviceActor->SetTransform(theTransform);
+ myOutsideDeviceActor->SetTransform(theTransform);
+ }
+ myInsideDeviceActor->SetTransform(theTransform);
+
+ Superclass::SetTransform(theTransform);
+ Modified();
+}
+
+int
+VISU_GaussPtsAct
+::RenderOpaqueGeometry(vtkViewport *viewport)
+{
+ return 1;
+}
+
+int
+VISU_GaussPtsAct
+::RenderTranslucentGeometry(vtkViewport *viewport)
+{
+ return 1;
+}
+
+
+//----------------------------------------------------------------
+void
+VISU_GaussPtsAct
+::SetImplicitFunctionWidget(VISU_ImplicitFunctionWidget* theWidget)
+{
+ myWidget = theWidget;
+ theWidget->AddObserver(vtkCommand::EnableEvent,
+ myEventCallbackCommand.GetPointer(),
+ 0.0);
+ theWidget->AddObserver(vtkCommand::DisableEvent,
+ myEventCallbackCommand.GetPointer(),
+ 0.0);
+ if(!myIsSegmented)
+ myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidget->ImplicitFunction());
+ myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidget->ImplicitFunction());
+
+ if(myWidget->IsEnabled())
+ OnInteractorEvent(vtkCommand::EnableEvent);
+ else
+ OnInteractorEvent(vtkCommand::DisableEvent);
}
//----------------------------------------------------------------
+namespace
+{
+ VISU_GaussPointsPL*
+ CreatePipeLine(VISU_GaussPointsPL* thePipeLine)
+ {
+ VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New();
+ aPipeLine->ShallowCopy(thePipeLine);
+ aPipeLine->Update();
+ return thePipeLine;
+ }
+}
+
void
VISU_GaussPtsAct
::SetMapperInput(vtkDataSet* theDataSet)
{
if(vtkPolyData* aPolyData = dynamic_cast<vtkPolyData*>(theDataSet)){
- myPSMapper->SetInput(aPolyData);
- SetMapper(myPSMapper.GetPointer());
+ if(!myIsSegmented){
+ myDeviceActor->SetPipeLine(GetGaussPointsPL());
+ if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
+ myInsideDeviceActor->SetPipeLine(aPipeLine);
+ aPipeLine->Delete();
+ }
+ if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
+ myOutsideDeviceActor->SetPipeLine(aPipeLine);
+ myOutsideDeviceActor->GetMapper()->ScalarVisibilityOff();
+ myOutsideDeviceActor->GetPipeLine()->SetExtractInside(true);
+ aPipeLine->Delete();
+ }
+ }else
+ myInsideDeviceActor->SetPipeLine(GetGaussPointsPL());
+ vtkLODActor::SetMapper(GetMapper());
}
}
+vtkMapper*
+VISU_GaussPtsAct
+::GetMapper()
+{
+ return GetPSMapper();
+}
+
void
VISU_GaussPtsAct
::SetPipeLine(VISU_PipeLine* thePipeLine)
::SetVisibility(int theMode)
{
Superclass::SetVisibility(theMode);
+
+ if(!myIsSegmented){
+ myDeviceActor->SetVisibility(GetVisibility() && !myWidget->IsEnabled());
+ myOutsideDeviceActor->SetVisibility(GetVisibility() && myWidget->IsEnabled());
+ }
+ myInsideDeviceActor->SetVisibility(GetVisibility() && myWidget->IsEnabled());
+
mySetVisibilitySignal(GetVisibility());
}
return;
}
myUpdatePrs3dSignal(this);
- return;
+ break;
}
+ case vtkCommand::EnableEvent:
+ case vtkCommand::DisableEvent:
+ if(!myIsSegmented){
+ myDeviceActor->SetVisibility(GetVisibility() && !myWidget->IsEnabled());
+ myOutsideDeviceActor->SetVisibility(GetVisibility() && myWidget->IsEnabled());
+ myOutsideDeviceActor->GetPipeLine()->SetExtractInside(true);
+ myOutsideDeviceActor->GetMapper()->ScalarVisibilityOff();
+ }
+ myInsideDeviceActor->SetVisibility(GetVisibility() && myWidget->IsEnabled());
+ break;
+ default:
break;
}
}
// To calculate display (2D) position of the annotation
float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.0};
- myTextActor->SetWorldPoint(aWorldCoord);
+ myTextActor->Init(aWorldCoord);
// To prepare the annotation text
std::ostringstream aStr;
aStr<<"Global ID: "<<anObjId;
VISU_LookupTable* aLookupTable = myGaussPointsPL->GetMapperTable();
aLookupTable->GetColor(aVal,aColor);
mySphereActor->GetProperty()->SetColor(aColor);
- //
- float aMaxPointSize;
- //
- aMaxPointSize=myGaussPointsPL->GetMaxPointSize();
-
- myCursorPyramid->SetHeight(aMaxPointSize);
- myCursorPyramid->SetRadius(aRadius);
- myCursorPyramid->SetColor(aColor);
- myCursorPyramid->SetPosition(aNodeCoord);
- myCursorPyramid->Init();
+
+ myCursorPyramid->Init(myGaussPointsPL->GetMaxPointSize(),
+ aRadius,
+ aNodeCoord,
+ aColor);
}
if(vtkDataArray *aVectorArray = aCellData->GetVectors()){
myTextActor->SetVisibility(true);
mySphereActor->SetVisibility(true);
- myCursorPyramid->SetVisibility(1);
+ myCursorPyramid->SetVisibility(true);
myIsPreselected = theIsHighlight;
anIsChanged = true;
}
theSelector->AddIObject(this);
}
//
- float *aNodeCoord, aRadius, aDollyWas;
- //
- aNodeCoord = GetNodeCoord(anObjId);
- //
- aDollyWas = anIteractor->GetDolly();
+ float* aNodeCoord = GetNodeCoord(anObjId);
+ float aDollyWas = anIteractor->GetDolly();
anIteractor->SetDolly(0.0);
anIteractor->FlyTo(aRenderer,aNodeCoord);
aRenderer->ResetCameraClippingRange();
//
// To calculate display (2D) position of the annotation
float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.};
- myTextActor->SetWorldPoint(aWorldCoord);
+ myTextActor->Init(aWorldCoord);
//
// Selected
mySphereSourceSelected->SetCenter(aNodeCoord);
//
vtkDataSet* aDataSet = GetInput();
vtkCellData* aCellData = aDataSet->GetCellData();
- vtkDataArray *aScalarArray = aCellData->GetScalars();
- //
- aRadius = myGaussPointsPL->GetPointSize(anObjId, aScalarArray);
- mySphereSourceSelected->SetRadius(aRadius);
- //
- if (theSelector->HasIndex(myIO)) {
- mySphereActorSelected->SetVisibility(1);
- }
- else {
- mySphereActorSelected->SetVisibility(0);
- mySphereActor->SetVisibility(1);
+ if(vtkDataArray* aScalarArray = aCellData->GetScalars()){
+ float aRadius = myGaussPointsPL->GetPointSize(anObjId, aScalarArray);
+ mySphereSourceSelected->SetRadius(aRadius);
+ if(theSelector->HasIndex(myIO)){
+ mySphereActorSelected->SetVisibility(1);
+ }else{
+ mySphereActorSelected->SetVisibility(0);
+ mySphereActor->SetVisibility(1);
+ }
+ myTextActor->SetVisibility(1);
}
- //
- myTextActor->SetVisibility(1);
- //
if(aSelectionMode == CellSelection){
// Hilighting an element from the parent Mesh
if(theSelector->HasIndex(myIO)){
//mySphereActor->SetVisibility(aSphereVisibility);
return bRet;
}
-//
-///////////////////////////////////////////////////////////////////////////
-//
-// class: VISU_CursorPyramid
-//
-#include <vtkActor.h>
-#include <vtkConeSource.h>
-#include <vtkPolyDataMapper.h>
-
-vtkStandardNewMacro(VISU_CursorPyramid);
-
-//==================================================================
-// function : Constructor
-// purpose :
-//==================================================================
-VISU_CursorPyramid::VISU_CursorPyramid()
-{
- int i;
- //
- myResolution=4;
- myAngle=20.;
- myHeight=1.;
- myRadius=4.;
- myNbCones=6;
- //
- for (i=0; i<myNbCones; ++i) {
- mySources[i]=vtkConeSource::New();
- myMappers[i]=vtkPolyDataMapper::New();
- myActors [i]=vtkActor::New();
- //
- myMappers[i]->Delete();
- mySources[i]->Delete();
- myActors [i]->Delete();
- //
- myMappers[i]->SetInput(mySources[i]->GetOutput());
- myActors [i]->SetMapper(myMappers[i].GetPointer());
- myActors [i]->SetPickable(0);
- }
- //
- SetVisibility(0);
- SetPosition(0.,0.,0.);
- SetColor (1.,1.,1.);
- //
- myActors[1]->SetOrientation(0. ,180.,0.);
- myActors[3]->SetOrientation(0. , 0. ,180.);
- myActors[5]->SetOrientation(180., 0. ,0.);
- //
- Init();
-}
-//==================================================================
-// function : Init
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::Init()
-{
- float aD;
- //
- SetResolution(myResolution);
- SetAngle(myAngle);
- SetHeight(myHeight);
- //
- aD=-0.5*myHeight-myRadius;
- //
- // X
- //mySources[0]->SetDirection(1., 0., 0.);
- mySources[0]->SetCenter(aD, 0.,0.);
- //myActors [0]->GetProperty()->SetColor(myColor);
- //
- //mySources[1]->SetDirection(1., 0., 0.);
- mySources[1]->SetCenter(aD, 0.,0.);
- //myActors [1]->GetProperty()->SetColor(myColor);
- //
- // Y
- mySources[2]->SetDirection(0., 1., 0.);
- mySources[2]->SetCenter(0, aD, 0.);
- //myActors [2]->GetProperty()->SetColor(myColor);
- //
- mySources[3]->SetDirection(0., 1., 0.);
- mySources[3]->SetCenter(0., aD, 0.);
- //myActors [3]->GetProperty()->SetColor(myColor);
- //
- // Z
- mySources[4]->SetDirection(0., 0., 1.);
- mySources[4]->SetCenter(0, 0., aD);
- //myActors [4]->GetProperty()->SetColor(myColor);
- //
- mySources[5]->SetDirection(0., 0., 1.);
- mySources[5]->SetCenter(0., 0., aD);
- //myActors [5]->GetProperty()->SetColor(myColor);
-}
-//==================================================================
-// function : SetColor
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::SetColor(const float theR,
- const float theG,
- const float theB)
-{
- float aColor[3];
- //
- aColor[0]=theR;
- aColor[1]=theG;
- aColor[2]=theB;
- SetColor(aColor);
-}
-//==================================================================
-// function : SetColor
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::SetColor(const float theColor[3])
-{
- int i;
- //
- for (i=0; i<3; ++i) {
- myColor[i]=theColor[i];
- }
- for (i=0; i<myNbCones; ++i) {
- myActors[i]->GetProperty()->SetColor(myColor);
- }
-}
-//==================================================================
-// function : Color
-// purpose :
-//==================================================================
- float* VISU_CursorPyramid::Color()
-{
- return myColor;
-}
-//==================================================================
-// function : SetRadius
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::SetRadius(const float theR)
-{
- myRadius=theR;
- //Init();
-}
-//==================================================================
-// function : Radius
-// purpose :
-//==================================================================
-float VISU_CursorPyramid::Radius()const
-{
- return myRadius;
-}
-//==================================================================
-// function : SetResolution
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::SetResolution(const int theResolution)
-{
- int i;
- //
- myResolution=theResolution;
- //
- for (i=0; i<myNbCones; ++i) {
- mySources[i]->SetResolution(myResolution);
- }
-}
-//==================================================================
-// function : Resolution
-// purpose :
-//==================================================================
-int VISU_CursorPyramid::Resolution()const
-{
- return myResolution;
-}
-//==================================================================
-// function : SetAngle
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::SetAngle(const float theAngle)
-{
- int i;
- //
- myAngle=theAngle;
- //
- for (i=0; i<myNbCones; ++i) {
- mySources[i]->SetAngle(myAngle);
- }
-}
-//==================================================================
-// function : Angle
-// purpose :
-//==================================================================
-float VISU_CursorPyramid::Angle()const
-{
- return myAngle;
-}
-//==================================================================
-// function : SetHeight
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::SetHeight(const float theHeight)
-{
- int i;
- //
- myHeight=theHeight;
- //
- for (i=0; i<myNbCones; ++i) {
- mySources[i]->SetHeight(myHeight);
- }
-}
-//==================================================================
-// function : Height
-// purpose :
-//==================================================================
-float VISU_CursorPyramid::Height()const
-{
- return myHeight;
-}
-//==================================================================
-// function : SetVisibility
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::SetVisibility(const int theVisibility)
-{
- int i;
- //
- for (i=0; i<myNbCones; ++i) {
- myActors [i]->SetVisibility(theVisibility);
- }
-}
-//==================================================================
-// function : GetVisibility
-// purpose :
-//==================================================================
-int VISU_CursorPyramid::GetVisibility()const
-{
- return myActors[0]->GetVisibility();
-}
-//==================================================================
-// function : AddToRender
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::AddToRender(vtkRenderer* theRenderer)
-{
- int i;
- //
- for (i=0; i<myNbCones; ++i) {
- theRenderer->AddActor(myActors[i].GetPointer());
- }
-}
-//==================================================================
-// function : RemoveFromRender
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::RemoveFromRender(vtkRenderer* theRenderer)
-{
- int i;
- //
- for (i=0; i<myNbCones; ++i) {
- theRenderer->RemoveActor(myActors[i].GetPointer());
- }
-}
-//==================================================================
-// function : SetPosition
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::SetPosition(float theX,
- float theY,
- float theZ)
-{
- int i;
- //
- for (i=0; i<myNbCones; ++i) {
- myActors[i]->SetPosition(theX,theY, theZ);
- }
-}
-//==================================================================
-// function : SetPosition
-// purpose :
-//==================================================================
-void VISU_CursorPyramid::SetPosition(float thePosition[3])
-{
- SetPosition(thePosition[0],
- thePosition[1],
- thePosition[2]);
-}
-//==================================================================
-// function : ~
-// purpose :
-//==================================================================
-VISU_CursorPyramid::~VISU_CursorPyramid()
-{
-}