]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Merge branch 'BR_v14_rc' of ssh://git.salome-platform.org/modules/hydro into BR_v14_rc
authormkr <mkr@opencascade.com>
Thu, 25 Jun 2015 14:06:12 +0000 (17:06 +0300)
committermkr <mkr@opencascade.com>
Thu, 25 Jun 2015 14:06:12 +0000 (17:06 +0300)
27 files changed:
src/HYDROData/HYDROData_PolylineOperator.cxx
src/HYDROData/HYDROData_PolylineOperator.h
src/HYDROData/HYDROData_PolylineXY.cxx
src/HYDROData/HYDROData_PolylineXY.h
src/HYDROGUI/HYDROGUI_DeleteOp.cxx
src/HYDROGUI/HYDROGUI_ExportFileOp.cxx
src/HYDROGUI/HYDROGUI_ExportFileOp.h
src/HYDROGUI/HYDROGUI_ImportLandCoverOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportLandCoverOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportLandcoverOp.cxx [deleted file]
src/HYDROGUI/HYDROGUI_ImportLandcoverOp.h [deleted file]
src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx
src/HYDROGUI/HYDROGUI_MergePolylinesDlg.cxx
src/HYDROGUI/HYDROGUI_MergePolylinesDlg.h
src/HYDROGUI/HYDROGUI_MergePolylinesOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_SplitPolylinesDlg.cxx
src/HYDROGUI/HYDROGUI_SplitPolylinesDlg.h
src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx
src/HYDROGUI/resources/HYDROGUI_images.ts
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROGUI/resources/icon_export_polyline.png [deleted file]
src/HYDROGUI/resources/icon_export_shp.png [new file with mode: 0644]

index 61c835f6123d389986b42d23e185f3cc4ea43910..e8a7eec82937ebdb4ef51b491f27025a618bfbc6 100644 (file)
 //
 
 #include <HYDROData_PolylineOperator.h>
+#include <HYDROData_Document.h>
 #include <BRepBuilderAPI_MakeEdge2d.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
 #include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
 
 template<class T> void append( std::vector<T>& theList, const std::vector<T>& theList2 )
 {
@@ -34,7 +37,9 @@ template<class T> void append( std::vector<T>& theList, const std::vector<T>& th
 }
 
 
-bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_PolylineXY )& thePolyline,
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+                                        const TCollection_AsciiString& theNamePrefix,
+                                        const Handle( HYDROData_PolylineXY )& thePolyline,
                                         const gp_Pnt2d& thePoint ) const
 {
   std::vector<gp_Pnt2d> aPointsList( 1 );
@@ -44,13 +49,15 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_PolylineXY )& th
   for( int i=0, n=aCurves.size(); i<n; i++ )
   {
     std::vector<Handle( Geom2d_Curve )> aCurvesList = Split( aCurves[i], aPointsList );
-    bool isLocalOK = CreatePolylines( aCurvesList );
+    bool isLocalOK = CreatePolylines( theDoc, theNamePrefix, aCurvesList );
     isOK = isOK && isLocalOK;
   }
   return isOK;
 }
 
-bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_PolylineXY )& thePolyline,
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+                                        const TCollection_AsciiString& theNamePrefix,
+                                        const Handle( HYDROData_PolylineXY )& thePolyline,
                                         const Handle( HYDROData_PolylineXY )& theTool ) const
 {
   std::vector<Handle( Geom2d_Curve )> aCurves = GetCurves( thePolyline );
@@ -61,13 +68,15 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_PolylineXY )& th
     {
       std::vector<gp_Pnt2d> aPointsList = Intersection( aCurves[i], aToolCurves[j] );
       std::vector<Handle( Geom2d_Curve )> aCurvesList = Split( aCurves[i], aPointsList );
-      bool isLocalOK = CreatePolylines( aCurvesList );
+      bool isLocalOK = CreatePolylines( theDoc, theNamePrefix, aCurvesList );
       isOK = isOK && isLocalOK;
     }
   return isOK;
 }
 
-bool HYDROData_PolylineOperator::Split( const HYDROData_SequenceOfObjects& thePolylines )
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+                                        const TCollection_AsciiString& theNamePrefix,
+                                        const HYDROData_SequenceOfObjects& thePolylines )
 {
   int f = thePolylines.Lower(), l = thePolylines.Upper();
   bool isOK = true;
@@ -90,13 +99,15 @@ bool HYDROData_PolylineOperator::Split( const HYDROData_SequenceOfObjects& thePo
       append( aCompletePointsList, aPointsList );
     }
     std::vector<Handle( Geom2d_Curve )> aCurvesList = Split( anAllCurves[i], aCompletePointsList );
-    bool isLocalOK = CreatePolylines( aCurvesList );
+    bool isLocalOK = CreatePolylines( theDoc, theNamePrefix, aCurvesList );
     isOK = isOK && isLocalOK;
   }
   return isOK;
 }
 
-bool HYDROData_PolylineOperator::Merge( const HYDROData_SequenceOfObjects& thePolylines )
+bool HYDROData_PolylineOperator::Merge( const Handle( HYDROData_Document )& theDoc,
+                                        const TCollection_AsciiString& theName,
+                                        const HYDROData_SequenceOfObjects& thePolylines )
 {
   //TODO
   return true;
@@ -125,13 +136,27 @@ std::vector<Handle( Geom2d_Curve )> HYDROData_PolylineOperator::Split( const Han
   return aResult;
 }
 
-bool HYDROData_PolylineOperator::CreatePolylines( const std::vector<Handle( Geom2d_Curve )>& theCurves )
+bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Document )& theDoc,
+                                                  const TCollection_AsciiString& theNamePrefix,
+                                                  const std::vector<Handle( Geom2d_Curve )>& theCurves )
 {
+  if( theDoc.IsNull() )
+    return false;
+
   int n = theCurves.size();
   for( int i=0; i<n; i++ )
   {
     TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge2d( theCurves[i] ).Edge();
-    //TODO
+    BRepBuilderAPI_MakeWire aMakeWire;
+    aMakeWire.Add( anEdge );
+
+    Handle( HYDROData_PolylineXY ) aPolyline = 
+      Handle( HYDROData_PolylineXY )::DownCast( theDoc->CreateObject( KIND_POLYLINEXY ) );
+    if( aPolyline.IsNull() )
+      return false;
+
+    aPolyline->SetShape( aMakeWire.Wire() );
+    //TODO: set name
   }
   return true;
 }
index d3e49e3526e0a1d4e7d7bcb5c94ce79ac844e90a..e11c41ba8772c9561805ac8d9598460837b540a3 100644 (file)
 #include <gp_Pnt2d.hxx>
 #include <vector>
 
-class HYDROData_PolylineOperator
+class Handle( HYDROData_Document );
+
+class HYDRODATA_EXPORT HYDROData_PolylineOperator
 {
 public:
-  HYDRODATA_EXPORT bool Split( const Handle( HYDROData_PolylineXY )& thePolyline,
-                               const gp_Pnt2d& thePoint ) const;
-  HYDRODATA_EXPORT bool Split( const Handle( HYDROData_PolylineXY )& thePolyline,
-                               const Handle( HYDROData_PolylineXY )& theTool ) const;
-  HYDRODATA_EXPORT bool Split( const HYDROData_SequenceOfObjects& thePolylines );
-  HYDRODATA_EXPORT bool Merge( const HYDROData_SequenceOfObjects& thePolylines );
-
-  static HYDRODATA_EXPORT std::vector<Handle( Geom2d_Curve )> GetCurves( const Handle( HYDROData_PolylineXY )& thePolyline );
-
-  static HYDRODATA_EXPORT std::vector<gp_Pnt2d> Intersection( const Handle( Geom2d_Curve )& theCurve,
-                                                              const Handle( Geom2d_Curve )& theTool );
-
-  static HYDRODATA_EXPORT std::vector<Handle( Geom2d_Curve )> Split( const Handle( Geom2d_Curve )& theCurve,
-                                                                     const std::vector<gp_Pnt2d>& thePoints );
-
-  static HYDRODATA_EXPORT bool CreatePolylines( const std::vector<Handle( Geom2d_Curve )>& theCurves );
+  bool Split( const Handle( HYDROData_Document )& theDoc,
+              const TCollection_AsciiString& theNamePrefix,
+              const Handle( HYDROData_PolylineXY )& thePolyline,
+              const gp_Pnt2d& thePoint ) const;
+  bool Split( const Handle( HYDROData_Document )& theDoc,
+              const TCollection_AsciiString& theNamePrefix,
+              const Handle( HYDROData_PolylineXY )& thePolyline,
+              const Handle( HYDROData_PolylineXY )& theTool ) const;
+  bool Split( const Handle( HYDROData_Document )& theDoc,
+              const TCollection_AsciiString& theNamePrefix,
+              const HYDROData_SequenceOfObjects& thePolylines );
+  bool Merge( const Handle( HYDROData_Document )& theDoc,
+              const TCollection_AsciiString& theName,
+              const HYDROData_SequenceOfObjects& thePolylines );
+
+protected:
+  static std::vector<Handle( Geom2d_Curve )> GetCurves( const Handle( HYDROData_PolylineXY )& thePolyline );
+
+  static std::vector<gp_Pnt2d> Intersection( const Handle( Geom2d_Curve )& theCurve,
+                                             const Handle( Geom2d_Curve )& theTool );
+
+  static std::vector<Handle( Geom2d_Curve )> Split( const Handle( Geom2d_Curve )& theCurve,
+                                                    const std::vector<gp_Pnt2d>& thePoints );
+
+  static bool CreatePolylines( const Handle( HYDROData_Document )& theDoc,
+                               const TCollection_AsciiString& theNamePrefix,
+                               const std::vector<Handle( Geom2d_Curve )>& theCurves );
 };
 
 #endif
