aParamLayout->addWidget( myStricklerTypesLabel, 1, 0, 1, 1 );
aParamLayout->addWidget( myStricklerTypes, 1, 1, 1, 1 );
+ // Label indicated the number of selected land covers
+ QString aDefaultLabel( "0" );
+ mySelectedLandCoversLabel = new QLabel( tr( "LAND_COVER_MAP_SELECTED_FACES" ) + aDefaultLabel, myParamGroup );
+ mySelectedLandCoversLabel->setStyleSheet("QLabel { font: italic; color : red; }");
+
// Common
addWidget( myObjectNameGroup );
addWidget( myParamGroup );
+ addWidget( mySelectedLandCoversLabel );
addStretch();
return myStricklerTypes->getSelectedStricklerTypeName();
}
+void HYDROGUI_LandCoverMapDlg::updateSelectedLandCoversLabel( int theNbSelected )
+{
+ QString aLabel;
+ aLabel.setNum( theNbSelected );
+ if ( theNbSelected == 0 )
+ mySelectedLandCoversLabel->setStyleSheet("QLabel { font: italic; color : red; }");
+ else
+ mySelectedLandCoversLabel->setStyleSheet("QLabel { font: italic; color : black; }");
+ mySelectedLandCoversLabel->setText( tr( "LAND_COVER_MAP_SELECTED_FACES" ) + aLabel );
+}
+
bool HYDROGUI_LandCoverMapDlg::isOk( const Handle(HYDROData_Entity)& theEntity ) const
{
Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast(theEntity);
myOperationId == ChangeLandCoverTypeId );
myStricklerTypesLabel->setVisible( aShowStricklerTypesCtrls );
myStricklerTypes->setVisible( aShowStricklerTypesCtrls );
+
+ bool aShowSelectedLandCoversLabel = ( myOperationId == RemoveLandCoverId ||
+ myOperationId == MergeLandCoverId ||
+ myOperationId == ChangeLandCoverTypeId );
+ mySelectedLandCoversLabel->setVisible( aShowSelectedLandCoversLabel );
}
else
{
myOperationId == ChangeLandCoverTypeId )
{
if ( myPreviewPrs )
- {
// Fill in aFacesSelectedInViewer list
- Handle(AIS_InteractiveContext) aCtx;
- getSelectedShapes( aFacesSelectedInViewer, aCtx );
- }
+ getSelectedShapes( aFacesSelectedInViewer );
}
// Get selected Strickler type
if ( aViewManager && myPreviewPrs && !myEditedObject.IsNull() )
{
- TopoDS_Shape aLandCoverMapShape = myEditedObject->GetShape();
- if( !aLandCoverMapShape.IsNull() )
- {
- if ( myOperationId == RemoveLandCoverId ||
- myOperationId == MergeLandCoverId ||
- myOperationId == ChangeLandCoverTypeId )
- 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;
- Handle(AIS_InteractiveContext) aCtx = getInteractiveContext();
- if ( !aCtx.IsNull() )
- {
- int aNbSelected = aCtx->NbSelected();
+ 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 == 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 ( myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId )
+ {
+ if ( aNbSelected == 1 && !myEditedObject.IsNull() )
{
- if ( aNbSelected == 1 && !myEditedObject.IsNull() )
+ TopTools_ListOfShape aFacesSelectedInViewer;
+ getSelectedShapes( aFacesSelectedInViewer );
+ if ( aFacesSelectedInViewer.Extent() == 1 )
{
- TopTools_ListOfShape aFacesSelectedInViewer;
- getSelectedShapes( aFacesSelectedInViewer, aCtx );
- if ( aFacesSelectedInViewer.Extent() == 1 )
- {
- QString aType = myEditedObject->StricklerType( TopoDS::Face( aFacesSelectedInViewer.First() ) );
- if ( !aType.isEmpty() )
- aPanel->setSelectedStricklerTypeName( aType );
- }
+ 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)
return aCtx;
}
-void HYDROGUI_LandCoverMapOp::getSelectedShapes( TopTools_ListOfShape& theSelectedShapes,
- Handle(AIS_InteractiveContext)& theCtx )
+void HYDROGUI_LandCoverMapOp::getSelectedShapes( TopTools_ListOfShape& theSelectedShapes )
{
- if ( theCtx.IsNull() )
- theCtx = getInteractiveContext();
-
- if ( !theCtx.IsNull() && theCtx->NbSelected() > 0 )
+ Handle(AIS_InteractiveContext) aCtx = getInteractiveContext();
+ if ( !aCtx.IsNull() )
{
- for ( theCtx->InitSelected(); theCtx->MoreSelected(); theCtx->NextSelected() )
+ for ( aCtx->InitSelected(); aCtx->MoreSelected(); aCtx->NextSelected() )
{
- TopoDS_Shape aSelectedShape = theCtx->SelectedShape();
+ TopoDS_Shape aSelectedShape = aCtx->SelectedShape();
if ( aSelectedShape.IsNull() )
continue;
}
}
}
+
+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();
+ }
+}