]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
OCC displayer implementation.
authoradv <adv@opencascade.com>
Fri, 27 Sep 2013 10:24:47 +0000 (10:24 +0000)
committeradv <adv@opencascade.com>
Fri, 27 Sep 2013 10:24:47 +0000 (10:24 +0000)
15 files changed:
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI.vcproj
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_DeleteOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_OCCDisplayer.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Shape.h
src/HYDROGUI/HYDROGUI_ShowHideOp.cxx
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/HYDROGUI_Tool.h
src/HYDROGUI/HYDROGUI_UpdateFlags.h
src/HYDROGUI/HYDROGUI_ZoneOp.cxx

index 73ac8c894aa0e4b757cee298b5706a081440b191..380ea7922a558f75f693eff9a01693da49c29f67 100644 (file)
@@ -22,6 +22,7 @@ set(PROJECT_HEADERS
     HYDROGUI_Module.h
     HYDROGUI_ObjSelector.h
     HYDROGUI_ObserveImageOp.h
+    HYDROGUI_OCCDisplayer.h
     HYDROGUI_Operation.h
     HYDROGUI_Operations.h
     HYDROGUI_PolylineDlg.h
@@ -70,6 +71,7 @@ set(PROJECT_SOURCES
     HYDROGUI_Module.cxx
     HYDROGUI_ObjSelector.cxx
     HYDROGUI_ObserveImageOp.cxx
+    HYDROGUI_OCCDisplayer.cxx
     HYDROGUI_Operation.cxx
     HYDROGUI_Operations.cxx
     HYDROGUI_PolylineDlg.cxx
index bc0513be459e73a2b5ff38c509326fcb3ae79896..fc8098393045bd25dfa22f7967491dbc7225b514 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="windows-1251"?>
 <VisualStudioProject
        ProjectType="Visual C++"
-       Version="9,00"
+       Version="9.00"
        Name="HYDROGUI"
        ProjectGUID="{D11F0AD0-D002-4A22-A8E6-3F906379206F}"
        RootNamespace="HYDROGUI"
                                RelativePath=".\HYDROGUI_ObserveImageOp.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_OCCDisplayer.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROGUI_Operation.cxx"
                                >
                                        />
                                </FileConfiguration>
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_OCCDisplayer.h"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROGUI_Operation.h"
                                >
index 6e8aa189d65e093eacbcb5bde5dfd3dababa5e08..fd48bc169f2a73f5f80a6feb9beaa1e4c6394b30 100644 (file)
@@ -357,13 +357,16 @@ void HYDROGUI_CalculationOp::createPreview()
       {
         Region& aRegion = *anIter;
         if ( aRegion.Shape )
+        {
+          aRegion.Shape->erase( false );
           delete aRegion.Shape;
+        }
 
-        aRegion.Shape = new HYDROGUI_Shape( aCtx );
+        aRegion.Shape = new HYDROGUI_Shape( aCtx, NULL );
 
-        aRegion.Shape->setFillingColor( aRegion.FillingColor, false );
-        aRegion.Shape->setBorderColor( aRegion.BorderColor, false );
-        aRegion.Shape->setFace( aRegion.SplitData.Face(), true );
+        aRegion.Shape->setFillingColor( aRegion.FillingColor, false, false );
+        aRegion.Shape->setBorderColor( aRegion.BorderColor, false, false );
+        aRegion.Shape->setFace( aRegion.SplitData.Face(), true, false );
       }
 
       //Process the draw events for viewer
@@ -387,6 +390,7 @@ void HYDROGUI_CalculationOp::closePreview()
     Region& aRegion = *anIter;
     if ( aRegion.Shape )
     {
+      aRegion.Shape->erase( false );
       delete aRegion.Shape;
       aRegion.Shape = NULL;
     }
index 1e9b8008e62fab87a4309244c7e2650145dd9e7c..8df9ef26cf8cccff6f0b0d8acc4ddfe2ac75f260 100644 (file)
@@ -99,6 +99,6 @@ void HYDROGUI_DeleteOp::startOperation()
   }
   commitDocOperation();
 
-  module()->update( UF_Model | UF_Viewer );
+  module()->update( UF_Model | UF_Viewer | UF_OCCViewer );
   commit();
 }
index 509fc2e357c31af76299d8ea46cf3b6f89fe1794..4c2a2cc5e2202f8120d62a027cc4b18585a1c240 100644 (file)
 #include "HYDROGUI_GVSelector.h"
 #include "HYDROGUI_InputPanel.h"
 #include "HYDROGUI_ObjSelector.h"
+#include "HYDROGUI_OCCDisplayer.h"
 #include "HYDROGUI_Operations.h"
 #include "HYDROGUI_PrsImage.h"
 #include "HYDROGUI_Tool.h"
 #include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_Shape.h"
 
 #include <HYDROData_Image.h>
 
 #include <LightApp_SelectionMgr.h>
 #include <LightApp_UpdateFlags.h>
 
+#include <OCCViewer_ViewFrame.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+
 #include <SALOME_Event.h>
 
 #include <SUIT_Desktop.h>
@@ -78,6 +84,7 @@ extern "C" HYDRO_EXPORT char* getModuleVersion()
 HYDROGUI_Module::HYDROGUI_Module()
 : LightApp_Module( "HYDRO" ),
   myDisplayer( 0 ),
+  myOCCDisplayer( 0 ),
   myIsUpdateEnabled( true )
 {
 }
@@ -106,6 +113,7 @@ void HYDROGUI_Module::initialize( CAM_Application* theApp )
   setToolShown( false );
 
   myDisplayer = new HYDROGUI_Displayer( this );
+  myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
 }
 
 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
@@ -141,6 +149,7 @@ bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
   myViewManagerMap.clear();
 
   myObjectStateMap.clear();
+  myShapesMap.clear();
 
   // clear the data model's list of copying objects
   HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
