]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
1) Show/Hide, Delete operations
authorouv <ouv@opencascade.com>
Thu, 8 Aug 2013 10:18:40 +0000 (10:18 +0000)
committerouv <ouv@opencascade.com>
Thu, 8 Aug 2013 10:18:40 +0000 (10:18 +0000)
2) Raw development
3) Fixing compilation errors in HYDROData

23 files changed:
src/HYDROData/HYDROData_Iterator.h
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROData/HYDROData_Polyline.cxx
src/HYDROData/HYDROData_Polyline.h
src/HYDROGUI/HYDROGUI_DataModel.h
src/HYDROGUI/HYDROGUI_DeleteOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_DeleteOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Displayer.cxx
src/HYDROGUI/HYDROGUI_GVSelector.cxx
src/HYDROGUI/HYDROGUI_ImportImageOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_Operation.cxx
src/HYDROGUI/HYDROGUI_Operation.h
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_ShowHideOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ShowHideOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/HYDROGUI_Tool.h
src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index b24ee4b2cbffa3f09c2e4a065639cf92d666e167..617d54d4a94ab5390315ea021e2c883997bb62b8 100644 (file)
@@ -21,7 +21,8 @@ public:
    * \param theDoc document to iterate
    * \param theKind kind of the iterated object, can be UNKNOWN: to iterate all objects
    */
-  HYDRODATA_EXPORT HYDROData_Iterator(Handle(HYDROData_Document) theDoc, ObjectKind theKind);
+  HYDRODATA_EXPORT HYDROData_Iterator(Handle(HYDROData_Document) theDoc,
+                                      ObjectKind theKind = KIND_UNKNOWN);
 
   /**
    * Iterates to the next object
index 46b4acc49e49863b96a74bb65cfa1c7778ac0a70..fe71e385569bfe734eb73ea5afe2c925ca650543 100644 (file)
@@ -2,8 +2,11 @@
 
 #include <TDataStd_Name.hxx>
 #include <TDataStd_ByteArray.hxx>
+#include <TDataStd_UAttribute.hxx>
 #include <TDF_CopyLabel.hxx>
 
+static const Standard_GUID GUID_VISIBILITY("d6a715c5-9c86-4adc-8a6c-13188f3ad94b");
+
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,MMgt_TShared)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,MMgt_TShared)
 
@@ -28,6 +31,20 @@ void HYDROData_Object::SetName(const QString& theName)
   TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData()));
 }
 
+bool HYDROData_Object::GetVisibility() const
+{
+  return myLab.IsAttribute(GUID_VISIBILITY);
+}
+
+void HYDROData_Object::SetVisibility(bool theState)
+{
+  if (theState) {
+    TDataStd_UAttribute::Set(myLab, GUID_VISIBILITY);
+  } else {
+    myLab.ForgetAttribute(GUID_VISIBILITY);
+  }
+}
+
 bool HYDROData_Object::IsRemoved() const
 {
   return !myLab.HasAttribute();
index f448d70a72f3a24c3320808061df257f84517c14..f4b30d7076e29afafa161007657ad784a910b28d 100644 (file)
@@ -43,6 +43,18 @@ public:
    */
   HYDRODATA_EXPORT void SetName(const QString& theName);
 
+  /**
+   * Returns the object visibility state.
+   * \returns visibility state
+   */
+  HYDRODATA_EXPORT bool GetVisibility() const;
+
+  /**
+   * Sets the object visibility state.
+   * \param theState visibility state
+   */
+  HYDRODATA_EXPORT void SetVisibility(bool theState);
+
   /**
    * Checks is object exists in the data structure.
    * \returns true is object is not exists in the data model
index a0ec4f2dabe4d613352fa4eeaa60a4626b3c7437..8b01e076bfbf845e6e903b2d33879876e017ef06 100755 (executable)
@@ -40,14 +40,14 @@ void HYDROData_Polyline::addPoint( const QPointF& thePoint )
   setPoints( aPointsArray );
 }
    
-bool HYDROData_Polyline::insertPoint( int theIndex, const QPointF& thePoint)
+void HYDROData_Polyline::insertPoint( int theIndex, const QPointF& thePoint)
 {
   QList<QPointF> aPointsArray = points();
   aPointsArray.insert( theIndex, thePoint );
   setPoints( aPointsArray );
 }
 
-bool HYDROData_Polyline::removePoint( int theIndex )
+void HYDROData_Polyline::removePoint( int theIndex )
 {
   QList<QPointF> aPointsArray = points();
   aPointsArray.removeAt( theIndex );
index 61a22bbcfc581ec88c072539321e8111f743ca18..641ade902f5a3b6085e374b88a35c1b19d7e1ff3 100755 (executable)
@@ -41,13 +41,13 @@ public:
    * Add point to the point list at the specified position
    * \param theIndex the index of the list the point will insert after
    */
