#include "HYDROGUI_VTKPrs.h"
#include "HYDROGUI_VTKPrsDisplayer.h"
#include "HYDROGUI_AbstractDisplayer.h"
+#include "HYDROGUI_PolylineOp.h"
+#include "HYDROGUI_SetColorOp.h"
+#include "HYDROGUI_ImportGeomObjectOp.h"
#include <HYDROData_Image.h>
+#include <HYDROData_Profile.h>
#include <HYDROData_Lambert93.h>
#include <HYDROData_Tool.h>
#include <SVTK_ViewModel.h>
#include <SVTK_Selector.h>
+#include <OCCViewer_ViewPort3d.h>
+
+#include <GEOMUtils.hxx>
+
#include <QAction>
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
#include <QMenu>
+#include <QMouseEvent>
+#include <QStatusBar>
static int ViewManagerId = 0;
HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
#endif
+ // Remove defunct view managers from the map.
+ // It's essential to do this before "update( UF_All )" call!
+ QList<int> anObsoleteIds;
+ ViewManagerList anAllViewManagers = anApp->viewManagers();
+ ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module
+ ViewManagerMapIterator anIter( myViewManagerMap );
+ while( anIter.hasNext() ) {
+ int anId = anIter.next().key();
+ const ViewManagerInfo& anInfo = anIter.value();
+
+ aHydroViewManagers << anInfo.first;
+
+ if ( !anAllViewManagers.contains( anInfo.first ) ) {
+ anObsoleteIds << anId;
+ }
+ }
+ foreach ( const int anId, anObsoleteIds ) {
+ myViewManagerMap.remove( anId );
+ myObjectStateMap.remove( anId );
+ myShapesMap.remove( anId );
+ myVTKPrsMap.remove( anId );
+ }
+ // Replace the default selector for all view managers.
+ // Add view managers created outside of HYDRO module to the map.
+ foreach ( SUIT_ViewManager* aViewManager, anAllViewManagers ) {
+ createSelector( aViewManager ); // replace the default selector
+ if ( !aHydroViewManagers.contains( aViewManager ) ) {
+ ViewManagerInfo anInfo( aViewManager, VMR_General );
+ myViewManagerMap.insert( ViewManagerId++, anInfo );
+ }
+ }
+
update( UF_All );
updateCommandsStatus();
connect( anApp, SIGNAL( operationFinished( const QString&, const QString&, const QStringList& ) ),
this, SLOT( onExternalOperationFinished( const QString&, const QString&, const QStringList& ) ) );
+ HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
+
+ ViewManagerList anOCCViewManagers;
+ anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
+ foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
+ connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
+ this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
+ foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() ) {
+ OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
+ if ( aViewFrame && aViewFrame->getViewPort() ) {
+ aViewFrame->getViewPort()->installEventFilter( this );
+ }
+ }
+ }
+
return aRes;
}
bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
{
+ /* Issues ## 68, 88.
ViewManagerMapIterator anIter( myViewManagerMap );
while( anIter.hasNext() )
if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
getApp()->removeViewManager( aViewManager );
myViewManagerMap.clear();
+ */
+
+ ViewManagerList anOCCViewManagers;
+ getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
+ foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
+ disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
+ this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
+ }
+ /* Issues ## 68, 88.
myObjectStateMap.clear();
myShapesMap.clear();
+ myVTKPrsMap.clear();
+ */
// clear the data model's list of copying objects
HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
disconnect( getApp(), SIGNAL( operationFinished( const QString&, const QString&, const QStringList& ) ),
this, SLOT( onExternalOperationFinished( const QString&, const QString&, const QStringList& ) ) );
+ HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
+
return LightApp_Module::deactivateModule( theStudy );
}
void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
{
- theTypesList << OCCViewer_Viewer::Type() << GraphicsView_Viewer::Type();
+ theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
}
void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
bool anIsFusedImage = false;
bool anIsCutImage = false;
bool anIsSplittedImage = false;
- bool anIsMustBeUpdatedImage = false;
+ bool anIsMustObjectBeUpdated = false;
bool anIsPolyline = false;
+ bool anIsPolyline3D = false;
+ bool anIsProfile = false;
+ bool anIsValidProfile = false;
+ bool anAllAreProfiles = false;
bool anIsBathymetry = false;
bool anIsCalculation = false;
bool anIsImmersibleZone = false;
bool anIsRegion = false;
bool anIsZone = false;
bool anIsObstacle = false;
- bool anIsGeomObject = false;
-
- // check the selected GEOM objects
- if ( !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) {
- theMenu->addAction( action( ImportGeomObjectId ) );
- theMenu->addSeparator();
+ bool anIsStream = false;
+ bool anIsChannel = false;
+ bool anIsDigue = false;
+ bool anIsDummyObject3D = false;
+ bool anIsObjectCanBeColored = false;
+
+ // Check the selected GEOM objects (take into account the Object Browser only)
+ if ( anIsObjectBrowser ) {
+ QList<GEOM::shape_type> anObstacleTypes =
+ HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
+ QList<GEOM::shape_type> aPolylineTypes =
+ HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
+
+ bool isCanBeImportedAsObstacle =
+ !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
+ bool isCanBeImportedAsPolyline =
+ !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
+
+ // Add import as obstacle action
+ if ( isCanBeImportedAsObstacle ) {
+ theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
+ }
+ // Add import as polyline action
+ if ( isCanBeImportedAsPolyline ) {
+ theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
+ }
+ // Add separator
+ if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
+ theMenu->addSeparator();
+ }
}
// check the selected data model objects
HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
+ int aNbOfSelectedProfiles = 0;
for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
{
Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
anIsVisibleInSelection |= aVisibility;
anIsHiddenInSelection |= !aVisibility;
- if( anObject->GetKind() == KIND_IMAGE )
+ if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated() )
+ {
+ anIsMustObjectBeUpdated = true;
+ }
+
+ ObjectKind anObjectKind = anObject->GetKind();
+ if( anObjectKind == KIND_IMAGE )
{
anIsImage = true;
Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
if( !anImage.IsNull() )
{
- anIsImportedImage = anImage->HasLocalPoints() && !anImage->IsSelfSplitted();
+ anIsImportedImage = anImage->HasLocalPoints();
anIsImageHasRefs = anImage->HasReferences();
if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
{
anIsSplittedImage = true;
}
}
- if ( anImage->IsMustBeUpdated() )
- {
- anIsMustBeUpdatedImage = true;
- }
}
}
- else if( anObject->GetKind() == KIND_POLYLINE )
+ else if( anObjectKind == KIND_POLYLINEXY )
anIsPolyline = true;
- else if( anObject->GetKind() == KIND_CALCULATION )
+ else if( anObjectKind == KIND_POLYLINE )
+ anIsPolyline3D = true;
+ else if( anObjectKind == KIND_PROFILE )
+ {
+ anIsProfile = true;
+ aNbOfSelectedProfiles++;
+
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( anObject );
+ if( !aProfile.IsNull() && aProfile->IsValid() ) {
+ anIsValidProfile = true;
+ }
+ }
+ else if( anObjectKind == KIND_CALCULATION )
anIsCalculation = true;
- else if( anObject->GetKind() == KIND_IMMERSIBLE_ZONE )
+ else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
anIsImmersibleZone = true;
- else if( anObject->GetKind() == KIND_VISUAL_STATE )
+ else if( anObjectKind == KIND_VISUAL_STATE )
anIsVisualState = true;
- else if( anObject->GetKind() == KIND_REGION )
+ else if( anObjectKind == KIND_REGION )
anIsRegion = true;
- else if( anObject->GetKind() == KIND_ZONE )
+ else if( anObjectKind == KIND_ZONE )
anIsZone = true;
- else if( anObject->GetKind() == KIND_BATHYMETRY )
+ else if( anObjectKind == KIND_BATHYMETRY )
anIsBathymetry = true;
- else if( anObject->GetKind() == KIND_OBSTACLE )
+ else if( anObjectKind == KIND_OBSTACLE )
anIsObstacle = true;
+ else if( anObjectKind == KIND_STREAM )
+ anIsStream = true;
+ else if( anObjectKind == KIND_CHANNEL )
+ anIsChannel = true;
+ else if( anObjectKind == KIND_DIGUE )
+ anIsDigue = true;
+ else if( anObjectKind == KIND_DUMMY_3D )
+ anIsDummyObject3D = true;
}
- anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject );
+ if ( !anIsObjectCanBeColored )
+ anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject );
}
+ // Check if all selected objects are profiles
+ anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
+ ( aNbOfSelectedProfiles == aSeq.Length() );
+
// check the selected partitions
if( !anIsSelectedDataObjects && anIsObjectBrowser )
{
case KIND_IMAGE:
theMenu->addAction( action( ImportImageId ) );
break;
- case KIND_POLYLINE:
- theMenu->addAction( action( CreatePolylineId ) );
- break;
- case KIND_VISUAL_STATE:
- theMenu->addAction( action( SaveVisualStateId ) );
- break;
case KIND_BATHYMETRY:
theMenu->addAction( action( ImportBathymetryId ) );
break;
- case KIND_CALCULATION:
- theMenu->addAction( action( CreateCalculationId ) );
+ case KIND_ARTIFICIAL_OBJECT:
+ theMenu->addAction( action( CreateChannelId ) );
+ theMenu->addAction( action( CreateDigueId ) );
break;
- case KIND_IMMERSIBLE_ZONE:
+ case KIND_NATURAL_OBJECT:
theMenu->addAction( action( CreateImmersibleZoneId ) );
+ theMenu->addAction( action( CreateStreamId ) );
break;
case KIND_OBSTACLE:
theMenu->addAction( action( ImportObstacleFromFileId ) );
theMenu->addAction( action( CreateBoxId ) );
theMenu->addAction( action( CreateCylinderId ) );
break;
+ case KIND_CALCULATION:
+ theMenu->addAction( action( CreateCalculationId ) );
+ break;
+ case KIND_POLYLINEXY:
+ theMenu->addAction( action( CreatePolylineId ) );
+ break;
+ case KIND_POLYLINE:
+ theMenu->addAction( action( CreatePolyline3DId ) );
+ break;
+ case KIND_PROFILE:
+ theMenu->addAction( action( CreateProfileId ) );
+ theMenu->addAction( action( ImportProfilesId ) );
+ theMenu->addAction( action( AllGeoreferencementId ) );
+ break;
+ case KIND_VISUAL_STATE:
+ theMenu->addAction( action( SaveVisualStateId ) );
+ break;
}
theMenu->addSeparator();
}
if( anIsSelectedDataObjects )
{
- if ( anIsMustBeUpdatedImage )
+ if ( anIsMustObjectBeUpdated )
{
- theMenu->addAction( action( UpdateImageId ) );
+ theMenu->addAction( action( UpdateObjectId ) );
theMenu->addSeparator();
}
theMenu->addAction( action( EditSplittedImageId ) );
}
- theMenu->addAction( action( ObserveImageId ) );
+ //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
theMenu->addAction( action( ExportImageId ) );
theMenu->addSeparator();
theMenu->addAction( action( SplitImageId ) );
theMenu->addSeparator();
}
+ else if( anIsBathymetry )
+ {
+ theMenu->addAction( action( EditImportedBathymetryId ) );
+ theMenu->addSeparator();
+ }
else if( anIsPolyline )
{
theMenu->addAction( action( EditPolylineId ) );
theMenu->addSeparator();
}
+ else if( anIsPolyline3D )
+ {
+ theMenu->addAction( action( EditPolyline3DId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsProfile )
+ {
+ theMenu->addAction( action( EditProfileId ) );
+ theMenu->addAction( action( SelectedGeoreferencementId ) );
+ theMenu->addSeparator();
+ }
else if( anIsCalculation )
{
theMenu->addAction( action( EditCalculationId ) );
theMenu->addAction( action( EditImmersibleZoneId ) );
theMenu->addSeparator();
}
+ else if( anIsStream )
+ {
+ theMenu->addAction( action( EditStreamId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsChannel )
+ {
+ theMenu->addAction( action( EditChannelId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsDigue )
+ {
+ theMenu->addAction( action( EditDigueId ) );
+ theMenu->addSeparator();
+ }
else if( anIsVisualState && anIsObjectBrowser )
{
theMenu->addAction( action( SaveVisualStateId ) );
}
// Add set color action for geometrical objects
- if ( anIsGeomObject )
+ if ( anIsObjectCanBeColored )
{
theMenu->addAction( action( SetColorId ) );
theMenu->addSeparator();
}
+ } else if ( anAllAreProfiles ) {
+ theMenu->addAction( action( SelectedGeoreferencementId ) );
+ theMenu->addSeparator();
}
- theMenu->addAction( action( DeleteId ) );
+ if( !anIsDummyObject3D )
+ theMenu->addAction( action( DeleteId ) );
theMenu->addSeparator();
- if( anIsImage || anIsPolyline || anIsImmersibleZone || anIsZone || anIsRegion || anIsBathymetry || anIsObstacle )
+ if( anIsImage || anIsPolyline || anIsPolyline3D ||
+ anIsImmersibleZone || anIsZone || anIsRegion ||
+ anIsBathymetry || anIsObstacle || anIsStream ||
+ anIsChannel || anIsDigue || anIsDummyObject3D ||
+ anIsValidProfile )
{
if( anIsHiddenInSelection )
theMenu->addAction( action( ShowId ) );
}
}
+ if ( anIsOCCView )
+ {
+ SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
+ HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
+ if ( aPolylineOp && aPolylineOp->deleteEnabled() )
+ theMenu->addAction( action( DeleteId ) );
+ }
+
if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
{
theMenu->addAction( action( ShowAllId ) );
if( theObject.IsNull() )
return;
+ if( theShape && theShape->needScalarBar() )
+ {
+ // Compute the new global Z range from the added presentation and the old global Z range.
+ double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
+ double* aRange = theShape->getInternalZRange();
+ bool anIsUpdate = false;
+ if ( aRange[0] < aGlobalRange[0] )
+ {
+ aGlobalRange[0] = aRange[0];
+ anIsUpdate = true;
+ }
+ if ( aRange[1] > aGlobalRange[1] )
+ {
+ aGlobalRange[1] = aRange[1];
+ anIsUpdate = true;
+ }
+
+ //if ( anIsUpdate )
+ //{
+ updateVTKZRange( theViewId, aGlobalRange );
+ //}
+ }
+
ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
aViewShapes.append( theShape );
}
++i;
}
+
+ // Invalidate global Z range
+ double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
+ getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
}
void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
myVTKPrsMap.remove( theViewId );
}
+
+void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
+{
+ if ( myVTKPrsMap.contains( theViewId ) )
+ {
+ // For the given viewer id update all VTK presentations ...
+ const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
+ HYDROGUI_VTKPrs* aShape;
+ for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
+ {
+ aShape = aViewShapes.at( i );
+ if ( aShape && aShape->needScalarBar() )
+ {
+ aShape->setZRange( theRange );
+ }
+ }
+ }
+ // ... and update the global color legend scalar bar.
+ getVTKDisplayer()->SetZRange( theViewId, theRange );
+}
/////////////////// END OF VTKPrs PROCESSING
CAM_DataModel* HYDROGUI_Module::createDataModel()
theObj->removeEventFilter( this );
}
}
+ else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
+ {
+ if( aType == QEvent::Leave )
+ {
+ SUIT_Desktop* aDesktop = getApp()->desktop();
+ if ( aDesktop && aDesktop->statusBar() ) {
+ aDesktop->statusBar()->clearMessage();
+ }
+ }
+ }
+
return LightApp_Module::eventFilter( theObj, theEvent );
}
{
connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
+ connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
+ this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
}
createSelector( theViewManager ); // replace the default selector
removeViewShapes( (size_t)anOCCViewer );
}
+ if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
+ {
+ SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
+ if ( aVTKViewer )
+ {
+ getVTKDisplayer()->EraseScalarBar( anId, true );
+ removeViewShapes( (size_t)aVTKViewer );
+ }
+ }
+
myViewManagerMap.remove( anId );
}
}
if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
{
aViewFrame->onTopView();
+
+ HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
+
+ OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
+ if ( aViewPort ) {
+ aViewPort->installEventFilter( this );
+ }
}
}
}
aSelectionMgr->setSelected( aList );
}
}
+
+void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
+{
+ OCCViewer_ViewWindow* anOCCViewWindow =
+ dynamic_cast<OCCViewer_ViewWindow*>(theViewWindow);
+ if ( !anOCCViewWindow ) {
+ return;
+ }
+
+ // Get the selected point coordinates
+ OCCViewer_ViewPort3d* aViewPort = anOCCViewWindow->getViewPort();
+ if ( !aViewPort ) {
+ return;
+ }
+
+ gp_Pnt aPnt = GEOMUtils::ConvertClickToPoint( theEvent->x(), theEvent->y(),
+ aViewPort->getView() );
+
+ // Show the coordinates in the status bar
+ SUIT_Desktop* aDesktop = getApp()->desktop();
+ if ( aDesktop && aDesktop->statusBar() ) {
+ QString aX = HYDROGUI_Tool::GetCoordinateString( aPnt.X() );
+ QString anY = HYDROGUI_Tool::GetCoordinateString( aPnt.Y() );
+ aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );
+ }
+}
\ No newline at end of file