1 // Copyright (C) 2005 OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : OPEN CASCADE
22 // File: GLViewer_Group.xx
23 // Created: March, 2005
25 //#include "GLViewerAfx.h"
26 #include "GLViewer_Group.h"
27 #include "GLViewer_Object.h"
32 GLViewer_Group::GLViewer_Group()
40 GLViewer_Group::~GLViewer_Group()
45 detection of empty group
47 bool GLViewer_Group::isEmpty()
49 return myList.empty();
53 \return number of elements
55 int GLViewer_Group::count()
61 \return the position of object if group contains it, else -1
63 int GLViewer_Group::contains( GLViewer_Object* theObject )
68 OGIterator it = myList.begin();
69 OGIterator end_it = myList.end();
70 for( int i = 0; it != end_it; ++it, i++ )
71 if( *it == theObject )
78 adding object to group
80 int GLViewer_Group::addObject( GLViewer_Object* theObject )
82 if( theObject && contains( theObject ) == -1 )
84 myList.push_back( theObject );
85 theObject->setGroup( this );
91 removing object from group
93 int GLViewer_Group::removeObject( GLViewer_Object* theObject )
97 myList.remove( theObject );
98 //theObject->setGroup( NULL );
104 this->~GLViewer_Group();
113 \param Once is true, if this operation calls only one time for all object
114 \param x, y - dragging position
116 void GLViewer_Group::dragingObjects( float x, float y, bool once )
122 OGIterator it = myList.begin();
123 OGIterator end_it = myList.end();
124 for( int i = 0; it != end_it; ++it, i++ )
125 if( (*it)->isSelected() )
138 OGIterator it = myList.begin();
139 OGIterator end_it = myList.end();
140 for( int i = 0; it != end_it; ++it, i++ )
141 (*it)->moveObject( x, y, true );
145 Updates zoom of object
146 \param sender - object to be updated
147 \param zoom - zoom coefficient
149 void GLViewer_Group::updateZoom( GLViewer_Object* sender, float zoom )
151 OGIterator it = myList.begin();
152 OGIterator end_it = myList.end();
153 for( int i = 0; it != end_it; ++it, i++ )
155 GLViewer_Object* anObject = *it;
156 if( anObject != sender )
157 anObject->setZoom( zoom, true, true );