return aResult;
}
+/**
+ Change Strickler type for the list of faces to the given one
+ @param theFaces the faces to change type
+ @param theType the Strickler type for the given land cover(s)
+ @return if the change type operation is successful
+*/
+bool HYDROData_LandCoverMap::ChangeType( const TopTools_ListOfShape& theFaces, const QString& theType )
+{
+ HYDROData_MapOfFaceToStricklerType aFacesToChangeType;
+ TopTools_ListIteratorOfListOfShape aFIt( theFaces );
+ for( ; aFIt.More(); aFIt.Next() )
+ {
+ TopoDS_Shape aShape = aFIt.Value();
+ if( aShape.ShapeType()==TopAbs_FACE )
+ aFacesToChangeType.Add( TopoDS::Face( aShape ), "" );
+ }
+
+ int aNbChanges = 0;
+ Iterator anIt( *this );
+ for( ; anIt.More(); anIt.Next() )
+ if( aFacesToChangeType.Contains( anIt.Face() ) )
+ {
+ anIt.SetStricklerType( theType );
+ aNbChanges++;
+ }
+ if ( aNbChanges != theFaces.Extent() )
+ return false;
+
+ return true;
+}
+
/**
Get the shape of the land cover map
*/
return HYDROData_Entity::GetShape( DataTag_Shape );
}
+/**
+ Get Strickler type of the given land cover
+ @param theLandCover the land cover to get Strickler type of
+ @return name of Strickler type
+*/
+QString HYDROData_LandCoverMap::StricklerType( const TopoDS_Face& theLandCover ) const
+{
+ QString aType = "";
+
+ Iterator anIt( *this );
+ for( ; anIt.More(); anIt.Next() )
+ if( anIt.Face().IsEqual( theLandCover) )
+ {
+ aType = anIt.StricklerType();
+ break;
+ }
+
+ return aType;
+}
+
/**
Set the shape of the land cover map
@param theShape the new shape for the land cover map
HYDRODATA_EXPORT bool Split( const TopoDS_Shape& );
HYDRODATA_EXPORT bool Merge( const TopTools_ListOfShape&, const QString& theType );
+ HYDRODATA_EXPORT bool ChangeType( const TopTools_ListOfShape&, const QString& theType );
+
HYDRODATA_EXPORT TopoDS_Face FindByPoint( const gp_Pnt2d&, QString& theType ) const;
HYDRODATA_EXPORT TopoDS_Shape GetShape() const;
+ HYDRODATA_EXPORT QString StricklerType( const TopoDS_Face& ) const;
+
HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
HYDRODATA_EXPORT int GetLCCount() const;
anEmptyPolylineFaceName = getPolylineFaceName().isEmpty();
setApplyEnabled( !anEmptyObjectName && !anEmptyPolylineFaceName );
-
- // TODO:
- //if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId ) => enable Apply,
- //Apply and Close buttons only if at least one face (land cover) is selected in the 3d viewer
}
}
#include <LightApp_Application.h>
+#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
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();
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 );
+ }
+ }
+}
void closePreview();
Handle(AIS_InteractiveContext) getInteractiveContext();
+ void getSelectedShapes( TopTools_ListOfShape& theSelectedShapes,
+ Handle(AIS_InteractiveContext)& theCtx );
private:
int myOperationId;
theMenu->addSeparator();
theMenu->addAction( action( SplitLandCoverId ) );
theMenu->addAction( action( MergeLandCoverId ) );
+ theMenu->addAction( action( ChangeLandCoverTypeId ) );
theMenu->addSeparator();
//
theMenu->addAction( action( ExportToShapeFileID ) );
case RemoveLandCoverId:
case SplitLandCoverId:
case MergeLandCoverId:
- anOp = new HYDROGUI_LandCoverMapOp( aModule, theId );
- break;
case ChangeLandCoverTypeId:
anOp = new HYDROGUI_LandCoverMapOp( aModule, theId );
break;
<source>MERGE_LAND_COVER_ICO</source>
<translation>icon_merge_land_cover.png</translation>
</message>
+ <message>
+ <source>CHANGE_LAND_COVER_TYPE_ICO</source>
+ <translation>icon_change_land_cover_type.png</translation>
+ </message>
<message>
<source>IMPORT_OBSTACLE_FROM_FILE_ICO</source>
<source>DSK_MERGE_LAND_COVER</source>
<translation>Merge land covers</translation>
</message>
+ <message>
+ <source>DSK_CHANGE_LAND_COVER_TYPE</source>
+ <translation>Change land cover(s) type</translation>
+ </message>
<message>
<source>DSK_COPY</source>
<translation>Copy</translation>
<source>MEN_MERGE_LAND_COVER</source>
<translation>Merge land covers</translation>
</message>
+ <message>
+ <source>MEN_CHANGE_LAND_COVER_TYPE</source>
+ <translation>Change land cover(s) type</translation>
+ </message>
<message>
<source>MEN_CUT_IMAGES</source>
<translation>Cut images</translation>
<source>STB_MERGE_LAND_COVER</source>
<translation>Merge land covers</translation>
</message>
+ <message>
+ <source>STB_CHANGE_LAND_COVER_TYPE</source>
+ <translation>Change land cover(s) type</translation>
+ </message>
<message>
<source>STB_COPY</source>
<translation>Copy</translation>
<source>MERGE_LAND_COVER</source>
<translation>Merge land covers inside the land cover map</translation>
</message>
+ <message>
+ <source>CHANGE_LAND_COVER_TYPE</source>
+ <translation>Change Strickler type(s) assigned to the land cover(s) inside the land cover map</translation>
+ </message>
<message>
<source>POLYLINE_FACE_NOT_DEFINED</source>
<translation>Polyline / Face object should be defined.</translation>
<source>LAND_COVER_NOT_MERGED</source>
<translation>Land cover can not be merged.</translation>
</message>
+ <message>
+ <source>LAND_COVER_TYPE_NOT_CHANGED</source>
+ <translation>Strickler type can not be changed for all selected land covers.</translation>
+ </message>
<message>
<source>LAND_COVER_OBJECT_CANNOT_BE_CREATED</source>
<translation>Land Cover object can not be created</translation>