index 1c824402a3276a9d19d48de047d4790d619d2061..608e5b9510bfa9f2fc2bac174e1e58249b5419f7 100755 (executable)
@@ -247,6 +247,12 @@ TopoDS_Shape HYDROData_PolylineXY::GetShape() const
   return getPolylineShape();
 }
 
+bool HYDROData_PolylineXY::SetShape( const TopoDS_Shape& theShape )
+{
+  setPolylineShape( theShape );
+  return true;
+}
+
 bool convertEdgeToSection( const TopoDS_Edge&                                       theEdge,
                            NCollection_Sequence<TCollection_AsciiString>&           theSectNames,
                            NCollection_Sequence<HYDROData_PolylineXY::SectionType>& theSectTypes,
index a0172fd743de4aed5bb98d2d698d1c3b83fbab62..3036097263f0ea5ff25c87eed0c64c0346253816 100644 (file)
@@ -126,13 +126,13 @@ public:
    * Returns the 2D presentation of all points.
    */
   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() const;
+  HYDRODATA_EXPORT bool SetShape( const TopoDS_Shape& theShape );
 
   /**
    * Returns the 3D presentation of all points.
    */
   HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape );
 
-
   /**
    * Returns flag indicating that polyline can be edited or not.
    */
index 8a85237954bf2078226d85a6eef5001eac94f329..1ef77793f9e786513d5392d6a4cf5074c8eddad8 100644 (file)
@@ -123,8 +123,11 @@ void HYDROGUI_DeleteOp::startOperation()
   for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
   {
     Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
-    if ( !anObject.IsNull() && !anObject->IsRemoved() )
+
+    if ( !anObject.IsNull() && !anObject->IsRemoved() ) {
       anObject->Remove();
+      module()->setObjectRemoved( anObject );
+    }
   }
 
   commitDocOperation();
index 02483407f1cd784252eed68dca1c19b7e87ec0ed..b52e18b030b71a5ed8ee813e60beab4de588545e 100644 (file)
@@ -30,6 +30,7 @@
 #include <HYDROData_Polyline3D.h>
 #include <HYDROGUI_DataObject.h>
 #include <HYDROData_Bathymetry.h>
+#include <HYDROData_LandCover.h>
 
 #include <HYDROData_Profile.h>
 
 #include <QFile>
 #include <QFileInfo>
 #include <SUIT_MessageBox.h>
+#include <TopoDS.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <BRep_Tool.hxx>
+#include <Precision.hxx>
 
 
 HYDROGUI_ExportFileOp::HYDROGUI_ExportFileOp( HYDROGUI_Module* theModule )
 : HYDROGUI_Operation( theModule )
 {
-  setName( tr( "EXPORT_POLYLINE" ) );
+  setName( tr( "EXPORT_TO_SHAPE_FILE" ) );
 }
 
 HYDROGUI_ExportFileOp::~HYDROGUI_ExportFileOp()
@@ -57,13 +64,14 @@ void HYDROGUI_ExportFileOp::startOperation()
 {
   HYDROGUI_Operation::startOperation();
   
-  QString aFilter( "*.shp" ); //temp  ext-n; replace with filter; TODO
+  QString aFilter( tr("SHP_FILTER") ); 
   
   Handle(HYDROData_PolylineXY) aPolyXY;
   Handle(HYDROData_Polyline3D) aPoly3D;
+  Handle(HYDROData_LandCover) aLC;
   NCollection_Sequence<Handle_HYDROData_PolylineXY> aPolyXYSeq;
   NCollection_Sequence<Handle_HYDROData_Polyline3D> aPoly3DSeq;
-
+  NCollection_Sequence<Handle_HYDROData_LandCover> aLCSeq;
   
   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
   for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
@@ -75,13 +83,22 @@ void HYDROGUI_ExportFileOp::startOperation()
     aPoly3D = Handle(HYDROData_Polyline3D)::DownCast( aSeq.Value( anIndex ));
     if (!aPoly3D.IsNull())
       aPoly3DSeq.Append(aPoly3D);
+
+    aLC = Handle(HYDROData_LandCover)::DownCast( aSeq.Value( anIndex ));
+    if (!aLC.IsNull())
+      aLCSeq.Append(aLC);
   }
 
   if (!aPolyXYSeq.IsEmpty() && !aPoly3DSeq.IsEmpty())
     SUIT_MessageBox::warning( module()->getApp()->desktop(), "Export Polyline", "Cannot export polylines of different kind");
   else
   {
-    QString aFileName = SUIT_FileDlg::getFileName( module()->getApp()->desktop(), "", aFilter, tr( "EXPORT_POLYLINE" ), false );
+    QString aPolyName = "";
+    if (aPolyXYSeq.Size() == 1 && aPoly3DSeq.IsEmpty())
+      aPolyName = aPolyXYSeq(1)->GetName();
+    if (aPoly3DSeq.Size() == 1 && aPolyXYSeq.IsEmpty())
+      aPolyName = aPoly3DSeq(1)->GetName();
+    QString aFileName = SUIT_FileDlg::getFileName( module()->getApp()->desktop(), aPolyName, aFilter, tr( "EXPORT_TO_SHAPE_FILE" ), false );
     if (!aFileName.isEmpty())
     {
       SHPHandle hSHPHandle;
@@ -96,7 +113,13 @@ void HYDROGUI_ExportFileOp::startOperation()
         hSHPHandle = SHPCreate( aFileName.toAscii().data(), SHPT_ARCZ );
         for (int i = 1; i <= aPoly3DSeq.Size(); i++)
           WriteObjectPoly3D(hSHPHandle, aPoly3DSeq(i));
-      }      
+      }
+      else if (aPolyXYSeq.IsEmpty() && aPoly3DSeq.IsEmpty() && !aLCSeq.IsEmpty())
+      {
+        hSHPHandle = SHPCreate( aFileName.toAscii().data(), SHPT_POLYGON );
+        for (int i = 1; i <= aLCSeq.Size(); i++)
+          WriteObjectLC(hSHPHandle, aLCSeq(i));
+      }
       SHPClose( hSHPHandle );
       commit();
     }
@@ -163,5 +186,80 @@ void HYDROGUI_ExportFileOp::WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYD
   SHPDestroyObject( aSHPObj );
 }
 
+void HYDROGUI_ExportFileOp::WriteObjectLC(SHPHandle theShpHandle, Handle_HYDROData_LandCover theLC )
+{
+
+  TopoDS_Shape aSh = theLC->GetShape();
+  if (aSh.IsNull())
+    return;
+  if (aSh.ShapeType() == TopAbs_FACE)
+  {
+    ProcessFace(TopoDS::Face(aSh), theShpHandle);
+  }
+  else if (aSh.ShapeType() == TopAbs_COMPOUND)
+  {
+    TopExp_Explorer Ex(aSh, TopAbs_FACE);
+    for (; Ex.More(); Ex.Next()) 
+    {
+      TopoDS_Face aF = TopoDS::Face(Ex.Current());   
+      if (aF.IsNull())
+        continue;
+      ProcessFace(aF, theShpHandle);
+    }
+  }
+  else
+    return;
+}
+
+void HYDROGUI_ExportFileOp::ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandle)
+{
+  SHPObject    *aSHPObj;
+  std::vector<double> x, y;
+  std::vector<int> anPartStart;
+  if (theFace.ShapeType() == TopAbs_FACE)
+  {
+    TopExp_Explorer Ex(theFace, TopAbs_WIRE);
+    int NbWires = 0;
+    for (; Ex.More(); Ex.Next()) 
+    {
+      TopoDS_Wire aW = TopoDS::Wire(Ex.Current());   
+      if (aW.IsNull())
+        continue;
+      NbWires++;
+      anPartStart.push_back(x.size());
+      TopExp_Explorer aVEx(aW, TopAbs_VERTEX);
+      NCollection_Sequence<gp_Pnt2d> aPnts;
+      for (; aVEx.More(); aVEx.Next())
+      {
+        TopoDS_Vertex aV = TopoDS::Vertex(aVEx.Current()); 
+        if (aV.IsNull())
+          continue;
+        gp_Pnt P = BRep_Tool::Pnt(aV);
+        aPnts.Append(gp_Pnt2d(P.X(), P.Y()));
+      }
+      NCollection_Sequence<gp_Pnt2d> aNPnts;
+      aNPnts.Append(aPnts.First());
+      for (int j = 1; j <= aPnts.Size() - 1; j++)
+      {
+        if (!aPnts(j).IsEqual(aPnts(j + 1), Precision::Confusion())) 
+          aNPnts.Append(aPnts(j + 1));
+      }
 
+      for (int j = 1; j <= aNPnts.Size(); j++)
+      { 
+        x.push_back( aNPnts(j).X());
+        y.push_back( aNPnts(j).Y()); 
+      }
+      //x.push_back( aNPnts(1).X());
+      //y.push_back( aNPnts(1).Y()); 
 
+    }
+    
+    aSHPObj = SHPCreateObject( SHPT_POLYGON, -1, NbWires, &anPartStart[0], NULL, x.size(), &x[0], &y[0], NULL, NULL );
+    SHPWriteObject( theShpHandle, -1, aSHPObj );
+    SHPDestroyObject( aSHPObj );
+  }
+  else
+    return;
+}
index abab9c298f46841f28da1cba6491089826748347..ed9baa99d37f9b711cfda1a276d645e077cdaf80 100644 (file)
@@ -34,6 +34,8 @@ class SUIT_FileDlg;
 class gp_XYZ;
 class Handle_HYDROData_PolylineXY;
 class Handle_HYDROData_Polyline3D;
