From: mkr Date: Mon, 16 Nov 2015 12:50:03 +0000 (+0300) Subject: refs #669, #677: selection of land covers in extended mode without pressing Shift... X-Git-Tag: v1.5~41 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=39a306b77b32044c89bf6cef4445d5bfdea43149;p=modules%2Fhydro.git refs #669, #677: selection of land covers in extended mode without pressing Shift/Ctrl buttons, fix bug about label of land cover maps sub-tree in the Object Browser. --- diff --git a/src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx b/src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx index a04f5a1c..2ee43916 100644 --- a/src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx +++ b/src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx @@ -26,6 +26,7 @@ #include "HYDROGUI_UpdateFlags.h" #include "HYDROGUI_DataObject.h" #include "HYDROGUI_ShapeLandCoverMap.h" +#include "HYDROGUI_OCCSelector.h" #include #include @@ -34,8 +35,12 @@ #include #include +#include +#include #include +#include +#include #include #include @@ -44,6 +49,7 @@ #include #include +#include HYDROGUI_LandCoverMapOp::HYDROGUI_LandCoverMapOp( HYDROGUI_Module* theModule, const int theOperationId ) : HYDROGUI_Operation( theModule ), @@ -378,7 +384,34 @@ void HYDROGUI_LandCoverMapOp::onCreatePreview() Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); if ( !aCtx.IsNull() ) { - connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) ); + 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 ) + { + QList aSelectorList; + aSelectionMgr->selectors( aViewManager->getType(), aSelectorList ); + QList::iterator anIter, anIterEnd = aSelectorList.end(); + for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ ) + { + 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() ) ); myPreviewPrs = new HYDROGUI_ShapeLandCoverMap( module()->getOCCDisplayer(), aCtx, myEditedObject, getPreviewZLayer()/*, theIsScalarMapMode*/ ); } } @@ -437,6 +470,70 @@ void HYDROGUI_LandCoverMapOp::onViewerSelectionChanged() } } +void HYDROGUI_LandCoverMapOp::onMousePress(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent) +{ + myStartPnt.setX(theEvent->x()); myStartPnt.setY(theEvent->y()); +} + +void HYDROGUI_LandCoverMapOp::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent) +{ + if (theEvent->button() != Qt::LeftButton) return; + if (!theWindow->inherits("OCCViewer_ViewWindow")) return; + + OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow; + if (!aView ) + return; + + OCCViewer_ViewManager* aViewManager = getPreviewManager(); + if ( !aViewManager ) + return; + + OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer(); + if ( !aViewer ) + return; + + Handle(AIS_InteractiveContext) aCtx = getInteractiveContext(); + if ( aCtx.IsNull() ) + return; + + myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y()); + + if (myStartPnt == myEndPnt) + { + if ( !aViewer->isPreselectionEnabled() ) { + Handle(V3d_View) aView3d = aView->getViewPort()->getView(); + if ( !aView3d.IsNull() ) { + aCtx->MoveTo(myEndPnt.x(), myEndPnt.y(), aView3d); + } + } + + Handle(StdSelect_ViewerSelector3d) aMainSelector = aCtx->MainSelector(); + if ( aMainSelector.IsNull() ) + return; + const Standard_Integer aDetectedNb = aMainSelector->NbPicked(); + if ( aDetectedNb == 0 ) + { + aCtx->ClearSelected( false ); + emit deselection(); + } + + for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter) + { + Handle(SelectMgr_EntityOwner) anOwner = aMainSelector->Picked (aDetIter); + aCtx->AddOrRemoveSelected( anOwner, Standard_False ); + } + } + else + { + aCtx->ShiftSelect(myStartPnt.x(), myStartPnt.y(), + myEndPnt.x(), myEndPnt.y(), + aView->getViewPort()->getView(), Standard_False ); + } + + aCtx->UpdateCurrentViewer(); + emit selectionChanged(); +} + void HYDROGUI_LandCoverMapOp::closePreview() { if( myPreviewPrs ) @@ -451,6 +548,39 @@ void HYDROGUI_LandCoverMapOp::closePreview() if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId ) aPanel->setApplyEnabled( false ); + + OCCViewer_ViewManager* aViewManager = getPreviewManager(); + if ( aViewManager ) + { + if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) + { + 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 ) + { + QList aSelectorList; + aSelectionMgr->selectors( aViewManager->getType(), aSelectorList ); + QList::iterator anIter, anIterEnd = aSelectorList.end(); + for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ ) + { + HYDROGUI_OCCSelector* aHydroSelector = dynamic_cast( *anIter ); + if ( aHydroSelector ) + { + disconnect( this, SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) ); + connect( aHydroSelector->viewer(), SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) ); + } + } + } + } + } } Handle(AIS_InteractiveContext) HYDROGUI_LandCoverMapOp::getInteractiveContext() diff --git a/src/HYDROGUI/HYDROGUI_LandCoverMapOp.h b/src/HYDROGUI/HYDROGUI_LandCoverMapOp.h index 1a33bf25..0c08817e 100644 --- a/src/HYDROGUI/HYDROGUI_LandCoverMapOp.h +++ b/src/HYDROGUI/HYDROGUI_LandCoverMapOp.h @@ -25,6 +25,9 @@ #include +class SUIT_ViewWindow; +class QMouseEvent; + class HYDROGUI_LandCoverMapOp : public HYDROGUI_Operation { Q_OBJECT @@ -45,10 +48,16 @@ protected: virtual HYDROGUI_Shape* getPreviewShape() const { return myPreviewPrs; }; +signals: + void selectionChanged(); + void deselection(); + protected slots: void onLandCoverMapChanged( const QString& theName ); void onCreatePreview(); void onViewerSelectionChanged(); + void onMousePress(SUIT_ViewWindow*, QMouseEvent*); + void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); private: void closePreview(); @@ -62,6 +71,8 @@ private: Handle(HYDROData_LandCoverMap) myEditedObject; HYDROGUI_Shape* myPreviewPrs; + + QPoint myStartPnt, myEndPnt; }; #endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index bc48132d..0a58c3f6 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -88,8 +88,8 @@ STRICKLER TABLES - LAND_COVERS - LAND COVERS + LAND_COVER_MAPS + LAND COVER MAPS ARTIFICIAL_OBJECTS @@ -369,10 +369,6 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) RESULTS_ON_GEOMETRY_OBJECTS Results on geometry objects - - RESULTS_ON_LAND_COVERS - Results on land covers - REGENERATE_COLORS Regenerate colors