1 // File: GLViewer_Group.xx
2 // Created: March, 2005
4 // Copyright (C) CEA 2005
5 //#include "GLViewerAfx.h"
6 #include "GLViewer_Group.h"
7 #include "GLViewer_Object.h"
9 /***************************************************************************
10 ** Class: GLViewer_Group
11 ** Descr: Group of GLViewer_Objects
13 ** Created: UI team, 25.03.05
14 ****************************************************************************/
16 //--------------------------------------------------------------------------
17 //Function: GLViewer_Group()
18 //Description: constructor
19 //--------------------------------------------------------------------------
20 GLViewer_Group::GLViewer_Group()
25 //--------------------------------------------------------------------------
26 //Function: GLViewer_Group()
27 //Description: destructor
28 //--------------------------------------------------------------------------
29 GLViewer_Group::~GLViewer_Group()
33 //--------------------------------------------------------------------------
35 //Description: detection of empty group
36 //--------------------------------------------------------------------------
37 bool GLViewer_Group::isEmpty()
39 return myList.empty();
42 //--------------------------------------------------------------------------
44 //Description: number of elements
45 //--------------------------------------------------------------------------
46 int GLViewer_Group::count()
51 //--------------------------------------------------------------------------
53 //Description: return the position of object, else -1
54 //--------------------------------------------------------------------------
55 int GLViewer_Group::contains( GLViewer_Object* theObject )
60 OGIterator it = myList.begin();
61 OGIterator end_it = myList.end();
62 for( int i = 0; it != end_it; ++it, i++ )
63 if( *it == theObject )
69 //--------------------------------------------------------------------------
71 //Description: adding object to group
72 //--------------------------------------------------------------------------
73 int GLViewer_Group::addObject( GLViewer_Object* theObject )
75 if( theObject && contains( theObject ) == -1 )
77 myList.push_back( theObject );
78 theObject->setGroup( this );
83 //--------------------------------------------------------------------------
84 //Function: removeObject
85 //Description: removing object from group
86 //--------------------------------------------------------------------------
87 int GLViewer_Group::removeObject( GLViewer_Object* theObject )
91 myList.remove( theObject );
92 //theObject->setGroup( NULL );
98 this->~GLViewer_Group();
105 //--------------------------------------------------------------------------
106 //Function: dragingObjects
108 //--------------------------------------------------------------------------
109 void GLViewer_Group::dragingObjects( float x, float y )
113 OGIterator it = myList.begin();
114 OGIterator end_it = myList.end();
115 for( int i = 0; it != end_it; ++it, i++ )
116 if( (*it)->isSelected() )
128 OGIterator it = myList.begin();
129 OGIterator end_it = myList.end();
130 for( int i = 0; it != end_it; ++it, i++ )
131 (*it)->moveObject( x, y, true );
134 //--------------------------------------------------------------------------
135 //Function: updateZoom
137 //--------------------------------------------------------------------------
138 void GLViewer_Group::updateZoom( GLViewer_Object* sender, float zoom )
140 OGIterator it = myList.begin();
141 OGIterator end_it = myList.end();
142 for( int i = 0; it != end_it; ++it, i++ )
144 GLViewer_Object* anObject = *it;
145 if( anObject != sender )
146 anObject->setZoom( zoom, GL_TRUE );