X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=blobdiff_plain;f=src%2FAIS%2FAIS_InteractiveContext_1.cxx;h=f7dac0792a2b980750ac7c5242ed58eddd2d80ef;hb=8c088c52fc6383168c53f674205c983d157925f7;hpb=d9ca2e0cb1399534b1196f652d86b95ee4c5a49f diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 2fa619a635..f7dac0792a 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -303,6 +303,11 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th const Handle(V3d_View)& theView, const Standard_Boolean theToRedrawOnUpdate) { + if (theView->Viewer() != myMainVwr) + { + throw Standard_ProgramError ("AIS_InteractiveContext::MoveTo() - invalid argument"); + } + if (HasOpenedContext()) { myWasLastMain = Standard_True; @@ -313,11 +318,6 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th myCurHighlighted = 0; myDetectedSeq.Clear(); - if (theView->Viewer() != myMainVwr) - { - return AIS_SOD_Error; - } - // preliminaires myLastPicked = myLastinMain; myWasLastMain = Standard_True; @@ -454,6 +454,11 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi const Handle(V3d_View)& theView, const Standard_Boolean toUpdateViewer) { + if (theView->Viewer() != myMainVwr) + { + throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument"); + } + // all objects detected by the selector are taken, previous current objects are emptied, // new objects are put... @@ -466,18 +471,11 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi ClearSelected (Standard_False); - Handle(StdSelect_ViewerSelector3d) aSelector; - - if (theView->Viewer() == myMainVwr) - { - aSelector = myMainSel; - myWasLastMain = Standard_True; - } - - aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); - for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter) + myWasLastMain = Standard_True; + myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); + for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter) { - const Handle(SelectMgr_EntityOwner)& aCurOwner = aSelector->Picked (aPickIter); + const Handle(SelectMgr_EntityOwner)& aCurOwner = myMainSel->Picked (aPickIter); if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner)) continue; @@ -503,6 +501,11 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the const Handle(V3d_View)& theView, const Standard_Boolean toUpdateViewer) { + if (theView->Viewer() != myMainVwr) + { + throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument"); + } + // all objects detected by the selector are taken, previous current objects are emptied, // new objects are put... @@ -513,18 +516,11 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the ClearSelected (Standard_False); - Handle(StdSelect_ViewerSelector3d) aSelector; - - if (theView->Viewer() == myMainVwr) - { - aSelector = myMainSel; - myWasLastMain = Standard_True; - } - - aSelector->Pick (thePolyline, theView); - for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter) + myWasLastMain = Standard_True; + myMainSel->Pick (thePolyline, theView); + for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter) { - const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter); + const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter); if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) continue; @@ -640,6 +636,11 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the const Handle(V3d_View)& theView, const Standard_Boolean toUpdateViewer) { + if (theView->Viewer() != myMainVwr) + { + throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument"); + } + if (HasOpenedContext()) { return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax, @@ -648,21 +649,11 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the UnhilightSelected (Standard_False); - Handle(StdSelect_ViewerSelector3d) aSelector; - if (theView->Viewer() == myMainVwr) - { - aSelector = myMainSel; - myWasLastMain = Standard_True; - } - else - { - return AIS_SOP_NothingSelected; - } - - aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); - for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter) + myWasLastMain = Standard_True; + myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); + for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter) { - const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter); + const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter); if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) continue; @@ -688,6 +679,11 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d const Handle(V3d_View)& theView, const Standard_Boolean toUpdateViewer) { + if (theView->Viewer() != myMainVwr) + { + throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument"); + } + if (HasOpenedContext()) { return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer); @@ -695,22 +691,11 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d UnhilightSelected (Standard_False); - Handle(StdSelect_ViewerSelector3d) aSelector; - - if (theView->Viewer() == myMainVwr) - { - aSelector= myMainSel; - myWasLastMain = Standard_True; - } - else - { - return AIS_SOP_NothingSelected; - } - - aSelector->Pick (thePolyline, theView); - for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter) + myWasLastMain = Standard_True; + myMainSel->Pick (thePolyline, theView); + for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter) { - const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter); + const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter); if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) continue; @@ -1482,21 +1467,30 @@ Standard_Boolean AIS_InteractiveContext::HasDetected() const Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const { - if(HasOpenedContext()) + if (HasOpenedContext()) + { return myLocalContexts(myCurLocalIndex)->HasDetectedShape(); - return Standard_False; + } + + Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked); + return !anOwner.IsNull() + && anOwner->HasShape(); } //======================================================================= //function : DetectedShape //purpose : //======================================================================= - -const TopoDS_Shape& -AIS_InteractiveContext::DetectedShape() const +const TopoDS_Shape& AIS_InteractiveContext::DetectedShape() const { - return myLocalContexts(myCurLocalIndex)->DetectedShape(); -} + if (HasOpenedContext()) + { + return myLocalContexts(myCurLocalIndex)->DetectedShape(); + } + + Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (myLastPicked); + return anOwner->Shape(); +} //======================================================================= //function : DetectedInteractive @@ -1696,13 +1690,9 @@ const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const Standard_DISABLE_DEPRECATION_WARNINGS Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject()); Standard_ENABLE_DEPRECATION_WARNINGS - - if (aCurrentShape.IsNull()) - { - return AIS_InteractiveContext_myDummyShape; - } - - return aCurrentShape->Shape(); + return !aCurrentShape.IsNull() + ? aCurrentShape->Shape() + : AIS_InteractiveContext_myDummyShape; } //======================================================================= @@ -1717,8 +1707,8 @@ Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() co } return MoreDetected() - ? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable()) - : NULL; + ? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable()) + : Handle(AIS_InteractiveObject)(); } //=======================================================================