- QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType();
- if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
- m_Interactor->StartPickCallback();
-
- if (!myShiftState) {
- this->PropPicked = 0;
- this->HighlightProp( NULL );
- aSel->ClearIObjects();
- }
-
- // Compute bounds
- // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
- QRect rect(myPoint, myOtherPoint);
- rect = rect.normalize();
- int w, h;
- m_Interactor->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(m_Interactor->GetPicker()) ) {
- vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
- aListActors->InitTraversal();
- while (vtkActor* aActor = aListActors->GetNextActor()) {
- if (!aActor->GetVisibility())
- continue;
- if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) {
- if (SActor->hasIO()) {
- Handle(SALOME_InteractiveObject) IO = SActor->getIO();
- if (IO.IsNull())
- continue;
- if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType())
- continue;
- if (vtkDataSet* aDataSet = SActor->GetInput()) {
- SALOME_Selection::TContainerOfId 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(SActor)){
- float aPickedPoint[3];
- aPointPicker->GetMapperPosition(aPickedPoint);
- vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
- if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){
- int anObjId = SActor->GetNodeObjId(aVtkId);
- anIndices.insert(anObjId);
- }
- }
- }
- }
- }
- }
- if (!anIndices.empty()) {
- aSel->AddOrRemoveIndex(IO, anIndices, true, false);
- aSel->AddIObject(IO, false);
- anIndices.clear();
- }else{
- aSel->RemoveIObject(IO, false);
- }
- }
- }
- }
- }
- }
- 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) aIO = aSActor->getIO();
- if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType())
- continue;
- VTKViewer_CellDataSet cellList = picker->GetCellData(aActor);
- if ( !cellList.empty() ) {
- SALOME_Selection::TContainerOfId 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.insert(anObjId);
- }
- }
- }
- aSel->AddOrRemoveIndex(aIO, anIndexes, true, false);
- aSel->AddIObject(aIO, false);
- }
- }
- }
- }
- }
- break;
- case ActorSelection: // objects selection
- {
- vtkSmartPointer<VTKViewer_RectPicker> picker = VTKViewer_RectPicker::New();
- picker->SetTolerance(0.001);
- picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
-
- vtkActorCollection* aListActors = picker->GetActors();
- SALOME_ListIO aListIO;
- aListActors->InitTraversal();
- while(vtkActor* aActor = aListActors->GetNextActor()) {
- if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
- if (aSActor->hasIO()) {
- Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
- if (!IsStored(aIO,aListIO))
- aListIO.Append(aIO);
- }
- }
- }
- if (!aListIO.IsEmpty()) {
- SALOME_ListIteratorOfListIO It(aListIO);
- for(;It.More();It.Next()) {
- Handle(SALOME_InteractiveObject) IOS = It.Value();
- this->PropPicked++;
- aSel->AddIObject( IOS, false );
- }
- }
- } // end case 4
- } //end switch
- m_Interactor->EndPickCallback();
- }
- aActiveStudy->update3dViewers();
+ QString aComponentDataType = SUIT_Application::getDesktop()->getComponentDataType();
+ if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
+ m_Interactor->StartPickCallback();
+
+ if (!myShiftState) {
+ this->PropPicked = 0;
+ this->HighlightProp( NULL );
+ aSel->ClearIObjects();
+ }
+
+ // Compute bounds
+ // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
+ QRect rect(myPoint, myOtherPoint);
+ rect = rect.normalize();
+ int w, h;
+ m_Interactor->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(m_Interactor->GetPicker()) ) {
+ vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
+ aListActors->InitTraversal();
+ while (vtkActor* aActor = aListActors->GetNextActor()) {
+ if (!aActor->GetVisibility())
+ continue;
+ if(SALOME_Actor* SActor = SALOME_Actor::SafeDownCast(aActor)) {
+ if (SActor->hasIO()) {
+ Handle(SALOME_InteractiveObject) IO = SActor->getIO();
+ if (IO.IsNull())
+ continue;
+ if (aSelActiveCompOnly && aComponentDataType != IO->getComponentDataType())
+ continue;
+ if (vtkDataSet* aDataSet = SActor->GetInput()) {
+ SALOME_Selection::TContainerOfId 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(SActor)){
+ float aPickedPoint[3];
+ aPointPicker->GetMapperPosition(aPickedPoint);
+ vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
+ if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){
+ int anObjId = SActor->GetNodeObjId(aVtkId);
+ anIndices.insert(anObjId);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (!anIndices.empty()) {
+ aSel->AddOrRemoveIndex(IO, anIndices, true, false);
+ aSel->AddIObject(IO, false);
+ anIndices.clear();
+ }else{
+ aSel->RemoveIObject(IO, false);
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+ case CellSelection:
+ case EdgeOfCellSelection:
+ case EdgeSelection:
+ case FaceSelection:
+ case VolumeSelection:
+ {
+ vtkSmartPointer<VTKViewer_CellAreaPicker> 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) aIO = aSActor->getIO();
+ if (aSelActiveCompOnly && aComponentDataType != aIO->getComponentDataType())
+ continue;
+ VTKViewer_CellDataSet cellList = picker->GetCellData(aActor);
+ if ( !cellList.empty() ) {
+ SALOME_Selection::TContainerOfId 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.insert(anObjId);
+ }
+ }
+ }
+ aSel->AddOrRemoveIndex(aIO, anIndexes, true, false);
+ aSel->AddIObject(aIO, false);
+ }
+ }
+ }
+ }
+ }
+ break;
+ case ActorSelection: // objects selection
+ {
+ vtkSmartPointer<VTKViewer_AreaPicker> picker = VTKViewer_AreaPicker::New();
+ picker->SetTolerance(0.001);
+ picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
+
+ vtkActorCollection* aListActors = picker->GetActors();
+ SALOME_ListIO aListIO;
+ aListActors->InitTraversal();
+ while(vtkActor* aActor = aListActors->GetNextActor()) {
+ if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
+ if (aSActor->hasIO()) {
+ Handle(SALOME_InteractiveObject) aIO = aSActor->getIO();
+ if (!IsStored(aIO,aListIO))
+ aListIO.Append(aIO);
+ }
+ }
+ }
+ if (!aListIO.IsEmpty()) {
+ SALOME_ListIteratorOfListIO It(aListIO);
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IOS = It.Value();
+ this->PropPicked++;
+ aSel->AddIObject( IOS, false );
+ }
+ }
+ } // end case 4
+ } //end switch
+ m_Interactor->EndPickCallback();
+ }
+ aActiveStudy->update3dViewers();