1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
23 // Author : OPEN CASCADE
24 // File: GLViewer_Group.xx
25 // Created: March, 2005
26 //#include "GLViewerAfx.h"
28 #include "GLViewer_Group.h"
29 #include "GLViewer_Object.h"
34 GLViewer_Group::GLViewer_Group()
42 GLViewer_Group::~GLViewer_Group()
47 detection of empty group
49 bool GLViewer_Group::isEmpty()
51 return myList.empty();
55 \return number of elements
57 int GLViewer_Group::count()
63 \return the position of object if group contains it, else -1
65 int GLViewer_Group::contains( GLViewer_Object* theObject )
70 OGIterator it = myList.begin();
71 OGIterator end_it = myList.end();
72 for( int i = 0; it != end_it; ++it, i++ )
73 if( *it == theObject )
80 adding object to group
82 int GLViewer_Group::addObject( GLViewer_Object* theObject )
84 if( theObject && contains( theObject ) == -1 )
86 myList.push_back( theObject );
87 theObject->setGroup( this );
93 removing object from group
95 int GLViewer_Group::removeObject( GLViewer_Object* theObject )
99 myList.remove( theObject );
100 //theObject->setGroup( NULL );
106 this->~GLViewer_Group();
115 \param Once is true, if this operation calls only one time for all object
116 \param x, y - dragging position
118 void GLViewer_Group::dragingObjects( float x, float y, bool once )
124 OGIterator it = myList.begin();
125 OGIterator end_it = myList.end();
126 for( int i = 0; it != end_it; ++it, i++ )
127 if( (*it)->isSelected() )
140 OGIterator it = myList.begin();
141 OGIterator end_it = myList.end();
142 for( int i = 0; it != end_it; ++it, i++ )
143 (*it)->moveObject( x, y, true );
147 Updates zoom of object
148 \param sender - object to be updated
149 \param zoom - zoom coefficient
151 void GLViewer_Group::updateZoom( GLViewer_Object* sender, float zoom )
153 OGIterator it = myList.begin();
154 OGIterator end_it = myList.end();
155 for( int i = 0; it != end_it; ++it, i++ )
157 GLViewer_Object* anObject = *it;
158 if( anObject != sender )
159 anObject->setZoom( zoom, true, true );