1 // File: GLViewer_Group.xx
2 // Created: March, 2005
4 // Copyright (C) CEA 2005
6 //#include "GLViewerAfx.h"
7 #include "GLViewer_Group.h"
8 #include "GLViewer_Object.h"
10 /***************************************************************************
11 ** Class: GLViewer_Group
12 ** Descr: Group of GLViewer_Objects
14 ** Created: UI team, 25.03.05
15 ****************************************************************************/
17 //--------------------------------------------------------------------------
18 //Function: GLViewer_Group()
19 //Description: constructor
20 //--------------------------------------------------------------------------
21 GLViewer_Group::GLViewer_Group()
26 //--------------------------------------------------------------------------
27 //Function: GLViewer_Group()
28 //Description: destructor
29 //--------------------------------------------------------------------------
30 GLViewer_Group::~GLViewer_Group()
34 //--------------------------------------------------------------------------
36 //Description: detection of empty group
37 //--------------------------------------------------------------------------
38 bool GLViewer_Group::isEmpty()
40 return myList.empty();
43 //--------------------------------------------------------------------------
45 //Description: number of elements
46 //--------------------------------------------------------------------------
47 int GLViewer_Group::count()
52 //--------------------------------------------------------------------------
54 //Description: return the position of object, else -1
55 //--------------------------------------------------------------------------
56 int GLViewer_Group::contains( GLViewer_Object* theObject )
61 OGIterator it = myList.begin();
62 OGIterator end_it = myList.end();
63 for( int i = 0; it != end_it; ++it, i++ )
64 if( *it == theObject )
70 //--------------------------------------------------------------------------
72 //Description: adding object to group
73 //--------------------------------------------------------------------------
74 int GLViewer_Group::addObject( GLViewer_Object* theObject )
76 if( theObject && contains( theObject ) == -1 )
78 myList.push_back( theObject );
79 theObject->setGroup( this );
84 //--------------------------------------------------------------------------
85 //Function: removeObject
86 //Description: removing object from group
87 //--------------------------------------------------------------------------
88 int GLViewer_Group::removeObject( GLViewer_Object* theObject )
92 myList.remove( theObject );
93 //theObject->setGroup( NULL );
99 this->~GLViewer_Group();
106 //--------------------------------------------------------------------------
107 //Function: dragingObjects
109 //--------------------------------------------------------------------------
110 void GLViewer_Group::dragingObjects( float x, float y, bool once )
116 OGIterator it = myList.begin();
117 OGIterator end_it = myList.end();
118 for( int i = 0; it != end_it; ++it, i++ )
119 if( (*it)->isSelected() )
132 OGIterator it = myList.begin();
133 OGIterator end_it = myList.end();
134 for( int i = 0; it != end_it; ++it, i++ )
135 (*it)->moveObject( x, y, true );
138 //--------------------------------------------------------------------------
139 //Function: updateZoom
141 //--------------------------------------------------------------------------
142 void GLViewer_Group::updateZoom( GLViewer_Object* sender, float zoom )
144 OGIterator it = myList.begin();
145 OGIterator end_it = myList.end();
146 for( int i = 0; it != end_it; ++it, i++ )
148 GLViewer_Object* anObject = *it;
149 if( anObject != sender )
150 anObject->setZoom( zoom, true, true );