Merge remote-tracking branch 'origin/master'

This commit is contained in:
Paul RASCLE 2018-07-19 09:14:10 +02:00
commit 3785fda32c
5 changed files with 119 additions and 13 deletions

View File

@ -39,6 +39,7 @@ SMESHGUI_FileInfoDlg::SMESHGUI_FileInfoDlg( QWidget* parent, SMESH::MedFileInfo*
fsize->setReadOnly( true );
QLineEdit* medversion = new QLineEdit( mainFrame() );
medversion->setReadOnly( true );
QLabel* medversionlabel = new QLabel( tr( "MED_VERSION" ), mainFrame() );
fname->setMinimumWidth( 300 );
QGridLayout* lay = new QGridLayout( mainFrame() );
@ -47,13 +48,15 @@ SMESHGUI_FileInfoDlg::SMESHGUI_FileInfoDlg( QWidget* parent, SMESH::MedFileInfo*
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( medversionlabel, 2, 0 );
lay->addWidget( medversion, 2, 1 );
fname->setText( (char*)inf->fileName );
fname->home( false );
fsize->setText( QString::number( inf->fileSize ) );
if ( fname->text().endsWith("med"))
{
QString version;
if( inf->major>=0 )
{
@ -66,6 +69,12 @@ SMESHGUI_FileInfoDlg::SMESHGUI_FileInfoDlg( QWidget* parent, SMESH::MedFileInfo*
}
}
medversion->setText( version );
}
else
{
medversionlabel->hide();
medversion->hide();
}
}
SMESHGUI_FileInfoDlg::~SMESHGUI_FileInfoDlg()

View File

@ -4325,7 +4325,7 @@ Use Display Entity menu command to show them.
</message>
<message>
<source>MEN_FILE_INFO</source>
<translation>MED File Information</translation>
<translation>File Information</translation>
</message>
<message>
<source>SMESH_WRN_NO_APPROPRIATE_SELECTION</source>

View File

@ -3089,7 +3089,6 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
myMesh->Load(); // load from study file if not yet done
TPythonDump pd; // not to dump GetGroups()
SMESH::ListOfGroups_var groups = myMesh->GetGroups();
pd << ""; // to avoid optimizing pd out
for ( CORBA::ULong i = 0; i < groups->length(); ++i )
{
SMESH_GroupBase_i* grImpl = SMESH::DownCast<SMESH_GroupBase_i*>( groups[i]);
@ -3343,6 +3342,17 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
}
}
// Store file info
std::string info = myImpl->FileInfoToString();
if ( !info.empty() )
{
aSize[ 0 ] = info.size();
aDataset = new HDFdataset( "file info", aTopGroup, HDF_STRING, aSize, 1 );
aDataset->CreateOnDisk();
aDataset->WriteOnDisk( (char*) info.data() );
aDataset->CloseOnDisk();
}
// write applied hypotheses if exist
SALOMEDS::SObject_wrap myHypBranch;
found = gotBranch->FindSubObject( GetRefOnAppliedHypothesisTag(), myHypBranch.inout() );
@ -4367,6 +4377,18 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
myNewMeshImpl->GetImpl().GetMeshDS()->SetPersistentId( *meshPersistentId );
delete [] meshPersistentId;
}
// Restore file info
if ( aTopGroup->ExistInternalObject( "file info" ))
{
aDataset = new HDFdataset( "file info", aTopGroup );
aDataset->OpenOnDisk();
size = aDataset->GetSize();
std::string info( size, ' ');
aDataset->ReadFromDisk( (char*) info.data() );
aDataset->CloseOnDisk();
myNewMeshImpl->FileInfoFromString( info );
}
}
}
} // reading MESHes

View File

