HYDROGUI_Module.h
HYDROGUI_ObjSelector.h
HYDROGUI_ObserveImageOp.h
+ HYDROGUI_OCCDisplayer.h
HYDROGUI_Operation.h
HYDROGUI_Operations.h
HYDROGUI_PolylineDlg.h
HYDROGUI_Module.cxx
HYDROGUI_ObjSelector.cxx
HYDROGUI_ObserveImageOp.cxx
+ HYDROGUI_OCCDisplayer.cxx
HYDROGUI_Operation.cxx
HYDROGUI_Operations.cxx
HYDROGUI_PolylineDlg.cxx
<?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"
>
{
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
Region& aRegion = *anIter;
if ( aRegion.Shape )
{
+ aRegion.Shape->erase( false );
delete aRegion.Shape;
aRegion.Shape = NULL;
}
}
commitDocOperation();
- module()->update( UF_Model | UF_Viewer );
+ module()->update( UF_Model | UF_Viewer | UF_OCCViewer );
commit();
}
#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>
HYDROGUI_Module::HYDROGUI_Module()
: LightApp_Module( "HYDRO" ),
myDisplayer( 0 ),
+ myOCCDisplayer( 0 ),
myIsUpdateEnabled( true )
{
}
setToolShown( false );
myDisplayer = new HYDROGUI_Displayer( this );
+ myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
}
bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
myViewManagerMap.clear();
myObjectStateMap.clear();
+ myShapesMap.clear();
// clear the data model's list of copying objects
HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
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,
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;
{
anIsSelectedDataObjects = true;
- bool aVisibility = isObjectVisible( aViewId, anObject );
+ bool aVisibility = isObjectVisible( anActiveViewId, anObject );
anIsVisibleInSelection |= aVisibility;
anIsHiddenInSelection |= !aVisibility;
theMenu->addSeparator();
}
- if( anIsObjectBrowser || anIsGraphicsView )
+ if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView )
{
theMenu->addAction( action( ShowAllId ) );
theMenu->addAction( action( HideAllId ) );
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() );
return myDisplayer;
}
+HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
+{
+ return myOCCDisplayer;
+}
+
GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
{
if( myViewManagerMap.contains( theId ) )
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 );
}
bool HYDROGUI_Module::isObjectVisible( const int theViewId,
- const Handle(HYDROData_Object)& theObject )
+ const Handle(HYDROData_Object)& theObject ) const
{
if( theObject.IsNull() )
return false;
}
}
+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 );
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 );
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 )
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();
}
}
}
// 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 );
}
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 )
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
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();
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 );
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();
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 );
private:
HYDROGUI_Displayer* myDisplayer;
+ HYDROGUI_OCCDisplayer* myOCCDisplayer;
ViewManagerMap myViewManagerMap;
ViewId2Name2ObjectStateMap myObjectStateMap;
+ ViewId2ListOfShapes myShapesMap;
+
bool myIsUpdateEnabled;
};
--- /dev/null
+// 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 );
+ }
+}
+
+
--- /dev/null
+// 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
+
#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 )
{
}
void HYDROGUI_Shape::display( const bool theIsUpdateViewer )
{
- if ( !myContext || myShape.IsNull() )
+ if ( myContext.IsNull() || myShape.IsNull() )
return;
myContext->Display( myShape, 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 )
myIsHighlight = theIsHighlight;
- if ( !myContext || myShape.IsNull() )
+ if ( myContext.IsNull() || myShape.IsNull() )
return;
colorShapeBorder( getActiveColor() );
}
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
}
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
myShape = new AIS_Shape( myFace );
+ if ( !myObject.IsNull() )
+ myShape->SetOwner( myObject );
+
myShape->SetTransparency( 0 );
myShape->SetDisplayMode( AIS_Shaded );
}
}
-void HYDROGUI_Shape::updateShape( const bool theIsForce )
+void HYDROGUI_Shape::updateShape( const bool theToDisplay,
+ const bool theIsUpdateViewer )
{
if ( myShape.IsNull() )
return;
colorShapeBorder( getActiveColor() );
}
- if ( !theIsForce || !myContext )
+ if ( !theToDisplay || myContext.IsNull() )
return;
- myContext->Display( myShape, theIsForce );
+ myContext->Display( myShape, theIsUpdateViewer );
}
QColor HYDROGUI_Shape::getActiveColor() const
#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:
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 );
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:
private:
Handle(AIS_InteractiveContext) myContext;
+ Handle(HYDROData_Object) myObject;
Handle(AIS_Shape) myShape;
+ bool myIsToUpdate;
+ bool myIsVisible;
+
bool myIsHighlight;
TopoDS_Face myFace;
#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 )
{
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 )
}
}
- 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();
}
#include <LightApp_DataOwner.h>
#include <LightApp_SelectionMgr.h>
+#include <OCCViewer_ViewModel.h>
+
#include <QtxWorkstack.h>
#include <STD_TabDesktop.h>
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() )
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() )
{
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 )
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
*/
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
*/
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
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
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;
}
Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
if ( !aCtx.IsNull() )
{
- myPreviewPrs = new HYDROGUI_Shape( aCtx );
+ myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL );
}
}
}
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 )