]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
First implimentation of Bathymetry. Import of Bathymetries from fiels (Feature #8).
authoradv <adv@opencascade.com>
Thu, 29 Aug 2013 05:39:45 +0000 (05:39 +0000)
committeradv <adv@opencascade.com>
Thu, 29 Aug 2013 05:39:45 +0000 (05:39 +0000)
14 files changed:
src/HYDROData/HYDROData.vcproj
src/HYDROData/HYDROData_Bathymetry.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_Bathymetry.h [new file with mode: 0644]
src/HYDROData/HYDROData_Iterator.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROGUI/HYDROGUI.vcproj
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 96e01b370f74b9464e0758dd05bf3e7e8825dcea..7d2363f6082ecf9d5dd9825c9315cecf335ae9f1 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="windows-1251"?>
 <VisualStudioProject
        ProjectType="Visual C++"
-       Version="9,00"
+       Version="9.00"
        Name="HYDROData"
        ProjectGUID="{EB7B7816-4EA0-4E7D-A88A-1417DEB0FC1C}"
        RootNamespace="HYDROData"
                                RelativePath=".\HYDROData_Application.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_Bathymetry.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Document.cxx"
                                >
                                RelativePath=".\HYDROData_Application.h"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROData_Bathymetry.h"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROData_Document.h"
                                >
diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx
new file mode 100644 (file)
index 0000000..31bd8cc
--- /dev/null
@@ -0,0 +1,170 @@
+
+#include "HYDROData_Bathymetry.h"
+
+#include <gp_XY.hxx>
+#include <gp_XYZ.hxx>
+
+#include <TDataStd_RealArray.hxx>
+
+#include <QFile>
+#include <QFileInfo>
+#include <QPointF>
+#include <QStringList>
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Object)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Bathymetry, HYDROData_Object)
+
+HYDROData_Bathymetry::HYDROData_Bathymetry()
+{
+}
+
+HYDROData_Bathymetry::~HYDROData_Bathymetry()
+{
+}
+
+void HYDROData_Bathymetry::SetAltitudePoints( const AltitudePoints& thePoints )
+{
+  RemoveAltitudePoints();
+
+  if ( thePoints.isEmpty() )
+    return;
+
+  // Save coordinates
+  Handle(TDataStd_RealArray) aCoordsArray = 
+    TDataStd_RealArray::Set( myLab.FindChild( DataTag_AltitudePoints ), 0, thePoints.size() * 3 - 1 );
+
+  AltitudePoints::const_iterator aListItBeg =  thePoints.constBegin();
+  AltitudePoints::const_iterator aListItEnd =  thePoints.constEnd();
+  for ( int i = 0 ; aListItBeg != aListItEnd; ++i, ++aListItBeg )
+  {
+    const AltitudePoint& aPoint = *aListItBeg;
+
+    aCoordsArray->SetValue( i * 3, aPoint.X() );
+    aCoordsArray->SetValue( i * 3 + 1, aPoint.Y() );
+    aCoordsArray->SetValue( i * 3 + 2, aPoint.Z() );
+  }
+}
+
+HYDROData_Bathymetry::AltitudePoints HYDROData_Bathymetry::GetAltitudePoints() const
+{
+  AltitudePoints aPoints;
+
+  Handle(TDataStd_RealArray) aCoordsArray;
+  if ( !myLab.FindChild( DataTag_AltitudePoints ).FindAttribute( TDataStd_RealArray::GetID(), aCoordsArray ) )
+    return aPoints;
+
+  int aLowerIdx = aCoordsArray->Lower();
+  int anUpperIdx = aCoordsArray->Upper();
+  for ( int i = aCoordsArray->Lower(), n = aCoordsArray->Upper(); i <= n; )
+  {
+    if ( i + 3 > n )
+      break;
+
+    AltitudePoint aPoint;
+    aPoint.SetX( aCoordsArray->Value( i++ ) );
+    aPoint.SetY( aCoordsArray->Value( i++ ) );
+    aPoint.SetZ( aCoordsArray->Value( i++ ) );
+
+    aPoints << aPoint;
+  }
+
+  return aPoints;
+}
+
+void HYDROData_Bathymetry::RemoveAltitudePoints()
+{
+  TDF_Label aLab = myLab.FindChild( DataTag_AltitudePoints );
+  aLab.ForgetAllAttributes();
+}
+
+double HYDROData_Bathymetry::GetAltitudeForPoint( const QPointF& thePoint ) const
+{
+  gp_XY aGpPoint( thePoint.x(), thePoint.y() );
+  return GetAltitudeForPoint( aGpPoint );
+}
+
+double HYDROData_Bathymetry::GetAltitudeForPoint( const gp_XY& thePoint ) const
+{
+  double aResAltitude = -9999.90;
+  
+  AltitudePoints anAltitudePoints = GetAltitudePoints();
+
+  // TODO : implement
+
+  return aResAltitude;
+}
+
+bool HYDROData_Bathymetry::ImportFromFile( const QString& theFileName )
+{
+  // Try to open the file
+  QFile aFile( theFileName );
+  if ( !aFile.exists() || !aFile.open( QIODevice::ReadOnly ) )
+    return false;
+
+  bool aRes = false;
+
+  QString aFileSuf = QFileInfo( aFile ).suffix().toLower();
+
+  AltitudePoints aPoints;
+
+  // Try to import the file
+  if ( aFileSuf == "xyz" )
+    aRes = importFromXYZFile( aFile, aPoints );
+    
+  // Close the file
+  aFile.close();
+
+  if ( aRes )
+  {
+    // Update altitude points of this Bathymetry
+    SetAltitudePoints( aPoints );
+  }
+
+  return aRes && !aPoints.isEmpty();
+}
+
+bool HYDROData_Bathymetry::importFromXYZFile( QFile&          theFile,
+                                              AltitudePoints& thePoints )
+{
+  if ( !theFile.isOpen() )
+    return false;
+
+  // Strings in file is written as:
+  //  1. X(float) Y(float) Z(float)
+  //  2. X(float) Y(float) Z(float)
+  //  ...
+
+  while ( !theFile.atEnd() )
+  {
+    QString aLine = theFile.readLine();
+    if ( aLine.isEmpty() )
+      continue;
+
+    QStringList aValues = aLine.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
+    if ( aValues.length() < 3 )
+      return false;
+
+    AltitudePoint aPoint;
+    
+    QString anX = aValues.value( 0 );
+    QString anY = aValues.value( 1 );
+    QString aZ  = aValues.value( 2 );
+
+    bool isXOk = false, isYOk = false, isZOk = false;
+
+    aPoint.SetX( anX.toDouble( &isXOk ) );
+    aPoint.SetY( anY.toDouble( &isYOk ) );
+    aPoint.SetZ(  aZ.toDouble( &isZOk ) );
+
+    if ( !isXOk || !isYOk || !isZOk )
+      return false;
+
+    thePoints << aPoint;
+  }
+
+  return true;
+}
+
+
+
+
diff --git a/src/HYDROData/HYDROData_Bathymetry.h b/src/HYDROData/HYDROData_Bathymetry.h
new file mode 100644 (file)
index 0000000..0f93d19
--- /dev/null
@@ -0,0 +1,119 @@
+
+#ifndef HYDROData_Bathymetry_HeaderFile
+#define HYDROData_Polyline_HeaderFile
+
+#include <HYDROData_Object.h>
+
+class gp_XY;
+class gp_XYZ;
+class QPointF;
+class QFile;
+
+DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Object)
+
+
+/**\class HYDROData_Bathymetry
+ * \brief Class that stores/retreives information about the Bathymetry.
+ *
+ * The Bathymetry represents measurement of the altitude of points on the terrain.
+ */
+class HYDROData_Bathymetry : public HYDROData_Object
+{
+public:
+
+  typedef gp_XYZ               AltitudePoint;
+  typedef QList<AltitudePoint> AltitudePoints;
+
+protected:
+
+  /**
+   * Enumeration of tags corresponding to the persistent object parameters.
+   */
+  enum DataTag
+  {
+    DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_AltitudePoints ///< altitude points, array of reals
+  };
+
+public:
+
+  DEFINE_STANDARD_RTTI(HYDROData_Bathymetry);
+
+  /**
+   * Returns the kind of this object. Must be redefined in all objects of known type.
+   */
+  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_BATHYMETRY; }
+
+
+public:      
+  // Public methods to work with Bathymetry altitudes.
+
+  /**
+   * Replace current altitude points by new one.
+   * \param thePoints the altitude points list
+   */
+  HYDRODATA_EXPORT virtual void             SetAltitudePoints( const AltitudePoints& thePoints );
+
+  /**
+   * Returns altitude points list.
+   * \return points list
+   */
+  HYDRODATA_EXPORT virtual AltitudePoints   GetAltitudePoints() const;
+
+  /**
+   * Remove all altitude points.
+   */
+  HYDRODATA_EXPORT virtual void             RemoveAltitudePoints();
+
+  /**
+   * Returns altitude for given point.
+   * \param thePoint the point to examine
+   * \return altitude value
+   */
+  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const QPointF& thePoint ) const;
+
+  /**
+   * Returns altitude for given point.
+   * \param thePoint the point to examine
+   * \return altitude value
+   */
+  HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint ) const;
+
+
+public:
+  // Public methods to work with files.
+
+  /**
+   * Imports Bathymetry data from file. The supported file types:
+   *  - xyz
+   * \param theFileName the path to file
+   * \return \c true if file has been successfully read
+   */
+  HYDRODATA_EXPORT virtual bool             ImportFromFile( const QString& theFileName );
+
+
+private:
+
+  /**
+   * Imports Bathymetry data from 'XYZ' file.
+   */
+  bool                                      importFromXYZFile( QFile&          theFile,
+                                                               AltitudePoints& thePoints );
+
+protected:
+
+  friend class HYDROData_Iterator;
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDROData_Bathymetry();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  ~HYDROData_Bathymetry();
+};
+
+#endif
index 95a70708b9a8c8531b4b3821d771e99fb1581d48..40e8322cc70b41ff12f4198feed6924bab9e6eba 100644 (file)
@@ -3,6 +3,7 @@
 #include <HYDROData_Image.h>
 #include <HYDROData_Polyline.h>
 #include <HYDROData_VisualState.h>
