Salome HOME
PAL16760 - MED file information
authorasl <asl@opencascade.com>
Tue, 27 May 2008 10:27:58 +0000 (10:27 +0000)
committerasl <asl@opencascade.com>
Tue, 27 May 2008 10:27:58 +0000 (10:27 +0000)
idl/SMESH_Mesh.idl
src/SMESHGUI/Makefile.am
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_FileInfoDlg.h [new file with mode: 0644]
src/SMESHGUI/SMESHGUI_Selection.cxx
src/SMESHGUI/SMESHGUI_Selection.h
src/SMESHGUI/SMESH_msg_en.po
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx

index 27f89506dbd33dafc1bff23ba9ccd28d61154172..e821eca1888f4c9891d2157653405f980b01eae8 100644 (file)
@@ -630,6 +630,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
index e56d1e567fdb0126767f2eaa25f128bc480d276e..de6c6c9cca8bd4be0299539af4be1f93a2c8446e 100644 (file)
@@ -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)
@@ -179,6 +181,8 @@ libSMESH_la_CPPFLAGS = \
        $(BOOST_CPPFLAGS) \
        $(CORBA_CXXFLAGS) \
        $(CORBA_INCLUDES) \
+       $(MED2_INCLUDES) \
+       $(HDF5_INCLUDES) \
        -I$(srcdir)/../OBJECT \
        -I$(srcdir)/../SMESHFiltersSelection \
        -I$(srcdir)/../SMDS \
index d41fd1d59a6a30d8ebadfcc582a6953519954a51..6e946de8c9f6a195cbbcdfd366217a9390900c53 100644 (file)
@@ -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"
 
 #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
@@ -1302,6 +1303,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<SMESH::SMESH_Mesh>(anIObject);
+        if ( !aMesh->_is_nil() )
+        {
+          SMESHGUI_FileInfoDlg dlg( desktop(), aMesh->GetMEDFileInfo() );
+          dlg.exec();
+        }
+      }
+      break;
+    }
   case 122:                                    // EXPORT MED
   case 121:
   case 123:
@@ -2532,6 +2551,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" );
@@ -2864,6 +2884,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 (file)
index 0000000..921a0eb
--- /dev/null
@@ -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 <SMESHGUI_FileInfoDlg.h>
+
+#include <MED_Common.hxx>
+
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+
+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 (file)
index 0000000..7cf917d
--- /dev/null
@@ -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 <MED.hh>
+#include <QtxDialog.h>
+
+class SMESHGUI_FileInfoDlg : public QtxDialog
+{
+  Q_OBJECT
+
+public:
+  SMESHGUI_FileInfoDlg( QWidget*, SALOME_MED::MedFileInfo* );
+  virtual ~SMESHGUI_FileInfoDlg();
+};
+
+#endif
index 9791ebebd05431113d4a2061abd0dfc15390613c..7cbde8fb1d4c8ea1f9023d7b9cab727495fc7b02 100644 (file)
@@ -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;
+}
index 440c8d4bd81a8bfd76209935c9a3d4fbb9038b45..ad6912198bbc6b2d384d1c786236a546c9448605 100644 (file)
@@ -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<SMESH_Actor>  myActors;
index f4831978a2426b77d9ce626059af7836c9a44af0..e45227fc9ec3125a83d9f4b922670ee815e84b11 100644 (file)
@@ -3554,3 +3554,17 @@ 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"
index 1e1b391ac9a702051f04a7b398c7956e9dcbe1c0..e844e24aeee6baca5fc006e891fd400331dd2626 100644 (file)
@@ -258,6 +258,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);
@@ -2497,3 +2498,28 @@ SMESH::ListOfGroups* SMESH_Mesh_i::GetGroups(const list<int>& 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();
+}
index e06f88022f9e6bb63bf89c08bbba53910f241c4e..f149e0093ed774f377910f7f0d4920ddc9161a8f 100644 (file)
@@ -441,6 +441,10 @@ public:
    */
   SMESH::double_array* BaryCenter(CORBA::Long id);
 
+  /*!
+   * Returns information about imported MED file
+   */
+  virtual SALOME_MED::MedFileInfo* GetMEDFileInfo();
 
   map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
   map<int, ::SMESH_subMesh*> _mapSubMesh;   //NRI
@@ -455,6 +459,7 @@ private:
   map<int, SMESH::SMESH_subMesh_ptr>    _mapSubMeshIor;
   map<int, SMESH::SMESH_GroupBase_ptr>  _mapGroups;
   map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;
+  string myFile;
 };
 
 #endif