@@ -165,7 +174,7 @@ void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
 
 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
 {
-  theTypesList << GraphicsView_Viewer::Type();
+  theTypesList << OCCViewer_Viewer::Type() << GraphicsView_Viewer::Type();
 }
 
 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
@@ -175,11 +184,12 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   HYDROGUI_DataModel* aModel = getDataModel();
 
   bool anIsObjectBrowser = theClient == "ObjectBrowser";
-  bool anIsGraphicsView = theClient == "GraphicsView";
-  if( !anIsObjectBrowser && !anIsGraphicsView )
+  bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
+  bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
+  if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView )
     return;
 
-  size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( this );
+  size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
 
   bool anIsSelectedDataObjects = false;
   bool anIsVisibleInSelection = false;
@@ -206,7 +216,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     {
       anIsSelectedDataObjects = true;
 
-      bool aVisibility = isObjectVisible( aViewId, anObject );
+      bool aVisibility = isObjectVisible( anActiveViewId, anObject );
       anIsVisibleInSelection |= aVisibility;
       anIsHiddenInSelection |= !aVisibility;
 
@@ -346,7 +356,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addSeparator();
   }
 
-  if( anIsObjectBrowser || anIsGraphicsView )
+  if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView )
   {
     theMenu->addAction( action( ShowAllId ) );
     theMenu->addAction( action( HideAllId ) );
@@ -372,6 +382,10 @@ void HYDROGUI_Module::update( const int flags )
     updateGV( flags & UF_GV_Init,
               flags & UF_GV_Forced );
 
+  if( ( flags & UF_OCCViewer ) )
+    updateOCCViewer( flags & UF_OCC_Init,
+                     flags & UF_OCC_Forced );
+
   if( ( flags & UF_Model ) && getDataModel() && getApp() )
   {
     getDataModel()->update( getStudyId() );
@@ -425,6 +439,11 @@ HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
   return myDisplayer;
 }
 
+HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
+{
+  return myOCCDisplayer;
+}
+
 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
 {
   if( myViewManagerMap.contains( theId ) )
@@ -438,6 +457,19 @@ GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
   return NULL;
 }
 
+OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
+{
+  if( myViewManagerMap.contains( theId ) )
+  {
+    ViewManagerInfo anInfo = myViewManagerMap[ theId ];
+    OCCViewer_ViewManager* aViewManager =
+      ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
+    if( aViewManager )
+      return aViewManager->getOCCViewer();
+  }
+  return NULL;
+}
+
 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
 {
   ViewManagerMapIterator anIter( myViewManagerMap );
@@ -474,7 +506,7 @@ void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
 }
 
 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
-                                       const Handle(HYDROData_Object)& theObject )
+                                       const Handle(HYDROData_Object)& theObject ) const
 {
   if( theObject.IsNull() )
     return false;
@@ -505,6 +537,77 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId,
   }
 }
 
+HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int                       theViewId,
+                                                 const Handle(HYDROData_Object)& theObject ) const
+{
+  HYDROGUI_Shape* aResShape = NULL;
+  if( theObject.IsNull() )
+    return aResShape;
+
+  if ( myShapesMap.contains( theViewId ) )
+  {
+    const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
+    foreach ( HYDROGUI_Shape* aShape, aViewShapes )
+    {
+      if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
+        continue;
+
+      aResShape = aShape;
+      break;
+    }
+  }
+
+  return aResShape;
+}
+
+void HYDROGUI_Module::setObjectShape( const int                       theViewId,
+                                      const Handle(HYDROData_Object)& theObject,
+                                      HYDROGUI_Shape*                 theShape )
+{
+  if( theObject.IsNull() )
+    return;
+
+  ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
+  aViewShapes.append( theShape );
+}
+
+void HYDROGUI_Module::removeObjectShape( const int                       theViewId,
+                                         const Handle(HYDROData_Object)& theObject )
+{
+  if ( !myShapesMap.contains( theViewId ) )
+    return;
+
+  ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
+  for ( int i = 0; i < aViewShapes.length(); )
+  {
+    HYDROGUI_Shape* aShape = aViewShapes.at( i );
+    if ( aShape && IsEqual( aShape->getObject(), theObject ) )
+    {
+      delete aShape;
+      aViewShapes.removeAt( i );
+      continue;
+    }
+
+    ++i;
+  }
+}
+
+void HYDROGUI_Module::removeViewShapes( const int theViewId )
+{
+  if ( !myShapesMap.contains( theViewId ) )
+    return;
+
+  const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
+  for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
+  {
+    HYDROGUI_Shape* aShape = aViewShapes.at( i );
+    if ( aShape )
+      delete aShape;
+  }
+
+  myShapesMap.remove( theViewId );
+}
+
 CAM_DataModel* HYDROGUI_Module::createDataModel()
 {
   return new HYDROGUI_DataModel( this );
@@ -568,6 +671,11 @@ void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
     connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
              this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
   }
+  else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
+  {
+    connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
+             this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
+  }
 
   ViewManagerInfo anInfo( theViewManager, VMR_General );
   myViewManagerMap.insert( ViewManagerId++, anInfo );
@@ -581,7 +689,18 @@ void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
 
   int anId = getViewManagerId( theViewManager );
   if( anId != -1 )
+  {
+    OCCViewer_ViewManager* anOCCViewManager =
+      ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
+    if ( anOCCViewManager )
+    {
+      OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
+      if ( anOCCViewer )
+        removeViewShapes( (size_t)anOCCViewer );
+    }
+
     myViewManagerMap.remove( anId );
+  }
 }
 
 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
@@ -596,7 +715,13 @@ void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
 
       connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
                this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
-      return;
+    }
+  }
+  else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
+  {
+    if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
+    {
+      aViewFrame->onTopView();
     }
   }
 }
