-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
// 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.
-//
-// 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// 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.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#include "LightApp_GLSelector.h"
#include "LightApp_DataOwner.h"
#include <GLViewer_Context.h>
+#include <GLViewer_Object.h>
/*!Constructor. Initialize by GLViewer_Viewer2d and SUIT_SelectionMgr.*/
LightApp_GLSelector::LightApp_GLSelector( GLViewer_Viewer2d* viewer, SUIT_SelectionMgr* mgr )
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() ) ) );
}
}
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;
-}