+class Handle_HYDROData_LandCover;
+class TopoDS_Face;
 
 class HYDROGUI_ExportFileOp : public HYDROGUI_Operation
 {
@@ -47,6 +49,9 @@ protected:
   virtual void startOperation();
   void WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly );
   void WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly );
+  void WriteObjectLC(SHPHandle theShpHandle, Handle_HYDROData_LandCover theLC );
+private:
+  void ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandle);
  private:
   SUIT_FileDlg* myFileDlg;
   std::vector<SHPObject*> mySHPObjects;
diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverOp.cxx b/src/HYDROGUI/HYDROGUI_ImportLandCoverOp.cxx
new file mode 100644 (file)
index 0000000..d072688
--- /dev/null
@@ -0,0 +1,441 @@
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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_ImportLandCoverOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_ImportLandCoverDlg.h"
+#include "HYDROGUI_Shape.h"
+#include <HYDROData_LandCover.h>
+#include <HYDROGUI_ZLayers.h>
+
+#include <HYDROGUI_DataObject.h>
+#include <HYDROData_Iterator.h>
+
+#include <HYDROData_Profile.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_FileDlg.h>
+#include <LightApp_Application.h>
+
+#include <QApplication>
+#include <QFile>
+#include <QFileInfo>
+#include <SUIT_MessageBox.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+
+#include <SalomeApp_Study.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_DataOwner.h>
+#include <LightApp_Displayer.h>
+#include <LightApp_SelectionMgr.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewManager.h>
+
+#include <BRep_Builder.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Wire.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <gp_Pln.hxx>
+#include <BRepLib.hxx>
+#include <ShapeFix_Shape.hxx>
+
+
+HYDROGUI_ImportLandCoverOp::HYDROGUI_ImportLandCoverOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+  setName( tr( "IMPORT_LANDCOVER" ) );
+}
+
+HYDROGUI_ImportLandCoverOp::~HYDROGUI_ImportLandCoverOp()
+{
+  erasePreview();
+}
+
+void HYDROGUI_ImportLandCoverOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  if ( !getPreviewManager() ) {
+    setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( 
+                       module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
+  }
+
+  if ( !isApplyAndClose() ) {
+    return;
+  }
+
+  HYDROGUI_ImportLandCoverDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
+  if ( !aPanel ) {
+    return;
+  }
+
+  aPanel->reset();
+}
+
+
+HYDROGUI_InputPanel* HYDROGUI_ImportLandCoverOp::createInputPanel() const
+{
+  HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportLandCoverDlg( module(), getName() );
+
+  connect( aPanel, SIGNAL( FileSelected( const QString& ) ), SLOT( onFileSelected() ) );
+
+  connect( aPanel, SIGNAL( selectionChanged( const QStringList& ) ), this, SLOT( onSelectionChanged( const QStringList& ) ) );
+
+  return aPanel;
+}
+
+bool HYDROGUI_ImportLandCoverOp::processApply( int& theUpdateFlags,
+                                                QString& theErrorMsg,
+                                                QStringList& theBrowseObjectsEntries )
+{
+
+  HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
+  if ( !aPanel ) {
+    return false;
+  }
+  
+  QStringList aSelectedtPolygons = aPanel->getSelectedPolygonNames();
+  aPanel->removePolygonNames( aSelectedtPolygons );
+    
+  if (!aSelectedtPolygons.empty())
+  {
+    Handle(HYDROData_LandCover) aLC =  Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) );
+    TopoDS_Shape aResShape;
+    if (aSelectedtPolygons.size() > 1) 
+    {
+      TopoDS_Compound cmp;
+      BRep_Builder BB;
+      BB.MakeCompound(cmp);
+
+      foreach ( QString aName, aSelectedtPolygons ) {
+        TopoDS_Shape aShape = myPolygonName2PrsShape.value( aName )->getTopoShape();
+        if ( aShape.IsNull() ) 
+          continue;
+        BB.Add(cmp, aShape);
+        HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aName );
+        delete aShapeToDelete;
+      }
+      aResShape = cmp;
+    }
+    else
+    {         
+      TopoDS_Shape aShape = myPolygonName2PrsShape.value( aSelectedtPolygons.first() )->getTopoShape();
+      if ( !aShape.IsNull() ) 
+      {
+        HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aSelectedtPolygons.first() );
+        delete aShapeToDelete;
+       aResShape = aShape;
+      }
+    }
+    if( !aLC.IsNull() ) 
+    {
+      QString aLCName = aPanel->getObjectName() + "_polygon";
+      int i = 0;
+      for( ;HYDROGUI_Tool::FindObjectByName(module(), aLCName); i++)
+        aLCName = aPanel->getObjectName() + "_polygon_" + QString::number(i);
+      aLC->SetName( aLCName );
+      aLC->SetFillingColor( HYDROData_LandCover::DefaultFillingColor() );
+      aLC->SetBorderColor( HYDROData_LandCover::DefaultBorderColor() );
+      
+      aLC->setShape(aResShape);
+      aLC->Show();
+            
+      //erasePreview();
+      
+      module()->setIsToUpdate( aLC );
+      
+    }
+  }
+  module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
+
+  if ( isApplyAndClose() )
+    erasePreview();
+
+  return true;
+}
+
+
+void HYDROGUI_ImportLandCoverOp::Parse(SHPHandle theHandle)
+{
+  int aShapeType;
+  mySHPObjects.clear();
+  SHPGetInfo( theHandle, NULL, &aShapeType, NULL, NULL );
+  if (aShapeType == 5) 
+  {
+    for (int i = 0; i < theHandle->nRecords; i++) 
+      mySHPObjects.push_back(SHPReadObject(theHandle, i));
+  }
+}
+
+void HYDROGUI_ImportLandCoverOp::ProcessSHP(SHPObject* anObj, int i, TopoDS_Face& F)
+{
+  TopoDS_Wire W;
+  TopoDS_Edge E; 
+  int nParts = anObj->nParts;
+  gp_Pln pln(gp_Pnt(0,0,0), gp_Dir(0,0,1));
+  BRepBuilderAPI_MakeFace aFBuilder(pln);
+
+  //Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
+  //sfs->FixFaceTool()->FixOrientationMode() = 1;
+  
+  for ( int i = 0 ; i < nParts ; i++ )
+  { 
+    BRepBuilderAPI_MakeWire aBuilder;
+    int StartIndex = anObj->panPartStart[i];
+    int EndIndex;
+    if (i != nParts - 1)
+      EndIndex = anObj->panPartStart[i + 1];
+    else
+      EndIndex = anObj->nVertices;
+
+    for ( int k = StartIndex; k < EndIndex - 1  ; k++ )
+    {
+      gp_Pnt P1 (anObj->padfX[k], anObj->padfY[k], 0);
+      gp_Pnt P2 (anObj->padfX[k+1], anObj->padfY[k+1], 0);
+      if (P1.Distance(P2) < Precision::Confusion())
+        continue;
+      BRepBuilderAPI_MakeEdge aMakeEdge(P1, P2);
+      aBuilder.Add(TopoDS::Edge(aMakeEdge.Shape()));
+    }
+    
+    aBuilder.Build();
+    W = TopoDS::Wire(aBuilder.Shape());
+    W.Reverse();
+    aFBuilder.Add(W);
+  }
+
+  aFBuilder.Build();
+  TopoDS_Face DF = aFBuilder.Face();
+  BRepLib::BuildCurves3d(DF);  
+  bool IsInf = DF.Infinite();
+  if(!DF.IsNull()) 
+  {
+    //sfs->Init ( DF );
+    //sfs->Perform();
+    F = DF; //TopoDS::Face(sfs->Shape());
+  }
+}
+
+void HYDROGUI_ImportLandCoverOp::onFileSelected()
+{
+  HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+  
+  QString anObjectName = aPanel->getObjectName().simplified();
+  anObjectName = aPanel->getFileName();
+  if ( !anObjectName.isEmpty() ) 
+      anObjectName = QFileInfo( anObjectName ).baseName();
+
+  if ( anObjectName.isEmpty() ) 
+    anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_LANDCOVER_NAME" ) );
+  aPanel->setObjectName( anObjectName );
+
+  QString aFileName = aPanel->getFileName();
+  if ( aFileName.isEmpty() )
+  {
+    abort();
+    return;
+  }
+
+  QString anExt = aFileName.split('.', QString::SkipEmptyParts).back();
+
+  if (anExt == "shp")
+  {
+    SHPHandle aHSHP;
+    aHSHP = SHPOpen( aFileName.toAscii().data(), "rb" );
+    Parse(aHSHP);
+    
+    startDocOperation();
+    QStringList aPolygonsList;
+    for (int i = 0; i < mySHPObjects.size(); i++)
+      aPolygonsList.append("polygon_" + QString::number(i + 1));
+    aPanel->setPolygonNames(aPolygonsList);
+
+    SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
+    if ( !aStudy ) {
+      return;
+    }
+
+    erasePreview();
+
+    Handle(AIS_InteractiveContext) aCtx = NULL;
+
+    LightApp_Application* anApp = module()->getApp();
+    if ( !getPreviewManager() )
+      setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
+    OCCViewer_ViewManager* aViewManager = getPreviewManager();
+
+    if ( aViewManager )
+    {
+      if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
+      {
+        aCtx = aViewer->getAISContext();
+        connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) );
+      }
+    }
+
+    QApplication::setOverrideCursor(Qt::WaitCursor);
+
+    TopTools_SequenceOfShape aFaces;
+    TopoDS_Face aF;
+    if (aHSHP->nShapeType == 5)
+    {
+      for (int i = 0; i < mySHPObjects.size(); i++) 
+      {
+         ProcessSHP(mySHPObjects[i], i, aF);
+         aFaces.Append(aF);
+      }
+    }
+    else
+      SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_LANDCOVER" ), "Cannot import land cover;\nThe shape type is not polygon" );
+    QApplication::restoreOverrideCursor();
+
+    Handle(HYDROData_LandCover) aLC = Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) );
+    for ( int i = 1; i <= aFaces.Length(); i++ ) 
+    {
+      TopoDS_Face aFace = TopoDS::Face(aFaces.Value( i ));
+
+      aLC->setShape( aFace );      
+      
+      if ( aViewManager && !aCtx.IsNull() )
+      {
+        HYDROGUI_Shape* aShape = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() );
+
+        aShape->setFillingColor( HYDROData_LandCover::DefaultFillingColor(), false, false );
+        aShape->setBorderColor( HYDROData_LandCover::DefaultBorderColor(), false, false );
+        if( !aFace.IsNull() )
+          aShape->setShape( aLC->GetShape() );
+        myPolygonName2PrsShape.insert( "polygon_" + QString::number(i), aShape);
+      }
+    }
+    aLC->Remove();
+
+    if ( !aCtx.IsNull() ) {
+      UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, Graphic3d_ZLayerId_TopOSD );
+      aCtx->UpdateCurrentViewer();
+    }
+
+    commitDocOperation();
+    
+    for (size_t i = 0; i < mySHPObjects.size(); i++ )
+      free (mySHPObjects[i]);
+
+    mySHPObjects.clear();
+    SHPClose(aHSHP);
+  }
+  
+}
+
+void HYDROGUI_ImportLandCoverOp::onSelectionChanged( const QStringList& theSelectedNames )
+{
+  Handle(AIS_InteractiveContext) aCtx = NULL;
+
+  OCCViewer_ViewManager* aViewManager = getPreviewManager();
+  if ( aViewManager ) {
+    if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
+      aCtx = aViewer->getAISContext();
+    }
+  }
+
+  if ( !aCtx.IsNull() ) {
+    foreach ( QString aName, myPolygonName2PrsShape.keys() ) {
+      Handle(AIS_InteractiveObject) anObject = 
+        myPolygonName2PrsShape.value(aName)->getAISObject();
+
+      bool isSelected = theSelectedNames.contains( aName );
+      if ( ( isSelected && !aCtx->IsSelected( anObject) ) ||
+           ( !isSelected && aCtx->IsSelected( anObject) ) ) {
+        aCtx->AddOrRemoveSelected( anObject, Standard_False );
+      }
+    }
+    aCtx->UpdateCurrentViewer();
+  }
+}
+
+
+void HYDROGUI_ImportLandCoverOp::onViewerSelectionChanged()
+{
+  // Get panel
+  HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
+  if ( !aPanel ) {
+    return;
+  }
+
+  OCCViewer_ViewManager* aViewManager = getPreviewManager();
+  Handle(AIS_InteractiveContext) aCtx = NULL;
+  if ( aViewManager ) {
+    if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
+      aCtx = aViewer->getAISContext();
+    }
+  }
+  
+  if ( !aCtx.IsNull() )
+  {
+    QStringList aSelectedNames;
+    foreach ( QString aName, myPolygonName2PrsShape.keys() ) {
+      bool isSelected = aCtx->IsSelected( myPolygonName2PrsShape.value(aName)->getAISObject() );
+      if ( isSelected ) {
+        aSelectedNames << aName;
+      }
+    }
+    aPanel->setSelectedPolygonNames( aSelectedNames );
+  }
+}
+
+
+void HYDROGUI_ImportLandCoverOp::erasePreview()
+{
+  foreach ( HYDROGUI_Shape* aShape, myPolygonName2PrsShape ) {
+    delete aShape;
+  }
+
+  myPolygonName2PrsShape.clear();
+}
+
+
+void HYDROGUI_ImportLandCoverOp::abortOperation()
+{
+  LightApp_Application* anApp = module()->getApp();
+  if ( anApp ) {
+    anApp->disconnect( this );
+  }
+
+  erasePreview();
+
+  HYDROGUI_Operation::abortOperation();
+}
+
+
diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverOp.h b/src/HYDROGUI/HYDROGUI_ImportLandCoverOp.h
new file mode 100644 (file)
index 0000000..35c8ef8
--- /dev/null
@@ -0,0 +1,67 @@
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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_IMPORTLANDCOVER_H
+#define HYDROGUI_IMPORTLANDCOVER_H
+
+#include "HYDROGUI_Operation.h"
+#include <vector>
+#include <QMap>
+
+//extern "C" {
+#include <shapelib/shapefil.h> 
+//};
+
+class SUIT_FileDlg;
+class HYDROGUI_Shape;
+class TopoDS_Face;
+
+
+class HYDROGUI_ImportLandCoverOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ImportLandCoverOp( HYDROGUI_Module* theModule );
+  virtual ~HYDROGUI_ImportLandCoverOp();
+
+protected:
+  virtual void startOperation();
+  virtual void abortOperation();
+
+  virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries );
+  HYDROGUI_InputPanel* createInputPanel() const;
+  void Parse(SHPHandle theHandle);
+  void ProcessSHP(SHPObject* anObj, int i, TopoDS_Face& F);
+  void erasePreview();
+protected slots:
+  void onFileSelected();
+  void onSelectionChanged( const QStringList& theSelectedNames );
+  void onViewerSelectionChanged ();
+
+private:
+  std::vector<SHPObject*> mySHPObjects;
+  QMap<QString, HYDROGUI_Shape*> myPolygonName2PrsShape;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_ImportLandcoverOp.cxx b/src/HYDROGUI/HYDROGUI_ImportLandcoverOp.cxx
deleted file mode 100644 (file)
index 79179eb..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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_ImportLandCoverOp.h"
-
-#include "HYDROGUI_DataModel.h"
-#include "HYDROGUI_Module.h"
-#include "HYDROGUI_UpdateFlags.h"
-#include "HYDROGUI_Tool.h"
-#include "HYDROGUI_ImportLandCoverDlg.h"
-#include "HYDROGUI_Shape.h"
-#include <HYDROData_LandCover.h>
-#include <HYDROGUI_ZLayers.h>
-
-#include <HYDROGUI_DataObject.h>
-#include <HYDROData_Iterator.h>
-
-#include <HYDROData_Profile.h>
-
-#include <SUIT_Desktop.h>
-#include <SUIT_FileDlg.h>
-#include <LightApp_Application.h>
-
-#include <QApplication>
-#include <QFile>
-#include <QFileInfo>
-#include <SUIT_MessageBox.h>
-
-#include <OCCViewer_ViewManager.h>
-#include <OCCViewer_ViewModel.h>
-
-#include <SalomeApp_Study.h>
-
-#include <LightApp_Application.h>
-#include <LightApp_DataOwner.h>
-#include <LightApp_Displayer.h>
-#include <LightApp_SelectionMgr.h>
-
-#include <SUIT_Desktop.h>
-#include <SUIT_ViewManager.h>
-
-#include <BRep_Builder.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Wire.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeWire.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <gp_Pln.hxx>
-#include <BRepLib.hxx>
-#include <ShapeFix_Shape.hxx>
-
-
-HYDROGUI_ImportLandCoverOp::HYDROGUI_ImportLandCoverOp( HYDROGUI_Module* theModule )
-: HYDROGUI_Operation( theModule )
-{
-  setName( tr( "IMPORT_LANDCOVER" ) );
-}
-
-HYDROGUI_ImportLandCoverOp::~HYDROGUI_ImportLandCoverOp()
-{
-  erasePreview();
-}
-
-void HYDROGUI_ImportLandCoverOp::startOperation()
-{
-  HYDROGUI_Operation::startOperation();
-
-  if ( !getPreviewManager() ) {
-    setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( 
-                       module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
-  }
-
-  if ( !isApplyAndClose() ) {
-    return;
-  }
-
-  HYDROGUI_ImportLandCoverDlg* aPanel = 
-    ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
-  if ( !aPanel ) {
-    return;
-  }
-
-  aPanel->reset();
-}
-
-
-HYDROGUI_InputPanel* HYDROGUI_ImportLandCoverOp::createInputPanel() const
-{
-  HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportLandCoverDlg( module(), getName() );
-
-  connect( aPanel, SIGNAL( FileSelected( const QString& ) ), SLOT( onFileSelected() ) );
-
-  connect( aPanel, SIGNAL( selectionChanged( const QStringList& ) ), this, SLOT( onSelectionChanged( const QStringList& ) ) );
-
-  return aPanel;
-}
-
-bool HYDROGUI_ImportLandCoverOp::processApply( int& theUpdateFlags,
-                                                QString& theErrorMsg,
-                                                QStringList& theBrowseObjectsEntries )
-{
-
-  HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
-  if ( !aPanel ) {
-    return false;
-  }
-  
-  QStringList aSelectedtPolygons = aPanel->getSelectedPolygonNames();
-  aPanel->removePolygonNames( aSelectedtPolygons );
-    
-  if (!aSelectedtPolygons.empty())
-  {
-    Handle(HYDROData_LandCover) aLC =  Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) );
-    TopoDS_Shape aResShape;
-    if (aSelectedtPolygons.size() > 1) 
-    {
-      TopoDS_Compound cmp;
-      BRep_Builder BB;
-      BB.MakeCompound(cmp);
-
-      foreach ( QString aName, aSelectedtPolygons ) {
-        TopoDS_Shape aShape = myPolygonName2PrsShape.value( aName )->getTopoShape();
-        if ( aShape.IsNull() ) 
-          continue;
-        BB.Add(cmp, aShape);
-        HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aName );
-        delete aShapeToDelete;
-      }
-      aResShape = cmp;
-    }
-    else
-    {         
-      TopoDS_Shape aShape = myPolygonName2PrsShape.value( aSelectedtPolygons.first() )->getTopoShape();
-      if ( !aShape.IsNull() ) 
-      {
-        HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aSelectedtPolygons.first() );
-        delete aShapeToDelete;
-       aResShape = aShape;
-      }
-    }
-    if( !aLC.IsNull() ) 
-    {
-      QString aLCName = aPanel->getObjectName() + "_polygon";
-      int i = 0;
-      for( ;HYDROGUI_Tool::FindObjectByName(module(), aLCName); i++)
-        aLCName = aPanel->getObjectName() + "_polygon_" + QString::number(i);
-      aLC->SetName( aLCName );
-      aLC->SetFillingColor( HYDROData_LandCover::DefaultFillingColor() );
-      aLC->SetBorderColor( HYDROData_LandCover::DefaultBorderColor() );
-      
-      aLC->setShape(aResShape);
-      aLC->Show();
-            
-      //erasePreview();
-      
-      module()->setIsToUpdate( aLC );
-      
-    }
-  }
-  module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
-
-  if ( isApplyAndClose() )
-    erasePreview();
-
-  return true;
-}
-
-
-void HYDROGUI_ImportLandCoverOp::Parse(SHPHandle theHandle)
-{
-  int aShapeType;
-  mySHPObjects.clear();
-  SHPGetInfo( theHandle, NULL, &aShapeType, NULL, NULL );
-  if (aShapeType == 5) 
-  {
-    for (int i = 0; i < theHandle->nRecords; i++) 
-      mySHPObjects.push_back(SHPReadObject(theHandle, i));
-  }
-}
-
-void HYDROGUI_ImportLandCoverOp::ProcessSHP(SHPObject* anObj, int i, TopoDS_Face& F)
-{
-  TopoDS_Wire W;
-  TopoDS_Edge E; 
-  int nParts = anObj->nParts;
-  gp_Pln pln(gp_Pnt(0,0,0), gp_Dir(0,0,1));
-  BRepBuilderAPI_MakeFace aFBuilder(pln);
-
-  //Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
-  //sfs->FixFaceTool()->FixOrientationMode() = 1;
-  
-  for ( int i = 0 ; i < nParts ; i++ )
-  { 
-    BRepBuilderAPI_MakeWire aBuilder;
-    int StartIndex = anObj->panPartStart[i];
-    int EndIndex;
-    if (i != nParts - 1)
-      EndIndex = anObj->panPartStart[i + 1];
-    else
-      EndIndex = anObj->nVertices;
-
-    for ( int k = StartIndex; k < EndIndex - 1  ; k++ )
-    {
-      gp_Pnt P1 (anObj->padfX[k], anObj->padfY[k], 0);
-      gp_Pnt P2 (anObj->padfX[k+1], anObj->padfY[k+1], 0);
-      BRepBuilderAPI_MakeEdge aMakeEdge(P1, P2);
-      aBuilder.Add(TopoDS::Edge(aMakeEdge.Shape()));
-    }
-    
-    aBuilder.Build();
-    W = TopoDS::Wire(aBuilder.Shape());
-    W.Reverse();
-    aFBuilder.Add(W);
-  }
-
-  aFBuilder.Build();
-  TopoDS_Face DF = aFBuilder.Face();
-  BRepLib::BuildCurves3d(DF);
-  if(!DF.IsNull()) 
-  {
-    //sfs->Init ( DF );
-    //sfs->Perform();
-    F = DF; //TopoDS::Face(sfs->Shape());
-  }
-}
-
-void HYDROGUI_ImportLandCoverOp::onFileSelected()
-{
-  HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
-  if ( !aPanel )
-    return;
-  
-  QString anObjectName = aPanel->getObjectName().simplified();
-  anObjectName = aPanel->getFileName();
-  if ( !anObjectName.isEmpty() ) 
-      anObjectName = QFileInfo( anObjectName ).baseName();
-
-  if ( anObjectName.isEmpty() ) 
-    anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_LANDCOVER_NAME" ) );
-  aPanel->setObjectName( anObjectName );
-
-  QString aFileName = aPanel->getFileName();
-  if ( aFileName.isEmpty() )
-  {
-    abort();
-    return;
-  }
-
-  QString anExt = aFileName.split('.', QString::SplitBehavior::SkipEmptyParts).back();
-
-  if (anExt == "shp")
-  {
-    SHPHandle aHSHP;
-    aHSHP = SHPOpen( aFileName.toAscii().data(), "rb" );
-    Parse(aHSHP);
-    
-    startDocOperation();
-    QStringList aPolygonsList;
-    for (int i = 1; i < mySHPObjects.size(); i++)
-      aPolygonsList.append("polygon_" + QString::number(i));
-    aPanel->setPolygonNames(aPolygonsList);
-
-    SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
-    if ( !aStudy ) {
-      return;
-    }
-
-    erasePreview();
-
-    Handle(AIS_InteractiveContext) aCtx = NULL;
-
-    LightApp_Application* anApp = module()->getApp();
-    if ( !getPreviewManager() )
-      setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
-    OCCViewer_ViewManager* aViewManager = getPreviewManager();
-
-    if ( aViewManager )
-    {
-      if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
-      {
-        aCtx = aViewer->getAISContext();
-        connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) );
-      }
-    }
-
-    QApplication::setOverrideCursor(Qt::WaitCursor);
-
-    TopTools_SequenceOfShape aFaces;
-    TopoDS_Face aF;
-    if (aHSHP->nShapeType == 5)
-    {
-      for (int i = 0; i < mySHPObjects.size(); i++) 
-      {
-         ProcessSHP(mySHPObjects[i], i, aF);
-         aFaces.Append(aF);
-      }
-    }
-    else
-      SUIT_MessageBox::warning( module()->getApp()->desktop(), "Import Land cover", "Cannot land cover;\nThe shape type is not polygon" );
-    QApplication::restoreOverrideCursor();
-
-    Handle(HYDROData_LandCover) aLC = Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) );
-    for ( int i = 1; i <= aFaces.Length(); i++ ) 
-    {
-      TopoDS_Face aFace = TopoDS::Face(aFaces.Value( i ));
-
-      aLC->setShape( aFace );      
-      
-      if ( aViewManager && !aCtx.IsNull() )
-      {
-        HYDROGUI_Shape* aShape = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() );
-
-        aShape->setFillingColor( HYDROData_LandCover::DefaultFillingColor(), false, false );
-        aShape->setBorderColor( HYDROData_LandCover::DefaultBorderColor(), false, false );
-        if( !aFace.IsNull() )
-          aShape->setShape( aLC->GetShape() );
-        myPolygonName2PrsShape.insert( "polygon_" + QString::number(i), aShape);
-      }
-    }
-    aLC->Remove();
-
-    if ( !aCtx.IsNull() ) {
-      UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, Graphic3d_ZLayerId_TopOSD );
-      aCtx->UpdateCurrentViewer();
-    }
-
-    commitDocOperation();
-    
-    for (size_t i = 0; i < mySHPObjects.size(); i++ )
-      free (mySHPObjects[i]);
-
-    mySHPObjects.clear();
-    SHPClose(aHSHP);
-  }
-  
-}
-
-void HYDROGUI_ImportLandCoverOp::onSelectionChanged( const QStringList& theSelectedNames )
-{
-  Handle(AIS_InteractiveContext) aCtx = NULL;
-
-  OCCViewer_ViewManager* aViewManager = getPreviewManager();
-  if ( aViewManager ) {
-    if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
-      aCtx = aViewer->getAISContext();
-    }
-  }
-
-  if ( !aCtx.IsNull() ) {
-    foreach ( QString aName, myPolygonName2PrsShape.keys() ) {
-      Handle(AIS_InteractiveObject) anObject = 
-        myPolygonName2PrsShape.value(aName)->getAISObject();
-
-      bool isSelected = theSelectedNames.contains( aName );
-      if ( ( isSelected && !aCtx->IsSelected( anObject) ) ||
-           ( !isSelected && aCtx->IsSelected( anObject) ) ) {
-        aCtx->AddOrRemoveSelected( anObject, Standard_False );
-      }
-    }
-    aCtx->UpdateCurrentViewer();
-  }
-}
-
-
-void HYDROGUI_ImportLandCoverOp::onViewerSelectionChanged()
-{
-  // Get panel
-  HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
-  if ( !aPanel ) {
-    return;
-  }
-
-  OCCViewer_ViewManager* aViewManager = getPreviewManager();
-  Handle(AIS_InteractiveContext) aCtx = NULL;
-  if ( aViewManager ) {
-    if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
-      aCtx = aViewer->getAISContext();
-    }
-  }
-  
-  if ( !aCtx.IsNull() )
-  {
-    QStringList aSelectedNames;
-    foreach ( QString aName, myPolygonName2PrsShape.keys() ) {
-      bool isSelected = aCtx->IsSelected( myPolygonName2PrsShape.value(aName)->getAISObject() );
-      if ( isSelected ) {
-        aSelectedNames << aName;
-      }
-    }
-    aPanel->setSelectedPolygonNames( aSelectedNames );
-  }
-}
-
-
-void HYDROGUI_ImportLandCoverOp::erasePreview()
-{
-  foreach ( HYDROGUI_Shape* aShape, myPolygonName2PrsShape ) {
-    delete aShape;
-  }
-
-  myPolygonName2PrsShape.clear();
-}
-
-
-void HYDROGUI_ImportLandCoverOp::abortOperation()
-{
-  LightApp_Application* anApp = module()->getApp();
-  if ( anApp ) {
-    anApp->disconnect( this );
-  }
-
-  erasePreview();
-
-  HYDROGUI_Operation::abortOperation();
-}
-
-
diff --git a/src/HYDROGUI/HYDROGUI_ImportLandcoverOp.h b/src/HYDROGUI/HYDROGUI_ImportLandcoverOp.h
deleted file mode 100644 (file)
index 35c8ef8..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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_IMPORTLANDCOVER_H
-#define HYDROGUI_IMPORTLANDCOVER_H
-
-#include "HYDROGUI_Operation.h"
-#include <vector>
-#include <QMap>
-
-//extern "C" {
-#include <shapelib/shapefil.h> 
-//};
-
-class SUIT_FileDlg;
-class HYDROGUI_Shape;
-class TopoDS_Face;
-
-
-class HYDROGUI_ImportLandCoverOp : public HYDROGUI_Operation
-{
-  Q_OBJECT
-
-public:
-  HYDROGUI_ImportLandCoverOp( HYDROGUI_Module* theModule );
-  virtual ~HYDROGUI_ImportLandCoverOp();
-
-protected:
-  virtual void startOperation();
-  virtual void abortOperation();
-
-  virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries );
-  HYDROGUI_InputPanel* createInputPanel() const;
-  void Parse(SHPHandle theHandle);
-  void ProcessSHP(SHPObject* anObj, int i, TopoDS_Face& F);
-  void erasePreview();
-protected slots:
-  void onFileSelected();
-  void onSelectionChanged( const QStringList& theSelectedNames );
-  void onViewerSelectionChanged ();
-
-private:
-  std::vector<SHPObject*> mySHPObjects;
-  QMap<QString, HYDROGUI_Shape*> myPolygonName2PrsShape;
-};
-
-#endif
index 1d02a454ce772bb972d0064c67b08a427a622b9d..a3c7f833205e32a8f7d36fafb8656da35172235a 100644 (file)
@@ -41,7 +41,7 @@
 #include <QApplication>
 #include <QFile>
 #include <QFileInfo>
