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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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"
29 /***************************************************************************
30 ** Class: GLViewer_Group
31 ** Descr: Group of GLViewer_Objects
33 ** Created: UI team, 25.03.05
34 ****************************************************************************/
36 //--------------------------------------------------------------------------
37 //Function: GLViewer_Group()
38 //Description: constructor
39 //--------------------------------------------------------------------------
40 GLViewer_Group::GLViewer_Group()
45 //--------------------------------------------------------------------------
46 //Function: GLViewer_Group()
47 //Description: destructor
48 //--------------------------------------------------------------------------
49 GLViewer_Group::~GLViewer_Group()
53 //--------------------------------------------------------------------------
55 //Description: detection of empty group
56 //--------------------------------------------------------------------------
57 bool GLViewer_Group::isEmpty()
59 return myList.empty();
62 //--------------------------------------------------------------------------
64 //Description: number of elements
65 //--------------------------------------------------------------------------
66 int GLViewer_Group::count()
71 //--------------------------------------------------------------------------
73 //Description: return the position of object, else -1
74 //--------------------------------------------------------------------------
75 int GLViewer_Group::contains( GLViewer_Object* theObject )
80 OGIterator it = myList.begin();
81 OGIterator end_it = myList.end();
82 for( int i = 0; it != end_it; ++it, i++ )
83 if( *it == theObject )
89 //--------------------------------------------------------------------------
91 //Description: adding object to group
92 //--------------------------------------------------------------------------
93 int GLViewer_Group::addObject( GLViewer_Object* theObject )
95 if( theObject && contains( theObject ) == -1 )
97 myList.push_back( theObject );
98 theObject->setGroup( this );
103 //--------------------------------------------------------------------------
104 //Function: removeObject
105 //Description: removing object from group
106 //--------------------------------------------------------------------------
107 int GLViewer_Group::removeObject( GLViewer_Object* theObject )
111 myList.remove( theObject );
112 //theObject->setGroup( NULL );
118 this->~GLViewer_Group();
125 //--------------------------------------------------------------------------
126 //Function: dragingObjects
128 //--------------------------------------------------------------------------
129 void GLViewer_Group::dragingObjects( float x, float y, bool once )
135 OGIterator it = myList.begin();
136 OGIterator end_it = myList.end();
137 for( int i = 0; it != end_it; ++it, i++ )
138 if( (*it)->isSelected() )
151 OGIterator it = myList.begin();
152 OGIterator end_it = myList.end();
153 for( int i = 0; it != end_it; ++it, i++ )
154 (*it)->moveObject( x, y, true );
157 //--------------------------------------------------------------------------
158 //Function: updateZoom
160 //--------------------------------------------------------------------------
161 void GLViewer_Group::updateZoom( GLViewer_Object* sender, float zoom )
163 OGIterator it = myList.begin();
164 OGIterator end_it = myList.end();
165 for( int i = 0; it != end_it; ++it, i++ )
167 GLViewer_Object* anObject = *it;
168 if( anObject != sender )
169 anObject->setZoom( zoom, true, true );