@ -445,6 +445,13 @@ SMESH::DriverMED_ReadStatus SMESH_Mesh_i::ImportCGNSFile( const char* theFileNa
CreateGroupServants();
_medFileInfo = new SMESH::MedFileInfo();
_medFileInfo->fileName = theFileName;
_medFileInfo->major = 0;
_medFileInfo->minor = 0;
_medFileInfo->release = 0;
_medFileInfo->fileSize = SMESH_File( theFileName ).size();
return ConvertDriverMEDReadStatus(status);
}
@ -479,6 +486,13 @@ int SMESH_Mesh_i::ImportUNVFile( const char* theFileName )
CreateGroupServants();
_medFileInfo = new SMESH::MedFileInfo();
_medFileInfo->fileName = theFileName;
_medFileInfo->major = 0;
_medFileInfo->minor = 0;
_medFileInfo->release = 0;
_medFileInfo->fileSize = SMESH_File( theFileName ).size();
SMESH_CATCH( SMESH::throwCorbaException );
return 1;
@ -503,6 +517,12 @@ int SMESH_Mesh_i::ImportSTLFile( const char* theFileName )
SALOMEDS::SObject_wrap meshSO = _gen_i->ObjectToSObject( _this() );
_gen_i->SetName( meshSO, name.c_str() );
}
_medFileInfo = new SMESH::MedFileInfo();
_medFileInfo->fileName = theFileName;
_medFileInfo->major = 0;
_medFileInfo->minor = 0;
_medFileInfo->release = 0;
_medFileInfo->fileSize = SMESH_File( theFileName ).size();
SMESH_CATCH( SMESH::throwCorbaException );
@ -541,6 +561,13 @@ SMESH::ComputeError* SMESH_Mesh_i::ImportGMFFile( const char* theFileName,
error = _impl->GMFToMesh( theFileName, theMakeRequiredGroups );
_medFileInfo = new SMESH::MedFileInfo();
_medFileInfo->fileName = theFileName;
_medFileInfo->major = 0;
_medFileInfo->minor = 0;
_medFileInfo->release = 0;
_medFileInfo->fileSize = SMESH_File( theFileName ).size();
SMESH_CATCH( exceptionToComputeError );
#undef SMESH_CAUGHT
#define SMESH_CAUGHT
@ -5073,6 +5100,48 @@ SMESH::MedFileInfo* SMESH_Mesh_i::GetMEDFileInfo()
return res._retn();
}
//=======================================================================
//function : FileInfoToString
//purpose : Persistence of file info
//=======================================================================
std::string SMESH_Mesh_i::FileInfoToString()
{
std::string s;
if ( &_medFileInfo.in() && _medFileInfo->fileName[0] )
{
s = SMESH_Comment( _medFileInfo->fileSize )
<< " " << _medFileInfo->major
<< " " << _medFileInfo->minor
<< " " << _medFileInfo->release
<< " " << _medFileInfo->fileName;
}
return s;
}
//=======================================================================
//function : FileInfoFromString
//purpose : Persistence of file info
//=======================================================================
void SMESH_Mesh_i::FileInfoFromString(const std::string& info)
{
std::string size, major, minor, release, fileName;
std::istringstream is(info);
is >> size >> major >> minor >> release;
fileName = info.data() + ( size.size() + 1 +
major.size() + 1 +
minor.size() + 1 +
release.size()+ 1 );
_medFileInfo = new SMESH::MedFileInfo();
_medFileInfo->fileName = fileName.c_str();
_medFileInfo->fileSize = atoi( size.c_str() );
_medFileInfo->major = atoi( major.c_str() );
_medFileInfo->minor = atoi( minor.c_str() );
_medFileInfo->release = atoi( release.c_str() );
}
//=============================================================================
/*!
* \brief Pass names of mesh groups from study to mesh DS

View File

@ -600,6 +600,12 @@ public:
*/
virtual SMESH::MedFileInfo* GetMEDFileInfo();
/*!
* Persistence of file info
*/
std::string FileInfoToString();
void FileInfoFromString(const std::string& info);
/*!
* Sets list of notebook variables used for Mesh operations separated by ":" symbol
*/