-#include <QMessageBox>
+#include <SUIT_MessageBox.h>
 
 
 HYDROGUI_ImportPolylineOp::HYDROGUI_ImportPolylineOp( HYDROGUI_Module* theModule )
@@ -77,82 +77,91 @@ void HYDROGUI_ImportPolylineOp::onApply()
     return;
   }
 
-  QString aFileName = myFileDlg->selectedFile();
-  if ( aFileName.isEmpty() )
+  QStringList aFileNames = myFileDlg->selectedFiles();
+  
+  QApplication::setOverrideCursor( Qt::WaitCursor );  
+  startDocOperation();
+
+  foreach (QString aFileName, aFileNames) 
   {
-    abort();
-    return;
-  }
+    if ( aFileName.isEmpty() )
+      continue;
 
-  QString anExt = aFileName.split('.', QString::SkipEmptyParts).back();
+    QString anExt = aFileName.split('.', QString::SkipEmptyParts).back();
 
-  if (anExt == "shp")
-  {
-    SHPHandle aHSHP;
-    aHSHP = SHPOpen( aFileName.toAscii().data(), "rb" );
-    Parse(aHSHP);
-    
-    QApplication::setOverrideCursor( Qt::WaitCursor );
-    
-    startDocOperation();
+    if (anExt == "shp")
+    {
+      SHPHandle aHSHP;
+      aHSHP = SHPOpen( aFileName.toAscii().data(), "rb" );
+      Parse(aHSHP);
 
-    HYDROData_Iterator anIter( doc() );
-    int anInd = 0;
-    QStringList anExistingNames;
-    std::vector<int> anAllowedIndexes;
-    for( ; anIter.More(); anIter.Next() )
-      anExistingNames.push_back(anIter.Current()->GetName());
+      HYDROData_Iterator anIter( doc() );
+      int anInd = 0;
+      QStringList anExistingNames;
+      std::vector<int> anAllowedIndexes;
+      for( ; anIter.More(); anIter.Next() )
+        anExistingNames.push_back(anIter.Current()->GetName());
 
-    QFileInfo aFileInfo(aFileName);
-    QString aBaseFileName = aFileInfo.baseName();
+      QFileInfo aFileInfo(aFileName);
+      QString aBaseFileName = aFileInfo.baseName();
 
-    if (aHSHP->nShapeType == 3 || aHSHP->nShapeType == 23)
-    {
-      anInd = 0;
-      for (;anAllowedIndexes.size() < mySHPObjects.size();)
+      if (aHSHP->nShapeType == 3 || aHSHP->nShapeType == 23)
       {
-        if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd)))
+        anInd = 0;
+        for (;anAllowedIndexes.size() < mySHPObjects.size();)
         {
-          anAllowedIndexes.push_back(anInd);
-          anInd++;
+          if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd)))
+          {
+            anAllowedIndexes.push_back(anInd);
+            anInd++;
+          }
+          else
+            anInd++;
+        }
+        
+        for (size_t i = 0; i < mySHPObjects.size(); i++ )
+        {
+          ProcessSHPPolyXY(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]);
         }
