-// Copyright (C) 2011-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2011-2022 CEA/DEN, EDF R&D
//
// 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.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <qfiledialog.h>
#include <qstring.h>
#include <stdlib.h>
+#ifndef WIN32
#include <unistd.h>
+#endif
#include <sys/stat.h>
#include "SalomeApp_Tools.h"
using namespace std;
-extern "C"
-{
-#include <med.h>
-}
+#include <med.h>
// ============================================================================
QString HOMARD_QT_COMMUN::SelectionArbreEtude(QString commentaire, int option )
// . si le commentaire est une chaine vide, on ne tient pas compte du type de l'objet
// et on retourne le nom de cet objet
// . sinon :
-// . si l'objet est du type defini par commentaitr, retourne le nom de cet objet
+// . si l'objet est du type defini par commentaire, retourne le nom de cet objet
// . sinon on retourne une QString("")
// option :
// . Si option = 0, ce n'est pas grave de ne rien trouver ; aucun message n'est emis
// . Si option = 1, ce n'est pas grave de ne rien trouver mais on emet un message
{
- MESSAGE("SelectionArbreEtude : commentaire = " << commentaire.toStdString().c_str() << " et option = " << option);
+// MESSAGE("SelectionArbreEtude : commentaire = " << commentaire.toStdString().c_str() << " et option = " << option);
int nbSel = HOMARD_UTILS::IObjectCount() ;
if ( nbSel == 0 )
{
Handle(SALOME_InteractiveObject) aIO = HOMARD_UTILS::firstIObject();
if ( aIO->hasEntry() )
{
- _PTR(Study) aStudy = HOMARD_UTILS::GetActiveStudyDocument();
+// MESSAGE("aIO->getEntry() = " << aIO->getEntry());
+ _PTR(Study) aStudy = HOMARD_UTILS::getStudy();
_PTR(SObject) aSO ( aStudy->FindObjectID( aIO->getEntry() ) );
_PTR(GenericAttribute) anAttr;
if (aSO->FindAttribute(anAttr, "AttributeComment") )
{
_PTR(AttributeComment) attributComment = anAttr;
QString aComment= QString(attributComment->Value().data());
- MESSAGE("... aComment = " << aComment.toStdString().c_str());
+// MESSAGE("... aComment = " << aComment.toStdString().c_str());
int iaux = aComment.lastIndexOf(commentaire);
- MESSAGE("... iaux = " << iaux);
+// MESSAGE("... iaux = " << iaux);
if ( iaux !=0 )
{
QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
Handle(SALOME_InteractiveObject) aIO = HOMARD_UTILS::firstIObject();
if ( aIO->hasEntry() )
{
- _PTR(Study) aStudy = HOMARD_UTILS::GetActiveStudyDocument();
+ _PTR(Study) aStudy = HOMARD_UTILS::getStudy();
_PTR(SObject) aSO ( aStudy->FindObjectID( aIO->getEntry() ) );
_PTR(SObject) aSObjCas = aSO->GetFather();
_PTR(GenericAttribute) anAttr;
}
// =======================================================================
-QString HOMARD_QT_COMMUN::PushNomFichier(bool avertir)
+QString HOMARD_QT_COMMUN::PushNomFichier(bool avertir, QString TypeFichier)
// =======================================================================
// Gestion les boutons qui permettent de
// 1) retourne le nom d'un fichier par une fenetre de dialogue si aucun
// 2) retourne le nom du fichier asocie a l objet
// selectionne dans l arbre d etude
{
- MESSAGE("PushNomFichier");
- QString aFile=QString::null;
+// MESSAGE("PushNomFichier avec avertir "<<avertir<<" et TypeFichier = "<<TypeFichier.toStdString().c_str());
+ QString aFile = QString::null;
+//
+ // A. Filtre
+ QString filtre ;
+//
+ if ( TypeFichier == "med" ) { filtre = QString("Med") ; }
+ else if ( TypeFichier == "py" ) { filtre = QString("Python") ; }
+ else { filtre = TypeFichier ; }
+//
+ if ( TypeFichier != "" ) { filtre += QString(" files (*.") + TypeFichier + QString(");;") ; }
+//
+ filtre += QString("all (*) ") ;
+//
+ // B. Selection
int nbSel = HOMARD_UTILS::IObjectCount() ;
+// MESSAGE("nbSel ="<<nbSel);
+ // B.1. Rien n'est selectionne
if ( nbSel == 0 )
{
- aFile = QFileDialog::getOpenFileName(0,QString("File Selection"),QString("") ,QString("Med files (*.med);;all (*) ") );
+// aFile = QFileDialog::getOpenFileName(0, QObject::tr("HOM_SELECT_FILE_0"), QString(""), QString("Med files (*.med);;all (*) ") );
+ aFile = QFileDialog::getOpenFileName(0, QObject::tr("HOM_SELECT_FILE_0"), QString(""), filtre );
}
- if (nbSel > 1)
- {
- QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
- QObject::tr("HOM_SELECT_FILE_2") );
- }
- if (nbSel == 1)
+ // B.2. Un objet est selectionne
+ else if (nbSel == 1)
{
Handle(SALOME_InteractiveObject) aIO = HOMARD_UTILS::firstIObject();
if ( aIO->hasEntry() )
{
- _PTR(Study) aStudy = HOMARD_UTILS::GetActiveStudyDocument();
+ _PTR(Study) aStudy = HOMARD_UTILS::getStudy();
_PTR(SObject) aSO ( aStudy->FindObjectID( aIO->getEntry() ) );
_PTR(GenericAttribute) anAttr;
_PTR(AttributeFileType) aFileType;
{
if ( avertir ) {
QMessageBox::warning( 0, QObject::tr("HOM_WARNING"),
- QObject::tr("HOM_SELECT_STUDY") );
- }
- aFile = QFileDialog::getOpenFileName();
- if (!aFile.isEmpty())
- {
- aFile=aFile;
+ QObject::tr("HOM_SELECT_STUDY") );
}
+ aFile = QFileDialog::getOpenFileName(0, QObject::tr("HOM_SELECT_FILE_0"), QString(""), filtre );
}
}
- return aFile;
+ // B.3. Bizarre
+ else
+ {
+ QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
+ QObject::tr("HOM_SELECT_FILE_2") );
+ }
+ return aFile;
}
// =======================================================================
-int HOMARD_QT_COMMUN::OuvrirFichier(QString aFile)
+med_idt HOMARD_QT_COMMUN::OuvrirFichier(QString aFile)
// =======================================================================
// renvoie le medId associe au fichier Med apres ouverture
{
- med_int medIdt = MEDfileOpen(aFile.toStdString().c_str(),MED_ACC_RDONLY);
+ med_idt medIdt = MEDfileOpen(aFile.toStdString().c_str(),MED_ACC_RDONLY);
if (medIdt <0)
{
QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
QObject::tr("HOM_MED_FILE_1") );
}
- return (int) medIdt;
+ return medIdt;
}
// ======================================================
{
QString nomMaillage = "" ;
int erreur = 0 ;
- med_int medIdt ;
+ med_idt medIdt ;
while ( erreur == 0 )
{
// Ouverture du fichier
break ;
}
- nomMaillage = HOMARD_QT_COMMUN::LireNomMaillage(medIdt,1);
+ nomMaillage = HOMARD_QT_COMMUN::LireNomMaillage2(medIdt,1);
break ;
}
// Fermeture du fichier
return nomMaillage;
}
// =======================================================================
-QString HOMARD_QT_COMMUN::LireNomMaillage(int medIdt ,int meshId)
+QString HOMARD_QT_COMMUN::LireNomMaillage2(med_idt medIdt ,int meshId)
// =======================================================================
{
QString NomMaillage=QString::null;
std::list<QString> ListeChamp ;
med_err erreur = 0 ;
- med_int medIdt ;
+ med_idt medIdt ;
while ( erreur == 0 )
{
std::list<QString> ListeComposants;
med_err erreur = 0 ;
- med_int medIdt ;
+ med_idt medIdt ;
while ( erreur == 0 )
{