]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
0020830: EDF 1357 GUI : Hide/Show Icon
authorptv <ptv@opencascade.com>
Wed, 17 Nov 2010 08:32:44 +0000 (08:32 +0000)
committerptv <ptv@opencascade.com>
Wed, 17 Nov 2010 08:32:44 +0000 (08:32 +0000)
34 files changed:
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/LightApp/LightApp_DataObject.cxx
src/LightApp/LightApp_DataObject.h
src/LightApp/LightApp_Displayer.cxx
src/LightApp/LightApp_Displayer.h
src/LightApp/LightApp_Module.cxx
src/LightApp/LightApp_OBSelector.cxx
src/LightApp/LightApp_OBSelector.h
src/LightApp/LightApp_SelectionMgr.cxx
src/LightApp/LightApp_ShowHideOp.cxx
src/Prs/SALOME_Prs.h
src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx
src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h
src/SOCC/SOCC_ViewModel.cxx
src/SOCC/SOCC_ViewModel.h
src/SPlot2d/SPlot2d_ViewModel.cxx
src/SPlot2d/SPlot2d_ViewModel.h
src/STD/STD_Application.cxx
src/SUIT/SUIT_DataBrowser.cxx
src/SUIT/SUIT_DataBrowser.h
src/SUIT/SUIT_DataObject.cxx
src/SUIT/SUIT_DataObject.h
src/SUIT/SUIT_TreeModel.cxx
src/SUIT/SUIT_TreeModel.h
src/SalomeApp/Makefile.am
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h
src/SalomeApp/SalomeApp_DataObject.cxx
src/SalomeApp/SalomeApp_Module.cxx
src/SalomeApp/SalomeApp_Module.h
src/SalomeApp/resources/SalomeApp_images.ts
src/SalomeApp/resources/icon_visibility_off.png [new file with mode: 0644]
src/SalomeApp/resources/icon_visibility_on.png [new file with mode: 0644]

index 8ad007ba55c0b4d0ae2068c5a1e7ed0b58f450c9..24dea7174fe9bbf58187e9540785527415d01723 100644 (file)
   #include <VTKViewer_ViewModel.h>
 #endif
 
+#ifndef DISABLE_SALOMEOBJECT
+  #include <SALOME_Prs.h>
+  #include <SUIT_DataObject.h>
+#endif
+
 //#ifndef DISABLE_SUPERVGRAPHVIEWER
 //  #include <SUPERVGraph_ViewModel.h>
 //  #include <SUPERVGraph_ViewFrame.h>
@@ -3425,3 +3430,13 @@ void LightApp_Application::onPaste()
   if( m )
     m->paste();
 }
+
+#ifndef DISABLE_SALOMEOBJECT
+/*!
+  Update visibility state of given objects
+ */
+void LightApp_Application::updateVisibilityState( DataObjectList& /*theList*/,
+                                                  SALOME_View*    /*theView*/ )
+{
+}
+#endif
index 4561c4d779c1b3ce3aa57e85fa66f12b89e737ca..1142b739c90c8f8cb85174a2e026b89b4fede7e8 100644 (file)
@@ -50,6 +50,11 @@ class SUIT_Study;
 class SUIT_Accel;
 class CAM_Module;
 
+#ifndef DISABLE_SALOMEOBJECT
+class SALOME_View;
+#include <LightApp_DataObject.h>
+#endif
+
 class QString;
 class QWidget;
 class QStringList;
@@ -157,6 +162,12 @@ public:
   //! Removes ViewManagers only of known type
   virtual void                        clearKnownViewManagers();
 
+#ifndef DISABLE_SALOMEOBJECT
+  //! update visibility state of objects
+  virtual void                        updateVisibilityState( DataObjectList& theList,
+                                                             SALOME_View*    theView );
+#endif
+
 signals:
   void                                studyOpened();
   void                                studySaved();
index 804bbc214e3ccaab95615a6247a499d5009ce63a..789c42189bb474d63aa07c4f62c3a0acb92e6ab3 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <CAM_Module.h>
 #include <SUIT_DataObjectKey.h>
+#include <SUIT_DataObjectIterator.h>
 
 #include <QVariant>
 
@@ -269,6 +270,24 @@ bool LightApp_DataObject::compare( const QVariant& left, const QVariant& right,
   return CAM_DataObject::compare( left, right, id );
 }
 
+/*!
+  \brief Constructor.
+  \param theRoot - main parent object
+  \param theMap - map of entry-object relation
+*/
+void LightApp_DataObject::FillEntryObjMap( SUIT_DataObject* theRoot,
+                                           LightApp_EntryObjMap& theMap )
+{
+  if (!theRoot)
+    return;
+  SUIT_DataObjectIterator it( theRoot, SUIT_DataObjectIterator::DepthLeft );
+  for ( ; it.current(); ++it ) {
+    LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( it.current() );
+    if ( obj )
+      theMap.insert( obj->entry(), obj );
+  }
+}
+
 /*!
   \class LightApp_ModuleObject
   \brief Used for optimized access to the data model from the data objects.
index 3b8bb9cc12e72cb4b7110c0648afd42715b2944d..c6f5cf7fd314bf082c5bab66de6e76ee12277e89 100644 (file)
 
 #include "LightApp.h"
 #include <CAM_DataObject.h>
+#include <QMap>
 
 class CAM_DataModel;
 class LightApp_Study;
+class LightApp_DataObject;
+
+//! entry - data object relationship map
+typedef QMap<QString, LightApp_DataObject*> LightApp_EntryObjMap;
 
 class LIGHTAPP_EXPORT LightApp_DataObject : public virtual CAM_DataObject
 {
@@ -58,6 +63,10 @@ public:
   virtual bool                    compare( const QVariant&, const QVariant&, const int = NameId ) const;
   virtual int                     groupId() const;
 
+  static void                     FillEntryObjMap( SUIT_DataObject*      theRoot,
+                                                   LightApp_EntryObjMap& theMap );
+
+
 protected:
   QString                         myCompDataType;
   SUIT_DataObject*                myCompObject;
index afa34797535d15aee404256e4ce563031f91ffa8..e2c430af04638f5f0d8fe20df79591984f00319f 100644 (file)
 #include <SUIT_ViewWindow.h>
 
 #include <QString>
+#include <QStringList>
 #ifndef DISABLE_SALOMEOBJECT
-  #include "SALOME_InteractiveObject.hxx"
+#include <SALOME_InteractiveObject.hxx>
+#include <SUIT_DataObjectIterator.h>
 #endif
 
 /*!
@@ -57,24 +59,44 @@ LightApp_Displayer::~LightApp_Displayer()
   \param updateViewer - is it necessary to update viewer
   \param theViewFrame - view
 */
