+
+ if ( myPolylineFacePreviewPrs )
+ {
+ delete myPolylineFacePreviewPrs;
+ myPolylineFacePreviewPrs = 0;
+ }
+
+ HYDROGUI_LandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverMapDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId )
+ aPanel->setApplyEnabled( false );
+
+ if ( myOperationId == RemoveLandCoverId ||
+ myOperationId == MergeLandCoverId ||
+ myOperationId == ChangeLandCoverTypeId )
+ {
+ 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<SUIT_Selector*> aSelectorList;
+ aSelectionMgr->selectors( aViewManager->getType(), aSelectorList );
+ QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
+ for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
+ {
+ HYDROGUI_OCCSelector* aHydroSelector = dynamic_cast<HYDROGUI_OCCSelector*>( *anIter );
+ if ( aHydroSelector )
+ {
+ disconnect( this, SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) );
+ connect( aHydroSelector->viewer(), SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+Handle(AIS_InteractiveContext) HYDROGUI_LandCoverMapOp::getInteractiveContext()
+{
+ OCCViewer_ViewManager* aViewManager = getPreviewManager();
+ Handle(AIS_InteractiveContext) aCtx = NULL;
+ if ( aViewManager ) {
+ if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
+ aCtx = aViewer->getAISContext();
+ }
+ }
+ return aCtx;
+}
+
+void HYDROGUI_LandCoverMapOp::getSelectedShapes( TopTools_ListOfShape& theSelectedShapes )
+{
+ Handle(AIS_InteractiveContext) aCtx = getInteractiveContext();
+ if ( !aCtx.IsNull() )
+ {
+ for ( aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected() )
+ {
+ TopoDS_Shape aSelectedShape = aCtx->SelectedShape();
+ if ( aSelectedShape.IsNull() )
+ continue;
+
+ theSelectedShapes.Append( aSelectedShape );
+ }
+ }
+}
+
+int HYDROGUI_LandCoverMapOp::getNbSelected()
+{
+ int aNbSelected = 0;
+
+ Handle(AIS_InteractiveContext) aCtx = getInteractiveContext();
+ if ( !aCtx.IsNull() )
+ {
+ for ( aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected() )
+ {
+ TopoDS_Shape aSelectedShape = aCtx->SelectedShape();
+ if ( aSelectedShape.IsNull() )
+ continue;
+ aNbSelected++;
+ }
+ }
+
+ return aNbSelected;
+}
+
+void HYDROGUI_LandCoverMapOp::selectLandCoverInPreview()
+{
+ if ( myPreviewPrs && !myEditedObject.IsNull() && myEditedObject->GetLCCount() == 1 )
+ {
+ OCCViewer_ViewManager* aViewManager = getPreviewManager();
+ if ( !aViewManager )
+ return;
+
+ Handle(AIS_InteractiveContext) aCtx = getInteractiveContext();
+ if ( aCtx.IsNull() )
+ return;
+
+ OCCViewer_ViewWindow* aViewWindow = (OCCViewer_ViewWindow*)aViewManager->getActiveView();
+ if ( !aViewWindow )
+ return;
+
+ OCCViewer_ViewPort3d* aViewPort = aViewWindow->getViewPort();
+ if ( !aViewPort )
+ return;
+
+ Handle(V3d_View) aView = aViewPort->getView();
+ if ( aView.IsNull() )
+ return;
+
+ aCtx->ShiftSelect( 0, 0, aViewPort->width(), aViewPort->height(), aView, Standard_False );
+ aCtx->UpdateCurrentViewer();
+ emit selectionChanged();
+ }