@@ -657,8 +782,13 @@ void HYDROGUI_Module::updateGV( const bool theIsInit,
   // currently, all views are updated
   ViewManagerMapIterator anIter( myViewManagerMap );
   while( anIter.hasNext() )
-  {
-    int anId = anIter.next().key();
+  { 
+    GraphicsView_ViewManager* aViewManager =
+      dynamic_cast<GraphicsView_ViewManager*>( anIter.next().value().first );
+    if ( !aViewManager )
+      continue;
+
+    int anId = anIter.key();
     aViewManagerIdList.append( anId );
   }
 
@@ -667,6 +797,33 @@ void HYDROGUI_Module::updateGV( const bool theIsInit,
     getDisplayer()->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
 }
 
+void HYDROGUI_Module::updateOCCViewer( const bool theIsInit,
+                                       const bool theIsForced )
+{
+  HYDROGUI_OCCDisplayer* anOCCDisplayer = getOCCDisplayer();
+  if( !anOCCDisplayer )
+    return;
+
+  QList<int> aViewManagerIdList;
+
+  // currently, all views are updated
+  ViewManagerMapIterator anIter( myViewManagerMap );
+  while( anIter.hasNext() )
+  { 
+    OCCViewer_ViewManager* aViewManager =
+      ::qobject_cast<OCCViewer_ViewManager*>( anIter.next().value().first );
+    if ( !aViewManager )
+      continue;
+
+    int anId = anIter.key();
+    aViewManagerIdList.append( anId );
+  }
+
+  QListIterator<int> anIdIter( aViewManagerIdList );
+  while( anIdIter.hasNext() )
+    anOCCDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
+}
+
 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
 {
   if( !theViewManager )
index 32e1162e3f05fcd2bb44f6c23bc3b0586a287acd..0f0ac14848c39340d0518ffb34150629ccb72cc2 100644 (file)
@@ -37,6 +37,10 @@ class SUIT_ViewWindow;
 
 class HYDROGUI_DataModel;
 class HYDROGUI_Displayer;
+class HYDROGUI_OCCDisplayer;
+class HYDROGUI_Shape;
+
+class OCCViewer_Viewer;
 
 /**\class HYDROGUI_Module
  *\brief The class representing the HYDROGUI module
@@ -67,6 +71,9 @@ public:
   typedef QMap< QString, ObjectState > Name2ObjectStateMap;
   typedef QMap< int, Name2ObjectStateMap > ViewId2Name2ObjectStateMap;
 
+  typedef QList<HYDROGUI_Shape*> ListOfShapes;
+  typedef QMap<int,ListOfShapes> ViewId2ListOfShapes;
+
 public:
   HYDROGUI_Module();
   virtual ~HYDROGUI_Module();
@@ -86,8 +93,10 @@ public:
 
   HYDROGUI_DataModel*             getDataModel() const;
   HYDROGUI_Displayer*             getDisplayer() const;
+  HYDROGUI_OCCDisplayer*          getOCCDisplayer() const;
 
   GraphicsView_Viewer*            getViewer( const int theId ) const;
+  OCCViewer_Viewer*               getOCCViewer( const int theId ) const;
 
   int                             getViewManagerId( SUIT_ViewManager* theViewManager );
   ViewManagerRole                 getViewManagerRole( SUIT_ViewManager* theViewManager );
@@ -95,11 +104,20 @@ public:
                                                       const ViewManagerRole theRole );
 
   bool                            isObjectVisible( const int theViewId,
-                                                   const Handle(HYDROData_Object)& theObject );
+                                                   const Handle(HYDROData_Object)& theObject ) const;
   void                            setObjectVisible( const int theViewId,
                                                     const Handle(HYDROData_Object)& theObject,
                                                     const bool theState );
 
+  HYDROGUI_Shape*                 getObjectShape( const int                       theViewId,
+                                                  const Handle(HYDROData_Object)& theObject ) const;
+  void                            setObjectShape( const int                       theViewId,
+                                                  const Handle(HYDROData_Object)& theObject,
+                                                  HYDROGUI_Shape*                 theShape );
+  void                            removeViewShapes( const int                       theViewId );
+  void                            removeObjectShape( const int                       theViewId,
+                                                     const Handle(HYDROData_Object)& theObject );
+
 protected:
   CAM_DataModel*                  createDataModel();
 
@@ -129,6 +147,9 @@ private:
   void                            updateGV( const bool theIsInit = false, 
                                             const bool theIsForced = false );
 
+  void                            updateOCCViewer( const bool theIsInit = false, 
+                                                   const bool theIsForced = false );
+
   void                            createSelector( SUIT_ViewManager* viewMgr );
 
   bool                            setUpdateEnabled( const bool theState );
@@ -154,10 +175,13 @@ private:
 
 private:
   HYDROGUI_Displayer*             myDisplayer;
+  HYDROGUI_OCCDisplayer*          myOCCDisplayer;
 
   ViewManagerMap                  myViewManagerMap;
   ViewId2Name2ObjectStateMap      myObjectStateMap;
 
+  ViewId2ListOfShapes             myShapesMap;
+
   bool                            myIsUpdateEnabled;
 };
 
diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
new file mode 100644 (file)
index 0000000..d20db24
--- /dev/null
@@ -0,0 +1,235 @@
+// 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_OCCDisplayer.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_Shape.h"
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_ListOfInteractive.hxx>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewWindow.h>
+
+#include <QApplication>
+
+HYDROGUI_OCCDisplayer::HYDROGUI_OCCDisplayer( HYDROGUI_Module* theModule )
+: myModule( theModule )
+{
+}
+
+HYDROGUI_OCCDisplayer::~HYDROGUI_OCCDisplayer()
+{
+}
+
+void HYDROGUI_OCCDisplayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
+                                         const int                          theViewerId )
+{
+  OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId );
+  if( !aViewer )
+    return;
+
+  for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
+  {
+    Handle(HYDROData_Object) anObj = theObjs.Value( i );
+    if( anObj.IsNull() )
+      continue;
+
+    HYDROGUI_Shape* anObjShape = myModule->getObjectShape( (size_t)aViewer, anObj );
+    if ( !anObjShape )
+      continue;
+    
+    anObjShape->setIsToUpdate( true );
+  }
+}
+
+void HYDROGUI_OCCDisplayer::UpdateAll( const int  theViewerId,
+                                       const bool theIsInit,
+                                       const bool theIsForced )
+{
+  if ( theIsInit )
+    EraseAll( theViewerId );
+
+  DisplayAll( theViewerId, theIsForced );
+}
+
+void HYDROGUI_OCCDisplayer::EraseAll( const int theViewerId )
+{
+  OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId );
+  if( !aViewer )
+    return;
+
+  myModule->removeViewShapes( (size_t)aViewer );
+}
+
+void HYDROGUI_OCCDisplayer::DisplayAll( const int  theViewerId,
+                                        const bool theIsForced )
+{
+  HYDROData_SequenceOfObjects aSeq;
+  HYDROGUI_Tool::GetPrsSubObjects( myModule, aSeq );
+  Update( aSeq, theViewerId, theIsForced );
+}
+
+void HYDROGUI_OCCDisplayer::Update( const HYDROData_SequenceOfObjects& theObjs,
+                                    const int                          theViewerId,
+                                    const bool                         theIsForced )
+{
+  // First of all, kill all bad presentations
+  purgeObjects( theViewerId );
+
+  // Now dig in the data model
+  HYDROData_SequenceOfObjects anObjectsToErase, anObjectsToDisplay;
+
+  for( int i = 1, n = theObjs.Length(); i <= n; i++ )
+  {
+    const Handle(HYDROData_Object)& anObj = theObjs.Value( i );
+    if( anObj.IsNull() )
+      anObjectsToErase.Append( anObj );
+    else
+      anObjectsToDisplay.Append( anObj );
+  }
+
+  if( anObjectsToErase.Length() )
+    Erase( anObjectsToErase, theViewerId );
+  if( anObjectsToDisplay.Length() )
+    Display( anObjectsToDisplay, theViewerId, theIsForced );
+}
+
+void HYDROGUI_OCCDisplayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
+                                   const int                          theViewerId )
+{
+  OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId );
+  if( !aViewer )
+    return;
+
+  for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
+  {
+    Handle(HYDROData_Object) anObj = theObjs.Value( i );
+    if( anObj.IsNull() )
+      continue;
+
+    myModule->removeObjectShape( (size_t)aViewer, anObj );
+  }
+}
+
+HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int                             theViewerId,
+                                                    const Handle(AIS_InteractiveContext)& theContext,
+                                                    const Handle(HYDROData_Object)&       theObject )
+{
+  HYDROGUI_Shape* aResShape = NULL;
+  if ( theContext.IsNull() || theObject.IsNull() )
+    return aResShape;
+
+  ObjectKind anObjectKind = theObject->GetKind();
+  if ( anObjectKind != KIND_POLYLINE &&
+       anObjectKind != KIND_ZONE )
+    return aResShape;
+
+  aResShape = new HYDROGUI_Shape( theContext, theObject );
+  myModule->setObjectShape( theViewerId, theObject, aResShape );
+
+  return aResShape;
+}
+
+void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs,
+                                     const int                          theViewerId,
+                                     const bool                         theIsForced )
+{
+  OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId );
+  if( !aViewer )
+    return;
+
+  Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+  if( aCtx.IsNull() )
+    return;
+
+  for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
+  {
+    Handle(HYDROData_Object) anObj = theObjs.Value( i );
+    if ( anObj.IsNull() || anObj->IsRemoved() )
+      continue;
+
+    HYDROGUI_Shape* anObjShape = myModule->getObjectShape( (size_t)aViewer, anObj );
+
+    if ( !anObjShape || anObjShape->getIsToUpdate() || theIsForced )
+    {
+      if ( !anObjShape )
+        anObjShape = createShape( (size_t)aViewer, aCtx, anObj );
+
+      if ( anObjShape )
+        anObjShape->update( false );
+    }
+
+    if ( anObjShape )
+    {
+      bool anIsVisible = myModule->isObjectVisible( (size_t)aViewer, anObj );
+      anObjShape->setVisible( anIsVisible, false );
+    }
+  }
+
+  OCCViewer_ViewManager* aViewManager
+    = ::qobject_cast<OCCViewer_ViewManager*>( aViewer->getViewManager() );
+  if ( aViewManager )
+  {
+    OCCViewer_ViewWindow* aViewWindow = 
+      ::qobject_cast<OCCViewer_ViewWindow*>( aViewManager->getActiveView() );
+    if ( aViewWindow )
+    {
+      QApplication::processEvents(); //Process the draw events for viewer
+      aViewWindow->onFitAll();
+    }
+  }
+}
+
+void HYDROGUI_OCCDisplayer::purgeObjects( const int theViewerId )
+{
+  OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId );
+  if( !aViewer )
+    return;
+
+  Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+  if( aCtx.IsNull() )
+    return;
+
+  AIS_ListOfInteractive aDisplayedObjects;
+  aCtx->DisplayedObjects( aDisplayedObjects );
+
+  AIS_ListIteratorOfListOfInteractive aListIter( aDisplayedObjects );
+  for ( ; aListIter.More(); aListIter.Next() )
+  {
+    Handle(AIS_InteractiveObject) aPrsObj = aListIter.Value();
+    if ( aPrsObj.IsNull() )
+      continue;
+
+    Handle(HYDROData_Object) anOwnerObj = 
+      Handle(HYDROData_Object)::DownCast( aPrsObj->GetOwner() );
+    if ( !anOwnerObj.IsNull() && anOwnerObj->IsRemoved() )
+      myModule->removeObjectShape( (size_t)aViewer, anOwnerObj );
+  }
+}
+
+
diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.h b/src/HYDROGUI/HYDROGUI_OCCDisplayer.h
new file mode 100644 (file)
index 0000000..f4c013b
--- /dev/null
@@ -0,0 +1,136 @@
+// 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_OCCDISPLAYER_H
+#define HYDROGUI_OCCDISPLAYER_H
+
+#include <HYDROData_Object.h>
+
+class HYDROGUI_Module;
+class HYDROGUI_Shape;
+class Handle(AIS_InteractiveContext);
+
+/**
+ * \class HYDROGUI_OCCDisplayer
+ * \brief Class intended to create, display and update the presentations on OCC viewer.
+ */
+class HYDROGUI_OCCDisplayer
+{
+public:
+  /**
+   * \brief Constructor.
+   * \param theModule module object
+   */
+  HYDROGUI_OCCDisplayer( HYDROGUI_Module* theModule );
+
+  /**
+   * \brief Destructor.
+   */
+  virtual ~HYDROGUI_OCCDisplayer();
+
+public:
+  /**
+   * \brief Force the specified objects to be updated.
+   * \param theObjs sequence of objects to update
+   * \param theViewerId viewer identifier
+   */
+  void                            SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
+                                               const int theViewerId );
+
+  /**
+   * \brief Update all objects in the viewer.
+   * \param theViewerId viewer identifier
+   * \param theIsInit flag used for initial update
+   * \param theIsForced flag used to update all objects, including the unchanged ones
+   */
+  void                            UpdateAll( const int theViewerId,
+                                             const bool theIsInit,
+                                             const bool theIsForced );
+
+protected:
+  /**
+   * \brief Erase all viewer objects.
+   * \param theViewerId viewer identifier
+   */
+  void                            EraseAll( const int theViewerId );
+
+  /**
+   * \brief Update and display all objects in the viewer.
+   * \param theViewerId viewer identifier
+   * \param theIsForced flag used to update all objects, including the unchanged ones
+   */
+  void                            DisplayAll( const int theViewerId,
+                                              const bool theIsForced );
+
+  /**
+   * \brief Update the specified viewer objects.
+   * \param theObjs sequence of objects to update
+   * \param theViewerId viewer identifier
+   * \param theIsForced flag used to update all objects, including the unchanged ones
+   */
+  void                            Update( const HYDROData_SequenceOfObjects& theObjs,
+                                          const int theViewerId,
+                                          const bool theIsForced );
+
+  /**
+   * \brief Erase the specified viewer objects.
+   * \param theObjs sequence of objects to erase
+   * \param theViewerId viewer identifier
+   */
+  void                            Erase( const HYDROData_SequenceOfObjects& theObjs,
+                                         const int theViewerId );
+
+  /**
+   * \brief Display the specified viewer objects.
+   * \param theObjs sequence of objects to display
+   * \param theViewerId viewer identifier
+   * \param theIsForced flag used to update all objects, including the unchanged ones
+   */
+  void                            Display( const HYDROData_SequenceOfObjects& theObjs,
+                                           const int theViewerId,
+                                           const bool theIsForced );
+
+private:
+  /**
+   * \brief Purge all invalid objects in the viewer.
+   * \param theViewerId viewer identifier
+   */
+  void                            purgeObjects( const int theViewerId );
+
+  /**
+   * \brief Creates new OCC shape.
+   * \param theViewerId viewer identifier
+   * \param theContext context of OCC viwer
+   * \param theObject data model object
+   * \return pointer to new created shape
+   */
+  HYDROGUI_Shape*                 createShape( const int                             theViewerId,
+                                               const Handle(AIS_InteractiveContext)& theContext,
+                                               const Handle(HYDROData_Object)&       theObject );
+
+private:
+  HYDROGUI_Module*                myModule;
+
+};
+
+#endif
+
index b973cefd80d9a8f9d7f5d262653f75ff9810f3a0..33ceeda2c3519d649e220421644ddfe3e5a1f4c2 100644 (file)
@@ -33,6 +33,9 @@
 #include <Graphic3d_AspectFillArea3d.hxx>
 #include <Graphic3d_MaterialAspect.hxx>
 
+#include <HYDROData_Domain.h>
+#include <HYDROData_Polyline.h>
+
 #include <TopoDS_Wire.hxx>
 #include <TopoDS_Face.hxx>
 
 
 #include <QColor>
 
-HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext )
+HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext,
+                                const Handle(HYDROData_Object)&       theObject )
 : myContext( theContext ),