-  HYDRODATA_EXPORT bool insertPoint( int theIndex, const QPointF& thePoint);
+  HYDRODATA_EXPORT void insertPoint( int theIndex, const QPointF& thePoint);
 
   /**
    * Remove point from polyline
    * \param theIndex the point index
    */
-  HYDRODATA_EXPORT bool removePoint( int theIndex );
+  HYDRODATA_EXPORT void removePoint( int theIndex );
 
   /**
    * Remove all points from polyline
index 9b08ac8d6deb7469ec39ce8ca3b4d0fb6b5d5c72..eb6f374f65b4757967af4953fc84425aadb55d01 100644 (file)
@@ -140,7 +140,7 @@ public:
    * Find a data object by the specified entry and kind
    */
   Handle(HYDROData_Object) objectByEntry( const QString& theEntry,
-                                          const ObjectKind theObjectKind );
+                                          const ObjectKind theObjectKind = KIND_UNKNOWN );
 
   /**
    * Check if it is possible to perform 'undo' operation
diff --git a/src/HYDROGUI/HYDROGUI_DeleteOp.cxx b/src/HYDROGUI/HYDROGUI_DeleteOp.cxx
new file mode 100644 (file)
index 0000000..8337223
--- /dev/null
@@ -0,0 +1,86 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_DeleteOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Operations.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <HYDROData_Iterator.h>
+#include <HYDROData_Object.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_DataOwner.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_SelectionMgr.h>
+
+HYDROGUI_DeleteOp::HYDROGUI_DeleteOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+  setName( tr( "DELETE" ) );
+}
+
+HYDROGUI_DeleteOp::~HYDROGUI_DeleteOp()
+{
+}
+
+void HYDROGUI_DeleteOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  HYDROGUI_DataModel* aModel = module()->getDataModel();
+
+  SUIT_SelectionMgr* aSelectionMgr = selectionMgr();
+  SUIT_DataOwnerPtrList anOwners;
+  aSelectionMgr->selected( anOwners );
+
+  if( !anOwners.isEmpty() )
+  {
+    int anAnswer = SUIT_MessageBox::question( module()->getApp()->desktop(),
+                                              tr( "DELETE_OBJECTS" ),
+                                              tr( "CONFIRM_DELETION" ),
+                                              QMessageBox::Yes | QMessageBox::No,
+                                              QMessageBox::No );
+    if( anAnswer == QMessageBox::No )
+    {
+      abort();
+      return;
+    }
+  }
+
+  foreach( SUIT_DataOwner* aSUITOwner, anOwners )
+  {
+    if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
+    {
+      Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() );
+      if( !anObject.IsNull() )
+        anObject->Remove();
+    }
+  }
+
+  module()->update( UF_Model | UF_Viewer );
+  commit();
+}
diff --git a/src/HYDROGUI/HYDROGUI_DeleteOp.h b/src/HYDROGUI/HYDROGUI_DeleteOp.h
new file mode 100644 (file)
index 0000000..ca7a538
--- /dev/null
@@ -0,0 +1,40 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_DELETEOP_H
+#define HYDROGUI_DELETEOP_H
+
+#include "HYDROGUI_Operation.h"
+
+class HYDROGUI_DeleteOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_DeleteOp( HYDROGUI_Module* theModule );
+  virtual ~HYDROGUI_DeleteOp();
+
+protected:
+  virtual void               startOperation();
+};
+
+#endif
index 66cb4c11a4897933cb77be78251815dabb8193b7..2947e10a268274091462ab55cef8b7cbed827839 100644 (file)
@@ -82,13 +82,13 @@ void HYDROGUI_Displayer::EraseAll( const int theViewerId )
   if( !aViewPort )
     return;
 
-  GraphicsView_ObjectListIterator anIter( aViewPort->getObjects() );
+  GraphicsView_ObjectListIterator anIter( HYDROGUI_Tool::GetPrsList( aViewPort ) );
   while( anIter.hasNext() )
   {
     if( GraphicsView_Object* anObject = anIter.next() )
     {
       aViewPort->removeItem( anObject );
-      //delete anObject; // ouv: to do
+      delete anObject;
     }
   }
 }
@@ -144,7 +144,7 @@ void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
   HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)myModule->dataModel();
   if( aModel ) 
   {
-    GraphicsView_ObjectList anObjectList = aViewPort->getObjects();
+    GraphicsView_ObjectList anObjectList = HYDROGUI_Tool::GetPrsList( aViewPort );
     for( int i = 1, n = theObjs.Length(); i <= n; i++ )
     {
       // the object may be null or dead
@@ -152,7 +152,7 @@ void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
       if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( anObj, anObjectList ) )
       {
         aViewPort->removeItem( aPrs );
-        //delete aPrs; // ouv: to do
+        delete aPrs;
       }
     }
   }
@@ -192,8 +192,8 @@ void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs,
 
     if( aPrs )
     {
-      bool isVisible = true; // anObj->IsVisible()
-      aPrs->setVisible( true );
+      bool anIsVisible = anObj->GetVisibility();
+      aPrs->setVisible( anIsVisible );
     }
   }
 
@@ -210,17 +210,16 @@ void HYDROGUI_Displayer::purgeObjects( const int theViewerId )
   if( !aViewPort )
     return;
 
-  GraphicsView_ObjectListIterator anIter( aViewPort->getObjects() );
+  GraphicsView_ObjectListIterator anIter( HYDROGUI_Tool::GetPrsList( aViewPort ) );
   while( anIter.hasNext() )
   {
-    GraphicsView_Object* tmp = anIter.next();
-    if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( tmp ) )
+    if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( anIter.next() ) )
     {
       Handle(HYDROData_Object) anObject = aPrs->getObject();
-      if( anObject.IsNull() )
+      if( !anObject.IsNull() && anObject->IsRemoved() )
       {
         aViewPort->removeItem( aPrs );
-        //delete aPrs; // ouv: to do
+        delete aPrs;
       }
     }
   }
index 6f0266fa9fe50e80d9d6b532ed57bc3605d6f883..95f72cdcb19af04865a0dccc2b15c0f8857730cd 100644 (file)
@@ -76,7 +76,7 @@ void HYDROGUI_GVSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
       if ( anOwner )
       {
         QString anEntry = anOwner->entry();
-        Handle(HYDROData_Object) aModelObject = aModel->objectByEntry( anEntry, KIND_IMAGE );
+        Handle(HYDROData_Object) aModelObject = aModel->objectByEntry( anEntry );
         if( !aModelObject.IsNull() )
         {
           if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( aModelObject, anObjectList ) )
index bcc97ca11b17097b51fec7808b05292d95cf46ee..21ab2da2defd8682bce888cee104266e1b7edf53 100644 (file)
@@ -116,6 +116,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags )
 
   anImageObj->SetImage( anImage );
   anImageObj->SetTrsf( aTransform );
+  anImageObj->SetVisibility( true );
 
   theUpdateFlags = UF_Model | UF_Viewer;
   return true;
index 3993bfc452439a3e169a6a5f739c53841edf5261..aaefcdfbdbb8a257bcf267efcfa739e8760d06ae 100644 (file)
 #include <GraphicsView_Viewer.h>
 
 #include <LightApp_Application.h>
+#include <LightApp_DataOwner.h>
 #include <LightApp_GVSelector.h>
 #include <LightApp_SelectionMgr.h>
 #include <LightApp_UpdateFlags.h>
 
+#include <SALOME_Event.h>
+
 #include <SUIT_Study.h>
 #include <SUIT_ViewManager.h>
 
+#include <QAction>
 #include <QApplication>
+#include <QMenu>
 
 extern "C" HYDRO_EXPORT CAM_Module* createModule()
 {
@@ -92,6 +97,8 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
   setMenuShown( true );
   setToolShown( true );
 
+  update( UF_All );
+
   updateCommandsStatus();
 
   return aRes;
@@ -117,6 +124,58 @@ void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
   theTypesList << GraphicsView_Viewer::Type();
 }
 
+void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
+                                        QMenu* theMenu,
+                                        QString& theTitle )
+{
+  HYDROGUI_DataModel* aModel = getDataModel();
+
+  LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
+  if( !aSelectionMgr )
+    return;
+
+  SUIT_DataOwnerPtrList anOwners;
+  aSelectionMgr->selected( anOwners );
+
+  bool anIsSelection = false;
+  bool anIsVisibleInSelection = false;
+  bool anIsHiddenInSelection = false;
+
+  foreach( SUIT_DataOwner* aSUITOwner, anOwners )
+  {
+    if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
+    {
+      Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() );
+      if( !anObject.IsNull() )
+      {
+        bool aVisibility = anObject->GetVisibility();
+        anIsVisibleInSelection |= aVisibility;
+        anIsHiddenInSelection |= !aVisibility;
+        anIsSelection = true;
+      }
+    }
+  }
+
+  if( anIsSelection )
+  {
+    theMenu->addAction( action( DeleteId ) );
+    theMenu->addSeparator();
+  }
+
+  if( anIsSelection )
+  {
+    if( anIsHiddenInSelection )
+      theMenu->addAction( action( ShowId ) );
+    theMenu->addAction( action( ShowOnlyId ) );
+    if( anIsVisibleInSelection )
+      theMenu->addAction( action( HideId ) );
+    theMenu->addSeparator();
+  }
+  theMenu->addAction( action( ShowAllId ) );
+  theMenu->addAction( action( HideAllId ) );
+  theMenu->addSeparator();
+}
+
 void HYDROGUI_Module::update( const int flags )
 {
   if( !isUpdateEnabled() )
@@ -193,6 +252,46 @@ CAM_DataModel* HYDROGUI_Module::createDataModel()
   return new HYDROGUI_DataModel( this );
 }
 
+void HYDROGUI_Module::customEvent( QEvent* e )
+{
+  int aType = e->type();
+  if ( aType == NewViewEvent )
+  {
+    SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
+    if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
+    {
+      if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
+      {
+        update( UF_Viewer | UF_GV_Forced );
+        aViewer->activateTransform( GraphicsView_Viewer::FitAll );
+
+        if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
+        {
+          aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
+          aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
+          aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
+        }
+      }
+    }
+  }
+}
+
+bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
+{
+  QEvent::Type aType = theEvent->type();
+  if( theObj->inherits( "GraphicsView_ViewFrame" ) )
+  {
+    if( aType == QEvent::Show )
+    {
+      SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
+      e->setData( theObj );
+      QApplication::postEvent( this, e );
+      theObj->removeEventFilter( this );
+    }
+  }
+  return LightApp_Module::eventFilter( theObj, theEvent );
+}
+
 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
 {
   LightApp_Module::onViewManagerAdded( theViewManager );
@@ -213,8 +312,15 @@ void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
   createSelector( theViewManager ); // replace the default selector
 }
 
-void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theWnd )
+void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
 {
+  if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
+  {
+    if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
+    {
+      aViewFrame->installEventFilter( this );
+    }
+  }
 }
 
 void HYDROGUI_Module::updateGV( const bool theIsInit,
index fdb8d03e148e00e4475324ce350724664fdcff65..e35a9fb3113ce68aa537016cb8fa02e3299daf21 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <LightApp_Module.h>
 
+#include <QEvent>
+
 class GraphicsView_Viewer;
 
 class SUIT_ViewWindow;
@@ -39,6 +41,8 @@ class HYDROGUI_Module : public LightApp_Module
 {
   Q_OBJECT
 
+  enum CustomEvent { NewViewEvent = QEvent::User + 100 };
+
 public:
   HYDROGUI_Module();
   virtual ~HYDROGUI_Module();
@@ -52,6 +56,8 @@ public:
   virtual void windows( QMap<int, int>& ) const;
   virtual void viewManagers( QStringList& ) const;
 
+  virtual void contextMenuPopup( const QString&, QMenu*, QString& );
+
   virtual void update( const int );
   virtual void updateCommandsStatus();
 
@@ -70,6 +76,9 @@ public slots:
 protected:
   virtual LightApp_Operation* createOperation( const int ) const;
 
+  virtual void customEvent( QEvent* );
+  virtual bool eventFilter( QObject*, QEvent* );
+
 protected slots:
   void onOperation();
 
index 35705791c9c0e6c071ac873463e8e771444858bb..b19684ab4b6fbed37f84bf2509419e76b7617a90 100644 (file)
@@ -86,8 +86,8 @@ void HYDROGUI_Operation::startOperation()
 
   if( inputPanel() )
   {
-    inputPanel()->show();
     myModule->getApp()->desktop()->addDockWidget( Qt::RightDockWidgetArea, inputPanel() );
+    inputPanel()->show();
   }
 }
 
@@ -111,6 +111,11 @@ void HYDROGUI_Operation::commitOperation()
     inputPanel()->hide();
 }
 
+HYDROGUI_InputPanel* HYDROGUI_Operation::createInputPanel() const
+{
+  return NULL;
+}
+
 bool HYDROGUI_Operation::processApply( int& theUpdateFlags )
 {
   return false;
@@ -126,7 +131,7 @@ Handle_HYDROData_Document HYDROGUI_Operation::doc() const
   return HYDROData_Document::Document( aStudyId );
 }
 
-Handle_HYDROData_Object HYDROGUI_Operation::FindObjectByName( const QString& theName, int theKind ) const
+Handle_HYDROData_Object HYDROGUI_Operation::findObjectByName( const QString& theName, int theKind ) const
 {
   HYDROData_Iterator anIt( doc(), theKind );
   for( ; anIt.More(); anIt.Next() )
index dd7bcaeea8f8c25c9f3c3b31d05b8dfdfaa40614..1f3ae1d54971e74d59f95827b18a6c63003a1665 100644 (file)
@@ -51,13 +51,13 @@ protected:
   virtual void abortOperation();
   virtual void commitOperation();
 
-  virtual HYDROGUI_InputPanel* createInputPanel() const = 0;
+  virtual HYDROGUI_InputPanel* createInputPanel() const;
 
   virtual bool processApply( int& theUpdateFlags );
   virtual void processCancel();
 
   Handle_HYDROData_Document doc() const;
-  Handle_HYDROData_Object FindObjectByName( const QString& theName, int theKind ) const;
+  Handle_HYDROData_Object findObjectByName( const QString& theName, int theKind ) const;
 
 protected slots:
   virtual void onApply();
index f17376e2114e0255d01324f989253dcdea59aa0f..b0714ecc3300a1dfa9edc5e272aefe696b53d61b 100644 (file)
 #include "HYDROGUI_Operations.h"
 
 #include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_DeleteOp.h"
 #include "HYDROGUI_ImportImageOp.h"
 #include "HYDROGUI_Module.h"
+#include "HYDROGUI_ShowHideOp.h"
 #include "HYDROGUI_TwoImagesOp.h"
 #include "HYDROGUI_UpdateFlags.h"
 
@@ -62,6 +64,14 @@ void HYDROGUI_Module::createActions()
   createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I );
   createAction( FuseId, "FUSE_IMAGES" );
   createAction( CutId, "CUT_IMAGES" );
+
+  createAction( DeleteId, "DELETE", "", Qt::Key_Delete );
+
+  createAction( ShowId, "SHOW" );
+  createAction( ShowOnlyId, "SHOW_ONLY" );
+  createAction( ShowAllId, "SHOW_ALL" );
+  createAction( HideId, "HIDE" );
+  createAction( HideAllId, "HIDE_ALL" );
 }
 
 void HYDROGUI_Module::createMenus()
@@ -196,6 +206,16 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case CutId:
     anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut );
     break;
+  case DeleteId:
+    anOp = new HYDROGUI_DeleteOp( aModule );
+    break;
+  case ShowId:
+  case ShowOnlyId:
+  case ShowAllId:
+  case HideId:
+  case HideAllId:
+    anOp = new HYDROGUI_ShowHideOp( aModule, theId );
+    break;
   }
 
   if( !anOp )
index 2200cb61226cc411f3dbd6a94660298efb3ada37..972bcfb5e9b1cfec5689bb17f4c204ac700007bb 100644 (file)
@@ -25,7 +25,7 @@
 
 enum OperationId
 {
-  FirstId,
+  FirstId = 0,
 
   UndoId,
   RedoId,
@@ -33,6 +33,14 @@ enum OperationId
   ImportImageId,
   FuseId,
   CutId,
+
+  DeleteId,
+
+  ShowId,
+  ShowOnlyId,
+  ShowAllId,
+  HideId,
+  HideAllId,
 };
 
 #endif
diff --git a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx
new file mode 100644 (file)
index 0000000..47e0a2b
--- /dev/null
@@ -0,0 +1,98 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ShowHideOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Operations.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <HYDROData_Iterator.h>
+#include <HYDROData_Object.h>
+
+#include <LightApp_DataOwner.h>
+
+#include <SUIT_SelectionMgr.h>
+
+HYDROGUI_ShowHideOp::HYDROGUI_ShowHideOp( HYDROGUI_Module* theModule, int theId )
+: HYDROGUI_Operation( theModule ),
+  myId( theId )
+{
+  QString aName;
+  switch( myId )
+  {
+    case ShowId:     aName = tr( "SHOW" ); break;
+    case ShowOnlyId: aName = tr( "SHOW_ONLY" ); break;
+    case ShowAllId:  aName = tr( "SHOW_ALL" ); break;
+    case HideId:     aName = tr( "HIDE" ); break;
+    case HideAllId:  aName = tr( "HIDE_ALL" ); break;
+    default: break;
+  }
+  setName( aName );
+}
+
+HYDROGUI_ShowHideOp::~HYDROGUI_ShowHideOp()
+{
+}
+
+void HYDROGUI_ShowHideOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  HYDROGUI_DataModel* aModel = module()->getDataModel();
+
+  // for all objects
+  if( myId == ShowOnlyId || myId == ShowAllId || myId == HideAllId )
+  {
+    bool aVisibility = myId == ShowAllId;
+    HYDROData_Iterator anIterator( doc() );
+    for( ; anIterator.More(); anIterator.Next() )
+    {
+      Handle(HYDROData_Object) anObject = anIterator.Current();
+      if( !anObject.IsNull() )
+        anObject->SetVisibility( aVisibility );
+    }
+  }
+
+  // for selected objects
+  if( myId == ShowId || myId == ShowOnlyId || myId == HideId )
+  {
+    SUIT_SelectionMgr* aSelectionMgr = selectionMgr();
+    SUIT_DataOwnerPtrList anOwners;
+    aSelectionMgr->selected( anOwners );
+
+    bool aVisibility = myId == ShowId || myId == ShowOnlyId;
+    foreach( SUIT_DataOwner* aSUITOwner, anOwners )
+    {
+      if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
+      {
+        Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() );
+        if( !anObject.IsNull() )
+          anObject->SetVisibility( aVisibility ? true : false );
+      }
+    }
+  }
+
+  module()->update( UF_Viewer );
+  commit();
+}
diff --git a/src/HYDROGUI/HYDROGUI_ShowHideOp.h b/src/HYDROGUI/HYDROGUI_ShowHideOp.h
new file mode 100644 (file)
index 0000000..dbd0d79
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_SHOWHIDEOP_H
+#define HYDROGUI_SHOWHIDEOP_H
+
+#include "HYDROGUI_Operation.h"
+
+class HYDROGUI_ShowHideOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ShowHideOp( HYDROGUI_Module* theModule, int theId );
+  virtual ~HYDROGUI_ShowHideOp();
+
+protected:
+  virtual void               startOperation();
+
+private:
+  int                        myId;
+};
+
+#endif
index edcf41b312a74c935b24d4f047505628ee60d01a..28072d7cb228537057e41d7641c6857d58d9cf79 100644 (file)
@@ -162,10 +162,31 @@ void HYDROGUI_Tool::GetPrsSubObjects( const HYDROGUI_DataModel* theModel,
 HYDROGUI_Prs* HYDROGUI_Tool::GetPresentation( const Handle(HYDROData_Object)& theObj,
                                               const GraphicsView_ObjectList& theObjects )
 {
-  GraphicsView_ObjectListIterator anIter( theObjects );
-  while( anIter.hasNext() )
-    if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( anIter.next() ) )
-      if( aPrs->getObject()->Label() == theObj->Label() )
-        return aPrs;
+  if( !theObj.IsNull() )
+  {
+    GraphicsView_ObjectListIterator anIter( theObjects );
+    while( anIter.hasNext() )
+    {
+      if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( anIter.next() ) )
+      {
+        Handle(HYDROData_Object) anObj = aPrs->getObject();
+        if( !anObj.IsNull() && anObj->Label() == theObj->Label() )
+          return aPrs;
+      }
+    }
+  }
   return NULL;
 }
+
+GraphicsView_ObjectList HYDROGUI_Tool::GetPrsList( GraphicsView_ViewPort* theViewPort )
+{
+  GraphicsView_ObjectList aList;
+  if( theViewPort )
+  {
+    GraphicsView_ObjectListIterator anIter( theViewPort->getObjects() );
+    while( anIter.hasNext() )
+      if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( anIter.next() ) )
+        aList.append( aPrs );
+  }
+  return aList;
+}
index a419734ce6fd348845c82c7ff61ecfc327298c3c..41d7fe2ffa33856ae57265336b4264b9e78cc7d3 100644 (file)
@@ -26,6 +26,7 @@
 #include <HYDROData_Object.h>
 
 #include <GraphicsView_Defs.h>
+#include <GraphicsView_ViewPort.h>
 
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_ExtendedString.hxx>
@@ -111,6 +112,13 @@ public:
    */
   static HYDROGUI_Prs*            GetPresentation( const Handle(HYDROData_Object)& theObj,
                                                    const GraphicsView_ObjectList& theObjects );
