]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
PAL9391
authorasl <asl@opencascade.com>
Tue, 27 Sep 2005 06:31:14 +0000 (06:31 +0000)
committerasl <asl@opencascade.com>
Tue, 27 Sep 2005 06:31:14 +0000 (06:31 +0000)
12 files changed:
src/CAM/CAM_Module.h
src/Qtx/QtxStdOperations.cxx
src/SPlot2d/SPlot2d_ViewModel.cxx
src/SVTK/SVTK_ViewModel.cxx
src/SalomeApp/Makefile.in
src/SalomeApp/SalomeApp_Displayer.cxx [new file with mode: 0644]
src/SalomeApp/SalomeApp_Displayer.h [new file with mode: 0644]
src/SalomeApp/SalomeApp_Module.cxx
src/SalomeApp/SalomeApp_Module.h
src/SalomeApp/SalomeApp_Selection.cxx
src/SalomeApp/SalomeApp_ShowHideOp.cxx [new file with mode: 0644]
src/SalomeApp/SalomeApp_ShowHideOp.h [new file with mode: 0644]

index feff5c1f43fc15450dfaf0a712d1e83b16ea9462..b0fcfc7cd8fd78af8299d05d1b0824ab7d70481e 100755 (executable)
@@ -41,6 +41,20 @@ public:
   virtual void           contextMenuPopup( const QString&, QPopupMenu*, QString& title ) {};
   virtual void           updateCommandsStatus() {};
 
+  /** @name Set Menu Shown*/
+  //@{
+  void                   setMenuShown( const bool );
+  void                   setMenuShown( QAction*, const bool );
+  void                   setMenuShown( const int, const bool );
+  //@}
+
+  /** @name Set Tool Shown*/
+  //@{
+  void                   setToolShown( const bool );
+  void                   setToolShown( QAction*, const bool );
+  void                   setToolShown( const int, const bool );
+  //@}
+
 public slots:
   virtual bool           activateModule( SUIT_Study* );
   virtual bool           deactivateModule( SUIT_Study* );
@@ -76,20 +90,6 @@ protected:
   int                    createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
   //@}
 
-  /** @name Set Menu Shown*/
-  //@{
-  void                   setMenuShown( const bool );
-  void                   setMenuShown( QAction*, const bool );
-  void                   setMenuShown( const int, const bool );
-  //@}
-
-  /** @name Set Tool Shown*/
-  //@{
-  void                   setToolShown( const bool );
-  void                   setToolShown( QAction*, const bool );
-  void                   setToolShown( const int, const bool );
-  //@}
-
   static QAction*        separator();
 
   /**Action ids methods.*/
index 5301bfef8fd7d7d35d97b1d19f4fa045a3a1fa29..69a7453c9b2f33fecc87f136d00d59a9a46aad12 100644 (file)
@@ -289,6 +289,8 @@ QtxLogic::QtxLogic()
 
     ListOfTypes aTypes;
     aTypes.append( QVariant::Bool );
+    aTypes.append( QVariant::Int );
+    aTypes.append( QVariant::UInt );
     addTypes( aTypes );
 }
 
@@ -308,9 +310,9 @@ bool QtxLogic::createValue( const QString& str, QtxValue& v ) const
 {
     bool ok = true;
     if( str.lower()=="true" )
-        v = true;
+        v = QtxValue( true, 0 );
     else if( str.lower()=="false" )
-        v = false;
+        v = QtxValue( false, 0 );
     else
         ok = QtxStdOperations::createValue( str, v );
 
@@ -338,6 +340,18 @@ int QtxLogic::prior( const QString& op, bool isBin ) const
             return 0;
 }
 
+bool boolean_value( const QtxValue& v )
+{
+  if( v.type()==QVariant::Bool )
+    return v.toBool();
+  else if( v.type()==QVariant::Int )
+    return v.toInt()!=0;
+  else if( v.type()==QVariant::UInt )
+    return v.toUInt()!=0;
+  else
+    return false;
+}
+
 //================================================================
 // Function : 
 // Purpose  : 
