1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // Author : OPEN CASCADE
23 // File: GLViewer_Group.xx
24 // Created: March, 2005
25 //#include "GLViewerAfx.h"
27 #include "GLViewer_Group.h"
28 #include "GLViewer_Object.h"
33 GLViewer_Group::GLViewer_Group()
41 GLViewer_Group::~GLViewer_Group()
46 detection of empty group
48 bool GLViewer_Group::isEmpty()
50 return myList.empty();
54 \return number of elements
56 int GLViewer_Group::count()
62 \return the position of object if group contains it, else -1
64 int GLViewer_Group::contains( GLViewer_Object* theObject )
69 OGIterator it = myList.begin();
70 OGIterator end_it = myList.end();
71 for( int i = 0; it != end_it; ++it, i++ )
72 if( *it == theObject )
79 adding object to group
81 int GLViewer_Group::addObject( GLViewer_Object* theObject )
83 if( theObject && contains( theObject ) == -1 )
85 myList.push_back( theObject );
86 theObject->setGroup( this );
92 removing object from group
94 int GLViewer_Group::removeObject( GLViewer_Object* theObject )
98 myList.remove( theObject );
99 //theObject->setGroup( NULL );
105 this->~GLViewer_Group();
114 \param Once is true, if this operation calls only one time for all object
115 \param x, y - dragging position
117 void GLViewer_Group::dragingObjects( float x, float y, bool once )
123 OGIterator it = myList.begin();
124 OGIterator end_it = myList.end();
125 for( int i = 0; it != end_it; ++it, i++ )
126 if( (*it)->isSelected() )
139 OGIterator it = myList.begin();
140 OGIterator end_it = myList.end();
141 for( int i = 0; it != end_it; ++it, i++ )
142 (*it)->moveObject( x, y, true );
146 Updates zoom of object
147 \param sender - object to be updated
148 \param zoom - zoom coefficient
150 void GLViewer_Group::updateZoom( GLViewer_Object* sender, float zoom )
152 OGIterator it = myList.begin();
153 OGIterator end_it = myList.end();
154 for( int i = 0; it != end_it; ++it, i++ )
156 GLViewer_Object* anObject = *it;
157 if( anObject != sender )
158 anObject->setZoom( zoom, true, true );