+  myObject( theObject ),
   myIsHighlight( false ),
-  myFillingColor( Qt::green ),
+  myFillingColor( Qt::transparent ),
   myBorderColor( Qt::black ),
-  myHighlightColor( Qt::white )
+  myHighlightColor( Qt::white ),
+  myIsToUpdate( false ),
+  myIsVisible( true )
 {
 }
 
@@ -63,7 +70,7 @@ HYDROGUI_Shape::~HYDROGUI_Shape()
 
 void HYDROGUI_Shape::display( const bool theIsUpdateViewer )
 {
-  if ( !myContext || myShape.IsNull() )
+  if ( myContext.IsNull() || myShape.IsNull() )
     return;
 
   myContext->Display( myShape, theIsUpdateViewer );
@@ -71,12 +78,69 @@ void HYDROGUI_Shape::display( const bool theIsUpdateViewer )
 
 void HYDROGUI_Shape::erase( const bool theIsUpdateViewer )
 {
-  if ( !myContext || myShape.IsNull() )
+  if ( myContext.IsNull() || myShape.IsNull() )
     return;
 
   myContext->Erase( myShape, theIsUpdateViewer );
 }
 
+void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
+{
+  setIsToUpdate( false );
+
+  if ( myContext.IsNull() )
+    return;
+
+  // Try to retrieve information from object
+  if ( !myObject.IsNull() )
+  {
+    if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Domain) ) )
+    {
+      Handle(HYDROData_Domain) aDomainObj =
+        Handle(HYDROData_Domain)::DownCast( myObject );
+
+      QColor aFillingColor = aDomainObj->GetFillingColor();
+      QColor aBorderColor = aDomainObj->GetBorderColor();
+      TopoDS_Face aDomainFace = aDomainObj->Face();
+
+      setFillingColor( aFillingColor, false, false );
+      setBorderColor( aBorderColor, false, false );
+      setFace( aDomainFace, false, false );
+    }
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline) ) )
+    {
+      Handle(HYDROData_Polyline) aPolyline =
+        Handle(HYDROData_Polyline)::DownCast( myObject );
+
+      TopoDS_Wire aPolylineWire = aPolyline->Wire();
+
+      setWire( aPolylineWire, false, false );
+    }
+  }
+
+  if ( myShape.IsNull() )
+    return;
+
+  myContext->Display( myShape, theIsUpdateViewer );
+}
+
+void HYDROGUI_Shape::setVisible( const bool theState,
+                                 const bool theIsUpdateViewer )
+{
+  if ( myIsVisible == theState )
+    return;
+
+  myIsVisible = theState;
+
+  if ( myShape.IsNull() )
+    return;
+
+  if ( myIsVisible )
+    myContext->Display( myShape, theIsUpdateViewer );
+  else
+    myContext->Erase( myShape, theIsUpdateViewer );
+}
+
 void HYDROGUI_Shape::highlight( bool theIsHighlight )
 {
   if ( myIsHighlight == theIsHighlight )
@@ -84,7 +148,7 @@ void HYDROGUI_Shape::highlight( bool theIsHighlight )
 
   myIsHighlight = theIsHighlight;
 
-  if ( !myContext || myShape.IsNull() )
+  if ( myContext.IsNull() || myShape.IsNull() )
     return;
 
   colorShapeBorder( getActiveColor() );
@@ -97,30 +161,33 @@ bool HYDROGUI_Shape::isHighlighted() const
 }
 
 void HYDROGUI_Shape::setWire( const TopoDS_Wire& theWire,
-                              const bool         theToDisplay )
+                              const bool         theToDisplay,
+                              const bool         theIsUpdateViewer )
 {
   BRepBuilderAPI_MakeFace aFaceBuilder( theWire, Standard_True );
   aFaceBuilder.Build();
   if( aFaceBuilder.IsDone() )
   {
     TopoDS_Face aFace = aFaceBuilder.Face();
-    setFace( aFace, theToDisplay );
+    setFace( aFace, theToDisplay, theIsUpdateViewer );
   }
 }
 
 void HYDROGUI_Shape::setFace( const TopoDS_Face& theFace,
-                              const bool         theToDisplay )
+                              const bool         theToDisplay,
+                              const bool         theIsUpdateViewer )
 {
   myFace = theFace;
   buildShape();
-  updateShape( theToDisplay );
+  updateShape( theToDisplay, theIsUpdateViewer );
 }
 
 void HYDROGUI_Shape::setFillingColor( const QColor& theColor,
-                                      const bool    theToDisplay )
+                                      const bool    theToDisplay,
+                                      const bool    theIsUpdateViewer )
 {
   myFillingColor = theColor;
-  updateShape( theToDisplay );
+  updateShape( theToDisplay, theIsUpdateViewer );
 }
 
 QColor HYDROGUI_Shape::getFillingColor() const
