HYDROData_LandCoverMap.h
HYDROData_LCM_FaceClassifier.h
HYDROData_DTM.h
+ HYDROData_BCPolygon.h
+ HYDROData_BoundaryPolygonTools.h
)
set(PROJECT_SOURCES
HYDROData_LandCoverMap.cxx
HYDROData_LCM_FaceClassifier.cxx
HYDROData_DTM.cxx
+ HYDROData_BCPolygon.cxx
+ HYDROData_BoundaryPolygonTools.cxx
)
SET( ECW_INCLUDES $ENV{ECWLIB_ROOT_DIR}/include )
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROData_BCPolygon.h"
+
+//#include "HYDROData_IAltitudeObject.h"
+#include "HYDROData_Document.h"
+//#include "HYDROData_ShapesGroup.h"
+#include "HYDROData_PolylineXY.h"
+#include "HYDROData_ShapesTool.h"
+
+#include <TopoDS.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_HSequenceOfShape.hxx>
+#include <TDataStd_Integer.hxx>
+
+#include <HYDROData_Tool.h>
+
+#include <QColor>
+#include <QStringList>
+
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_BCPolygon,HYDROData_Object)
+
+
+HYDROData_BCPolygon::HYDROData_BCPolygon()
+: HYDROData_Object( Geom_2d )
+{
+}
+
+HYDROData_BCPolygon::~HYDROData_BCPolygon()
+{
+}
+
+QStringList HYDROData_BCPolygon::DumpToPython( const QString& thePyScriptPath,
+ MapOfTreatedObjects& theTreatedObjects ) const
+{
+ QStringList aResList = dumpObjectCreation( theTreatedObjects );
+
+ QString aBCName = GetObjPyName();
+
+ //Handle(HYDROData_IAltitudeObject) aRefAltitude = GetAltitudeObject();
+ //setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefAltitude, "SetAltitudeObject" );
+
+ Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline();
+ setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
+
+ aResList << QString( "" );
+
+ aResList << QString( "%1.Update()" ).arg( aBCName );
+ aResList << QString( "" );
+
+ return aResList;
+}
+
+HYDROData_SequenceOfObjects HYDROData_BCPolygon::GetAllReferenceObjects() const
+{
+ HYDROData_SequenceOfObjects aResSeq = HYDROData_Object::GetAllReferenceObjects();
+
+ Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline();
+ if ( !aRefPolyline.IsNull() )
+ aResSeq.Append( aRefPolyline );
+
+ return aResSeq;
+}
+
+int HYDROData_BCPolygon::GetBoundaryType() const
+{
+ Handle(TDataStd_Integer) aBoundaryTypeAttr;
+
+ int aBoundaryTypeVal = 0; //default
+ if( myLab.FindAttribute(TDataStd_Integer::GetID(), aBoundaryTypeAttr ) )
+ aBoundaryTypeVal = aBoundaryTypeAttr->Get();
+ return aBoundaryTypeVal;
+}
+
+void HYDROData_BCPolygon::SetBoundaryType( int theBoundaryType ) const
+{
+ TDataStd_Integer::Set( myLab, theBoundaryType );
+}
+
+void HYDROData_BCPolygon::Update()
+{
+ HYDROData_Object::Update();
+ SetTopShape( generateTopShape() );
+}
+
+void HYDROData_BCPolygon::Update(const TopoDS_Shape& theTopShape)
+{
+ HYDROData_Object::Update();
+ SetTopShape( theTopShape);
+}
+
+bool HYDROData_BCPolygon::IsHas2dPrs() const
+{
+ return true;
+}
+
+TopoDS_Shape HYDROData_BCPolygon::generateTopShape() const
+{
+ return generateTopShape( GetPolyline() );
+}
+
+TopoDS_Shape HYDROData_BCPolygon::generateTopShape( const Handle(HYDROData_PolylineXY)& aPolyline )
+{
+ return HYDROData_Tool::PolyXY2Face(aPolyline);
+}
+
+TopoDS_Shape HYDROData_BCPolygon::GetShape3D() const
+{
+ return GetTopShape();
+}
+
+QColor HYDROData_BCPolygon::DefaultFillingColor() const
+{
+ int aBT = GetBoundaryType();
+ QColor aFC;
+ if (aBT == 1)
+ aFC = QColor( Qt::blue );
+ else if (aBT == 2)
+ aFC = QColor( Qt::darkGreen );
+ else if (aBT == 3)
+ aFC = QColor( Qt::darkYellow );
+ else
+ aFC = QColor( Qt::red );
+ //aFC.setAlpha(175);
+ return aFC;
+}
+
+QColor HYDROData_BCPolygon::DefaultBorderColor() const
+{
+ return QColor( Qt::black );
+}
+
+void HYDROData_BCPolygon::SetPolyline( const Handle(HYDROData_PolylineXY)& thePolyline )
+{
+ if( IsEqual( GetPolyline(), thePolyline ) )
+ return;
+
+ SetReferenceObject( thePolyline, DataTag_Polyline );
+ Changed( Geom_2d );
+}
+
+Handle(HYDROData_PolylineXY) HYDROData_BCPolygon::GetPolyline() const
+{
+ return Handle(HYDROData_PolylineXY)::DownCast(
+ GetReferenceObject( DataTag_Polyline ) );
+}
+
+void HYDROData_BCPolygon::RemovePolyline()
+{
+ ClearReferenceObjects( DataTag_Polyline );
+ Changed( Geom_2d );
+}
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROData_BCPolygon_HeaderFile
+#define HYDROData_BCPolygon_HeaderFile
+
+#include <HYDROData_Object.h>
+
+class HYDROData_PolylineXY;
+
+/**\class HYDROData_BCPolygon
+ * \brief
+ *
+ */
+class HYDROData_BCPolygon : public HYDROData_Object
+{
+protected:
+ /**
+ * Enumeration of tags corresponding to the persistent object parameters.
+ */
+ enum DataTag
+ {
+ DataTag_First = HYDROData_Object::DataTag_First + 100,
+ DataTag_Polyline, ///< reference polyline
+ DataTag_BoundaryType ///< boundary type: cutting(1), bounding(2), selection(3)
+};
+
+public:
+ DEFINE_STANDARD_RTTIEXT(HYDROData_BCPolygon, HYDROData_Object);
+
+ /**
+ * Returns the kind of this object. Must be redefined in all objects of known type.
+ */
+ HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_BC_POLYGON;}
+
+ /**
+ * Dump object to Python script representation.
+ */
+ HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+ MapOfTreatedObjects& theTreatedObjects ) const;
+
+ /**
+ * Returns the list of all reference objects of this object.
+ */
+ HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
+
+ /**
+ * Update the object.
+ * Call this method whenever you made changes for object data.
+ */
+ HYDRODATA_EXPORT virtual void Update();
+
+ /**
+ * Update the object with new top shape.
+ * Call this method whenever you made changes for object data.
+ */
+ HYDRODATA_EXPORT void Update(const TopoDS_Shape& theTopShape);
+
+ /**
+ * Checks that object has 2D presentation. Reimlemented to retun true.
+ */
+ HYDRODATA_EXPORT virtual bool IsHas2dPrs() const;
+
+ /**
+ * Returns the 3d shape of the object.
+ */
+ HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
+
+ /**
+ * Returns default filling color for new zone.
+ */
+ HYDRODATA_EXPORT virtual QColor DefaultFillingColor() const;
+
+ /**
+ * Returns default border color for new zone.
+ */
+ HYDRODATA_EXPORT virtual QColor DefaultBorderColor() const;
+
+ /**
+ * Sets reference polyline object for zone.
+ */
+ HYDRODATA_EXPORT virtual void SetPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
+
+ /**
+ * Returns reference polyline object of zone.
+ */
+ HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetPolyline() const;
+
+ /**
+ * Remove reference polyline object of zone.
+ */
+ HYDRODATA_EXPORT virtual void RemovePolyline();
+
+ HYDRODATA_EXPORT TopoDS_Shape generateTopShape() const;
+
+ HYDRODATA_EXPORT static TopoDS_Shape generateTopShape( const Handle(HYDROData_PolylineXY)& );
+
+ HYDRODATA_EXPORT int GetBoundaryType() const;
+
+ HYDRODATA_EXPORT void SetBoundaryType( int ) const;
+
+
+private:
+
+ /**
+ * Create all necessary child group objects.
+ */
+ //HYDRODATA_EXPORT void createGroupObjects();
+
+protected:
+
+ friend class HYDROData_Iterator;
+
+ /**
+ * Creates new object in the internal data structure. Use higher level objects
+ * to create objects with real content.
+ */
+ HYDRODATA_EXPORT HYDROData_BCPolygon();
+
+ /**
+ * Destructs properties of the object and object itself, removes it from the document.
+ */
+ virtual HYDRODATA_EXPORT ~HYDROData_BCPolygon();
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <HYDROData_Tool.h>
+#include <HYDROData_BoundaryPolygonTools.h>
+
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Wire.hxx>
+
+
+#include <BRep_Builder.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopExp.hxx>
+#include <NCollection_List.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+#include <TopExp_Explorer.hxx>
+
+#include <NCollection_IndexedDataMap.hxx>
+#include <BOPAlgo_BOP.hxx>
+#include <BOPAlgo_Section.hxx>
+
+
+#include <Basics_OCCTVersion.hxx>
+
+static bool FindInterBySection(const TopoDS_Face& IncF, TopoDS_Shape poly)
+{
+ if (IncF.IsNull())
+ return false;
+ //make cmp from edges of Inc_sh
+ TopTools_IndexedMapOfShape IncToolsE;
+ TopExp::MapShapes(IncF, TopAbs_EDGE, IncToolsE);
+ BRep_Builder BB;
+ TopoDS_Compound aToolCmp;
+ BB.MakeCompound(aToolCmp);
+ for (int i=1; i<= IncToolsE.Extent();i++)
+ BB.Add(aToolCmp, IncToolsE(i));
+ //
+ //perform bsection - poly vs aToolCmp
+ BOPAlgo_Section aBOP;
+ aBOP.AddArgument(poly);
+ aBOP.AddArgument(aToolCmp);
+ aBOP.SetRunParallel(true);
+
+ aBOP.Perform();
+ //aBOP.GetReport());
+
+//#if OCC_VERSION_LARGE > 0x07020000
+// if (aBOP.HasErrors())
+// return false;
+//#endif
+
+ const TopoDS_Shape& aRes=aBOP.Shape();
+ if (aRes.IsNull())
+ return false;
+
+ bool IsInter = false;
+ TopTools_IndexedMapOfShape aShVE;
+ TopExp::MapShapes(aRes, TopAbs_VERTEX, aShVE);
+ if (aShVE.IsEmpty())
+ {
+ TopExp::MapShapes(aRes, TopAbs_EDGE, aShVE);
+ if (!aShVE.IsEmpty())
+ IsInter = true;
+ }
+ else
+ IsInter = true;
+ return IsInter;
+}
+
+bool HYDROData_BoundaryPolygonTools::CutTool( const TopTools_SequenceOfShape& CutTools,
+ NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape>& ObjToRes )
+{
+ TopTools_IndexedMapOfShape EdgesTools;
+ for (int i =1; i<=CutTools.Length();i++)
+ {
+ const TopoDS_Shape& CSH = CutTools(i);
+ TopExp::MapShapes(CSH, TopAbs_EDGE, EdgesTools);
+ }
+ //
+ BRep_Builder BB;
+ TopoDS_Compound aToolCmp;
+ BB.MakeCompound(aToolCmp);
+ for (int i=1; i<= EdgesTools.Extent();i++)
+ BB.Add(aToolCmp, EdgesTools(i));
+ //
+ for (int i = 1; i <= ObjToRes.Extent(); i++ )
+ {
+ const TopoDS_Shape& Obj = ObjToRes.FindKey(i);
+ Standard_Real aTol;
+ if (!Obj.IsNull())
+ {
+ aTol = Precision::Confusion();
+ BOPAlgo_BOP aBOP;
+ //
+ aBOP.AddArgument(Obj);
+ aBOP.AddTool(aToolCmp);
+ aBOP.SetOperation(BOPAlgo_CUT);
+ aBOP.SetRunParallel(true);
+
+ aBOP.Perform();
+
+#if OCC_VERSION_LARGE > 0x07020000
+ if (aBOP.HasErrors())
+ return false;
+#endif
+
+ const TopoDS_Shape& aRes=aBOP.Shape();
+ ObjToRes.ChangeFromKey(Obj) = aRes;
+ }
+ }
+ return true;
+}
+
+
+bool HYDROData_BoundaryPolygonTools::IncludeTool( const TopTools_SequenceOfShape& IncludeTools,
+ TopoDS_Shape Obj)
+{
+ TopExp_Explorer exp(Obj, TopAbs_VERTEX);
+ if (!exp.More())
+ return false;
+ TopoDS_Vertex aV = TopoDS::Vertex(exp.Current());
+ gp_Pnt aP = BRep_Tool::Pnt(aV);
+ for (int i=1; i<=IncludeTools.Size(); i++)
+ {
+ TopoDS_Face IncF = TopoDS::Face(IncludeTools(i));
+ bool IsInter = FindInterBySection(IncF, Obj);
+ if (IsInter)
+ return false;
+ //
+ gp_XY aP2d(aP.X(), aP.Y());
+ TopAbs_State aState = HYDROData_Tool::ComputePointState(aP2d, IncF);
+ if (aState != TopAbs_IN)
+ return false;
+ }
+ return true;
+}
+
+bool HYDROData_BoundaryPolygonTools::SelectionTool( const TopTools_SequenceOfShape& SelectionTool,
+ TopoDS_Shape Obj)
+{
+ for (int i=1; i<=SelectionTool.Size(); i++)
+ {
+ TopoDS_Face IncF = TopoDS::Face(SelectionTool(i));
+ bool IsInter = FindInterBySection(IncF, Obj);
+ if (!IsInter)
+ return false;
+ }
+ return true;
+}
+
+
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROData_BoundaryPolygonTools_HeaderFile
+#define HYDROData_BoundaryPolygonTools_HeaderFile
+
+#include "HYDROData.h"
+#include <TopTools_SequenceOfShape.hxx>
+#include <NCollection_IndexedDataMap.hxx>
+
+
+class TopoDS_Shape;
+
+class HYDRODATA_EXPORT HYDROData_BoundaryPolygonTools {
+
+public:
+
+ static bool CutTool( const TopTools_SequenceOfShape& CutTools,
+ NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape>& ObjToRes );
+
+ static bool IncludeTool( const TopTools_SequenceOfShape& IncludeTools,
+ TopoDS_Shape Obj);
+
+ static bool SelectionTool( const TopTools_SequenceOfShape& SelectionTool,
+ TopoDS_Shape Obj) ;
+
+};
+
+#endif
+
+
#include "HYDROData_Region.h"
#include "HYDROData_Tool.h"
#include "HYDROData_GeomTool.h"
+#include <HYDROData_Tool.h>
+#include <HYDROData_BCPolygon.h>
+#include <HYDROData_BoundaryPolygonTools.h>
#ifdef WIN32
#pragma warning ( disable: 4251 )
#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
+#include <BRepTools_ReShape.hxx>
+#include <BRepLib_MakeWire.hxx>
#include <BRepTools.hxx>
return aResSeq;
}
+static void FilterEdgesByIncludeSelectionBoundaryPolygons( const HYDROData_SplitToZonesTool::SplitDataList& anEdgesList,
+ HYDROData_SequenceOfObjects aBoundaryPolygons,
+ HYDROData_SplitToZonesTool::SplitDataList& outEdgesList)
+{
+ //perform boundary condition polygons on EdgesList
+ TopTools_SequenceOfShape IncTools, SelectionTools;
+ HYDROData_SplitToZonesTool::SplitDataListIterator anIter(anEdgesList);
+ for (int i=1; i<=aBoundaryPolygons.Size();i++)
+ {
+ Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast( aBoundaryPolygons(i));
+ TopoDS_Shape aPolyTopShape = aBCPoly->GetTopShape();
+ int bType = aBCPoly->GetBoundaryType();
+ if (bType == 2)
+ IncTools.Append(aPolyTopShape);
+ else if (bType == 3)
+ SelectionTools.Append(aPolyTopShape);
+ }
+
+ while( anIter.hasNext() )
+ {
+ const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
+ if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
+ continue;
+ if (aSplitData.Shape.ShapeType() != TopAbs_EDGE)
+ continue;
+ if (HYDROData_BoundaryPolygonTools::IncludeTool(IncTools, aSplitData.Shape) && HYDROData_BoundaryPolygonTools::SelectionTool(SelectionTools, aSplitData.Shape))
+ outEdgesList.append(aSplitData);
+ }
+}
+
+
+static void SplitEdgesByBoundaryPolygons( const HYDROData_SplitToZonesTool::SplitDataList& anEdgesList,
+ const HYDROData_SequenceOfObjects& aBoundaryPolygons,
+ NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape>& ObjToRes)
+{
+ //perform boundary condition polygons on EdgesList
+ TopTools_SequenceOfShape CutTools;
+ ObjToRes.Clear();
+ HYDROData_SplitToZonesTool::SplitDataListIterator anIter(anEdgesList);
+ for (int i=1; i<=aBoundaryPolygons.Size();i++)
+ {
+ Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast( aBoundaryPolygons(i));
+ TopoDS_Shape aPolyTopShape = aBCPoly->GetTopShape();
+ int bType = aBCPoly->GetBoundaryType();
+ if (bType == 1)
+ CutTools.Append(aPolyTopShape);
+ }
+
+ while( anIter.hasNext() )
+ {
+ const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
+ if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
+ continue;
+ if (aSplitData.Shape.ShapeType() != TopAbs_EDGE)
+ continue;
+ ObjToRes.Add(aSplitData.Shape, TopoDS_Shape());
+ }
+
+ HYDROData_BoundaryPolygonTools::CutTool(CutTools, ObjToRes);
+}
+
+
+static void PerformEdgeReplInZones(const HYDROData_SplitToZonesTool::SplitDataList& ZoneList,
+ const NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape>& ObjToRes,
+ HYDROData_SplitToZonesTool::SplitDataList& outZoneList)
+{
+ HYDROData_SplitToZonesTool::SplitDataListIterator it( ZoneList );
+ BRepTools_ReShape reshaper;
+ for (;it.hasNext();)
+ {
+ const HYDROData_SplitToZonesTool::SplitData& aSplitData = it.next();
+ if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
+ continue;
+
+ TopoDS_Shape mS = aSplitData.Shape;
+ for (int i=1; i<=ObjToRes.Extent();i++)
+ {
+ TopoDS_Shape K = ObjToRes.FindKey(i);
+ TopoDS_Shape V = ObjToRes.FindFromIndex(i);
+ if (V.ShapeType() != TopAbs_EDGE && V.ShapeType() != TopAbs_WIRE && V.ShapeType() != TopAbs_COMPOUND)
+ continue;
+ if (V.ShapeType() == TopAbs_COMPOUND)
+ {
+ TopExp_Explorer exp(V, TopAbs_EDGE);
+ TopTools_ListOfShape lE;
+ for (;exp.More();exp.Next())
+ lE.Append(exp.Current());
+ if (lE.Extent() == 1)
+ V = lE.First();
+ else if (lE.Extent() > 1)
+ {
+ BRepLib_MakeWire MW;
+ MW.Add(lE);
+ if (MW.IsDone())
+ V = MW.Wire();
+ else
+ continue;
+ }
+ else
+ continue;
+ }
+ reshaper.Replace(K, V);
+ }
+ TopoDS_Shape nS = reshaper.Apply(mS);
+ HYDROData_SplitToZonesTool::SplitData aNS(aSplitData.Type, nS, aSplitData.ObjectNames);
+ outZoneList.append(aNS);
+ }
+}
+
+static void CreateNewEdgeList( const HYDROData_SplitToZonesTool::SplitDataList& theEdges,
+ const NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape>& ObjToRes,
+ HYDROData_SplitToZonesTool::SplitDataList& newEdges)
+{
+ HYDROData_SplitToZonesTool::SplitDataListIterator anIter( theEdges );
+ while( anIter.hasNext() )
+ {
+ const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
+ if ( aSplitData.ObjectNames.isEmpty() || aSplitData.Shape.IsNull() )
+ continue;
+
+ const TopoDS_Shape* aDivShape = ObjToRes.Seek(aSplitData.Shape);
+ if (aDivShape)
+ {
+ TopExp_Explorer exp(*aDivShape, TopAbs_EDGE);
+ for (;exp.More();exp.Next())
+ {
+ HYDROData_SplitToZonesTool::SplitData anNewSData(aSplitData.Type, exp.Current(), aSplitData.ObjectNames);
+ newEdges.append(anNewSData);
+ }
+ }
+ else
+ newEdges.append(aSplitData);
+ }
+}
+
+
void HYDROData_CalculationCase::Update()
{
HYDROData_Entity::Update();
}
}
+ //
+ //split edges by boundary polygons
+ HYDROData_SequenceOfObjects aBoundaryPolygons = GetBoundaryPolygons();
+ //edge to splitted edge (compound of edges or original edge)
+ NCollection_IndexedDataMap<TopoDS_Shape, TopoDS_Shape> ObjToRes;
+ //split edge list by BP
+ SplitEdgesByBoundaryPolygons(anEdgesList, aBoundaryPolygons, ObjToRes);
+ HYDROData_SplitToZonesTool::SplitDataList aNewZonesList;
+ //replace splitted edges in zone list (faces)
+ PerformEdgeReplInZones(aZonesList, ObjToRes, aNewZonesList);
+ //
+ //create new edges list based on splitting info from ObjToRes
+ HYDROData_SplitToZonesTool::SplitDataList newEdgesList1,newEdgesList2;
+ CreateNewEdgeList(anEdgesList, ObjToRes, newEdgesList1);
+ //filter out edges list by include&selection tools
+ FilterEdgesByIncludeSelectionBoundaryPolygons(newEdgesList1,aBoundaryPolygons,newEdgesList2);
+
switch( GetAssignmentMode() )
{
case MANUAL:
- CreateRegionsDef( aDocument, aZonesList );
+ CreateRegionsDef( aDocument,aNewZonesList );
break;
case AUTOMATIC:
- CreateRegionsAuto( aDocument, aZonesList );
+ CreateRegionsAuto( aDocument,aNewZonesList );
break;
}
- CreateEdgeGroupsDef( aDocument, anEdgesList );
+ CreateEdgeGroupsDef( aDocument, newEdgesList2 );
}
void HYDROData_CalculationCase::CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
if ( aSplitGroup.IsNull() )
continue;
- aSplitGroup->AddShape( aSplitData.Shape );
+ aSplitGroup->AddShape( aSplitData.Shape );
TopTools_SequenceOfShape theShapes;
aSplitGroup->GetShapes(theShapes);
Changed( Geom_2d );
}
+bool HYDROData_CalculationCase::AddBoundaryPolygon( const Handle(HYDROData_BCPolygon)& theBCPolygon )
+{
+ HYDROData_CalculationCase::DataTag aDataTag = DataTag_BCPolygon;
+
+ if ( HasReference( theBCPolygon, aDataTag ) )
+ return false;
+
+ AddReferenceObject( theBCPolygon, aDataTag );
+
+ Changed( Geom_2d );
+
+ return true;
+}
+
+HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetBoundaryPolygons() const
+{
+ return GetReferenceObjects( DataTag_BCPolygon );
+}
+
+void HYDROData_CalculationCase::RemoveBoundaryPolygon( const Handle(HYDROData_BCPolygon)& theBCPolygon )
+{
+ if ( theBCPolygon.IsNull() )
+ return;
+
+ RemoveReferenceObject( theBCPolygon->Label(), DataTag_BCPolygon );
+
+ Changed( Geom_2d );
+}
+
+
class HYDROData_Document;
class HYDROData_StricklerTable;
class HYDROData_LandCoverMap;
+class HYDROData_BCPolygon;
/**\class HYDROData_CalculationCase
* \brief Calculation case is defined by selection of Geometry objects with or without �Zone of water�.
DataTag_AssignmentMode, ///< assignment mode
DataTag_StricklerTable, ///< reference Strickler table
DataTag_InterPoly, ///< intersection polyline
+ DataTag_BCPolygon, ///< reference boundary polygons
DataTag_LandCover_Obsolete, ///< reference land covers
DataTag_CustomLandCoverRules_Obsolete, ///< custom rules for land covers priority
HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetInterPolyObjects() const;
+ HYDRODATA_EXPORT virtual bool AddBoundaryPolygon( const Handle(HYDROData_BCPolygon)& theBCPolygon );
+
+ HYDRODATA_EXPORT virtual void RemoveBoundaryPolygon( const Handle(HYDROData_BCPolygon)& theBCPolygon );
+
+ HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetBoundaryPolygons() const;
+
/**
* Exports the calculation case data (shell and groups) to GEOM module.
* \param theStudyId the id of the study where the GEOM module should be used for export
aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_DIGUE );
aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_OBSTACLE );
aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_LAND_COVER_MAP );
+ aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_BC_POLYGON );
aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_CALCULATION );
// Dump code to close python fuction
return "Land_cover_map";
case KIND_DTM:
return "DTM";
+ case KIND_BC_POLYGON:
+ return "Boundary Polygon";
}
return "";
}
case KIND_LAND_COVER_OBSOLETE: return "";
case KIND_CHANNEL_ALTITUDE: return "KIND_CHANNEL_ALTITUDE";
case KIND_LAND_COVER_MAP: return "KIND_LAND_COVER_MAP";
+ case KIND_BC_POLYGON: return "KIND_BC_POLYGON";
default: return "KIND_UNKNOWN"; ///! Unrecognized object
}
}
const ObjectKind KIND_CHANNEL_ALTITUDE = 28;
const ObjectKind KIND_LAND_COVER_MAP = 29;
const ObjectKind KIND_DTM = 30;
-const ObjectKind KIND_LAST = KIND_DTM+1;
+const ObjectKind KIND_BC_POLYGON = 31;
+const ObjectKind KIND_LAST = KIND_BC_POLYGON+1;
class MapOfTreatedObjects : public QMap<QString,Handle(Standard_Transient)>
{
#include "HYDROData_PolylineXY.h"
#include "HYDROData_ShapesTool.h"
-#include <BRepBuilderAPI_MakeFace.hxx>
+#include <HYDROData_Tool.h>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_HSequenceOfShape.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepAlgo_FaceRestrictor.hxx>
-#include <BRepCheck_Analyzer.hxx>
#include <ShapeAnalysis.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
+
#include <QColor>
#include <QStringList>
TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape( const Handle(HYDROData_PolylineXY)& aPolyline )
{
- //DEBTRACE("generateTopShape");
- TopoDS_Face aResultFace = TopoDS_Face(); // --- result: default = null face
-
- if (!aPolyline.IsNull())
- {
- TopoDS_Shape aPolylineShape = aPolyline->GetShape();
-#ifdef DEB_IMZ
- std::string brepName = "imz.brep";
- BRepTools::Write(aPolylineShape, brepName.c_str());
-#endif
- TopTools_ListOfShape aWiresList;
-
- if (!aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE)
- {
- // --- only one wire: try to make a face
- //DEBTRACE("one wire: try to build a face");
- const TopoDS_Wire& aPolylineWire = TopoDS::Wire(aPolylineShape);
- if (!aPolylineWire.IsNull())
- {
- BRepBuilderAPI_MakeFace aMakeFace(aPolylineWire, Standard_True);
- aMakeFace.Build();
- if (aMakeFace.IsDone())
- {
- //DEBTRACE(" a face with the only wire given");
- aResultFace = aMakeFace.Face();
- }
- }
- }
- else
- {
- // --- a list of wires ? inventory of wires and edges
- Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
- Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
- TopExp_Explorer anExp(aPolylineShape, TopAbs_WIRE);
- //DEBTRACE("list of wires ?");
- for (; anExp.More(); anExp.Next())
- {
- if (!anExp.Current().IsNull())
- {
- const TopoDS_Wire& aWire = TopoDS::Wire(anExp.Current());
- aWiresList.Append(aWire);
- //DEBTRACE(" append wire");
- TopExp_Explorer it2(aWire, TopAbs_EDGE);
- for (; it2.More(); it2.Next())
- aSeqEdges->Append(it2.Current());
- }
- }
- if (aWiresList.IsEmpty())
- return aResultFace; // --- no wires: null result
-
- if (aSeqEdges->Length() > 1)
- {
- //DEBTRACE("try to connect all the edges together, build a unique wire and a face");
- // --- try to create one wire by connecting edges with a distance tolerance (no necessity of sharing points)
- ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, 1E-5, Standard_False, aSeqWires);
-
- if (aSeqWires->Length() == 1)
- {
- // --- one wire: try to make a face
- const TopoDS_Wire& aPolylineWire = TopoDS::Wire(aSeqWires->Value(1));
- if (!aPolylineWire.IsNull())
- {
- BRepBuilderAPI_MakeFace aMakeFace(aPolylineWire, Standard_True);
- aMakeFace.Build();
- if (aMakeFace.IsDone())
- {
- //DEBTRACE(" a face from all the wires connected");
- aResultFace = aMakeFace.Face();
- }
- }
- }
- }
-
- if (aResultFace.IsNull())
- {
- //DEBTRACE("try to make a face with the first wire of the list and other wires as restrictions");
- // --- try to make a face with the first wire of the list and other wires as restrictions
- BRepAlgo_FaceRestrictor aFR;
- TopoDS_Face aRefFace;
- TopoDS_Shape aS = aWiresList.First();
- BRepBuilderAPI_MakeFace aMakeFace(TopoDS::Wire(aWiresList.First()), Standard_True);
- aMakeFace.Build();
- if (aMakeFace.IsDone())
- {
- //DEBTRACE(" a face with first wire");
- aRefFace = aMakeFace.Face();
- }
- if (!aRefFace.IsNull())
- {
- aFR.Init(aRefFace, Standard_False, Standard_True);
- TopTools_ListIteratorOfListOfShape anIt(aWiresList);
- for (; anIt.More(); anIt.Next())
- {
- TopoDS_Wire& aWire = TopoDS::Wire(anIt.Value());
- if (aWire.IsNull())
- continue;
- aFR.Add(aWire);
- }
- aFR.Perform();
- if (aFR.IsDone())
- {
- for (; aFR.More(); aFR.Next())
- {
- //DEBTRACE(" a restricted face");
- aResultFace = aFR.Current();
- break;
- }
- }
- }
- }
- }
- }
-
- if (aResultFace.IsNull())
- return aResultFace;
-
- //DEBTRACE("check the face");
- BRepCheck_Analyzer anAnalyzer(aResultFace);
- if (anAnalyzer.IsValid() && aResultFace.ShapeType() == TopAbs_FACE)
- {
- //DEBTRACE("face OK");
- return aResultFace;
- }
- else
- {
- //DEBTRACE("bad face");
- }
- return TopoDS_Face();
+ return HYDROData_Tool::PolyXY2Face(aPolyline);
}
void HYDROData_ImmersibleZone::createGroupObjects()
#include "HYDROData_Zone.h"
#include "HYDROData_StricklerTable.h"
#include "HYDROData_DTM.h"
-
+#include "HYDROData_BCPolygon.h"
#include <TDataStd_Name.hxx>
#include <TDataStd_NamedData.hxx>
case KIND_CHANNEL_ALTITUDE: aResult = new HYDROData_ChannelAltitude(); break;
case KIND_LAND_COVER_MAP: aResult = new HYDROData_LandCoverMap(); break;
case KIND_DTM: aResult = new HYDROData_DTM(); break;
+ case KIND_BC_POLYGON: aResult = new HYDROData_BCPolygon(); break;
default: break;
}
}
int HYDROData_ShapeFile::ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName,
- NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile)
+ NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile, ImportShapeType theShapeTypesToImport)
{
//Free();
int aStat = TryOpenShapeFile(theFileName);
if (!Parse(aHSHP, HYDROData_ShapeFile::ShapeType_Polyline, theShapeTypeOfFile))
return 0;
- if (aHSHP->nShapeType == 3 || aHSHP->nShapeType == 23)
+
+ int sh_type = aHSHP->nShapeType;
+
+ if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All ||
+ theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polyline)
+ && (sh_type == 3 || sh_type == 23))
{
size_t anObjsSize = mySHPObjects.size();
GetFreeIndices(anAllowedIndexes, "_PolyXY_", anObjsSize, anExistingNames, aBaseFileName);
}
aStat = 1;
}
- else if (aHSHP->nShapeType == 13)
+ else if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All ||
+ theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polyline3D) && sh_type == 13)
{
anInd = 0;
for (;anAllowedIndexes.size() < mySHPObjects.size();)
}
aStat = 1;
}
- else if (aHSHP->nShapeType == 5)
+ else if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All ||
+ theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polygon) && sh_type == 5)
{
//import polygon's contours as polylines
size_t anObjsSize = mySHPObjects.size();
DBF_FieldType_Invalid
};
+enum ImportShapeType
+{
+ ImportShapeType_Polyline,
+ ImportShapeType_Polyline3D,
+ ImportShapeType_Polygon,
+ ImportShapeType_All
+};
struct DBF_AttrValue
{
int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities);
HYDRODATA_EXPORT int ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName,
- NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile);
+ NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile,
+ ImportShapeType theShapeTypesToImport);
HYDRODATA_EXPORT QString GetShapeTypeName(int theType);
#include <HYDROData_Iterator.h>
#include <HYDROData_NaturalObject.h>
#include <HYDROData_ShapesGroup.h>
+#include <HYDROData_PolylineXY.h>
#include <QColor>
#include <QFile>
#include <QStringList>
#include <BRepTools.hxx>
#include <NCollection_Map.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS_Face.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <BRep_Builder.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <NCollection_List.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+
+#include <TopExp_Explorer.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_HSequenceOfShape.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepAlgo_FaceRestrictor.hxx>
+#include <BRepCheck_Analyzer.hxx>
+
+#include <ShapeAnalysis.hxx>
+#include <ShapeAnalysis_FreeBounds.hxx>
+
+
static int aMaxNameId = INT_MAX;
static int aMaxColorNb = 92000;
void HYDROData_Tool::WriteStringsToFile( QFile& theFile,
}
+TopoDS_Shape HYDROData_Tool::PolyXY2Face( const Handle(HYDROData_PolylineXY)& aPolyline )
+{
+ //DEBTRACE("generateTopShape");
+ TopoDS_Face aResultFace = TopoDS_Face(); // --- result: default = null face
+
+ if (!aPolyline.IsNull())
+ {
+ TopoDS_Shape aPolylineShape = aPolyline->GetShape();
+#ifdef DEB_IMZ
+ std::string brepName = "imz.brep";
+ BRepTools::Write(aPolylineShape, brepName.c_str());
+#endif
+ TopTools_ListOfShape aWiresList;
+
+ if (!aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE)
+ {
+ // --- only one wire: try to make a face
+ //DEBTRACE("one wire: try to build a face");
+ const TopoDS_Wire& aPolylineWire = TopoDS::Wire(aPolylineShape);
+ if (!aPolylineWire.IsNull())
+ {
+ BRepBuilderAPI_MakeFace aMakeFace(aPolylineWire, Standard_True);
+ aMakeFace.Build();
+ if (aMakeFace.IsDone())
+ {
+ //DEBTRACE(" a face with the only wire given");
+ aResultFace = aMakeFace.Face();
+ }
+ }
+ }
+ else
+ {
+ // --- a list of wires ? inventory of wires and edges
+ Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
+ Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
+ TopExp_Explorer anExp(aPolylineShape, TopAbs_WIRE);
+ //DEBTRACE("list of wires ?");
+ for (; anExp.More(); anExp.Next())
+ {
+ if (!anExp.Current().IsNull())
+ {
+ const TopoDS_Wire& aWire = TopoDS::Wire(anExp.Current());
+ aWiresList.Append(aWire);
+ //DEBTRACE(" append wire");
+ TopExp_Explorer it2(aWire, TopAbs_EDGE);
+ for (; it2.More(); it2.Next())
+ aSeqEdges->Append(it2.Current());
+ }
+ }
+ if (aWiresList.IsEmpty())
+ return aResultFace; // --- no wires: null result
+
+ if (aSeqEdges->Length() > 1)
+ {
+ //DEBTRACE("try to connect all the edges together, build a unique wire and a face");
+ // --- try to create one wire by connecting edges with a distance tolerance (no necessity of sharing points)
+ ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, 1E-5, Standard_False, aSeqWires);
+
+ if (aSeqWires->Length() == 1)
+ {
+ // --- one wire: try to make a face
+ const TopoDS_Wire& aPolylineWire = TopoDS::Wire(aSeqWires->Value(1));
+ if (!aPolylineWire.IsNull())
+ {
+ BRepBuilderAPI_MakeFace aMakeFace(aPolylineWire, Standard_True);
+ aMakeFace.Build();
+ if (aMakeFace.IsDone())
+ {
+ //DEBTRACE(" a face from all the wires connected");
+ aResultFace = aMakeFace.Face();
+ }
+ }
+ }
+ }
+
+ if (aResultFace.IsNull())
+ {
+ //DEBTRACE("try to make a face with the first wire of the list and other wires as restrictions");
+ // --- try to make a face with the first wire of the list and other wires as restrictions
+ BRepAlgo_FaceRestrictor aFR;
+ TopoDS_Face aRefFace;
+ TopoDS_Shape aS = aWiresList.First();
+ BRepBuilderAPI_MakeFace aMakeFace(TopoDS::Wire(aWiresList.First()), Standard_True);
+ aMakeFace.Build();
+ if (aMakeFace.IsDone())
+ {
+ //DEBTRACE(" a face with first wire");
+ aRefFace = aMakeFace.Face();
+ }
+ if (!aRefFace.IsNull())
+ {
+ aFR.Init(aRefFace, Standard_False, Standard_True);
+ TopTools_ListIteratorOfListOfShape anIt(aWiresList);
+ for (; anIt.More(); anIt.Next())
+ {
+ TopoDS_Wire& aWire = TopoDS::Wire(anIt.Value());
+ if (aWire.IsNull())
+ continue;
+ aFR.Add(aWire);
+ }
+ aFR.Perform();
+ if (aFR.IsDone())
+ {
+ for (; aFR.More(); aFR.Next())
+ {
+ //DEBTRACE(" a restricted face");
+ aResultFace = aFR.Current();
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (aResultFace.IsNull())
+ return aResultFace;
+
+ //DEBTRACE("check the face");
+ BRepCheck_Analyzer anAnalyzer(aResultFace);
+ if (anAnalyzer.IsValid() && aResultFace.ShapeType() == TopAbs_FACE)
+ {
+ //DEBTRACE("face OK");
+ return aResultFace;
+ }
+ else
+ {
+ //DEBTRACE("bad face");
+ }
+ return TopoDS_Face();
+}
std::ostream& operator<<( std::ostream& theStream, const QString& theText )
{
#include <QStringList>
#include <Precision.hxx>
#include <QVector>
+#include <TopTools_SequenceOfShape.hxx>
+#include <NCollection_IndexedDataMap.hxx>
+
+class HYDROData_PolylineXY;
class HYDROData_Document;
class HYDROData_Entity;
class HYDROData_SequenceOfObjects;
Rebuilds shape container (like compound/compsolid/shell) which contains faces (shared or nonshared with each other)
*/
static TopoDS_Shape RebuildCmp(const TopoDS_Shape& in);
+
+ static TopoDS_Shape PolyXY2Face(const Handle(HYDROData_PolylineXY)& aPolyline);
+
};
inline bool ValuesEquals( const double& theFirst, const double& theSecond )
HYDROGUI_ImportLandCoverMapOp.h
HYDROGUI_ImportLandCoverMapDlg.h
HYDROGUI_ImportPolylineOp.h
+ HYDROGUI_ImportBCPolygonOp.h
HYDROGUI_ImportSinusXOp.h
HYDROGUI_ExportSinusXOp.h
HYDROGUI_ExportSinusXDlg.h
HYDROGUI_ZoneSetColorOp.h
HYDROGUI_PolyAttrDlg.h
HYDROGUI_ShowAttrPolyOp.h
+ HYDROGUI_SetBoundaryTypePolygonOp.h
+ HYDROGUI_SetBoundaryTypePolygonDlg.h
)
QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
HYDROGUI_ImportSinusXOp.cxx
HYDROGUI_ExportSinusXOp.cxx
HYDROGUI_ExportSinusXDlg.cxx
+ HYDROGUI_ImportBCPolygonOp.cxx
HYDROGUI_ExportLandCoverMapDlg.cxx
HYDROGUI_InputPanel.cxx
HYDROGUI_LandCoverArgsFilter.cxx
HYDROGUI_ZoneSetColorOp.cxx
HYDROGUI_PolyAttrDlg.cxx
HYDROGUI_ShowAttrPolyOp.cxx
+ HYDROGUI_SetBoundaryTypePolygonOp.cxx
+ HYDROGUI_SetBoundaryTypePolygonDlg.cxx
)
add_definitions(
{
addPage( createObjectsPage() );
addPage( createGroupsPage() );
+ addPage( createBoundaryPolygonsPage() );
+
addPage( createLandCoverMapPage() );
addPage( createZonesPage() );
}
return aPage;
}
+QWizardPage* HYDROGUI_CalculationDlg::createBoundaryPolygonsPage() {
+ QWizardPage* aPage = new QWizardPage( mainFrame() );
+ QFrame* aFrame = new QFrame( aPage );
+
+ myBoundaryPolygons = new QListWidget( aPage );
+ myBoundaryPolygons->setSelectionMode( QListWidget::ExtendedSelection );
+ myBoundaryPolygons->setEditTriggers( QListWidget::NoEditTriggers );
+ myBoundaryPolygons->setViewMode( QListWidget::ListMode );
+ myBoundaryPolygons->setSortingEnabled( true );
+
+ myISBoundaryPolygons = new QListWidget( aPage );
+ myISBoundaryPolygons->setSelectionMode( QListWidget::ExtendedSelection );
+ myISBoundaryPolygons->setEditTriggers( QListWidget::NoEditTriggers );
+ myISBoundaryPolygons->setViewMode( QListWidget::ListMode );
+ myISBoundaryPolygons->setSortingEnabled( true );
+
+ myAvailableBoundaryPolygons = new QListWidget( aPage );
+ myAvailableBoundaryPolygons->setSelectionMode( QListWidget::ExtendedSelection );
+ myAvailableBoundaryPolygons->setEditTriggers( QListWidget::NoEditTriggers );
+ myAvailableBoundaryPolygons->setViewMode( QListWidget::ListMode );
+ myAvailableBoundaryPolygons->setSortingEnabled( true );
+
+ //connect( myGroups, SIGNAL( itemSelectionChanged() ),
+ // SIGNAL( groupsSelected() ) ); //TODO
+
+ QFrame* aBPFrame = new QFrame( aPage );
+ QGridLayout* aBPLayout = new QGridLayout( aBPFrame );
+ aBPLayout->setMargin( 5 );
+ aBPLayout->setSpacing( 5 );
+ aBPFrame->setLayout( aBPLayout );
+
+ QFrame* aBtnsFrame = new QFrame( aBPFrame );
+ QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
+ aBtnsLayout->setMargin( 5 );
+ aBtnsLayout->setSpacing( 5 );
+ aBtnsFrame->setLayout( aBtnsLayout );
+ QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
+ QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
+
+ // Fill the butons frame with two buttons
+ aBtnsLayout->addWidget( anAddBtn );
+ aBtnsLayout->addWidget( aRemoveBtn );
+ aBtnsLayout->addStretch( 1 );
+
+ QLabel* anIncludedLabelCut = new QLabel( tr( "INCLUDED_BOUNDARY_POLYGONS_CUT" ), aBPFrame );
+
+ QLabel* anAvailableLabel = new QLabel( tr( "AVAILABLE_BOUNDARY_POLYGONS" ), aBPFrame );
+
+ QLabel* anIncludedLabelIS = new QLabel( tr( "INCLUDED_BOUNDARY_POLYGONS_INCSEL" ) );
+
+ // Fill the objects frame with two lists, two labels and with buttons frame
+ aBPLayout->addWidget( anAvailableLabel, 0, 0, Qt::AlignHCenter );
+ aBPLayout->addWidget( anIncludedLabelCut, 0, 2, Qt::AlignHCenter );
+
+ aBPLayout->addWidget( myAvailableBoundaryPolygons, 1, 0, 3, 1 );
+ aBPLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
+ aBPLayout->addWidget( myBoundaryPolygons, 1, 2 );
+
+ aBPLayout->addWidget( anIncludedLabelIS, 2, 2 );
+
+ aBPLayout->addWidget( myISBoundaryPolygons, 3, 2 );
+
+
+ // Fill the page
+ QGridLayout* aPageLayout = new QGridLayout( aPage );
+ aPageLayout->setMargin( 5 );
+ aPageLayout->setSpacing( 5 );
+ aPageLayout->setVerticalSpacing( 10 );
+ aPageLayout->addWidget( aBPFrame, 0, 0 );
+
+ aPage->setLayout( aPageLayout );
+
+ connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addBoundaryPolygons() ) );
+ connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeBoundaryPolygons() ) );
+
+ return aPage;
+}
+
+
QWizardPage* HYDROGUI_CalculationDlg::createLandCoverMapPage() {
QWizardPage* aPage = new QWizardPage( mainFrame() );
QFrame* aFrame = new QFrame( aPage );
moveItems( myGroups, myAvailableGroups, theObjects );
}
+///
+
+void HYDROGUI_CalculationDlg::setAvailableBoundaryPolygons( const QStringList& theBoundaryPolygons,
+ const QVector<int>& theTypes )
+{
+ myAvailableBoundaryPolygons->clear();
+ myBoundaryPolygons->clear();
+ myISBoundaryPolygons->clear();
+ QString iconStr;
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ int i = 0;
+ foreach( QString aBP, theBoundaryPolygons )
+ {
+ int aBT = theTypes[i];
+ i++;
+ if (aBT == 1)
+ iconStr = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE1_ICO").toLatin1());
+ else if (aBT == 2)
+ iconStr = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE2_ICO").toLatin1());
+ else if (aBT == 3)
+ iconStr = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE3_ICO").toLatin1());
+ else
+ continue;
+ QPixmap aPM = aResMgr->loadPixmap( "HYDRO", iconStr );
+ QListWidgetItem* item = new QListWidgetItem(QIcon(aPM), aBP);
+ myAvailableBoundaryPolygons->addItem(item);
+ }
+}
+
+QStringList HYDROGUI_CalculationDlg::getSelectedBoundaryPolygons() const
+{
+ return getSelected( myBoundaryPolygons );
+}
+
+QStringList HYDROGUI_CalculationDlg::getSelectedISBoundaryPolygons() const
+{
+ return getSelected( myISBoundaryPolygons );
+}
+
+QStringList HYDROGUI_CalculationDlg::getSelectedAvailableBoundaryPolygons() const
+{
+ return getSelected( myAvailableBoundaryPolygons );
+}
+
+void HYDROGUI_CalculationDlg::includeBoundaryPolygons( const QStringList& theObjects )
+{
+ moveItems( myAvailableBoundaryPolygons, myBoundaryPolygons, theObjects );
+}
+
+void HYDROGUI_CalculationDlg::includeISBoundaryPolygons( const QStringList& theObjects )
+{
+ moveItems( myAvailableBoundaryPolygons, myISBoundaryPolygons, theObjects );
+}
+
+void HYDROGUI_CalculationDlg::excludeBoundaryPolygons( const QStringList& theObjects )
+{
+ moveItems( myBoundaryPolygons, myAvailableBoundaryPolygons, theObjects );
+}
+
+void HYDROGUI_CalculationDlg::excludeISBoundaryPolygons( const QStringList& theObjects )
+{
+ moveItems( myISBoundaryPolygons, myAvailableBoundaryPolygons, theObjects );
+}
+
/**
Get creation mode.
@param theMode the mode
QStringList getSelectedAvailableGeomObjects() const;
QStringList getSelectedGroups() const;
QStringList getSelectedAvailableGroups() const;
+ QStringList getSelectedBoundaryPolygons() const;
+ QStringList getSelectedISBoundaryPolygons() const;
+ QStringList getSelectedAvailableBoundaryPolygons() const;
HYDROGUI_Zone* getCurrentZone() const;
void setAvailableGroups( const QStringList& );
+ void setAvailableBoundaryPolygons( const QStringList&, const QVector<int>& );
+
void setEditZonesEnabled( const bool theIsEnabled );
HYDROData_ListOfRules getRules() const;
void excludeGeomObjects( const QStringList& theObjects );
void includeGroups( const QStringList& theObjects );
void excludeGroups( const QStringList& theObjects );
+
+ void includeBoundaryPolygons( const QStringList& theObjects );
+ void includeISBoundaryPolygons( const QStringList& theObjects );
+
+ void excludeBoundaryPolygons( const QStringList& theObjects );
+ void excludeISBoundaryPolygons( const QStringList& theObjects );
+
+
void onEmptyName();
void onAlreadyExists( QString theName );
void refreshZonesBrowser();
void removeGroups();
void groupsSelected();
+ void addBoundaryPolygons();
+ void removeBoundaryPolygons();
+
void boundarySelected( const QString & theObjName );
void setMergeType( int theMergeType, QString& theBathymetryName );
void createRegion( const QList<SUIT_DataObject*>& theZonesList );
QWizardPage* createObjectsPage();
QWizardPage* createGroupsPage();
+ QWizardPage* createBoundaryPolygonsPage();
+
QWizardPage* createLandCoverMapPage();
QWizardPage* createZonesPage();
QListWidget* myAvailableGroups;
QListWidget* myGroups;
+ QListWidget* myAvailableBoundaryPolygons;
+ QListWidget* myBoundaryPolygons;
+ QListWidget* myISBoundaryPolygons;
+
+
HYDROGUI_DataBrowser* myBrowser;
Handle(HYDROData_CalculationCase) myEditedObject;
QComboBox* myBathymetryChoice;
#include <HYDROData_Object.h>
#include <HYDROData_Tool.h>
#include <HYDROData_StricklerTable.h>
+#include <HYDROData_BCPolygon.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
connect( aPanel, SIGNAL( addGroups() ), SLOT( onAddGroups() ) );
connect( aPanel, SIGNAL( removeGroups() ), SLOT( onRemoveGroups() ) );
+ connect( aPanel, SIGNAL( addBoundaryPolygons() ), SLOT( onAddBoundaryPolygons() ) );
+ connect( aPanel, SIGNAL( removeBoundaryPolygons() ), SLOT( onRemoveBoundaryPolygons() ) );
+
connect( aPanel, SIGNAL( orderChanged( bool& ) ), SLOT( onOrderChanged( bool& ) ) );
connect( aPanel, SIGNAL( ruleChanged( bool& ) ), SLOT( onRuleChanged( bool& ) ) );
setAvailableGroups();
}
else if( theIndex==2 )
+ {
+ setAvailableBoundaryPolygons();
+ }
+ else if( theIndex==3 )
{
// Land cover map panel
HYDROGUI_CalculationDlg* aPanel =
closePreview( false );
createPreview( true );
}
- else if( theIndex==3 )
+ else if( theIndex==4 )
{
HYDROGUI_CalculationDlg* aPanel =
::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
closePreview( false );
createPreview( false );
}
- if( theIndex==2 )
+ if( theIndex==3 )
{
setLandCoverMapVisible( true );
// Hide zones
setZonesVisible( false );
}
- else if( theIndex==3 )
+ else if( theIndex==4 )
{
AssignDefaultZonesColors();
aPanel->excludeGroups( aSelectedList );
}
+
+void HYDROGUI_CalculationOp::setAvailableBoundaryPolygons()
+{
+ HYDROGUI_CalculationDlg* aPanel = ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+
+ HYDROData_Iterator anIter( doc(), KIND_BC_POLYGON );
+ Handle(HYDROData_BCPolygon) aBCP;
+ QStringList aNames;
+ QVector<int> aTypes;
+ for (;anIter.More(); anIter.Next())
+ {
+ aBCP = Handle(HYDROData_BCPolygon)::DownCast( anIter.Current() );
+ aNames.append(aBCP->GetName());
+ aTypes.append(aBCP->GetBoundaryType());
+ }
+ HYDROData_SequenceOfObjects aBCPSeq = myEditedObject->GetBoundaryPolygons();
+
+ QStringList aListCut, aListIS;
+ for (int i=1; i<=aBCPSeq.Size();i++)
+ {
+ int type = Handle(HYDROData_BCPolygon)::DownCast(aBCPSeq(i))->GetBoundaryType();
+ if (type == 1)
+ aListCut << aBCPSeq(i)->GetName();
+ else if (type == 2 || type == 3)
+ aListIS << aBCPSeq(i)->GetName();
+ }
+
+ aPanel->setAvailableBoundaryPolygons( aNames, aTypes );
+ aPanel->includeBoundaryPolygons( aListCut );
+ aPanel->includeISBoundaryPolygons( aListIS );
+}
+
+void HYDROGUI_CalculationOp::onRemoveBoundaryPolygons()
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ QStringList aSelectedListCut = aPanel->getSelectedBoundaryPolygons();
+ QStringList aSelectedListIS = aPanel->getSelectedISBoundaryPolygons();
+
+ if ( aSelectedListCut.isEmpty() && aSelectedListIS.isEmpty() )
+ return;
+
+ for (int i = 0; i < aSelectedListCut.length(); i++)
+ {
+ Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedListCut.at(i) ) );
+ if ( aBCPoly.IsNull() )
+ continue;
+ myEditedObject->RemoveBoundaryPolygon( aBCPoly );
+ }
+
+ for (int i = 0; i < aSelectedListIS.length(); i++)
+ {
+ Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedListIS.at(i) ) );
+ if ( aBCPoly.IsNull() )
+ continue;
+ myEditedObject->RemoveBoundaryPolygon( aBCPoly );
+ }
+
+ aPanel->excludeBoundaryPolygons( aSelectedListCut );
+ aPanel->excludeISBoundaryPolygons( aSelectedListIS );
+}
+
+
+void HYDROGUI_CalculationOp::onAddBoundaryPolygons()
+{
+ HYDROGUI_CalculationDlg* aPanel = ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ QStringList aSelectedList = aPanel->getSelectedAvailableBoundaryPolygons();
+ if ( aSelectedList.isEmpty())
+ return;
+
+ QStringList anAddedListCut, anAddedListIS;
+ for (int i = 0; i < aSelectedList.length(); i++)
+ {
+ Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
+ if ( aBCPoly.IsNull() )
+ continue;
+
+ if ( myEditedObject->AddBoundaryPolygon( aBCPoly ) )
+ {
+ QString aName = aBCPoly->GetName();
+ int type = aBCPoly->GetBoundaryType();
+ if (type == 1)
+ anAddedListCut.append(aName);
+ else if (type == 2 || type == 3)
+ anAddedListIS.append(aName);
+ }
+
+ }
+
+ if ( !anAddedListCut.isEmpty() )
+ aPanel->includeBoundaryPolygons(anAddedListCut);
+ if ( !anAddedListIS.isEmpty() )
+ aPanel->includeISBoundaryPolygons(anAddedListIS);
+}
+
void HYDROGUI_CalculationOp::onChangeMode( int theMode )
{
HYDROGUI_CalculationDlg* aPanel =
void setAvailableGroups();
+ void setAvailableBoundaryPolygons();
+
protected slots:
/**
*/
void onRemoveGroups();
+ void onAddBoundaryPolygons();
+
+ void onRemoveBoundaryPolygons();
+
/**
* Set the given bathymetry/type merge type to the current zone.
*/
#include <HYDROData_Stream.h>
#include <HYDROData_StricklerTable.h>
#include <HYDROData_LandCoverMap.h>
+#include <HYDROData_BCPolygon.h>
#include <CAM_Module.h>
#include <CAM_Study.h>
// OBSTACLES
LightApp_DataObject* anObstaclesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_OBSTACLE ).toLatin1() ) );
+ //BC Polygons
+ LightApp_DataObject* aBCPolygonRootObj = createObject( aNewRootObj, tr( partitionName( KIND_BC_POLYGON ).toLatin1() ) );
+
// STRICKLER TABLES
LightApp_DataObject* aStricklerTablesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_STRICKLER_TABLE ).toLatin1() ) );
obj = createObject( aVisualStateRootObj, aVisualStateObj );
}
+ break;
+ }
+ case KIND_BC_POLYGON:
+ {
+ Handle(HYDROData_BCPolygon) aBCPolygonObj =
+ Handle(HYDROData_BCPolygon)::DownCast( anObj );
+ if( !aBCPolygonObj.IsNull() ) {
+ obj = createObject( aBCPolygonRootObj, aBCPolygonObj );
+ }
+
break;
}
}
case KIND_STRICKLER_TABLE: return "STRICKLER_TABLES";
case KIND_LAND_COVER_MAP: return "LAND_COVER_MAPS";
case KIND_REGION: return "REGIONS";
+ case KIND_BC_POLYGON: return "BOUNDARY_POLYGONS";
default: break;
}
return QString();
aKind == KIND_SHAPES_GROUP || aKind == KIND_SPLIT_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_LAND_COVER_MAP;
+ aKind == KIND_DIGUE || aKind == KIND_DUMMY_3D || aKind == KIND_LAND_COVER_MAP ||
+ aKind == KIND_BC_POLYGON;
if ( !visibility )
{
Handle(HYDROData_Profile) aProfObj = Handle(HYDROData_Profile)::DownCast( theModelObject );
HYDROData_SequenceOfObjects aPolylines = aLandCoverMapObj->GetPolylines();
buildObjectPartition( aGuiObj, aPolylines, tr( "LAND_COVER_POLYLINES" ), true );*/
}
-
+ else if ( anObjectKind == KIND_BC_POLYGON )
+ {
+ Handle(HYDROData_BCPolygon) aBCObj =
+ Handle(HYDROData_BCPolygon)::DownCast( aDataObj );
+
+ LightApp_DataObject* aPolylineSect =
+ createObject( aGuiObj, tr( "BC_POLYGON_POLYLINE" ), aGuiObj->entry() );
+
+ Handle(HYDROData_PolylineXY) aPolyline = aBCObj->GetPolyline();
+ if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
+ createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
+ }
HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
if( aModule )
aModule->enableLCMActions();
#include <HYDROData_Object.h>
#include <HYDROData_ArtificialObject.h>
#include <HYDROData_NaturalObject.h>
+#include <HYDROData_BCPolygon.h>
#include <TDF_Tool.hxx>
painter.end();
return qpmD;
}
+ else if (anObjectKind == KIND_BC_POLYGON)
+ {
+ Handle(HYDROData_BCPolygon) aBCObj = Handle(HYDROData_BCPolygon)::DownCast( aDataObject );
+ int aBT = aBCObj->GetBoundaryType();
+ if (aBT == 1)
+ anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE1_ICO").toLatin1());
+ else if (aBT == 2)
+ anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE2_ICO").toLatin1());
+ else if (aBT == 3)
+ anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE3_ICO").toLatin1());
+ else
+ anIcon = QObject::tr( QString("HYDRO_BC_POLYGON_TYPE_UNDEF_ICO").toLatin1());
+ }
else
anIcon = QObject::tr( QString("HYDRO_%1TYPE%2_ICO").arg( aNeedUpdate ).arg( anObjectKind ).toLatin1() );
}
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ImportBCPolygonOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_Tool2.h"
+#include <HYDROData_PolylineXY.h>
+
+#include <HYDROData_BCPolygon.h>
+#include <HYDROGUI_DataObject.h>
+
+#include <HYDROGUI_ImportPolylineOp.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_FileDlg.h>
+#include <LightApp_Application.h>
+
+#include <QApplication>
+#include <QFile>
+#include <QFileInfo>
+#include <SUIT_MessageBox.h>
+
+
+HYDROGUI_ImportBCPolygonOp::HYDROGUI_ImportBCPolygonOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+ setName( tr( "IMPORT_BC_POLYGON" ) );
+}
+
+HYDROGUI_ImportBCPolygonOp::~HYDROGUI_ImportBCPolygonOp()
+{
+}
+
+void HYDROGUI_ImportBCPolygonOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ myFileDlg = new SUIT_FileDlg( module()->getApp()->desktop(), true );
+ myFileDlg->setWindowTitle( getName() );
+ myFileDlg->setFileMode( SUIT_FileDlg::ExistingFiles );
+ myFileDlg->setNameFilter( tr("BC_POLYGON_FILTER") );
+
+ connect( myFileDlg, SIGNAL( accepted() ), this, SLOT( onApply() ) );
+ connect( myFileDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
+
+ myFileDlg->exec();
+}
+
+
+bool HYDROGUI_ImportBCPolygonOp::processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
+{
+ if ( !myFileDlg )
+ {
+ //abort();
+ return false;
+ }
+
+ QStringList aFileNames = myFileDlg->selectedFiles();
+
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ //startDocOperation();
+
+ NCollection_Sequence<Handle(HYDROData_Entity)> importedEnts =
+ HYDROGUI_ImportPolylineOp::ImportPolyOp(aFileNames, doc(), module(),
+ HYDROData_ShapeFile::ImportShapeType_Polygon);
+
+ for (int i=1;i<=importedEnts.Size();i++ )
+ {
+ Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast(importedEnts(i));
+ if (aPolylineXY.IsNull())
+ continue;
+ TopoDS_Shape aTopSh = HYDROData_BCPolygon::generateTopShape(aPolylineXY);
+ if (aTopSh.IsNull())
+ continue;
+
+ //get boundary type from DBF
+ QStringList aDBFTableList;
+ aPolylineXY->GetDBFInfo(aDBFTableList);
+ QVector<QString> aDBFTable = aDBFTableList.toVector();
+ int nbs = aDBFTable.size();
+ QString aBTypeStr;
+ for (int i = 0; i < nbs / 2; i++)
+ if (aDBFTable[i] == "type")
+ {
+ aBTypeStr = aDBFTable[nbs / 2 + i];
+ break;
+ }
+
+ int aBTypeVal = 0;
+ bool Ok = false;
+ aBTypeVal = aBTypeStr.toInt(&Ok);
+ if (!Ok)
+ aBTypeVal = 0;
+
+ QString aPolyXYName = aPolylineXY->GetName();
+ Handle(HYDROData_BCPolygon) aBCObj = Handle(HYDROData_BCPolygon)::DownCast( doc()->CreateObject( KIND_BC_POLYGON ) );
+ aBCObj->SetName( "BP_" + aPolyXYName );
+ aBCObj->SetBoundaryType(aBTypeVal);
+
+ aBCObj->SetFillingColor( aBCObj->DefaultFillingColor() );
+ aBCObj->SetBorderColor( aBCObj->DefaultBorderColor() );
+ aBCObj->SetPolyline( aPolylineXY );
+ aBCObj->Update(aTopSh);
+
+ module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aBCObj, true );
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aBCObj );
+ theBrowseObjectsEntries.append( anEntry );
+ module()->setIsToUpdate( aBCObj );
+ }
+
+ if (!aFileNames.empty())
+ {
+ //commitDocOperation();
+ //commit();
+ //module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init | UF_OCCViewer );
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
+ }
+ //else
+ // abort();
+
+ QApplication::restoreOverrideCursor();
+ return true;
+}
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_IMPORTBCPOLYGON_H
+#define HYDROGUI_IMPORTBCPOLYGON_H
+
+#include "HYDROGUI_Operation.h"
+#include <vector>
+
+#include <NCollection_Sequence.hxx>
+
+class SUIT_FileDlg;
+class HYDROData_Entity;
+
+class HYDROGUI_ImportBCPolygonOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_ImportBCPolygonOp( HYDROGUI_Module* theModule );
+ virtual ~HYDROGUI_ImportBCPolygonOp();
+
+protected:
+ virtual void startOperation();
+ // virtual void onApply();
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
+ void UpdateView( NCollection_Sequence<Handle(HYDROData_Entity)>& anEntities);
+
+private:
+ SUIT_FileDlg* myFileDlg;
+};
+
+#endif
myFileDlg->exec();
}
-void HYDROGUI_ImportPolylineOp::onApply()
+NCollection_Sequence<Handle(HYDROData_Entity)> HYDROGUI_ImportPolylineOp::ImportPolyOp(
+ const QStringList& aFileNames, Handle(HYDROData_Document) theDocument,
+ HYDROGUI_Module* module, HYDROData_ShapeFile::ImportShapeType theShapeTypesToImport)
{
- if ( !myFileDlg )
- {
- abort();
- return;
- }
-
- QStringList aFileNames = myFileDlg->selectedFiles();
-
- QApplication::setOverrideCursor( Qt::WaitCursor );
- startDocOperation();
-
+ NCollection_Sequence<Handle(HYDROData_Entity)> importedEntities;
foreach (QString aFileName, aFileNames)
{
if ( aFileName.isEmpty() )
HYDROData_ShapeFile anImporter;
NCollection_Sequence<Handle(HYDROData_Entity)> theEntities;
int aShapeTypeOfFile = -1;
- int aStat = anImporter.ImportPolylines(doc(), aFileName, theEntities, aShapeTypeOfFile );
+ int aStat = anImporter.ImportPolylines(theDocument, aFileName, theEntities,
+ aShapeTypeOfFile, theShapeTypesToImport );
if (aStat == 1 || aStat == 2)
{
//try to import DBF
}
if (indNameAttrFound != -1)
- bUseNameAttrFound = SUIT_MessageBox::question( module()->getApp()->desktop(),
+ bUseNameAttrFound = SUIT_MessageBox::question( module->getApp()->desktop(),
tr( "IMPORT_POLYLINE" ),
tr( "IMPORT_POLYLINE_USE_NAME_ATTR" ),
QMessageBox::Yes | QMessageBox::No,
}
}
if (aStat == 1)
- UpdateView(theEntities);
+ UpdateView(module, theEntities);
else if (aStat == 2)
{
- UpdateView(theEntities);
- SUIT_MessageBox::information(module()->getApp()->desktop(),
- tr( "IMPORT_POLYLINE" ), "Contour of the polygon(s) have been imported as polyline(s)");
+ UpdateView(module, theEntities);
+ if (theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All) //if other flag = > no need to show this messagebox
+ SUIT_MessageBox::information(module->getApp()->desktop(),
+ tr( "IMPORT_POLYLINE" ), "Contour of the polygon(s) have been imported as polyline(s)");
}
else
{
aMess += "Cannot open SHX file";
else
aMess += "The shape type of file is " + anImporter.GetShapeTypeName(aShapeTypeOfFile);
- SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_POLYLINE" ), aMess);
+ SUIT_MessageBox::warning( module->getApp()->desktop(), tr( "IMPORT_POLYLINE" ), aMess);
}
+ importedEntities.Append(theEntities);
}
}
+ return importedEntities;
+}
+
+void HYDROGUI_ImportPolylineOp::onApply()
+{
+ if ( !myFileDlg )
+ {
+ abort();
+ return;
+ }
+
+ QStringList aFileNames = myFileDlg->selectedFiles();
+
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ startDocOperation();
+
+ ImportPolyOp(aFileNames, doc(), module(), HYDROData_ShapeFile::ImportShapeType_All);
+
if (!aFileNames.empty())
{
commitDocOperation();
QApplication::restoreOverrideCursor();
}
-void HYDROGUI_ImportPolylineOp::UpdateView( NCollection_Sequence<Handle(HYDROData_Entity)>& anEntities)
+void HYDROGUI_ImportPolylineOp::UpdateView( HYDROGUI_Module* module, NCollection_Sequence<Handle(HYDROData_Entity)>& anEntities)
{
- size_t anActiveViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
+ size_t anActiveViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module );
if ( anActiveViewId == 0 )
- anActiveViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() );
+ anActiveViewId = HYDROGUI_Tool::GetActiveOCCViewId( module );
for (int i = 1; i <= anEntities.Size() ; i++)
{
anEntities(i)->Update();
- module()->setObjectVisible( anActiveViewId, anEntities(i), true );
- module()->setIsToUpdate( anEntities(i) );
+ module->setObjectVisible( anActiveViewId, anEntities(i), true );
+ module->setIsToUpdate( anEntities(i) );
}
}
#include <vector>
#include <NCollection_Sequence.hxx>
+#include <HYDROData_ShapeFile.h>
class SUIT_FileDlg;
class HYDROData_Entity;
public:
HYDROGUI_ImportPolylineOp( HYDROGUI_Module* theModule );
+
virtual ~HYDROGUI_ImportPolylineOp();
+ static NCollection_Sequence<Handle(HYDROData_Entity)> ImportPolyOp(const QStringList& aFileNames,
+ Handle(HYDROData_Document) theDocument,
+ HYDROGUI_Module* module,
+ HYDROData_ShapeFile::ImportShapeType theShapeTypesToImport);
+
protected:
+
virtual void startOperation();
virtual void onApply();
- void UpdateView( NCollection_Sequence<Handle(HYDROData_Entity)>& anEntities);
+
+ static void UpdateView( HYDROGUI_Module* module, NCollection_Sequence<Handle(HYDROData_Entity)>& anEntities);
private:
SUIT_FileDlg* myFileDlg;
bool anIsObjectCanBeColored = false;
bool isRoot = false;
bool isStreamHasBottom = false;
+ bool anIsBCPolygon = false;
SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
SUIT_DataOwnerPtrList anOwners;
anIsStricklerTable = true;
else if( anObjectKind == KIND_LAND_COVER_MAP )
anIsLandCoverMap = true;
+ else if (anObjectKind == KIND_BC_POLYGON)
+ anIsBCPolygon = true;
else if( anObjectKind == KIND_STREAM )
{
anIsStream = true;
case KIND_VISUAL_STATE:
theMenu->addAction( action( SaveVisualStateId ) );
break;
+ case KIND_BC_POLYGON:
+ theMenu->addAction( action( ImportBCPolygonId ) );
+ break;
}
theMenu->addSeparator();
}
}
else if (anIsZone)
theMenu->addAction( action( ZoneSetColorId ) );
+ else if (anIsBCPolygon)
+ theMenu->addAction( action( SetBoundaryTypePolygonId ) );
if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
{
anIsImmersibleZone || anIsZone || anIsRegion ||
anIsBathymetry || anIsObstacle || anIsStream ||
anIsChannel || anIsDigue || anIsDummyObject3D ||
- anIsValidProfile || anIsGroup || anIsLandCoverMap )
+ anIsValidProfile || anIsGroup || anIsLandCoverMap ||
+ anIsBCPolygon)
{
if( anIsHiddenInSelection )
theMenu->addAction( action( ShowId ) );
#include "HYDROGUI_RiverBottomOp.h"
#include "HYDROGUI_ProfileInterpolateOp.h"
#include "HYDROGUI_RecognizeContoursOp.h"
+#include <HYDROGUI_ImportBCPolygonOp.h>
#include "HYDROGUI_SubmersibleOp.h"
#include "HYDROGUI_StricklerTableOp.h"
#include "HYDROGUI_DuplicateOp.h"
#include "HYDROGUI_PolylineStyleOp.h"
#include "HYDROGUI_ZoneSetColorOp.h"
#include <HYDROGUI_ShowAttrPolyOp.h>
+#include <HYDROGUI_SetBoundaryTypePolygonOp.h>
#include <HYDROData_Document.h>
#include <HYDROData_Obstacle.h>
#include <HYDROData_SplitToZonesTool.h>
createAction( ExportSinusXId, "EXPORT_SINUSX", "EXPORT_SINUSX_ICO" );
createAction( ImportLandCoverMapId, "IMPORT_LANDCOVER_MAP", "IMPORT_LANDCOVER_MAP_ICO" );
+ createAction( ImportBCPolygonId, "IMPORT_BC_POLYGON", "IMPORT_BC_POLYGON_ICO" );
+
createAction( CreatePolylineId, "CREATE_POLYLINE", "CREATE_POLYLINE_ICO" );
createAction( EditPolylineId, "EDIT_POLYLINE", "EDIT_POLYLINE_ICO" );
createAction( RegenerateRegionColorsId, "REGENERATE_REGION_COLORS" );
createAction( ZoneSetColorId, "ZONE_SET_COLOR" );
createAction( ShowHideArrows, "SHOW_HIDE_ARROWS" );
+ createAction( SetBoundaryTypePolygonId, "SET_BOUNDARY_TYPE_POLYGON" );
}
void HYDROGUI_Module::createMenus()
createTool( ExportSinusXId, aToolBar );
createTool( ImportLandCoverMapId, aToolBar );
+ createTool( ImportBCPolygonId, aToolBar );
+
createTool( ImportBathymetryId, aToolBar );
createTool( CreatePolylineId, aToolBar );
createTool( CreatePolyline3DId, aToolBar );
case ExportSinusXId:
anOp = new HYDROGUI_ExportSinusXOp( aModule );
break;
+ case ImportBCPolygonId:
+ anOp = new HYDROGUI_ImportBCPolygonOp( aModule );
+ break;
case ObserveImageId:
anOp = new HYDROGUI_ObserveImageOp( aModule );
break;
case ShowAttrPolylinesId:
anOp = new HYDROGUI_ShowAttrPolyOp( aModule );
break;
+ case SetBoundaryTypePolygonId:
+ anOp = new HYDROGUI_SetBoundaryTypePolygonOp( aModule );
+ break;
case LandCoverScalarMapModeOnId:
case LandCoverScalarMapModeOffId:
anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId );
ImportPolylineId,
ImportSinusXId,
ExportSinusXId,
-
+ ImportBCPolygonId,
+
ExportToShapeFileID,
ImportLandCoverMapId,
BathymetryRescaleDefaultId,
RegenerateRegionColorsId,
ShowHideArrows,
- ZoneSetColorId
+ ZoneSetColorId,
+ SetBoundaryTypePolygonId
};
#endif
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_SetBoundaryTypePolygonDlg.h"
+#include <QVBoxLayout>
+#include <QPushButton>
+#include <QFrame>
+#include <QLabel>
+#include <QFrame>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <QListWidgetItem>
+
+HYDROGUI_SetBoundaryTypePolygonDlg::HYDROGUI_SetBoundaryTypePolygonDlg( QWidget* theParent, int theType )
+ : QDialog( theParent )
+{
+ QVBoxLayout* aMainLayout = new QVBoxLayout( this );
+ aMainLayout->setMargin( 5 );
+ aMainLayout->setSpacing( 5 );
+
+ QFrame* aBTFrame = new QFrame( this );
+ QLabel* aBoundaryLabel = new QLabel( tr( "BOUNDARY_TYPE" ), aBTFrame );
+ myBTBox = new QComboBox( aBTFrame );
+ myBTBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ QStringList Types;
+ Types << QObject::tr( QString("HYDRO_BC_POLYGON_TYPE1_ICO").toLatin1()) <<
+ QObject::tr( QString("HYDRO_BC_POLYGON_TYPE2_ICO").toLatin1()) <<
+ QObject::tr( QString("HYDRO_BC_POLYGON_TYPE3_ICO").toLatin1());
+
+ myBTBox->addItem(QIcon( aResMgr->loadPixmap( "HYDRO", Types[0])), tr( "CUT_TOOL" ));
+ myBTBox->addItem(QIcon( aResMgr->loadPixmap( "HYDRO", Types[1])), tr( "INCLUDE_TOOL" ));
+ myBTBox->addItem(QIcon( aResMgr->loadPixmap( "HYDRO", Types[2])), tr( "SELECTION_TOOL" ));
+
+ if (theType != 1 && theType != 2 && theType != 3)
+ theType = -1;
+ myBTBox->setCurrentIndex(theType - 1);
+
+ QBoxLayout* aColorLayout = new QHBoxLayout( aBTFrame );
+ aColorLayout->setMargin( 10 );
+ aColorLayout->setSpacing( 5 );
+ aColorLayout->addWidget( aBoundaryLabel );
+ aColorLayout->addWidget( myBTBox );
+
+ aMainLayout->addWidget( aBTFrame );
+
+ // Buttons
+ QPushButton* anOkButton = new QPushButton( tr( "OK" ), this );
+ anOkButton->setDefault( true );
+ QPushButton* aCancelButton = new QPushButton( tr( "CANCEL" ), this );
+ aCancelButton->setAutoDefault( true );
+
+ QHBoxLayout* aButtonsLayout = new QHBoxLayout;
+ aButtonsLayout->setMargin( 5 );
+ aButtonsLayout->setSpacing( 5 );
+ aButtonsLayout->addWidget( anOkButton );
+ aButtonsLayout->addStretch();
+ aButtonsLayout->addWidget( aCancelButton );
+
+ aMainLayout->addStretch();
+ aMainLayout->addLayout( aButtonsLayout );
+
+ setLayout( aMainLayout );
+
+ connect( anOkButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( aCancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
+}
+
+int HYDROGUI_SetBoundaryTypePolygonDlg::GetCurrentType()
+{
+ return myBTBox->currentIndex();
+}
+
+HYDROGUI_SetBoundaryTypePolygonDlg::~HYDROGUI_SetBoundaryTypePolygonDlg()
+{
+}
+
+
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_SETBOUNDARYTYPEPOLYGONDLG_H
+#define HYDROGUI_SETBOUNDARYTYPEPOLYGONDLG_H
+
+#include <QComboBox>
+#include <QDialog>
+
+class HYDROGUI_SetBoundaryTypePolygonDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+
+ HYDROGUI_SetBoundaryTypePolygonDlg( QWidget* theParent, int theType );
+
+ virtual ~HYDROGUI_SetBoundaryTypePolygonDlg();
+
+ int GetCurrentType();
+
+private:
+
+ QComboBox* myBTBox;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_SetBoundaryTypePolygonOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+
+#include <HYDROData_Object.h>
+#include <HYDROData_BCPolygon.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <SUIT_Desktop.h>
+#include <HYDROGUI_Tool2.h>
+#include <HYDROGUI_SetBoundaryTypePolygonDlg.h>
+#include <SUIT_MessageBox.h>
+#include <HYDROGUI_UpdateFlags.h>
+
+HYDROGUI_SetBoundaryTypePolygonOp::HYDROGUI_SetBoundaryTypePolygonOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule ),
+ mySetBTDlg( 0 )
+{
+ setName( tr( "SET_BOUNDARY_TYPE_POLYGON" ) );
+}
+
+HYDROGUI_SetBoundaryTypePolygonOp::~HYDROGUI_SetBoundaryTypePolygonOp()
+{
+}
+
+void HYDROGUI_SetBoundaryTypePolygonOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects(module());
+ myBCP = Handle(HYDROData_BCPolygon)::DownCast(aSeq(1));
+
+ int bType = myBCP->GetBoundaryType();
+
+ mySetBTDlg = new HYDROGUI_SetBoundaryTypePolygonDlg( module()->getApp()->desktop(), bType );
+ mySetBTDlg->setModal( true );
+ mySetBTDlg->setWindowTitle(getName());
+
+ // Connect the dialog to operation slots
+ connect( mySetBTDlg, SIGNAL( accepted() ), this, SLOT( onApply() ) );
+ connect( mySetBTDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
+
+ mySetBTDlg->exec();
+}
+
+ bool HYDROGUI_SetBoundaryTypePolygonOp::processApply( int& theUpdateFlags,
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
+{
+ if ( !mySetBTDlg )
+ return false;
+
+ int aType = mySetBTDlg->GetCurrentType();
+
+ myBCP->SetBoundaryType( aType + 1 );
+ myBCP->SetFillingColor( myBCP->DefaultFillingColor() );
+ myBCP->SetBorderColor( myBCP->DefaultBorderColor() );
+
+ module()->setIsToUpdate( myBCP );
+
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced;
+
+ return true;
+}
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_SETBOUNDARYTYPEPOLYGONOP_H
+#define HYDROGUI_SETBOUNDARYTYPEPOLYGONOP_H
+
+#include "HYDROGUI_Operation.h"
+#include <HYDROData_Entity.h>
+
+class HYDROData_BCPolygon;
+class HYDROGUI_SetBoundaryTypePolygonDlg;
+
+class HYDROGUI_SetBoundaryTypePolygonOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_SetBoundaryTypePolygonOp( HYDROGUI_Module* theModule );
+
+ virtual ~HYDROGUI_SetBoundaryTypePolygonOp();
+
+ bool processApply( int& theUpdateFlags,
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries );
+
+protected:
+ virtual void startOperation();
+
+private:
+
+ HYDROGUI_SetBoundaryTypePolygonDlg* mySetBTDlg;
+
+ Handle(HYDROData_BCPolygon) myBCP;
+};
+
+#endif
\ No newline at end of file
#include <HYDROData_Document.h>
#include <HYDROData_DummyObject3D.h>
#include <HYDROData_ImmersibleZone.h>
+#include <HYDROData_BCPolygon.h>
#include <HYDROData_Obstacle.h>
#include <HYDROData_PolylineXY.h>
#include <HYDROData_Polyline3D.h>
setShape( aCompound, false, false );
}
+ else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_BCPolygon) ) )
+ {
+ Handle(HYDROData_BCPolygon) aBCObj = Handle(HYDROData_BCPolygon)::DownCast( myObject );
+
+ TopoDS_Shape aBCShape = aBCObj->GetTopShape();
+ if ( !aBCShape.IsNull() )
+ {
+ if ( aBCShape.ShapeType() == TopAbs_FACE )
+ {
+ TopoDS_Face aBCFace = TopoDS::Face( aBCShape );
+ setFace( aBCFace, false, false, "" );
+ }
+ else
+ {
+ myTopoShape = aBCShape;
+ myDisplayMode = AIS_Shaded;
+ buildShape();
+ updateShape( false, false );
+ }
+ }
+
+ QColor aFillingColor = aBCObj->GetFillingColor();
+ QColor aBorderColor = aBCObj->GetBorderColor();
+ aFillingColor.setAlpha(175);
+
+ setFillingColor( aFillingColor, false, false );
+ setBorderColor( aBorderColor, false, false );
+ }
+
}
if ( myShapes.empty() || !isVisible() )
anObjectKind == KIND_DIGUE ||
anObjectKind == KIND_DUMMY_3D ||
anObjectKind == KIND_BATHYMETRY ||
+ anObjectKind == KIND_BC_POLYGON ||
anObjectKind == KIND_LAND_COVER_MAP
#ifdef DEB_GROUPS
|| anObjectKind == KIND_SHAPES_GROUP ||
#include <HYDROData_DummyObject3D.h>
#include <HYDROData_Image.h>
#include <HYDROData_ImmersibleZone.h>
+#include <HYDROData_BCPolygon.h>
#include <HYDROData_Obstacle.h>
#include <HYDROData_PolylineXY.h>
#include <HYDROData_Polyline3D.h>
//setFillingColor( aFillingColor, false, false );
//setBorderColor( aBorderColor, false, false );
}
+ else if ( anObject->IsKind( STANDARD_TYPE(HYDROData_BCPolygon) ) )
+ {
+ Handle(HYDROData_BCPolygon) aBCObj =
+ Handle(HYDROData_BCPolygon)::DownCast( anObject );
+
+ TopoDS_Shape aBCShape = aBCObj->GetTopShape();
+ if ( !aBCShape.IsNull() )
+ {
+ if ( aBCShape.ShapeType() == TopAbs_FACE )
+ {
+ TopoDS_Face aFace = TopoDS::Face( aBCShape );
+ setFace( aFace, false, false );
+ }
+ else
+ {
+ myTopoShape = aBCShape;
+ }
+ }
+
+ QColor aFillingColor = aBCObj->GetFillingColor();
+ QColor aBorderColor = aBCObj->GetBorderColor();
+ }
+
}
}
<source>HYDRO_SUBMERSIBLE16_ICO</source>
<translation>icon_sumb_16.png</translation>
</message>
-
+ <message>
+ <source>HYDRO_BC_POLYGON_TYPE1_ICO</source>
+ <translation>icon_bc_polygon_type_1.png</translation>
+ </message>
+ <message>
+ <source>HYDRO_BC_POLYGON_TYPE2_ICO</source>
+ <translation>icon_bc_polygon_type_2.png</translation>
+ </message>
+ <message>
+ <source>HYDRO_BC_POLYGON_TYPE3_ICO</source>
+ <translation>icon_bc_polygon_type_3.png</translation>
+ </message>
+ <message>
+ <source>HYDRO_BC_POLYGON_TYPE_UNDEF_ICO</source>
+ <translation>icon_bc_polygon_type_undef.png</translation>
+ </message>
<!-- Icons for objects -->
<message>
<message>
<source>BATHYMETRY_RESCALE_DEFAULT_ICO</source>
<translation>icon_bathymetry_rescale_default.png</translation>
- </message> </context>
+ </message>
+ <message>
+ <source>IMPORT_BC_POLYGON_ICO</source>
+ <translation>icon_bc_import.png</translation>
+ </message>
+ </context>
</TS>
<source>NATURAL_OBJECTS</source>
<translation>NATURAL OBJECTS</translation>
</message>
+ <message>
+ <source>BOUNDARY_POLYGONS</source>
+ <translation>BOUNDARY POLYGONS</translation>
+ </message>
<message>
<source>BATHYMETRY_FILTER</source>
<translation>Bathymetry files (*.xyz);;ASC files (*.asc);;All files (*.* *)</translation>
<source>INCLUDED_GROUPS</source>
<translation>Included groups</translation>
</message>
+ <message>
+ <source>INCLUDED_BOUNDARY_POLYGONS_CUT</source>
+ <translation>Included boundary polygons (cut tools)</translation>
+ </message>
+ <message>
+ <source>INCLUDED_BOUNDARY_POLYGONS_INCSEL</source>
+ <translation>Included boundary polygons (include/selection tools)</translation>
+ </message>
+ <message>
+ <source>AVAILABLE_BOUNDARY_POLYGONS</source>
+ <translation>Available boundary polygons</translation>
+ </message>
<message>
<source>LIMITS</source>
<translation>Limits</translation>
<source>DSK_IMPORT_SINUSX</source>
<translation>Import from SinusX</translation>
</message>
+ <message>
+ <source>DSK_IMPORT_BC_POLYGON</source>
+ <translation>Import boundary polygons from SHP file</translation>
+ </message>
<message>
<source>DSK_EXPORT_SINUSX</source>
<translation>Export to SinusX</translation>
<source>MEN_IMPORT_BATHYMETRY</source>
<translation>Import bathymetry</translation>
</message>
+ <message>
+ <source>MEN_IMPORT_BC_POLYGON</source>
+ <translation>Import boundary polygons</translation>
+ </message>
<message>
<source>MEN_EDIT_IMPORTED_BATHYMETRY</source>
<translation>Edit imported bathymetry</translation>
<source>MEN_ZONE_SET_COLOR</source>
<translation>Set color</translation>
</message>
+ <message>
+ <source>MEN_SET_BOUNDARY_TYPE_POLYGON</source>
+ <translation>Set boundary type</translation>
+ </message>
<message>
<source>STB_CREATE_CALCULATION</source>
<translation>Create calculation case</translation>
</message>
</context>
+ <context>
+ <name>HYDROGUI_ImportBCPolygonOp</name>
+ <message>
+ <source>BC_POLYGON_FILTER</source>
+ <translation>Shape files (*.shp)</translation>
+ </message>
+ </context>
+ <context>
+ <name>HYDROGUI_SetBoundaryTypePolygonOp</name>
+ <message>
+ <source>SET_BOUNDARY_TYPE_POLYGON</source>
+ <translation>Set Boundary Type</translation>
+ </message>
+ </context>
+ <context>
+ <name>HYDROGUI_SetBoundaryTypePolygonDlg</name>
+ <message>
+ <source>BOUNDARY_TYPE</source>
+ <translation>Boundary Type: </translation>
+ </message>
+ <message>
+ <source>CUT_TOOL</source>
+ <translation>Cut Tool</translation>
+ </message>
+ <message>
+ <source>INCLUDE_TOOL</source>
+ <translation>Include Tool</translation>
+ </message>
+ <message>
+ <source>SELECTION_TOOL</source>
+ <translation>Selection tool</translation>
+ </message>
+
+ </context>
+
</TS>