Back to index

salome-med  6.5.0
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Slots
MedGUI Class Reference

#include <MEDGUI.h>

Collaboration diagram for MedGUI:
Collaboration graph
[legend]

List of all members.

Public Slots

virtual bool deactivateModule (SUIT_Study *)
virtual bool activateModule (SUIT_Study *)

Signals

void SignalCloseAllDialogs ()

Public Member Functions

 MedGUI ()
virtual void initialize (CAM_Application *)
virtual QString engineIOR () const
virtual void windows (QMap< int, int > &mappa) const
virtual bool OnGUIEvent (int theCommandID)
virtual bool OnKeyPress (QKeyEvent *pe, SUIT_ViewWindow *)
virtual bool OnMousePress (QMouseEvent *pe, SUIT_ViewWindow *)
virtual bool OnMouseMove (QMouseEvent *pe, SUIT_ViewWindow *)
void createMedAction (const int, const QString &, const QString &="")
SALOME_MED::MED_Gen_ptr InitMedGen () const
void EmitSignalCloseAllDialogs ()

Static Public Member Functions

static bool DumpMesh (SALOME_MED::MESH_var aMesh)
static bool DumpSubMesh (SALOME_MED::FAMILY_var Fam)
static void setOrb ()

Protected Attributes

MEDGUIDataBaseDockWidget_data_base

Private Slots

void onGUIEvent ()
void onWindowActivated (SUIT_ViewWindow *)

Detailed Description

Definition at line 39 of file MEDGUI.h.


Constructor & Destructor Documentation

Definition at line 72 of file MEDGUI.cxx.

               : LightApp_Module( "MED" ),SalomeApp_Module( "MED" )
{
}

Member Function Documentation

bool MedGUI::activateModule ( SUIT_Study *  study) [virtual, slot]

Definition at line 216 of file MEDGUI.cxx.

{
  bool res = SalomeApp_Module::activateModule( study );

  setMenuShown( true );
  setToolShown( true );

  _data_base->setVisible( true );
  _data_base->toggleViewAction()->setVisible( true );

  connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
          this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
  return res;
}

Here is the call graph for this function:

void MedGUI::createMedAction ( const int  id,
const QString &  po_id,
const QString &  icon_id = "" 
)

Definition at line 76 of file MEDGUI.cxx.

{
  QWidget* parent = application()->desktop();
  SUIT_ResourceMgr* mgr = application()->resourceMgr();

  QPixmap pix;
  QIcon icon;
  if( !icon_id.isEmpty() )
    pix = mgr->loadPixmap( "MED", tr( (const char*)icon_id.toLatin1() ) );
//   else
//     pix = mgr->loadPixmap( "MED", tr( QString( "ICO_" )+po_id ) );

  if ( !pix.isNull() )
    icon = QIcon( pix );

  createAction( id,
                tr( (const char*)("TOP_" + po_id).toLatin1() ),
                icon,
                tr( (const char*)("MEN_" + po_id).toLatin1() ),
                tr( (const char*)("STB_" + po_id).toLatin1() ),
                0,
                parent,
                false,
                this,
                SLOT( onGUIEvent() ) );

  if ( action( id ) )
    action( id )->setObjectName( QString( "Action %1" ).arg( id ) );
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool MedGUI::deactivateModule ( SUIT_Study *  study) [virtual, slot]

Definition at line 195 of file MEDGUI.cxx.

{
  setMenuShown( false );
  setToolShown( false );

  _data_base->setVisible( false );
  _data_base->toggleViewAction()->setVisible( false );

  disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
             this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );

  EmitSignalCloseAllDialogs();

  return SalomeApp_Module::deactivateModule( study );
}

Here is the call graph for this function:

bool MedGUI::DumpMesh ( SALOME_MED::MESH_var  aMesh) [static]

Definition at line 537 of file MEDGUI.cxx.

