// Close the file
aFile.Close();
- for ( int i = 1, n = aCreatedProfiles.Length(); i < n ; ++i )
+ for ( int i = 1, n = aCreatedProfiles.Length(); i <= n ; ++i )
{
Handle(HYDROData_Profile) aProfile = aCreatedProfiles.Value( i );
if ( aRes )
HYDROGUI_ObstacleDlg.h
HYDROGUI_SetColorOp.h
HYDROGUI_ColorDlg.h
+ HYDROGUI_ImportProfilesOp.h
)
QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
HYDROGUI_ObstacleDlg.cxx
HYDROGUI_SetColorOp.cxx
HYDROGUI_ColorDlg.cxx
+ HYDROGUI_ImportProfilesOp.cxx
)
add_definitions(
--- /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_ImportProfilesOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+
+#include <HYDROData_Profile.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_FileDlg.h>
+
+#include <QFileInfo>
+
+HYDROGUI_ImportProfilesOp::HYDROGUI_ImportProfilesOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+ setName( tr( "IMPORT_PROFILES" ) );
+}
+
+HYDROGUI_ImportProfilesOp::~HYDROGUI_ImportProfilesOp()
+{
+}
+
+void HYDROGUI_ImportProfilesOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ myFileDlg = new SUIT_FileDlg( module()->getApp()->desktop(), true );
+ myFileDlg->setWindowTitle( getName() );
+ myFileDlg->setFileMode( SUIT_FileDlg::ExistingFiles );
+ myFileDlg->setFilter( tr("PROFILE_FILTER") );
+
+ connect( myFileDlg, SIGNAL( accepted() ), this, SLOT( onApply() ) );
+ connect( myFileDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
+
+ myFileDlg->exec();
+}
+
+bool HYDROGUI_ImportProfilesOp::processApply( int& theUpdateFlags,
+ QString& theErrorMsg )
+{
+ if ( !myFileDlg ) {
+ return false;
+ }
+
+ bool aRes = false;
+
+ // Get the selected files
+ QStringList aFileNames = myFileDlg->selectedFiles();
+
+ // Import each of the selected files, fill the list of bad imported files
+ QString aBadImportedFiles;
+ foreach ( const QString& aFileName, aFileNames ) {
+ if ( !HYDROData_Profile::ImportFromFile( doc(), qPrintable( aFileName ) ) ) {
+ aBadImportedFiles += aFileName + "\n";
+ }
+ }
+
+ // Operation is successful if all the selected files imported succesfully
+ if ( aBadImportedFiles.isEmpty() ) {
+ aRes = true;
+ } else {
+ theErrorMsg = tr( "BAD_IMPORTED_PROFILES_FILES" ).arg( aBadImportedFiles );
+ abort();
+ }
+
+ theUpdateFlags = UF_Model;
+
+ return aRes;
+}
--- /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_IMPORTPROFILES_H
+#define HYDROGUI_IMPORTPROFILES_H
+
+#include "HYDROGUI_Operation.h"
+
+class SUIT_FileDlg;
+
+class HYDROGUI_ImportProfilesOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_ImportProfilesOp( HYDROGUI_Module* theModule );
+ virtual ~HYDROGUI_ImportProfilesOp();
+
+protected:
+ virtual void startOperation();
+
+ virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+
+private:
+ SUIT_FileDlg* myFileDlg;
+};
+
+#endif
break;
case KIND_PROFILE:
theMenu->addAction( action( CreateProfileId ) );
+ theMenu->addAction( action( ImportProfilesId ) );
break;
case KIND_VISUAL_STATE:
theMenu->addAction( action( SaveVisualStateId ) );
#include "HYDROGUI_ImportGeomObjectOp.h"
#include "HYDROGUI_ImportObstacleFromFileOp.h"
#include "HYDROGUI_ExportCalculationOp.h"
+#include "HYDROGUI_ImportProfilesOp.h"
#include "HYDROGUI_SetColorOp.h"
#include "HYDROData_Document.h"
createAction( EditPolylineId, "EDIT_POLYLINE" );
createAction( CreateProfileId, "CREATE_PROFILE" );
+ createAction( ImportProfilesId, "IMPORT_PROFILES" );
createAction( EditProfileId, "EDIT_PROFILE" );
createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "", Qt::CTRL + Qt::Key_B );
createMenu( ImportImageId, aHydroId, -1, -1 );
createMenu( ImportBathymetryId, aHydroId, -1, -1 );
createMenu( CreatePolylineId, aHydroId, -1, -1 );
- createMenu( CreateProfileId, aHydroId, -1, -1 );
+
+ int aNewProfileId = createMenu( tr( "MEN_PROFILE" ), aHydroId, -1 );
+ createMenu( CreateProfileId, aNewProfileId, -1, -1 );
+ createMenu( ImportProfilesId, aNewProfileId, -1, -1 );
+
createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
int aNewObstacleId = createMenu( tr( "MEN_OBSTACLE" ), aHydroId, -1 );
case EditProfileId:
anOp = new HYDROGUI_ProfileOp( aModule, theId == EditProfileId );
break;
+ case ImportProfilesId:
+ anOp = new HYDROGUI_ImportProfilesOp( aModule ) ;
+ break;
case ImportBathymetryId:
anOp = new HYDROGUI_ImportBathymetryOp( aModule );
break;
CreatePolylineId,
EditPolylineId,
+ ImportProfilesId,
CreateProfileId,
EditProfileId,
CreateBoxId,
CreateCylinderId,
- ImportProfilesId,
-
DeleteId,
ShowId,
//OCCViewer_ViewManager* myViewManager;
bool myIsEdit;
- Handle(HYDROData_Profile) myEditedObject;
+ Handle(HYDROData_Profile) myEditedObject;
CurveCreator_Curve* myCurve;
};
<source>DSK_CREATE_PROFILE</source>
<translation>Create profile</translation>
</message>
+ <message>
+ <source>DSK_IMPORT_PROFILES</source>
+ <translation>Import profiles from file(s)</translation>
+ </message>
<message>
<source>DSK_CREATE_IMMERSIBLE_ZONE</source>
<translation>Create immersible zone</translation>
<source>MEN_CREATE_PROFILE</source>
<translation>Create profile</translation>
</message>
+ <message>
+ <source>MEN_IMPORT_PROFILES</source>
+ <translation>Import profiles</translation>
+ </message>
<message>
<source>MEN_CREATE_ZONE</source>
<translation>Create zone</translation>
<source>MEN_OBSTACLE</source>
<translation>Obstacle</translation>
</message>
+ <message>
+ <source>MEN_PROFILE</source>
+ <translation>Profile</translation>
+ </message>
<message>
<source>MEN_IMPORT_OBSTACLE_FROM_FILE</source>
<translation>Import obstacle</translation>
<source>STB_CREATE_PROFILE</source>
<translation>Create profile</translation>
</message>
+ <message>
+ <source>STB_IMPORT_PROFILES</source>
+ <translation>Import profiles from file(s)</translation>
+ </message>
<message>
<source>STB_CREATE_IMMERSIBLE_ZONE</source>
<translation>Create immersible zone</translation>
</message>
</context>
+ <context>
+ <name>HYDROGUI_ImportProfilesOp</name>
+ <message>
+ <source>IMPORT_PROFILES</source>
+ <translation>Import profiles</translation>
+ </message>
+ <message>
+ <source>PROFILE_FILTER</source>
+ <translation>All files (*.* *)</translation>
+ </message>
+ <message>
+ <source>BAD_IMPORTED_PROFILES_FILES</source>
+ <translation>The following files cannot be correctly imported for a Profile definition:
+%1
+</translation>
+ </message>
+ </context>
+
<context>
<name>HYDROGUI_SetColorOp</name>
<message>