Salome HOME
updated copyright message
[modules/gui.git] / src / GLViewer / GLViewer_Context.cxx
index 0383b0325519889905878c5c3b1b2052b4326402..205458d97b51726acc5fac6dd198989653dc7a1c 100644 (file)
@@ -1,27 +1,29 @@
-//  Copyright (C) 2005 OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  Author : OPEN CASCADE
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
+//  Author : OPEN CASCADE
 // File:      GLViewer_Context.cxx
 // Created:   November, 2004
-
+//
 /*!
   \class GLViewer_AspectLine
   \brief Class for manage of presentations in GLViewer
 #include "GLViewer_Object.h"
 #include "GLViewer_Viewer2d.h"
 #include "GLViewer_ViewPort2d.h"
+#include "GLViewer_ViewFrame.h"
+
+//QT includes
+#include <QRect>
 
 #include <TColStd_SequenceOfInteger.hxx>
 
@@ -176,7 +182,7 @@ int GLViewer_Context::MoveTo( int xi, int yi, bool byCircle )
     if( myLastPickedChanged || myUpdateAll )
         myGLViewer2d->updateAll();
     else
-        myGLViewer2d->activateDrawers( anUpdatedObjects, TRUE, TRUE );
+        myGLViewer2d->activateDrawers( anUpdatedObjects, true, true );
 
     return 0;
 }
@@ -205,16 +211,16 @@ int GLViewer_Context::Select( bool Append, bool byCircle )
         if ( !Append )
         {
             for( it = mySelectedObjects.begin(), itEnd = mySelectedObjects.end() ; it != itEnd; ++it )
-                   if( myLastPicked != *it )
+                    if( myLastPicked != *it )
                 {
-                       updateAll = (*it)->unselect() || updateAll;
-                       aList.append( *it );
+                        updateAll = (*it)->unselect() || updateAll;
+                        aList.append( *it );
                 }
 
             if( updateAll || myUpdateAll )
                 myGLViewer2d->updateAll();
             else
-                myGLViewer2d->activateDrawers( aList, TRUE, TRUE );
+                myGLViewer2d->activateDrawers( aList, true, true );
 
             if( mySelectedObjects.count() != 0 && status == SS_Invalid )
                 status = SS_GlobalChanged;
@@ -222,7 +228,7 @@ int GLViewer_Context::Select( bool Append, bool byCircle )
         } 
         else if( myLastPicked->isSelected() && status != SS_LocalChanged )
         {
-            mySelectedObjects.remove( myLastPicked );
+            mySelectedObjects.removeAll( myLastPicked );
             myLastPicked->unselect();
             myGLViewer2d->updateAll();
 
@@ -233,10 +239,10 @@ int GLViewer_Context::Select( bool Append, bool byCircle )
         }
 
         if ( myLastPicked->select( myXhigh, myYhigh, myTolerance, GLViewer_Rect(), false, byCircle, Append )
-             && mySelectedObjects.findIndex( myLastPicked ) == -1 )
+             && mySelectedObjects.indexOf( myLastPicked ) == -1 )
         {
             mySelectedObjects.append( myLastPicked );
-            myGLViewer2d->activateDrawer( myLastPicked, TRUE, TRUE );
+            myGLViewer2d->activateDrawer( myLastPicked, true, true );
 
             if( status == SS_Invalid )
                 status = SS_GlobalChanged;
@@ -252,16 +258,16 @@ int GLViewer_Context::Select( bool Append, bool byCircle )
         if ( !Append )
         {
             for( it = mySelectedObjects.begin(), itEnd = mySelectedObjects.end() ; it != itEnd; ++it )
-                   if ( myLastPicked != *it )
+                    if ( myLastPicked != *it )
                 {
-                       updateAll = (*it)->unselect() || updateAll;
-                       aList.append( *it );
+                        updateAll = (*it)->unselect() || updateAll;
+                        aList.append( *it );
                 }
 
             if( updateAll || myUpdateAll )
                 myGLViewer2d->updateAll();
             else
-                myGLViewer2d->activateDrawers( aList, TRUE, TRUE );
+                myGLViewer2d->activateDrawers( aList, true, true );
 
             if( mySelectedObjects.count() != 0 )
                 status = SS_GlobalChanged;
@@ -291,7 +297,7 @@ int GLViewer_Context::Select( bool Append, bool byCircle )
             if( updateAll || myUpdateAll )
                 myGLViewer2d->updateAll();
             else
-                myGLViewer2d->activateDrawers( aList, TRUE, TRUE );
+                myGLViewer2d->activateDrawers( aList, true, true );
 
             if( mySelectedObjects.count() != 0 )
                 status = SS_GlobalChanged;
@@ -313,7 +319,7 @@ int GLViewer_Context::Select( bool Append, bool byCircle )
             {
                 myLastPicked = *oit;
                 mySelectedObjects.append( myLastPicked );
-                myGLViewer2d->activateDrawer( myLastPicked, TRUE, TRUE );
+                myGLViewer2d->activateDrawer( myLastPicked, true, true );
                 status = SS_GlobalChanged;
                 return status;
             }
@@ -370,7 +376,7 @@ int GLViewer_Context::SelectByRect( const QRect& theRect, bool Append )
             isSel = (*it)->isSelected();
         }
 
-        if( isSel && mySelectedObjects.findIndex( *it ) == -1 )
+        if( isSel && mySelectedObjects.indexOf( *it ) == -1 )
         {
             aList.append( *it );
             mySelectedObjects.append( *it );
@@ -381,7 +387,7 @@ int GLViewer_Context::SelectByRect( const QRect& theRect, bool Append )
     if( updateAll || myUpdateAll )
         myGLViewer2d->updateAll();
     else
-        myGLViewer2d->activateDrawers( aList, TRUE, TRUE );
+        myGLViewer2d->activateDrawers( aList, true, true );
 
     return status;
 }
@@ -464,10 +470,10 @@ bool GLViewer_Context::NextSelected()
   if ( mySelCurIndex >= 0 && mySelCurIndex < NbSelected() )
   {
     mySelCurIndex++;
-    return TRUE;
+    return true;
   }
 
-  return FALSE;
+  return false;
 }
 
 /*!
@@ -506,7 +512,7 @@ int GLViewer_Context::insertObject( GLViewer_Object* object, bool display, bool
         {
             //QRect* rect = object->getRect()->toQRect();
             //myGLViewer2d->updateBorders( *rect );
-            myGLViewer2d->activateDrawer( object, FALSE );
+            myGLViewer2d->activateDrawer( object, false );
         }
     }
     else
@@ -527,14 +533,14 @@ bool GLViewer_Context::replaceObject( GLViewer_Object* oldObject, GLViewer_Objec
 
   if( myActiveObjects.contains( oldObject ) )
   {
-    myActiveObjects.remove( oldObject );
+    myActiveObjects.removeAll( oldObject );
     myActiveObjects.append( newObject );
     return true;
   }
 
   if( myInactiveObjects.contains( oldObject ) )
   {
-    myInactiveObjects.remove( oldObject );
+    myInactiveObjects.removeAll( oldObject );
     myInactiveObjects.append( newObject );
     return true;
   }
@@ -594,7 +600,7 @@ void GLViewer_Context::clearSelected( bool updateViewer )
   }          
         
   if( updateViewer )
-    myGLViewer2d->activateDrawers( aList, TRUE );
+    myGLViewer2d->activateDrawers( aList, true );
   mySelectedObjects.clear();    
 }
 
@@ -609,12 +615,12 @@ void GLViewer_Context::setSelected( GLViewer_Object* object, bool updateViewer )
 
   if( myActiveObjects.contains( object ) && !mySelectedObjects.contains( object ) )
   {
-    object->setSelected( TRUE );
+    object->setSelected( true );
     mySelectedObjects.append( object );
   }
      
   if( updateViewer )
-    myGLViewer2d->activateDrawer( object, TRUE, TRUE );
+    myGLViewer2d->activateDrawer( object, true, true );
 }
 
 /*!
@@ -626,11 +632,11 @@ void GLViewer_Context::remSelected( GLViewer_Object* object, bool updateViewer )
   if( !object || !mySelectedObjects.contains( object ) )
     return;
   
-  mySelectedObjects.remove( object );
+  mySelectedObjects.removeAll( object );
   object->unselect();
   
   if( updateViewer )
-    myGLViewer2d->activateDrawer( object, TRUE, TRUE );
+    myGLViewer2d->activateDrawer( object, true, true );
 }
 
 /*!
@@ -661,14 +667,14 @@ void GLViewer_Context::deleteObject( GLViewer_Object* theObject, bool updateView
         return;
 
     if( myActiveObjects.contains( theObject ) )      
-        myActiveObjects.remove( theObject );
+        myActiveObjects.removeAll( theObject );
     else if( myInactiveObjects.contains( theObject ) )
-        myInactiveObjects.remove( theObject );
+        myInactiveObjects.removeAll( theObject );
     else 
         return;
      
     if( mySelectedObjects.contains( theObject ) )
-        mySelectedObjects.remove( theObject );
+        mySelectedObjects.removeAll( theObject );
 
     GLViewer_Group* aGroup = theObject->getGroup();
     if( aGroup )
@@ -690,7 +696,7 @@ bool GLViewer_Context::setActive( GLViewer_Object* theObject )
   if( !theObject || !myInactiveObjects.contains( theObject ) )
     return false;
 
-  myInactiveObjects.remove( theObject );
+  myInactiveObjects.removeAll( theObject );
   myActiveObjects.append( theObject );
   return true;
 }
@@ -704,7 +710,7 @@ bool GLViewer_Context::setInactive( GLViewer_Object* theObject )
   if( !theObject || !myActiveObjects.contains( theObject ) )
     return false;
 
-  myActiveObjects.remove( theObject );
+  myActiveObjects.removeAll( theObject );
   myInactiveObjects.append( theObject );
   return true;
 }