NIS_InteractiveContext::NIS_InteractiveContext ()
: myAllocator (new NIS_Allocator(1024*100)),
+ myLastObjectId (0),
+ myObjects (1000),
// myDrawers (101, myAllocator),
mySelectionMode (Mode_NoSelection),
myIsShareDrawList (Standard_True)
{
// ID == 0 is invalid so we reserve this item from subsequent allocation.
- myObjects.Append (NULL);
+ myObjects.SetValue(myLastObjectId, NULL);
}
//=======================================================================
}
}
+//=======================================================================
+//function : GetObject
+//purpose :
+//=======================================================================
+
+const Handle_NIS_InteractiveObject& NIS_InteractiveContext::GetObject
+ (const Standard_Integer theID) const
+{
+ if (!myObjects.IsBound(theID))
+ {
+ static Handle_NIS_InteractiveObject aNull;
+ return aNull;
+ }
+ return myObjects(theID);
+}
+
//=======================================================================
//function : redraw
//purpose :
aDrawer->removeObject(theObj.operator->(), isUpdateViews);
theObj->myID = 0;
theObj->myDrawer.Nullify();
- myObjects(anID).Nullify();
+ myObjects.UnsetValue(anID);
+ myMapNonSelectableObjects.Remove(anID);
}
}
}
void NIS_InteractiveContext::DisplayAll ()
{
// UnHide all objects in the Context
- NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator anIter(myObjects);
+ NCollection_SparseArray <Handle_NIS_InteractiveObject>::ConstIterator
+ anIter(myObjects);
for (; anIter.More(); anIter.Next()) {
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
if (anObj.IsNull() == Standard_False)
void NIS_InteractiveContext::EraseAll ()
{
// Hide all objects in the Context
- NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator anIter(myObjects);
+ NCollection_SparseArray <Handle_NIS_InteractiveObject>::ConstIterator
+ anIter(myObjects);
for (; anIter.More(); anIter.Next()) {
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
if (anObj.IsNull() == Standard_False) {
void NIS_InteractiveContext::RemoveAll ()
{
// Remove objects from the Context
- NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator anIter(myObjects);
+ NCollection_SparseArray <Handle_NIS_InteractiveObject>::Iterator
+ anIter(myObjects);
for (; anIter.More(); anIter.Next()) {
Handle(NIS_InteractiveObject)& anObj = anIter.ChangeValue();
if (anObj.IsNull() == Standard_False) {
myAllocator->Reset();
myAllocator->ResetCounters();
- myDrawers.Clear();
-
// Remove objects from maps
myMapObjects[0].Clear();
myMapObjects[1].Clear();
myMapObjects[2].Clear();
myMapObjects[3].Clear();
myMapNonSelectableObjects.Clear();
+ myObjects.Clear();
}
//=======================================================================
if (mySelectionMode != Mode_NoSelection || isOnlySel == Standard_False)
{
DetectedEnt anEnt;
- NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator
+ NCollection_SparseArray <Handle_NIS_InteractiveObject>::ConstIterator
anIter(myObjects);
for (; anIter.More(); anIter.Next()) {
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
{
Standard_Boolean aResult (Standard_False);
if (mySelectionMode != Mode_NoSelection) {
- NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator
+ NCollection_SparseArray <Handle_NIS_InteractiveObject>::ConstIterator
anIter(myObjects);
for (; anIter.More(); anIter.Next()) {
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
Standard_Boolean aResult (Standard_False);
if (mySelectionMode != Mode_NoSelection) {
- NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator
+ NCollection_SparseArray <Handle_NIS_InteractiveObject>::ConstIterator
anIter(myObjects);
for (; anIter.More(); anIter.Next()) {
Handle(NIS_InteractiveObject) anObj;
theObj->Clone(myAllocator, anObj);
theObj = anObj;
- anObj->myID = myObjects.Length();
- myObjects.Append (anObj);
+ anObj->myID = ++myLastObjectId;
+ myObjects.SetValue (myLastObjectId, anObj);
myMapObjects[theDrawType].Add(anObj->myID);
anObj->myDrawType = theDrawType;
}
// Compact the memory: clone all objects to a new allocator, release
// the old allocator instance.
aNewAlloc = new NIS_Allocator;
- NCollection_Vector<Handle_NIS_InteractiveObject>::Iterator
+ NCollection_SparseArray<Handle_NIS_InteractiveObject>::Iterator
anIter(myObjects);
for (; anIter.More(); anIter.Next()) {
if (anIter.Value().IsNull() == Standard_False) {
#include <Handle_NIS_InteractiveObject.hxx>
#include <Handle_NIS_View.hxx>
#include <NCollection_Map.hxx>
-#include <NCollection_Vector.hxx>
+#include <NCollection_SparseArray.hxx>
#include <NIS_Allocator.hxx>
#include <NIS_Drawer.hxx>
#include <NIS_SelectFilter.hxx>
/**
* Query the InteractiveObject instance by its ID.
*/
- inline const Handle_NIS_InteractiveObject&
- GetObject (const Standard_Integer theID) const
- { return myObjects(theID); }
+ Standard_EXPORT const Handle_NIS_InteractiveObject&
+ GetObject (const Standard_Integer theID) const;
/**
* Query the total number of InteractiveObject instances. This number can be
*/
Handle_NIS_Allocator myAllocator;
+ /**
+ * The last added object ID.
+ */
+ Standard_Integer myLastObjectId;
/**
* Container of InteractiveObject instances.
*/
- NCollection_Vector <Handle_NIS_InteractiveObject> myObjects;
+ NCollection_SparseArray <Handle_NIS_InteractiveObject>
+ myObjects;
/**
* List of Views.