+#include <HYDROData_Bathymetry.h>
 
 #include <TDataStd_Name.hxx>
 #include <NCollection_DataMap.hxx>
@@ -62,6 +63,9 @@ Handle_HYDROData_Object HYDROData_Iterator::Object(const TDF_Label theLabel)
   case KIND_VISUAL_STATE:
     aResult = new HYDROData_VisualState();
     break;
+  case KIND_BATHYMETRY:
+    aResult = new HYDROData_Bathymetry();
+    break;
   }
   if (!aResult.IsNull())
     aResult->SetLabel(theLabel);
index 993297ad76778812ca1343d005e611208f6ef2eb..a8f999f202b30a4fc460169a4427b68cda47811f 100644 (file)
@@ -15,6 +15,7 @@ const ObjectKind KIND_UNKNOWN = 0;
 const ObjectKind KIND_IMAGE = 1;
 const ObjectKind KIND_POLYLINE = 2;
 const ObjectKind KIND_VISUAL_STATE = 3;
+const ObjectKind KIND_BATHYMETRY = 4;
 
 DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
 
index 16b849d194bed5bbe948ce0e63d8febb769cc12e..02ebe2d9168813035d09f9f8c2d854dcadae814f 100644 (file)
                                RelativePath=".\HYDROGUI_GVSelector.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ImportBathymetryDlg.cxx"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ImportBathymetryOp.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\HYDROGUI_ImportImageDlg.cxx"
                                >
                                        />
                                </FileConfiguration>
                        </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ImportBathymetryDlg.h"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating moc_$(InputName).cxx"