@@ -129,10 +196,11 @@ QColor HYDROGUI_Shape::getFillingColor() const
 }
 
 void HYDROGUI_Shape::setBorderColor( const QColor& theColor,
-                                     const bool    theToDisplay )
+                                     const bool    theToDisplay,
+                                     const bool    theIsUpdateViewer )
 {
   myBorderColor = theColor;
-  updateShape( theToDisplay );
+  updateShape( theToDisplay, theIsUpdateViewer );
 }
 
 QColor HYDROGUI_Shape::getBorderColor() const
@@ -160,6 +228,9 @@ void HYDROGUI_Shape::buildShape()
 
   myShape = new AIS_Shape( myFace );
 
+  if ( !myObject.IsNull() )
+    myShape->SetOwner( myObject );
+
   myShape->SetTransparency( 0 );
   myShape->SetDisplayMode( AIS_Shaded );
 
@@ -188,7 +259,8 @@ void HYDROGUI_Shape::buildShape()
   }
 }
 
-void HYDROGUI_Shape::updateShape( const bool theIsForce )
+void HYDROGUI_Shape::updateShape( const bool theToDisplay,
+                                  const bool theIsUpdateViewer )
 {
   if ( myShape.IsNull() )
     return;
@@ -213,10 +285,10 @@ void HYDROGUI_Shape::updateShape( const bool theIsForce )
     colorShapeBorder( getActiveColor() );
   }
 