+
+  /**
+   * \brief Get list of HYDRO presentations from the specified viewport
+   * \param theViewPort viewport
+   * \return list of HYDRO presentations
+   */
+  static GraphicsView_ObjectList  GetPrsList( GraphicsView_ViewPort* theViewPort );
 };
 
 #endif
index 748da501760394934055afe2799a707af8a485bb..a91d4734465c3ef0f172cd95caa465e6901741d7 100644 (file)
@@ -70,9 +70,9 @@ bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags )
     return false;
 
   Handle(HYDROData_Image) anImage1 = Handle(HYDROData_Image)::DownCast(
-    FindObjectByName( aName1, KIND_IMAGE ) );
+    findObjectByName( aName1, KIND_IMAGE ) );
   Handle(HYDROData_Image) anImage2 = Handle(HYDROData_Image)::DownCast(
-    FindObjectByName( aName2, KIND_IMAGE ) );
+    findObjectByName( aName2, KIND_IMAGE ) );
   if( anImage1.IsNull() || anImage2.IsNull() )
     return false;
 
index 5ef51a558b86589b930245257acb56cc85c6a91a..b9ee02a2e6f3ef8579061a11877269b3c7929b17 100644 (file)
       <translation>Study could not be saved</translation>
     </message>
   </context>