+                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+                                               Outputs="moc/moc_$(InputName).cxx"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath=".\HYDROGUI_ImportBathymetryOp.h"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Generating moc_$(InputName).cxx"
+                                               CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+                                               Outputs="moc/moc_$(InputName).cxx"
+                                       />
+                               </FileConfiguration>
+                       </File>
                        <File
                                RelativePath=".\HYDROGUI_ImportImageDlg.h"
                                >
                                RelativePath=".\moc\moc_HYDROGUI_GVSelector.cxx"
                                >
                        </File>
+                       <File
+                               RelativePath=".\moc\moc_HYDROGUI_ImportBathymetryDlg.cxx"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\moc\moc_HYDROGUI_ImportBathymetryOp.cxx"
+                               >
+                       </File>
                        <File
                                RelativePath=".\moc\moc_HYDROGUI_ImportImageDlg.cxx"
                                >
index 63a65988236d2b226aae0af598d2a9fc2791bccf..1c8368ffaf5d37f99c03aeb4cd531f6065a0d6b2 100644 (file)
@@ -31,6 +31,7 @@
 #include <HYDROData_Iterator.h>
 #include <HYDROData_Polyline.h>
 #include <HYDROData_VisualState.h>
+#include <HYDROData_Bathymetry.h>
 
 #include <CAM_Application.h>
 #include <CAM_DataObject.h>
