#include <vtkCamera.h>
#include <sstream>
+
+#include <vtkUnstructuredGrid.h>
+#include <vtkDataSetMapper.h>
+#include <vtkCell.h>
+#include <vtkCellArray.h>
+
+#include "VISU_Convertor_impl.hxx"
//
///////////////////////////////////////////////////////////////////////////
//
void SetPosition(float thePosition[3]);
+ void Init();
//
vtkTypeMacro(VISU_CursorPyramid, vtkObject);
virtual ~VISU_CursorPyramid();
- void Init();
protected:
// sphere parameters
mySphereActor->SetPickable(false);
//
myCursorPyramid->Delete();
+ //
+ mySphereSourceSelected=vtkSphereSource::New();
+ mySphereMapperSelected=vtkPolyDataMapper::New();
+ mySphereActorSelected=vtkActor::New();
+ //
+ mySphereSourceSelected->Delete();
+ mySphereMapperSelected->Delete();
+ mySphereActorSelected->Delete();
+ //
+ mySphereMapperSelected->SetInput(mySphereSourceSelected->GetOutput());
+ mySphereActorSelected->SetMapper(mySphereMapperSelected.GetPointer());
+ mySphereActorSelected->SetVisibility(false);
+ mySphereActorSelected->SetPickable(false);
+ float aColorSelected[3]={1.,1.,1.};
+ mySphereActorSelected->GetProperty()->SetColor(aColorSelected);
+ //
+ // Cell
+ myCellSource=vtkUnstructuredGrid::New();
+ myCellSource->Allocate();
+ myCellMapper=vtkDataSetMapper::New();
+ myCellActor=vtkActor::New();
+ //
+ myCellSource->Delete();
+ myCellMapper->Delete();
+ myCellActor->Delete();
+ //
+ myCellMapper->SetInput(myCellSource.GetPointer());
+ myCellActor->SetMapper(myCellMapper.GetPointer());
+ myCellActor->SetVisibility(0);
+ myCellActor->SetPickable(0);
+ float aColorCell[3]={.9,.9,.9};
+ vtkProperty* pPropertyCell=myCellActor->GetProperty();
+ pPropertyCell->SetColor(aColorCell);
+ pPropertyCell->SetRepresentationToWireframe();
}
VISU_GaussPtsAct
Superclass::AddToRender(theRenderer);
theRenderer->AddActor(myTextActor.GetPointer());
theRenderer->AddActor(mySphereActor.GetPointer());
+ theRenderer->AddActor(mySphereActorSelected.GetPointer());
myCursorPyramid->AddToRender(theRenderer);
+ theRenderer->AddActor(myCellActor.GetPointer());
}
void
myCursorPyramid->RemoveFromRender(theRenderer);
theRenderer->RemoveActor(mySphereActor.GetPointer());
theRenderer->RemoveActor(myTextActor.GetPointer());
+ theRenderer->RemoveActor(mySphereActorSelected.GetPointer());
Superclass::RemoveFromRender(theRenderer);
+ theRenderer->RemoveActor(myCellActor.GetPointer());
}
mySphereActor->SetVisibility(false);
myCursorPyramid->SetVisibility(0);
+
if(theSelectionEvent.mySelectionMode == ActorSelection || !theIsHighlight) {
return Superclass::PreHighlight(theSelector,theIS,theSelectionEvent,theIsHighlight);
}
if(myPointPicker->GetActor() != this) {
return false;
}
-
+
vtkIdType aVtkId = myPointPicker->GetPointId();
if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && hasIO() ){
//float* aSelectionPoint = myPointPicker->GetSelectionPoint();
//
aMaxPointSize=myGaussPointsPL->GetMaxPointSize();
+ myCursorPyramid->SetHeight(aMaxPointSize);
myCursorPyramid->SetRadius(aRadius);
myCursorPyramid->SetColor(aColor);
myCursorPyramid->SetPosition(aNodeCoord);
- myCursorPyramid->SetHeight(aMaxPointSize);
+ myCursorPyramid->Init();
}
if(vtkDataArray *aVectorArray = aCellData->GetVectors()){
return anIsChanged;
}
-//----------------------------------------------------------------
-bool
-VISU_GaussPtsAct::Highlight( SVTK_Selector *theSelector,
- vtkInteractorStyle *theIS,
- SVTK_SelectionEvent theSelectionEvent,
- bool theIsHighlight )
+//==================================================================
+// function : Highlight
+// purpose :
+//==================================================================
+bool VISU_GaussPtsAct::Highlight( SVTK_Selector *theSelector,
+ vtkInteractorStyle *theIS,
+ SVTK_SelectionEvent theSelectionEvent,
+ bool theIsHighlight )
{
- int aTextVisibility, aSphereVisibility;
+ int aTextVisibility, aSphereVisibility, aSphereVisibilitySelected, aSelectionMode;
//
aTextVisibility=myTextActor->GetVisibility();
aSphereVisibility=mySphereActor->GetVisibility();
+ aSphereVisibilitySelected= mySphereActorSelected->GetVisibility();
//
myTextActor->SetVisibility(0);
mySphereActor->SetVisibility(0);
+ mySphereActorSelected->SetVisibility(0);
+ myCellActor->SetVisibility(0);
//
vtkRenderer *aRenderer=theIS->GetCurrentRenderer();
vtkRenderWindowInteractor* aRWI=theIS->GetInteractor();
//
- int aSelectionMode = theSelectionEvent.mySelectionMode;
+ 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);
}
//
- 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, bHasIO;
+ 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 );
-
if(myPointPicker->GetActor() != this) {
+
myTextActor->SetVisibility(aTextVisibility);
mySphereActor->SetVisibility(aSphereVisibility);
return bRet;
//
if( anObjId >= 0 ) {
bRet=!bRet;
+ //
+ // Update the Selector
if( theSelector->IsSelected( myIO ) ) {
theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
}
theSelector->AddOrRemoveIndex( myIO, anObjId, isShift );
theSelector->AddIObject( this );
}
- float* aNodeCoord = GetNodeCoord(anObjId);
- aRWI->FlyTo (aRenderer, aNodeCoord);
- aRenderer->ResetCameraClippingRange();
+ float *aNodeCoord, aRadius;
+ //
+ 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};
+ float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.};
myTextActor->SetWorldPoint(aWorldCoord);
//
- float aColor[3]={1.,1.,1.};
- mySphereActor->GetProperty()->SetColor(aColor);
+ // Selected
+ mySphereSourceSelected->SetCenter(aNodeCoord);
+ //
+ vtkDataSet* aDataSet = GetInput();
+ vtkCellData* aCellData = aDataSet->GetCellData();
+ vtkDataArray *aScalarArray = aCellData->GetScalars();
+ //
+ aRadius = myGaussPointsPL->GetPointSize(anObjId, aScalarArray);
+ mySphereSourceSelected->SetRadius(aRadius);
+ //
+ if (theSelector->HasIndex(myIO)) {
+ mySphereActorSelected->SetVisibility(1);
+ }
+ else {
+ mySphereActorSelected->SetVisibility(0);
+ mySphereActor->SetVisibility(1);
+ }
+ //
+ myTextActor->SetVisibility(1);
+ //
+ if (aSelectionMode==CellSelection) {
+ // Hilighting an element from the parent Mesh
+ int k, aNbPoints, aIDs[20];
+ float *pX;
+ vtkIdType aCellID;
+ vtkCell* pCell;
+ vtkPoints *pPoints;
+ VISU::TMeshOnEntityImpl* pMeshOnEntityImpl;
+ //
+ const VISU::PGaussMesh& aGaussMesh=myGaussPointsPL->GetGaussMesh();
+ VISU::TGaussMeshImpl* pGaussMeshImpl=
+ dynamic_cast<VISU::TGaussMeshImpl*>(aGaussMesh.get());
+ //
+ VISU::TGaussPointID anGPID= aGaussMesh->GetObjID(anObjId);
+ aCellID=anGPID.first;
+
+ pMeshOnEntityImpl=pGaussMeshImpl->GetParentMesh();
+ pCell=pMeshOnEntityImpl->GetElemCell(aCellID);
+ //
+ pPoints=pCell->GetPoints();
+ //
+ aNbPoints=pCell->GetNumberOfPoints();
+ for (k=0; k<aNbPoints; ++k) {
+ pX=pPoints->GetPoint(k);
+ aIDs[k]=k;
+ }
+ myCellSource->Initialize();
+ myCellSource->Allocate();
+ myCellSource->SetPoints(pCell->GetPoints());
+ myCellSource->InsertNextCell(pCell->GetCellType(), aNbPoints, aIDs);
+ //
+ vtkProperty* pPropertyCell=myCellActor->GetProperty();
+ pPropertyCell->SetAmbient(1.0);
+ pPropertyCell->SetDiffuse(0.0);
+ pPropertyCell->SetRepresentationToWireframe();
+ if (theSelector->HasIndex(myIO)) {
+ myCellActor->SetVisibility(1);
+ }
+ else {
+ myCellActor->SetVisibility(0);
+ }
+ }
+
+ return bRet;
//
}// if( anObjId >= 0 ) {
}//if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && hasIO())
}
}
}//else ... if(!isRectangle )
- myTextActor->SetVisibility(aTextVisibility);
- mySphereActor->SetVisibility(aSphereVisibility);
+ //myTextActor->SetVisibility(aTextVisibility);
+ //mySphereActor->SetVisibility(aSphereVisibility);
return bRet;
}
//
void VISU_CursorPyramid::SetRadius(const float theR)
{
myRadius=theR;
- Init();
+ //Init();
}
//==================================================================
// function : Radius