From: adv Date: Thu, 29 Aug 2013 05:39:45 +0000 (+0000) Subject: First implimentation of Bathymetry. Import of Bathymetries from fiels (Feature #8). X-Git-Tag: BR_hydro_v_0_1~96 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8527695a89dcaeb06af9f772063c85ba4aa7eb42;p=modules%2Fhydro.git First implimentation of Bathymetry. Import of Bathymetries from fiels (Feature #8). --- diff --git a/src/HYDROData/HYDROData.vcproj b/src/HYDROData/HYDROData.vcproj index 96e01b37..7d2363f6 100644 --- a/src/HYDROData/HYDROData.vcproj +++ b/src/HYDROData/HYDROData.vcproj @@ -1,7 +1,7 @@ + + @@ -182,6 +186,10 @@ RelativePath=".\HYDROData_Application.h" > + + diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx new file mode 100644 index 00000000..31bd8cc7 --- /dev/null +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -0,0 +1,170 @@ + +#include "HYDROData_Bathymetry.h" + +#include +#include + +#include + +#include +#include +#include +#include + +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 index 00000000..0f93d19c --- /dev/null +++ b/src/HYDROData/HYDROData_Bathymetry.h @@ -0,0 +1,119 @@ + +#ifndef HYDROData_Bathymetry_HeaderFile +#define HYDROData_Polyline_HeaderFile + +#include + +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 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 diff --git a/src/HYDROData/HYDROData_Iterator.cxx b/src/HYDROData/HYDROData_Iterator.cxx index 95a70708..40e8322c 100644 --- a/src/HYDROData/HYDROData_Iterator.cxx +++ b/src/HYDROData/HYDROData_Iterator.cxx @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -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); diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index 993297ad..a8f999f2 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -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) diff --git a/src/HYDROGUI/HYDROGUI.vcproj b/src/HYDROGUI/HYDROGUI.vcproj index 16b849d1..02ebe2d9 100644 --- a/src/HYDROGUI/HYDROGUI.vcproj +++ b/src/HYDROGUI/HYDROGUI.vcproj @@ -154,6 +154,14 @@ RelativePath=".\HYDROGUI_GVSelector.cxx" > + + + + @@ -349,6 +357,34 @@ /> + + + + + + + + + + @@ -721,6 +757,14 @@ RelativePath=".\moc\moc_HYDROGUI_GVSelector.cxx" > + + + + diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 63a65988..1c8368ff 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -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 index 00000000..447a8132 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.cxx @@ -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 +#include + +#include +#include +#include +#include +#include +#include +#include + +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 index 00000000..1a8a10a7 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.h @@ -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 + +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 index 00000000..d902c7d3 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx @@ -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 + +#include +#include + +#include + +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( 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( 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( 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 index 00000000..850ef425 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h @@ -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 diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 77d05454..101a4425 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -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; diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 2e5015d1..d68f4bcb 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -26,20 +26,29 @@ enum OperationId { FirstId = 0, + SaveVisualStateId, LoadVisualStateId, + UndoId, RedoId, + ImportImageId, EditImportedImageId, EditCompositeImageId, ObserveImageId, ExportImageId, + CreatePolylineId, EditPolylineId, + + ImportBathymetryId, + EditImportedBathymetryId, + FuseId, CutId, DeleteId, + ShowId, ShowOnlyId, ShowAllId, diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index a2a238b8..3792b419 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1,11 +1,29 @@ + @default + + BATHYMETRY_FILTER + Bathymetry files (*.xyz);;All files (*.* *) + + + FILE_NOT_EXISTS_OR_CANT_BE_READ + The file '%1' +does not exist or you have not enough permissions to open it. + IMAGE_FILTER Image files (*.bmp *.jpg *.jpeg *.png);;All files (*.* *) + + INCORRECT_OBJECT_NAME + The object name must not be an empty string value. + + + INCORRECT_FILE_NAME + The file name must not be an empty string value. + INSUFFICIENT_INPUT_DATA Insufficient input data @@ -19,6 +37,7 @@ Object with name '%1' already exists in the document. + HYDROGUI_DataModel @@ -30,6 +49,7 @@ Study could not be saved + HYDROGUI_DeleteOp @@ -45,6 +65,7 @@ Do you really want to delete the selected object(s)? + HYDROGUI_ExportImageOp @@ -56,6 +77,7 @@ Export image to file + HYDROGUI_InputPanel @@ -71,6 +93,40 @@ Help + + + HYDROGUI_ImportBathymetryDlg + + BATHYMETRY_NAME + Bathymetry name + + + FILE_NAME + File name + + + IMPORT_BATHYMETRY_FROM_FILE + Import Bathymetry from file + + + NAME + Name + + + + + HYDROGUI_ImportBathymetryOp + + IMPORT_BATHYMETRY + Import Bathymetry + + + BAD_IMPORTED_BATHYMETRY_FILE + '%1' +file cannot be correctly imported for a Bathymetry definition. + + + HYDROGUI_ImportImageDlg @@ -106,6 +162,7 @@ Transform image + HYDROGUI_ImportImageOp @@ -129,6 +186,7 @@ Transformation matrix cannot be computed. + HYDROGUI_Module @@ -171,6 +229,10 @@ DSK_HIDE_ALL Hide all + + DSK_IMPORT_BATHYMETRY + Import Bathymetry + DSK_IMPORT_IMAGE Import image @@ -255,6 +317,10 @@ MEN_HIDE_ALL Hide all + + MEN_IMPORT_BATHYMETRY + Import Bathymetry + MEN_IMPORT_IMAGE Import image @@ -331,6 +397,10 @@ STB_HIDE_ALL Hide all + + STB_IMPORT_BATHYMETRY + Import Bathymetry + STB_IMPORT_IMAGE Import image @@ -368,6 +438,7 @@ Undo + HYDROGUI_PolylineOp @@ -379,6 +450,7 @@ Edit polyline + HYDROGUI_ShowHideOp @@ -402,6 +474,7 @@ Hide all + HYDROGUI_ObserveImageOp @@ -409,6 +482,7 @@ Observe image + HYDROGUI_PolylineDlg @@ -416,6 +490,7 @@ Name + HYDROGUI_TwoImagesDlg @@ -451,6 +526,7 @@ Transparent + HYDROGUI_TwoImagesOp @@ -462,6 +538,7 @@ Fuse + HYDROGUI_VisualStateOp @@ -473,4 +550,5 @@ Save visual state +