Salome HOME
updated copyright message
[modules/gui.git] / src / LightApp / LightApp_Module.cxx
index 45954c3824991b60db002248ed4fa6adc95d0142..19c1624c5b8c9923125b618c3df50cf0d5becf6b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -53,7 +53,6 @@
 
 #ifndef DISABLE_SALOMEOBJECT
 #include <SALOME_ListIO.hxx>
-#include <SALOME_ListIteratorOfListIO.hxx>
 #endif
 
 #ifndef DISABLE_VTKVIEWER
   #include <PVViewer_ViewManager.h>
   #include <PVViewer_ViewWindow.h>
 #endif
+#ifndef DISABLE_PV3DVIEWER
+  #include <PV3DViewer_ViewWindow.h>
+  #include <PV3DViewer_ViewModel.h>
+#endif
 #ifndef DISABLE_PLOT2DVIEWER
   #include <Plot2d_ViewWindow.h>
   #include <Plot2d_ViewFrame.h>
@@ -150,6 +153,7 @@ void LightApp_Module::contextMenuPopup( const QString& client, QMenu* menu, QStr
   popupMgr()->setSelection( sel );
   popupMgr()->setMenu( menu );
   popupMgr()->updateMenu();
+  popupMgr()->setSelection( 0 );
 }
 
 /*!Update object browser.
@@ -158,6 +162,8 @@ void LightApp_Module::contextMenuPopup( const QString& client, QMenu* menu, QStr
 void LightApp_Module::updateObjBrowser( bool theIsUpdateDataModel, 
                                         SUIT_DataObject* theDataObject )
 {
+  if (!getApp()->objectBrowser())
+    return;
   bool upd = getApp()->objectBrowser()->autoUpdate();
   getApp()->objectBrowser()->setAutoUpdate( false );
 
@@ -203,7 +209,7 @@ bool LightApp_Module::isSelectionCompatible()
     // check data type of selection
     SALOME_ListIteratorOfListIO It( selected );
     for ( ; isCompatible && It.More(); It.Next()) {
-      Handle(SALOME_InteractiveObject)& io = It.Value();
+      Handle(SALOME_InteractiveObject) io = It.Value();
       isCompatible = ( aStudy->componentDataType( io->getEntry() ) == moduleDataType );
     }
   }
@@ -250,11 +256,6 @@ bool LightApp_Module::activateModule( SUIT_Study* study )
     treeModel->setAppropriate( EntryCol, Qtx::Toggled );
   }*/
 
-  if ( myIsFirstActivate ) {
-    updateModuleVisibilityState();
-    myIsFirstActivate = false;
-  }
-  
   return res;
 }
 
@@ -318,6 +319,11 @@ void LightApp_Module::MenuItem()
 {
 }
 
+/*!NOT IMPLEMENTED*/
+void LightApp_Module::updateInfoPanel()
+{
+}
+
 /*!NOT IMPLEMENTED*/
 void LightApp_Module::createPreferences()
 {
@@ -375,6 +381,12 @@ void LightApp_Module::update( const int theFlags )
           ( (VTKViewer_ViewWindow*)viewWnd )->Repaint();
 #endif
 #endif
+#ifndef DISABLE_PV3DVIEWER
+        // if ( viewWnd->inherits( "SPV3D_ViewWindow" ) )
+        //   ( (SPV3D_ViewWindow*)viewWnd )->Repaint();
+        // if ( viewWnd->inherits( "PV3DViewer_ViewWindow" ) )
+        //   ( (PV3DViewer_ViewWindow*)viewWnd )->getMultiViewManager()->Repaint();
+#endif
 #ifndef DISABLE_OCCVIEWER
         if ( viewWnd->inherits( "OCCViewer_ViewWindow" ) )
           ( (OCCViewer_ViewWindow*)viewWnd )->getViewPort()->onUpdate();
@@ -461,9 +473,9 @@ QtxPopupMgr* LightApp_Module::popupMgr()
     myPopupMgr->insert( eraseAll, -1, 0 );
     myPopupMgr->insert( separator(), -1, 0 );
 
-    QString oneAndNotActive = "( count( $component ) = 1 ) and ( not( activeModule in $component ) )";
+    QString oneAndNotActive = "( count( $component ) = 1 ) and ( not( activeModule in $component ) ) and ( not($displayer={'%3'}) )";
     QString uniform = "true in $canBeDisplayed and %1 and ( activeModule = '%2' )";
-    uniform = uniform.arg( oneAndNotActive ).arg( name() );
+    uniform = uniform.arg( oneAndNotActive ).arg( name() ).arg( LightApp_Application::moduleDisplayer( name() ) );
     myPopupMgr->setRule( disp, /*QString( "( not isVisible ) and " ) + */ uniform, QtxPopupMgr::VisibleRule );
     myPopupMgr->setRule( erase, /*QString( "( isVisible ) and " ) + */ uniform, QtxPopupMgr::VisibleRule );
     myPopupMgr->setRule( dispOnly, uniform, QtxPopupMgr::VisibleRule );
@@ -484,6 +496,13 @@ QtxPopupMgr* LightApp_Module::popupMgr()
     viewers.append( VTKViewer_Viewer::Type() );
 #endif
 #endif
+#ifndef DISABLE_PV3DVIEWER
+// #ifndef DISABLE_SALOMEOBJECT
+//     viewers.append( SPV3D_ViewModel::Type() );
+// #else
+    viewers.append( PV3DViewer_ViewModel::Type() );
+// #endif
+#endif
 #ifndef DISABLE_PLOT2DVIEWER
 #ifndef DISABLE_SALOMEOBJECT
     viewers.append( SPlot2d_Viewer::Type() );
@@ -703,7 +722,7 @@ LightApp_Operation* LightApp_Module::operation( const int id ) const
 /*!
   virtual method called to manage the same operations
 */
-bool LightApp_Module::reusableOperation( const int id )
+bool LightApp_Module::reusableOperation( const int /*id*/ )
 {
  return true;
 } 
@@ -801,9 +820,17 @@ void LightApp_Module::updateModuleVisibilityState()
   SUIT_DataBrowser* ob = app->objectBrowser();
   if ( !ob || !ob->model() ) return;
 
+  if ( !myIsFirstActivate )
+    return;
+
+  myIsFirstActivate = false;
+
   // connect to click on item
   connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
            this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection );
+  // connect to click on item
+  connect( ob, SIGNAL( destroyed( QObject* ) ),
+           this, SLOT( onOBDestroyed() ), Qt::UniqueConnection );
 
   SUIT_DataObject* rootObj = ob->root();
   if ( !rootObj ) return;
@@ -846,3 +873,8 @@ void LightApp_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn
   if ( id != -1 )
     startOperation( id );
 }
+
+void LightApp_Module::onOBDestroyed()
+{
+  myIsFirstActivate = true;
+}