/*!
-\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.
</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
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
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
}
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'}" );
}
//***************************************************************************
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());
+ }
+}
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