From 8fca8ce02e414cf84d31e063dc43f15540d2ca03 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 3 Nov 2016 10:29:21 +0300 Subject: [PATCH] Check if Erase comes from Redisplay, in this case, Annotation Manager should not erase displayed annotations. Problem case: Click on tree widget item do not visualizes it, icon stays gray. --- src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx | 16 +++++++++----- src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx | 14 +++++++----- src/GEOMGUI/GEOMGUI_TextTreeWdg.h | 2 +- src/GEOMGUI/GEOM_Displayer.cxx | 32 +++++++++++++++++++++++++++ src/GEOMGUI/GEOM_Displayer.h | 1 + src/GEOMGUI/GeometryGUI.cxx | 22 +----------------- src/GEOMGUI/GeometryGUI.h | 3 --- 7 files changed, 53 insertions(+), 37 deletions(-) diff --git a/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx index 91d063a07..e6796ed41 100755 --- a/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx +++ b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx @@ -208,10 +208,11 @@ void GEOMGUI_AnnotationMgr::DisplayVisibleAnnotations( const QString& theEntry, void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SALOME_View* theView ) { - if ( !myVisualized.contains( theView ) ) + SALOME_View* aView = viewOrActiveView( theView ); + if ( !myVisualized.contains( aView ) ) return; - EntryToAnnotations anEntryToAnnotation = myVisualized[theView]; + EntryToAnnotations anEntryToAnnotation = myVisualized[aView]; if ( !anEntryToAnnotation.contains( theEntry ) ) return; AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry]; @@ -228,11 +229,11 @@ void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SA // erase presentation from the viewer SALOME_Prs* aPrs = anAnnotationToPrs[anIndex]; - theView->Erase( getDisplayer(), aPrs ); + aView->Erase( getDisplayer(), aPrs ); } getDisplayer()->UpdateViewer(); anEntryToAnnotation.remove( theEntry ); - myVisualized[theView] = anEntryToAnnotation; + myVisualized[aView] = anEntryToAnnotation; } void GEOMGUI_AnnotationMgr::RemoveView( SALOME_View* theView ) @@ -282,11 +283,14 @@ GEOM_Displayer* GEOMGUI_AnnotationMgr::getDisplayer() const SALOME_View* GEOMGUI_AnnotationMgr::viewOrActiveView(SALOME_View* theView) const { - if ( !theView ) { + SALOME_View* aView = theView; + if ( !aView ) { SalomeApp_Application* anApp = getApplication(); SUIT_ViewWindow* anActiveWindow = anApp->desktop()->activeWindow(); - theView = dynamic_cast(anActiveWindow->getViewManager()->getViewModel()); + if (anActiveWindow) + aView = dynamic_cast(anActiveWindow->getViewManager()->getViewModel()); } + return aView; } void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theIndex, diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx index 881e9dbb8..b22a826e3 100644 --- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx +++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx @@ -207,7 +207,8 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app ) this, SLOT( updateAnnotationBranch( const QString& ) ) ); connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ), this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) ); - + connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ), + this, SLOT( onUpdateVisibilityColumn( QString, Qtx::VisibilityState ) ) ); } //================================================================================= @@ -405,15 +406,16 @@ void GEOMGUI_TextTreeWdg::onItemClicked( QTreeWidgetItem* theItem, int theColumn QSharedPointer aProp = getVisualProperty( aBranchType, myStudy, anEntry ); + CAM_Application* anApp = dynamic_cast(myStudy->application()); + GeometryGUI* aModule = dynamic_cast(anApp->activeModule()); if ( aProp->GetIsVisible( aDimIndex ) ) { - aProp->SetIsVisible( aDimIndex, false ); + aModule->GetAnnotationMgr()->Erase(anEntry.c_str(), aDimIndex); theItem->setIcon( 1, myInvisibleIcon ); } else { - aProp->SetIsVisible( aDimIndex, true ); + aModule->GetAnnotationMgr()->Display(anEntry.c_str(), aDimIndex); + theItem->setIcon( 1, myVisibleIcon ); } - aProp->Save(); - redisplay( anEntry.c_str() ); } @@ -460,7 +462,7 @@ QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( const BranchType& theBranch // function : onUpdateVisibilityColumn // purpose : Update visible state of icons of entry items. //================================================================================= -void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState ) +void GEOMGUI_TextTreeWdg::onUpdateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState ) { // dimension property branch updateVisibilityColumn( DimensionShape, theEntry, theState ); diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h index abbb99b6c..433a64df1 100644 --- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h +++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h @@ -67,7 +67,6 @@ public: QTreeWidgetItem* theWidgetItem, const bool theVisibility ); void updateVisibility( SALOME_View* theView ); - void updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState ); protected: void createActions(); @@ -80,6 +79,7 @@ public slots: void updateAnnotationBranch( const QString& theEntry ); private slots: + void onUpdateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState ); void onItemClicked(QTreeWidgetItem*, int ); void setVisibility( QTreeWidgetItem* theItem, bool visibility ); void showContextMenu( const QPoint& pos ); diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 1e7d72690..206c8ff6e 100755 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -464,6 +464,7 @@ static std::string getName( GEOM::GEOM_BaseObject_ptr object ) */ //================================================================= GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st ) +: myIsRedisplayed( false ) { if( st ) myApp = dynamic_cast( st->application() ); @@ -640,6 +641,8 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO, const bool updateViewer, const bool checkActiveViewer ) { + bool aRedisplayed = myIsRedisplayed; + myIsRedisplayed = true; // Remove the object permanently ( == true) SUIT_Session* ses = SUIT_Session::session(); SUIT_Application* app = ses->activeApplication(); @@ -669,6 +672,7 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO, } } } + myIsRedisplayed = aRedisplayed; } //================================================================= @@ -688,8 +692,19 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO, return; } + bool aRedisplayed = myIsRedisplayed; + myIsRedisplayed = true; 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 ) + aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(theIO->getEntry()), theViewFrame); + } } //================================================================= @@ -2159,6 +2174,14 @@ void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* ) void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p ) { UpdateColorScale(false,false); + if ( !myIsRedisplayed ) { + // visualize annotations for displayed presentation + SUIT_Session* session = SUIT_Session::session(); + SalomeApp_Application* anApp = dynamic_cast( session->activeApplication() ); + GeometryGUI* aModule = dynamic_cast( anApp->activeModule() ); + if ( aModule ) + aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(p->GetEntry()), v); + } } void GEOM_Displayer::BeforeErase( SALOME_View* v, const SALOME_OCCPrs* p ) @@ -2171,6 +2194,15 @@ void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p ) { LightApp_Displayer::AfterErase( v, p ); UpdateColorScale(false,false); + + if ( !myIsRedisplayed ) { + // 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 ) + aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(p->GetEntry()), v); + } } //================================================================= diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h index 1ae652870..390466f58 100755 --- a/src/GEOMGUI/GEOM_Displayer.h +++ b/src/GEOMGUI/GEOM_Displayer.h @@ -318,6 +318,7 @@ protected: Aspect_TypeOfMarker myTypeOfMarker; double myScaleOfMarker; double myTransparency; + bool myIsRedisplayed; private: SalomeApp_Application* myApp; diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index e9d676bd0..a1f8677dd 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -1828,11 +1828,6 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); - SalomeApp_Study* appStudy = dynamic_cast( application()->activeStudy() ); - if ( appStudy ) - connect( appStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ), - this, SLOT( onUpdateVisibilityColumn( QString, Qtx::VisibilityState ) ) ); - // Reset actions accelerator keys action(GEOMOp::OpDelete)->setEnabled( true ); // Delete: Key_Delete @@ -1885,6 +1880,7 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) // 0020836 (Basic vectors and origin) SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); if ( aResourceMgr->booleanValue( "Geometry", "auto_create_base_objects", false ) ) { + SalomeApp_Study* appStudy = dynamic_cast( application()->activeStudy() ); if ( appStudy ) { _PTR(Study) studyDS = appStudy->studyDS(); if ( studyDS ) { @@ -1914,10 +1910,6 @@ bool GeometryGUI::deactivateModule( SUIT_Study* study ) disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); - SalomeApp_Study* appStudy = dynamic_cast( application()->activeStudy() ); - if ( appStudy ) - disconnect( appStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ), - this, SLOT( onUpdateVisibilityColumn( QString, Qtx::VisibilityState ) ) ); LightApp_SelectionMgr* selMrg = getApp()->selectionMgr(); @@ -1988,18 +1980,6 @@ void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win ) } } -void GeometryGUI::onUpdateVisibilityColumn( QString theEntry, - Qtx::VisibilityState theState ) -{ - if ( myTextTreeWdg ) - myTextTreeWdg->updateVisibilityColumn( theEntry, theState ); - - if ( theState == Qtx::ShownState ) - GetAnnotationMgr()->DisplayVisibleAnnotations( theEntry ); - else - GetAnnotationMgr()->EraseVisibleAnnotations( theEntry ); -} - void GeometryGUI::windows( QMap& mappa ) const { mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea ); diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index f334ba3b9..2481cdfad 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -171,9 +171,6 @@ protected slots: private slots: void OnGUIEvent(); void onWindowActivated( SUIT_ViewWindow* ); - void onUpdateVisibilityColumn( QString theEntry, - Qtx::VisibilityState theState ); - void onViewAboutToShow(); void OnSetMaterial( const QString& ); void updateMaterials(); -- 2.39.2