@@ -346,22 +360,24 @@ QtxParser::Error QtxLogic::calculate( const QString& op,
                                           QtxValue& v1, QtxValue& v2 ) const
 {
     QtxParser::Error err = QtxParser::OK;
+    bool val1 = boolean_value( v1 ),
+         val2 = boolean_value( v2 );
     if( v1.isValid() && v2.isValid() )
     {
         if( op=="and" || op=="&&" )
-            set( v1, v1.toBool() && v2.toBool() );
+            set( v1, val1 && val2 );
         else if( op=="or" || op=="||" )
-            set( v1, v1.toBool() || v2.toBool() );
+            set( v1, val1 || val2 );
         else if( op=="xor" )
-            set( v1, ( !v1.toBool() && v2.toBool() ) || ( v1.toBool() && !v2.toBool() ) );
+            set( v1, ( !val1 && val2 ) || ( val1 && !val2 ) );
         else if( op=="imp" )
-            set( v1, !v1.toBool() || v2.toBool() );
+            set( v1, !val1 || val2 );
         else if( op=="=" )
-            set( v1, v1.toBool()==v2.toBool() );
+            set( v1, val1==val2 );
     }
     else
         if( op=="not" || op=="!" )
-            set( v2, !v2.toBool() );
+            set( v2, !val2 );
 
     return err;
 }
index b90fe2b5cfe1df65aedd8245408ba76616102a39..9bd3937716cef4fa9a513a8fd3f97ecb58bed080 100644 (file)
@@ -223,8 +223,11 @@ void SPlot2d_Viewer::Erase( const SALOME_Prs2d* prs, const bool )
 SALOME_Prs* SPlot2d_Viewer::CreatePrs( const char* entry )
 {
   Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
-  if(aViewFrame) {
-    return new SPlot2d_Prs(aViewFrame->CreatePrs(entry));
+  if(aViewFrame)
+  {
+    Plot2d_Prs* prs = aViewFrame->CreatePrs(entry);
+    if( prs )
+      return new SPlot2d_Prs( prs );
   }
 
   return NULL;
index 17f0ac85c997da479c1b5afc43f3a4cbffeafcd8..b87a147462593b30aac771bd1f952450a5ebf817 100644 (file)
@@ -422,7 +422,11 @@ SVTK_Viewer
     if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
       if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
        if(SVTK_RenderWindow* aRW = aView->getRenderWindow())
+       {
+         aView->getRenderer()->Render();
+         aView->getRWInteractor()->unHighlightAll();
          aRW->update();
+       }
 }
 
 void 
index fb914ced07366f2f605c030260cf5a91db7ec109..b80a6844a362502bc75590818741498a35350741 100755 (executable)
@@ -44,7 +44,7 @@ EXPORT_HEADERS= SalomeApp.h \
                SalomeApp_Operation.h \
                SalomeApp_Dialog.h \
                SalomeApp_UpdateFlags.h \
-               SalomeApp_SwitchOp.cxx
+               SalomeApp_Displayer.h
 
 # .po files to transform in .qm
 PO_FILES = SalomeApp_images.po \
@@ -85,7 +85,9 @@ LIB_SRC= SalomeApp_Module.cxx \
         SalomeApp_CheckFileDlg.cxx \
         SalomeApp_Operation.cxx \
         SalomeApp_Dialog.cxx \
-        SalomeApp_SwitchOp.cxx
+        SalomeApp_SwitchOp.cxx \
+        SalomeApp_Displayer.cxx \
+        SalomeApp_ShowHideOp.cxx
 
 LIB_MOC = SalomeApp_AboutDlg.h \
           SalomeApp_Application.h \
@@ -107,7 +109,8 @@ LIB_MOC = SalomeApp_AboutDlg.h \
          SalomeApp_CheckFileDlg.h \
          SalomeApp_Operation.h \
          SalomeApp_Dialog.h \
-         SalomeApp_SwitchOp.h
+         SalomeApp_SwitchOp.h \
+         SalomeApp_ShowHideOp.h
 
 LIB_CLIENT_IDL = SALOMEDS.idl \
                 SALOME_Exception.idl \
@@ -125,7 +128,7 @@ RESOURCES_FILES = icon_about.png \
 CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) -I${KERNEL_ROOT_DIR}/include/salome
 
 LDFLAGS+=$(PYTHON_LIBS) $(QT_MT_LIBS) 
-LIBS+= -lsuit -lstd -lCAM -lObjBrowser -L$(KERNEL_ROOT_DIR)/lib/salome -lOpUtil -lSALOMELocalTrace $(CAS_KERNEL) -lSPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole -lLogWindow -lSalomeContainer -lToolsGUI
+LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lSalomePrs -L$(KERNEL_ROOT_DIR)/lib/salome -lOpUtil -lSALOMELocalTrace $(CAS_KERNEL) -lSPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole -lLogWindow -lSalomeContainer -lToolsGUI
 
 @CONCLUDE@
 
