#include <LightApp_Application.h>
+#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
aPanel->setObjectName( anObjectName );
closePreview();
- QStringList aPolylineFaceNames;
- onCreatePreview( aPolylineFaceNames );
+ if ( myOperationId != CreateLandCoverMapId )
+ onCreatePreview();
aPanel->blockSignals( false );
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& ) ) );
return aPanel;
}
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 );
- }
- }
+ Handle(AIS_InteractiveContext) aCtx;
+ getSelectedShapes( aFacesSelectedInViewer, aCtx );
}
}
QString aSelectedStricklerType;
if ( myOperationId == CreateLandCoverMapId ||
myOperationId == AddLandCoverId ||
- myOperationId == MergeLandCoverId )
+ myOperationId == MergeLandCoverId ||
+ myOperationId == ChangeLandCoverTypeId )
{
aSelectedStricklerType = aPanel->getSelectedStricklerTypeName();
if ( aSelectedStricklerType.isEmpty() )
}
}
}
+
+ // 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();
{
// 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::onCreatePreview()
{
HYDROGUI_LandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverMapDlg*>( inputPanel() );
if ( !aPanel )
TopoDS_Shape aLandCoverMapShape = myEditedObject->GetShape();
if( !aLandCoverMapShape.IsNull() )
{
- if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId)
+ if ( myOperationId == RemoveLandCoverId ||
+ myOperationId == MergeLandCoverId ||
+ myOperationId == ChangeLandCoverTypeId )
myPreviewPrs->setSelectionMode( AIS_Shape::SelectionMode( TopAbs_FACE ) );
myPreviewPrs->setShape( aLandCoverMapShape );
}
{
int aNbSelected = aCtx->NbSelected();
- if ( myOperationId == RemoveLandCoverId )
+ 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, aCtx );
+ if ( aFacesSelectedInViewer.Extent() == 1 )
+ {
+ QString aType = myEditedObject->StricklerType( TopoDS::Face( aFacesSelectedInViewer.First() ) );
+ if ( !aType.isEmpty() )
+ aPanel->setSelectedStricklerTypeName( aType );
+ }
+ }
+ }
}
}
if ( !aPanel )
return;
- if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId )
+ if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId || myOperationId == ChangeLandCoverTypeId )
aPanel->setApplyEnabled( false );
}
}
return aCtx;
}
+
+void HYDROGUI_LandCoverMapOp::getSelectedShapes( TopTools_ListOfShape& theSelectedShapes,
+ Handle(AIS_InteractiveContext)& theCtx )
+{
+ if ( theCtx.IsNull() )
+ theCtx = getInteractiveContext();
+
+ if ( !theCtx.IsNull() && theCtx->NbSelected() > 0 )
+ {
+ for ( theCtx->InitSelected(); theCtx->MoreSelected(); theCtx->NextSelected() )
+ {
+ TopoDS_Shape aSelectedShape = theCtx->SelectedShape();
+ if ( aSelectedShape.IsNull() )
+ continue;
+
+ theSelectedShapes.Append( aSelectedShape );
+ }
+ }
+}