+  <context>
+    <name>HYDROGUI_DeleteOp</name>
+    <message>
+      <source>DELETE</source>
+      <translation>Delete</translation>
+    </message>
+    <message>
+      <source>DELETE_OBJECTS</source>
+      <translation>Delete objects</translation>
+    </message>
+    <message>
+      <source>CONFIRM_DELETION</source>
+      <translation>Do you really want to delete the selected object(s)?</translation>
+    </message>
+  </context>
   <context>
     <name>HYDROGUI_InputPanel</name>
     <message>
       <source>DSK_CUT_IMAGES</source>
       <translation>Cut images</translation>
     </message>
+    <message>
+      <source>DSK_DELETE</source>
+      <translation>Delete</translation>
+    </message>
     <message>
       <source>DSK_FUSE_IMAGES</source>
       <translation>Fuse images</translation>
     </message>
+    <message>
+      <source>DSK_HIDE</source>
+      <translation>Hide</translation>
+    </message>
+    <message>
+      <source>DSK_HIDE_ALL</source>
+      <translation>Hide all</translation>
+    </message>
     <message>
       <source>DSK_IMPORT_IMAGE</source>
       <translation>Import image</translation>
       <source>DSK_REDO</source>
       <translation>Redo</translation>
     </message>
+    <message>
+      <source>DSK_SHOW</source>
+      <translation>Show</translation>
+    </message>
+    <message>
+      <source>DSK_SHOW_ALL</source>
+      <translation>Show all</translation>
+    </message>
+    <message>
+      <source>DSK_SHOW_ONLY</source>
+      <translation>Show only</translation>
+    </message>
     <message>
       <source>DSK_UNDO</source>
       <translation>Undo</translation>
       <translation>Cut images</translation>
     </message>
     <message>
