From: pkv Date: Thu, 8 Sep 2005 06:29:46 +0000 (+0000) Subject: Adds pyramidal cursor for VISU_GaussPtsAct::PreHighlight(...) method X-Git-Tag: BR-D5-38-2003_D2005-12-09~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2c35efc07dfc0a2e53411c59ffb57667fb7d5f98;p=modules%2Fvisu.git Adds pyramidal cursor for VISU_GaussPtsAct::PreHighlight(...) method --- diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index d5b095d1..51e3e06c 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -50,6 +50,84 @@ #include #include +// +/////////////////////////////////////////////////////////////////////////// +// +// 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 mySources[6]; + vtkSmartPointer myMappers[6]; + vtkSmartPointer myActors[6]; +}; +// vtkStandardNewMacro(VISU_GaussPtsAct); @@ -62,6 +140,7 @@ VISU_GaussPtsAct mySphereSource(vtkSphereSource::New()), mySphereMapper(vtkPolyDataMapper::New()), mySphereActor(vtkActor::New()) + ,myCursorPyramid(VISU_CursorPyramid::New()) { myTextMapper->Delete(); myTextActor->Delete(); @@ -83,6 +162,8 @@ VISU_GaussPtsAct mySphereActor->SetMapper(mySphereMapper.GetPointer()); mySphereActor->SetVisibility(false); mySphereActor->SetPickable(false); + // + myCursorPyramid->Delete(); } VISU_GaussPtsAct @@ -96,12 +177,14 @@ 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); @@ -127,6 +210,8 @@ VISU_GaussPtsAct // myTextActor->SetVisibility(false); mySphereActor->SetVisibility(false); + myCursorPyramid->SetVisibility(0); + if(theSelectionEvent.mySelectionMode == ActorSelection || !theIsHighlight) { return Superclass::PreHighlight(theSelector,theIS,theSelectionEvent,theIsHighlight); } @@ -194,6 +279,15 @@ VISU_GaussPtsAct 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()){ @@ -206,9 +300,10 @@ VISU_GaussPtsAct myLastObjPointID = anObjId; } + myTextActor->SetVisibility(true); mySphereActor->SetVisibility(true); - + myCursorPyramid->SetVisibility(1); myIsPreselected = theIsHighlight; anIsChanged = true; } @@ -413,3 +508,289 @@ VISU_GaussPtsAct::Highlight( SVTK_Selector *theSelector, mySphereActor->SetVisibility(aSphereVisibility); return bRet; } +// +/////////////////////////////////////////////////////////////////////////// +// +// class: VISU_CursorPyramid +// +#include +#include +#include + +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; iDelete(); + 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; iGetProperty()->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; iSetResolution(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; iSetAngle(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; iSetHeight(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; iSetVisibility(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; iAddActor(myActors[i].GetPointer()); + } +} +//================================================================== +// function : RemoveFromRender +// purpose : +//================================================================== +void VISU_CursorPyramid::RemoveFromRender(vtkRenderer* theRenderer) +{ + int i; + // + for (i=0; iRemoveActor(myActors[i].GetPointer()); + } +} +//================================================================== +// function : SetPosition +// purpose : +//================================================================== +void VISU_CursorPyramid::SetPosition(float theX, + float theY, + float theZ) +{ + int i; + // + for (i=0; iSetPosition(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() +{ +} diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index 7c6e81e8..99f0c773 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -41,6 +41,8 @@ class vtkPolyDataMapper; class vtkActor; class vtkInteractorStyle; +class VISU_CursorPyramid; + class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_ScalarMapAct { public: @@ -87,6 +89,8 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_ScalarMapAct vtkSmartPointer mySphereSource; vtkSmartPointer mySphereMapper; vtkSmartPointer mySphereActor; + + vtkSmartPointer myCursorPyramid; }; #endif