#include <vtkRenderer.h>
#include <vtkCellPicker.h>
#include <vtkCell.h>
+#include <vtkPointPicker.h>
#include <vtkPoints.h>
#include <vtkInteractorStyle.h>
#include <vtkDataSet.h>
return myPipeLine->GetElemCell(theObjID);
}
-//==================================================================
-// function: PreHighlight
-// purpose :
-//==================================================================
-bool VISU_Actor::PreHighlight( SVTK_Selector* theSelector,
- vtkInteractorStyle *theIS,
- SVTK_SelectionEvent theSelectionEvent,
- bool theIsHighlight )
+
+//----------------------------------------------------------------------------
+bool
+VISU_Actor
+::PreHighlight(SVTK_Selector* theSelector,
+ vtkInteractorStyle* theInteractorStyle,
+ SVTK_SelectionEvent* theSelectionEvent,
+ bool theIsHighlight)
{
- bool bRet, anIsChanged;
- float x, y, z;
- vtkIdType aVtkId;
-
- bRet=Superclass::PreHighlight(theSelector,
- theIS,
- theSelectionEvent,
- theIsHighlight);
+ bool aRet = Superclass::PreHighlight(theSelector,
+ theInteractorStyle,
+ theSelectionEvent,
+ theIsHighlight);
//
myAnnotationActor->SetVisibility(0);
- //
- anIsChanged = false;
- x = theSelectionEvent.myX;
- y = theSelectionEvent.myY;
- z = 0.0;
- vtkRenderer *aRenderer=theIS->GetCurrentRenderer();
- //
- if(theIsHighlight) {
+ bool anIsChanged = false;
+ if(theIsHighlight){
switch(mySelectionMode){
case CellSelection:{
- myCellPicker->Pick(x, y, z, aRenderer);
- //if(myCellPicker->GetActor() != this){
- // return false;
- //}
- aVtkId = myCellPicker->GetCellId();
- if (aVtkId >= 0 &&
- theSelector->IsValid( this, aVtkId, true ) &&
- hasIO() ) {
- vtkIdType anObjId = GetElemObjId( aVtkId );
- vtkCell* pCell=GetElemCell(anObjId);
- if (pCell){
- int aNbPnts, i, j;
- float *aCoord, *aCoordX;
- //
- aNbPnts=pCell->GetNumberOfPoints();
- if (aNbPnts){
- aCoord=new float[3];
- for (j=0; j<3; ++j) {
- aCoord[j]=0.;
+ vtkRenderer* aRenderer = theInteractorStyle->GetCurrentRenderer();
+ myCellPicker->Pick(theSelectionEvent->myX,
+ theSelectionEvent->myY,
+ 0.0,
+ aRenderer);
+
+ if(myCellPicker->GetActor() != this)
+ return false;
+
+ vtkIdType aVTKId = myCellPicker->GetCellId();
+ if(aVTKId >= 0 && theSelector->IsValid(this,aVTKId,true) && hasIO()){
+ vtkIdType anObjId = GetElemObjId(aVTKId);
+ if(vtkCell* aCell = GetElemCell(anObjId)){
+ vtkPoints* aPts = aCell->GetPoints();
+ if(int aNbPts = aCell->GetNumberOfPoints()){
+ float aCoord[3] = {0.0, 0.0, 0.0};
+ for(int i = 0; i < aNbPts; i++){
+ float *aPntCoord = aPts->GetPoint(i);
+ aCoord[0] += aPntCoord[0];
+ aCoord[1] += aPntCoord[1];
+ aCoord[2] += aPntCoord[2];
}
- //
- vtkPoints * pPnts=pCell->GetPoints();
- for (i=0; i<aNbPnts; ++i){
- aCoordX=pPnts->GetPoint(i);
- for (j=0; j<3; ++j) {
- aCoord[j]+=aCoordX[j];
- }
- }
- for (j=0; j<3; ++j) {
- aCoord[j]/=aNbPnts;
- }
- //printf(" aVtkId=%d, x=%f, y=%f, {%f, %f, %f}\n",
- // aVtkId, x, y, aCoord[0], aCoord[1], aCoord[2]);
- //
// Display coordinates
- float aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0};
+ float aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0};
aRenderer->SetWorldPoint(aWorldCoord);
aRenderer->WorldToDisplay();
float aSelectionPoint[3];
//
// To prepare the annotation text
std::ostringstream aStr;
- aStr<<"Global ID: "<< anObjId;
+ aStr<<"Cell ID: "<< anObjId;
std::string aString = aStr.str();
myAnnotationMapper->SetInput(aString.c_str());
myAnnotationActor->SetVisibility(1);
- delete aCoord;
return true;
}
}
}
+ break;
}
+ case NodeSelection:{
+ vtkRenderer* aRenderer = theInteractorStyle->GetCurrentRenderer();
+ myPointPicker->Pick(theSelectionEvent->myX,
+ theSelectionEvent->myY,
+ 0.0,
+ aRenderer);
+
+ if(myPointPicker->GetActor() != this)
+ return false;
+
+ vtkIdType aVtkId = myPointPicker->GetPointId();
+ if(aVtkId >= 0 && theSelector->IsValid(this,aVtkId,true) && hasIO()){
+ vtkIdType anObjId = GetNodeObjId( aVtkId );
+ if(float* aCoord = GetNodeCoord(anObjId)){
+ // Display coordinates
+ float aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0};
+ aRenderer->SetWorldPoint(aWorldCoord);
+ aRenderer->WorldToDisplay();
+ float aSelectionPoint[3];
+ aRenderer->GetDisplayPoint(aSelectionPoint);
+ myAnnotationActor->SetPosition(aSelectionPoint);
+ //
+ // To prepare the annotation text
+ std::ostringstream aStr;
+ aStr<<"Node ID: "<< anObjId;
+ std::string aString = aStr.str();
+ myAnnotationMapper->SetInput(aString.c_str());
+
+ myAnnotationActor->SetVisibility(1);
+
+ return true;
+ }
+ }
break;
- case NodeSelection:
+ }
case EdgeOfCellSelection:
+ break;
default:
break;
}
}
- return bRet;
-
+
+ return aRet;
}
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
-#include <vtkCell.h>
-#include <vtkCellArray.h>
#include <vtkRenderWindow.h>
+#include <vtkCellArray.h>
+#include <vtkCell.h>
+#include <vtkMath.h>
#include "VISU_Convertor_impl.hxx"
//
//----------------------------------------------------------------
bool
VISU_GaussPtsAct
-::PreHighlight( SVTK_Selector* theSelector,
- vtkInteractorStyle *theIS,
- SVTK_SelectionEvent theSelectionEvent,
- bool theIsHighlight )
+::PreHighlight(SVTK_Selector* theSelector,
+ vtkInteractorStyle* theInteractorStyle,
+ SVTK_SelectionEvent* theSelectionEvent,
+ bool theIsHighlight)
{
- vtkRenderer *aRenderer=theIS->GetCurrentRenderer();
- //
myTextActor->SetVisibility(false);
mySphereActor->SetVisibility(false);
- myCursorPyramid->SetVisibility(0);
-
+ myCursorPyramid->SetVisibility(0);
- if(theSelectionEvent.mySelectionMode == ActorSelection || !theIsHighlight) {
- return Superclass::PreHighlight(theSelector,theIS,theSelectionEvent,theIsHighlight);
- }
- myPreHighlightActor->SetVisibility( false );
+ if(theSelectionEvent->mySelectionMode == ActorSelection || !theIsHighlight)
+ return Superclass::PreHighlight(theSelector,theInteractorStyle,theSelectionEvent,theIsHighlight);
+
+ myPreHighlightActor->SetVisibility(false);
- bool anIsSelectionModeChanged = (theSelectionEvent.mySelectionMode != mySelectionMode);
+ bool anIsSelectionModeChanged = (theSelectionEvent->mySelectionMode != mySelectionMode);
if(!anIsSelectionModeChanged && mySelectionMode == ActorSelection)
return false;
- mySelectionMode = theSelectionEvent.mySelectionMode;
-
- float x = theSelectionEvent.myX;
- float y = theSelectionEvent.myY;
- float z = 0.0;
+ mySelectionMode = theSelectionEvent->mySelectionMode;
bool anIsChanged = false;
if(theIsHighlight){
case NodeSelection:
case CellSelection:
{
- myPointPicker->Pick( x, y, z, aRenderer );
+ myPointPicker->Pick(theSelectionEvent->myX,
+ theSelectionEvent->myY,
+ 0.0,
+ theInteractorStyle->GetCurrentRenderer());
- if(myPointPicker->GetActor() != this) {
+ if(myPointPicker->GetActor() != this)
return false;
- }
vtkIdType aVtkId = myPointPicker->GetPointId();
- if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && hasIO() ){
- //float* aSelectionPoint = myPointPicker->GetSelectionPoint();
- vtkIdType aVtkId = myPointPicker->GetPointId();
+ if(aVtkId >= 0 && theSelector->IsValid(this,aVtkId,true) && hasIO()){
vtkIdType anObjId = GetNodeObjId( aVtkId );
if(myLastObjPointID != anObjId){
float* aNodeCoord = GetNodeCoord(anObjId);
return anIsChanged;
}
-#include<vtkMath.h>
+
//==================================================================
// function : Highlight
// purpose :
//==================================================================
-bool VISU_GaussPtsAct::Highlight( SVTK_Selector *theSelector,
- vtkInteractorStyle *theIS,
- SVTK_SelectionEvent theSelectionEvent,
- bool theIsHighlight )
+bool VISU_GaussPtsAct::Highlight(SVTK_Selector* theSelector,
+ vtkInteractorStyle* theInteractorStyle,
+ SVTK_SelectionEvent* theSelectionEvent,
+ bool theIsHighlight)
{
- int aTextVisibility, aSphereVisibility, aSphereVisibilitySelected, aSelectionMode;
- //
- aTextVisibility=myTextActor->GetVisibility();
- aSphereVisibility=mySphereActor->GetVisibility();
- aSphereVisibilitySelected= mySphereActorSelected->GetVisibility();
+ int aTextVisibility = myTextActor->GetVisibility();
+ int aSphereVisibility = mySphereActor->GetVisibility();
+ int aSphereVisibilitySelected = mySphereActorSelected->GetVisibility();
//
myTextActor->SetVisibility(0);
mySphereActor->SetVisibility(0);
mySphereActorSelected->SetVisibility(0);
myCellActor->SetVisibility(0);
//
- vtkRenderer *aRenderer=theIS->GetCurrentRenderer();
- vtkRenderWindowInteractor* aRWI=theIS->GetInteractor();
+ vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
+ vtkRenderWindowInteractor* anIteractor = theInteractorStyle->GetInteractor();
//
- aSelectionMode = theSelectionEvent.mySelectionMode;
+ Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
mySelectionMode = aSelectionMode;
//
if(aSelectionMode==ActorSelection ){ //|| !theIsHighlight) {
myTextActor->SetVisibility(aTextVisibility);
mySphereActor->SetVisibility(aSphereVisibility);
mySphereActorSelected->SetVisibility(aSphereVisibilitySelected);
- return Superclass::Highlight(theSelector,theIS,theSelectionEvent,theIsHighlight);
+ return Superclass::Highlight(theSelector,theInteractorStyle,theSelectionEvent,theIsHighlight);
}
//
- bool isShift, isRectangle, bRet, bHasIO;
- float x1, y1, z1, x2, y2, z2;
- //
- x1 = theSelectionEvent.myX;
- y1 = theSelectionEvent.myY;
- z1 = 0.0;
- x2 = theSelectionEvent.myLastX;
- y2 = theSelectionEvent.myLastY;
- z2 = 0.0;
-
- isShift = theSelectionEvent.myIsShift;
- isRectangle = theSelectionEvent.myIsRectangle;
-
- bHasIO=hasIO();
- bRet=false;
- if( !isRectangle ) {
- myPointPicker->Pick( x1, y1, z1, aRenderer );
+ bool bRet = false;
+ if(!theSelectionEvent->myIsRectangle){
+
+ myPointPicker->Pick(theSelectionEvent->myX,
+ theSelectionEvent->myY,
+ 0.0,
+ 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 ) && bHasIO) {
+ 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 ) {
+ if(anObjId >= 0){
bRet=!bRet;
//
// Update the Selector
- if( theSelector->IsSelected( myIO ) ) {
- theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
- }
- else {
- if( !isShift ) {
+ if(theSelector->IsSelected(myIO))
+ theSelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
+ else{
+ if(!theSelectionEvent->myIsShift)
theSelector->ClearIObjects();
- }
- theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
- theSelector->AddIObject( this );
+ theSelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
+ theSelector->AddIObject(this);
}
//
float *aNodeCoord, aRadius, aDollyWas;
//
aNodeCoord = GetNodeCoord(anObjId);
//
- aDollyWas=aRWI->GetDolly();
- aRWI->SetDolly(0.);
- aRWI->FlyTo (aRenderer, aNodeCoord);
+ aDollyWas = anIteractor->GetDolly();
+ anIteractor->SetDolly(0.0);
+ anIteractor->FlyTo(aRenderer,aNodeCoord);
aRenderer->ResetCameraClippingRange();
- aRWI->SetDolly(aDollyWas);
+ anIteractor->SetDolly(aDollyWas);
//
// To calculate display (2D) position of the annotation
float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.};
//
myTextActor->SetVisibility(1);
//
- if (aSelectionMode==CellSelection) {
+ if(aSelectionMode == CellSelection){
// Hilighting an element from the parent Mesh
int k, aNbPoints, aIDs[20];
float *pX;
//
else {
if( vtkDataSet* aDataSet = GetInput() ) {
- int i, aNbPnts;
- //
- aNbPnts=aDataSet->GetNumberOfPoints();
- for(i = 0; i<aNbPnts && !bRet; i++){
+ float x1 = theSelectionEvent->myX;
+ float y1 = theSelectionEvent->myY;
+ float x2 = theSelectionEvent->myLastX;
+ float y2 = theSelectionEvent->myLastY;
+
+ int aNbPnts=aDataSet->GetNumberOfPoints();
+ for(int i = 0; i < aNbPnts && !bRet; i++){
float aPoint[3];
aDataSet->GetPoint( i, aPoint );
bRet=!bRet; // true
//
if( theSelector->IsSelected( myIO ) ) {
- theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+ theSelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
}
else {
- if( !isShift ) {
+ if(!theSelectionEvent->myIsShift)
theSelector->ClearIObjects();
- }
- theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+
+ theSelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
theSelector->AddIObject( this );
bIsAdded=!bIsAdded;
}
//
if (bIsAdded){
float* aNodeCoord = GetNodeCoord(anObjId);
- aRWI->FlyTo (aRenderer, aNodeCoord);
+ anIteractor->FlyTo (aRenderer, aNodeCoord);
aRenderer->ResetCameraClippingRange();
// To calculate display (2D) position of the annotation
float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.0};