-        else
-          anInd++;
-      }
-      
-      for (size_t i = 0; i < mySHPObjects.size(); i++ )
-      {
-        ProcessSHPPolyXY(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]);
       }
-    }
-    else if (aHSHP->nShapeType == 13)
-    {
-      anInd = 0;
-      for (;anAllowedIndexes.size() < mySHPObjects.size();)
+      else if (aHSHP->nShapeType == 13)
       {
-        if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd)) &&
-            !anExistingNames.contains(aBaseFileName + "_Poly3D_" + QString::number(anInd)) &&
-            !anExistingNames.contains(aBaseFileName + "_Bath_" + QString::number(anInd)))
+        anInd = 0;
+        for (;anAllowedIndexes.size() < mySHPObjects.size();)
         {
-          anAllowedIndexes.push_back(anInd);
-          anInd++;
+          if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd)) &&
+              !anExistingNames.contains(aBaseFileName + "_Poly3D_" + QString::number(anInd)) &&
+              !anExistingNames.contains(aBaseFileName + "_Bath_" + QString::number(anInd)))
+          {
+            anAllowedIndexes.push_back(anInd);
+            anInd++;
+          }
+          else
+            anInd++;
         }
-        else
-          anInd++;
+        for (size_t i = 0; i < mySHPObjects.size(); i++ )
+          ProcessSHPPoly3D(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]);
       }
