]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Check if Erase comes from Redisplay, in this case, Annotation Manager should not...
authornds <natalia.ermolaeva@opencascade.com>
Thu, 3 Nov 2016 07:29:21 +0000 (10:29 +0300)
committernds <natalia.ermolaeva@opencascade.com>
Thu, 3 Nov 2016 07:29:21 +0000 (10:29 +0300)
Problem case: Click on tree widget item do not visualizes it, icon stays gray.

src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx
src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx
src/GEOMGUI/GEOMGUI_TextTreeWdg.h
src/GEOMGUI/GEOM_Displayer.cxx
src/GEOMGUI/GEOM_Displayer.h
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI.h

index 91d063a072ae2e7f9ed852fe4de4dac96b2560b3..e6796ed414be55d217e32552c0be2da76ab1f39f 100755 (executable)
@@ -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,
index 881e9dbb8c3f249bfb4d13b33271b3f359599587..b22a826e37b2c8c2a390e5be22702f1091d33470 100644 (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 );
index abbb99b6c2c680bc25d669c56d7708fa2a4b70ca..433a64df176efe5c17b995011fc56b5f7fbdef19 100644 (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 );
index 1e7d726903aa1d9c943828b531881f5e7d3f6807..206c8ff6e760d2161c84fb51bc9123c37b9be5ce 100755 (executable)
@@ -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);
+  }
 }
 
 //=================================================================
index 1ae65287039954d986b3d7faa17a52f8cdb906aa..390466f58fd5e362339a1d09ca3712fef2a15f56 100755 (executable)
@@ -318,6 +318,7 @@ protected:
   Aspect_TypeOfMarker              myTypeOfMarker;
   double                           myScaleOfMarker;
   double                           myTransparency;
+  bool                             myIsRedisplayed;
 
 private:
   SalomeApp_Application* myApp;
index e9d676bd0820fdf9142ad72bdbe76bf6573efc22..a1f8677dd2667579f9fca9ecd964f36bab3b9187 100644 (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 );
index f334ba3b9dbb923f38605339b50ac17a0bee3075..2481cdfad9814bd83ae6a09835b31030a5188388 100644 (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();