diff --git a/src/SalomeApp/SalomeApp_Displayer.cxx b/src/SalomeApp/SalomeApp_Displayer.cxx
new file mode 100644 (file)
index 0000000..ad8bbaa
--- /dev/null
@@ -0,0 +1,145 @@
+
+#include "SalomeApp_Displayer.h"
+#include "SalomeApp_Application.h"
+
+#include <SALOME_InteractiveObject.hxx>
+
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ViewModel.h>
+#include <SUIT_ViewWindow.h>
+
+#include <qstring.h>
+
+SalomeApp_Displayer::SalomeApp_Displayer()
+{
+}
+
+SalomeApp_Displayer::~SalomeApp_Displayer()
+{
+}
+
+void SalomeApp_Displayer::Display( const QString& entry, const bool updateViewer, SALOME_View* theViewFrame )
+{
+  SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+  if ( vf )
+  {
+    SALOME_Prs* prs = buildPresentation( entry, vf );
+
+    if ( prs )
+    {
+      vf->BeforeDisplay( this );
+      vf->Display( prs );
+      vf->AfterDisplay( this );
+
+      if ( updateViewer )
+        vf->Repaint();
+
+      delete prs;  // delete presentation because displayer is its owner
+    }
+  }
+}
+
+void SalomeApp_Displayer::Redisplay( const QString& entry, const bool updateViewer )
+{
+  // Remove the object permanently (<forced> == true)
+  SUIT_Session* ses = SUIT_Session::session();
+  SUIT_Application* app = ses->activeApplication();
+  if ( app )
+  {
+    SUIT_Desktop* desk = app->desktop();
+    QPtrList<SUIT_ViewWindow> wnds = desk->windows();
+    SUIT_ViewWindow* wnd;
+    for ( wnd = wnds.first(); wnd; wnd = wnds.next() )
+    {
+      SUIT_ViewManager* vman = wnd->getViewManager();
+      if( !vman )
+        continue;
+
+      SUIT_ViewModel* vmodel = vman->getViewModel();
+      if( !vmodel )
+       continue;
+       
+      SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
+      if( view && ( IsDisplayed( entry, view ) || view == GetActiveView() ) )
+      {
+       Erase( entry, true, false, view );
+       Display( entry, updateViewer, view );
+      }
+    }
+  }
+}
+
+void SalomeApp_Displayer::Erase( const QString& entry, const bool forced,
+                                const bool updateViewer, SALOME_View* theViewFrame )
+{
+  SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+
+  if ( vf ) {
+    SALOME_Prs* prs = vf->CreatePrs( entry.latin1() );
+    if ( prs ) {
+      vf->Erase( prs, forced );
+      if ( updateViewer )
+       vf->Repaint();
+      delete prs;  // delete presentation because displayer is its owner
+    }
+  }
+}
+
+void SalomeApp_Displayer::EraseAll( const bool forced, const bool updateViewer, SALOME_View* theViewFrame ) const
+{
+  SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+
+  if ( vf ) {
+    vf->EraseAll( forced );
+    if ( updateViewer )
+      vf->Repaint();
+  }
+}
+
+bool SalomeApp_Displayer::IsDisplayed( const QString& entry, SALOME_View* theViewFrame ) const
+{
+  SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+  if( vf )
+  {
+    Handle( SALOME_InteractiveObject ) temp = new SALOME_InteractiveObject();
+    temp->setEntry( entry.latin1() );
+    return vf->isVisible( temp );
+  }
+  else
+    return false;
+}
+
+void SalomeApp_Displayer::UpdateViewer() const
+{
+  SALOME_View* vf = GetActiveView();
+  if ( vf )
+    vf->Repaint();
+}
+
+SALOME_Prs* SalomeApp_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame )
+{
+  SALOME_Prs* prs = 0;
+
+  SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+
+  if ( vf )
+    prs = vf->CreatePrs( entry.latin1() );
+
+  return prs;
+}
+
+SALOME_View* SalomeApp_Displayer::GetActiveView()
+{
+  SUIT_Session* session = SUIT_Session::session();
+  if (  SUIT_Application* app = session->activeApplication() ) {
+    if ( SalomeApp_Application* sApp = dynamic_cast<SalomeApp_Application*>( app ) ) {
+      if( SUIT_ViewManager* vman = sApp->activeViewManager() ) {
+       if ( SUIT_ViewModel* vmod = vman->getViewModel() )
+         return dynamic_cast<SALOME_View*>( vmod );
+      }
+    }
+  }
+  return 0;
+}
diff --git a/src/SalomeApp/SalomeApp_Displayer.h b/src/SalomeApp/SalomeApp_Displayer.h
new file mode 100644 (file)
index 0000000..a28effd
--- /dev/null
@@ -0,0 +1,28 @@
+
+#ifndef SALOMEAPP_DISPLAYER_HEADER
+#define SALOMEAPP_DISPLAYER_HEADER
+
+#include <SALOME_Prs.h>
+
+class QString;
+
+class SalomeApp_Displayer : public SALOME_Displayer
+{
+public:
+  SalomeApp_Displayer();
+  virtual ~SalomeApp_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;
+  bool IsDisplayed( const QString&, SALOME_View* = 0 ) const;
+  void UpdateViewer() const;
+
+  static SALOME_View*  GetActiveView();
+
+protected:
+  virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
+};
+
+#endif
index f62a3eca47a2b2344841e67bbb493071626ce5f9..21da6e5091e24c99e6bca845e18fe8fc7079968f 100644 (file)
@@ -12,6 +12,7 @@
 #include "SalomeApp_UpdateFlags.h"
 #include "SalomeApp_Operation.h"
 #include "SalomeApp_SwitchOp.h"