+      else  
+      {
+        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_POLYLINE" ), "Cannot import polyline;\nThe shape type is incorrect" );
+      }
+    
       for (size_t i = 0; i < mySHPObjects.size(); i++ )
-        ProcessSHPPoly3D(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]);
+        free (mySHPObjects[i]);
+
+      mySHPObjects.clear();
+      SHPClose(aHSHP);
     }
+  }
+  if (!aFileNames.empty())
+  {
     commitDocOperation();
     commit();
-    
-    for (size_t i = 0; i < mySHPObjects.size(); i++ )
-      free (mySHPObjects[i]);
-
-    mySHPObjects.clear();
-    SHPClose(aHSHP);
+    module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
   }
-  module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
+  else
+    abort();
   
   QApplication::restoreOverrideCursor();
 }
index 39bbcc1a0bd8595cd2764cbdf19d42936b3af7aa..5035aae9a265dc29f4da0942df82516beba49ef0 100644 (file)
@@ -19,7 +19,9 @@
 #include <HYDROGUI_MergePolylinesDlg.h>
 #include <HYDROGUI_ObjListBox.h>
 #include <QFrame>
+#include <QLabel>
 #include <QGridLayout>
+#include <QLineEdit>
 
 HYDROGUI_MergePolylinesDlg::HYDROGUI_MergePolylinesDlg( HYDROGUI_Module* theModule, const QString& theTitle )
 : HYDROGUI_InputPanel( theModule, theTitle )
