SVTK_SelectionEvent* theSelectionEvent,
bool theIsHighlight)
{
- myTextActor->SetVisibility(false);
mySphereActor->SetVisibility(false);
myCursorPyramid->SetVisibility(false);
- myCellActor->SetVisibility(false);
if(theSelectionEvent->mySelectionMode == ActorSelection || !theIsHighlight)
- return Superclass::PreHighlight(theSelector,theInteractorStyle,theSelectionEvent,theIsHighlight);
+ return Superclass::PreHighlight(theSelector,
+ theInteractorStyle,
+ theSelectionEvent,
+ theIsHighlight);
myPreHighlightActor->SetVisibility(false);
// To calculate display (2D) position of the annotation
float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.0};
- myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition());
- myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency());
- myTextActor->SetWorldPoint(aWorldCoord);
//
// To prepare the annotation text
std::ostringstream aStr;
float* aVal = aVectorArray->GetTuple3(aVtkId);
aStr<<"\nVector: {"<<aVal[0]<<"; "<<aVal[1]<<"; "<<aVal[2]<<"}";
}
-
+
std::string aString = aStr.str();
- myTextActor->SetText(aString.c_str());
myLastObjPointID = anObjId;
}
-
- myTextActor->SetVisibility(true);
mySphereActor->SetVisibility(true);
myCursorPyramid->SetVisibility(true);
myIsPreselected = theIsHighlight;
return anIsChanged;
}
-
-
//----------------------------------------------------------------------------
-bool
-VISU_GaussPtsAct
-::Highlight(SVTK_Selector* theSelector,
- vtkInteractorStyle* theInteractorStyle,
- SVTK_SelectionEvent* theSelectionEvent,
- bool theIsHighlight)
+bool VISU_GaussPtsAct::Highlight(SVTK_Selector* theSelector,
+ vtkInteractorStyle* theInteractorStyle,
+ SVTK_SelectionEvent* theSelectionEvent,
+ bool theIsHighlight)
{
- 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 = theInteractorStyle->GetCurrentRenderer();
vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor();
//
- Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
- mySelectionMode = aSelectionMode;
+ Selection_Mode aSelectionMode=theSelectionEvent->mySelectionMode;
+ mySelectionMode=aSelectionMode;
//
- if(aSelectionMode == ActorSelection ){
- myTextActor->SetVisibility(aTextVisibility);
- mySphereActor->SetVisibility(aSphereVisibility);
- mySphereActorSelected->SetVisibility(aSphereVisibilitySelected);
- return Superclass::Highlight(theSelector,theInteractorStyle,theSelectionEvent,theIsHighlight);
+ if(aSelectionMode==ActorSelection ){
+ return Superclass::Highlight(theSelector,
+ theInteractorStyle,
+ theSelectionEvent,
+ theIsHighlight);
}
//
bool bRet = false;
+
if(!theSelectionEvent->myIsRectangle){
myPointPicker->Pick(theSelectionEvent->myX,
aRenderer);
if(myPointPicker->GetActor() != this) {
- myTextActor->SetVisibility(aTextVisibility);
- mySphereActor->SetVisibility(aSphereVisibility);
- //
- if (GetScalarBarCtrl()->GetIsMarked()) {
- GetScalarBarCtrl()->SetIsMarked(false);
- GetScalarBarCtrl()->Update();
- }
+ theSelector->ClearIObjects();
return bRet;
}
theSelector->AddIObject(this);
}
//
- // FlyTo
float* aNodeCoord = GetNodeCoord(anObjId);
+ //
+ // FlyTo
float aDollyWas = anInteractor->GetDolly();
int aNumberOfFlyFramesWas=anInteractor->GetNumberOfFlyFrames();
aRenderer->ResetCameraClippingRange();
anInteractor->SetDolly(aDollyWas);
anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
- //
- // To calculate display (2D) position of the annotation
- float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.};
- myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition());
- myTextActor->SetWorldPoint(aWorldCoord);
- //
- // Selected
- mySphereSourceSelected->SetCenter(aNodeCoord);
- //
- vtkDataSet* aDataSet = GetInput();
- vtkCellData* aCellData = aDataSet->GetCellData();
- if(vtkDataArray* aScalarArray = aCellData->GetScalars()){
- float aVal = aScalarArray->GetTuple1(aVtkId);
- float aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray);
- mySphereSourceSelected->SetRadius(aRadius);
- if(theSelector->HasIndex(myIO)){
- mySphereActorSelected->SetVisibility(1);
- GetScalarBarCtrl()->SetIsMarked(true);
- GetScalarBarCtrl()->SetMarkValue(aVal);
- }
- else{
- mySphereActorSelected->SetVisibility(0);
- mySphereActor->SetVisibility(1);
- GetScalarBarCtrl()->SetIsMarked(false);
- }
- GetScalarBarCtrl()->Update();
- myTextActor->SetVisibility(1);
- }
- if(aSelectionMode == CellSelection){
- // Hilighting an element from the parent Mesh
- if(theSelector->HasIndex(myIO)){
- const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper =
- myGaussPointsPL->GetGaussPtsIDMapper();
- VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
-
- myCellSource->Reset();
- myCellSource->Modified(); // a VTK bug
- myCellSource->SetPoints(aParent->GetVTKOutput()->GetPoints());
-
- VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId);
- vtkIdType aCellID = aGaussPointID.first;
- vtkCell* aCell = aParent->GetElemCell(aCellID);
- myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
- myCellActor->GetProperty()->SetRepresentationToWireframe(); // VTK bug
- myCellActor->SetVisibility(1);
- }
- }
+
return bRet;
//
}// if( anObjId >= 0 ) {
}//if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && hasIO())
- if (GetScalarBarCtrl()->GetIsMarked()) {
- GetScalarBarCtrl()->SetIsMarked(false);
- GetScalarBarCtrl()->Update();
- }
- }
+ }//if(!theSelectionEvent->myIsRectangle){
+
return bRet;
}
-
//==================================================================
// function : highlight
// purpose :
//==================================================================
void
-VISU_GaussPtsAct
-::highlight(bool theHighlight,
- SVTK_Selector* theSelector)
+VISU_GaussPtsAct::highlight(bool theHighlight,
+ Selection_Mode theSelectionMode)
+{
+ myTextActor->SetVisibility(0);
+ mySphereActorSelected->SetVisibility(0);
+ myCellActor->SetVisibility(0);
+ GetScalarBarCtrl()->SetIsMarked(false);
+ GetScalarBarCtrl()->Update();
+}
+//==================================================================
+// function : highlight
+// purpose :
+//==================================================================
+void VISU_GaussPtsAct::highlight(bool theHighlight,
+ SVTK_Selector* theSelector)
{
TColStd_IndexedMapOfInteger aMapIndex;
+ //
theSelector->GetIndex( getIO(), aMapIndex );
int aNbOfParts = aMapIndex.Extent();
- if(!aNbOfParts){
- mySphereActorSelected->SetVisibility(0);
- GetScalarBarCtrl()->SetIsMarked(false);
- GetScalarBarCtrl()->Update();
- }else if(aNbOfParts == 1){
- int anObjId = aMapIndex(1);
- vtkIdType aVtkId = GetNodeVTKID(anObjId);
- if(aVtkId >= 0){
- float* aNodeCoord = GetNodeCoord(anObjId);
+ //
+ if(aNbOfParts!=1) {
+ return;
+ }
+ //
+ std::ostringstream aStr;
+ int anObjId = aMapIndex(1);
+ aStr<<"Global ID: "<<anObjId;
+ //
+ vtkIdType aVtkId = GetNodeVTKID(anObjId);
+ if(aVtkId >= 0){
+ float *aNodeCoord, aVal, aRadius;
+ //
+ aNodeCoord = GetNodeCoord(anObjId);
+ float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.};
+ //
+ vtkDataSet* aDataSet = GetInput();
+ vtkCellData* aCellData = aDataSet->GetCellData();
+ //
+ vtkDataArray* aScalarArray = aCellData->GetScalars();
+ vtkDataArray *aVectorArray = aCellData->GetVectors();
+ //
+ // mySphereSourceSelected
+ if(aScalarArray){
+ aVal = aScalarArray->GetTuple1(aVtkId);
+ aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray);
+ //
mySphereSourceSelected->SetCenter(aNodeCoord);
+ mySphereSourceSelected->SetRadius(aRadius);
+ mySphereActorSelected->SetVisibility(1);
+ // ScalarBarCtrl
+ GetScalarBarCtrl()->SetIsMarked(true);
+ GetScalarBarCtrl()->SetMarkValue(aVal);
+ GetScalarBarCtrl()->Update();
+ //
+ const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper=
+ myGaussPointsPL->GetGaussPtsIDMapper();
+ VISU::TNamedIDMapper* aParent=aGaussPtsIDMapper->GetParent();
- vtkDataSet* aDataSet = GetInput();
- vtkCellData* aCellData = aDataSet->GetCellData();
- if(vtkDataArray* aScalarArray = aCellData->GetScalars()){
- float aVal = aScalarArray->GetTuple1(aVtkId);
- float aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray);
- mySphereSourceSelected->SetRadius(aRadius);
- GetScalarBarCtrl()->SetIsMarked(true);
- GetScalarBarCtrl()->SetMarkValue(aVal);
- GetScalarBarCtrl()->Update();
+ VISU::TGaussPointID aGaussPointID = myGaussPointsPL->GetObjID(anObjId);
+ VISU::TCellID aCellID = aGaussPointID.first;
+ VISU::TLocalPntID aLocalPntID=aGaussPointID.second;
+ aStr<<"\nParentCellID: "<<aCellID;
+ std::string aParentName = aParent->GetElemName(aCellID);
+ if(aParentName != "") {
+ aStr<<"\nParentCellName: '"<<aParentName<<"'";
}
- mySphereActorSelected->SetVisibility(1);
+ aStr<<"\nLocalPntID: "<<aLocalPntID;
+ aStr<<"\nScalar: "<<aVal;
+ }
+ if(aVectorArray) {
+ float* pVec = aVectorArray->GetTuple3(aVtkId);
+ aStr<<"\nVector: {"<<pVec[0]<<"; "<<pVec[1]<<"; "<<pVec[2]<<"}";
+ }
+ //
+ // myTextActor
+ std::string aString=aStr.str();
+ myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition());
+ myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency());
+ myTextActor->SetWorldPoint(aWorldCoord);
+ myTextActor->SetText(aString.c_str());
+ myTextActor->SetVisibility(1);
+ //
+ // myCellActor
+ if(mySelectionMode==CellSelection){
+ const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper =
+ myGaussPointsPL->GetGaussPtsIDMapper();
+ VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
+
+ myCellSource->Reset();
+ myCellSource->Modified(); // a VTK bug
+ myCellSource->SetPoints(aParent->GetVTKOutput()->GetPoints());
+
+ VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId);
+ vtkIdType aCellID = aGaussPointID.first;
+ vtkCell* aCell = aParent->GetElemCell(aCellID);
+ myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+ myCellActor->GetProperty()->SetRepresentationToWireframe(); // VTK bug
+ myCellActor->SetVisibility(1);
}
}
}