#include "HYDROGUI_OCCDisplayer.h"
#include "HYDROGUI_Operations.h"
#include "HYDROGUI_LandCoverMapDlg.h"
-#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_Tool2.h"
#include "HYDROGUI_UpdateFlags.h"
#include "HYDROGUI_DataObject.h"
#include "HYDROGUI_ShapeLandCoverMap.h"
+#include "HYDROGUI_OCCSelector.h"
#include <HYDROData_Iterator.h>
#include <HYDROData_StricklerTable.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
+#include <OCCViewer_ViewManager.h>
+
+#include <SalomeApp_Study.h>
#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_DataOwner.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_DataObject.h>
+#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <AIS_Shape.hxx>
#include <QApplication>
+#include <QMouseEvent>
HYDROGUI_LandCoverMapOp::HYDROGUI_LandCoverMapOp( HYDROGUI_Module* theModule, const int theOperationId )
: HYDROGUI_Operation( theModule ),
myOperationId( theOperationId ),
- myPreviewPrs( 0 )
+ myPreviewPrs( 0 ),
+ myPolylineFacePreviewPrs( 0 )
{
switch( myOperationId )
{
{
if ( isApplyAndClose() )
myEditedObject = Handle(HYDROData_LandCoverMap)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
- if ( !myEditedObject.IsNull() )
+
+ // Construct a list of names of all land cover map objects defined within the data model
+ QStringList aLandCoverMapNames;
+ HYDROData_Iterator anIterator( doc(), KIND_LAND_COVER_MAP );
+ for( ; anIterator.More(); anIterator.Next() )
{
- anObjectName = myEditedObject->GetName();
+ Handle(HYDROData_LandCoverMap) aLandCoverObj =
+ Handle(HYDROData_LandCoverMap)::DownCast( anIterator.Current() );
+ if ( !aLandCoverObj.IsNull() )
+ aLandCoverMapNames.append( aLandCoverObj->GetName() );
+ }
+
+ //aLandCoverMapNames.sort();
+ aPanel->setObjectNames( aLandCoverMapNames );
- // Construct a list of names of all land cover map objects defined within the data model
- QStringList aLandCoverMapNames;
- HYDROData_Iterator anIterator( doc(), KIND_LAND_COVER_MAP );
- for( ; anIterator.More(); anIterator.Next() )
+ if ( myEditedObject.IsNull() )
+ {
+ if ( !aLandCoverMapNames.empty() )
{
- Handle(HYDROData_LandCoverMap) aLandCoverObj =
- Handle(HYDROData_LandCoverMap)::DownCast( anIterator.Current() );
- if ( !aLandCoverObj.IsNull() )
- aLandCoverMapNames.append( aLandCoverObj->GetName() );
+ anObjectName = aLandCoverMapNames.first();
+ if ( !anObjectName.isEmpty())
+ {
+ Handle(HYDROData_LandCoverMap) anObject =
+ Handle(HYDROData_LandCoverMap)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), anObjectName ) );
+ if( !anObject.IsNull() )
+ myEditedObject = anObject;
+ }
}
-
- //aLandCoverMapNames.sort();
- aPanel->setObjectNames( aLandCoverMapNames );
}
+ else
+ anObjectName = myEditedObject->GetName();
}
aPanel->setObjectName( anObjectName );
closePreview();
- QStringList aPolylineFaceNames;
- onCreatePreview( aPolylineFaceNames );
+ if ( myOperationId != CreateLandCoverMapId )
+ onCreatePreview();
aPanel->blockSignals( false );
{
closePreview();
+ bool aNoActiveOps = module()->getActiveOperations().isEmpty();
+
HYDROGUI_Operation::abortOperation();
- module()->update( UF_OCCViewer | UF_FitAll );
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
+ if ( aStudy && !aNoActiveOps )
+ module()->update( UF_OCCViewer | UF_FitAll );
}
void HYDROGUI_LandCoverMapOp::commitOperation()
HYDROGUI_LandCoverMapDlg* aPanel = new HYDROGUI_LandCoverMapDlg( module(), getName(), myOperationId );
connect( aPanel, SIGNAL( landCoverMapChanged( const QString& ) ),
this, SLOT( onLandCoverMapChanged( const QString& ) ) );
- connect( aPanel, SIGNAL( CreatePreview( const QStringList& ) ),
- this, SLOT( onCreatePreview( const QStringList& ) ) );
+ connect( aPanel, SIGNAL( polylineFaceChanged() ),
+ this, SLOT( onPolylineFaceChanged() ) );
return aPanel;
}
myOperationId == ChangeLandCoverTypeId )
{
if ( myPreviewPrs )
- {
// Fill in aFacesSelectedInViewer list
- Handle(AIS_InteractiveContext) aCtx = getInteractiveContext();
- if ( !aCtx.IsNull() && aCtx->NbSelected() > 0 )
- {
- for ( aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected() )
- {
- TopoDS_Shape aSelectedShape = aCtx->SelectedShape();
- if ( aSelectedShape.IsNull() )
- continue;
-
- aFacesSelectedInViewer.Append( aSelectedShape );
- }
- }
- }
+ getSelectedShapes( aFacesSelectedInViewer );
}
// Get selected Strickler type
QString aSelectedStricklerType;
if ( myOperationId == CreateLandCoverMapId ||
myOperationId == AddLandCoverId ||
- myOperationId == MergeLandCoverId )
+ myOperationId == MergeLandCoverId ||
+ myOperationId == ChangeLandCoverTypeId )
{
aSelectedStricklerType = aPanel->getSelectedStricklerTypeName();
if ( aSelectedStricklerType.isEmpty() )
// Create / find the new / edited land cover map object
Handle(HYDROData_LandCoverMap) aLandCoverMapObj = myOperationId != CreateLandCoverMapId ? myEditedObject :
Handle(HYDROData_LandCoverMap)::DownCast( doc()->CreateObject( KIND_LAND_COVER_MAP ) );
+ if ( aLandCoverMapObj.IsNull() )
+ {
+ theErrorMsg = tr( "LAND_COVER_MAP_UNDEFINED" );
+ return false;
+ }
// Set land cover map name
aLandCoverMapObj->SetName( anObjectName );
// Split land cover(s) inside edited land cover map
if ( myOperationId == SplitLandCoverId )
{
- bool aLandCoverSplitted = false;
+ bool aLandCoverSplit = false;
if ( !aPolyline.IsNull() )
- aLandCoverSplitted = aLandCoverMapObj->Split( aPolyline );
+ aLandCoverSplit = aLandCoverMapObj->Split( aPolyline );
else if ( !aFace.IsNull() )
{
// Get the complete boundary of the object face as the splitting polyline
continue;
bool aSplitResult = aLandCoverMapObj->Split( aShape );
- aLandCoverSplitted = ( i==0 ? aSplitResult : aLandCoverSplitted && aSplitResult );
+ aLandCoverSplit = ( i==0 ? aSplitResult : aLandCoverSplit && aSplitResult );
}
}
- if ( !aLandCoverSplitted )
+ if ( !aLandCoverSplit )
{
- theErrorMsg = tr( "LAND_COVER_NOT_SPLITTED" );
+ theErrorMsg = tr( "LAND_COVER_NOT_SPLIT" );
return false;
}
}
}
}
}
+
+ // Change Strickler type for land cover(s) inside edited land cover map
+ if ( myOperationId == ChangeLandCoverTypeId )
+ {
+ bool aLandCoverChangeType = false;
+ if ( !aFacesSelectedInViewer.IsEmpty() )
+ {
+ aLandCoverChangeType = aLandCoverMapObj->ChangeType( aFacesSelectedInViewer, aSelectedStricklerType );
+ if ( !aLandCoverChangeType )
+ {
+ theErrorMsg = tr( "LAND_COVER_TYPE_NOT_CHANGED" );
+ return false;
+ }
+ }
+ }
// Update land cover map object and close preview
aLandCoverMapObj->Update();
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+ if ( myOperationId == CreateLandCoverMapId )
+ module()->enableLCMActions();
+
+ if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId )
+ aPanel->updateSelectedLandCoversLabel( getNbSelected() );
+
return true;
}
{
// Show preview of the newly selected land cover map
closePreview();
- QStringList aPolylineFaceNames;
- onCreatePreview( aPolylineFaceNames );
+ onCreatePreview();
}
}
}
-void HYDROGUI_LandCoverMapOp::onCreatePreview( const QStringList& thePolylineFaceNames )
+void HYDROGUI_LandCoverMapOp::onPolylineFaceChanged()
+{
+ HYDROGUI_LandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverMapDlg*>( 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<LightApp_DataOwner*>( 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<OCCViewer_ViewManager*>(
+ 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<HYDROGUI_LandCoverMapDlg*>( inputPanel() );
if ( !aPanel )
Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
if ( !aCtx.IsNull() )
{
- connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) );
+ if ( myOperationId == RemoveLandCoverId ||
+ myOperationId == MergeLandCoverId ||
+ myOperationId == ChangeLandCoverTypeId )
+ {
+ 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<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( aHydroSelector->viewer(), SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) );
+ connect( this, SIGNAL( deselection() ), aHydroSelector, SLOT( onDeselection() ) );
+ }
+ }
+ }
+
+ 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*/ );
}
}
}
- if ( aViewManager && myPreviewPrs )
+ if ( aViewManager && myPreviewPrs && !myEditedObject.IsNull() )
{
- TopoDS_Shape aLandCoverMapShape = myEditedObject->GetShape();
- if( !aLandCoverMapShape.IsNull() )
- {
- if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId)
- myPreviewPrs->setSelectionMode( AIS_Shape::SelectionMode( TopAbs_FACE ) );
- myPreviewPrs->setShape( aLandCoverMapShape );
- }
+ if ( myOperationId == RemoveLandCoverId ||
+ myOperationId == MergeLandCoverId ||
+ myOperationId == ChangeLandCoverTypeId )
+ myPreviewPrs->setSelectionMode( AIS_Shape::SelectionMode( TopAbs_FACE ) );
+ myPreviewPrs->update( false, false );
+
+ if ( myOperationId == ChangeLandCoverTypeId )
+ selectLandCoverInPreview();
}
module()->update( UF_OCCViewer | UF_FitAll );
if ( !aPanel )
return;
+ int aNbSelected = getNbSelected();
+
+ if ( myOperationId == RemoveLandCoverId || myOperationId == ChangeLandCoverTypeId )
+ // Enable Apply, Apply and Close buttons only if at least one face (land cover) is selected in the 3d viewer
+ aPanel->setApplyEnabled( aNbSelected > 0 );
+ else if ( myOperationId == MergeLandCoverId )
+ // Enable Apply, Apply and Close buttons only if at least two faces (land covers) are selected in the 3d viewer
+ aPanel->setApplyEnabled( aNbSelected > 1 );
+
+ if ( myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId )
+ {
+ if ( aNbSelected == 1 && !myEditedObject.IsNull() )
+ {
+ TopTools_ListOfShape aFacesSelectedInViewer;
+ getSelectedShapes( aFacesSelectedInViewer );
+ if ( aFacesSelectedInViewer.Extent() == 1 )
+ {
+ QString aType = myEditedObject->StricklerType( TopoDS::Face( aFacesSelectedInViewer.First() ) );
+ if ( !aType.isEmpty() )
+ aPanel->setSelectedStricklerTypeName( aType );
+ }
+ }
+ }
+
+ if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId )
+ aPanel->updateSelectedLandCoversLabel( aNbSelected );
+}
+
+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() )
+ if ( aCtx.IsNull() )
+ return;
+
+ myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
+
+ if (myStartPnt == myEndPnt)
{
- int aNbSelected = aCtx->NbSelected();
+ if ( !aViewer->isPreselectionEnabled() ) {
+ Handle(V3d_View) aView3d = aView->getViewPort()->getView();
+ if ( !aView3d.IsNull() ) {
+ aCtx->MoveTo(myEndPnt.x(), myEndPnt.y(), aView3d);
+ }
+ }
- if ( myOperationId == RemoveLandCoverId )
- aPanel->setApplyEnabled( aNbSelected > 0 );
- else if ( myOperationId == MergeLandCoverId )
- aPanel->setApplyEnabled( aNbSelected > 1 );
+ 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 )
+ if ( myPreviewPrs )
{
delete myPreviewPrs;
myPreviewPrs = 0;
}
+ if ( myPolylineFacePreviewPrs )
+ {
+ delete myPolylineFacePreviewPrs;
+ myPolylineFacePreviewPrs = 0;
+ }
+
HYDROGUI_LandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverMapDlg*>( inputPanel() );
if ( !aPanel )
return;
- if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId )
+ 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()
}
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();
+ }
+}