-  if ( !theIsForce || !myContext )
+  if ( !theToDisplay || myContext.IsNull() )
     return;
   
-  myContext->Display( myShape, theIsForce );
+  myContext->Display( myShape, theIsUpdateViewer );
 }
 
 QColor HYDROGUI_Shape::getActiveColor() const
index 885e23d04896953cc44768e7e6ec6527c9694b17..6572c80d5674fcc3798e086aa7941efb2cf9d5e2 100644 (file)
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_Shape.hxx>
 
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Wire.hxx>
+#include <HYDROData_Object.h>
 
 #include <QColor>
 
-class BRepBuilderAPI_MakeFace;
-class BRepBuilderAPI_MakeWire;
-class gp_Pnt;
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
 
 class HYDROGUI_Shape
 {
 public:
-  HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext );
+  HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext,
+                  const Handle(HYDROData_Object)&       theObject );
   ~HYDROGUI_Shape();
 
 public:
@@ -48,18 +47,33 @@ public:
   virtual void               highlight( bool theIsHighlight );
   virtual bool               isHighlighted() const;
 
+  Handle(HYDROData_Object)   getObject() const { return myObject; }
+
+  virtual void               update( const bool theIsUpdateViewer = true );
+
+  virtual bool               getIsToUpdate() const { return myIsToUpdate; }
+  virtual void               setIsToUpdate( bool theState ) { myIsToUpdate = theState; }
+
+  virtual bool               isVisible() const { return myIsVisible; }
+  virtual void               setVisible( const bool theState,
+                                         const bool theIsUpdateViewer = true );
+
   virtual void               setWire( const TopoDS_Wire& theWire,
-                                      const bool         theToDisplay = true );
+                                      const bool         theToDisplay = true,
+                                      const bool         theIsUpdateViewer = true );
 
   virtual void               setFace( const TopoDS_Face& theFace,
-                                      const bool         theToDisplay = true );
+                                      const bool         theToDisplay = true,
+                                      const bool         theIsUpdateViewer = true );
 
   virtual void               setFillingColor( const QColor& theColor,
-                                              const bool    theToDisplay = true );
+                                              const bool    theToDisplay = true,
+                                              const bool    theIsUpdateViewer = true );
   virtual QColor             getFillingColor() const;
 
   virtual void               setBorderColor( const QColor& theColor,
-                                             const bool    theToDisplay = true );
+                                             const bool    theToDisplay = true,
+                                             const bool    theIsUpdateViewer = true );
   virtual QColor             getBorderColor() const;
 
   virtual void               setHighlightColor( const QColor& theColor );
