#include <vtkObjectFactory.h>
#include <vtkInteractorStyle.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkCamera.h>
#include <sstream>
myTextActor->SetMapper(myTextMapper.GetPointer());
//myTextActor->SetAlignmentPoint(3);
myTextActor->SetVisibility(false);
+ myTextActor->SetPickable(false);
mySphereSource->Delete();
mySphereMapper->Delete();
mySphereMapper->SetInput(mySphereSource->GetOutput());
mySphereActor->SetMapper(mySphereMapper.GetPointer());
mySphereActor->SetVisibility(false);
+ mySphereActor->SetPickable(false);
}
VISU_GaussPtsAct
//
myTextActor->SetVisibility(false);
mySphereActor->SetVisibility(false);
-
if(theSelectionEvent.mySelectionMode == ActorSelection || !theIsHighlight) {
return Superclass::PreHighlight(theSelector,theIS,theSelectionEvent,theIsHighlight);
}
{
myPointPicker->Pick( x, y, z, aRenderer );
- if(myPointPicker->GetActor() != this)
+ if(myPointPicker->GetActor() != this) {
return false;
+ }
vtkIdType aVtkId = myPointPicker->GetPointId();
if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && hasIO() ){
return anIsChanged;
}
+
+//----------------------------------------------------------------
+bool
+VISU_GaussPtsAct::Highlight( SVTK_Selector *theSelector,
+ vtkInteractorStyle *theIS,
+ SVTK_SelectionEvent theSelectionEvent,
+ bool theIsHighlight )
+{
+ int aTextVisibility, aSphereVisibility;
+ //
+ aTextVisibility=myTextActor->GetVisibility();
+ aSphereVisibility=mySphereActor->GetVisibility();
+ //
+ myTextActor->SetVisibility(0);
+ mySphereActor->SetVisibility(0);
+ //
+ vtkRenderer *aRenderer=theIS->GetCurrentRenderer();
+ vtkRenderWindowInteractor* aRWI=theIS->GetInteractor();
+ //
+ int aSelectionMode = theSelectionEvent.mySelectionMode;
+ mySelectionMode = aSelectionMode;
+ //
+ if(aSelectionMode==ActorSelection ){ //|| !theIsHighlight) {
+ myTextActor->SetVisibility(aTextVisibility);
+ mySphereActor->SetVisibility(aSphereVisibility);
+ return Superclass::Highlight(theSelector,theIS,theSelectionEvent,theIsHighlight);
+ }
+ //
+ float x1 = theSelectionEvent.myX;
+ float y1 = theSelectionEvent.myY;
+ float z1 = 0.0;
+ float x2 = theSelectionEvent.myLastX;
+ float y2 = theSelectionEvent.myLastY;
+ float z2 = 0.0;
+ bool isShift = theSelectionEvent.myIsShift;
+ bool isRectangle = theSelectionEvent.myIsRectangle;
+ bool bRet=false;
+ //
+ if( !isRectangle ) {
+ myPointPicker->Pick( x1, y1, z1, aRenderer );
+
+ if(myPointPicker->GetActor() != this) {
+ myTextActor->SetVisibility(aTextVisibility);
+ mySphereActor->SetVisibility(aSphereVisibility);
+ return bRet;
+ }
+
+ vtkIdType aVtkId = myPointPicker->GetPointId();
+ if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && hasIO()) {
+ vtkIdType anObjId = GetNodeObjId( aVtkId );
+ //
+ //double aCoeff=0.667;
+ //vtkCamera *aCamera = aRenderer->GetActiveCamera();
+ //double aScale = aCamera->GetParallelScale();
+ //aCamera->SetParallelScale(aScale*aCoeff);
+ //
+ if( anObjId >= 0 ) {
+ bRet=!bRet;
+ if( theSelector->IsSelected( myIO ) ) {
+ theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+ }
+ else {
+ if( !isShift ) {
+ theSelector->ClearIObjects();
+ }
+ theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+ theSelector->AddIObject( this );
+ }
+ float* aNodeCoord = GetNodeCoord(anObjId);
+ aRWI->FlyTo (aRenderer, aNodeCoord);
+ aRenderer->ResetCameraClippingRange();
+ //
+ // 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);
+ //
+ float aColor[3]={1.,1.,1.};
+ mySphereActor->GetProperty()->SetColor(aColor);
+ }
+ }
+ }// if( !isRectangle )
+ else {
+ if( vtkDataSet* aDataSet = GetInput() ) {
+ int i, aNbPnts;
+ //
+ aNbPnts=aDataSet->GetNumberOfPoints();
+ for(i = 0; i<aNbPnts && !bRet; i++){
+ float aPoint[3];
+ aDataSet->GetPoint( i, aPoint );
+
+ float aPnt[3];
+ aRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 );
+ aRenderer->WorldToDisplay();
+ aRenderer->GetDisplayPoint( aPnt );
+
+ if( aPnt[0] > x2 && aPnt[0] < x1 && aPnt[1] > y1 && aPnt[1] < y2 ) {
+ float aDisp[3];
+ aRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 );
+ aRenderer->WorldToDisplay();
+ aRenderer->GetDisplayPoint( aDisp );
+
+ if( myPointPicker->Pick( aDisp[0], aDisp[1], 0.0, aRenderer ) ) {
+ if( vtkActorCollection* anActorCollection = myPointPicker->GetActors() ) {
+ if( anActorCollection->IsItemPresent( this ) ) {
+ float aPickedPoint[3];
+ myPointPicker->GetMapperPosition( aPickedPoint );
+ vtkIdType aVtkId = aDataSet->FindPoint( aPickedPoint );
+ if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) ) {
+ vtkIdType anObjId = GetNodeObjId( aVtkId );
+
+ if( anObjId >= 0 ) {
+ //
+ bool bIsAdded=false;
+ bRet=!bRet; // true
+ //
+ if( theSelector->IsSelected( myIO ) ) {
+ theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+ }
+ else {
+ if( !isShift ) {
+ theSelector->ClearIObjects();
+ }
+ theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+ theSelector->AddIObject( this );
+ bIsAdded=!bIsAdded;
+ }
+ //
+ if (bIsAdded){
+ float* aNodeCoord = GetNodeCoord(anObjId);
+ aRWI->FlyTo (aRenderer, aNodeCoord);
+ aRenderer->ResetCameraClippingRange();
+ // 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);
+ //
+ // annotation text
+ {
+ std::ostringstream aStr;
+ aStr<<"Global ID: "<<anObjId;
+
+ VISU::TGaussPointID aGaussPointID = myGaussPointsPL->GetObjID(anObjId);
+ VISU::TCellID aCellID = aGaussPointID.first;
+ VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
+ aStr<<"\nParentCellID: "<<aCellID;
+ aStr<<"\nLocalPntID: "<<aLocalPntID;
+
+ vtkDataSet* aDataSet = GetInput();
+ vtkCellData* aCellData = aDataSet->GetCellData();
+ if(vtkDataArray *aScalarArray = aCellData->GetScalars()){
+ float aVal = aScalarArray->GetTuple1(aVtkId);
+ aStr<<"\nScalar: "<<aVal;
+
+ mySphereSource->SetCenter(aNodeCoord);
+ float aRadius = myGaussPointsPL->GetPointSize(anObjId,aScalarArray);
+ mySphereSource->SetRadius(aRadius);
+ }
+
+ if(vtkDataArray *aVectorArray = aCellData->GetVectors()){
+ float* aVal = aVectorArray->GetTuple3(aVtkId);
+ aStr<<"\nVector: {"<<aVal[0]<<"; "<<aVal[1]<<"; "<<aVal[2]<<"}";
+ }
+
+ std::string aString = aStr.str();
+ myTextMapper->SetInput(aString.c_str());
+ }// annotation text
+ //
+ float aColor[3]={1.,1.,1.};
+ mySphereActor->GetProperty()->SetColor(aColor);
+ // shoe sphere
+ myTextActor->SetVisibility(1);
+ mySphereActor->SetVisibility(1);
+ return bRet;
+ }// if (bIsAdded){
+ }// if( anObjId >= 0 )
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }//else ... if(!isRectangle )
+ myTextActor->SetVisibility(aTextVisibility);
+ mySphereActor->SetVisibility(aSphereVisibility);
+ return bRet;
+}