@@ -31,8 +33,12 @@ HYDROGUI_MergePolylinesDlg::HYDROGUI_MergePolylinesDlg( HYDROGUI_Module* theModu
   aLayout->setMargin( 5 );
   aLayout->setSpacing( 5 );
 
+  myName = new QLineEdit( mainFrame() );
+  aLayout->addWidget( new QLabel( tr( "RESULT_NAME" ) ), 0, 0 );
+  aLayout->addWidget( myName, 0, 1 );
+
   myList = new HYDROGUI_ObjListBox( theModule, tr( "POLYLINES" ), KIND_POLYLINEXY, mainFrame() );
-  aLayout->addWidget( myList, 0, 0 );
+  aLayout->addWidget( myList, 1, 0, 1, 2 );
 }
 
 HYDROGUI_MergePolylinesDlg::~HYDROGUI_MergePolylinesDlg()
@@ -53,3 +59,8 @@ void HYDROGUI_MergePolylinesDlg::setPolylinesFromSelection()
 {
   return myList->setObjectsFromSelection();
 }
+
+QString HYDROGUI_MergePolylinesDlg::GetResultName() const
+{
+  return myName->text();
+}
index 874f0225330e2dfd9b4e401d1d212ac74a790004..9213deff5f26b7771105c14b6f74493d375d4859 100644 (file)
@@ -22,6 +22,7 @@
 #include <HYDROGUI_InputPanel.h>
 #include <HYDROData_Entity.h>
 
+class QLineEdit;
 class HYDROGUI_ObjListBox;
 
 class HYDROGUI_MergePolylinesDlg : public HYDROGUI_InputPanel
@@ -32,11 +33,13 @@ public:
   HYDROGUI_MergePolylinesDlg( HYDROGUI_Module* theModule, const QString& theTitle );
   virtual ~HYDROGUI_MergePolylinesDlg();
 
+  QString                     GetResultName() const;
   HYDROData_SequenceOfObjects selectedPolylines() const;
   void                        setSelectedPolylines( const HYDROData_SequenceOfObjects& );
   void                        setPolylinesFromSelection();
 
 private:
+  QLineEdit*           myName;
   HYDROGUI_ObjListBox* myList;
 };
 
index 8c6f21befca054c715b2a04505817333304f2555..9e0eaf0ccea3f59905530671f787a34d8c86f473 100644 (file)
@@ -19,6 +19,7 @@
 #include <HYDROGUI_MergePolylinesOp.h>
 #include <HYDROGUI_MergePolylinesDlg.h>
 #include <HYDROGUI_UpdateFlags.h>
+#include <HYDROData_Document.h>
 #include <HYDROData_PolylineOperator.h>
 
 HYDROGUI_MergePolylinesOp::HYDROGUI_MergePolylinesOp( HYDROGUI_Module* theModule )
@@ -56,9 +57,10 @@ bool HYDROGUI_MergePolylinesOp::processApply( int& theUpdateFlags,
   if ( !aPanel )
     return false;
 
+  QString aName = aPanel->GetResultName();
   HYDROData_SequenceOfObjects aPolylinesList = aPanel->selectedPolylines();
   HYDROData_PolylineOperator anOp;
-  anOp.Merge( aPolylinesList );
+  anOp.Merge( doc(), aName.toLatin1().data(), aPolylinesList );
 
   theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
   return true;
index 77aecedec32b355f6ba39745ce9d1507bdb22943..a4177f665ba69b50ddd94c16ac896f83eb28ff7c 100644 (file)
@@ -655,8 +655,13 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         theMenu->addAction( action( DuplicateStricklerTableId ) );
         theMenu->addSeparator();
 
-        if ( !isLandCoversScalarMapModeOn( anActiveViewId ) && 
-             !getObjectShapes( anActiveViewId, KIND_LAND_COVER ).isEmpty() ) {
+        Handle(HYDROData_StricklerTable) aTable = 
+          Handle(HYDROData_StricklerTable)::DownCast( aSeq.First() );
+        QString aCurrentTable = 
+          HYDROGUI_DataObject::dataObjectEntry( getLandCoverColoringTable( anActiveViewId ) );
+        bool isUsed = aCurrentTable == HYDROGUI_DataObject::dataObjectEntry( aTable );
+
+        if ( !isUsed && !getObjectShapes( anActiveViewId, KIND_LAND_COVER ).isEmpty() ) {
           theMenu->addAction( action( LandCoverScalarMapModeOnId ) );
           theMenu->addSeparator();
         }
@@ -684,8 +689,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       theMenu->addSeparator();
     }
 
-    if (anIsPolyline || anIsPolyline3D)
-      theMenu->addAction( action( ExportPolylineId ) );
+    bool anIsPoly = anIsPolyline || anIsPolyline3D;
+    if ((anIsPoly && !anIsLandCover) || (!anIsPoly && anIsLandCover))
+      theMenu->addAction( action( ExportToShapeFileID ) );
 
     // Add copy action
     QAction* aCopyAction = action( CopyId );
@@ -1798,3 +1804,23 @@ bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
 {
   return myLandCoverColoringMap.contains( theViewId );
 }
+
+void HYDROGUI_Module::setObjectRemoved( const Handle(HYDROData_Entity)& theObject )
+{
+  if ( theObject.IsNull() || !theObject->IsRemoved() ) {
+    return;
+  }
+
+  if ( theObject->GetKind() == KIND_STRICKLER_TABLE ) {
+    Handle(HYDROData_StricklerTable) aTable = 
+      Handle(HYDROData_StricklerTable)::DownCast( theObject );
+    QList<int> aViewIds;
+    QMutableMapIterator<int, Handle(HYDROData_StricklerTable)> anIter( myLandCoverColoringMap );
+    while ( anIter.hasNext() ) {
+      if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) == 
+           HYDROGUI_DataObject::dataObjectEntry( aTable ) ) {
+        anIter.remove();
+      }
+    }
+  }
+}
index 3798c08d62a01fea7729a6b25c898e1291286927..ddd8faad4961d03d31b62222851a4c9a86c9de6a 100644 (file)
@@ -236,6 +236,12 @@ public:
    */
   bool                             isLandCoversScalarMapModeOn( const int theViewId ) const;
 
+  /**
+   * Set object as removed.
+   * @param theObject the removed object
+   */
+  void                            setObjectRemoved( const Handle(HYDROData_Entity)& theObject );
+
 protected:
   CAM_DataModel*                  createDataModel();
 
index 6cfbf67e20ebbfedb2ef2d6d431a2159eb88628b..433ce8a615bedbf11ccd6fb5e2166797bd46aa82 100644 (file)
@@ -415,7 +415,7 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
   
   OCCViewer_ViewWindow* aWnd = dynamic_cast<OCCViewer_ViewWindow*>( theViewer->getViewManager()->getActiveView() );
   Handle(V3d_View) aView = aWnd->getViewPort()->getView();
-    
+      
   int aViewerId = (size_t)theViewer;//TODO: check if viewer id is correct
   bool isLandCoverColoringOn = module()->isLandCoversScalarMapModeOn( aViewerId );
     
@@ -439,7 +439,8 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
   if ( isLandCoverColoringOn ) {
     aTable = module()->getLandCoverColoringTable( aViewerId );
     if ( !aTable.IsNull() ) {
-      aColorScaleTitle = TCollection_ExtendedString( aTable->GetName().toLatin1().constData() );
+      // TODO: non-empty title leads to buggy behaviour
+      // aColorScaleTitle = TCollection_ExtendedString( aTable->GetName().toLatin1().constData() );
       aTable->GetCoefficientRange( aColorScaleMin, aColorScaleMax );
       aTableTypes = aTable->GetTypes();
     }
@@ -535,9 +536,6 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
     aLandCoverShape->setFillingColor( aColor, true, true );
     aLandCoverShape->setScalarMapModeEnabled( isLandCoverColoringOn );
     theViewer->getAISContext()->Redisplay( aLandCoverShape->getAISObject() );
-    //theViewer->getAISContext()->UpdateCurrentViewer(); //@MZN
-    //theViewer->getAISContext()->UpdateCurrent();
-    //theViewer->getAISContext()->UpdateSelected( true );
   }
 
   myToUpdateColorScale = false;
index 8858974a1039c9aea1daf4309bf7485828750096..98e3ee3c6c8a59610ecd179d474a8f6d2330b3ad 100644 (file)
@@ -212,7 +212,7 @@ void HYDROGUI_Module::createActions()
   createAction( ProfileInterpolateId, "PROFILE_INTERPOLATE", "PROFILE_INTERPOLATE_ICO" );
 
   createAction( SubmersibleId, "SUBMERSIBLE", "SUBMERSIBLE_ICO" );
-  createAction( ExportPolylineId, "EXPORT_POLYLINE", "EXPORT_POLYLINE_ICO" );
+  createAction( ExportToShapeFileID, "EXPORT_TO_SHAPE_FILE", "EXPORT_TO_SHAPE_FILE_ICO" );
 
   createAction( SplitPolylinesId, "SPLIT_POLYLINES", "SPLIT_POLYLINES_ICO" );
   createAction( MergePolylinesId, "MERGE_POLYLINES", "MERGE_POLYLINES_ICO" );
@@ -473,7 +473,7 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case ForcedUpdateObjectId:
     anOp = new HYDROGUI_UpdateObjectOp( aModule, theId == ForcedUpdateObjectId );
     break;
-  case ExportPolylineId:
+  case ExportToShapeFileID:
     anOp = new HYDROGUI_ExportFileOp( aModule );
     break;
   case ImportLandcoverId:
