#include <vtkCamera.h>
#include <sstream>
+//
+///////////////////////////////////////////////////////////////////////////
+//
+// class: VISU_CursorPyramid
+//
+class vtkConeSource;
+class vtkRenderer;
+class vtkPolyDataMapper;
+class vtkActor;
+
+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);
+
+ void RemoveFromRender(vtkRenderer* theRenderer);
+
+ void SetVisibility (int);
+
+ int GetVisibility () const;
+
+ void SetPosition(float theX, float theY, float theZ);
+
+ void SetPosition(float thePosition[3]);
+
+ //
+ vtkTypeMacro(VISU_CursorPyramid, vtkObject);
+
+ static VISU_CursorPyramid* New();
+ //
+
+protected:
+ VISU_CursorPyramid();
+
+ virtual ~VISU_CursorPyramid();
+
+ void Init();
+
+protected:
+ // sphere parameters
+ float myRadius;
+ // cone parameters
+ int myResolution;
+ float myAngle;
+ float myHeight;
+ //
+ int myNbCones;
+ float myColor[3];
+ vtkSmartPointer<vtkConeSource> mySources[6];
+ vtkSmartPointer<vtkPolyDataMapper> myMappers[6];
+ vtkSmartPointer<vtkActor> myActors[6];
+};
+//
vtkStandardNewMacro(VISU_GaussPtsAct);
mySphereSource(vtkSphereSource::New()),
mySphereMapper(vtkPolyDataMapper::New()),
mySphereActor(vtkActor::New())
+ ,myCursorPyramid(VISU_CursorPyramid::New())
{
myTextMapper->Delete();
myTextActor->Delete();
mySphereActor->SetMapper(mySphereMapper.GetPointer());
mySphereActor->SetVisibility(false);
mySphereActor->SetPickable(false);
+ //
+ myCursorPyramid->Delete();
}
VISU_GaussPtsAct
Superclass::AddToRender(theRenderer);
theRenderer->AddActor(myTextActor.GetPointer());
theRenderer->AddActor(mySphereActor.GetPointer());
+ myCursorPyramid->AddToRender(theRenderer);
}
void
VISU_GaussPtsAct
::RemoveFromRender(vtkRenderer* theRenderer)
{
+ myCursorPyramid->RemoveFromRender(theRenderer);
theRenderer->RemoveActor(mySphereActor.GetPointer());
theRenderer->RemoveActor(myTextActor.GetPointer());
Superclass::RemoveFromRender(theRenderer);
//
myTextActor->SetVisibility(false);
mySphereActor->SetVisibility(false);
+ myCursorPyramid->SetVisibility(0);
+
if(theSelectionEvent.mySelectionMode == ActorSelection || !theIsHighlight) {
return Superclass::PreHighlight(theSelector,theIS,theSelectionEvent,theIsHighlight);
}
VISU_LookupTable* aLookupTable = myGaussPointsPL->GetMapperTable();
aLookupTable->GetColor(aVal,aColor);
mySphereActor->GetProperty()->SetColor(aColor);
+ //
+ float aMaxPointSize;
+ //
+ aMaxPointSize=myGaussPointsPL->GetMaxPointSize();
+
+ myCursorPyramid->SetRadius(aRadius);
+ myCursorPyramid->SetColor(aColor);
+ myCursorPyramid->SetPosition(aNodeCoord);
+ myCursorPyramid->SetHeight(aMaxPointSize);
}
if(vtkDataArray *aVectorArray = aCellData->GetVectors()){
myLastObjPointID = anObjId;
}
+
myTextActor->SetVisibility(true);
mySphereActor->SetVisibility(true);
-
+ myCursorPyramid->SetVisibility(1);
myIsPreselected = theIsHighlight;
anIsChanged = true;
}
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()
+{
+}