vtkSmartPointer<vtkActor> myActors[6];
};
//
+///////////////////////////////////////////////////////////////////////////
+//
+// class: VISU_GPTextActor
+//
+class vtkViewport;
+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);
+
+protected:
+ float myWorldPoint[4];
+};
+//
+///////////////////////////////////////////////////////////////////////////
+//
+// class: VISU_CursorPyramid
+//
+#include <vtkViewport.h>
+
+vtkStandardNewMacro(VISU_GPTextActor);// <- static VISU_GPTextActor* New()
+
+//==================================================================
+// 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)
+{
+ float aSelectionPoint[3];
+ //
+ theViewport->SetWorldPoint(myWorldPoint);
+ theViewport->WorldToDisplay();
+ theViewport->GetDisplayPoint(aSelectionPoint);
+ SetPosition(aSelectionPoint);
+ //
+ Superclass::RenderOpaqueGeometry(theViewport);
+}
+//
+//VISU_GaussPtsAct
vtkStandardNewMacro(VISU_GaussPtsAct);
VISU_GaussPtsAct
::VISU_GaussPtsAct():
myGaussPointsPL(NULL),
myTextMapper(vtkTextMapper::New()),
- myTextActor(vtkTextActor::New()),
+ myTextActor(VISU_GPTextActor::New()),
myLastObjPointID(-1),
mySphereSource(vtkSphereSource::New()),
mySphereMapper(vtkPolyDataMapper::New()),
mySphereActor->SetPickable(false);
//
myCursorPyramid->Delete();
+
}
VISU_GaussPtsAct
// To calculate display (2D) position of the annotation
float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.0};
- aRenderer->SetWorldPoint(aWorldCoord);
- aRenderer->WorldToDisplay();
- float aSelectionPoint[3];
- aRenderer->GetDisplayPoint(aSelectionPoint);
- myTextActor->SetPosition(aSelectionPoint);
-
+ myTextActor->SetWorldPoint(aWorldCoord);
// To prepare the annotation text
std::ostringstream aStr;
aStr<<"Global ID: "<<anObjId;
vtkInteractorStyle *theIS,
SVTK_SelectionEvent theSelectionEvent,
bool theIsHighlight )
-{
+{
int aTextVisibility, aSphereVisibility;
//
aTextVisibility=myTextActor->GetVisibility();
float z2 = 0.0;
bool isShift = theSelectionEvent.myIsShift;
bool isRectangle = theSelectionEvent.myIsRectangle;
- bool bRet=false;
+ bool bRet, bHasIO;
//
+ bHasIO=hasIO();
+ bRet=false;
if( !isRectangle ) {
myPointPicker->Pick( x1, y1, z1, aRenderer );
mySphereActor->SetVisibility(aSphereVisibility);
return bRet;
}
-
+ //
vtkIdType aVtkId = myPointPicker->GetPointId();
- if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && hasIO()) {
+ if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && bHasIO) {
vtkIdType anObjId = GetNodeObjId( aVtkId );
//
//double aCoeff=0.667;
//
// To calculate display (2D) position of the annotation
float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.0};
- aRenderer->SetWorldPoint(aWorldCoord);
- aRenderer->WorldToDisplay();
- float aSelectionPoint[3];
- aRenderer->GetDisplayPoint(aSelectionPoint);
- myTextActor->SetPosition(aSelectionPoint);
+ myTextActor->SetWorldPoint(aWorldCoord);
//
float aColor[3]={1.,1.,1.};
mySphereActor->GetProperty()->SetColor(aColor);
- }
- }
+ //
+ }// if( anObjId >= 0 ) {
+ }//if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && hasIO())
}// if( !isRectangle )
+ //
else {
if( vtkDataSet* aDataSet = GetInput() ) {
int i, aNbPnts;
#include <vtkObjectFactory.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCommand.h>
+#include <vtkRenderer.h>
+#include <vtkCamera.h>
+#include <SVTK_Selector.h>
//----------------------------------------------------------------------------
vtkStandardNewMacro(VVTK_InteractorStyle);
//----------------------------------------------------------------------------
startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
}
}
+
+//----------------------------------------------------------------------------
+void VVTK_InteractorStyle::onFinishOperation()
+{
+ int aNbObjWas, aNbObjNow;
+ //
+ aNbObjWas=GetSelector()->IObjectCount();
+ //
+ SVTK_InteractorStyle::onFinishOperation();
+ //
+ aNbObjNow=GetSelector()->IObjectCount();
+
+ if (aNbObjWas+aNbObjNow==1){
+ double aScale, aCoeff;
+ vtkRenderer *aRenderer=GetCurrentRenderer();
+ vtkCamera *aCamera = aRenderer->GetActiveCamera();
+ //
+ aCoeff=0.667;
+ aScale = aCamera->GetParallelScale();
+ //
+ if (!aNbObjWas && aNbObjNow) {
+ aCamera->SetParallelScale(aScale*aCoeff);
+ }
+ else {
+ aCoeff=1./aCoeff;
+ aCamera->SetParallelScale(aScale*aCoeff);
+ }
+ }
+}