//! @param theOwners owners to change selection state
//! @param theSelScheme selection scheme
//! @return picking status
- Standard_EXPORT AIS_StatusOfPick Select (const AIS_NListOfEntityOwner& theOwners,
+ Standard_EXPORT AIS_StatusOfPick Select (const AIS_NArray1OfEntityOwner& theOwners,
const AIS_SelectionScheme theSelScheme);
//! Fits the view correspondingly to the bounds of selected objects.
{
(*aStatusPtr)->SetHilightStatus (Standard_False);
}
+ (*aStatusPtr)->SetHilightStyle (Handle(Prs3d_Drawer)());
}
for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
{
}
myLastActiveView = theView.get();
- if (myAutoHilight)
- {
- UnhilightSelected (Standard_False);
- }
myMainSel->Pick (thePntMin.x(), thePntMin.y(), thePntMax.x(), thePntMax.y(), theView);
- AIS_NListOfEntityOwner aPickedOwners;
- for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ AIS_NArray1OfEntityOwner aPickedOwners;
+ if (myMainSel->NbPicked() > 0)
{
- aPickedOwners.Append (myMainSel->Picked (aPickIter));
+ aPickedOwners.Resize (1, myMainSel->NbPicked(), Standard_False);
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ {
+ aPickedOwners.ChangeValue (aPickIter) = myMainSel->Picked (aPickIter);
+ }
}
return Select (aPickedOwners, theSelScheme);
}
myLastActiveView = theView.get();
- if (myAutoHilight)
- {
- UnhilightSelected (Standard_False);
- }
myMainSel->Pick (thePolyline, theView);
- AIS_NListOfEntityOwner aPickedOwners;
- for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ AIS_NArray1OfEntityOwner aPickedOwners;
+ if (myMainSel->NbPicked() > 0)
{
- aPickedOwners.Append (myMainSel->Picked (aPickIter));
+ aPickedOwners.Resize (1, myMainSel->NbPicked(), Standard_False);
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ {
+ aPickedOwners.ChangeValue (aPickIter) = myMainSel->Picked (aPickIter);
+ }
}
return Select (aPickedOwners, theSelScheme);
throw Standard_ProgramError ("AIS_InteractiveContext::SelectPoint() - invalid argument");
}
- if (myAutoHilight)
- {
- UnhilightSelected (Standard_False);
- }
-
myLastActiveView = theView.get();
myMainSel->Pick (thePnt.x(), thePnt.y(), theView);
- AIS_NListOfEntityOwner aPickedOwners;
- for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ AIS_NArray1OfEntityOwner aPickedOwners;
+ if (myMainSel->NbPicked() > 0)
{
- aPickedOwners.Append (myMainSel->Picked (aPickIter));
+ aPickedOwners.Resize (1, myMainSel->NbPicked(), Standard_False);
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ {
+ aPickedOwners.ChangeValue (aPickIter) = myMainSel->Picked (aPickIter);
+ }
}
return Select (aPickedOwners, theSelScheme);
}
}
- if (myAutoHilight && theSelScheme != AIS_SelectionScheme_XOR)
- {
- UnhilightSelected (Standard_False);
- }
-
- AIS_NListOfEntityOwner aPickedOwners;
- aPickedOwners.Append (myLastPicked);
+ AIS_NArray1OfEntityOwner aPickedOwners(1, 1);
+ aPickedOwners.ChangeValue (1) = myLastPicked;
return Select (aPickedOwners, theSelScheme);
}
//function : Select
//purpose :
//=======================================================================
-AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_NListOfEntityOwner& theOwners,
+AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_NArray1OfEntityOwner& theOwners,
const AIS_SelectionScheme theSelScheme)
{
- // all objects detected by the selector are taken, previous current objects are emptied,
- // new objects are put...
+ NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)> aSelOwnerMap (myAutoHilight ? mySelection->Objects().Size() : 0);
if (myAutoHilight)
{
clearDynamicHighlight();
+
+ // collect currently selected owners
+ for (AIS_NListOfEntityOwner::Iterator anOwnerIter (mySelection->Objects()); anOwnerIter.More(); anOwnerIter.Next())
+ {
+ aSelOwnerMap.Add (anOwnerIter.Value());
+ }
}
mySelection->SelectOwners (theOwners, theSelScheme, myFilters);
if (myAutoHilight)
{
- HilightSelected (Standard_False);
+ // collect lists of owners to unhighlight (unselected) and to highlight (selected)
+ AIS_NListOfEntityOwner anOwnersToUnhighlight, anOwnersToHighlight;
+ for (AIS_NListOfEntityOwner::Iterator anOwnerIter (mySelection->Objects()); anOwnerIter.More(); anOwnerIter.Next())
+ {
+ // add newly selected owners
+ const Handle(SelectMgr_EntityOwner)& anOwner = anOwnerIter.Value();
+ if (!aSelOwnerMap.RemoveKey (anOwner))
+ {
+ // newly selected owner
+ anOwnersToHighlight.Append (anOwner);
+ }
+ else
+ {
+ // already selected owner
+ if (!anOwner->IsAutoHilight()
+ && theSelScheme != AIS_SelectionScheme_XOR
+ && theSelScheme != AIS_SelectionScheme_Add)
+ {
+ // hack to perform AIS_InteractiveObject::ClearSelected() before highlighting
+ anOwnersToUnhighlight.Append (anOwner);
+ anOwnersToHighlight.Append (anOwner);
+ }
+ else if (anOwner->IsForcedHilight()
+ || !anOwner->IsAutoHilight())
+ {
+ anOwnersToHighlight.Append (anOwner);
+ }
+ }
+ }
+
+ for (NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)>::Iterator anOwnerIter (aSelOwnerMap); anOwnerIter.More(); anOwnerIter.Next())
+ {
+ // owners removed from selection
+ const Handle(SelectMgr_EntityOwner)& anOwner = anOwnerIter.Value();
+ anOwnersToUnhighlight.Append (anOwner);
+ }
+
+ unhighlightOwners (anOwnersToUnhighlight);
+ highlightOwners (anOwnersToHighlight);
}
Standard_Integer aSelNum = NbSelected();
--- /dev/null
+// Created on: 2003-05-04
+// Created by: Alexander Grigoriev (a-grigoriev@opencascade.com)
+// Copyright (c) 2003-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _AIS_NArray1Transient_HeaderFile
+#define _AIS_NArray1Transient_HeaderFile
+
+#include <SelectMgr_EntityOwner.hxx>
+#include <NCollection_Array1.hxx>
+
+typedef NCollection_Array1<Handle(SelectMgr_EntityOwner)> AIS_NArray1OfEntityOwner;
+
+#endif
//function : SelectOwners
//purpose :
//=======================================================================
-void AIS_Selection::SelectOwners (const AIS_NListOfEntityOwner& thePickedOwners,
+void AIS_Selection::SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwners,
const AIS_SelectionScheme theSelScheme,
const Handle(SelectMgr_Filter)& theFilter)
{
{
return;
}
+ case AIS_SelectionScheme_ReplaceExtra:
+ {
+ // If picked owners is equivalent to the selected then just clear selected
+ // Else go to AIS_SelectionScheme_Replace
+ if (thePickedOwners.Size() == myresult.Size())
+ {
+ Standard_Boolean isTheSame = Standard_True;
+ for (AIS_NArray1OfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
+ {
+ if (!myResultMap.IsBound (aSelIter.Value()))
+ {
+ isTheSame = Standard_False;
+ break;
+ }
+ }
+ if (isTheSame)
+ {
+ Clear();
+ return;
+ }
+ }
+ }
case AIS_SelectionScheme_Replace:
{
Clear();
- for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
+ for (AIS_NArray1OfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
{
appendOwner (aSelIter.Value(), theFilter);
}
}
case AIS_SelectionScheme_Add:
{
- for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
+ for (AIS_NArray1OfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
{
appendOwner (aSelIter.Value(), theFilter);
}
}
case AIS_SelectionScheme_Remove:
{
- for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
+ for (AIS_NArray1OfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
{
if (myResultMap.IsBound (aSelIter.Value()))
{
}
case AIS_SelectionScheme_XOR:
{
- for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
+ for (AIS_NArray1OfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
{
const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value();
if (anOwner.IsNull()
|| !anOwner->HasSelectable()
- || !theFilter->IsOk (anOwner))
+ || !theFilter->IsOk (anOwner, SelectMgr_FilterReaction_Select))
{
continue;
}
Clear();
return;
}
- case AIS_SelectionScheme_ReplaceExtra:
- {
- AIS_NListOfEntityOwner aPrevSelected = Objects();
- Clear();
-
- Standard_Boolean toAppend = false;
- if (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)
- toAppend = Standard_True;
- }
- for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
- {
- if (toAppend)
- appendOwner (aSelIter.Value(), theFilter);
- else
- XOROwner(aSelIter.Value(), aPrevSelected, theFilter);
- }
- return;
- }
}
}
{
if (theOwner.IsNull()
|| !theOwner->HasSelectable()
- || !theFilter->IsOk (theOwner))
+ || !theFilter->IsOk (theOwner, SelectMgr_FilterReaction_Select))
{
return AIS_SS_NotDone;
}
const AIS_NListOfEntityOwner& thePreviousSelected,
const Handle(SelectMgr_Filter)& theFilter)
{
- if (theOwner.IsNull() || !theOwner->HasSelectable() || !theFilter->IsOk (theOwner))
+ if (theOwner.IsNull() || !theOwner->HasSelectable() || !theFilter->IsOk (theOwner, SelectMgr_FilterReaction_Select))
return AIS_SS_NotDone;
if (thePreviousSelected.Contains (theOwner)) // was selected, should not be now
#define _AIS_Selection_HeaderFile
#include <AIS_NListOfEntityOwner.hxx>
+#include <AIS_NArray1OfEntityOwner.hxx>
#include <AIS_SelectionScheme.hxx>
#include <AIS_SelectStatus.hxx>
#include <Standard.hxx>
//! @param theOwners [in] elements to change selection state
//! @param theSelScheme [in] selection scheme, defines how owner is selected
//! @param theFilter [in] context filter to skip not acceptable owners
- Standard_EXPORT virtual void SelectOwners (const AIS_NListOfEntityOwner& thePickedOwners,
+ Standard_EXPORT virtual void SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwners,
const AIS_SelectionScheme theSelScheme,
const Handle(SelectMgr_Filter)& theFilter);
AIS_MultipleConnectedInteractive.lxx
AIS_NavigationMode.hxx
AIS_NListOfEntityOwner.hxx
+AIS_NArray1OfEntityOwner.hxx
AIS_Plane.cxx
AIS_Plane.hxx
AIS_PlaneTrihedron.cxx
AIS_SelectStatus.hxx
AIS_SelectionModesConcurrency.hxx
AIS_SelectionScheme.hxx
-AIS_SequenceOfDimension.hxx
AIS_SequenceOfInteractive.hxx
AIS_Shape.cxx
AIS_Shape.hxx