-void LightApp_Displayer::Display( const QString& entry, const bool updateViewer, SALOME_View* theViewFrame )
+void LightApp_Displayer::Display( const QString& entry, const bool updateViewer,
+                                  SALOME_View* theViewFrame, const bool updateVisState )
 {
-  SALOME_Prs* prs = buildPresentation( entry, theViewFrame );
-  if ( prs )
+  QStringList aList;
+  aList.append( entry );
+  Display( aList, updateViewer, theViewFrame, updateVisState );
+}
+
+/*!
+  Displays object in view
+  \param list - object entries
+  \param updateViewer - is it necessary to update viewer
+  \param theViewFrame - view
+*/
+void LightApp_Displayer::Display( const QStringList& list, const bool updateViewer,
+                                  SALOME_View* theViewFrame, const bool updateVisState )
+{
+  SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+  QStringList::const_iterator it = list.constBegin();
+  for ( ; it != list.constEnd(); ++it)
   {
-    SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
-    if ( vf )
+    SALOME_Prs* prs = buildPresentation( *it, vf );
+    if ( prs )
     {
-      vf->BeforeDisplay( this );
-      vf->Display( prs );
-      vf->AfterDisplay( this );
-
-      if ( updateViewer )
-        vf->Repaint();
+      if ( vf )
+      {
+        vf->BeforeDisplay( this );
+        vf->Display( prs );
+        vf->AfterDisplay( this );
 
+        if ( updateViewer )
+          vf->Repaint();
+      }
       delete prs;  // delete presentation because displayer is its owner
     }
   }
+  if ( updateVisState )
+    updateVisibilityState( list, vf );
 }
 
 /*!
@@ -104,8 +126,8 @@ void LightApp_Displayer::Redisplay( const QString& entry, const bool updateViewe
       SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
       if( view && ( IsDisplayed( entry, view ) || view == GetActiveView() ) )
       {
-        Erase( entry, true, false, view );
-        Display( entry, updateViewer, view );
+        Erase( entry, true, false, view, false );
+        Display( entry, updateViewer, view, false );
       }
     }
   }
@@ -119,12 +141,34 @@ void LightApp_Displayer::Redisplay( const QString& entry, const bool updateViewe
   \param theViewFrame - view
 */
 void LightApp_Displayer::Erase( const QString& entry, const bool forced,
-                                const bool updateViewer, SALOME_View* theViewFrame )
+                                const bool updateViewer,
+                                SALOME_View* theViewFrame, const bool updateVisState )
+{
+  QStringList aList;
+  aList.append( entry );
+  Erase( aList, forced, updateViewer, theViewFrame, updateVisState );
+}
+
+/*!
+  Erases object in view
+  \param list - object entries
+  \param forced - deletes object from viewer (otherwise it will be erased, but cached)
+  \param updateViewer - is it necessary to update viewer
+  \param theViewFrame - view
+*/
+void LightApp_Displayer::Erase( const QStringList& list, const bool forced,
+                                const bool updateViewer,
+                                SALOME_View* theViewFrame, const bool updateVisState )
 {
   SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
 
-  if ( vf ) {
-    SALOME_Prs* prs = vf->CreatePrs( entry.toLatin1() );
+  if ( !vf )
+    return;
+
+  QStringList::const_iterator it = list.constBegin();
+  for ( ; it != list.constEnd(); ++it)
+  {
+    SALOME_Prs* prs = vf->CreatePrs( (*it).toLatin1().data() );
     if ( prs ) {
       vf->Erase( prs, forced );
       if ( updateViewer )
@@ -132,6 +176,8 @@ void LightApp_Displayer::Erase( const QString& entry, const bool forced,
       delete prs;  // delete presentation because displayer is its owner
     }
   }
+  if ( updateVisState )
+    updateVisibilityState( list, vf );
 }
 
 /*!
@@ -140,7 +186,8 @@ void LightApp_Displayer::Erase( const QString& entry, const bool forced,
   \param updateViewer - is it necessary to update viewer
   \param theViewFrame - view
 */
-void LightApp_Displayer::EraseAll( const bool forced, const bool updateViewer, SALOME_View* theViewFrame ) const
+void LightApp_Displayer::EraseAll( const bool forced, const bool updateViewer,
+                                   SALOME_View* theViewFrame, const bool updateVisState ) const
 {
   SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
 
@@ -149,6 +196,69 @@ void LightApp_Displayer::EraseAll( const bool forced, const bool updateViewer, S
     if ( updateViewer )
       vf->Repaint();
   }
+  if ( updateVisState )
+    updateVisibilityState( vf );
+}
+
+/*!
+  updte visibility state of all objects
+  \param theViewFrame - view
+*/
+void LightApp_Displayer::updateVisibilityState( SALOME_View* theViewFrame ) const
+{
+  // this code wrapped by pre-processor directive, becase it works with SALOME_View
+  // and has no effect in case of SALOMEOBJECT disabled
+#ifndef DISABLE_SALOMEOBJECT
+  SUIT_Session* session = SUIT_Session::session();
+  LightApp_Application* app = dynamic_cast<LightApp_Application*>(session->activeApplication());
+  if (!app)
+    return;
+  SUIT_Study* study =  app->activeStudy();
+  if (!study)
+    return;
+  
+  DataObjectList anObjList;
+  SUIT_DataObjectIterator it( study->root(), SUIT_DataObjectIterator::DepthLeft );
+  for ( ; it.current(); ++it )
+    anObjList.append( it.current() );
+  app->updateVisibilityState( anObjList, theViewFrame );
+#endif
+}
+/*!
+  updte visibility state of given objects
+  \param theList - objects to update state
+  \param theViewFrame - view
+*/
+void LightApp_Displayer::updateVisibilityState( const QStringList& theList,
+                                                SALOME_View* theViewFrame ) const
+{
+  // this code wrapped by pre-processor directive, becase it works with SALOME_View
+  // and has no effect in case of SALOMEOBJECT disabled
+#ifndef DISABLE_SALOMEOBJECT
+  SUIT_Session* session = SUIT_Session::session();
+  LightApp_Application* app = dynamic_cast<LightApp_Application*>(session->activeApplication());
+  if (!app)
+    return;
+  SUIT_Study* study = app->activeStudy();
+  if (!study)
+    return;
+  
+  LightApp_EntryObjMap anEntryObjMap;
+  LightApp_DataObject::FillEntryObjMap( study->root(), anEntryObjMap );
+  if (anEntryObjMap.isEmpty())
+    return;
+
+  // take data objects by entries
+  DataObjectList anObjList;
+  QStringList::const_iterator it = theList.constBegin();
+  for ( ; it != theList.constEnd(); ++it) {
+    if (anEntryObjMap.contains( *it ) )
+      anObjList.append( anEntryObjMap[ *it ] );
+  }
+
+  app->updateVisibilityState( anObjList,  theViewFrame );
+#endif
 }
 
 /*!
index 272cd7f6ea5358cb7d404bb29b554839c2650287..1685b2f06e4334d83326a14211dce4a86f4616d7 100644 (file)
@@ -28,6 +28,7 @@
 #include <SALOME_Prs.h>
 
 class QString;
+class QStringList;
 
 /*!
   \class LightApp_Displayer
@@ -40,10 +41,17 @@ public:
   LightApp_Displayer();
   virtual ~LightApp_Displayer();
 
-  void Display( const QString&, const bool = true, SALOME_View* = 0 );
-  void Redisplay( const QString&, const bool = true );
-  void Erase( const QString&, const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 );
-  void EraseAll( const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 ) const;
+  void Display( const QString&, const bool = true,
+                SALOME_View* = 0, const bool updateVisState = true );
+  void Display( const QStringList&, const bool = true,
+                SALOME_View* = 0, const bool updateVisState= true );
+  void Redisplay( const QString&,     const bool = true );
+  void Erase( const QString&,     const bool forced = false,
+              const bool updateViewer = true, SALOME_View* = 0, const bool updateVisState = true );
+  void Erase( const QStringList&, const bool forced = false,
+              const bool updateViewer = true, SALOME_View* = 0, const bool updateVisState = true );
+  void EraseAll( const bool forced = false, const bool updateViewer = true,
+                 SALOME_View* = 0, const bool updateVisState = true ) const;
   bool IsDisplayed( const QString&, SALOME_View* = 0 ) const;
   void UpdateViewer() const;
 
@@ -55,6 +63,10 @@ public:
 
 protected:
   virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
+
+  void updateVisibilityState( SALOME_View* theViewFrame ) const;
+  void updateVisibilityState( const QStringList& theList,
+                              SALOME_View* theViewFrame ) const;
 };
 
 #endif
index c456acd828b84725e0e619344b8d250b849e410a..11f02ba0eb2318f13c84ca4647c8cc09958d6bd6 100644 (file)
@@ -121,6 +121,24 @@ void LightApp_Module::initialize( CAM_Application* app )
   SUIT_ResourceMgr* resMgr = app ? app->resourceMgr() : 0;
   if ( resMgr )
     resMgr->raiseTranslators( name() );
+
+  // create show-hide actions
+  QPixmap p;
+  SUIT_Desktop* d = app->desktop();
+  QAction 
+    *disp = createAction( -1, tr( "TOP_SHOW" ), p, tr( "MEN_SHOW" ), tr( "STB_SHOW" ),
+                          0, d, false, this, SLOT( onShowHide() ), QString("General:Show object(s)") ),
+    *erase = createAction( -1, tr( "TOP_HIDE" ), p, tr( "MEN_HIDE" ), tr( "STB_HIDE" ),
+                           0, d, false, this, SLOT( onShowHide() ) , QString("General:Hide object(s)") ),
+    *dispOnly = createAction( -1, tr( "TOP_DISPLAY_ONLY" ), p, tr( "MEN_DISPLAY_ONLY" ), tr( "STB_DISPLAY_ONLY" ),
+                              0, d, false, this, SLOT( onShowHide() ) ),
+    *eraseAll = createAction( -1, tr( "TOP_ERASE_ALL" ), p, tr( "MEN_ERASE_ALL" ), tr( "STB_ERASE_ALL" ),
+                              0, d, false, this, SLOT( onShowHide() ) );
+  // store actions indeces in protected fields
+  myDisplay     = actionId( disp );
+  myErase       = actionId( erase );
+  myDisplayOnly = actionId( dispOnly );
+  myEraseAll    = actionId( eraseAll );
 }
 
 /*!NOT IMPLEMENTED*/
@@ -398,22 +416,12 @@ QtxPopupMgr* LightApp_Module::popupMgr()
   {
     myPopupMgr = new QtxPopupMgr( 0, this );
 
-    QPixmap p;
-    SUIT_Desktop* d = application()->desktop();
-    
+    // take already created actions
     QAction 
-      *disp = createAction( -1, tr( "TOP_SHOW" ), p, tr( "MEN_SHOW" ), tr( "STB_SHOW" ),
-                            0, d, false, this, SLOT( onShowHide() ), QString("General:Show object(s)") ),
-      *erase = createAction( -1, tr( "TOP_HIDE" ), p, tr( "MEN_HIDE" ), tr( "STB_HIDE" ),
-                             0, d, false, this, SLOT( onShowHide() ) , QString("General:Hide object(s)") ),
-      *dispOnly = createAction( -1, tr( "TOP_DISPLAY_ONLY" ), p, tr( "MEN_DISPLAY_ONLY" ), tr( "STB_DISPLAY_ONLY" ),
-                                0, d, false, this, SLOT( onShowHide() ) ),
-      *eraseAll = createAction( -1, tr( "TOP_ERASE_ALL" ), p, tr( "MEN_ERASE_ALL" ), tr( "STB_ERASE_ALL" ),
-                                0, d, false, this, SLOT( onShowHide() ) );
-    myDisplay     = actionId( disp );
-    myErase       = actionId( erase );
-    myDisplayOnly = actionId( dispOnly );
-    myEraseAll    = actionId( eraseAll );
+      *disp     = action( myDisplay ),
+      *erase    = action( myErase ),
+      *dispOnly = action( myDisplayOnly ),
+      *eraseAll = action( myEraseAll );
 
     myPopupMgr->insert( disp, -1, 0 ); 
     myPopupMgr->insert( erase, -1, 0 );
index 0e48995e2da162912cf6c7814dfbcdbde9eeea0b..7624af2769039c8a34e834f826d6611ac2b1bf26 100644 (file)
@@ -154,7 +154,7 @@ void LightApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
     return;
 
   if( myEntries.count() == 0 || myModifiedTime < myBrowser->getModifiedTime() )
-    fillEntries( myEntries );
+    fillEntries();
 
   DataObjectList objList;
   for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); 
@@ -172,19 +172,13 @@ void LightApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
   \brief Fill map of the data objects currently shown in the Object Browser.
   \param entries map to be filled
 */
-void LightApp_OBSelector::fillEntries( QMap<QString, LightApp_DataObject*>& entries )
+void LightApp_OBSelector::fillEntries()
 {
-  entries.clear();
+  myEntries.clear();
 
   if ( !myBrowser )
     return;
-
-  for ( SUIT_DataObjectIterator it( myBrowser->root(),
-                                    SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) {
-    LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( it.current() );
-    if ( obj )
-      entries.insert( obj->entry(), obj );
-  }
+  LightApp_DataObject::FillEntryObjMap( myBrowser->root(), myEntries );
 
   setModified();
 }
index 4a7bb6239d52f93c2a2688cc7a52679d9034f646..3d9a813dcb13136d0f51d49db23332134a756b4f 100644 (file)
@@ -27,6 +27,7 @@
 #define LIGHTAPP_OBSELECTOR_H
 
 #include "LightApp.h"
+#include "LightApp_DataObject.h"
 
 #include <SUIT_Selector.h>
 #include <SUIT_DataOwner.h>
@@ -34,7 +35,6 @@
 #include <QObject>
 
 class SUIT_DataBrowser;
-class LightApp_DataObject;
 
 class LIGHTAPP_EXPORT LightApp_OBSelector : public QObject, public SUIT_Selector
 {
@@ -50,7 +50,7 @@ public:
 
   unsigned long      getModifiedTime() const;
   void               setModified();
-
+  
 private slots:
   void               onSelectionChanged();
 
@@ -59,13 +59,13 @@ protected:
   virtual void       setSelection( const SUIT_DataOwnerPtrList& );
 
 private:
-  void               fillEntries( QMap<QString, LightApp_DataObject*>& );
+  void               fillEntries();
 
 private:
-  SUIT_DataBrowser*                   myBrowser;
-  SUIT_DataOwnerPtrList               mySelectedList;
-  QMap<QString, LightApp_DataObject*> myEntries;
-  unsigned long                       myModifiedTime;
+  SUIT_DataBrowser*     myBrowser;
+  SUIT_DataOwnerPtrList mySelectedList;
+  LightApp_EntryObjMap  myEntries;
+  unsigned long         myModifiedTime;
 };
 
 #endif
index a7b9b17d20ac0d3446daa93781ea1ed1fe028180..9424ee37773542a9cf0233f057986f6c84748a07 100644 (file)
@@ -71,6 +71,10 @@ LightApp_Application* LightApp_SelectionMgr::application() const
 void LightApp_SelectionMgr::selectedObjects( SALOME_ListIO& theList, const QString& theType,
                                              const bool convertReferences ) const
 {
+  LightApp_Study* study = dynamic_cast<LightApp_Study*>( application()->activeStudy() );
+  if ( !study )
+    return;
+
   theList.Clear();
 
   SUIT_DataOwnerPtrList aList;
@@ -85,10 +89,6 @@ void LightApp_SelectionMgr::selectedObjects( SALOME_ListIO& theList, const QStri
     if( !owner )
       continue;
 
-    LightApp_Study* study = dynamic_cast<LightApp_Study*>( application()->activeStudy() );
-    if ( !study )
-      return;
-
     entry = owner->entry();
     // Entry to check object uniqueness.
     // It is selected owner entry in the case, when we do not convert references,
@@ -138,7 +138,7 @@ void LightApp_SelectionMgr::selectedObjects( QStringList& theList, const QString
                                              const bool convertReferences ) const
 {
   theList.clear();
-
+  
   SUIT_DataOwnerPtrList aList;
   selected( aList, theType );
 
@@ -149,10 +149,6 @@ void LightApp_SelectionMgr::selectedObjects( QStringList& theList, const QString
     if( !owner )
       continue;
 
-    LightApp_Study* study = dynamic_cast<LightApp_Study*>( application()->activeStudy() );
-    if ( !study )
-      return;
-
     entry = owner->entry();
     if( !theList.contains( entry ) )
       theList.append( entry );
index d2d3608d92ab5a952f5c17cc04812684f0560a53..063af3111d2c467e526911487e50ac1b2952d8fe 100644 (file)
@@ -142,15 +142,17 @@ void LightApp_ShowHideOp::startOperation()
       else
         entries.append( entry );
     }
+  // be sure to use real obejct entries
+  QStringList objEntries;
+  QStringList::const_iterator it = entries.begin(), last = entries.end();
+  for ( ; it!=last; ++it )
+    objEntries.append( study->referencedToEntry( *it ) ); 
+  
+  if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
+    d->Display( objEntries, false, 0, true );
+  else if( myActionType==ERASE )
+    d->Erase( objEntries, false, false, 0, true );
 
-  for( QStringList::const_iterator it = entries.begin(), last = entries.end(); it!=last; it++ )
-  {
-    QString e = study->referencedToEntry( *it );
-    if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
-      d->Display( e, false, 0 );
-    else if( myActionType==ERASE )
-      d->Erase( e, false, false, 0 );
-  }
   d->UpdateViewer();
   commit();
 }
index 3ce235a4ca2fbe7e347dc888937688afd7170452..22eb63d24c7eb2c8a34f4f0b6ea45a580c4ef9bb 100755 (executable)
@@ -35,6 +35,7 @@
 
 class SALOME_View;
 class SALOME_Displayer;
+class SALOME_ListIO;
 class Handle_SALOME_InteractiveObject;
 
 /*!
@@ -199,6 +200,7 @@ public:
   //! \retval Return false.
   virtual bool isVisible( const Handle_SALOME_InteractiveObject& ){ return false; }
   virtual void Repaint() {} //!< Null body here.
+  virtual void GetVisible( SALOME_ListIO& theList ) {}
 };
 
 /*!
index c89d9cc0b534f16aadd13318f955e1dcc038b687..a905484517fe3e961ef5a0e2846f0f3f3b8c37e5 100644 (file)
@@ -142,6 +142,14 @@ QString SALOME_PYQT_Module::engineIOR() const
   return myIOR;
 }
 
+/*!
+ * Redefined to invokec correct version
+ */
+bool SALOME_PYQT_Module::activateModule( SUIT_Study* study )
+{
+  return SalomeApp_Module::activateModule( study );
+}
+
 /*!
  * Tries to get engine IOR from the Python module using engineIOR() function.
  * That function can load module engine using appropriate container if required.
index f4a35eaeb6370311804891130fa224366ed87bac..8660ecc4d1cceb35c8016d21a3dc18a4f29e5f79 100644 (file)
@@ -48,6 +48,7 @@ public:
   virtual QString            engineIOR() const;
 
 public slots:
+  virtual bool               activateModule( SUIT_Study* );
   void                       preferenceChanged( const QString&, 
                                                 const QString&, 
                                                 const QString& );
index 260bed36e5692ef21b8d2a56c520b18d6fd0c7b7..d38101e355c687ecc097861dffd5f8e490332109 100755 (executable)
@@ -45,6 +45,7 @@
 #include <SALOME_AISShape.hxx>
 #include <SALOME_AISObject.hxx>
 #include <SALOME_InteractiveObject.hxx>
+#include <SALOME_ListIO.hxx>
 
 // Temporarily commented to avoid awful dependecy on SALOMEDS
 // TODO: better mechanism of storing display/erse status in a study
@@ -198,6 +199,26 @@ bool SOCC_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& obj )
   return false;
 }
 
+/*!
+  \Collect objects visible in viewer
+  \param theList - visible objects collection
+*/
+void SOCC_Viewer::GetVisible( SALOME_ListIO& theList )
+{
+  AIS_ListOfInteractive List;
+  getAISContext()->DisplayedObjects(List);
+  
+  AIS_ListIteratorOfListOfInteractive ite(List);
+  for ( ; ite.More(); ite.Next() )
+  {
+    Handle(SALOME_InteractiveObject) anObj =
+        Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+    if ( !anObj.IsNull() && anObj->hasEntry() )
+      theList.Append( anObj );
+  }
+}
+
 /*!
   Sets color of object
   \param obj - object to be updated
index 7a5b10ef436ae9ce458c2a39f524da459e0d1ba1..04b10bbf40eff04bb788799dc78e2b5b82559d0a 100755 (executable)
@@ -31,6 +31,7 @@
 #include "SALOME_Prs.h"
 #include "OCCViewer_ViewModel.h"
 
+class SALOME_ListIO;
 class Handle(SALOME_InteractiveObject);
 
 class SOCC_EXPORT SOCC_Viewer: public OCCViewer_Viewer, public SALOME_View
@@ -63,6 +64,7 @@ public:
   virtual void                LocalSelection( const SALOME_OCCPrs*, const int );
   virtual void                GlobalSelection( const bool = false ) const;
   virtual bool                isVisible( const Handle(SALOME_InteractiveObject)& );
+  virtual void                GetVisible( SALOME_ListIO& );
   virtual void                Repaint();
 
   // a utility function, used by SALOME_View_s methods
index 581027ee37cf080b07f4d5c8b3a54adde7f67bd8..832213e569466e444acb09e7431c7d1c96a813c5 100644 (file)
@@ -309,6 +309,23 @@ bool SPlot2d_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& IObject
   return aViewFrame->isVisible( curve );
 }
 
+/*!
+  \Collect objects visible in viewer
+  \param theList - visible objects collection
+*/
+void SPlot2d_Viewer::GetVisible( SALOME_ListIO& theList )
+{
+  Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
+  if(aViewFrame == NULL) return;
+  CurveDict aCurves = aViewFrame->getCurves();
+  CurveDict::Iterator it = aCurves.begin();
+  for( ; it != aCurves.end(); ++it ) {
+    SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>(it.value()); 
+    if ( aCurve && aCurve->hasIO() && aViewFrame->isVisible( aCurve ) )
+      theList.Append( aCurve->getIO() );
+  }
+}
+
 /*!
   Return interactive obeject if is presented in the viewer
 */
index 87e187474d37bffc0502132de28e169bd3badc63..992ec97145345e09c4a77a1ed3c2e31d0ab96b3e 100644 (file)
 
 #include "SPlot2d.h"  
 
-#include "SALOME_Prs.h"
+#include <SALOME_Prs.h>
 #include "Plot2d_ViewModel.h"
-#include "SALOME_InteractiveObject.hxx"
+#include <SALOME_InteractiveObject.hxx>
+#include <SALOME_ListIO.hxx>
 #include "Plot2d_ViewFrame.h"
 #include "Plot2d_ViewWindow.h"
 #include "SPlot2d_Curve.h"
@@ -73,6 +74,7 @@ public:
   virtual void         BeforeDisplay( SALOME_Displayer* d );
   virtual void         AfterDisplay ( SALOME_Displayer* d );
   virtual bool         isVisible( const Handle(SALOME_InteractiveObject)& IObject );
+  virtual void         GetVisible( SALOME_ListIO& theList );
 
 
   /* operations */
index 9006a49ff3648de8dd6d75b05606425115cf4700..16fd187119ec770ebe4472b311093103c7c27e2f 100755 (executable)
@@ -932,10 +932,16 @@ QString STD_Application::getDirectory( const QString& initial, const QString& ca
 void STD_Application::setDesktop( SUIT_Desktop* desk )
 {
   SUIT_Desktop* prev = desktop();
+  if ( prev == desk )
+    return;
+
+  if ( prev != 0 )
+    disconnect( prev, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
+                this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
 
   SUIT_Application::setDesktop( desk );
 
-  if ( prev != desk && desk )
+  if ( desk )
     connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
              this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
 }
index d4ec696a8feec3acdcf1daf4f2e3d4bc6411ff11..d08fcfeafe945825f8ebcb612eb40794a6af7698 100644 (file)
@@ -372,7 +372,11 @@ void SUIT_DataBrowser::onClicked( const QModelIndex& index )
 
   if ( m ) {
     SUIT_DataObject* obj = m->object( index );
-    if ( obj ) emit( clicked( obj ) );
+    if ( obj )
+    {
+      emit( clicked( obj ) );
+      emit( clicked( obj, index.column() ) );
+    }
   }
 }
 
index 1c8e8d9582750513b3870c88eff81a3912f2c549..cc153cad72e7bd9950133a2b816684e916cf5724 100644 (file)
@@ -73,6 +73,7 @@ private:
 signals:
   void             requestUpdate();
   void             clicked( SUIT_DataObject* );
+  void             clicked( SUIT_DataObject*, int );
   void             doubleClicked( SUIT_DataObject* );
 
 private slots:
index 96f91e7d7ade73f71e8cb8ee7c5786b90c31976d..f6fe060370720afd5ac919861230f562e05c493d 100755 (executable)
@@ -49,7 +49,8 @@ SUIT_DataObject::SUIT_DataObject( SUIT_DataObject* p )
 : myParent( 0 ),
   myOpen( false ),
   myCheck( false ),
-  myAutoDel( true )
+  myAutoDel( true ),
+  myVisState( Unpresentable )
 {
   setParent( p );
   signal()->emitCreated( this );
@@ -645,6 +646,28 @@ void SUIT_DataObject::setOpen( const bool on )
   myOpen = on;
 }
 
+/*!
+  \brief Returns the visibility state of the object.
+  \sa setVisibilityState()
+*/
+SUIT_DataObject::VisibilityState SUIT_DataObject::visibilityState() const
+{
+  return myVisState;
+}
+
+/*!
+  \brief Set the visibility state of the object.
+  \param on new "opened" state of the object
+  \sa isOpen()
+*/
+void SUIT_DataObject::setVisibilityState( const VisibilityState theState )
+{
+  if (myVisState == theState)
+    return;
+  myVisState = theState;
+  signal()->emitUpdated( this );
+}
+
 /*!
   \brief Check if the specified column supports custom sorting.
 
@@ -863,6 +886,16 @@ void SUIT_DataObject::Signal::emitRemoved( SUIT_DataObject* object, SUIT_DataObj
   emit( removed( object, parent ) );
 }
 
+/*!
+  \brief Emit signal about data object modification
+  \param object data object being updated
+*/
+void SUIT_DataObject::Signal::emitUpdated( SUIT_DataObject* object )
+{
+  if ( object )
+    emit updated( object );
+}
+
 /*!
   \brief Schedule data object for the late deleting.
   \param object data object to be deleted later
index 7966202486e6c90c067788bb6debc29a3e8e40be..4c82dffaebe2b999e5d4ee4de7daf6a718ee5d32 100755 (executable)
@@ -61,9 +61,18 @@ public:
   //! Column id
   enum
   { 
+    VisibilityId,     //!< visibility state column
     NameId            //!< name column
   };
 
+  //! object visibility state
+  typedef enum
+  {
+    Shown,
+    Hidden,
+    Unpresentable,
+  } VisibilityState;
+
   SUIT_DataObject( SUIT_DataObject* = 0 );
   virtual ~SUIT_DataObject();
 
@@ -119,6 +128,9 @@ public:
   virtual bool                isOpen() const;
   virtual void                setOpen( const bool );
 
+  virtual VisibilityState     visibilityState() const;
+  virtual void                setVisibilityState( const VisibilityState );
+  
   virtual void                update();
   virtual bool                customSorting( const int = NameId ) const;
   virtual bool                compare( const QVariant&, const QVariant&, const int = NameId ) const;
@@ -140,6 +152,7 @@ private:
   bool                        myCheck;
   bool                        myAutoDel;
   DataObjectList              myChildren;
+  VisibilityState             myVisState;
 
   static Signal*              mySignal;
 
@@ -160,6 +173,7 @@ private:
   void emitDestroyed( SUIT_DataObject* );
   void emitInserted( SUIT_DataObject*, SUIT_DataObject* );
   void emitRemoved( SUIT_DataObject*, SUIT_DataObject* );
+  void emitUpdated( SUIT_DataObject* );
 
   void deleteLater( SUIT_DataObject* );
 
@@ -168,6 +182,7 @@ signals:
   void destroyed( SUIT_DataObject* );
   void inserted( SUIT_DataObject*, SUIT_DataObject* );
   void removed( SUIT_DataObject*, SUIT_DataObject* );
+  void updated( SUIT_DataObject* );
 
   friend class SUIT_DataObject;
 
index 71211f3ca17996b773fe0347be35019045665c07..46c55ced279deff430af108edb618379db0240fd 100755 (executable)
@@ -469,6 +469,8 @@ SUIT_TreeModel::~SUIT_TreeModel()
                                  this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
     SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
                                  this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+    SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ),
+                                 this, SLOT( onUpdated( SUIT_DataObject* ) ) );
     delete myRoot;
   }
 
@@ -529,6 +531,27 @@ void SUIT_TreeModel::unregisterColumn( const int group_id, const QString& name )
     }
 }
 
+/*!
+  \brief Return column name by group and custom indeces
+  \param group_id - unique data object group identificator
+  \param custom_id - custom column id that should be passed into method SUIT_DataObject::data()
+  \return column name or empty string if column not found
+ */
+QString SUIT_TreeModel::columnName( const int group_id, const int custom_id )
+{
+  QString name = QString::null;
+  for( int i = 0, n = myColumns.size(); i<n; ++i )
+  {
+    
+    if (myColumns[i].myIds.contains( group_id ) &&
+        myColumns[i].myIds[ group_id ] == custom_id) {
+      name = myColumns[i].myName;
+      break;
+    }
+  }
+  return name;
+}
+
 /*!
   \brief Change column icon.
 
@@ -634,6 +657,8 @@ void SUIT_TreeModel::setRoot( SUIT_DataObject* r )
                                  this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
     SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
                                  this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+    SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ),
+                                 this, SLOT( onUpdated( SUIT_DataObject* ) ) );
     delete myRoot;
   }
 
@@ -758,6 +783,10 @@ QVariant SUIT_TreeModel::data( const QModelIndex& index, int role ) const
       // data size hint
       // NOTE! not supported currently
       break;
+    case VisibilityRole:
+      // visibility state
+      val = obj->visibilityState();
+      break;
     default:
       break;
     } // ... switch ( role ) ...
@@ -789,6 +818,14 @@ bool SUIT_TreeModel::setData( const QModelIndex& index,
           return true;
         }
         break;
+      case VisibilityRole:
+        // visibility state
+        if ( (int)obj->visibilityState() != value.toInt() ) {
+          obj->setVisibilityState( (SUIT_DataObject::VisibilityState)value.toInt() );
+          emit( dataChanged( index, index ) );
+          return true;
+        }
+        break;
       default:
         break;
       }
@@ -1007,6 +1044,8 @@ void SUIT_TreeModel::setAutoUpdate( const bool on )
                                this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
   SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
                                this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+  SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ),
+                               this, SLOT( onUpdated( SUIT_DataObject* ) ) );
   myAutoUpdate = on;
 
   if ( myAutoUpdate ) {
@@ -1014,6 +1053,8 @@ void SUIT_TreeModel::setAutoUpdate( const bool on )
                               this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
     SUIT_DataObject::connect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
                               this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+    SUIT_DataObject::connect( SIGNAL( updated( SUIT_DataObject* ) ),
+                              this, SLOT( onUpdated( SUIT_DataObject* ) ) );
 
     updateTree();
   }
@@ -1106,11 +1147,15 @@ void SUIT_TreeModel::initialize()
                                this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
   SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
                                this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+  SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ),
+                               this, SLOT( onUpdated( SUIT_DataObject* ) ) );
   if ( autoUpdate() ) {
     SUIT_DataObject::connect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ),
                               this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
     SUIT_DataObject::connect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
                               this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+    SUIT_DataObject::connect( SIGNAL( updated( SUIT_DataObject* ) ),
+                              this, SLOT( onUpdated( SUIT_DataObject* ) ) );
   }
 
   myItems.clear(); // ????? is it really necessary
@@ -1118,7 +1163,10 @@ void SUIT_TreeModel::initialize()
   if ( !myRootItem )
     myRootItem = new TreeItem( 0 );
 
+  QString VisCol = QObject::tr( "VISIBILITY_COLUMN" );
+  registerColumn( 0, VisCol, SUIT_DataObject::VisibilityId );
   registerColumn( 0, QObject::tr( "NAME_COLUMN" ), SUIT_DataObject::NameId );
+  setAppropriate( VisCol, Qtx::Hidden );
   updateTree();
 }
 
@@ -1278,6 +1326,20 @@ void SUIT_TreeModel::onRemoved( SUIT_DataObject* /*object*/, SUIT_DataObject* pa
     updateTree( parent );
 }
 
+/*!
+  \brief Called when the data object is modified (their data updated)
+  \param object data object being modified
+*/
+void SUIT_TreeModel::onUpdated( SUIT_DataObject* object )
+{
+  if ( !object )
+    return;
+  // update all columns corresponding to the given data object
+  QModelIndex firstIdx = index( object, 0 );
+  QModelIndex lastIdx  = index( object, columnCount() - 1 );
+  emit dataChanged( firstIdx, lastIdx );
+}
+
 /*!
   \class SUIT_ProxyModel
   \brief Proxy model which can be used above the SUIT_TreeMovel class
@@ -1555,6 +1617,17 @@ void SUIT_ProxyModel::unregisterColumn( const int group_id, const QString& name
     treeModel()->unregisterColumn( group_id, name );
 }
 
+/*!
+  \brief Return column name by group and custom indeces
+  \param group_id - unique data object group identificator
+  \param custom_id - custom column id that should be passed into method SUIT_DataObject::data()
+  \return column name or empty string if column not found
+ */
+QString SUIT_ProxyModel::columnName( const int group_id, const int custom_id )
+{
+  return treeModel() ? treeModel()->columnName( group_id, custom_id ) : QString::null;
+}
+
 /*!
   \brief Change column icon.
 
index adc728c2d091ca99bd0c9f02999886fc669311e9..c17eb38792c46991835301a1934002e9feff25ed 100755 (executable)
@@ -66,6 +66,7 @@ public:
 
   virtual void             registerColumn( const int group_id, const QString& name, const int custom_id ) = 0;
   virtual void             unregisterColumn( const int group_id, const QString& name ) = 0;
+  virtual QString          columnName( const int group_id, const int custom_id ) = 0;
   virtual void             setColumnIcon( const QString& name, const QPixmap& icon ) = 0;
   virtual QPixmap          columnIcon( const QString& name ) const = 0;
   virtual void             setAppropriate( const QString& name, const Qtx::Appropriate appr ) = 0;
@@ -102,6 +103,7 @@ public:
     TextColorRole,                               //!< (editor) text color    (Qt::UserRole + 1)
     HighlightRole,                               //!< highlight color        (Qt::UserRole + 2)
     HighlightedTextRole,                         //!< highlighted text color (Qt::UserRole + 3)
+    VisibilityRole,                              //!< visibility state role  (Qt::UserRole + 4)
     AppropriateRole     = Qtx::AppropriateRole   //!< appropriate flag       (Qt::UserRole + 100)
   } Role;
 
@@ -124,6 +126,7 @@ public:
   virtual int              rowCount( const QModelIndex& = QModelIndex() ) const;
   virtual void             registerColumn( const int group_id, const QString& name, const int custom_id );
   virtual void             unregisterColumn( const int group_id, const QString& name );
+  virtual QString          columnName( const int group_id, const int custom_id );
   virtual void             setColumnIcon( const QString& name, const QPixmap& icon );
   virtual QPixmap          columnIcon( const QString& name ) const;
   virtual void             setAppropriate( const QString& name, const Qtx::Appropriate appr );
@@ -165,6 +168,7 @@ private:
 private slots:
   void                   onInserted( SUIT_DataObject*, SUIT_DataObject* );
   void                   onRemoved( SUIT_DataObject*, SUIT_DataObject* );
+  void                   onUpdated( SUIT_DataObject* );
 
 private:
   typedef QMap<SUIT_DataObject*, TreeItem*> ItemMap;
@@ -215,6 +219,7 @@ public:
   virtual bool             lessThan( const QModelIndex&, const QModelIndex& ) const;
   virtual void             registerColumn( const int group_id, const QString& name, const int custom_id );
   virtual void             unregisterColumn( const int group_id, const QString& name );
+  virtual QString          columnName( const int group_id, const int custom_id );
   virtual void             setColumnIcon( const QString& name, const QPixmap& icon );
   virtual QPixmap          columnIcon( const QString& name ) const;
   virtual void             setAppropriate( const QString& name, const Qtx::Appropriate appr );
index c82f8e5ebaf1e2bb2261576bbcf726d5a3bdcfec..c2f1df2c309dc274d40849d5cdc1be1044f4b39e 100755 (executable)
@@ -101,6 +101,8 @@ salomepython_PYTHON = salome_pluginsmanager.py
 dist_salomescript_DATA = addvars2notebook.py
 
 dist_salomeres_DATA =          \
+       resources/icon_visibility_on.png \
+       resources/icon_visibility_off.png\
        resources/SalomeApp.ini \
        resources/SalomeApp.xml
 
@@ -116,7 +118,7 @@ libSalomeApp_la_CPPFLAGS = $(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES)        \
        -I$(srcdir)/../STD -I$(srcdir)/../VTKViewer -I$(srcdir)/../ObjBrowser   \
        -I$(srcdir)/../PyConsole -I$(srcdir)/../TOOLSGUI                        \
        -I$(srcdir)/../PyInterp -I$(srcdir)/../Session -I$(top_builddir)/idl    \
-       -I$(srcdir)/../Event -I$(srcdir)/../CASCatch                            \
+       -I$(srcdir)/../Event -I$(srcdir)/../CASCatch -I$(srcdir)/../Prs         \
        @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @LIBXML_INCLUDES@
 libSalomeApp_la_LDFLAGS = $(PYTHON_LIBS) $(QT_MT_LIBS) 
 libSalomeApp_la_LIBADD  = $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSalomeDSClient               \
@@ -126,4 +128,4 @@ libSalomeApp_la_LIBADD  = $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSalome
        ../SVTK/libSVTK.la ../SOCC/libSOCC.la ../PyInterp/libPyInterp.la                        \
        ../PyConsole/libPyConsole.la ../LogWindow/libLogWindow.la                               \
        ../LightApp/libLightApp.la ../TOOLSGUI/libToolsGUI.la ../Session/libSalomeSession.la    \
-       ../Event/libEvent.la ../CASCatch/libCASCatch.la $(CAS_KERNEL)
+       ../Event/libEvent.la ../CASCatch/libCASCatch.la ../Prs/libSalomePrs.la $(CAS_KERNEL)
index 3adecffd4fb3d05baa4f45aeef886bd6570d83b0..3bebeb56e44ad50dcf05227907b4b0af96e0cfe2 100644 (file)
@@ -41,6 +41,7 @@
 #include "SalomeApp_StudyPropertiesDlg.h"
 #include "SalomeApp_LoadStudiesDlg.h"
 #include "SalomeApp_NoteBookDlg.h"
+#include "SalomeApp_Module.h"
 
 #include "SalomeApp_ExitDlg.h"
 
@@ -61,6 +62,9 @@
 #include <SUIT_MessageBox.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_TreeModel.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ViewModel.h>
 
 #include <QtxTreeView.h>
 
@@ -89,8 +93,9 @@
 #include <SALOMEDSClient_ClientFactory.hxx>
 #include <Basics_Utils.hxx>
 
-#include <SALOME_ListIteratorOfListIO.hxx>
 #include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
+#include <SALOME_Prs.h>
 
 #include <ToolsGUI_CatalogGeneratorDlg.h>
 #include <ToolsGUI_RegWidget.h>
@@ -154,6 +159,8 @@ SalomeApp_Application::SalomeApp_Application()
 {
   connect( desktop(), SIGNAL( message( const QString& ) ),
            this,      SLOT( onDesktopMessage( const QString& ) ) );
+  connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+           this,      SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
   setNoteBook(0);
 }
 
@@ -339,6 +346,32 @@ void SalomeApp_Application::createActions()
 
 }
 
+/*!Set desktop:*/
+void SalomeApp_Application::setDesktop( SUIT_Desktop* desk )
+{
+  SUIT_Desktop* prev = desktop();
+  if ( prev == desk )
+    return;
+
+  if ( prev != 0 )
+  {
+    disconnect( prev, SIGNAL( message( const QString& ) ),
+                this, SLOT( onDesktopMessage( const QString& ) ) );
+    disconnect( prev, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+                this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
+  }
+
+  LightApp_Application::setDesktop( desk );
+
+  if ( desk != 0 )
+  {
+    connect( desk, SIGNAL( message( const QString& ) ),
+             this, SLOT( onDesktopMessage( const QString& ) ) );
+    connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+             this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
+  }
+}
+
 /*!
   \brief Close application.
 */
@@ -861,15 +894,20 @@ QWidget* SalomeApp_Application::createWindow( const int flag )
         EntryCol = QObject::tr( "ENTRY_COLUMN" );
 
       SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
-      treeModel->registerColumn( 0, EntryCol, SalomeApp_DataObject::EntryId );
-      treeModel->registerColumn( 0, ValueCol, SalomeApp_DataObject::ValueId );
-      treeModel->registerColumn( 0, IORCol, SalomeApp_DataObject::IORId );
-      treeModel->registerColumn( 0, RefCol, SalomeApp_DataObject::RefEntryId );
-      treeModel->setAppropriate( EntryCol, Qtx::Toggled );
-      treeModel->setAppropriate( ValueCol, Qtx::Toggled );
-      treeModel->setAppropriate( IORCol, Qtx::Toggled );
-      treeModel->setAppropriate( RefCol, Qtx::Toggled );
-
+      if (treeModel)
+      {
+        treeModel->registerColumn( 0, EntryCol, SalomeApp_DataObject::EntryId );
+        treeModel->registerColumn( 0, ValueCol, SalomeApp_DataObject::ValueId );
+        treeModel->registerColumn( 0, IORCol, SalomeApp_DataObject::IORId );
+        treeModel->registerColumn( 0, RefCol, SalomeApp_DataObject::RefEntryId );
+        treeModel->setAppropriate( EntryCol, Qtx::Toggled );
+        treeModel->setAppropriate( ValueCol, Qtx::Toggled );
+        treeModel->setAppropriate( IORCol, Qtx::Toggled );
+        treeModel->setAppropriate( RefCol, Qtx::Toggled );
+        // show visibility column
+        treeModel->setAppropriate( treeModel->columnName( 0, SalomeApp_DataObject::VisibilityId ), Qtx::Toggled );
+      }
+      
       bool autoSize      = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
       bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
       bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", true );
@@ -1266,6 +1304,13 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
 {
   // update "non-existing" (not loaded yet) data models
   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
+  SUIT_DataBrowser* ob = objectBrowser();
+  if ( !ob )
+  {
+    getWindow( WT_ObjectBrowser );
+    ob = objectBrowser();
+  }
+
   if ( study )
   {
     _PTR(Study) stdDS = study->studyDS();
@@ -1277,13 +1322,14 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
 
         if ( aComponent->ComponentDataType() == "Interface Applicative" )
           continue; // skip the magic "Interface Applicative" component
-
-        if ( !objectBrowser() )
-          getWindow( WT_ObjectBrowser );
-        const bool isAutoUpdate = objectBrowser()->autoUpdate();
-        objectBrowser()->setAutoUpdate( false );
-        SalomeApp_DataModel::synchronize( aComponent, study );
-        objectBrowser()->setAutoUpdate( isAutoUpdate );
+        
+        if (ob)
+        {
+          const bool isAutoUpdate = ob->autoUpdate();
+          ob->setAutoUpdate( false );
+          SalomeApp_DataModel::synchronize( aComponent, study );
+          ob->setAutoUpdate( isAutoUpdate );
+        }
       }
     }
   }
@@ -1543,11 +1589,12 @@ bool SalomeApp_Application::useStudy( const QString& theName )
 /*! Show/hide object browser colums according to preferences */
 void SalomeApp_Application::objectBrowserColumnsVisibility()
 {
-  if ( objectBrowser() )
+  SUIT_DataBrowser* ob = objectBrowser();
+  if ( ob )
     for ( int i = SalomeApp_DataObject::EntryId; i <= SalomeApp_DataObject::RefEntryId; i++ )
     {
       bool shown = resourceMgr()->booleanValue( "ObjectBrowser", QString( "visibility_column_id_%1" ).arg( i ), true );
-      objectBrowser()->treeView()->setColumnHidden( i, !shown );
+      ob->treeView()->setColumnHidden( i, !shown );
     }
 }
 
@@ -1652,3 +1699,56 @@ void SalomeApp_Application::onExtAction()
   if (!QMetaObject::invokeMethod(aModule, qPrintable(aDataList[1]), Q_ARG(QString, aEntry)))
     printf("Error: Can't Invoke method %s\n", qPrintable(aDataList[1]));
 }
+
+
+/*!
+ * Called when window activated
+ */
+void SalomeApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
+{
+  SUIT_DataBrowser* anOB = objectBrowser();
+  if( !anOB )
+    return;
+  SUIT_DataObject* rootObj = anOB->root();
+  if( !rootObj )
+    return;
+
+  DataObjectList listObj = rootObj->children( true );
+  
+  SALOME_View* sView = 0;
+  if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
+    if ( SUIT_ViewModel* vmod = vman->getViewModel() )
+      sView = dynamic_cast<SALOME_View*>( vmod );
+  updateVisibilityState( listObj, sView );
+}
+
+/*!
+  Update visibility state of given objects
+ */
+void SalomeApp_Application::updateVisibilityState( DataObjectList& theList,
+                                                   SALOME_View*    theView )
+{
+  if (theList.isEmpty() || !theView )
+    return;
+  // take visibale objects from current view
+  QMap<QString,int> aVisEntityMap;
+  SALOME_ListIO aListOfIO;
+  theView->GetVisible( aListOfIO );
+  SALOME_ListIteratorOfListIO anIter(aListOfIO);
+  for(; anIter.More(); anIter.Next())
+  {
+    Handle_SALOME_InteractiveObject& anObj = anIter.Value();
+    if (!anObj.IsNull() && anObj->hasEntry())
+      aVisEntityMap[ anObj->getEntry() ] = 1;
+  }
+
+  for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr )
+  {
+    LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
+    if (!obj) continue;
+    if (aVisEntityMap.contains( obj->entry() ) )
+      obj->setVisibilityState( SUIT_DataObject::Shown );
+    else if (obj->visibilityState() == SUIT_DataObject::Shown)
+      obj->setVisibilityState( SUIT_DataObject::Hidden );
+  }
+}
index f4e82a0a9b305a02226f2c748a1926a54ac44bfb..0fcf17f5e573b152cfc0dade7021490840bbe53f 100644 (file)
@@ -34,6 +34,8 @@
 #include "SalomeApp.h"
 #include <LightApp_Application.h>
 
+#include <SUIT_DataObject.h>
+
 #include <CORBA.h>
 
 //#include <SALOMEconfig.h>
@@ -45,8 +47,9 @@
 class LightApp_Preferences;
 class SalomeApp_Study;
 class SalomeApp_NoteBookDlg;
-class SUIT_DataObject;
+class SUIT_Desktop;
 
+class SALOME_View;
 class SALOME_LifeCycleCORBA;
 
 
@@ -87,6 +90,8 @@ public:
 
   virtual bool                        checkDataObject(LightApp_DataObject* theObj);
 
+  virtual void                        setDesktop( SUIT_Desktop* );
+
   static CORBA::ORB_var               orb();
   static SALOMEDSClient_StudyManager* studyMgr();
   static SALOME_NamingService*        namingService();
@@ -104,6 +109,10 @@ public:
   virtual void                        setNoteBook(SalomeApp_NoteBookDlg* theNoteBook);
   virtual SalomeApp_NoteBookDlg*      getNoteBook() const;
 
+  //! update visibility state of objects
+  void                                updateVisibilityState( DataObjectList& theList,
+                                                             SALOME_View*    theView );
+
 public slots:
   virtual void                        onLoadDoc();
   virtual bool                        onLoadDoc( const QString& );
@@ -158,6 +167,8 @@ private slots:
   void                                onOpenWith();
   void                                onExtAction();
 
+  void                                onWindowActivated( SUIT_ViewWindow* theViewWindow );
+
 private:
   void                                createExtraActions();
 
index 28ac15f0e419e8c46b31ad77f5e477d2d2746923..4aa3bcee4f05a69c8caab00f940df07e9fafb24e 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <QObject>
 #include <QVariant>
+#include <QMap>
 
 /*!
   \class SalomeApp_DataObject
@@ -153,6 +154,11 @@ QString SalomeApp_DataObject::text( const int id ) const
   return txt;
 }
 
+/*!
+  \brief Map to store data object icons
+*/
+typedef QMap<QString,QPixmap> MapKeyPixmap;
+
 /*!
   \brief Get data object icon for the specified column.
   \param id column id
@@ -160,29 +166,56 @@ QString SalomeApp_DataObject::text( const int id ) const
 */
 QPixmap SalomeApp_DataObject::icon( const int id ) const
 {
-  // we display icon only for the first (NameId ) column
+  // we display icon only for the NameId and VisibilityId columns
+  QString pixmapName = QString::null;
+  QString componentType = QString::null;
   if ( id == NameId ) {
+    componentType = componentDataType();
     _PTR(GenericAttribute) anAttr;
     if ( myObject && myObject->FindAttribute( anAttr, "AttributePixMap" ) ){
       _PTR(AttributePixMap) aPixAttr ( anAttr );
       if ( aPixAttr->HasPixMap() ) {
-        QString componentType = componentDataType();
-        QString pixmapID      = aPixAttr->GetPixMap().c_str();
+        QString pixmapID = aPixAttr->GetPixMap().c_str();
         // select a plugin within a component
         QStringList plugin_pixmap = pixmapID.split( "::", QString::KeepEmptyParts );
         if ( plugin_pixmap.size() == 2 ) {
           componentType = plugin_pixmap.front();
           pixmapID      = plugin_pixmap.back();
         }
-        QString pixmapName = QObject::tr( pixmapID.toLatin1().constData() );
-        LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() );
-        if ( aRoot && aRoot->study() ) {
-          SUIT_ResourceMgr* mgr = aRoot->study()->application()->resourceMgr();
-          return mgr->loadPixmap( componentType, pixmapName, false ); 
-        }
+        pixmapName = QObject::tr( pixmapID.toLatin1().constData() );
       }
     }
   }
+  else if ( id == VisibilityId ) {
+    componentType = "SalomeApp";
+    if (visibilityState() == Shown)
+      pixmapName = QObject::tr( "ICON_DATAOBJ_VISIBLE" );
+    else if (visibilityState() == Hidden)
+      pixmapName = QObject::tr( "ICON_DATAOBJ_INVISIBLE" );
+    else
+      return QPixmap();
+  }
+  if (pixmapName.isEmpty())
+    return LightApp_DataObject::icon( id );
+
+  // here we assume that user doesnot reaplce icons during application work
+  static QMap<QString,MapKeyPixmap> CompKeyMap;
+  if (!CompKeyMap.contains ( componentType ))
+    CompKeyMap.insert( componentType, MapKeyPixmap() );
+  MapKeyPixmap& keyPixMap = CompKeyMap[ componentType ];
+  if (!keyPixMap.contains( pixmapName ))
+  {
+    // load from resources
+    SUIT_ResourceMgr* mgr = 0;
+    LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() );
+    if ( aRoot && aRoot->study() )
+      mgr = aRoot->study()->application()->resourceMgr();
+    if (mgr)
+      keyPixMap.insert( pixmapName, mgr->loadPixmap( componentType, pixmapName, false ) );
+  }
+  if (keyPixMap.contains( pixmapName ))
+    return keyPixMap[ pixmapName ];
+
   return LightApp_DataObject::icon( id );
 }
 
index 4e35ccca7fead8d40f8516e00b531ddc2c328090..96603fba3deb099286b4f97a218c093008a1a44e 100644 (file)
 #include "SalomeApp_DataModel.h"
 #include "SalomeApp_Application.h"
 #include "SalomeApp_Study.h"
+#include "SalomeApp_DataObject.h"
 
 #include "LightApp_Selection.h"
+#include "LightApp_DataObject.h"
 
 #include "CAM_DataModel.h"
 
 #include <SALOME_InteractiveObject.hxx>
 
 #include <SUIT_Session.h>
+#include <SUIT_DataObject.h>
+#include <SUIT_DataBrowser.h>
 
 #include <QString>
 
 /*!Constructor.*/
 SalomeApp_Module::SalomeApp_Module( const QString& name )
-: LightApp_Module( name )
+  : LightApp_Module( name ),
+    myIsFirstActivate( true )
 {
+  SUIT_DataObject::connect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ),
+                            this, SLOT( onObjectInserted( SUIT_DataObject* ) ) );
 }
 
 /*!Destructor.*/
