Improved AIS_SelectionScheme_ReplaceExtra scheme (now is a part of AIS_SelectionScheme_Replace)
Replaced AIS_NListOfEntityOwner with AIS_NArray1OfEntityOwner
Fixed bug with incorrect highlighting in xor mode (select several times the same objects)
//! @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.
}
myMainSel->Pick (thePntMin.x(), thePntMin.y(), thePntMax.x(), thePntMax.y(), theView);
- AIS_NListOfEntityOwner aPickedOwners;
- for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ if (myMainSel->NbPicked() > 0)
{
- aPickedOwners.Append (myMainSel->Picked (aPickIter));
+ AIS_NArray1OfEntityOwner aPickedOwners (1, myMainSel->NbPicked());
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ {
+ aPickedOwners.ChangeValue (aPickIter) = myMainSel->Picked (aPickIter);
+ }
+
+ return Select (aPickedOwners, theSelScheme);
}
- return Select (aPickedOwners, theSelScheme);
+ return Select (AIS_NArray1OfEntityOwner(), theSelScheme);
}
//=======================================================================
}
myMainSel->Pick (thePolyline, theView);
- AIS_NListOfEntityOwner aPickedOwners;
- for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ if (myMainSel->NbPicked() > 0)
{
- aPickedOwners.Append (myMainSel->Picked (aPickIter));
+ AIS_NArray1OfEntityOwner aPickedOwners (1, myMainSel->NbPicked());
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ {
+ aPickedOwners.ChangeValue (aPickIter) = myMainSel->Picked (aPickIter);
+ }
+
+ return Select (aPickedOwners, theSelScheme);
}
- return Select (aPickedOwners, theSelScheme);
+ return Select (AIS_NArray1OfEntityOwner(), theSelScheme);
}
//=======================================================================
myLastActiveView = theView.get();
myMainSel->Pick (thePnt.x(), thePnt.y(), theView);
- AIS_NListOfEntityOwner aPickedOwners;
- for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ if (myMainSel->NbPicked() > 0)
{
- aPickedOwners.Append (myMainSel->Picked (aPickIter));
+ AIS_NArray1OfEntityOwner aPickedOwners (1, myMainSel->NbPicked());
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
+ {
+ aPickedOwners.ChangeValue (aPickIter) = myMainSel->Picked (aPickIter);
+ }
+
+ return Select (aPickedOwners, theSelScheme);
}
- return Select (aPickedOwners, theSelScheme);
+ return Select (AIS_NArray1OfEntityOwner(), theSelScheme);
}
//=======================================================================
}
}
- if (myAutoHilight && theSelScheme != AIS_SelectionScheme_XOR)
+ 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,
--- /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()
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;
- }
}
}
#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);
const Graphic3d_Vec2i aPnt1 (aPoints.Value (1).x(), -aPoints.Value (1).y());
const Graphic3d_Vec2i aPnt2 (aPoints.Value (3).x(), -aPoints.Value (3).y());
theCtx->MainSelector()->AllowOverlapDetection (aPnt1.y() != Min (aPnt1.y(), aPnt2.y()));
- if (myGL.Selection.IsXOR)
- {
- theCtx->ShiftSelect (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()),
- Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()),
- theView, false);
- }
- else
- {
- theCtx->MainSelector()->AllowOverlapDetection (aPnt1.y() != Min (aPnt1.y(), aPnt2.y()));
- theCtx->SelectRectangle (Graphic3d_Vec2i (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y())),
- Graphic3d_Vec2i (Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y())),
- theView,
- myGL.Selection.IsXOR ? AIS_SelectionScheme_XOR : AIS_SelectionScheme_Replace);
- theCtx->MainSelector()->AllowOverlapDetection (false);
- }
+ theCtx->SelectRectangle (Graphic3d_Vec2i (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y())),
+ Graphic3d_Vec2i (Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y())),
+ theView,
+ myGL.Selection.IsXOR ? AIS_SelectionScheme_XOR : AIS_SelectionScheme_Replace);
theCtx->MainSelector()->AllowOverlapDetection (false);
}
else if (aPoints.Length() >= 3)
AIS_MultipleConnectedInteractive.lxx
AIS_NavigationMode.hxx
AIS_NListOfEntityOwner.hxx
+AIS_NArray1OfEntityOwner.hxx
AIS_OffsetDimension.cxx
AIS_OffsetDimension.hxx
AIS_OffsetDimension.lxx