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.
This commit is contained in:
nds 2016-11-03 10:29:21 +03:00
parent fafd844ade
commit 8fca8ce02e
7 changed files with 53 additions and 37 deletions

View File

@ -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<SALOME_View*>(anActiveWindow->getViewManager()->getViewModel());
if (anActiveWindow)
aView = dynamic_cast<SALOME_View*>(anActiveWindow->getViewManager()->getViewModel());
}
return aView;
}
void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theIndex,

View File

@ -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<VisualProperty> aProp = getVisualProperty( aBranchType, myStudy, anEntry );
CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(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 );

View File

@ -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 );

View File

@ -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<SalomeApp_Application*>( 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 (<forced> == 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<SalomeApp_Application*>( session->activeApplication() );
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( 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<SalomeApp_Application*>( session->activeApplication() );
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( 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<SalomeApp_Application*>( session->activeApplication() );
GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
if ( aModule )
aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(p->GetEntry()), v);
}
}
//=================================================================

View File

@ -318,6 +318,7 @@ protected:
Aspect_TypeOfMarker myTypeOfMarker;
double myScaleOfMarker;
double myTransparency;
bool myIsRedisplayed;
private:
SalomeApp_Application* myApp;

View File

@ -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<SalomeApp_Study*>( 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<SalomeApp_Study*>( 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<SalomeApp_Study*>( 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<int, int>& mappa ) const
{
mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );

View File

@ -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();