@@ -143,3 +150,130 @@ void SalomeApp_Module::restoreVisualParameters(int savePoint)
 {
 }
 
+/*!Returns module  data object module*/
+static SalomeApp_Module* objectModule( CAM_Application* theApp,
+                                       SalomeApp_DataObject* theObj )
+{
+  SalomeApp_Module* mod = 0;
+  if ( !theApp || !theObj )
+    return mod;
+
+  mod = dynamic_cast<SalomeApp_Module*>
+    (theApp->module(theApp->moduleTitle( theObj->componentDataType() )));
+
+  return mod;
+}
+
+/*! Redefined to reset internal flags valid for study instance */
+void SalomeApp_Module::studyClosed( SUIT_Study* theStudy )
+{
+  LightApp_Module::studyClosed( theStudy );
+  myIsFirstActivate = true;
+  
+  LightApp_Application* app = dynamic_cast<LightApp_Application*>(application());
+  if (!app)
+    return;
+  SUIT_DataBrowser* ob = app->objectBrowser();
+  if (ob)
+    disconnect( ob, SIGNAL( clicked( SUIT_DataObject*, int ) ),
+                this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ) );
+}
+
+/*!Activate module.*/
+bool SalomeApp_Module::activateModule( SUIT_Study* theStudy )
+{
+  bool state = LightApp_Module::activateModule( theStudy );
+  if (!myIsFirstActivate)
+    return state;
+
+  myIsFirstActivate = false;
+
+  // update visibility state of objects
+  LightApp_Application* app = dynamic_cast<LightApp_Application*>(application());
+  if (!app)
+    return state;
+  
+  SUIT_DataBrowser* ob = app->objectBrowser();
+  if (!ob)
+    return state;
+
+  // connect to click on item
+  connect( ob, SIGNAL( clicked( SUIT_DataObject*, int ) ),
+           this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ) );
+
+  SUIT_DataObject* rootObj = ob->root();
+  if( !rootObj )
+    return state;
+  DataObjectList listObj = rootObj->children( true );
+  for ( DataObjectList::iterator itr = listObj.begin(); itr != listObj.end(); ++itr )
+  {
+    SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(*itr);
+    if ( !obj || dynamic_cast<LightApp_ModuleObject*>(obj) || obj->isReference() )
+      continue;
+    
+    SalomeApp_Module* mod = objectModule( app, obj );
+    if (mod && mod == this)
+      mod->initVisibilityState( obj );
+  }
+  return state;
+}
+
+/*!
+ * \brief Virtual public slot
+ *
+ * This method is called after the object inserted into data view
+ * This is default implementation
+ */
+void SalomeApp_Module::onObjectInserted( SUIT_DataObject* theObject )
+{
+  SalomeApp_DataObject* anObj = dynamic_cast<SalomeApp_DataObject*>( theObject );
+  if (!anObj)
+    return;
+  
+  // no visibility state for module root and reference objects
+  if ( dynamic_cast<LightApp_ModuleObject*>(anObj) || anObj->isReference())
+  {
+    anObj->setVisibilityState( SUIT_DataObject::Unpresentable );
+    return;
+  }
+  
+  // update visibility state in native object module
+  SalomeApp_Module* mod = objectModule( application(), anObj );
+  if ( mod )
+    mod->initVisibilityState( anObj );
+}
+
+/*!
+ * \brief Virtual protected method
+ *
+ * This method is intended to update their visibility state
+ * This is default implementation
+ */
+void SalomeApp_Module::initVisibilityState( SUIT_DataObject* theObject )
+{
+  if ( theObject )
+    theObject->setVisibilityState( SUIT_DataObject::Unpresentable );
+}
+
+/*!
+ * \brief Virtual public slot
+ *
+ * This method is called after the object inserted into data view to update their visibility state
+ * This is default implementation
+ */
+void SalomeApp_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
+{
+  if (!isActiveModule())
+    return;
+  // change visibility of object
+  if (!theObject || theColumn != SUIT_DataObject::VisibilityId )
+    return;
+  // detect action index (from LightApp level)
+  int id = -1;
+  if ( theObject->visibilityState() == SUIT_DataObject::Shown )
+    id = myErase;
+  else if ( theObject->visibilityState() == SUIT_DataObject::Hidden )
+    id = myDisplay;
+  if ( id != -1 )
+    startOperation( id );
+}
index 9530f9da03c20e5feb36beed7efb63c9f7005d66..a062cb60d223b9334ffed63f84309da5e816ae6b 100644 (file)
@@ -36,6 +36,7 @@ class SalomeApp_Application;
 class LightApp_Selection;
 class SALOME_ListIO;
 class QString;