{

  if ( MEDMesh->_is_nil() )
    {
      return false;
    }

  std::string name = MEDMesh->getName();
  SCRUTE(name);

  int dim2 = MEDMesh->getSpaceDimension();
  SCRUTE(dim2);

  int k = MEDMesh->getNumberOfNodes() ;
  SCRUTE(k);
  SALOME_TYPES::ListOfDouble_var coords = MEDMesh->getCoordinates( SALOME_MED::MED_FULL_INTERLACE );
  int i = 0;
  int lu = 0;
  while (lu < k ) {
    if (dim2==3)
      {
        MESSAGE ( " Coordinates  X = " << coords[i] << " Y = " << coords[i+1] << " Z = " << coords[i+2] );
        i = i + 3;
      }
    else
      {
        MESSAGE ( " Coordinates  X = " << coords[i] << " Y = " << coords[i+1] );
        i = i + 2;
      }
    lu=lu+1;
  }

  int nbfam=MEDMesh->getNumberOfFamilies(SALOME_MED::MED_NODE);
  SCRUTE(nbfam);
  SALOME_MED::Family_array_var Families=MEDMesh->getFamilies(SALOME_MED::MED_NODE) ;

  for (k=0;  k < nbfam; k++) {
    SCRUTE(k);
    std::string nomFam=Families[k]->getName();
    SCRUTE(nomFam);
    SALOME_TYPES::ListOfLong_var tabnoeuds=Families[k]->getNumber(SALOME_MED::MED_NONE);
    for (int l=0;l<(int)tabnoeuds->length();l++)
      SCRUTE(tabnoeuds[l]);
  }

  return true;
}

Here is the caller graph for this function:

bool MedGUI::DumpSubMesh ( SALOME_MED::FAMILY_var  Fam) [static]

Definition at line 591 of file MEDGUI.cxx.

{

  if ( Fam->_is_nil() )
    return false;

  SALOME_TYPES::ListOfLong_var tabnoeuds=Fam->getNumber(SALOME_MED::MED_NONE);
  for (int l=0;l<(int)tabnoeuds->length();l++)
    SCRUTE(tabnoeuds[l]);

  return true;
}

Definition at line 185 of file MEDGUI.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

QString MedGUI::engineIOR ( ) const [virtual]

Definition at line 144 of file MEDGUI.cxx.

{
  QString anIOR( "" );
  SALOME_MED::MED_Gen_ptr aMedGen = InitMedGen();
  if ( !CORBA::is_nil( aMedGen) )
  {
    CORBA::String_var objStr = getApp()->orb()->object_to_string( aMedGen );
    anIOR = QString( objStr.in() );
  }
  return anIOR;
}

Here is the call graph for this function:

void MedGUI::initialize ( CAM_Application *  app) [virtual]

Definition at line 111 of file MEDGUI.cxx.

{
  SalomeApp_Module::initialize( app );

  //QWidget* parent = application()->desktop();

  createMedAction( 931, "MESHSEL", "ICO_TB_MESHSEL" );
  createMedAction( 932, "FIELDSEL", "ICO_TB_FIELDSEL" );
  createMedAction( 934, "DUMPMESH" );
  createMedAction( 935, "DUMPSUBMESH" );
  createMedAction( 936, "EXPLORE", "ICO_TB_EXPLORE");

  createMedAction( 4031, "MESHSEL", "ICO_TB_MESHSEL" );
  createMedAction( 4032, "FIELDSEL", "ICO_TB_FIELDSEL" );
  createMedAction( 4034, "EXPLORE", "ICO_TB_EXPLORE");

  int MedId = createMenu( tr( "MED" ), -1, 50, 10 );
  createMenu( separator(), MedId, 10 );
  createMenu( 931, MedId, 11 );
  createMenu( 932, MedId, 11 );
  createMenu( 934, MedId, 11 );
  createMenu( 935, MedId, 11 );
  createMenu( 936, MedId, 11 );

  int medTb = createTool( tr( "TB_MED" ) );
  createTool( 4031, medTb );
  createTool( 4032, medTb );
  createTool( 4034, medTb );

  _data_base = new MEDGUIDataBaseDockWidget(application(),application()->desktop());
  application()->desktop()->addDockWidget(Qt::LeftDockWidgetArea,_data_base);
}

Here is the call graph for this function:

SALOME_MED::MED_Gen_ptr MedGUI::InitMedGen ( ) const

Definition at line 609 of file MEDGUI.cxx.

{
  SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
  Engines::EngineComponent_var comp =
    SALOME_LifeCycleCORBA(app->namingService()).FindOrLoad_Component( "FactoryServer", "MED" );

  MESSAGE("_________________________________________");
  SALOME_MED::MED_Gen_var clr = SALOME_MED::MED_Gen::_narrow(comp);
  ASSERT(!CORBA::is_nil(clr));
  return clr._retn();
}

Here is the caller graph for this function:

bool MedGUI::OnGUIEvent ( int  theCommandID) [virtual]

Definition at line 245 of file MEDGUI.cxx.