@@ -196,6 +197,17 @@ void HYDROGUI_DataModel::update( const int theStudyId )
       createObject( anImageRootObj, anImageObj );
   }
 
+  LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, "BATHYMETRIES" );
+
+  anIterator = HYDROData_Iterator( aDocument, KIND_BATHYMETRY );
+  for( ; anIterator.More(); anIterator.Next() )
+  {
+    Handle(HYDROData_Bathymetry) aBathymetryObj =
+      Handle(HYDROData_Bathymetry)::DownCast( anIterator.Current() );
+    if( !aBathymetryObj.IsNull() )
+      createObject( aBathymetryRootObj, aBathymetryObj );
+  }
+
   LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, "POLYLINES" );
 
   anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE );
diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.cxx
new file mode 100644 (file)
index 0000000..447a813
--- /dev/null
@@ -0,0 +1,130 @@
+// Copyright (C) 2007-2013  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.
+//
+// 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_ImportBathymetryDlg.h"
+
+#include "HYDROGUI_Tool.h"
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
+#include <QFileDialog>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+#include <QPicture>
+#include <QToolButton>
+
+HYDROGUI_ImportBathymetryDlg::HYDROGUI_ImportBathymetryDlg( HYDROGUI_Module* theModule, const QString& theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle )
+{
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+
+  // Import bathymetry from file
+  myFileNameGroup = new QGroupBox( tr( "IMPORT_BATHYMETRY_FROM_FILE" ) );
+
+  QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
+
+  myFileName = new QLineEdit( myFileNameGroup );
+  myFileName->setReadOnly( true );
+
+  QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup );
+  aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
+
+  QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup );
+  aFileNameLayout->setMargin( 5 );
+  aFileNameLayout->setSpacing( 5 );
+  aFileNameLayout->addWidget( aFileNameLabel );
+  aFileNameLayout->addWidget( myFileName );
+  aFileNameLayout->addWidget( aBrowseBtn );
+
+  // Bathymetry name
+  myObjectNameGroup = new QGroupBox( tr( "BATHYMETRY_NAME" ) );
+
+  QLabel* aBathymetryNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup );
+  myObjectName = new QLineEdit( myObjectNameGroup );
+
+  QBoxLayout* aBathymetryNameLayout = new QHBoxLayout( myObjectNameGroup );
+  aBathymetryNameLayout->setMargin( 5 );
+  aBathymetryNameLayout->setSpacing( 5 );
+  aBathymetryNameLayout->addWidget( aBathymetryNameLabel );
+  aBathymetryNameLayout->addWidget( myObjectName );
+
+  // Common
+  addWidget( myFileNameGroup );
+  addWidget( myObjectNameGroup );
+  addStretch();
+
+  connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
+}
+
+HYDROGUI_ImportBathymetryDlg::~HYDROGUI_ImportBathymetryDlg()
+{
+}
+
+void HYDROGUI_ImportBathymetryDlg::reset()
+{
+  myFileName->clear();
+  myObjectName->clear();
+  myObjectNameGroup->setEnabled( false );
+}
+
+void HYDROGUI_ImportBathymetryDlg::setObjectName( const QString& theName )
+{
+  myObjectName->setText( theName );
+  myObjectNameGroup->setEnabled( !theName.isEmpty() || !myFileName->text().isEmpty() );
+}
+
+QString HYDROGUI_ImportBathymetryDlg::getObjectName() const
+{
+  return myObjectName->text();
+}
+
+void HYDROGUI_ImportBathymetryDlg::setFileName( const QString& theFileName )
+{
+  myFileName->setText( theFileName );
+
+  if ( !myObjectNameGroup->isEnabled() )
+    myObjectNameGroup->setEnabled( !theFileName.isEmpty() );
+}
+
+QString HYDROGUI_ImportBathymetryDlg::getFileName() const
+{
+  return myFileName->text();
+}
+
+void HYDROGUI_ImportBathymetryDlg::onBrowse()
+{
+  QString aFilter( tr( "BATHYMETRY_FILTER" ) );
+  QString aFileName = QFileDialog::getOpenFileName( this, tr( "IMPORT_BATHYMETRY_FROM_FILE" ), "", aFilter );
+
+  if( !aFileName.isEmpty() )
+  {
+    setFileName( aFileName );
+    emit FileSelected( aFileName );
+  }
+}
+
+
+
+
diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.h b/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.h
new file mode 100644 (file)
index 0000000..1a8a10a
--- /dev/null
@@ -0,0 +1,63 @@
+// Copyright (C) 2007-2013  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.
+//
+// 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_IMPORTBATHYMETRYDLG_H
+#define HYDROGUI_IMPORTBATHYMETRYDLG_H
+
+#include "HYDROGUI_InputPanel.h"
+
+#include <QMap>
+
+class QGroupBox;
+class QLineEdit;
+
+class HYDROGUI_ImportBathymetryDlg : public HYDROGUI_InputPanel
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ImportBathymetryDlg( HYDROGUI_Module* theModule, const QString& theTitle );
+  virtual ~HYDROGUI_ImportBathymetryDlg();
+
+  void                       reset();
+
+  void                       setObjectName( const QString& theName );
+  QString                    getObjectName() const;
+
+  void                       setFileName( const QString& theFileName );
+  QString                    getFileName() const;
+
+signals:
+  void                       FileSelected( const QString& theFileName );
+
+protected slots:
+  void                       onBrowse();
+
+private:
+  QGroupBox*                 myFileNameGroup;
+  QLineEdit*                 myFileName;
+
+  QGroupBox*                 myObjectNameGroup;
+  QLineEdit*                 myObjectName;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx
new file mode 100644 (file)
index 0000000..d902c7d
--- /dev/null
@@ -0,0 +1,149 @@
+// Copyright (C) 2007-2013  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.
+//
+// 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_ImportBathymetryOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_ImportBathymetryDlg.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+#include <HYDROData_Bathymetry.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <QFileInfo>
+
+HYDROGUI_ImportBathymetryOp::HYDROGUI_ImportBathymetryOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+  setName( tr( "IMPORT_BATHYMETRY" ) );
+}
+
+HYDROGUI_ImportBathymetryOp::~HYDROGUI_ImportBathymetryOp()
+{
+}
+
+void HYDROGUI_ImportBathymetryOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  HYDROGUI_ImportBathymetryDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_ImportBathymetryDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  aPanel->reset();
+}
+
+void HYDROGUI_ImportBathymetryOp::abortOperation()
+{
+  HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_ImportBathymetryOp::commitOperation()
+{
+  HYDROGUI_Operation::commitOperation();
+}
+
+HYDROGUI_InputPanel* HYDROGUI_ImportBathymetryOp::createInputPanel() const
+{
+  HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportBathymetryDlg( module(), getName() );
+  
+  connect ( aPanel, SIGNAL( FileSelected( const QString& ) ), SLOT( onFileSelected() ) );
+
+  return aPanel;
+}
+
+bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags,
+                                                QString& theErrorMsg )
+{
+  HYDROGUI_ImportBathymetryDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_ImportBathymetryDlg*>( inputPanel() );
+  if ( !aPanel )
+    return false;
+
+  QString anObjectName = aPanel->getObjectName().simplified();
+  if ( anObjectName.isEmpty() )
+  {
+    theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+    return false;
+  }
+
+  QString aFileName = aPanel->getFileName().simplified();
+  if ( aFileName.isEmpty() )
+  {
+    theErrorMsg = tr( "INCORRECT_FILE_NAME" );
+    return false;
+  }
+
+  QFileInfo aFileInfo( aFileName );
+  if ( !aFileInfo.exists() || !aFileInfo.isReadable() )
+  {
+    theErrorMsg = tr( "FILE_NOT_EXISTS_OR_CANT_BE_READ" ).arg( aFileName );
+    return false;
+  }
+
+  // check that there are no other objects with the same name in the document
+  Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
+  if ( !anObject.IsNull() )
+  {
+    theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
+    return false;
+  }
+
+  Handle(HYDROData_Bathymetry) aBathymetryObj = 
+    Handle(HYDROData_Bathymetry)::DownCast( doc()->CreateObject( KIND_BATHYMETRY ) );
+  if ( aBathymetryObj.IsNull() )
+    return false;
+
+  if ( !aBathymetryObj->ImportFromFile( aFileName ) )
+  {
+    theErrorMsg = tr( "BAD_IMPORTED_BATHYMETRY_FILE" ).arg( aFileName );
+    return false;
+  }
+
+  aBathymetryObj->SetName( anObjectName );
+
+  theUpdateFlags = UF_Model;
+  return true;
+}
+
+void HYDROGUI_ImportBathymetryOp::onFileSelected()
+{
+  HYDROGUI_ImportBathymetryDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_ImportBathymetryDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  QString anObjectName = aPanel->getObjectName().simplified();
+  if ( anObjectName.isEmpty() )
+  {
+    anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Bathymetry" );
+    aPanel->setObjectName( anObjectName );
+  }
+}
+
+
+
diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h
new file mode 100644 (file)
index 0000000..850ef42
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright (C) 2007-2013  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.
+//
+// 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_IMPORTBATHYMETRY_H
+#define HYDROGUI_IMPORTBATHYMETRY_H
+
+#include "HYDROGUI_Operation.h"
+
+
+class HYDROGUI_ImportBathymetryOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ImportBathymetryOp( HYDROGUI_Module* theModule );
+  virtual ~HYDROGUI_ImportBathymetryOp();
+
+protected:
+  virtual void                    startOperation();
+  virtual void                    abortOperation();
+  virtual void                    commitOperation();
+
+  virtual HYDROGUI_InputPanel*    createInputPanel() const;
+
+  virtual bool                    processApply( int& theUpdateFlags, QString& theErrorMsg );
+
+
+protected slots:
+  void                            onFileSelected();
+
+private:
+};
+
+#endif
index 77d054542e69df5fba289ad4527f98bd9e15c5b5..101a44251b0169a842c6138b4247eee09489cf6c 100644 (file)
@@ -26,6 +26,7 @@
 #include "HYDROGUI_DeleteOp.h"
 #include "HYDROGUI_ExportImageOp.h"
 #include "HYDROGUI_ImportImageOp.h"
+#include "HYDROGUI_ImportBathymetryOp.h"
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_ObserveImageOp.h"
 #include "HYDROGUI_PolylineOp.h"
@@ -73,9 +74,12 @@ void HYDROGUI_Module::createActions()
   createAction( EditCompositeImageId, "EDIT_COMPOSITE_IMAGE" );
   createAction( ObserveImageId, "OBSERVE_IMAGE" );
   createAction( ExportImageId, "EXPORT_IMAGE" );
+
   createAction( CreatePolylineId, "CREATE_POLYLINE" );
   createAction( EditPolylineId, "EDIT_POLYLINE" ); 
 
+  createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "", Qt::CTRL + Qt::SHIFT + Qt::Key_I );
+
   createAction( FuseId, "FUSE_IMAGES" );
   createAction( CutId, "CUT_IMAGES" );
 
@@ -102,6 +106,7 @@ void HYDROGUI_Module::createMenus()
   int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
   int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
   createMenu( ImportImageId, aHydroId, -1, -1 );
+  createMenu( ImportBathymetryId, aHydroId, -1, -1 );
   createMenu( CreatePolylineId, aHydroId, -1, -1 );
   createMenu( FuseId, aHydroId, -1, -1 );
   createMenu( CutId, aHydroId, -1, -1 );
