<?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"
>
--- /dev/null
+
+#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;
+}
+
+
+
+
--- /dev/null
+
+#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
#include <HYDROData_Image.h>
#include <HYDROData_Polyline.h>
#include <HYDROData_VisualState.h>
+#include <HYDROData_Bathymetry.h>
#include <TDataStd_Name.hxx>
#include <NCollection_DataMap.hxx>
case KIND_VISUAL_STATE:
aResult = new HYDROData_VisualState();
break;
+ case KIND_BATHYMETRY:
+ aResult = new HYDROData_Bathymetry();
+ break;
}
if (!aResult.IsNull())
aResult->SetLabel(theLabel);
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)
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"
>
#include <HYDROData_Iterator.h>
#include <HYDROData_Polyline.h>
#include <HYDROData_VisualState.h>
+#include <HYDROData_Bathymetry.h>
#include <CAM_Application.h>
#include <CAM_DataObject.h>
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 );
--- /dev/null
+// 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 );
+ }
+}
+
+
+
+
--- /dev/null
+// 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
--- /dev/null
+// 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 );
+ }
+}
+
+
+
--- /dev/null
+// 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
#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"
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" );
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 );
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;
enum OperationId
{
FirstId = 0,
+
SaveVisualStateId,
LoadVisualStateId,
+
UndoId,
RedoId,
+
ImportImageId,
EditImportedImageId,
EditCompositeImageId,
ObserveImageId,
ExportImageId,
+
CreatePolylineId,
EditPolylineId,
+
+ ImportBathymetryId,
+ EditImportedBathymetryId,
+
FuseId,
CutId,
DeleteId,
+
ShowId,
ShowOnlyId,
ShowAllId,
<!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>
<translation>Object with name '%1' already exists in the document.</translation>
</message>
</context>
+
<context>
<name>HYDROGUI_DataModel</name>
<message>
<translation>Study could not be saved</translation>
</message>
</context>
+
<context>
<name>HYDROGUI_DeleteOp</name>
<message>
<translation>Do you really want to delete the selected object(s)?</translation>
</message>
</context>
+
<context>
<name>HYDROGUI_ExportImageOp</name>
<message>
<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>