From: nds Date: Tue, 8 Nov 2016 06:21:46 +0000 (+0300) Subject: Selection synchronization between OCC viewer and TreeWidget. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=765d34906eb04e437f2c0dbe3c3e0b5294ef91a0;p=modules%2Fgeom.git Selection synchronization between OCC viewer and TreeWidget. --- diff --git a/src/GEOMGUI/CMakeLists.txt b/src/GEOMGUI/CMakeLists.txt index 4565143b0..9dd7a50d8 100755 --- a/src/GEOMGUI/CMakeLists.txt +++ b/src/GEOMGUI/CMakeLists.txt @@ -76,6 +76,7 @@ SET(GEOMGUI_HEADERS GEOM_GEOMGUI.hxx GEOMGUI_CreationInfoWdg.h GEOMGUI_TextTreeWdg.h + GEOMGUI_TextTreeSelector.h GEOMGUI_DimensionProperty.h GEOMGUI_AnnotationAttrs.h ) @@ -85,6 +86,7 @@ SET(_moc_HEADERS GEOMGUI_AnnotationMgr.h GEOMGUI_CreationInfoWdg.h GEOMGUI_TextTreeWdg.h + GEOMGUI_TextTreeSelector.h GeometryGUI.h ) @@ -119,6 +121,7 @@ SET(GEOMGUI_SOURCES GEOMGUI_Selection.cxx GEOMGUI_CreationInfoWdg.cxx GEOMGUI_TextTreeWdg.cxx + GEOMGUI_TextTreeSelector.cxx GEOMGUI_DimensionProperty.cxx GEOMGUI_AnnotationAttrs.cxx ${_moc_SOURCES} diff --git a/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx index e6796ed41..0ffd1d6ce 100755 --- a/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx +++ b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -53,10 +54,22 @@ GEOMGUI_AnnotationMgr::GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplicat { } +QString GEOMGUI_AnnotationMgr::GetEntrySeparator() +{ + return "_annotation:"; +} + SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty, - GEOM::GEOM_Object_ptr theObject ) + GEOM::GEOM_Object_ptr theObject, + const QString& theEntry ) { Handle ( GEOM_Annotation ) aPresentation = new GEOM_Annotation(); + if ( !theEntry.isEmpty() ) { + // owner should be set to provide selection mechanizm + Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject(); + anIO->setEntry( theEntry.toLatin1().constData() ); + aPresentation->SetOwner( anIO ); + } SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) ); @@ -133,7 +146,8 @@ void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex getObject( theEntry, theIndex, anObject, aProperty ); // display presentation in the viewer - SALOME_Prs* aPrs = CreatePresentation( aProperty, anObject ); + QString anEntry = QString("%1%2%3").arg(theEntry).arg(GetEntrySeparator()).arg(theIndex); + SALOME_Prs* aPrs = CreatePresentation( aProperty, anObject, anEntry ); aView->Display( getDisplayer(), aPrs ); getDisplayer()->UpdateViewer(); @@ -236,6 +250,81 @@ void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SA myVisualized[aView] = anEntryToAnnotation; } +Handle(SALOME_InteractiveObject) GEOMGUI_AnnotationMgr::FindInteractiveObject( const QString& theEntry, + const int theIndex, + SALOME_View* theView ) const +{ + Handle(SALOME_InteractiveObject) anIO; + + SALOME_View* aView = viewOrActiveView( theView ); + if ( !myVisualized.contains( aView ) ) + return anIO; + + EntryToAnnotations anEntryToAnnotation = myVisualized[aView]; + if ( !anEntryToAnnotation.contains( theEntry ) ) + return anIO; + + AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry]; + if ( !anAnnotationToPrs.contains(theIndex) ) + return anIO; + + SALOME_Prs* aPrs = anAnnotationToPrs[theIndex]; + SOCC_Prs* anOCCPrs = dynamic_cast( aPrs ); + if ( !anOCCPrs ) + return anIO; + + AIS_ListOfInteractive anIOs; + anOCCPrs->GetObjects( anIOs ); + AIS_ListIteratorOfListOfInteractive anIter( anIOs ); + for ( ; anIter.More() && anIO.IsNull(); anIter.Next() ) { + Handle(AIS_InteractiveObject) aPrs = anIter.Value(); + if ( aPrs->GetOwner() ) + anIO = Handle(SALOME_InteractiveObject)::DownCast(aPrs->GetOwner()); + } + return anIO; +} + +int GEOMGUI_AnnotationMgr::FindAnnotationIndex( Handle(SALOME_InteractiveObject) theIO, + SALOME_View* theView ) +{ + int anIndex = -1; + + SALOME_View* aView = viewOrActiveView( theView ); + if ( !myVisualized.contains( aView ) ) + return anIndex; + + QString anEntry = theIO->getEntry(); + + EntryToAnnotations anEntryToAnnotation = myVisualized[aView]; + if ( !anEntryToAnnotation.contains( anEntry ) ) + return anIndex; + + AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[anEntry]; + //typedef QMap AnnotationToPrs; + AnnotationToPrs::const_iterator anIt = anAnnotationToPrs.begin(), + aLast = anAnnotationToPrs.end(); + for (; anIt != aLast && anIndex < 0; anIt++) { + SALOME_Prs* aPrs = anIt.value(); + SOCC_Prs* anOCCPrs = dynamic_cast( aPrs ); + if ( !anOCCPrs ) + continue; + + AIS_ListOfInteractive anIOs; + anOCCPrs->GetObjects( anIOs ); + AIS_ListIteratorOfListOfInteractive anIter( anIOs ); + for ( ; anIter.More() && anIndex < 0; anIter.Next() ) { + Handle(AIS_InteractiveObject) aPrs = anIter.Value(); + if ( aPrs->GetOwner() ) { + Handle(SALOME_InteractiveObject) aPrsOwner = Handle(SALOME_InteractiveObject)::DownCast(aPrs->GetOwner()); + if ( aPrsOwner == theIO ) + anIndex = anIt.key(); + } + } + } + + return anIndex; +} + void GEOMGUI_AnnotationMgr::RemoveView( SALOME_View* theView ) { if ( !theView && myVisualized.contains( theView ) ) diff --git a/src/GEOMGUI/GEOMGUI_AnnotationMgr.h b/src/GEOMGUI/GEOMGUI_AnnotationMgr.h index 1d26e70c6..fe0339319 100755 --- a/src/GEOMGUI/GEOMGUI_AnnotationMgr.h +++ b/src/GEOMGUI/GEOMGUI_AnnotationMgr.h @@ -29,6 +29,7 @@ #include #include +#include class SalomeApp_Application; class GEOM_Displayer; @@ -47,8 +48,10 @@ public: GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplication ); ~GEOMGUI_AnnotationMgr() {} + static QString GetEntrySeparator(); + SALOME_Prs* CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty, - GEOM::GEOM_Object_ptr theObject ); + GEOM::GEOM_Object_ptr theObject, const QString& theEntry = QString() ); bool IsDisplayed( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 ) const; void Display( const QString& theEntry, const int theIndex, SALOME_View* theView = 0 ); @@ -59,6 +62,12 @@ public: void RemoveView( SALOME_View* theView); + int FindAnnotationIndex( Handle(SALOME_InteractiveObject) theIO, + SALOME_View* theView = 0 ); + + Handle(SALOME_InteractiveObject) FindInteractiveObject( const QString& theEntry, const int theIndex, + SALOME_View* theView = 0 ) const; + QString getDisplayedIndicesInfo( const QString& theEntry, SALOME_View* theView ) const; void setDisplayedIndicesInfo( const QString& theEntry, SALOME_View* theView, const QString theIndicesInfo ); diff --git a/src/GEOMGUI/GEOMGUI_TextTreeSelector.cxx b/src/GEOMGUI/GEOMGUI_TextTreeSelector.cxx new file mode 100644 index 000000000..e65817249 --- /dev/null +++ b/src/GEOMGUI/GEOMGUI_TextTreeSelector.cxx @@ -0,0 +1,218 @@ +// Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : GEOMGUI_TextTreeSelector.cxx +// Author : +// +#include "GEOMGUI_TextTreeSelector.h" +#include "GEOMGUI_TextTreeWdg.h" +#include "GEOMGUI_AnnotationMgr.h" + +#include "LightApp_DataOwner.h" +#include "LightApp_DataObject.h" +#include "LightApp_Application.h" +#include +#include + +/*! + \class GEOMGUI_TextTreeSelector + \brief Text tree selection handler class. +*/ + +/*! + \brief Constructor. + \param widget text tree widget + \param theManager selection manager +*/ +GEOMGUI_TextTreeSelector::GEOMGUI_TextTreeSelector( GEOMGUI_TextTreeWdg* theWidget, + GEOMGUI_AnnotationMgr* theAnnotationMgr, + SUIT_SelectionMgr* theManager ) +: SUIT_Selector( theManager, theWidget ), + myTextTree( theWidget ), myAnnotationMgr( theAnnotationMgr ) +{ + if ( myTextTree ) { + connect( myTextTree, SIGNAL( itemSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + } +} + +/*! + \brief Destructor. +*/ +GEOMGUI_TextTreeSelector::~GEOMGUI_TextTreeSelector() +{ +} + +/*! + \brief Get object browser. + \return a pointer to the object browser +*/ +GEOMGUI_TextTreeWdg* GEOMGUI_TextTreeSelector::textTree() const +{ + return myTextTree; +} + +/*! + \brief Get selector type. + \return selector type +*/ +QString GEOMGUI_TextTreeSelector::type() const +{ + return "TextTree"; +} + +/*! + \brief Called when the Object browser selection is changed. +*/ +void GEOMGUI_TextTreeSelector::onSelectionChanged() +{ + //QTime t1 = QTime::currentTime(); + mySelectedList.clear(); + selectionChanged(); + //QTime t2 = QTime::currentTime(); + //qDebug( QString( "selection time = %1 msecs" ).arg( t1.msecsTo( t2 ) ).toLatin1().constData() ); +} + +/*! + \brief Get list of currently selected objects. + \param theList list to be filled with the selected objects owners +*/ +void GEOMGUI_TextTreeSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const +{ + if ( mySelectedList.count() == 0 ) { + + GEOMGUI_TextTreeSelector* aThisSelector = (GEOMGUI_TextTreeSelector*)this; + QMap > aSelectedAnnotations; + myTextTree->getSelected(aSelectedAnnotations); + + QMap >::const_iterator anIt = aSelectedAnnotations.begin(), + aLast = aSelectedAnnotations.end(); + for ( ; anIt != aLast; anIt++ ) { + QString anEntry = anIt.key(); + QList anIndices = anIt.value(); + QList::const_iterator anIdIt = anIndices.begin(), anIdLast = anIndices.end(); + for ( ; anIdIt != anIdLast; anIdIt++ ) { + int anIndex = *anIdIt; + Handle(SALOME_InteractiveObject) anIO = myAnnotationMgr->FindInteractiveObject( anEntry, anIndex ); + if ( anIO.IsNull() ) + continue; + + LightApp_DataOwner* owner = new LightApp_DataOwner( anIO ); + aThisSelector->mySelectedList.append( SUIT_DataOwnerPtr( owner ) ); + } + } + } + theList = mySelectedList; + + /*if ( aSelectedAnnotations.count() == 0 ) { + SUIT_Session* session = SUIT_Session::session(); + SUIT_Application* sapp = session ? session->activeApplication() : 0; + LightApp_Application* app = dynamic_cast( sapp ); + if( !app || !myBrowser ) + return; + + DataObjectList objlist; + myBrowser->getSelected( objlist ); + GEOMGUI_TextTreeSelector* that = (GEOMGUI_TextTreeSelector*)this; + QListIterator it( objlist ); + while ( it.hasNext() ) { + LightApp_DataObject* obj = dynamic_cast( it.next() ); + if ( obj && app->checkDataObject( obj) ) { +#ifndef DISABLE_SALOMEOBJECT + Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject + ( obj->entry().toLatin1().constData(), + obj->componentDataType().toLatin1().constData(), + obj->name().toLatin1().constData() ); + LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj ); +#else + LightApp_DataOwner* owner = new LightApp_DataOwner( obj->entry() ); +#endif + that->mySelectedList.append( SUIT_DataOwnerPtr( owner ) ); + } + } + } + theList = mySelectedList;*/ +} + +/*! + \brief Set selection. + \param theList list of the object owners to be set selected +*/ +void GEOMGUI_TextTreeSelector::setSelection( const SUIT_DataOwnerPtrList& theList ) +{ + if ( !myTextTree ) + return; + + //if( myEntries.count() == 0 || myModifiedTime < myBrowser->getModifiedTime() ) + // fillEntries( myEntries ); + + QMap > aSelectedAnnotations; + DataObjectList objList; + for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); + it != theList.end(); ++it ) { + const LightApp_DataOwner* anOwner = dynamic_cast( (*it).operator->() ); + if ( !anOwner ) + continue; + Handle(SALOME_InteractiveObject) anIO = anOwner->IO(); + if ( anIO.IsNull() ) + continue; + + QString anIOEntry = anIO->getEntry(); + QStringList anAnnotationInfo = anIOEntry.split(GEOMGUI_AnnotationMgr::GetEntrySeparator()); + if (anAnnotationInfo.size() != 2 ) + continue; + + QString anEntry = anAnnotationInfo[0]; + int anAnnotationId = anAnnotationInfo[1].toInt();//myAnnotationMgr->FindAnnotationIndex( anIO ); + if ( anAnnotationId < 0) + continue; + + QList anIndices; + if ( aSelectedAnnotations.contains( anEntry ) ) + anIndices = aSelectedAnnotations[anEntry]; + + if ( !anIndices.contains( anAnnotationId ) ) + anIndices.append( anAnnotationId ); + + aSelectedAnnotations[anEntry] = anIndices; + } + myTextTree->setSelected(aSelectedAnnotations); + mySelectedList.clear(); +} + +/*! + \brief Fill map of the data objects currently shown in the Object Browser. + \param entries map to be filled +*/ +/*void GEOMGUI_TextTreeSelector::fillEntries( QMap& entries ) +{ + entries.clear(); + + if ( !myBrowser ) + return; + + for ( SUIT_DataObjectIterator it( myBrowser->root(), + SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) { + LightApp_DataObject* obj = dynamic_cast( it.current() ); + if ( obj ) + entries.insert( obj->entry(), obj ); + } + + setModified(); +}*/ + diff --git a/src/GEOMGUI/GEOMGUI_TextTreeSelector.h b/src/GEOMGUI/GEOMGUI_TextTreeSelector.h new file mode 100644 index 000000000..0d2b201bb --- /dev/null +++ b/src/GEOMGUI/GEOMGUI_TextTreeSelector.h @@ -0,0 +1,67 @@ +// Copyright (C) 2015-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : GEOMGUI_TextTreeSelector.h +// Author : +// +#ifndef GEOMGUI_TEXTTREESELECTOR_H +#define GEOMGUI_TEXTTREESELECTOR_H + +#include "GEOM_GEOMGUI.hxx" + +#include +#include + +#include + +class GEOMGUI_TextTreeWdg; +class GEOMGUI_AnnotationMgr; +//class LightApp_DataObject; + +class GEOMGUI_EXPORT GEOMGUI_TextTreeSelector : public QObject, public SUIT_Selector +{ + Q_OBJECT + +public: + GEOMGUI_TextTreeSelector( GEOMGUI_TextTreeWdg* theWidget, + GEOMGUI_AnnotationMgr* theAnnotationMgr, + SUIT_SelectionMgr* theManager ); + virtual ~GEOMGUI_TextTreeSelector(); + + GEOMGUI_TextTreeWdg* textTree() const; + + virtual QString type() const; + +private slots: + void onSelectionChanged(); + +protected: + virtual void getSelection( SUIT_DataOwnerPtrList& ) const; + virtual void setSelection( const SUIT_DataOwnerPtrList& ); + +//private: + //void fillEntries( QMap& ); + +private: + GEOMGUI_TextTreeWdg* myTextTree; + GEOMGUI_AnnotationMgr* myAnnotationMgr; + SUIT_DataOwnerPtrList mySelectedList; +}; + +#endif diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx index b22a826e3..a70cce9b0 100644 --- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx +++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx @@ -626,21 +626,86 @@ void GEOMGUI_TextTreeWdg::updateVisibility( SALOME_View* theView ) QList anAnnotationObjEntries = getObjects( aBranchType ).keys(); - QTreeWidgetItem* anItem; + QTreeWidgetItem* anEntryItem; foreach ( QString anEntry, getObjects( aBranchType ).keys() ) { - anItem = itemFromEntry( aBranchType, anEntry ); + anEntryItem = itemFromEntry( aBranchType, anEntry ); - int aDimIndex = idFromItem( anItem ); - QSharedPointer aProp = getVisualProperty( aBranchType, myStudy, - anEntry.toStdString() ); - bool isItemVisible = aProp->GetIsVisible( aDimIndex ); - anItem->setIcon( 1, isItemVisible ? myVisibleIcon : myInvisibleIcon ); + QTreeWidgetItem* anItem; + for ( int i = 0; i < anEntryItem->childCount(); i++ ) { + anItem = anEntryItem->child( i ); + int aDimIndex = idFromItem( anItem ); + QSharedPointer aProp = getVisualProperty( aBranchType, myStudy, + anEntry.toStdString() ); + bool isItemVisible = aProp->GetIsVisible( aDimIndex ); + anItem->setIcon( 1, isItemVisible ? myVisibleIcon : myInvisibleIcon ); + } redisplay( anEntry ); } } +//================================================================================= +// function : getSelected +// purpose : +//================================================================================= +void GEOMGUI_TextTreeWdg::getSelected( QMap >& theAnnotations ) +{ + theAnnotations.clear(); + + QItemSelectionModel* aSelectionModel = selectionModel(); + QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes(); + + for (int i = 0, aNbItems = aSelectedIndices.size(); i < aNbItems; i++) { + QTreeWidgetItem* anItem = itemFromIndex( aSelectedIndices[i] ); + if ( !anItem ) + continue; + QString anEntry = entryFromItem( anItem->parent() ); + int aDimIndex = idFromItem( anItem ); + if ( aDimIndex < 0 ) + continue; + + if ( theAnnotations.contains( anEntry ) ) + theAnnotations[anEntry].append( aDimIndex ); + else { + QList anIndices; + anIndices.append( aDimIndex ); + theAnnotations[anEntry] = anIndices; + } + } +} + +//================================================================================= +// function : setSelected +// purpose : +//================================================================================= +void GEOMGUI_TextTreeWdg::setSelected( const QMap >& theAnnotations ) +{ + QItemSelectionModel* aSelectionModel = selectionModel(); + aSelectionModel->clearSelection(); + + QMap >::const_iterator anIt = theAnnotations.begin(), + aLast = theAnnotations.end(); + BranchType aBranchType = AnnotationShape; + for ( ; anIt != aLast; anIt++ ) { + QString anEntry = anIt.key(); + QTreeWidgetItem* anEntryItem = itemFromEntry( aBranchType, anEntry ); + if ( !anEntryItem ) + continue; + + QList anAnnotationIds = anIt.value(); + QTreeWidgetItem* anItem; + for ( int i = 0; i < anEntryItem->childCount(); i++ ) { + anItem = anEntryItem->child( i ); + int aDimIndex = idFromItem( anItem ); + if ( anAnnotationIds.contains( aDimIndex ) ) { + QModelIndex anIndex = indexFromItem( anItem ); + aSelectionModel->select( anIndex, QItemSelectionModel::Select ); + } + } + } +} + //================================================================================= // function : setShapeItemVisibility // purpose : diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h index 433a64df1..2025a511e 100644 --- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h +++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h @@ -24,6 +24,8 @@ #include "GEOM_Displayer.h" #include +#include +#include #include #include @@ -68,6 +70,9 @@ public: const bool theVisibility ); void updateVisibility( SALOME_View* theView ); + void getSelected( QMap >& theAnnotations ); + void setSelected( const QMap >& theAnnotations ); + protected: void createActions(); void redisplay( QString theEntry ); diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 206c8ff6e..e2ab1e289 100755 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -697,13 +697,15 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO, Erase( theIO, true, false, theViewFrame ); Display( theIO, theUpdateViewer, theViewFrame ); myIsRedisplayed = aRedisplayed; - if ( !theViewFrame->isVisible( theIO ) ) { - // hide annotations for erased presentation - SUIT_Session* session = SUIT_Session::session(); - SalomeApp_Application* anApp = dynamic_cast( session->activeApplication() ); - GeometryGUI* aModule = dynamic_cast( anApp->activeModule() ); - if ( aModule ) + // hide annotations for erased presentation + SUIT_Session* session = SUIT_Session::session(); + SalomeApp_Application* anApp = dynamic_cast( session->activeApplication() ); + GeometryGUI* aModule = dynamic_cast( anApp->activeModule() ); + if ( aModule ) { + if ( !theViewFrame->isVisible( theIO ) ) aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(theIO->getEntry()), theViewFrame); + else + aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(theIO->getEntry()), theViewFrame); } } diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index a1f8677dd..83705e6d2 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -40,6 +40,7 @@ #include "GEOM_AISShape.hxx" #include "GEOMUtils_XmlHandler.hxx" #include "GEOMGUI_AnnotationMgr.h" +#include "GEOMGUI_TextTreeSelector.h" #include "GEOM_Actor.h" @@ -1847,8 +1848,10 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg ); getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea ); - if ( !myTextTreeWdg ) + if ( !myTextTreeWdg ) { myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() ); + new GEOMGUI_TextTreeSelector( myTextTreeWdg, GetAnnotationMgr(), getApp()->selectionMgr() ); + } getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg ); getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );