X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FHYDROGUI%2FHYDROGUI_LandCoverMapOp.cxx;h=3f54816fdc09b1c7a81bf4016691cd9454b9d499;hb=21456a609299f2ab340ea325a17c508c0748e45b;hp=1c83e787b722bba04fee5debae9ddd3b5126775e;hpb=c3aaf9774d926aa6095597b4d52a8858dc0898c5;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx b/src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx index 1c83e787..3f54816f 100644 --- a/src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx +++ b/src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx @@ -38,9 +38,13 @@ #include #include +#include + #include #include +#include #include +#include #include #include @@ -54,7 +58,8 @@ HYDROGUI_LandCoverMapOp::HYDROGUI_LandCoverMapOp( HYDROGUI_Module* theModule, const int theOperationId ) : HYDROGUI_Operation( theModule ), myOperationId( theOperationId ), - myPreviewPrs( 0 ) + myPreviewPrs( 0 ), + myPolylineFacePreviewPrs( 0 ) { switch( myOperationId ) { @@ -168,6 +173,8 @@ HYDROGUI_InputPanel* HYDROGUI_LandCoverMapOp::createInputPanel() const HYDROGUI_LandCoverMapDlg* aPanel = new HYDROGUI_LandCoverMapDlg( module(), getName(), myOperationId ); connect( aPanel, SIGNAL( landCoverMapChanged( const QString& ) ), this, SLOT( onLandCoverMapChanged( const QString& ) ) ); + connect( aPanel, SIGNAL( polylineFaceChanged() ), + this, SLOT( onPolylineFaceChanged() ) ); return aPanel; } @@ -382,6 +389,88 @@ void HYDROGUI_LandCoverMapOp::onLandCoverMapChanged( const QString& theName ) } } +void HYDROGUI_LandCoverMapOp::onPolylineFaceChanged() +{ + HYDROGUI_LandCoverMapDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + LightApp_DataOwner* aPolylineFaceDataOwner = NULL; + Handle(HYDROData_Entity) aPolylineFace = aPanel->getPolylineFace(); + if ( !aPolylineFace.IsNull() ) + { + // Select chosen polyline/face in the Object Browser, if it is not selected yet + // (i.e. object was chosen not in the Object Browser or 3d Viewer, but in combo-box) + aPolylineFaceDataOwner = new LightApp_DataOwner( HYDROGUI_DataObject::dataObjectEntry( aPolylineFace ) ); + LightApp_SelectionMgr* aSelectionMgr = module()->getApp()->selectionMgr(); + if ( aSelectionMgr ) + { + bool bIsAlreadySelected = false; + SUIT_DataOwnerPtrList aSelectedOwners; + aSelectionMgr->selected( aSelectedOwners ); + foreach( SUIT_DataOwner* aSUITOwner, aSelectedOwners ) + { + if ( LightApp_DataOwner* anOwner = dynamic_cast( aSUITOwner ) ) + { + if ( anOwner->entry() == aPolylineFaceDataOwner->entry() ) + { + bIsAlreadySelected = true; + break; + } + } + } + if ( !bIsAlreadySelected ) + { + SUIT_DataOwnerPtrList aList( true ); + aList.append( SUIT_DataOwnerPtr( aPolylineFaceDataOwner ) ); + aSelectionMgr->setSelected( aList ); + } + } + + // Show Preview of selected polyline/face + Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aPolylineFace ); + Handle(HYDROData_Object) aFace = Handle(HYDROData_Object)::DownCast( aPolylineFace ); + if ( !aPolyline.IsNull() || !aFace.IsNull() ) + { + TopoDS_Shape aTopoDSShape; + if ( !aPolyline.IsNull() ) + aTopoDSShape = aPolyline->GetShape(); + else + aTopoDSShape = aFace->GetTopShape(); + + OCCViewer_ViewManager* aViewManager = ::qobject_cast( + module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ); + if ( aViewManager ) + { + if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) + { + if ( myPolylineFacePreviewPrs ) + { + delete myPolylineFacePreviewPrs; + myPolylineFacePreviewPrs = 0; + } + + int aViewerId = (size_t)aViewer; + if ( !module()->isObjectVisible( aViewerId, aPolylineFace ) ) + { + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if ( !aCtx.IsNull() ) + { + myPolylineFacePreviewPrs = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() ); + aCtx->ClearSelected(); + + myPolylineFacePreviewPrs->setBorderColor( Qt::white, false, false ); + myPolylineFacePreviewPrs->setShape( aTopoDSShape, true, true, !aPolyline.IsNull() ? AIS_WireFrame : AIS_Shaded ); + + module()->update( UF_OCCViewer | UF_FitAll ); + } + } + } + } + } + } +} + void HYDROGUI_LandCoverMapOp::onCreatePreview() { HYDROGUI_LandCoverMapDlg* aPanel = ::qobject_cast( inputPanel() ); @@ -402,34 +491,41 @@ void HYDROGUI_LandCoverMapOp::onCreatePreview() Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); if ( !aCtx.IsNull() ) { - disconnect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), - aViewer, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); - disconnect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), - aViewer, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); - - connect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); - connect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); - - LightApp_SelectionMgr* aSelectionMgr = module()->getApp()->selectionMgr(); - if( aSelectionMgr ) + if ( myOperationId == RemoveLandCoverId || + myOperationId == MergeLandCoverId || + myOperationId == ChangeLandCoverTypeId ) { - QList aSelectorList; - aSelectionMgr->selectors( aViewManager->getType(), aSelectorList ); - QList::iterator anIter, anIterEnd = aSelectorList.end(); - for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ ) + disconnect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), + aViewer, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + disconnect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), + aViewer, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); + + connect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + connect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); + + LightApp_SelectionMgr* aSelectionMgr = module()->getApp()->selectionMgr(); + if ( aSelectionMgr ) { - HYDROGUI_OCCSelector* aHydroSelector = dynamic_cast( *anIter ); - if ( aHydroSelector ) + QList aSelectorList; + aSelectionMgr->selectors( aViewManager->getType(), aSelectorList ); + QList::iterator anIter, anIterEnd = aSelectorList.end(); + for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ ) { - disconnect( aHydroSelector->viewer(), SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) ); - connect( this, SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) ); + HYDROGUI_OCCSelector* aHydroSelector = dynamic_cast( *anIter ); + if ( aHydroSelector ) + { + disconnect( aHydroSelector->viewer(), SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) ); + connect( this, SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) ); + } } } - } - connect( this, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) ); + connect( this, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) ); + } + else + connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) ); myPreviewPrs = new HYDROGUI_ShapeLandCoverMap( module()->getOCCDisplayer(), aCtx, myEditedObject, getPreviewZLayer()/*, theIsScalarMapMode*/ ); } } @@ -552,12 +648,18 @@ void HYDROGUI_LandCoverMapOp::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseE void HYDROGUI_LandCoverMapOp::closePreview() { - if( myPreviewPrs ) + if ( myPreviewPrs ) { delete myPreviewPrs; myPreviewPrs = 0; } + if ( myPolylineFacePreviewPrs ) + { + delete myPolylineFacePreviewPrs; + myPolylineFacePreviewPrs = 0; + } + HYDROGUI_LandCoverMapDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) return; @@ -565,33 +667,38 @@ void HYDROGUI_LandCoverMapOp::closePreview() if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId ) aPanel->setApplyEnabled( false ); - OCCViewer_ViewManager* aViewManager = getPreviewManager(); - if ( aViewManager ) + if ( myOperationId == RemoveLandCoverId || + myOperationId == MergeLandCoverId || + myOperationId == ChangeLandCoverTypeId ) { - if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) + OCCViewer_ViewManager* aViewManager = getPreviewManager(); + if ( aViewManager ) { - disconnect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); - disconnect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); - connect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), - aViewer, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); - connect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), - aViewer, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); - - LightApp_SelectionMgr* aSelectionMgr = module()->getApp()->selectionMgr(); - if( aSelectionMgr ) + if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) { - QList aSelectorList; - aSelectionMgr->selectors( aViewManager->getType(), aSelectorList ); - QList::iterator anIter, anIterEnd = aSelectorList.end(); - for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ ) + disconnect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + disconnect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); + connect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), + aViewer, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + connect(aViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), + aViewer, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); + + LightApp_SelectionMgr* aSelectionMgr = module()->getApp()->selectionMgr(); + if ( aSelectionMgr ) { - HYDROGUI_OCCSelector* aHydroSelector = dynamic_cast( *anIter ); - if ( aHydroSelector ) + QList aSelectorList; + aSelectionMgr->selectors( aViewManager->getType(), aSelectorList ); + QList::iterator anIter, anIterEnd = aSelectorList.end(); + for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ ) { - disconnect( this, SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) ); - connect( aHydroSelector->viewer(), SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) ); + HYDROGUI_OCCSelector* aHydroSelector = dynamic_cast( *anIter ); + if ( aHydroSelector ) + { + disconnect( this, SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) ); + connect( aHydroSelector->viewer(), SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) ); + } } } }