index eef042d9e8709782ff7b77bd0252c91f141641d9..fc1908471cdb0f02706eae33be88150ebe904609 100644 (file)
@@ -113,7 +113,7 @@ enum OperationId
   ImportSinusXId,
   ExportSinusXId,
     
-  ExportPolylineId,
+  ExportToShapeFileID,
   ImportLandcoverId,
 
   ImportStricklerTableFromFileId,
index ddc5d0b3ffed5fee408f4c1069376a4035a1fa16..aa70371aac72b4a49798d1c8e364e2146979724c 100644 (file)
@@ -31,6 +31,7 @@
 #include <QGridLayout>
 #include <QTabWidget>
 #include <QMouseEvent>
+#include <QLineEdit>
 #include <gp_Pnt2d.hxx>
 
 const double MIN_COORD = -1000000;
@@ -47,8 +48,12 @@ HYDROGUI_SplitPolylinesDlg::HYDROGUI_SplitPolylinesDlg( HYDROGUI_Module* theModu
   aLayout->setMargin( 5 );
   aLayout->setSpacing( 5 );
 
+  myName = new QLineEdit( mainFrame() );
+  aLayout->addWidget( new QLabel( tr( "RESULT_NAME" ) ), 0, 0 );
+  aLayout->addWidget( myName, 0, 1 );
+
   myTab = new QTabWidget( aFrame );
-  aLayout->addWidget( myTab, 0, 0 );
+  aLayout->addWidget( myTab, 1, 0, 1, 2 );
 
   QFrame* aPointPage = new QFrame();
   myMainPolyline1 = new HYDROGUI_ObjComboBox( theModule, tr( "POLYLINE" ), KIND_POLYLINEXY, aPointPage );
@@ -184,3 +189,8 @@ OCCViewer_ViewPort3d* HYDROGUI_SplitPolylinesDlg::getViewPort() const
     
   return aViewPort;
 }
+
+QString HYDROGUI_SplitPolylinesDlg::GetResultName() const
+{
+  return myName->text();
+}
index c550472a7d3a99482a2572930d56745bf45fb681..dedda92985f4eb284e996dbc8f719f07b2a4a4cf 100644 (file)
@@ -30,6 +30,7 @@ class gp_Pnt2d;
 class OCCViewer_Viewer;
 class SUIT_ViewWindow;
 class OCCViewer_ViewPort3d;
+class QLineEdit;
 
 class HYDROGUI_SplitPolylinesDlg : public HYDROGUI_InputPanel
 {
@@ -42,11 +43,12 @@ public:
   HYDROGUI_SplitPolylinesDlg( HYDROGUI_Module* theModule, const QString& theTitle );
   virtual ~HYDROGUI_SplitPolylinesDlg();
 
-  Mode GetMode() const; 
+  QString                        GetResultName() const;
+  Mode                           GetMode() const; 
   Handle( HYDROData_PolylineXY ) GetMainPolyline() const;
   Handle( HYDROData_PolylineXY ) GetToolPolyline() const;
-  gp_Pnt2d GetPoint() const;
-  HYDROData_SequenceOfObjects GetPolylines() const;
+  gp_Pnt2d                       GetPoint() const;
+  HYDROData_SequenceOfObjects    GetPolylines() const;
 
   void setPolylinesFromSelection();
   void setOCCViewer( OCCViewer_Viewer* theViewer );
@@ -63,9 +65,10 @@ private:
   OCCViewer_ViewPort3d* getViewPort() const;
 
 private:
-  QTabWidget* myTab;
-  QtxDoubleSpinBox* myX;
-  QtxDoubleSpinBox* myY;
+  QLineEdit*            myName;
+  QTabWidget*           myTab;
+  QtxDoubleSpinBox*     myX;
+  QtxDoubleSpinBox*     myY;
   HYDROGUI_ObjComboBox* myMainPolyline1;
   HYDROGUI_ObjComboBox* myMainPolyline2;
   HYDROGUI_ObjComboBox* myToolPolyline;
index 73f415a8957783ee7e0e6d81bb8eef3f32855fb4..d6556fbafd290457137764ebfd5f4d8ef492d42c 100644 (file)
@@ -22,6 +22,7 @@
 #include <HYDROGUI_UpdateFlags.h>
 #include <HYDROGUI_Shape.h>
 #include <HYDROData_PolylineOperator.h>
+#include <HYDROData_Document.h>
 #include <LightApp_Application.h>
 #include <OCCViewer_ViewModel.h>
 #include <OCCViewer_ViewManager.h>
@@ -78,6 +79,7 @@ bool HYDROGUI_SplitPolylinesOp::processApply( int& theUpdateFlags,
   if ( !aPanel )
     return false;
 
+  QString aName = aPanel->GetResultName();
   Handle( HYDROData_PolylineXY ) aMainPolyline = aPanel->GetMainPolyline();
   Handle( HYDROData_PolylineXY ) aToolPolyline = aPanel->GetToolPolyline();
   HYDROData_SequenceOfObjects aPolylinesList = aPanel->GetPolylines();
@@ -87,13 +89,13 @@ bool HYDROGUI_SplitPolylinesOp::processApply( int& theUpdateFlags,
   switch( aPanel->GetMode() )
   {
   case HYDROGUI_SplitPolylinesDlg::ByPoint:
-    anOp.Split( aMainPolyline, aPoint );
+    anOp.Split( doc(), aName.toLatin1().data(), aMainPolyline, aPoint );
     break;
   case HYDROGUI_SplitPolylinesDlg::ByTool:
-    anOp.Split( aMainPolyline, aToolPolyline );
+    anOp.Split( doc(), aName.toLatin1().data(), aMainPolyline, aToolPolyline );
     break;
   case HYDROGUI_SplitPolylinesDlg::Split:
-    anOp.Split( aPolylinesList );
+    anOp.Split( doc(), aName.toLatin1().data(), aPolylinesList );
     break;
   }
   
index 613d7f574266a1e4e90aed3d7fc88f0176995470..475bbaba59020b943d02d948b365629747f60dab 100644 (file)
     </message>
 
     <message>
-      <source>EXPORT_POLYLINE_ICO</source>
-      <translation>icon_export_polyline.png</translation>
+      <source>EXPORT_TO_SHAPE_FILE_ICO</source>
+      <translation>icon_export_shp.png</translation>
     </message>
 
     <message>
index bd88bd54135141c0c106e17dd6f4b90dfd0ca35e..7f5cf26d9b0670a827c57901e705bfe1273368bb 100644 (file)
@@ -1047,8 +1047,8 @@ Would you like to remove all references from the image?</translation>
       <translation>Submersible</translation>
     </message>
     <message>
-      <source>DSK_EXPORT_POLYLINE</source>
-      <translation>Export Polyline</translation>
+      <source>DSK_EXPORT_TO_SHAPE_FILE</source>
+      <translation>Export to Shape file</translation>
     </message>
     <message>
       <source>MEN_CREATE_CALCULATION</source>
@@ -1359,8 +1359,8 @@ Would you like to remove all references from the image?</translation>
       <translation>Submersible</translation>
     </message>
     <message>
-      <source>MEN_EXPORT_POLYLINE</source>
-      <translation>Export Polyline</translation>
+      <source>MEN_EXPORT_TO_SHAPE_FILE</source>
+      <translation>Export to Shape file</translation>
     </message>
 
     <message>
@@ -1653,8 +1653,8 @@ Would you like to remove all references from the image?</translation>
       <translation>If the object is submersible</translation>
     </message>
     <message>
-      <source>STB_EXPORT_POLYLINE</source>
-      <translation>Export Polyline</translation>
+      <source>STB_EXPORT_TO_SHAPE_FILE</source>
+      <translation>Export to Shape file</translation>
     </message>
 
 
@@ -2315,8 +2315,12 @@ file cannot be correctly imported for an Obstacle definition.</translation>
   <context>
     <name>HYDROGUI_ExportFileOp</name>
     <message>
-      <source>EXPORT_POLYLINE</source>
-      <translation>Export polyline</translation>
+      <source>EXPORT_TO_SHAPE_FILE</source>
+      <translation>Export to Shape file</translation>
+    </message>
+    <message>
+      <source>SHP_FILTER</source>
+      <translation>Shape Files (*.shp)</translation>
     </message>
   </context>
   
@@ -3017,6 +3021,10 @@ Polyline should consist from one not closed curve.</translation>
       <source>COMPLETE_SPLIT</source>
       <translation>Complete split</translation>
     </message>
+    <message>
+      <source>RESULT_NAME</source>
+      <translation>Result name prefix:</translation>
+    </message>
   </context>
 
   <context>
@@ -3029,6 +3037,10 @@ Polyline should consist from one not closed curve.</translation>
       <source>MERGE_POLYLINES</source>
       <translation>Merge polylines</translation>
     </message>
+    <message>
+      <source>RESULT_NAME</source>
+      <translation>Result name:</translation>
+    </message>
   </context>
 
   <context>
diff --git a/src/HYDROGUI/resources/icon_export_polyline.png b/src/HYDROGUI/resources/icon_export_polyline.png
deleted file mode 100644 (file)
index 3e28616..0000000
Binary files a/src/HYDROGUI/resources/icon_export_polyline.png and /dev/null differ
diff --git a/src/HYDROGUI/resources/icon_export_shp.png b/src/HYDROGUI/resources/icon_export_shp.png
new file mode 100644 (file)
index 0000000..3e28616
Binary files /dev/null and b/src/HYDROGUI/resources/icon_export_shp.png differ