#include "LightApp_GLSelector.h"
#include "LightApp_DataOwner.h"
+#include "LightApp_DataObject.h"
#include <GLViewer_Context.h>
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;
-}
#include <string>
#include <GLViewer_Object.h>
+class LightApp_DataObject;
+
/*!
\class LightApp_GLSelector
Custom selector to get/set selection from GL viewer
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