set(PROJECT_HEADERS
HYDROGUI.h
+ HYDROGUI_AbstractDisplayer.h
HYDROGUI_AISCurve.h
HYDROGUI_CalculationDlg.h
HYDROGUI_CalculationOp.h
set(PROJECT_SOURCES
HYDROGUI_AISCurve.cxx
+ HYDROGUI_AbstractDisplayer.cxx
HYDROGUI_CalculationDlg.cxx
HYDROGUI_CalculationOp.cxx
HYDROGUI_ColorWidget.cxx
if ( !aPanel )
return false;
- theUpdateFlags = UF_Model;
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
return true;
}
#include <GraphicsView_ViewPort.h>
HYDROGUI_Displayer::HYDROGUI_Displayer( HYDROGUI_Module* theModule )
-: myModule( theModule )
+: HYDROGUI_AbstractDisplayer( theModule )
{
}
void HYDROGUI_Displayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
const int theViewerId )
{
- GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+ GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
if( !aViewer )
return;
}
}
-void HYDROGUI_Displayer::UpdateAll( const int theViewerId,
- const bool theIsInit,
- const bool theIsForced )
-{
- if( theIsInit )
- EraseAll( theViewerId );
- DisplayAll( theViewerId, theIsForced );
-}
-
void HYDROGUI_Displayer::EraseAll( const int theViewerId )
{
- GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+ GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
if( !aViewer )
return;
}
}
-void HYDROGUI_Displayer::DisplayAll( const int theViewerId,
- const bool theIsForced )
-{
- HYDROData_SequenceOfObjects aSeq;
- HYDROGUI_Tool::GetPrsSubObjects( myModule, aSeq );
- Update( aSeq, theViewerId, theIsForced );
-}
-
-void HYDROGUI_Displayer::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_Entity)& 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_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
const int theViewerId )
{
- GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+ GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
if( !aViewer )
return;
if( !aViewPort )
return;
- HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)myModule->dataModel();
+ HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)module()->dataModel();
if( aModel )
{
GraphicsView_ObjectList anObjectList = HYDROGUI_Tool::GetPrsList( aViewPort );
const int theViewerId,
const bool theIsForced )
{
- GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+ GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
if( !aViewer )
return;
if( aPrs )
{
- bool anIsVisible = myModule->isObjectVisible( (size_t)aViewer, anObj );
+ bool anIsVisible = module()->isObjectVisible( (size_t)aViewer, anObj );
aPrs->setVisible( anIsVisible );
}
}
void HYDROGUI_Displayer::purgeObjects( const int theViewerId )
{
- GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+ GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
if( !aViewer )
return;
#ifndef HYDROGUI_DISPLAYER_H
#define HYDROGUI_DISPLAYER_H
-#include <HYDROData_Entity.h>
+#include "HYDROGUI_AbstractDisplayer.h"
#include <QMap>
-class HYDROGUI_Module;
class HYDROGUI_PrsDriver;
class GraphicsView_Viewer;
* \class HYDROGUI_DataModel
* \brief Class intended to create, display and update the presentations.
*/
-class HYDROGUI_Displayer
+class HYDROGUI_Displayer : public HYDROGUI_AbstractDisplayer
{
public:
/**
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.
*/
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
const int theViewerId,
const bool theIsForced );
-private:
/**
* \brief Purge all invalid objects in the viewer.
* \param theViewerId viewer identifier
*/
void purgeObjects( const int theViewerId );
+private:
/**
* \brief Get the presentation driver for the specified data object.
* \param theObj data object
HYDROGUI_PrsDriver* getDriver( const Handle(HYDROData_Entity)& theObj );
private:
- HYDROGUI_Module* myModule;
-
typedef QMap< ObjectKind, HYDROGUI_PrsDriver* > PrsDriversMap;
PrsDriversMap myPrsDriversMap;
};
#include <SALOME_Event.h>
+#include <SUIT_DataBrowser.h>
#include <SUIT_Desktop.h>
#include <SUIT_Study.h>
#include <SUIT_ViewManager.h>
{
HYDROGUI_DataModel* aModel = getDataModel();
- bool anIsObjectBrowser = theClient == "ObjectBrowser";
+ bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView )
bool anIsCalculation = false;
bool anIsImmersibleZone = false;
bool anIsVisualState = false;
+ bool anIsRegion = false;
+ bool anIsZone = false;
// check the selected data model objects
HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
anIsSplittedImage = true;
}
}
- anIsMustBeUpdatedImage = anImage->IsMustBeUpdated();
+ if ( anImage->IsMustBeUpdated() )
+ {
+ anIsMustBeUpdatedImage = true;
+ }
}
}
else if( anObject->GetKind() == KIND_POLYLINE )
anIsImmersibleZone = true;
else if( anObject->GetKind() == KIND_VISUAL_STATE )
anIsVisualState = true;
+ else if( anObject->GetKind() == KIND_REGION )
+ anIsRegion = true;
+ else if( anObject->GetKind() == KIND_ZONE )
+ anIsZone = true;
}
}
}
}
- if( anIsSelectedDataObjects && anIsMustBeUpdatedImage )
+ if( anIsSelectedDataObjects )
{
- theMenu->addAction( action( UpdateImageId ) );
- theMenu->addSeparator();
- }
+ if ( anIsMustBeUpdatedImage )
+ {
+ theMenu->addAction( action( UpdateImageId ) );
+ theMenu->addSeparator();
+ }
- if( anIsSelectedDataObjects && aSeq.Length() == 1 )
- {
- if( anIsImage )
+ if( aSeq.Length() == 1 )
{
- if( anIsImportedImage )
- theMenu->addAction( action( EditImportedImageId ) );
- else if( anIsImageHasRefs )
+ if( anIsImage )
{
- if( anIsFusedImage )
- theMenu->addAction( action( EditFusedImageId ) );
- else if( anIsCutImage )
- theMenu->addAction( action( EditCutImageId ) );
- else if( anIsSplittedImage )
- theMenu->addAction( action( EditSplittedImageId ) );
- }
+ if( anIsImportedImage )
+ theMenu->addAction( action( EditImportedImageId ) );
+ else if( anIsImageHasRefs )
+ {
+ if( anIsFusedImage )
+ theMenu->addAction( action( EditFusedImageId ) );
+ else if( anIsCutImage )
+ theMenu->addAction( action( EditCutImageId ) );
+ else if( anIsSplittedImage )
+ theMenu->addAction( action( EditSplittedImageId ) );
+ }
- theMenu->addAction( action( ObserveImageId ) );
- theMenu->addAction( action( ExportImageId ) );
- theMenu->addSeparator();
+ theMenu->addAction( action( ObserveImageId ) );
+ theMenu->addAction( action( ExportImageId ) );
+ theMenu->addSeparator();
+
+ if( anIsImageHasRefs )
+ {
+ theMenu->addAction( action( RemoveImageRefsId ) );
+ theMenu->addSeparator();
+ }
- if( anIsImageHasRefs )
+ theMenu->addAction( action( FuseImagesId ) );
+ theMenu->addAction( action( CutImagesId ) );
+ theMenu->addAction( action( SplitImageId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsPolyline )
{
- theMenu->addAction( action( RemoveImageRefsId ) );
+ theMenu->addAction( action( EditPolylineId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsCalculation )
+ {
+ theMenu->addAction( action( EditCalculationId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsImmersibleZone )
+ {
+ theMenu->addAction( action( EditImmersibleZoneId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsVisualState && anIsObjectBrowser )
+ {
+ theMenu->addAction( action( SaveVisualStateId ) );
+ theMenu->addAction( action( LoadVisualStateId ) );
theMenu->addSeparator();
}
-
- theMenu->addAction( action( FuseImagesId ) );
- theMenu->addAction( action( CutImagesId ) );
- theMenu->addAction( action( SplitImageId ) );
- theMenu->addSeparator();
- }
- else if( anIsPolyline )
- {
- theMenu->addAction( action( EditPolylineId ) );
- theMenu->addSeparator();
- }
- else if( anIsCalculation )
- {
- theMenu->addAction( action( EditCalculationId ) );
- theMenu->addSeparator();
- }
- else if( anIsImmersibleZone )
- {
- theMenu->addAction( action( EditImmersibleZoneId ) );
- theMenu->addSeparator();
- }
- else if( anIsVisualState && anIsObjectBrowser )
- {
- theMenu->addAction( action( SaveVisualStateId ) );
- theMenu->addAction( action( LoadVisualStateId ) );
- theMenu->addSeparator();
}
- }
- if( anIsSelectedDataObjects )
- {
theMenu->addAction( action( DeleteId ) );
theMenu->addSeparator();
- }
- if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsImmersibleZone ) )
- {
- if( anIsHiddenInSelection )
- theMenu->addAction( action( ShowId ) );
- theMenu->addAction( action( ShowOnlyId ) );
- if( anIsVisibleInSelection )
- theMenu->addAction( action( HideId ) );
- theMenu->addSeparator();
+ if( anIsImage || anIsPolyline || anIsImmersibleZone || anIsZone || anIsRegion )
+ {
+ if( anIsHiddenInSelection )
+ theMenu->addAction( action( ShowId ) );
+ theMenu->addAction( action( ShowOnlyId ) );
+ if( anIsVisibleInSelection )
+ theMenu->addAction( action( HideId ) );
+ theMenu->addSeparator();
+ }
}
if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView )
#include <OCCViewer_ViewModel.h>
#include <OCCViewer_ViewWindow.h>
-#include <QApplication>
-
HYDROGUI_OCCDisplayer::HYDROGUI_OCCDisplayer( HYDROGUI_Module* theModule )
-: myModule( theModule )
+: HYDROGUI_AbstractDisplayer( theModule )
{
}
void HYDROGUI_OCCDisplayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
const int theViewerId )
{
- OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId );
+ OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
if( !aViewer )
return;
if( anObj.IsNull() )
continue;
- HYDROGUI_Shape* anObjShape = myModule->getObjectShape( (size_t)aViewer, anObj );
+ HYDROGUI_Shape* anObjShape = module()->getObjectShape( (size_t)aViewer, anObj );
if ( !anObjShape )
continue;
}
}
-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 );
+ OCCViewer_Viewer* aViewer = module()->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_Entity)& 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 );
+ module()->removeViewShapes( (size_t)aViewer );
}
void HYDROGUI_OCCDisplayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
const int theViewerId )
{
- OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId );
+ OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
if( !aViewer )
return;
if( anObj.IsNull() )
continue;
- myModule->removeObjectShape( (size_t)aViewer, anObj );
+ module()->removeObjectShape( (size_t)aViewer, anObj );
}
}
return aResShape;
aResShape = new HYDROGUI_Shape( theContext, theObject );
- myModule->setObjectShape( theViewerId, theObject, aResShape );
+ module()->setObjectShape( theViewerId, theObject, aResShape );
return aResShape;
}
const int theViewerId,
const bool theIsForced )
{
- OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId );
+ OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
if( !aViewer )
return;
if ( anObj.IsNull() || anObj->IsRemoved() )
continue;
- HYDROGUI_Shape* anObjShape = myModule->getObjectShape( (size_t)aViewer, anObj );
+ HYDROGUI_Shape* anObjShape = module()->getObjectShape( (size_t)aViewer, anObj );
if ( !anObjShape || anObjShape->getIsToUpdate() || theIsForced )
{
if ( anObjShape )
{
- bool anIsVisible = myModule->isObjectVisible( (size_t)aViewer, anObj );
+ bool anIsVisible = module()->isObjectVisible( (size_t)aViewer, anObj );
anObjShape->setVisible( anIsVisible, false );
}
}
::qobject_cast<OCCViewer_ViewWindow*>( aViewManager->getActiveView() );
if ( aViewWindow )
{
- //RKV: QApplication::processEvents(); //Process the draw events for viewer
aViewWindow->onFitAll();
}
}
void HYDROGUI_OCCDisplayer::purgeObjects( const int theViewerId )
{
- OCCViewer_Viewer* aViewer = myModule->getOCCViewer( theViewerId );
+ OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
if( !aViewer )
return;
Handle(HYDROData_Entity) anOwnerObj =
Handle(HYDROData_Entity)::DownCast( aPrsObj->GetOwner() );
if ( !anOwnerObj.IsNull() && anOwnerObj->IsRemoved() )
- myModule->removeObjectShape( (size_t)aViewer, anOwnerObj );
+ module()->removeObjectShape( (size_t)aViewer, anOwnerObj );
}
}
#ifndef HYDROGUI_OCCDISPLAYER_H
#define HYDROGUI_OCCDISPLAYER_H
-#include <HYDROData_Entity.h>
+#include "HYDROGUI_AbstractDisplayer.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
+class HYDROGUI_OCCDisplayer : public HYDROGUI_AbstractDisplayer
{
public:
/**
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.
*/
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
const int theViewerId,
const bool theIsForced );
-private:
/**
* \brief Purge all invalid objects in the viewer.
* \param theViewerId viewer identifier
*/
void purgeObjects( const int theViewerId );
+private:
/**
* \brief Creates new OCC shape.
* \param theViewerId viewer identifier
HYDROGUI_Shape* createShape( const int theViewerId,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(HYDROData_Entity)& theObject );
-
-private:
- HYDROGUI_Module* myModule;
-
};
#endif
setWire( aPolylineWire, false, false );
}
- else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Region) ) )
- {
- Handle(HYDROData_Region) aRegion =
- Handle(HYDROData_Region)::DownCast( myObject );
- }
else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Zone) ) )
{
Handle(HYDROData_Zone) aZone =
#include <HYDROData_Iterator.h>
#include <HYDROData_Entity.h>
+#include <HYDROData_Region.h>
#include <LightApp_Application.h>
HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
bool aVisibility = myId == ShowId || myId == ShowOnlyId;
+ Handle( HYDROData_Entity ) anObject;
for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
{
- Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
+ anObject = aSeq.Value( anIndex );
if( !anObject.IsNull() )
+ {
module()->setObjectVisible( aViewId, anObject, aVisibility );
+ if ( anObject->GetKind() == KIND_REGION )
+ {
+ Handle( HYDROData_Region ) aRegion = Handle( HYDROData_Region )::DownCast( anObject );
+ if ( !aRegion.IsNull() )
+ {
+ HYDROData_SequenceOfObjects aZonesSeq = aRegion->GetZones();
+ for( Standard_Integer aZoneIdx = 1, aNbZones = aZonesSeq.Length(); aZoneIdx <= aNbZones; aZoneIdx++ )
+ {
+ anObject = aZonesSeq.Value( aZoneIdx );
+ if( !anObject.IsNull() )
+ {
+ module()->setObjectVisible( aViewId, anObject, aVisibility );
+ }
+ }
+ }
+ }
+ }
}
}
HYDROData_SequenceOfObjects& theSeq )
{
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
- if( aDocument.IsNull() )
- return;
-
- HYDROData_Iterator anIterator( aDocument, KIND_IMAGE );
- for( ; anIterator.More(); anIterator.Next() )
- {
- Handle(HYDROData_Entity) anObject = anIterator.Current();
- if( !anObject.IsNull() )
- theSeq.Append( anObject );
- }
-
- anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE );
- for( ; anIterator.More(); anIterator.Next() )
+ if( !aDocument.IsNull() )
{
- Handle(HYDROData_Entity) anObject = anIterator.Current();
- if( !anObject.IsNull() )
- theSeq.Append( anObject );
- }
-
- anIterator = HYDROData_Iterator( aDocument, KIND_IMMERSIBLE_ZONE );
- for( ; anIterator.More(); anIterator.Next() )
- {
- Handle(HYDROData_Entity) anObject = anIterator.Current();
- if( !anObject.IsNull() )
- theSeq.Append( anObject );
+ HYDROData_Iterator anIterator( aDocument );
+ for( ; anIterator.More(); anIterator.Next() )
+ {
+ Handle(HYDROData_Entity) anObject = anIterator.Current();
+ if( !anObject.IsNull() && (
+ ( anObject->GetKind() == KIND_IMAGE ) ||
+ ( anObject->GetKind() == KIND_POLYLINE ) ||
+ ( anObject->GetKind() == KIND_IMMERSIBLE_ZONE ) ||
+ ( anObject->GetKind() == KIND_REGION ) ||
+ ( anObject->GetKind() == KIND_ZONE ) ) )
+ {
+ theSeq.Append( anObject );
+ }
+ }
}
}