]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Class LightApp_GLOwner was removed. LightApp_DataOwner used instead.
authorstv <stv@opencascade.com>
Tue, 29 Aug 2006 11:44:13 +0000 (11:44 +0000)
committerstv <stv@opencascade.com>
Tue, 29 Aug 2006 11:44:13 +0000 (11:44 +0000)
src/LightApp/LightApp_GLSelector.cxx
src/LightApp/LightApp_GLSelector.h

index ceebdeeb41d880fc85993ff72d6a2eba9a4f7e23..d7c14c59b186ac0d81ea0770a187c43e59932d9c 100644 (file)
@@ -19,6 +19,7 @@
 #include "LightApp_GLSelector.h"
 
 #include "LightApp_DataOwner.h"
+#include "LightApp_DataObject.h"
 
 #include <GLViewer_Context.h>
 
@@ -64,8 +65,8 @@ void LightApp_GLSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
     GLViewer_Object* obj = cont->SelectedObject();
     if ( obj )
     {
-      LightApp_GLOwner* owner = dynamic_cast< LightApp_GLOwner* >( obj->owner() );
-      if( owner )
+      LightApp_DataOwner* owner = dynamic_cast<LightApp_DataOwner*>( obj->owner() );
+      if ( owner )
         aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( owner->entry() ) ) );
     }
   }
@@ -81,70 +82,32 @@ void LightApp_GLSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
   if ( !cont )
     return;
 
-  QMap<QString, GLViewer_Object*> aDisplayed;
-  const ObjList& displayed = cont->getObjects();
-  for ( ObjList::const_iterator it = displayed.begin(); it != displayed.end(); ++it )
-  {
-    GLViewer_Object* obj = *it;
-    if ( obj && obj->getVisible() )
-    {
-      LightApp_GLOwner* owner = dynamic_cast< LightApp_GLOwner* >( obj->owner() );
-      if ( owner )
-       aDisplayed.insert( owner->entry(), obj );
-    }
-  }
-
-  int Nb = 0;
-  cont->clearSelected( false );
+  QMap<QString, int> aSelected;
   for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
   {
     const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
 
-    if ( !owner )
-      continue;
+    if ( owner )
+      aSelected.insert( owner->entry(), 0 );
+  }
 
-    if ( aDisplayed.contains( owner->entry() ) )
+  bool changed = false;
+  const ObjList& displayed = cont->getObjects();
+  for ( ObjList::const_iterator it = displayed.begin(); it != displayed.end(); ++it )
+  {
+    GLViewer_Object* obj = *it;
+    if ( obj && obj->getVisible() )
     {
-      cont->setSelected( aDisplayed[owner->entry()], false );
-      Nb++;
+      LightApp_DataOwner* owner = dynamic_cast<LightApp_DataOwner*>( obj->owner() );
+      bool sel = owner && aSelected.contains( owner->entry() );
+      changed = changed || sel != (bool)obj->isSelected();
+      if ( sel && !obj->isSelected() )
+        cont->setSelected( obj, false );
+      else if ( !sel && obj->isSelected() )
+        cont->remSelected( obj, false );
     }
   }
 
-  if ( Nb > 0 )
+  if ( changed )
     myViewer->updateAll();
 }
-
-
-/*!
-  Constructor
-  \param entry - entry of object
-*/
-LightApp_GLOwner::LightApp_GLOwner( const char* entry )
-: GLViewer_Owner()
-{
-  setEntry( entry );
-}
-
-/*!
-  Destructor
-*/
-LightApp_GLOwner::~LightApp_GLOwner()
-{
-}
-
-/*!
-  \return entry
-*/
-const char* LightApp_GLOwner::entry() const
-{
-  return myEntry.c_str();
-}
-
-/*!
-  Sets new entry
-  \param entry - entry of object
-*/
-void LightApp_GLOwner::setEntry( const char* entry )
-{
-  myEntry = entry;
-}
index 13cb191beea846b702c16c31dd6730262eb4b664..2923c25ab54d473604609cf8a0f8d8aff374c5e1 100644 (file)
@@ -28,6 +28,8 @@
 #include <string>
 #include <GLViewer_Object.h>
 
+class LightApp_DataObject;
+
 /*!
   \class LightApp_GLSelector
   Custom selector to get/set selection from GL viewer
@@ -55,21 +57,4 @@ private:
   GLViewer_Viewer2d*  myViewer;
 };
 
-
-/*!
-  This class provide data owner objects for GLViewer.
-*/
-class LIGHTAPP_EXPORT LightApp_GLOwner : public GLViewer_Owner
-{
-public:
-  LightApp_GLOwner( const char* );
-  ~LightApp_GLOwner();
-
-  const char*       entry() const;
-  void              setEntry( const char* );
-
-private:
-  std::string       myEntry;
-};
-
 #endif