@@ -244,6 +249,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case EditCompositeImageId:
     anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Edit );
     break;
+  case ImportBathymetryId:
+    anOp = new HYDROGUI_ImportBathymetryOp( aModule );
+    break;
   case DeleteId:
     anOp = new HYDROGUI_DeleteOp( aModule );
     break;
index 2e5015d102c9ecc3f810c5582aa271087a285e60..d68f4bcb17dfd1c70fb8fb66cac472b5ee8fc933 100644 (file)
 enum OperationId
 {
   FirstId = 0,
+  
   SaveVisualStateId,
   LoadVisualStateId,
+  
   UndoId,
   RedoId,
+
   ImportImageId,
   EditImportedImageId,
   EditCompositeImageId,
   ObserveImageId,
   ExportImageId,
+
   CreatePolylineId,
   EditPolylineId,
+  
+  ImportBathymetryId,
+  EditImportedBathymetryId,
+
   FuseId,
   CutId,
   DeleteId,
+
   ShowId,
   ShowOnlyId,
   ShowAllId,
index a2a238b84f1559be18b57a4b307f515574e59d11..3792b419c1b65b1780bac6c43699b92162403a52 100644 (file)
@@ -1,11 +1,29 @@
 <!DOCTYPE TS>
 <TS version="1.1" >
+  
   <context>
     <name>@default</name>
+    <message>
+      <source>BATHYMETRY_FILTER</source>
+      <translation>Bathymetry files (*.xyz);;All files (*.* *)</translation>
+    </message>
+    <message>
+      <source>FILE_NOT_EXISTS_OR_CANT_BE_READ</source>
+      <translation>The file '%1'
+does not exist or you have not enough permissions to open it.</translation>
+    </message>
     <message>
       <source>IMAGE_FILTER</source>
       <translation>Image files (*.bmp *.jpg *.jpeg *.png);;All files (*.* *)</translation>
     </message>
+    <message>
+      <source>INCORRECT_OBJECT_NAME</source>
+      <translation>The object name must not be an empty string value.</translation>
+    </message>
+    <message>
+      <source>INCORRECT_FILE_NAME</source>
+      <translation>The file name must not be an empty string value.</translation>
+    </message>
     <message>
       <source>INSUFFICIENT_INPUT_DATA</source>
       <translation>Insufficient input data</translation>
@@ -19,6 +37,7 @@
       <translation>Object with name '%1' already exists in the document.</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_DataModel</name>
     <message>
@@ -30,6 +49,7 @@
       <translation>Study could not be saved</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_DeleteOp</name>
     <message>
@@ -45,6 +65,7 @@
       <translation>Do you really want to delete the selected object(s)?</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_ExportImageOp</name>
     <message>
@@ -56,6 +77,7 @@
       <translation>Export image to file</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_InputPanel</name>
     <message>
       <translation>Help</translation>
     </message>
   </context>
+  
+  <context>
+    <name>HYDROGUI_ImportBathymetryDlg</name>
+    <message>
+      <source>BATHYMETRY_NAME</source>
+      <translation>Bathymetry name</translation>
+    </message>
+    <message>
+      <source>FILE_NAME</source>
+      <translation>File name</translation>
+    </message>
+    <message>
+      <source>IMPORT_BATHYMETRY_FROM_FILE</source>
+      <translation>Import Bathymetry from file</translation>
+    </message>
+    <message>
+      <source>NAME</source>
+      <translation>Name</translation>
+    </message>
+  </context>
+  
+  <context>
+    <name>HYDROGUI_ImportBathymetryOp</name>
+    <message>
+      <source>IMPORT_BATHYMETRY</source>
+      <translation>Import Bathymetry</translation>
+    </message>
+    <message>
+      <source>BAD_IMPORTED_BATHYMETRY_FILE</source>
+      <translation>'%1'
+file cannot be correctly imported for a Bathymetry definition.</translation>
+    </message>
+  </context>
+  
   <context>
     <name>HYDROGUI_ImportImageDlg</name>
     <message>
       <translation>Transform image</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_ImportImageOp</name>
     <message>
       <translation>Transformation matrix cannot be computed.</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_Module</name>
     <message>
       <source>DSK_HIDE_ALL</source>
       <translation>Hide all</translation>
     </message>
+    <message>
+      <source>DSK_IMPORT_BATHYMETRY</source>
+      <translation>Import Bathymetry</translation>
+    </message>
     <message>
       <source>DSK_IMPORT_IMAGE</source>
       <translation>Import image</translation>
       <source>MEN_HIDE_ALL</source>
       <translation>Hide all</translation>
     </message>
+    <message>
+      <source>MEN_IMPORT_BATHYMETRY</source>
+      <translation>Import Bathymetry</translation>
+    </message>
     <message>
       <source>MEN_IMPORT_IMAGE</source>
       <translation>Import image</translation>
       <source>STB_HIDE_ALL</source>
       <translation>Hide all</translation>
     </message>
+    <message>
+      <source>STB_IMPORT_BATHYMETRY</source>
+      <translation>Import Bathymetry</translation>
+    </message>
     <message>
       <source>STB_IMPORT_IMAGE</source>
       <translation>Import image</translation>
       <translation>Undo</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_PolylineOp</name>
     <message>
       <translation>Edit polyline</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_ShowHideOp</name>
     <message>
       <translation>Hide all</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_ObserveImageOp</name>
     <message>
       <translation>Observe image</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_PolylineDlg</name>
     <message>
       <translation>Name</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_TwoImagesDlg</name>
     <message>
       <translation>Transparent</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_TwoImagesOp</name>
     <message>
       <translation>Fuse</translation>
     </message>
   </context>
+  
   <context>
     <name>HYDROGUI_VisualStateOp</name>
     <message>
       <translation>Save visual state</translation>
     </message>
   </context>
+  
 </TS>