From: dmv Date: Tue, 5 Aug 2008 12:15:59 +0000 (+0000) Subject: 0016187: EDF PAL 460: To be able to export a MED file saved in a HDF study X-Git-Tag: mergefrom_BR_WPdev_For_5_0_08Aug2008~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=55910e3056d22d6d033156600359b2c1574e80fa;p=modules%2Fvisu.git 0016187: EDF PAL 460: To be able to export a MED file saved in a HDF study --- diff --git a/doc/salome/gui/VISU/images/exportmedfile.png b/doc/salome/gui/VISU/images/exportmedfile.png new file mode 100644 index 00000000..c2fc56fd Binary files /dev/null and b/doc/salome/gui/VISU/images/exportmedfile.png differ diff --git a/doc/salome/gui/VISU/input/importing_med_objects.doc b/doc/salome/gui/VISU/input/importing_med_objects.doc index e4f00bba..e6a53c31 100644 --- a/doc/salome/gui/VISU/input/importing_med_objects.doc +++ b/doc/salome/gui/VISU/input/importing_med_objects.doc @@ -1,6 +1,6 @@ /*! -\page importing_med_objects_page Importing MED objects +\page importing_med_objects_page Import/Export MED objects \n There exist two sources of \ref structure_of_med_objects_page "MED objects": MED and other Salome components publishing them and MED files. @@ -77,4 +77,14 @@ highest and the lowest value. \b Time - shows the Elapsed time spent by the application on processing. +To export a MED file: +\par +Right-click on the top level of MED object in the Object Browser and select Export to MED +File option. When you do so you will see a standard dialog box where you can select the +path and change the name of the exported MED file: + +\image html exportmedfile.png + +To complete file export click Save. + */ \ No newline at end of file diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 36b383b4..a0484262 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -1916,6 +1916,9 @@ module VISU { /*! Gets information about imported MED file */ SALOME_MED::MedFileInfo GetMEDFileInfo(); + + /*! Export MED file from temp object. */ + boolean ExportMED(in string theFileName); }; //------------------------------------------------------- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 109c8242..202faadc 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -2505,6 +2505,10 @@ VisuGUI createAction( VISU_FILE_INFO, tr("MEN_FILE_INFO"), QIcon(), tr("MEN_FILE_INFO"), "", 0, aParent, false, this, SLOT(OnFileInfo())); + + createAction( VISU_EXPORT_MED, tr("MEN_EXPORT_MED"), QIcon(), + tr("MEN_EXPORT_MED"), "", 0, aParent, false, + this, SLOT(OnExportMED())); } void @@ -2689,6 +2693,7 @@ VisuGUI mgr->insert( action( VISU_MULTIPR_HIDE ), -1, -1, -1 ); mgr->insert( action( VISU_FILE_INFO ), -1, -1, -1 ); + mgr->insert( action( VISU_EXPORT_MED ), -1, -1, -1 ); // Rules @@ -2892,6 +2897,7 @@ VisuGUI } mgr->setRule( action( VISU_FILE_INFO ), "selcount=1 and type in {'VISU::TRESULT'}" ); + mgr->setRule( action( VISU_EXPORT_MED ), "selcount=1 and type in {'VISU::TRESULT'}" ); } //*************************************************************************** @@ -3913,3 +3919,43 @@ void VisuGUI::OnFileInfo() VisuGUI_FileInfoDlg dlg( getApp()->desktop(), aCResult->GetMEDFileInfo() ); dlg.exec(); } + +//--------------------------------------------------------------- +void VisuGUI::OnExportMED() +{ + SalomeApp_Study* aStudy = dynamic_cast( getApp()->activeStudy() ); + SUIT_DataOwnerPtrList lst; + getApp()->selectionMgr()->selected( lst ); + LightApp_DataOwner* owner = dynamic_cast( lst.first().get() ); + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry( aStudy, owner->entry().toLatin1().constData() ); + VISU::Result_i* aResult = dynamic_cast( anObjectInfo.myBase ); + if(!aResult) + return; + // VisuGUI_FileInfoDlg dlg( getApp()->desktop(), aResult->GetMEDFileInfo() ); + // dlg.exec(); + + SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); + QString aDir = aResourceMgr->stringValue("VISU","OutputDir",""); + + // get name for the file + QStringList aFilter; + aFilter.append("MED Files (*.med)"); + + std::string anInitFileName = aResult->GetInitFileName(); + QFileInfo anInitFileInfo(anInitFileName.c_str()); + QString aBaseName = anInitFileInfo.fileName(); + + QString aPath = Qtx::addSlash(aDir) + aBaseName; + + QFileInfo aFileInfo = + SUIT_FileDlg::getFileName(GetDesktop(this), + aPath, + aFilter, + tr("MEN_EXPORT_MED"), // "Export To Med File" + false); + + QString aFile = aFileInfo.filePath(); + if ( aFile.length() > 0 ) { + aResult->ExportMED((const char*)aFile.toLatin1()); + } +} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index f2d18169..2325ddc1 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -178,6 +178,7 @@ protected slots: void OnMultiprChangeRes(VISU::Result::Resolution theResolution); void OnFileInfo(); + void OnExportMED(); protected: virtual LightApp_Selection* createSelection() const; diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 5c1083fa..13cb18db 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -126,5 +126,6 @@ #define VISU_MULTIPR_HIDE 4098 #define VISU_FILE_INFO 4100 +#define VISU_EXPORT_MED 4101 #endif diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index a43015d9..4184edbc 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -1330,6 +1330,25 @@ VISU::Result_i Storable::DataToStream(theStr,"myIsBuildGroups", myIsGroupsDone); } +//--------------------------------------------------------------- + +bool +VISU::Result_i +::ExportMED(const char* theTargetFileName) +{ + static QString aCommand; + const char* aTempFileName = myFileInfo.absoluteFilePath().toLatin1(); + aCommand.sprintf(" %s %s", aTempFileName, theTargetFileName); + aCommand = QDir::convertSeparators( aCommand ); + aCommand.prepend( COPY_COMMAND ); + + if(system(aCommand.toLatin1().data()) != 0) { + if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<