+#include "SalomeApp_ShowHideOp.h"
 
 #include <OB_Browser.h>
 
 SalomeApp_Module::SalomeApp_Module( const QString& name )
 : CAM_Module( name ),
 myPopupMgr( 0 ),
-mySwitchOp( 0 )
+mySwitchOp( 0 ),
+myDisplay( -1 ),
+myErase( -1 ),
+myDisplayOnly( -1 )
 {
 }
 
@@ -132,7 +136,33 @@ void SalomeApp_Module::onModelClosed()
 QtxPopupMgr* SalomeApp_Module::popupMgr()
 {
   if ( !myPopupMgr )
+  {
     myPopupMgr = new QtxPopupMgr( 0, this );
+
+    QPixmap p;
+    SUIT_Desktop* d = application()->desktop();
+    
+    QAction 
+      *disp = createAction( -1, tr( "TOP_DISPLAY" ), p, tr( "MEN_DISPLAY" ), tr( "STB_DISPLAY" ),
+                           0, d, false, this, SLOT( onShowHide() ) ),
+      *erase = createAction( -1, tr( "TOP_ERASE" ), p, tr( "MEN_ERASE" ), tr( "STB_ERASE" ),
+                            0, d, false, this, SLOT( onShowHide() ) ),
+      *dispOnly = createAction( -1, tr( "TOP_DISPLAY_ONLY" ), p, tr( "MEN_DISPLAY_ONLY" ), tr( "STB_DISPLAY_ONLY" ),
+                               0, d, false, this, SLOT( onShowHide() ) );
+    myDisplay     = actionId( disp );
+    myErase       = actionId( erase );
+    myDisplayOnly = actionId( dispOnly );
+
+    myPopupMgr->insert( disp, -1, 0 ); 
+    myPopupMgr->insert( erase, -1, 0 );
+    myPopupMgr->insert( dispOnly, -1, 0 );
+    myPopupMgr->insert( separator(), -1, 0 );
+
+    QString uniform = "( count( $component ) = 1 ) and ( component != activeModule )";
+    myPopupMgr->setRule( disp, QString( "( not isVisible ) and " ) + uniform, true );
+    myPopupMgr->setRule( erase, QString( "( isVisible ) and " ) + uniform, true );
+    myPopupMgr->setRule( dispOnly, uniform, true );
+  }
   return myPopupMgr;
 }
 
@@ -305,9 +335,19 @@ void SalomeApp_Module::startOperation( const int id )
 * automatically from startOperation. You may redefine this method in concrete module to
 * create operations. 
 */
