#include <HYDROData_PolylineXY.h>
#include <HYDROData_Object.h>
+#include <TopoDS_Face.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
HYDROGUI_LandCoverMapOp::HYDROGUI_LandCoverMapOp( HYDROGUI_Module* theModule, const int theOperationId )
: HYDROGUI_Operation( theModule ),
myOperationId( theOperationId ),
HYDROGUI_InputPanel* HYDROGUI_LandCoverMapOp::createInputPanel() const
{
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( addPolylines() ), SLOT( onAddPolylines() ) );
connect( aPanel, SIGNAL( removePolylines() ), SLOT( onRemovePolylines() ) );
*/
}
}
- // Get selected polyline/face
Handle(HYDROData_PolylineXY) aPolyline;
Handle(HYDROData_Object) aFace;
+
+ TopTools_ListOfShape aFacesSelectedInViewer;
+
+ // Get polyline/face selected in combo-box
if ( myOperationId == CreateLandCoverMapId || myOperationId == AddLandCoverId || myOperationId == SplitLandCoverId )
{
Handle(HYDROData_Entity) aPolylineFace = aPanel->getPolylineFace();
return false;
}
}
+ // Get face(s) selected in the 3d viewer
+ else if ( myOperationId == RemoveLandCoverId || myOperationId == MergeLandCoverId )
+ {
+ // TODO:
+ //Fill in aFacesSelectedInViewer list
+ }
// Get selected Strickler type
QString aSelectedStricklerType;
// Set land cover map name
aLandCoverMapObj->SetName( anObjectName );
+ // Add land cover to new / edited land cover map
if ( myOperationId == CreateLandCoverMapId || myOperationId == AddLandCoverId )
{
bool aLandCoverAdded = false;
return false;
}
}
-
- /*TCollection_AsciiString anError;
- if ( HYDROData_LandCover::buildShape( aZonePolylines, anError ).IsNull() )
+
+ // Remove land cover from edited land cover map
+ if ( myOperationId == RemoveLandCoverId )
+ {
+ bool aLandCoverRemoved = false;
+ if ( !aFacesSelectedInViewer.IsEmpty() )
+ {
+ aLandCoverRemoved = aLandCoverMapObj->Remove( aFacesSelectedInViewer );
+ if ( !aLandCoverRemoved )
+ {
+ theErrorMsg = tr( "LAND_COVER_NOT_REMOVED" );
+ return false;
+ }
+ }
+ }
+
+ // Split land cover(s) inside edited land cover map
+ if ( myOperationId == SplitLandCoverId )
{
- if ( !anError.IsEmpty() ) {
- theErrorMsg = HYDROGUI_Tool::ToQString( anError );
- } else {
- theErrorMsg = tr( "LAND_COVER_OBJECT_CANNOT_BE_CREATED" );
+ bool aLandCoverSplitted = false;
+ if ( !aPolyline.IsNull() )
+ aLandCoverSplitted = aLandCoverMapObj->Split( aPolyline );
+ else if ( !aFace.IsNull() )
+ {
+ // TODO:
+ //Get the complete boundary of the object face as the splitting polyline
+ Handle(HYDROData_PolylineXY) aBoundaryPolyline;
+ aLandCoverSplitted = aLandCoverMapObj->Split( aBoundaryPolyline );
}
- return false;
- }*/
+ if ( !aLandCoverSplitted )
+ {
+ theErrorMsg = tr( "LAND_COVER_NOT_SPLITTED" );
+ return false;
+ }
+ }
+ // Merge land covers inside edited land cover map
+ if ( myOperationId == MergeLandCoverId )
+ {
+ bool aLandCoverMerged = false;
+ if ( !aFacesSelectedInViewer.IsEmpty() )
+ {
+ aLandCoverMerged = aLandCoverMapObj->Merge( aFacesSelectedInViewer, aSelectedStricklerType );
+ if ( !aLandCoverMerged )
+ {
+ theErrorMsg = tr( "LAND_COVER_NOT_MERGED" );
+ return false;
+ }
+ }
+ }
+
/*if ( myOperationId == CreateLandCoverMapId )
{
aLandCoverMapObj->SetFillingColor( aLandCoverMapObj->DefaultFillingColor() );
aLandCoverMapObj->SetBorderColor( aLandCoverMapObj->DefaultBorderColor() );
}*/
- //aLandCoverMapObj->SetPolylines( aZonePolylines );
- //aLandCoverMapObj->SetStricklerType( aSelectedStricklerType );
+ // Update land cover map object and close preview
aLandCoverMapObj->Update();
closePreview();
+ // Publish the newly created land cover map in the Object Browser
module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aLandCoverMapObj, true );
if ( myOperationId == CreateLandCoverMapId )
{
theBrowseObjectsEntries.append( anEntry );
}
+ // Update presentation of land cover object in the 3d viewer
module()->setIsToUpdate( aLandCoverMapObj );
module()->getOCCDisplayer()->SetToUpdateColorScale();
return true;
}
-void HYDROGUI_LandCoverMapOp::onCreatePreview( const QStringList& thePolylineNames )
+void HYDROGUI_LandCoverMapOp::onLandCoverMapChanged( const QString& theName )
+{
+ // If the edited land cover map was changed in the combo-box, update myEditedObject
+ if ( myOperationId != CreateLandCoverMapId )
+ {
+ myEditedObject = Handle(HYDROData_LandCoverMap)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), theName ) );
+ if ( !myEditedObject.IsNull() )
+ {
+ // Show preview of the newly selected land cover map
+ QStringList aPolylineFaceNames;
+ onCreatePreview( aPolylineFaceNames );
+ }
+ }
+}
+
+void HYDROGUI_LandCoverMapOp::onCreatePreview( const QStringList& thePolylineFaceNames )
{
/*
HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverDlg*>( inputPanel() );