+class SUIT_DataObject;
 
 /*!
  * \brief Base class for all salome modules
@@ -63,9 +64,19 @@ public:
   virtual void                        restoreVisualParameters(int savePoint);
   virtual LightApp_Selection*         createSelection() const;
 
+public slots:
+  virtual bool                        activateModule( SUIT_Study* );
+  virtual void                        studyClosed( SUIT_Study* );
+  virtual void                        onObjectInserted( SUIT_DataObject* );
+  virtual void                        onObjectClicked( SUIT_DataObject*, int );
+
 protected:
   virtual CAM_DataModel*              createDataModel();
   virtual void                        extractContainers( const SALOME_ListIO&, SALOME_ListIO& ) const;
+  virtual void                        initVisibilityState( SUIT_DataObject* );
+
+ protected:
+  bool myIsFirstActivate;
 };
 
 #endif
index 0d814c5d4c1b8cbadaee146672653fc75ef43622..250fc0bb8e70e2a21561954d14af7c403b7fcf79 100644 (file)
   See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 
 -->
+<context>
+    <name>@default</name>
+    <message>
+        <source>ICON_DATAOBJ_VISIBLE</source>
+        <translation>icon_visibility_on.png</translation>
+    </message>
+    <message>
+        <source>ICON_DATAOBJ_INVISIBLE</source>
+        <translation>icon_visibility_off.png</translation>
+    </message>
+</context>
 </TS>
diff --git a/src/SalomeApp/resources/icon_visibility_off.png b/src/SalomeApp/resources/icon_visibility_off.png
new file mode 100644 (file)
index 0000000..31c505d
Binary files /dev/null and b/src/SalomeApp/resources/icon_visibility_off.png differ
diff --git a/src/SalomeApp/resources/icon_visibility_on.png b/src/SalomeApp/resources/icon_visibility_on.png
new file mode 100644 (file)
index 0000000..61ebe47
Binary files /dev/null and b/src/SalomeApp/resources/icon_visibility_on.png differ