-SalomeApp_Operation* SalomeApp_Module::createOperation( const int /*id*/ ) const
+SalomeApp_Operation* SalomeApp_Module::createOperation( const int id ) const
 {
-  return 0;
+  if( id==-1 )
+    return 0;
+
+  if( id==myDisplay )
+    return new SalomeApp_ShowHideOp( SalomeApp_ShowHideOp::DISPLAY );
+  else if( id==myErase )
+    return new SalomeApp_ShowHideOp( SalomeApp_ShowHideOp::ERASE );
+  else if( id==myDisplayOnly )
+    return new SalomeApp_ShowHideOp( SalomeApp_ShowHideOp::DISPLAY_ONLY );
+  else
+    return 0;
 }
 
 /*!
@@ -345,3 +385,19 @@ void SalomeApp_Module::onOperationDestroyed()
       }
   }
 }
+
+SalomeApp_Displayer* SalomeApp_Module::displayer()
+{
+  return 0;
+}
+
+void SalomeApp_Module::onShowHide()
+{
+  if( !sender()->inherits( "QAction" ) || !popupMgr() )
+    return;
+
+  QAction* act = ( QAction* )sender();
+  int id = actionId( act );
+  if( id!=-1 )
+    startOperation( id );
+}
index 644608c5d8c0f8aa6008c8988f7eb8cba6d2bdba..1ab7f75cd8a284ff438cba71ae8287eb535da0bc 100644 (file)
@@ -30,6 +30,7 @@ class SalomeApp_Preferences;
 class SalomeApp_SelectionManager;
 class SalomeApp_Operation;
 class SalomeApp_SwitchOp;
+class SalomeApp_Displayer;
 
 /*!
  * \brief Base class for all salome modules
@@ -45,6 +46,7 @@ public:
   virtual void                        initialize( CAM_Application* );
   virtual void                        windows( QMap<int, int>& ) const;
   virtual void                        viewManagers( QStringList& ) const;
+  virtual SalomeApp_Displayer*        displayer();
 
   /*! engineIOR() should be a pure virtual method, to avoid logical errors!\n
    * Implementation in derived classes can return the following values:\n
@@ -88,6 +90,7 @@ protected slots:
   virtual void                        onModelClosed();
   virtual void                        onOperationStopped( SUIT_Operation* );
   virtual void                        onOperationDestroyed();
+  virtual void                        onShowHide();
 
 protected:
   QtxPopupMgr*                        popupMgr();
@@ -122,6 +125,7 @@ private:
   QtxPopupMgr*          myPopupMgr;
   MapOfOperation        myOperations;
   SalomeApp_SwitchOp*   mySwitchOp;
+  int                   myDisplay, myErase, myDisplayOnly;
 };
 
 #endif
index 8115b435c9da68c703c6707d13e2b3c316e166e6..14bcc8ad544f8f9e0a0e34a2b1d6f50149b21c7a 100644 (file)
@@ -1,10 +1,10 @@
 
 #include "SalomeApp_Selection.h"
-
 #include "SalomeApp_SelectionMgr.h"
 #include "SalomeApp_DataOwner.h"
 #include "SalomeApp_Study.h"
 #include "SalomeApp_Application.h"
+#include "SalomeApp_Displayer.h"
 
 #include "SUIT_Session.h"
 #include "SUIT_ViewWindow.h"
@@ -62,8 +62,27 @@ int SalomeApp_Selection::count() const
 /*!
   Gets QtxValue();
 */
-QtxValue SalomeApp_Selection::param( const int, const QString& p ) const
+QtxValue SalomeApp_Selection::param( const int ind, const QString& p ) const
 {
+  if( !( ind>=0 && ind<count() ) )
+    return QtxValue();
+
+  if( p=="isVisible" )
+  {
+    SalomeApp_Displayer d;
+    bool vis = d.IsDisplayed( myEntries[ ind ] );
+    return QtxValue( vis, 0 );
+  }
+  else if( p=="component" )
+  {
+    _PTR(SObject) obj( study()->studyDS()->FindObjectID( myEntries[ ind ] ) );
+    _PTR(SComponent) comp = obj->GetFatherComponent();
+    QString mod_name = comp->ComponentDataType().c_str();
+    //cout << "component : " << ind << " >> " << mod_name.latin1() << endl;
+    if( !mod_name.isEmpty() )
+      return mod_name;
+  }
+
   return QtxValue();
 }
 