{
  setOrb();

  SalomeApp_Study* myActiveStudy = dynamic_cast< SalomeApp_Study* >( application()->activeStudy() );
  if( !myActiveStudy )
    return false;

  _PTR(Study) aStudy = myActiveStudy->studyDS();
  //SALOME_NamingService* myNameService = parent->getNameService();

  QString file;
  QStringList filtersList ;

  filtersList.append( tr("MED_MEN_IMPORT_MED") );
  filtersList.append( tr("MED_MEN_ALL_FILES") ) ;

  SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
  if( !app )
    return false;

  switch (theCommandID)
    {
    case 4031:
    case 9031:
    case 931:
      {
        MESSAGE("command " << theCommandID << " activated");

        QString myStudyName = myActiveStudy->studyName();
        bool ok=FALSE;
//      int myStudyId = myActiveStudy->id();

        // load MED engine
        SALOME_MED::MED_Gen_ptr medgen = InitMedGen();

        // Selection du Fichier
        file = SUIT_FileDlg::getFileName(application()->desktop(),
                                        "",
                                        filtersList,
                                        tr("MED_MEN_IMPORT"),
                                        true);

        // Selection du Maillage
        if (!file.isEmpty() )
          {
            SCRUTE((const char*)file.toLatin1());
            QString meshName;
            meshName = QInputDialog::getText( application()->desktop(),
                                              tr("MED_INF_MESHNAME"),
                                              QString::null,
                                              QLineEdit::Normal,
                                              QString::null,
                                              &ok );
            if ( ok && !meshName.isEmpty() )
              {
                  try
                    {
                      medgen->readMeshInFile( (const char*)file.toLatin1(),
                                              (const char*)myStudyName.toLatin1(),
                                              (const char*)meshName.toLatin1() );
                      if (myActiveStudy->studyDS()->GetProperties()->IsLocked()) {
                        SUIT_MessageBox::warning ( application()->desktop(),
                                                   tr("WRN_WARNING"),
                                                   tr("WRN_STUDY_LOCKED") );
                        //QObject::tr("BUT_OK")); by default
                      }
                    }
                  catch (const SALOME::SALOME_Exception & S_ex)
                    {
                      SalomeApp_Tools::QtCatchCorbaException(S_ex);
                    }
                }
                updateObjBrowser();
          }
        break;
      }
    case 4032:
    case 9032:
    case 932:
      {
        MESSAGE("command " << theCommandID << " activated");

        QString myStudyName = myActiveStudy->studyName();
        bool ok=FALSE;
//      int myStudyId = myActiveStudy->id();

        // load MED engine
        SALOME_MED::MED_Gen_ptr medgen = InitMedGen();

        // Selection du Fichier
        QString anInitialPath = "";
        if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
          anInitialPath = QDir::currentPath();

        file = SUIT_FileDlg::getFileName(application()->desktop(),
                                        anInitialPath,
                                        filtersList,
                                        tr("MED_MEN_IMPORT"),
                                        true);

        // Selection du Maillage
        if (!file.isEmpty() )
          {
            SCRUTE((const char*)file.toLatin1());
            QString fieldName;
            fieldName = QInputDialog::getText( application()->desktop(),
                                               tr("MED_INF_FIELDNAME"),
                                               QString::null,
                                               QLineEdit::Normal,
                                               QString::null,
                                               &ok );
            if ( ok && !fieldName.isEmpty())
              {
                try
                  {
                    medgen->readFieldInFile( (const char*)file.toLatin1(),
                                             (const char*)myStudyName.toLatin1(),
                                             (const char*)fieldName.toLatin1(),
                                             -1,
                                             -1 );
                    if (myActiveStudy->studyDS()->GetProperties()->IsLocked()) {
                      SUIT_MessageBox::warning ( application()->desktop(),
                                                 tr("WRN_WARNING"),
                                                 tr("WRN_STUDY_LOCKED") );
                      //tr("BUT_OK")); by default
                    }
                  }
                catch (const SALOME::SALOME_Exception & S_ex)
                  {
                    SalomeApp_Tools::QtCatchCorbaException(S_ex);
                  }
                updateObjBrowser ();
              }
          }
        break;
      }
    case 934:
      {
        //Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter( MESH );

        SALOME_ListIO list;
        SalomeApp_Application* app = getApp();
        LightApp_SelectionMgr* mgr = app ? app->selectionMgr() : NULL;
        if( mgr )
          mgr->selectedObjects( list );
        //Sel->AddFilter(aMeshFilter) ;

        int nbSel = list.Extent();
        if ( nbSel == 1 )
          {
            //      SMESH::SMESH_Mesh_var aM;
            SALOME_MED::MESH_var aMesh;
            Handle(SALOME_InteractiveObject) IObject = list.First();
            if ( IObject->hasEntry() )
              {
                _PTR(SObject) aMorSM = aStudy->FindObjectID( IObject->getEntry() );
                if ( aMorSM )
                  {
                    _PTR(GenericAttribute) anAttr;
                    _PTR(AttributeIOR)     anIOR;
                    if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
                      {
                        anIOR = anAttr;
                        aMesh = SALOME_MED::MESH::_narrow( _orb->string_to_object(anIOR->Value().c_str()) );
                        if ( aMesh->_is_nil() )
                        {
                          SUIT_MessageBox::warning
                            ( application()->desktop(),
                              tr ("MED_WRN_WARNING"),
                              tr ("MED_INF_NOTIMPL") );
                          break;
                        }
                        DumpMesh( aMesh );
                        //Sel->ClearFilters() ;
                      }
                    else
                      {
                        SUIT_MessageBox::warning
                          ( application()->desktop(),
                            tr ("MED_WRN_WARNING"),
                            tr ("MED_INF_NOIOR") );
                        //tr ("MED_BUT_OK") ); by default
                        break;
                      }
                  }
              }
          }
        break;
      }

    case 935:
      {
        //Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter( SUBMESH );

        SALOME_ListIO list;
        SalomeApp_Application* app = getApp();
        LightApp_SelectionMgr* mgr = app ? app->selectionMgr() : NULL;
        if( mgr )
          mgr->selectedObjects( list );

        //Sel->AddFilter(aSubMeshFilter) ;

        int nbSel = list.Extent();
        if ( nbSel == 1 )
          {
            //      SMESH::SMESH_subMesh_var aSubM;
            SALOME_MED::FAMILY_var aFam;
            Handle(SALOME_InteractiveObject) IObject = list.First();
            if ( IObject->hasEntry() )
              {
                _PTR(SObject) aMorSM = aStudy->FindObjectID( IObject->getEntry() );
                if ( aMorSM )
                  {
                    _PTR(GenericAttribute) anAttr;
                    _PTR(AttributeIOR)     anIOR;
                    if (aMorSM->FindAttribute(anAttr, "AttributeIOR"))
                      {
                        anIOR = anAttr;
                      }
                    else
                      {
                        SUIT_MessageBox::warning
                          ( application()->desktop(),
                            tr ("MED_WRN_WARNING"),
                            tr ("MED_INFNOIOR") );
                        //  tr ("MED_BUT_OK") ); by default
                        break;
                      }
                  }
              }
          }
        break;
      }
      case 936 :
      case 4034 :
        {
          
          MEDGUIFileContentDial* mfcd = new MEDGUIFileContentDial(_data_base, application()->desktop());
          mfcd->show();
          break;
        }
    }

  app->updateActions(); //SRN: To update a Save button in the toolbar

  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MedGUI::onGUIEvent ( ) [private, slot]

Definition at line 170 of file MEDGUI.cxx.

{
  const QtxAction* obj = qobject_cast<const QtxAction*>(sender());
  if ( !obj )
    return;
  int id = actionId( obj );
  if ( id != -1 )
    OnGUIEvent( id );
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool MedGUI::OnKeyPress ( QKeyEvent *  pe,
SUIT_ViewWindow *  wnd 
) [virtual]

Definition at line 524 of file MEDGUI.cxx.

{
  MESSAGE("MedGUI::OnKeyPress");

  return true;
}
bool MedGUI::OnMouseMove ( QMouseEvent *  pe,
SUIT_ViewWindow *  wnd 
) [virtual]

Definition at line 512 of file MEDGUI.cxx.

{
  //   MESSAGE("MedGUI::OnMouseMouve");
  return true;
}
bool MedGUI::OnMousePress ( QMouseEvent *  pe,
SUIT_ViewWindow *  wnd 
) [virtual]

Definition at line 500 of file MEDGUI.cxx.

{
  MESSAGE("MedGUI::OnMousePress");
  return true;
}
void MedGUI::onWindowActivated ( SUIT_ViewWindow *  ) [private, slot]

Definition at line 236 of file MEDGUI.cxx.

{
}

Here is the caller graph for this function:

void MedGUI::setOrb ( ) [static]

Definition at line 626 of file MEDGUI.cxx.

{
  try {
    ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
    ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
    _orb = init( 0 , 0 );
  } catch (...) {
    INFOS("internal error : orb not found");
    _orb = 0;
  }
  ASSERT(! CORBA::is_nil(_orb));
}

Here is the caller graph for this function:

void MedGUI::SignalCloseAllDialogs ( ) [signal]

Here is the caller graph for this function:

void MedGUI::windows ( QMap< int, int > &  mappa) const [virtual]

Definition at line 156 of file MEDGUI.cxx.

{
  mappa.clear();
  mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
  mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
}

Member Data Documentation

Definition at line 82 of file MEDGUI.h.


The documentation for this class was generated from the following files: