if( isActive )
{
- myActiveObjects.append( object );
+ insertObjectToList( object );
if( display )
{
//QRect* rect = object->getRect()->toQRect();
}
}
else
- myInactiveObjects.append( object );
+ insertObjectToList( object, false );
return myActiveObjects.count() + myInactiveObjects.count();
}
if( myActiveObjects.contains( oldObject ) )
{
myActiveObjects.removeAll( oldObject );
- myActiveObjects.append( newObject );
+ insertObjectToList( newObject );
return true;
}
if( myInactiveObjects.contains( oldObject ) )
{
myInactiveObjects.removeAll( oldObject );
- myInactiveObjects.append( newObject );
+ insertObjectToList( newObject, false );
return true;
}
return false;
myInactiveObjects.removeAll( theObject );
- myActiveObjects.append( theObject );
+ insertObjectToList( theObject );
return true;
}
return false;
myActiveObjects.removeAll( theObject );
- myInactiveObjects.append( theObject );
+ insertObjectToList( theObject, false );
return true;
}
+
+/*!
+ Inserts the object to the corresponding list to the position based on its priority
+ \param theObject - object to be inserted
+ \param isActive - true if needs inserting object in active list
+*/
+void GLViewer_Context::insertObjectToList( GLViewer_Object* theObject, bool isActive )
+{
+ int aPriority = theObject->getPriority();
+
+ ObjList& anObjList = isActive ? myActiveObjects : myInactiveObjects;
+ ObjList::Iterator anIter = anObjList.begin(), anIterEnd = anObjList.end();
+ for( ; anIter != anIterEnd; anIter++ )
+ if( (*anIter)->getPriority() > aPriority )
+ break;
+
+ anObjList.insert( anIter, theObject );
+}
//! A function installing to theObject inactive status
bool setInactive( GLViewer_Object* theObject );
+protected:
+ //! Inserts the object to the corresponding list to the position based on its priority
+ void insertObjectToList( GLViewer_Object* theObject, bool isActive = true );
+
protected:
//! Flag of updating viewer after highlight
/*!
myObjects.clear();
myTextList = 0/*-1*/;
myObjectType = "GLViewer_Object";
- myPriority = 0;
myTextFormat = DTF_BITMAP;
myTextScale = 0.125;
}
glDeleteLists( myTextList, 1 );
}
+/*!
+ Returns object priority
+*/
+int GLViewer_Drawer::getPriority() const
+{
+ if( !myObjects.isEmpty() )
+ if( GLViewer_Object* anObject = myObjects.first() )
+ return anObject->getPriority();
+ return 0;
+}
+
+
/*!
Clears all generated textures
*/
QString getObjectType() const { return myObjectType; }
//! Returns object priority
- int getPriority() const { return myPriority; }
+ int getPriority() const;
//! The function enables and disables antialiasing in Open GL (for points, lines and polygons).
void setAntialiasing(const bool on);
//! Type of supporting object
QString myObjectType;
- //! Dislay priority
- int myPriority;
//! Default font for drawGLText() method
QFont myFont;
myAspectLine = new GLViewer_AspectLine();
myType = "GLViewer_Object";
+ myPriority = 0;
+
myOwner = NULL;
myDrawer = NULL;
delete myAspectLine;
}
-/*!
- \return priority of object
-*/
-int GLViewer_Object::getPriority() const
-{
- return myDrawer ? myDrawer->getPriority() : 0;
-}
-
/*!
\return true if object is inside rectangle
\param theRect - rectangle
QString getName() const { return myName; }
//! Returns object priority
- virtual int getPriority() const;
+ virtual int getPriority() const { return myPriority; }
//! Moves object per by recomputing
/*!
//! Line aspect for object presentation
GLViewer_AspectLine* myAspectLine;
+ //! Display priority
+ int myPriority;
+
//! Objet tool tip text
QString myToolTipText;
//! HTML object tool tip status