X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FLightApp%2FLightApp_GLSelector.cxx;h=61dd58dd26e1a9c570e0d1e7cc3339c2f48beba1;hb=5015bf4f1283a8ca5d6ab862f235322755cb7be9;hp=c9415eb4185ab612bc03e0bb21c868b026083f29;hpb=101fd10f1e736daa5d7f0f0ee5499b951460832a;p=modules%2Fgui.git diff --git a/src/LightApp/LightApp_GLSelector.cxx b/src/LightApp/LightApp_GLSelector.cxx index c9415eb41..61dd58dd2 100644 --- a/src/LightApp/LightApp_GLSelector.cxx +++ b/src/LightApp/LightApp_GLSelector.cxx @@ -1,26 +1,31 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// Copyright (C) 2007-2019 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/ +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + #include "LightApp_GLSelector.h" #include "LightApp_DataOwner.h" #include +#include /*!Constructor. Initialize by GLViewer_Viewer2d and SUIT_SelectionMgr.*/ LightApp_GLSelector::LightApp_GLSelector( GLViewer_Viewer2d* viewer, SUIT_SelectionMgr* mgr ) @@ -64,8 +69,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( obj->owner() ); + if ( owner ) aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( owner->entry() ) ) ); } } @@ -81,56 +86,32 @@ void LightApp_GLSelector::setSelection( const SUIT_DataOwnerPtrList& aList ) if ( !cont ) return; - QMap 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 aSelected; for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr ) { const LightApp_DataOwner* owner = dynamic_cast( (*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( 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(); } - - -LightApp_GLOwner::LightApp_GLOwner( const char* entry ) -: GLViewer_Owner() -{ - setEntry( entry ); -} - -LightApp_GLOwner::~LightApp_GLOwner() -{ -} - -const char* LightApp_GLOwner::entry() const -{ - return myEntry.c_str(); -} - -void LightApp_GLOwner::setEntry( const char* entry ) -{ - myEntry = entry; -}