#include <AIS_ListOfInteractive.hxx>
#include <AIS_Selection.hxx>
#include <AIS_SelectionModesConcurrency.hxx>
-#include <AIS_SelectionScheme.hxx>
#include <AIS_StatusOfDetection.hxx>
#include <AIS_StatusOfPick.hxx>
#include <AIS_TypeOfIso.hxx>
return AddSelect (theObject->GlobalSelOwner());
}
- //! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
- //! The objects detected are passed to the main viewer, which is then updated.
- Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
- const Standard_Integer theYPMin,
- const Standard_Integer theXPMax,
- const Standard_Integer theYPMax,
- const Handle(V3d_View)& theView,
- const AIS_SelectionScheme theSelScheme);
-
- //! polyline selection; clears the previous picked list
- Standard_EXPORT AIS_StatusOfPick Select (const TColgp_Array1OfPnt2d& thePolyline,
- const Handle(V3d_View)& theView,
- const AIS_SelectionScheme theSelScheme);
-
- //! Stores and hilights the previous detected; Unhilights the previous picked.
- //! @sa MoveTo().
- Standard_EXPORT AIS_StatusOfPick Select (const AIS_SelectionScheme theSelScheme);
-
//! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
//! The objects detected are passed to the main viewer, which is then updated.
Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
//! Returns bounding box of selected objects.
Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const;
- //! Sets list of owner selected/deselected using selection scheme
- //! It is possible that selection of other objects is changed relatively selection scheme .
- //! \param theOwner owners to change selection state
- //! \param theSelScheme selection scheme
- Standard_EXPORT AIS_StatusOfPick Select (const AIS_NListOfEntityOwner& theOwners,
- const AIS_SelectionScheme theSelScheme);
-
//! Fits the view correspondingly to the bounds of selected objects.
//! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
const Standard_Integer theXPMax,
const Standard_Integer theYPMax,
const Handle(V3d_View)& theView,
- const AIS_SelectionScheme theSelScheme)
+ 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...
+ ClearSelected (Standard_False);
myLastActiveView = theView.get();
- if (!myLastPicked.IsNull())
+ myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
- Graphic3d_Vec2i aMousePos (-1, -1);
- if (myMainSel->GetManager().GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Point)
- {
- aMousePos.SetValues ((Standard_Integer )myMainSel->GetManager().GetMousePosition().X(),
- (Standard_Integer )myMainSel->GetManager().GetMousePosition().Y());
- }
- if (myLastPicked->HandleMouseClick (aMousePos, Aspect_VKeyMouse_LeftButton, Aspect_VKeyFlags_NONE, false))
- {
- return AIS_SOP_NothingSelected;
- }
- }
+ const Handle(SelectMgr_EntityOwner)& aCurOwner = myMainSel->Picked (aPickIter);
+ if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
+ continue;
- myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
+ mySelection->Select (aCurOwner);
+ }
- AIS_NListOfEntityOwner aPickedOwners;
- for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ if (myAutoHilight)
{
- aPickedOwners.Append (myMainSel->Picked (aPickIter));
+ HilightSelected (toUpdateViewer);
}
- return Select (aPickedOwners, theSelScheme);
+ Standard_Integer aSelNum = NbSelected();
+
+ return (aSelNum == 0) ? AIS_SOP_NothingSelected
+ : (aSelNum == 1) ? AIS_SOP_OneSelected
+ : AIS_SOP_SeveralSelected;
+
}
//=======================================================================
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
const Handle(V3d_View)& theView,
- const AIS_SelectionScheme theSelScheme)
+ 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...
+ ClearSelected (Standard_False);
+ myLastActiveView = theView.get();
myMainSel->Pick (thePolyline, theView);
-
- AIS_NListOfEntityOwner aPickedOwners;
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
- aPickedOwners.Append (myMainSel->Picked (aPickIter));
+ const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
+ if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
+ continue;
+
+ mySelection->Select (anOwner);
+ }
+
+ if (myAutoHilight)
+ {
+ HilightSelected (toUpdateViewer);
}
- return Select (aPickedOwners, theSelScheme);
+ Standard_Integer aSelNum = NbSelected();
+
+ return (aSelNum == 0) ? AIS_SOP_NothingSelected
+ : (aSelNum == 1) ? AIS_SOP_OneSelected
+ : AIS_SOP_SeveralSelected;
+
}
//=======================================================================
//function : Select
//purpose :
//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_SelectionScheme theSelScheme)
+AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
{
- // special case: single selection of detected owner - is it necessary ?
- /*if (myWasLastMain && !myLastinMain.IsNull() && !myAutoHilight &&
- (myLastinMain->IsSelected()
- && !myLastinMain->IsForcedHilight()
- && NbSelected() <= 1))
+ if (!myLastPicked.IsNull())
{
- mySelection->selectOwner(myLastinMain, aPrevSelected, theSelScheme);
-
Graphic3d_Vec2i aMousePos (-1, -1);
if (myMainSel->GetManager().GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Point)
{
{
return AIS_SOP_NothingSelected;
}
- return getStatusOfPick (NbSelected());
- }*/
- AIS_NListOfEntityOwner aPickedOwners;
- if (!myLastPicked.IsNull() &&
- myLastPicked->HasSelectable())
- {
- Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(myLastPicked->Selectable());
- if (!anIO.IsNull() &&
- myObjects.IsBound(anIO))
+ if (myAutoHilight)
{
- aPickedOwners.Append (myLastPicked);
+ clearDynamicHighlight();
+ }
+ if (!myLastPicked->IsSelected()
+ || myLastPicked->IsForcedHilight()
+ || NbSelected() > 1)
+ {
+ SetSelected (myLastPicked, Standard_False);
+ if(toUpdateViewer)
+ {
+ UpdateCurrentViewer();
+ }
}
}
+ else
+ {
+ ClearSelected (toUpdateViewer);
+ }
- return Select (aPickedOwners, theSelScheme);
-}
-
-//=======================================================================
-//function : Select
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
- const Standard_Integer theYPMin,
- const Standard_Integer theXPMax,
- const Standard_Integer theYPMax,
- const Handle(V3d_View)& theView,
- const Standard_Boolean)
-{
- return Select (theXPMin, theYPMin, theXPMax, theYPMax, theView, AIS_SelectionScheme_ClearAndAdd);
-}
-
-//=======================================================================
-//function : Select
-//purpose : Selection by polyline
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
- const Handle(V3d_View)& theView,
- const Standard_Boolean)
-{
- return Select (thePolyline, theView, AIS_SelectionScheme_ClearAndAdd);
-}
+ Standard_Integer aSelNum = NbSelected();
-//=======================================================================
-//function : Select
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean)
-{
- return Select (AIS_SelectionScheme_ClearAndAdd);
+ return (aSelNum == 0) ? AIS_SOP_NothingSelected
+ : (aSelNum == 1) ? AIS_SOP_OneSelected
+ : AIS_SOP_SeveralSelected;
}
//=======================================================================
//function : ShiftSelect
//purpose :
//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean)
+AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
{
- return Select (AIS_SelectionScheme_Switch);
+ if (myAutoHilight)
+ {
+ clearDynamicHighlight();
+ }
+ if (!myLastPicked.IsNull())
+ {
+ AddOrRemoveSelected (myLastPicked, toUpdateViewer);
+ }
+
+ Standard_Integer aSelNum = NbSelected();
+
+ return (aSelNum == 0) ? AIS_SOP_NothingSelected
+ : (aSelNum == 1) ? AIS_SOP_OneSelected
+ : AIS_SOP_SeveralSelected;
}
//=======================================================================
const Standard_Integer theXPMax,
const Standard_Integer theYPMax,
const Handle(V3d_View)& theView,
- const Standard_Boolean)
+ const Standard_Boolean toUpdateViewer)
{
- return Select (theXPMin, theYPMin, theXPMax, theYPMax, theView, AIS_SelectionScheme_Switch);
+ if (theView->Viewer() != myMainVwr)
+ {
+ throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
+ }
+
+ myLastActiveView = theView.get();
+ if (myAutoHilight)
+ {
+ UnhilightSelected (Standard_False);
+ }
+ myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ {
+ const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
+ if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
+ continue;
+
+ mySelection->Select (anOwner);
+ }
+
+ if (myAutoHilight)
+ {
+ HilightSelected (toUpdateViewer);
+ }
+
+ Standard_Integer aSelNum = NbSelected();
+
+ return (aSelNum == 0) ? AIS_SOP_NothingSelected
+ : (aSelNum == 1) ? AIS_SOP_OneSelected
+ : AIS_SOP_SeveralSelected;
+
}
//=======================================================================
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
const Handle(V3d_View)& theView,
- const Standard_Boolean)
+ const Standard_Boolean toUpdateViewer)
{
- return Select (thePolyline, theView, AIS_SelectionScheme_Switch);
-}
+ if (theView->Viewer() != myMainVwr)
+ {
+ throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
+ }
-//=======================================================================
-//function : Select
-//purpose :
-//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_NListOfEntityOwner& theOwners,
- const AIS_SelectionScheme theSelScheme)
-{
- // all objects detected by the selector are taken, previous current objects are emptied,
- // new objects are put...
+ myLastActiveView = theView.get();
if (myAutoHilight)
{
- clearDynamicHighlight();
UnhilightSelected (Standard_False);
}
+ myMainSel->Pick (thePolyline, theView);
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ {
+ const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
+ if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
+ continue;
- mySelection->SelectOwners (theOwners, theSelScheme, myFilters);
+ mySelection->Select (anOwner);
+ }
if (myAutoHilight)
{
- HilightSelected (Standard_False);
+ HilightSelected (toUpdateViewer);
}
Standard_Integer aSelNum = NbSelected();
#include <AIS_Selection.hxx>
#include <AIS_InteractiveObject.hxx>
-#include <AIS_SelectionScheme.hxx>
-#include <SelectMgr_Filter.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
theObject->SetSelected (Standard_True);
return AIS_SS_Added;
}
-
-//=======================================================================
-//function : SelectOwners
-//purpose :
-//=======================================================================
-void AIS_Selection::SelectOwners (const AIS_NListOfEntityOwner& thePickedOwners,
- const int theSelScheme,
- const Handle(SelectMgr_Filter)& theFilter)
-{
- int aSelScheme = theSelScheme;
- AIS_NListOfEntityOwner aPrevSelected = Objects();
- if (theSelScheme & AIS_SelectionScheme_Clear)
- {
- Clear();
-
- if (theSelScheme & AIS_SelectionScheme_Switch &&
- theSelScheme & AIS_SelectionScheme_PickedIfEmpty &&
- thePickedOwners.Size() < aPrevSelected.Size())
- {
- // check if all picked objects are in previous selected list, if so, all objects will be deselected,
- // but in mode AIS_SelectionScheme_PickedIfEmpty new picked objects should be selected, here, after Clear, Add
- Standard_Boolean anOtherFound = Standard_False;
- for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
- {
- anOtherFound = !aPrevSelected.Contains (aSelIter.Value());
- if (anOtherFound)
- break;
- }
- if (!anOtherFound)
- aSelScheme = AIS_SelectionScheme_Add;
- }
- }
-
- for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
- {
- selectOwner(aSelIter.Value(), aPrevSelected, aSelScheme, theFilter);
- }
-}
-
-//=======================================================================
-//function : selectOwner
-//purpose :
-//=======================================================================
-AIS_SelectStatus AIS_Selection::selectOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
- const AIS_NListOfEntityOwner& thePreviousSelected,
- const int theSelScheme,
- const Handle(SelectMgr_Filter)& theFilter)
-{
- if (theOwner.IsNull() || !theOwner->HasSelectable() || !theFilter->IsOk (theOwner, SelectMgr_FilterReaction_Select))
- return AIS_SS_NotDone;
-
- if (theSelScheme & AIS_SelectionScheme_Add)
- {
- return AddSelect (theOwner);
- }
- else if (theSelScheme & AIS_SelectionScheme_Switch)
- {
- if (thePreviousSelected.Contains (theOwner)) // was selected, should not be now
- {
- if (theOwner->IsSelected())
- return Select (theOwner); // deselect
- }
- else
- return AddSelect (theOwner); // was not selected, should be now
- }
-
- return AIS_SS_NotDone;
-}