- if (myPoint == myOtherPoint) {
- // process point selection
- int w, h, x, y;
- myInteractor->GetSize(w, h);
- x = myPoint.x();
- y = h - myPoint.y() - 1;
-
- this->FindPokedRenderer(x, y);
- myInteractor->StartPickCallback();
-
- vtkPicker* aPicker = vtkPicker::SafeDownCast(myInteractor->GetPicker());
- aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
-
- SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
-
- if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
- int aVtkId = picker->GetCellId();
- if ( aVtkId >= 0 && aSActor && aSActor->hasIO() && IsValid( aSActor, aVtkId ) ) {
- int anObjId = aSActor->GetElemObjId(aVtkId);
- if(anObjId >= 0){
- Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
- if(aSelectionMode != EdgeOfCellSelection) {
- if(CheckDimensionId(aSelectionMode,aSActor,anObjId)){
- if(MYDEBUG) INFOS(" CellId : "<<anObjId);
- if (GetSelector()->IsSelected(anIO)) {
- // This IO is already in the selection
- GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
- } else {
- if (!myShiftState) {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
- GetSelector()->AddIObject(aSActor);
- }
- }
- }else{
- if (!myShiftState) {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- int anEdgeId = GetEdgeId(picker,aSActor,anObjId);
- if (anEdgeId >= 0) {
- if(MYDEBUG) INFOS(" CellId : "<<anObjId<<"; EdgeId : "<<anEdgeId);
- GetSelector()->AddOrRemoveIndex(anIO,anObjId,false);
- GetSelector()->AddOrRemoveIndex(anIO,-anEdgeId-1,true);
- GetSelector()->AddIObject(aSActor);
- }
- }
- }
- } else {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- } else if ( vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker) ) {
- int aVtkId = picker->GetPointId();
- if ( aVtkId >= 0 && IsValid( aSActor, aVtkId, true ) ) {
- if ( aSActor && aSActor->hasIO() ) {
- int anObjId = aSActor->GetNodeObjId(aVtkId);
- if(anObjId >= 0){
- Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
- if(GetSelector()->IsSelected(anIO)) {
- // This IO is already in the selection
- GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
- } else {
- if(!myShiftState) {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- if(MYDEBUG) INFOS(" PointId : "<<anObjId);
- GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
- GetSelector()->AddIObject(aSActor);
- }
- }
- }
- } else {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- } else {
- if ( aSActor && aSActor->hasIO() ) {
- this->PropPicked++;
- Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
- if(GetSelector()->IsSelected(anIO)) {
- // This IO is already in the selection
- if(myShiftState) {
- GetSelector()->RemoveIObject(aSActor);
- }
- }
- else {
- if(!myShiftState) {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- GetSelector()->AddIObject(aSActor);
- }
- }else{
- // No selection clear all
- this->PropPicked = 0;
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- }
- myInteractor->EndPickCallback();
- } else {
- //processing rectangle selection
- if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
- myInteractor->StartPickCallback();
-
- if (!myShiftState) {
- this->PropPicked = 0;
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
-
- // Compute bounds
- // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
- QRect rect(myPoint, myOtherPoint);
- rect = rect.normalize();
- int w, h;
- myInteractor->GetSize(w, h);
- int x1, y1, x2, y2;
- x1 = rect.left();
- y1 = h - rect.top() - 1;
- x2 = rect.right();
- y2 = h - rect.bottom() - 1;
-
- switch (aSelectionMode) {
- case NodeSelection: {
- if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(myInteractor->GetPicker()) ) {
- vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
- aListActors->InitTraversal();
- while (vtkActor* aActor = aListActors->GetNextActor()) {
- if (!aActor->GetVisibility())
- continue;
- if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
- if (aSActor->hasIO()) {
- Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
- if (anIO.IsNull())
- continue;
- if (aSelActiveCompOnly && aComponentDataType != anIO->getComponentDataType())
- continue;
- if (vtkDataSet* aDataSet = aSActor->GetInput()) {
- TColStd_MapOfInteger anIndices;
- for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
- float aPoint[3];
- aDataSet->GetPoint(i,aPoint);
- if (IsInRect(aPoint,x1,y1,x2,y2)){
- float aDisp[3];
- ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp);
- if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){
- if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){
- if(anActorCollection->IsItemPresent(aSActor)){
- float aPickedPoint[3];
- aPointPicker->GetMapperPosition(aPickedPoint);
- vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
- if ( aVtkId >= 0 && IsValid( aSActor, aVtkId, true ) ){
- int anObjId = aSActor->GetNodeObjId(aVtkId);
- anIndices.Add(anObjId);
- }
- }
- }
- }
- }
- }
- if (!anIndices.IsEmpty()) {
- GetSelector()->AddOrRemoveIndex(anIO,anIndices,true); // ENK false to true
- GetSelector()->AddIObject(aSActor);
- anIndices.Clear();
- }else{
- GetSelector()->RemoveIObject(aSActor);
- }
- }
- }
- }
- }
- }
- break;
- }
- case CellSelection:
- case EdgeOfCellSelection:
- case EdgeSelection:
- case FaceSelection:
- case VolumeSelection:
- {
- vtkSmartPointer<VTKViewer_CellRectPicker> picker = VTKViewer_CellRectPicker::New();
- picker->SetTolerance(0.001);
- picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
-
- vtkActorCollection* aListActors = picker->GetActors();
- aListActors->InitTraversal();
- while(vtkActor* aActor = aListActors->GetNextActor()) {
- if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
- if (aSActor->hasIO()) {
- Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
- if (aSelActiveCompOnly && aComponentDataType != anIO->getComponentDataType())
- continue;
- VTKViewer_CellDataSet cellList = picker->GetCellData(aActor);
- if ( !cellList.empty() ) {
- if(MYDEBUG) INFOS ( " NAME Actor : " << aSActor->getName() );
- TColStd_MapOfInteger anIndexes;
- VTKViewer_CellDataSet::iterator it;
- for ( it = cellList.begin(); it != cellList.end(); ++it ) {
- int aCellId = (*it).cellId;
-
- if ( !IsValid( aSActor, aCellId ) )
- continue;
-
- int anObjId = aSActor->GetElemObjId(aCellId);
- if (anObjId != -1){
- if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) {
- anIndexes.Add(anObjId);
- }
- }
- }
- GetSelector()->AddOrRemoveIndex(anIO,anIndexes,true);
- GetSelector()->AddIObject(aSActor);
- }
- }
- }
- }