From a3f9bbedb14ead1380484021186d5ac460e4d997 Mon Sep 17 00:00:00 2001 From: stv Date: Tue, 29 Aug 2006 11:44:13 +0000 Subject: [PATCH] Class LightApp_GLOwner was removed. LightApp_DataOwner used instead. --- src/LightApp/LightApp_GLSelector.cxx | 79 ++++++++-------------------- src/LightApp/LightApp_GLSelector.h | 19 +------ 2 files changed, 23 insertions(+), 75 deletions(-) diff --git a/src/LightApp/LightApp_GLSelector.cxx b/src/LightApp/LightApp_GLSelector.cxx index ceebdeeb4..d7c14c59b 100644 --- a/src/LightApp/LightApp_GLSelector.cxx +++ b/src/LightApp/LightApp_GLSelector.cxx @@ -19,6 +19,7 @@ #include "LightApp_GLSelector.h" #include "LightApp_DataOwner.h" +#include "LightApp_DataObject.h" #include @@ -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( 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 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(); } - - -/*! - 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; -} diff --git a/src/LightApp/LightApp_GLSelector.h b/src/LightApp/LightApp_GLSelector.h index 13cb191be..2923c25ab 100644 --- a/src/LightApp/LightApp_GLSelector.h +++ b/src/LightApp/LightApp_GLSelector.h @@ -28,6 +28,8 @@ #include #include +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 -- 2.39.2