@@ -67,7 +81,8 @@ public:
 
 protected:
   virtual void               buildShape();
-  virtual void               updateShape( const bool theIsForce = true );
+  virtual void               updateShape( const bool theToDisplay      = true,
+                                          const bool theIsUpdateViewer = true );
   virtual QColor             getActiveColor() const;
 
 private:
@@ -76,8 +91,12 @@ private:
 
 private:
   Handle(AIS_InteractiveContext) myContext;
+  Handle(HYDROData_Object)       myObject;
   Handle(AIS_Shape)              myShape;
 
+  bool                           myIsToUpdate;
+  bool                           myIsVisible;
+
   bool                           myIsHighlight;
   TopoDS_Face                    myFace;
   
index a2d46be4c950365e0c47cd440f7620137d097954..064d7785d9cc12862a6953d49286650be30720cb 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "HYDROGUI_ShowHideOp.h"
 
+#include <GraphicsView_Viewer.h>
+
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_Operations.h"
 #include "HYDROGUI_Tool.h"
 #include <HYDROData_Iterator.h>
 #include <HYDROData_Object.h>
 
+#include <LightApp_Application.h>
+
+#include <OCCViewer_ViewModel.h>
+
+#include <SUIT_ViewManager.h>
+
 HYDROGUI_ShowHideOp::HYDROGUI_ShowHideOp( HYDROGUI_Module* theModule, int theId )
 : HYDROGUI_Operation( theModule ),
   myId( theId )
@@ -55,7 +63,7 @@ void HYDROGUI_ShowHideOp::startOperation()
 {
   HYDROGUI_Operation::startOperation();
 
-  size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
+  size_t aViewId = HYDROGUI_Tool::GetActiveViewId( module() );
 
   // for all objects
   if( myId == ShowOnlyId || myId == ShowAllId || myId == HideAllId )
@@ -84,6 +92,21 @@ void HYDROGUI_ShowHideOp::startOperation()
     }
   }
 
-  module()->update( UF_Viewer );
+  int anUpdateFlags = 0;
+
+  SUIT_ViewManager* aViewMgr = module()->getApp()->activeViewManager();
+  if ( aViewMgr )
+  {
+    if ( aViewMgr->getType() == GraphicsView_Viewer::Type() )
+    {
+      anUpdateFlags |= UF_Viewer;
+    }
+    else if ( aViewMgr->getType() == OCCViewer_Viewer::Type() )
+    {
+      anUpdateFlags |= UF_OCCViewer;
+    }
+  }
+
+  module()->update( anUpdateFlags );
   commit();
 }
index 4650f24e36a5c2bd2115d005c9576c8ea7762f70..ac76bb18ebcd670e219e17700373a5f7b4c0f7f3 100644 (file)
@@ -37,6 +37,8 @@
 #include <LightApp_DataOwner.h>
 #include <LightApp_SelectionMgr.h>
 
+#include <OCCViewer_ViewModel.h>
+
 #include <QtxWorkstack.h>
 
 #include <STD_TabDesktop.h>
@@ -376,11 +378,12 @@ QString HYDROGUI_Tool::GenerateObjectName( HYDROGUI_Module*   theModule,
   return aName;
 }
 
-size_t HYDROGUI_Tool::GetActiveGraphicsViewId( HYDROGUI_Module* theModule )
+size_t HYDROGUI_Tool::GetActiveViewId( HYDROGUI_Module* theModule,
+                                       const QString&   theViewId )
 {
   size_t aViewId = 0;
   SUIT_ViewManager* aViewMgr = theModule->getApp()->activeViewManager();
-  if( !aViewMgr || aViewMgr->getType() != GraphicsView_Viewer::Type() )
+  if( !aViewMgr || ( !theViewId.isEmpty() && aViewMgr->getType() != theViewId ) )
     return aViewId;
 
   if( SUIT_ViewModel* aViewer = aViewMgr->getViewModel() )
@@ -388,11 +391,22 @@ size_t HYDROGUI_Tool::GetActiveGraphicsViewId( HYDROGUI_Module* theModule )
   return aViewId;
 }
 
