]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
0016187: EDF PAL 460: To be able to export a MED file saved in a HDF study
authordmv <dmv@opencascade.com>
Tue, 5 Aug 2008 12:15:59 +0000 (12:15 +0000)
committerdmv <dmv@opencascade.com>
Tue, 5 Aug 2008 12:15:59 +0000 (12:15 +0000)
doc/salome/gui/VISU/images/exportmedfile.png [new file with mode: 0644]
doc/salome/gui/VISU/input/importing_med_objects.doc
idl/VISU_Gen.idl
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h
src/VISU_I/VISU_Result_i.cc
src/VISU_I/VISU_Result_i.hh

diff --git a/doc/salome/gui/VISU/images/exportmedfile.png b/doc/salome/gui/VISU/images/exportmedfile.png
new file mode 100644 (file)
index 0000000..c2fc56f
Binary files /dev/null and b/doc/salome/gui/VISU/images/exportmedfile.png differ
index e4f00bba51c0b58bf3b9591abc0bd9942ef2b0fc..e6a53c315efccd391067995dcc395ecf6c2ce553 100644 (file)
@@ -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.</li>
 </ul>
 \b Time - shows the <b>Elapsed time</b> spent by the application on processing.
 
+<em>To export a MED file:</em>
+\par
+Right-click on the top level of MED object in the Object Browser and select <b>Export to MED
+File</b> 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 <b>Save</b>.
+
 */
\ No newline at end of file
index 36b383b44d12a5a7ae49749a10b484e99ea12a83..a048426206acb656f5444619ff4f612eadae363b 100644 (file)
@@ -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);
   };
 
   //-------------------------------------------------------
index 109c82428c47bc60f67aecc63cb199d5dadade67..202faadc735a68f5e6928e7efa335ed4bf1e6ed8 100644 (file)
@@ -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<SalomeApp_Study*>( getApp()->activeStudy() );
+  SUIT_DataOwnerPtrList lst;
+  getApp()->selectionMgr()->selected( lst );
+  LightApp_DataOwner* owner = dynamic_cast<LightApp_DataOwner*>( lst.first().get() );
+  VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry( aStudy, owner->entry().toLatin1().constData() );
+  VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>( 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());
+  }
+}
index f2d18169fee17b90df6b5db9d4d8f675e40035e8..2325ddc12656345b7824a79546d35f5d1551b5da 100644 (file)
@@ -178,6 +178,7 @@ protected slots:
   void OnMultiprChangeRes(VISU::Result::Resolution theResolution);
 
   void OnFileInfo();
+  void OnExportMED();
 
 protected:
   virtual LightApp_Selection* createSelection() const;
index 5c1083fa61515ed7d93081d48f400e82f0add301..13cb18dbee1517def33ee114d6f373695ead1538 100644 (file)
 #define VISU_MULTIPR_HIDE           4098
 
 #define VISU_FILE_INFO              4100
+#define VISU_EXPORT_MED             4101
 
 #endif
index a43015d952f21effc7ec1cd0a3de7f52c07d21fc..4184edbc7f6653befecc67a7709c5936514f8872 100644 (file)
@@ -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 :"<<aCommand.toLatin1().data());
+    return false;
+  }
+  return true;
+}
+
 
 //---------------------------------------------------------------
 std::string
index 39469abab009113d815d5816f41851552cc50abc..e3b1f0607a79c53084cbf5d1b059a009f0a58218 100644 (file)
@@ -100,6 +100,10 @@ namespace VISU
     Build(CORBA::Boolean theIsBuildAll,
          CORBA::Boolean theIsAtOnce);
 
+    virtual
+    CORBA::Boolean
+    ExportMED(const char* theFileName);
+
     virtual
     CORBA::Boolean
     IsDone();