#include "HYDROData_PolylineXY.h"
+#include <BRepBuilderAPI_MakeFace.hxx>
#include <TDataStd_AsciiString.hxx>
#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <NCollection_IncAllocator.hxx>
+#include <BOPAlgo_BOP.hxx>
+#include <QColor>
#include <QStringList>
IMPLEMENT_STANDARD_HANDLE( HYDROData_LandCover, HYDROData_Entity )
return GetReferenceObjects( DataTag_Polylines );
}
+TopoDS_Shape HYDROData_LandCover::GetShape() const
+{
+ TopoDS_Shape aShape;
+
+ TDF_Label aLabel = myLab.FindChild( DataTag_Shape, false );
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TNaming_NamedShape) aNamedShape;
+ if( aLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) ) {
+ aShape = aNamedShape->Get();
+ }
+ }
+
+ return aShape;
+}
+
+void HYDROData_LandCover::SetFillingColor( const QColor& theColor )
+{
+ SetColor( theColor, DataTag_FillingColor );
+}
+
+QColor HYDROData_LandCover::GetFillingColor() const
+{
+ return GetColor( DefaultFillingColor(), DataTag_FillingColor );
+}
+
+void HYDROData_LandCover::SetBorderColor( const QColor& theColor )
+{
+ SetColor( theColor, DataTag_BorderColor );
+}
+
+QColor HYDROData_LandCover::GetBorderColor() const
+{
+ return GetColor( DefaultBorderColor(), DataTag_BorderColor );
+}
+
+QColor HYDROData_LandCover::DefaultFillingColor()
+{
+ return QColor( Qt::magenta );
+}
+
+QColor HYDROData_LandCover::DefaultBorderColor()
+{
+ return QColor( Qt::transparent );
+}
+
void HYDROData_LandCover::setShape( const TopoDS_Shape& theShape )
{
TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) );
TopoDS_Shape aResShape;
///< \TODO to be reimplemented
+ TopoDS_Shape anArgShape;
+ TopTools_ListOfShape aToolShapes;
+
HYDROData_SequenceOfObjects aRefPolylines = GetPolylines();
for ( int i = 1, n = aRefPolylines.Length(); i <= n; ++i ) {
Handle(HYDROData_PolylineXY) aPolyline =
continue;
}
- if ( aPolyline->IsClosed() ) {
- aResShape = aPolyline->GetShape();
- break;
+ if ( !aPolyline->IsClosed() ) {
+ continue;
+ }
+
+ TopoDS_Shape aPolyShape = aPolyline->GetShape();
+ if ( aPolyShape.IsNull() || aPolyShape.ShapeType() != TopAbs_WIRE ) {
+ continue;
+ }
+
+ const TopoDS_Wire& aPolylineWire = TopoDS::Wire( aPolyShape );
+ if ( aPolylineWire.IsNull() ) {
+ continue;
+ }
+
+ TopoDS_Face aResultFace = TopoDS_Face();
+ BRepBuilderAPI_MakeFace aMakeFace( aPolylineWire, Standard_True );
+ aMakeFace.Build();
+ if( aMakeFace.IsDone() ) {
+ aResultFace = aMakeFace.Face();
+ }
+
+ if( aResultFace.IsNull() ) {
+ continue;
+ }
+
+ if ( anArgShape.IsNull() ) {
+ anArgShape = aResultFace;
+ } else {
+ aToolShapes.Append( aResultFace );
+ }
+ }
+
+ aResShape = anArgShape;
+
+ if ( !anArgShape.IsNull() && aToolShapes.Extent() > 0 ) {
+ Handle(NCollection_BaseAllocator)aAL=new NCollection_IncAllocator;
+ BOPAlgo_BOP aBOP(aAL);
+
+ aBOP.AddArgument( anArgShape );
+
+ TopTools_ListIteratorOfListOfShape anIt(aToolShapes);
+ for( ; anIt.More(); anIt.Next() ) {
+ aBOP.AddTool( anIt.Value() );
+ }
+
+ aBOP.SetOperation( BOPAlgo_CUT );
+ aBOP.Perform();
+
+ if ( !aBOP.Shape().IsNull() ) {
+ aResShape = aBOP.Shape();
}
}
+
return aResShape;
}
\ No newline at end of file
DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
DataTag_Shape, ///< the shape presentation of the land cover
DataTag_StricklerType, ///< the type corresponding to types in the Strickler tables
- DataTag_Polylines ///< the set of reference polylines
+ DataTag_Polylines, ///< the set of reference polylines
+ DataTag_FillingColor, ///< filling color of the land cover presentation
+ DataTag_BorderColor ///< border color of the land cover presentation
};
HYDRODATA_EXPORT HYDROData_LandCover();
*/
HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetPolylines() const;
+ /**
+ * Returns the shape presentation of the land cover.
+ */
+ HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() const;
+
+ /**
+ * Sets filling color for land cover.
+ */
+ HYDRODATA_EXPORT virtual void SetFillingColor( const QColor& theColor );
+
+ /**
+ * Returns filling color of land cover.
+ */
+ HYDRODATA_EXPORT virtual QColor GetFillingColor() const;
+
+ /**
+ * Sets border color for land cover.
+ */
+ HYDRODATA_EXPORT virtual void SetBorderColor( const QColor& theColor );
+
+ /**
+ * Returns border color of land cover.
+ */
+ HYDRODATA_EXPORT virtual QColor GetBorderColor() const;
+
+ /**
+ * Returns default filling color for new land cover.
+ */
+ HYDRODATA_EXPORT static QColor DefaultFillingColor();
+
+ /**
+ * Returns default border color for new land cover.
+ */
+ HYDRODATA_EXPORT static QColor DefaultBorderColor();
+
protected:
/**
- * Sets shape presentation of the land cover.
+ * Sets the shape presentation of the land cover.
*/
HYDRODATA_EXPORT virtual void setShape( const TopoDS_Shape& theShape );
aKind == KIND_SHAPES_GROUP || aKind == KIND_SPLITTED_GROUP || aKind == KIND_ZONE ||
aKind == KIND_IMMERSIBLE_ZONE || aKind == KIND_REGION || aKind == KIND_BATHYMETRY ||
aKind == KIND_OBSTACLE || aKind == KIND_STREAM || aKind == KIND_CHANNEL ||
- aKind == KIND_DIGUE || aKind == KIND_DUMMY_3D;
+ aKind == KIND_DIGUE || aKind == KIND_DUMMY_3D || aKind == KIND_LAND_COVER;
if ( !visibility )
{
Handle(HYDROData_Profile) aProfObj = Handle(HYDROData_Profile)::DownCast( theModelObject );
{
anObjectName = myEditedObject->GetName();
- // TODO: Temporary commented until getPolylinesCount, GetPolyline and GetStricklerType data model methods will be implemented
- /*
- int nNoPolylines = myEditedObject->getPolylinesCount();
- for (int i=0; i<nNoPolylines; i++)
- {
- Handle(HYDROData_PolylineXY) aRefPolyline = myEditedObject->GetPolyline(i);
- if ( !aRefPolyline.IsNull() )
- aSelectedPolylines.append( aRefPolyline->GetName() );
+ HYDROData_SequenceOfObjects aRefPolylines = myEditedObject->GetPolylines();
+ for ( int i = aRefPolylines.Lower(); i <= aRefPolylines.Upper(); i++ ) {
+ Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aRefPolylines.Value( i ) );
+ if ( !aPolyline.IsNull() ) {
+ aSelectedPolylines.append( aPolyline->GetName() );
+ }
}
-
- aSelectedStricklerType = myEditedObject->GetStricklerType();
- */
-
- // The code below is a sample of data filling Land cover object
- aSelectedPolylines.append( "Lake_1" );
- aSelectedPolylines.append( "Polyline_1" );
- aSelectedStricklerType = "Canaux naturels";
}
+
+ aSelectedStricklerType = myEditedObject->GetStricklerType();
}
aPanel->setObjectName( anObjectName );
}
}
- QList<Handle(HYDROData_PolylineXY)> aZonePolylines;
+ HYDROData_SequenceOfObjects aZonePolylines;
QString aStricklerType;
QStringList aSelectedPolylineNames = aPanel->getSelectedPolylineNames();
QString aPolylineName = *anIt;
if ( !aPolylineName.isEmpty() )
{
- aZonePolylines.append( Handle(HYDROData_PolylineXY)::DownCast(
+ aZonePolylines.Append( Handle(HYDROData_PolylineXY)::DownCast(
HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) ) );
}
}
aZoneObj->SetName( anObjectName );
- // TODO: Temporary commented until SetFillingColor, DefaultFillingColor,
- // SetBorderColor and DefaultBorderColor data model methods will be implemented
- /*
if ( !myIsEdit )
{
aZoneObj->SetFillingColor( HYDROData_LandCover::DefaultFillingColor() );
aZoneObj->SetBorderColor( HYDROData_LandCover::DefaultBorderColor() );
}
- */
- // TODO: Temporary commented until SetPolylines and SetStricklerType data model methods will be implemented
- //aZoneObj->SetPolylines( aZonePolylines );
- //aZoneObj->SetStricklerType( aSelectedStricklerType );
+ aZoneObj->SetPolylines( aZonePolylines );
+ aZoneObj->SetStricklerType( aSelectedStricklerType );
aZoneObj->Update();
closePreview();
anIsImmersibleZone || anIsZone || anIsRegion ||
anIsBathymetry || anIsObstacle || anIsStream ||
anIsChannel || anIsDigue || anIsDummyObject3D ||
- anIsValidProfile || anIsGroup )
+ anIsValidProfile || anIsGroup || anIsLandCover )
{
if( anIsHiddenInSelection )
theMenu->addAction( action( ShowId ) );
#include <HYDROData_Object.h>
#include <HYDROData_IPolyline.h>
+#include <HYDROData_LandCover.h>
#include <LightApp_Application.h>
#include <LightApp_UpdateFlags.h>
return false;
return theObject->IsKind( STANDARD_TYPE(HYDROData_Object) ) ||
- theObject->IsKind( STANDARD_TYPE(HYDROData_IPolyline) );
+ theObject->IsKind( STANDARD_TYPE(HYDROData_IPolyline) ) ||
+ theObject->IsKind( STANDARD_TYPE(HYDROData_LandCover) );
}
void HYDROGUI_SetColorOp::startOperation()
anIsOneColor = true;
}
+ else if ( myEditedObject->IsKind( STANDARD_TYPE(HYDROData_LandCover) ) )
+ {
+ Handle(HYDROData_LandCover) aLandCover =
+ Handle(HYDROData_LandCover)::DownCast( myEditedObject );
+
+ aFirstColor = aLandCover->GetFillingColor();
+ aSecondColor = aLandCover->GetBorderColor();
+ }
// Create color dialog
myColorDlg = new HYDROGUI_ColorDlg( module()->getApp()->desktop(), anIsOneColor );
aPolyObject->SetWireColor( aFirstColor );
}
+ else if ( myEditedObject->IsKind( STANDARD_TYPE(HYDROData_LandCover) ) )
+ {
+ Handle(HYDROData_LandCover) aLandCover =
+ Handle(HYDROData_LandCover)::DownCast( myEditedObject );
+
+ aLandCover->SetFillingColor( aFirstColor );
+ aLandCover->SetBorderColor( aSecondColor );
+ }
module()->setIsToUpdate( myEditedObject );
#include <HYDROGUI_Shape.h>
#include <HYDROGUI_Tool.h>
+#include <HYDROGUI_Polyline.h>
+
#include <HYDROData_Channel.h>
#include <HYDROData_Document.h>
#include <HYDROData_DummyObject3D.h>
#include <HYDROData_ShapesGroup.h>
#include <HYDROData_Stream.h>
#include <HYDROData_Zone.h>
-#include <HYDROGUI_Polyline.h>
+#include <HYDROData_LandCover.h>
#include <AIS_Shape.hxx>
#include <BRep_Builder.hxx>
setShape( aCompound, false, false );
}
+ else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_LandCover) ) )
+ {
+ Handle(HYDROData_LandCover) aLandCoverObj =
+ Handle(HYDROData_LandCover)::DownCast( myObject );
+
+ TopoDS_Shape aLandCoverShape = aLandCoverObj->GetShape();
+ if ( !aLandCoverShape.IsNull() ) {
+ setShape( aLandCoverShape, false, false );
+ }
+
+ QColor aFillingColor = aLandCoverObj->GetFillingColor();
+ QColor aBorderColor = aLandCoverObj->GetBorderColor();
+
+ setFillingColor( aFillingColor, false, false );
+ setBorderColor( aBorderColor, false, false );
+ }
}
if ( myShape.IsNull() || !isVisible() )
bool HYDROGUI_Tool::IsObjectHasPresentation( const Handle(HYDROData_Entity)& theObject,
const QString& theViewerType )
{
-
if ( theObject.IsNull() )
return false;
anObjectKind == KIND_CHANNEL ||
anObjectKind == KIND_DIGUE ||
anObjectKind == KIND_DUMMY_3D ||
- anObjectKind == KIND_BATHYMETRY
+ anObjectKind == KIND_BATHYMETRY ||
+ anObjectKind == KIND_LAND_COVER
#ifdef DEB_GROUPS
|| anObjectKind == KIND_SHAPES_GROUP ||
anObjectKind == KIND_SPLITTED_GROUP