-QList<size_t> HYDROGUI_Tool::GetGraphicsViewIdList( HYDROGUI_Module* theModule )
+size_t HYDROGUI_Tool::GetActiveGraphicsViewId( HYDROGUI_Module* theModule )
+{
+  return GetActiveViewId( theModule, GraphicsView_Viewer::Type() );
+}
+
+size_t HYDROGUI_Tool::GetActiveOCCViewId( HYDROGUI_Module* theModule )
+{
+  return GetActiveViewId( theModule, OCCViewer_Viewer::Type() );
+}
+
+QList<size_t> getViewIdList( HYDROGUI_Module* theModule,
+                             const QString&   theViewId )
 {
   QList<size_t> aList;
   ViewManagerList aViewMgrs;
-  theModule->getApp()->viewManagers( GraphicsView_Viewer::Type(), aViewMgrs );
+  theModule->getApp()->viewManagers( theViewId, aViewMgrs );
   QListIterator<SUIT_ViewManager*> anIter( aViewMgrs );
   while( anIter.hasNext() )
   {
@@ -405,6 +419,16 @@ QList<size_t> HYDROGUI_Tool::GetGraphicsViewIdList( HYDROGUI_Module* theModule )
   return aList;
 }
 
+QList<size_t> HYDROGUI_Tool::GetGraphicsViewIdList( HYDROGUI_Module* theModule )
+{
+  return getViewIdList( theModule, GraphicsView_Viewer::Type() );
+}
+
+QList<size_t> HYDROGUI_Tool::GetOCCViewIdList( HYDROGUI_Module* theModule )
+{
+  return getViewIdList( theModule, OCCViewer_Viewer::Type() );
+}
+
 void HYDROGUI_Tool::GetObjectReferences( const Handle(HYDROData_Image)& theImage,
                                          HYDROData_SequenceOfObjects& theRefObjects,
                                          QStringList& theRefNames )
index 264adbd58535eb9546090a3bb73d27c51f0543f0..cb77fb75c6468dd6a2efd39ed24c43294ff682c4 100644 (file)
@@ -198,6 +198,14 @@ public:
                                                       const QString&     thePrefix,
                                                       const QStringList& theUsedNames = QStringList() );
 
+  /**
+   * \brief Get id of the active view.
+   * \param theModule module
+   * \return view id
+   */
+  static size_t                   GetActiveViewId( HYDROGUI_Module* theModule,
+                                                   const QString&   theViewId = QString() );
+
   /**
    * \brief Get id of the active GraphicsView view.
    * \param theModule module
@@ -205,6 +213,13 @@ public:
    */
   static size_t                   GetActiveGraphicsViewId( HYDROGUI_Module* theModule );
 
+  /**
+   * \brief Get id of the active OCC view.
+   * \param theModule module
+   * \return view id
+   */
+  static size_t                   GetActiveOCCViewId( HYDROGUI_Module* theModule );
+
   /**
    * \brief Get list of ids of existing GraphicsView views.
    * \param theModule module
@@ -212,6 +227,13 @@ public:
    */
   static QList<size_t>            GetGraphicsViewIdList( HYDROGUI_Module* theModule );
 
+  /**
+   * \brief Get list of ids of existing OCC views.
+   * \param theModule module
+   * \return list of view ids
+   */
+  static QList<size_t>            GetOCCViewIdList( HYDROGUI_Module* theModule );
+
   /**
    * \brief Get the list of references (recursively) for the specified image object
    * \param theImage image data object
index e3ae171b55bb842bbb2c7cf609e8adce0186f147..b01da33503e14026fd35c480ef32736499bf1d34 100644 (file)
 typedef enum
 {
   UF_Base          = UF_Forced | UF_Model | UF_Viewer | UF_ObjBrowser | UF_Controls,
+  
   UF_GV_Init       = 0x00000020, //!< initial update (used with UF_Viewer)
   UF_GV_Forced     = 0x00000040, //!< to force recomputing all presentations (used with UF_Viewer)
-  UF_All           = UF_Base | UF_GV_Init | UF_GV_Forced //!< all update flags
+  
+  UF_OCCViewer     = 0x00000080, //!< OCC viewer
+  UF_OCC_Init      = 0x00000100, //!< initial update (used with UF_OCCViewer)
+  UF_OCC_Forced    = 0x00000200, //!< to force recomputing all presentations (used with UF_OCCViewer)
+  
+  UF_All           = UF_Base | UF_GV_Init | UF_GV_Forced | UF_OCCViewer | UF_OCC_Init | UF_OCC_Forced//!< all update flags
 } HYDRO_UpdateFlags;
 
 #endif
index 25cefb603a8fd27cf416baf1c0a48842740e61b4..5825105ee3bd00513bb70b92834da0a7c3b03535 100644 (file)
@@ -246,8 +246,12 @@ bool HYDROGUI_ZoneOp::processApply( int& theUpdateFlags,
     aZoneObj->AddBathymetry( aBathymetry );
   }
 
+  closePreview();
+
+  if( !myIsEdit )
+    module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aZoneObj, true );
 
-  theUpdateFlags = UF_Model;
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
 
   return true;
 }
@@ -291,7 +295,7 @@ void HYDROGUI_ZoneOp::onCreatePreview( const QString& thePolylineName )
         Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
         if ( !aCtx.IsNull() )
         {
-          myPreviewPrs = new HYDROGUI_Shape( aCtx );
+          myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL );
         }
       }
     }
@@ -300,9 +304,9 @@ void HYDROGUI_ZoneOp::onCreatePreview( const QString& thePolylineName )
   if ( !myPreviewViewManager || !myPreviewPrs )
     return;
 
-  myPreviewPrs->setFillingColor( aPanel->getFillingColor(), false );
-  myPreviewPrs->setBorderColor( aPanel->getBorderColor(), false );
-  myPreviewPrs->setWire( aWire, true );
+  myPreviewPrs->setFillingColor( aPanel->getFillingColor(), false, false );
+  myPreviewPrs->setBorderColor( aPanel->getBorderColor(), false, false );
+  myPreviewPrs->setWire( aWire );
 }
 
 void HYDROGUI_ZoneOp::onLastViewClosed( SUIT_ViewManager* theViewManager )