-      <source>MEN_FUSE_IMAGES</source>
-      <translation>Fuse images</translation>
+      <source>MEN_DELETE</source>
+      <translation>Delete</translation>
     </message>
     <message>
       <source>MEN_DESK_HYDRO</source>
       <translation>HYDRO</translation>
     </message>
+    <message>
+      <source>MEN_FUSE_IMAGES</source>
+      <translation>Fuse images</translation>
+    </message>
+    <message>
+      <source>MEN_HIDE</source>
+      <translation>Hide</translation>
+    </message>
+    <message>
+      <source>MEN_HIDE_ALL</source>
+      <translation>Hide all</translation>
+    </message>
     <message>
       <source>MEN_IMPORT_IMAGE</source>
       <translation>Import image</translation>
       <source>MEN_REDO</source>
       <translation>Redo</translation>
     </message>
+    <message>
+      <source>MEN_SHOW</source>
+      <translation>Show</translation>
+    </message>
+    <message>
+      <source>MEN_SHOW_ALL</source>
+      <translation>Show all</translation>
+    </message>
+    <message>
+      <source>MEN_SHOW_ONLY</source>
+      <translation>Show only</translation>
+    </message>
     <message>
       <source>MEN_UNDO</source>
       <translation>Undo</translation>
       <source>STB_CUT_IMAGES</source>
       <translation>Cut images</translation>
     </message>
