diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index b04164177..fd70cc9f5 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -625,6 +625,8 @@ module SMESH */ double_array BaryCenter(in long id); + /*! Gets information about imported MED file */ + SALOME_MED::MedFileInfo GetMEDFileInfo(); }; interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource diff --git a/src/SMESHGUI/Makefile.am b/src/SMESHGUI/Makefile.am index e56d1e567..2af4ca015 100644 --- a/src/SMESHGUI/Makefile.am +++ b/src/SMESHGUI/Makefile.am @@ -108,7 +108,8 @@ dist_libSMESH_la_SOURCES = \ SMESHGUI_BuildCompoundDlg.cxx \ SMESHGUI_ComputeDlg.cxx \ SMESHGUI_MakeNodeAtPointDlg.cxx \ - SMESHGUI_MeshEditPreview.cxx + SMESHGUI_MeshEditPreview.cxx \ + SMESHGUI_FileInfoDlg.cxx MOC_FILES = \ SMESHGUI_moc.cxx \ @@ -160,7 +161,8 @@ MOC_FILES = \ SMESHGUI_ConvToQuadOp_moc.cxx \ SMESHGUI_BuildCompoundDlg_moc.cxx \ SMESHGUI_ComputeDlg_moc.cxx \ - SMESHGUI_MakeNodeAtPointDlg_moc.cxx + SMESHGUI_MakeNodeAtPointDlg_moc.cxx \ + SMESHGUI_FileInfoDlg_moc.cxx nodist_libSMESH_la_SOURCES= \ $(MOC_FILES) diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 63ad64e37..ec738a1f1 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -68,6 +68,7 @@ #include "SMESHGUI_MakeNodeAtPointDlg.h" #include "SMESHGUI_BuildCompoundDlg.h" #include "SMESHGUI_ComputeDlg.h" +#include "SMESHGUI_FileInfoDlg.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_GEOMGenUtils.h" @@ -122,7 +123,7 @@ #include "SALOMEconfig.h" #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) -#include CORBA_SERVER_HEADER(SMESH_MeshEditor) +#include CORBA_CLIENT_HEADER(SMESH_MeshEditor) // QT Includes #define INCLUDE_MENUITEM_DEF @@ -1292,6 +1293,24 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) break; } + case 150: //MED FILE INFORMATION + { + SALOME_ListIO selected; + LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); + if( aSel ) + aSel->selectedObjects( selected ); + if( selected.Extent() ) + { + Handle(SALOME_InteractiveObject) anIObject = selected.First(); + SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(anIObject); + if ( !aMesh->_is_nil() ) + { + SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() ); + dlg.exec(); + } + } + break; + } case 122: // EXPORT MED case 121: case 123: @@ -2461,6 +2480,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createSMESHAction( 125, "EXPORT_MED" ); createSMESHAction( 126, "EXPORT_UNV" ); createSMESHAction( 141, "EXPORT_STL" ); + createSMESHAction( 150, "FILE_INFO" ); createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete ); createSMESHAction( 5105, "SEL_FILTER_LIB" ); createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" ); @@ -2790,6 +2810,8 @@ void SMESHGUI::initialize( CAM_Application* app ) // popup for object browser + createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION + createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH createPopupItem( 803, OB, group ); // EDIT_GROUP diff --git a/src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx b/src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx new file mode 100644 index 000000000..921a0eb97 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx @@ -0,0 +1,75 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 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 +// +// File : SMESHGUI_FileInfoDlg.cxx +// Author : Alexandre SOLOVYOV +// Module : SMESH +// $Header$ + +#include + +#include + +#include +#include +#include + +SMESHGUI_FileInfoDlg::SMESHGUI_FileInfoDlg( QWidget* parent, SALOME_MED::MedFileInfo* inf ) + : QtxDialog( parent, 0, true, false, QtxDialog::OK ) +{ + setCaption( tr( "CAPTION" ) ); + + QLineEdit* fname = new QLineEdit( mainFrame() ); + fname->setReadOnly( true ); + QLineEdit* fsize = new QLineEdit( mainFrame() ); + fsize->setReadOnly( true ); + QLineEdit* medversion = new QLineEdit( mainFrame() ); + medversion->setReadOnly( true ); + + QGridLayout* lay = new QGridLayout( mainFrame(), 4, 2, 5, 5 ); + lay->addWidget( new QLabel( tr( "FILE_NAME" ), mainFrame() ), 0, 0 ); + lay->addWidget( fname, 0, 1 ); + lay->addWidget( new QLabel( tr( "FILE_SIZE" ), mainFrame() ), 1, 0 ); + lay->addWidget( fsize, 1, 1 ); + lay->addWidget( new QLabel( tr( "MED_VERSION" ), mainFrame() ), 2, 0 ); + lay->addWidget( medversion, 2, 1 ); + + fname->setText( (char*)inf->fileName ); + fsize->setText( QString::number( inf->fileSize ) ); + + QString version; + if( inf->major>=0 ) + { + version = QString::number( inf->major ); + if( inf->minor>=0 ) + { + version += "." + QString::number( inf->minor ); + if( inf->release>=0 ) + version += "." + QString::number( inf->release ); + } + } + medversion->setText( version ); + setFixedSize( 640, 480 ); +} + +SMESHGUI_FileInfoDlg::~SMESHGUI_FileInfoDlg() +{ +} diff --git a/src/SMESHGUI/SMESHGUI_FileInfoDlg.h b/src/SMESHGUI/SMESHGUI_FileInfoDlg.h new file mode 100644 index 000000000..7cf917d65 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_FileInfoDlg.h @@ -0,0 +1,44 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 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 +// +// +// +// File : SMESHGUI_FileInfoDlg.h +// Author : Alexandre SOLOVYOV +// Module : SMESH +// $Header$ + +#ifndef SMESHGUI_FILE_INFO_DIALOG +#define SMESHGUI_FILE_INFO_DIALOG + +#include +#include + +class SMESHGUI_FileInfoDlg : public QtxDialog +{ + Q_OBJECT + +public: + SMESHGUI_FileInfoDlg( QWidget*, SALOME_MED::MedFileInfo* ); + virtual ~SMESHGUI_FileInfoDlg(); +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index 9791ebebd..7cbde8fb1 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -110,6 +110,8 @@ QtxValue SMESHGUI_Selection::param( const int ind, const QString& p ) const else if ( p=="displayMode" ) val = QtxValue( displayMode( ind ) ); else if ( p=="isComputable" ) val = QtxValue( isComputable( ind ) ); else if ( p=="hasReference" ) val = QtxValue( hasReference( ind ) ); + else if( p=="isImported" ) val = QtxValue( isImported( ind ) ); + // else if ( p=="isVisible" ) val = QtxValue( isVisible( ind ) ); // printf( "--> param() : [%s] = %s (%s)\n", p.latin1(), val.toString().latin1(), val.typeName() ); @@ -487,3 +489,20 @@ QString SMESHGUI_Selection::typeName( const int t ) return "Unknown"; } } + +bool SMESHGUI_Selection::isImported( const int ind ) const +{ + QString e = entry( ind ); + _PTR(SObject) SO = SMESH::GetActiveStudyDocument()->FindObjectID( e ); + bool res = false; + if( SO ) + { + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( SO ) ); + if( !aMesh->_is_nil() ) + { + SALOME_MED::MedFileInfo* inf = aMesh->GetMEDFileInfo(); + res = strlen( (char*)inf->fileName ) > 0; + } + } + return res; +} diff --git a/src/SMESHGUI/SMESHGUI_Selection.h b/src/SMESHGUI/SMESHGUI_Selection.h index 440c8d4bd..ad6912198 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.h +++ b/src/SMESHGUI/SMESHGUI_Selection.h @@ -69,6 +69,8 @@ public: static int type( const QString&, _PTR(Study) ); static QString typeName( const int type); + bool isImported( const int ) const; + private: QStringList myTypes; QPtrList myActors; diff --git a/src/SMESHGUI/SMESH_msg_en.po b/src/SMESHGUI/SMESH_msg_en.po index 3d6c79719..6d7b85633 100644 --- a/src/SMESHGUI/SMESH_msg_en.po +++ b/src/SMESHGUI/SMESH_msg_en.po @@ -3537,3 +3537,18 @@ msgstr "Error" #----------------------------------------------------------- + +msgid "MEN_FILE_INFO" +msgstr "MED file information" + +msgid "SMESHGUI_FileInfoDlg::CAPTION" +msgstr "File information" + +msgid "SMESHGUI_FileInfoDlg::FILE_NAME" +msgstr "File name" + +msgid "SMESHGUI_FileInfoDlg::FILE_SIZE" +msgstr "File size (bytes)" + +msgid "SMESHGUI_FileInfoDlg::MED_VERSION" +msgstr "MED version" diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 3de13f6f6..155c41e8a 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -240,6 +240,7 @@ SMESH_Mesh_i::ImportMEDFile( const char* theFileName, const char* theMeshName ) THROW_SALOME_CORBA_EXCEPTION("ImportMEDFile(): unknown exception", SALOME::BAD_PARAM); } + myFile = theFileName; CreateGroupServants(); return ConvertDriverMEDReadStatus(status); @@ -2479,3 +2480,28 @@ SMESH::ListOfGroups* SMESH_Mesh_i::GetGroups(const list& groupIDs) const aList->length( nbGroups ); return aList._retn(); } + +//============================================================================= +/*! + * \brief Return information about imported file + */ +//============================================================================= +SALOME_MED::MedFileInfo* SMESH_Mesh_i::GetMEDFileInfo() +{ + SALOME_MED::MedFileInfo_var res = new SALOME_MED::MedFileInfo(); + + const char* name = myFile.c_str(); + res->fileName = name; + res->fileSize = 0;//myFileInfo.size(); + int major, minor, release; + if( !MED::getMEDVersion( name, major, minor, release ) ) + { + major = -1; + minor = -1; + release = -1; + } + res->major = major; + res->minor = minor; + res->release = release; + return res._retn(); +} diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index d76ade836..58ca3edf9 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -436,6 +436,10 @@ public: */ SMESH::double_array* BaryCenter(CORBA::Long id); + /*! + * Returns information about imported MED file + */ + virtual SALOME_MED::MedFileInfo* GetMEDFileInfo(); map _mapSubMesh_i; //NRI map _mapSubMesh; //NRI @@ -450,6 +454,7 @@ private: map _mapSubMeshIor; map _mapGroups; map _mapHypo; + string myFile; }; #endif