@@ -73,6 +92,16 @@ QtxValue SalomeApp_Selection::param( const int, const QString& p ) const
 QtxValue SalomeApp_Selection::globalParam( const QString& p ) const
 {
   if      ( p == "client" )        return QtxValue( myPopupClient );
+  else if ( p == "activeModule" )
+  {
+    SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( myStudy->application() );
+    QString mod_name = app ? QString( app->activeModule()->name() ) : QString::null;
+    //cout << "activeModule : " << mod_name.latin1() << endl;
+    if( !mod_name.isEmpty() )
+      return mod_name;
+    else
+      return QtxValue();
+  }
   else if ( p == "isActiveView" )  return QtxValue( (bool)activeVW() );
   else if ( p == "activeView" )    return QtxValue( activeViewType() );
 #ifndef WNT
diff --git a/src/SalomeApp/SalomeApp_ShowHideOp.cxx b/src/SalomeApp/SalomeApp_ShowHideOp.cxx
new file mode 100644 (file)
index 0000000..d369393
--- /dev/null
@@ -0,0 +1,74 @@
+
+#include "SalomeApp_ShowHideOp.h"
+#include "SalomeApp_Application.h"
+#include "SalomeApp_SelectionMgr.h"
+#include "SalomeApp_DataOwner.h"
+#include "SalomeApp_Selection.h"
+#include "SalomeApp_Module.h"
+#include "SalomeApp_Displayer.h"
+
+SalomeApp_ShowHideOp::SalomeApp_ShowHideOp( ActionType type )
+: SalomeApp_Operation(),
+  myActionType( type )
+{
+}
+
+SalomeApp_ShowHideOp::~SalomeApp_ShowHideOp()
+{
+}
+
+void SalomeApp_ShowHideOp::startOperation()
+{
+  SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
+  if( !app )
+  {
+    abort();
+    return;
+  }
+
+  SalomeApp_SelectionMgr* mgr = app->selectionMgr();
+  SalomeApp_Selection sel; sel.init( "", mgr );
+  if( sel.count()==0 )
+  {
+    abort();
+    return;
+  }
+
+  QString mod_name = app->moduleTitle( sel.param( 0, "component" ).toString() );
+  SalomeApp_Module* m = dynamic_cast<SalomeApp_Module*>( app ? app->module( mod_name ) : 0 );
+  if( !m )
+  {
+    m = dynamic_cast<SalomeApp_Module*>( app->loadModule( mod_name ) );
+    app->addModule( m );
+    m->setMenuShown( false );
+    m->setToolShown( false );
+  }
+
+  SalomeApp_Displayer* d = m ? m->displayer(): 0;
+  if( !d )
+  {
+    abort();
+    return;
+  }
+
+  if( myActionType==DISPLAY_ONLY )
+    d->EraseAll( false, false, 0 );
+
+  SUIT_DataOwnerPtrList selected;
+  mgr->selected( selected );
+  SUIT_DataOwnerPtrList::const_iterator anIt = selected.begin(), aLast = selected.end();
+  for( ; anIt!=aLast; anIt++ )
+  {
+    SalomeApp_DataOwner* owner = dynamic_cast<SalomeApp_DataOwner*>( (*anIt).operator->() );
+    if( !owner )
+      continue;
+
+    if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
+      d->Display( owner->entry(), false, 0 );
+    else if( myActionType==ERASE )
+      d->Erase( owner->entry(), false, false, 0 );
+  }
+  d->UpdateViewer();
+  commit();
+}
+
diff --git a/src/SalomeApp/SalomeApp_ShowHideOp.h b/src/SalomeApp/SalomeApp_ShowHideOp.h
new file mode 100644 (file)
index 0000000..a3280a9
--- /dev/null
@@ -0,0 +1,26 @@
+
+#ifndef SALOMEAPP_SHOW_HIDE_OPERATION_HEADER
+#define SALOMEAPP_SHOW_HIDE_OPERATION_HEADER
+
+#include "SalomeApp_Operation.h"
+
+class SalomeApp_ShowHideOp : public SalomeApp_Operation
+{
+  Q_OBJECT
+
+public:
+    typedef enum { DISPLAY, ERASE, DISPLAY_ONLY } ActionType;
+
+public:
+  SalomeApp_ShowHideOp( ActionType );
+  ~SalomeApp_ShowHideOp();
+
+protected:
+  virtual void startOperation();
+
+private:
+  ActionType   myActionType;
+};
+
+#endif
+