+    <message>
+      <source>STB_DELETE</source>
+      <translation>Delete</translation>
+    </message>
     <message>
       <source>STB_FUSE_IMAGES</source>
       <translation>Fuse images</translation>
     </message>
+    <message>
+      <source>STB_HIDE</source>
+      <translation>Hide</translation>
+    </message>
+    <message>
+      <source>STB_HIDE_ALL</source>
+      <translation>Hide all</translation>
+    </message>
     <message>
       <source>STB_IMPORT_IMAGE</source>
       <translation>Import image</translation>
       <source>STB_REDO</source>
       <translation>Redo</translation>
     </message>
+    <message>
+      <source>STB_SHOW</source>
+      <translation>Show</translation>
+    </message>
+    <message>
+      <source>STB_SHOW_ALL</source>
+      <translation>Show all</translation>
+    </message>
+    <message>
+      <source>STB_SHOW_ONLY</source>
+      <translation>Show only</translation>
+    </message>
     <message>
       <source>STB_UNDO</source>
       <translation>Undo</translation>
     </message>
   </context>
+  <context>
+    <name>HYDROGUI_ShowHideOp</name>
+    <message>
+      <source>SHOW</source>
+      <translation>Show</translation>
+    </message>
+    <message>
+      <source>SHOW_ALL</source>
+      <translation>Show all</translation>
+    </message>
+    <message>
+      <source>SHOW_ONLY</source>
+      <translation>Show only</translation>
+    </message>
+    <message>
+      <source>HIDE</source>
+      <translation>Hide</translation>
+    </message>
+    <message>
+      <source>HIDE_ALL</source>
+      <translation>Hide all</translation>
+    </message>
+  </context>
   <context>
     <name>HYDROGUI_TwoImagesDlg</name>
     <message>