1 // Copyright (C) 2011-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : HOMARDGUI.cxx
21 // Author : Paul RASCLE, EDF
24 #include "HOMARDGUI.h"
27 #include "Utils_ORB_INIT.hxx"
28 #include "Utils_SINGLETON.hxx"
29 #include "SALOME_LifeCycleCORBA.hxx"
31 #include "SUIT_ResourceMgr.h"
32 #include "SUIT_MessageBox.h"
33 #include "SUIT_Session.h"
34 #include "SUIT_ViewWindow.h"
35 #include "SUIT_ViewManager.h"
36 #include <SUIT_Desktop.h>
38 #include "CAM_Module.h"
39 #include "OB_Browser.h"
41 #include "SALOME_ListIO.hxx"
42 #include "SALOME_ListIteratorOfListIO.hxx"
44 #include "SalomeApp_Application.h"
45 #include "SalomeApp_DataModel.h"
46 #include "SalomeApp_Study.h"
47 #include "LightApp_SelectionMgr.h"
48 #include "LightApp_Selection.h"
49 #include <LightApp_Preferences.h>
50 #include "SalomeApp_Module.h"
51 #include "SALOMEconfig.h"
52 #include <SALOME_LifeCycleCORBA.hxx>
54 #include <utilities.h>
59 #include "MonCreateCase.h"
60 #include "MonCreateIteration.h"
61 #include "MonPursueIteration.h"
62 #include "MonCreateYACS.h"
63 #include "MonEditBoundaryAn.h"
64 #include "MonEditBoundaryDi.h"
65 #include "MonEditCase.h"
66 #include "MonEditHypothesis.h"
67 #include "MonEditIteration.h"
68 #include "MonEditYACS.h"
69 #include "MonEditZone.h"
70 #include "MonMeshInfo.h"
71 #include "MonIterInfo.h"
72 #include "MonEditFile.h"
73 #include "HomardQtCommun.h"
76 #include <boost/shared_ptr.hpp>
79 #include "SALOMEDS_Study.hxx"
80 #include "HOMARDGUI_Utils.h"
84 static CORBA::ORB_var _orb;
86 //=======================================================================
87 // function : HOMARDGUI()
88 // purpose : Constructor
89 //=======================================================================
90 HOMARDGUI::HOMARDGUI(const QString&) :
91 SalomeApp_Module( "HOMARD" ) // default name
94 //=======================================================================
95 // function : ~HOMARDGUI()
96 // purpose : Destructor
97 //=======================================================================
98 HOMARDGUI::~HOMARDGUI()
102 //=======================================================================
103 // function : InitHOMARDGen
104 // launch HOMARD component and return a handle
105 //=======================================================================
106 HOMARD::HOMARD_Gen_var HOMARDGUI::InitHOMARDGen(SalomeApp_Application* app)
108 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer","HOMARD" );
109 HOMARD::HOMARD_Gen_var clr = HOMARD::HOMARD_Gen::_narrow(comp);
110 ASSERT(!CORBA::is_nil(clr));
114 //=======================================================================
115 // Module's initialization
116 void HOMARDGUI::initialize( CAM_Application* app )
117 //=======================================================================
119 SalomeApp_Module::initialize( app );
120 InitHOMARDGen(dynamic_cast<SalomeApp_Application*>( app ));
127 //================================================
128 // function : createHOMARDAction
129 // create an item in status bar and Homard menu
130 //================================================
131 void HOMARDGUI::createHOMARDAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
133 // MESSAGE("createHOMARDAction");
135 QWidget* parent = application()->desktop();
136 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
138 if ( icon_id.length() )
139 pix = resMgr->loadPixmap( "HOMARD", tr( icon_id .toLatin1().data()) );
141 pix = resMgr->loadPixmap( "HOMARD", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data()), false );
145 QString tooltip = tr(QString( "HOM_TOP_%1" ).arg( po_id ).toLatin1().data()),
146 menu = tr(QString( "HOM_MEN_%1" ).arg( po_id ).toLatin1().data()),
147 status_bar = tr(QString( "HOM_STB_%1" ).arg( po_id ).toLatin1().data());
149 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
152 //================================================
153 // function : createAction
154 // constructs Homard menu
155 // calls createHOMARDAction for each item
156 //================================================
157 void HOMARDGUI::createActions(){
159 createHOMARDAction( 1101, "NEW_CASE", "cas_calcule.png" );
160 createHOMARDAction( 1102, "PURSUE_ITERATION", "iter_poursuite.png" );
161 createHOMARDAction( 1103, "NEW_ITERATION", "iter_next.png" );
162 createHOMARDAction( 1111, "COMPUTE", "mesh_compute.png" );
163 createHOMARDAction( 1112, "COMPUTE_PUBLISH", "mesh_compute.png" );
164 createHOMARDAction( 1121, "MESH_INFO", "advanced_mesh_info.png" );
165 createHOMARDAction( 1131, "MESH_PUBLICATION", "mesh_tree_mesh.png" );
167 createHOMARDAction( 1201, "EDIT", "loop.png" );
168 createHOMARDAction( 1211, "DELETE", "delete.png" );
170 createHOMARDAction( 1301, "MESH_INFO", "advanced_mesh_info.png" );
171 createHOMARDAction( 1302, "EDIT_MESS_FILE", "texte.png" );
173 createHOMARDAction( 1401, "YACS", "table_view.png" );
177 //================================================
178 // function : createPreferences
179 //================================================
180 void HOMARDGUI::createPreferences()
182 MESSAGE("createPreferences")
184 int Onglet, Bloc, Pref ;
186 Onglet = addPreference( tr( "PREF_TAB_GENERAL" ) );
187 // Onglet = addPreference( tr( "PREF_TAB_SETTINGS" ) ) ;
189 Bloc = addPreference( tr( "PREF_PUBLICATION" ), Onglet );
190 setPreferenceProperty( Bloc, "columns", 1 );
192 Pref = addPreference( tr( "PREF_PUBLICATION_MAILLAGE_IN" ), Bloc, LightApp_Preferences::Bool, "HOMARD", "publish_mesh_in" );
194 Pref = addPreference( tr( "PREF_PUBLICATION_MAILLAGE_OUT" ), Bloc, LightApp_Preferences::Bool, "HOMARD", "publish_mesh_out" );
197 Onglet = addPreference( tr( "PREF_YACS" ) ) ;
199 Bloc = addPreference( tr( "PREF_YACS_MAX" ), Onglet );
200 setPreferenceProperty( Bloc, "columns", 1 );
202 Pref = addPreference( tr( "PREF_YACS_MAX_ITER" ), Bloc, LightApp_Preferences::IntSpin, "HOMARD", "yacs_max_iter" );
203 setPreferenceProperty( Pref, "min", 0 );
204 setPreferenceProperty( Pref, "max", 100000000 );
205 setPreferenceProperty( Pref, "step", 1 );
207 Pref = addPreference( tr( "PREF_YACS_MAX_NODE" ), Bloc, LightApp_Preferences::IntSpin, "HOMARD", "yacs_max_node" );
208 setPreferenceProperty( Pref, "min", 0 );
209 setPreferenceProperty( Pref, "max", 100000000 );
210 setPreferenceProperty( Pref, "step", 1000 );
212 Pref = addPreference( tr( "PREF_YACS_MAX_ELEM" ), Bloc, LightApp_Preferences::IntSpin, "HOMARD", "yacs_max_elem" );
213 setPreferenceProperty( Pref, "min", 0 );
214 setPreferenceProperty( Pref, "max", 100000000 );
215 setPreferenceProperty( Pref, "step", 1000 );
217 Bloc = addPreference( tr( "PREF_YACS_CONVERGENCE" ), Onglet );
218 setPreferenceProperty( Bloc, "columns", 1 );
220 Pref = addPreference( tr( "PREF_YACS_TYPE_TEST" ), Bloc, LightApp_Preferences::Selector, "HOMARD", "yacs_type_test" );
221 QStringList aListOfTypeTest;
222 aListOfTypeTest << "None";
223 aListOfTypeTest << "VTest > VRef";
224 aListOfTypeTest << "VTest < VRef";
225 setPreferenceProperty( Pref, "strings", aListOfTypeTest );
229 //================================================
230 // function : createMenus
231 //================================================
232 void HOMARDGUI::createMenus()
234 MESSAGE("createMenus")
236 int HOMARD_Id = createMenu( tr( "HOM_MEN_HOMARD" ), -1, 5, 10 );
237 createMenu( 1101, HOMARD_Id, -1 ); //Create_Case
238 createMenu( 1102, HOMARD_Id, -1 ); //Pursue_Iteration
239 createMenu( separator(), HOMARD_Id,-1);
240 createMenu( 1103, HOMARD_Id, -1 ); //Create_Iteration
241 createMenu( 1111, HOMARD_Id, -1 ); //Compute
242 createMenu( 1112, HOMARD_Id, -1 ); //Compute and publish
244 HOMARD_Id = createMenu( tr( "HOM_MEN_MODIFICATION" ), -1, 5, 10 );
245 createMenu( 1201, HOMARD_Id, -1 ); //Edit
246 createMenu( 1211, HOMARD_Id, -1 ); //Delete
248 HOMARD_Id = createMenu( tr( "HOM_MEN_INFORMATION" ), -1, 5, 10 );
249 createMenu( 1301, HOMARD_Id, -1 ); //Information sur un maillage
250 createMenu( 1131, HOMARD_Id, -1 ); //Mesh publication
251 createMenu( separator(), HOMARD_Id,-1);
252 createMenu( 1302, HOMARD_Id, -1 ); //EditAsciiFile pour le fichier listeStd ou bilan
253 createMenu( separator(), HOMARD_Id,-1);
254 createMenu( 1201, HOMARD_Id, -1 ); //Edit
255 createMenu( separator(), HOMARD_Id,-1);
257 HOMARD_Id = createMenu( tr( "HOM_MEN_YACS" ), -1, 5, 10 );
258 createMenu( 1401, HOMARD_Id, -1 ); // Création d'un schéma YACS
259 createMenu( separator(), HOMARD_Id,-1);
262 //================================================
263 // function : recupPreferences
264 // Pour chaque valeur, le defaut est la valeur definie dans HOMARD_Gen
265 // . Si la recuperation dans config/salome s'est bien passee a la creation de HOMARD_Gen,
266 // ces valeurs sont les valeurs definies.
267 // . Si cela ne s'est pas bien passe, ce sont les valeurs par defaut de HOMARD_Gen
268 //================================================
269 void HOMARDGUI::recupPreferences()
271 MESSAGE("recupPreferences")
275 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( application() );
276 HOMARD::HOMARD_Gen_var homardGen = HOMARDGUI::InitHOMARDGen(app);
278 std::string defaut_s ;
284 defaut_s = homardGen->GetLanguageShort();
285 SUIT_ResourceMgr* resMgr = getApp()->resourceMgr();
286 _LanguageShort = resMgr->stringValue("language", "language", QString(defaut_s.c_str()) );
288 // B.2. Les publications
291 _PublisMeshIN = homardGen->GetPublisMeshIN();
292 if ( _PublisMeshIN == 1 ) { publish_mesh = true ; }
293 else { publish_mesh = false ; }
294 publish_mesh = resMgr->booleanValue("HOMARD", "publish_mesh_in", publish_mesh );
295 if ( publish_mesh ) { _PublisMeshIN = 1 ; }
296 else { _PublisMeshIN = 0 ; }
298 _PublisMeshOUT = homardGen->GetPublisMeshOUT();
299 if ( _PublisMeshOUT == 1 ) { publish_mesh = true ; }
300 else { publish_mesh = false ; }
301 publish_mesh = resMgr->booleanValue("HOMARD", "publish_mesh_out", publish_mesh );
302 if ( publish_mesh ) { _PublisMeshOUT = 1 ; }
303 else { _PublisMeshOUT = 0 ; }
305 // B.3. Les maximum pour YACS
307 defaut_i = homardGen->GetYACSMaxIter();
308 _YACSMaxIter = resMgr->integerValue("HOMARD", "yacs_max_iter", defaut_i );
310 defaut_i = homardGen->GetYACSMaxNode();
311 _YACSMaxNode = resMgr->integerValue("HOMARD", "yacs_max_node", defaut_i );
313 defaut_i = homardGen->GetYACSMaxElem();
314 _YACSMaxElem = resMgr->integerValue("HOMARD", "yacs_max_elem", defaut_i );
316 // B.4. La convergence pour YACS
318 defaut_i = homardGen->GetYACSConvergenceType();
319 if ( defaut_i == 1 ) { QString_v = tr("VTest > VRef") ; }
320 else if ( defaut_i == 2 ) { QString_v = tr("VTest < VRef") ; }
321 else { QString_v = tr("None") ; }
322 QString_v = resMgr->stringValue ( "HOMARD", "yacs_type_test", QString_v );
323 if ( ( QString_v == "VTest > VRef" ) || ( QString_v == "VTest > VRef" ) ) { _YACSTypeTest = 1 ; }
324 else if ( ( QString_v == "VTest < VRef" ) || ( QString_v == "VTest < VRef" ) ) { _YACSTypeTest = 2 ; }
325 else { _YACSTypeTest = 0 ; }
327 // C. Enregistrement dans l'objet general
329 MESSAGE ("Enregistrement de LanguageShort = " << _LanguageShort.toStdString().c_str() );
330 MESSAGE ("Enregistrement de PublisMeshIN = " << _PublisMeshIN<<", PublisMeshOUT = "<< _PublisMeshOUT);
331 MESSAGE ("Enregistrement de YACSMaxIter = " << _YACSMaxIter<<", YACSMaxNode = "<< _YACSMaxNode<<", YACSMaxElem = "<< _YACSMaxElem);
332 MESSAGE ("Enregistrement de YACSTypeTest = " << _YACSTypeTest);
334 homardGen->SetLanguageShort(_LanguageShort.toStdString().c_str());
335 homardGen->SetPublisMesh(_PublisMeshIN, _PublisMeshOUT);
336 homardGen->SetYACSMaximum(_YACSMaxIter, _YACSMaxNode, _YACSMaxElem);
338 homardGen->SetYACSConvergenceType(_YACSTypeTest);
341 //================================================
342 void HOMARDGUI::OnGUIEvent()
343 //================================================
345 MESSAGE("OnGUIEvent()")
347 const QObject* obj = sender();
348 if ( !obj || !obj->inherits( "QAction" ) ) { return; }
349 int id = actionId((QAction*)obj);
350 if ( id != -1 ) { bool ret = OnGUIEvent( id ); }
351 MESSAGE("Fin de OnGUIEvent()");
354 //=======================================================================
355 // Method OnGUIEvent pour Homard
356 //=======================================================================
357 bool HOMARDGUI::OnGUIEvent (int theCommandID)
359 MESSAGE("OnGUIEvent avec theCommandID = "<<theCommandID);
361 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( application() );
362 if ( !app ) return false;
364 SalomeApp_Study* stud = dynamic_cast<SalomeApp_Study*> ( app->activeStudy() );
367 MESSAGE ( "FAILED to cast active study to SalomeApp_Study" );
371 SUIT_Desktop* parent = application()->desktop();
372 HOMARD::HOMARD_Gen_var homardGen = HOMARDGUI::InitHOMARDGen(app);
374 if (!CORBA::is_nil(homardGen))
377 SalomeApp_Study* aSAStudy =dynamic_cast<SalomeApp_Study*>(app->activeStudy());
378 _PTR(Study) aStudy = aSAStudy->studyDS();
379 SALOMEDS::Study_ptr aStudyDS;
381 aStudyDS = _CAST(Study,aStudy)->GetStudy();
382 homardGen->SetCurrentStudy(aStudyDS);
384 getApp()->updateObjectBrowser();
386 // B. Choix selon les commandes
387 SCRUTE(theCommandID);
388 switch (theCommandID)
390 case 1101: // Creation d un Cas
392 MESSAGE("command " << theCommandID << " activated");
393 MonCreateCase *aDlg = new MonCreateCase( true,
394 HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ;
399 case 1102: // Poursuite d une iteration
401 MESSAGE("command " << theCommandID << " activated");
402 MonPursueIteration *aDlg = new MonPursueIteration( true,
403 HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ;
408 case 1103: // Creation d une Iteration
410 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
411 MonCreateIteration *IterDlg = new MonCreateIteration( parent, true,
412 HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
417 case 1111: // Compute une iteration
419 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
420 try { homardGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 1); }
421 catch( SALOME::SALOME_Exception& S_ex )
423 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
424 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
425 getApp()->updateObjectBrowser();
431 case 1112: // Compute une iteration et publication
433 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
434 try { homardGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 2); }
435 catch( SALOME::SALOME_Exception& S_ex )
437 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
438 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
439 getApp()->updateObjectBrowser();
445 case 1121: // Information sur le maillage de l'iteration
447 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
448 MonIterInfo *IterDlg = new MonIterInfo( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
453 case 1131: // Publication du maillage de l'iteration
455 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
456 homardGen->PublishMeshIterInSmesh(_ObjectName.toStdString().c_str());
460 case 1132: // Publication du maillage de l'iteration a partir du fichier
462 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
463 homardGen->PublishResultInSmesh(_ObjectName.toStdString().c_str(), 1);
467 case 1201: // Edition d'un objet
469 MESSAGE("command " << theCommandID << " activated");
470 QString nomObjet = HOMARD_QT_COMMUN::SelectionArbreEtude(QString(""), 1);
471 if (nomObjet == QString("")) break;
472 _PTR(SObject) obj = chercheMonObjet();
475 // Edition d'une frontiere discrete
476 if (HOMARD_UTILS::isBoundaryDi(obj))
478 MonEditBoundaryDi *aDlg = new MonEditBoundaryDi(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
481 // Edition d'une frontiere analytique
482 else if (HOMARD_UTILS::isBoundaryAn(obj))
484 MonEditBoundaryAn *aDlg = new MonEditBoundaryAn(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
488 else if (HOMARD_UTILS::isCase(obj))
490 MonEditCase *aDlg = new MonEditCase(true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
493 // Edition d'une hypothese
494 else if (HOMARD_UTILS::isHypo(obj))
496 MonEditHypothesis *aDlg = new MonEditHypothesis(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName, QString(""), QString("")) ;
499 // Edition d'une iteration
500 else if (HOMARD_UTILS::isIter(obj))
502 MonEditIteration *aDlg = new MonEditIteration(parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
505 // Edition d'un schema YACS
506 else if (HOMARD_UTILS::isYACS(obj))
508 MESSAGE("appel de MonEditYACS");
509 MonEditYACS *aDlg = new MonEditYACS(true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName) ;
512 // Edition d'une zone
513 else if (HOMARD_UTILS::isZone(obj))
515 MonEditZone *aDlg = new MonEditZone(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
522 case 1211: // Suppression d'un objet
524 MESSAGE("command " << theCommandID << " activated");
525 QString nomObjet = HOMARD_QT_COMMUN::SelectionArbreEtude(QString(""), 1);
526 if (nomObjet == QString("")) break;
527 _PTR(SObject) obj = chercheMonObjet();
530 // Suppression d'une frontiere
531 if ( HOMARD_UTILS::isBoundaryDi(obj) || HOMARD_UTILS::isBoundaryAn(obj) )
534 { homardGen->DeleteBoundary(_ObjectName.toStdString().c_str()); }
535 catch( SALOME::SALOME_Exception& S_ex )
537 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
538 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
539 getApp()->updateObjectBrowser();
543 // Suppression d'un cas
544 else if (HOMARD_UTILS::isCase(obj))
547 { homardGen->DeleteCase(_ObjectName.toStdString().c_str(), 1); }
548 catch( SALOME::SALOME_Exception& S_ex )
550 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
551 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
552 getApp()->updateObjectBrowser();
556 // Suppression d'une hypothese
557 else if (HOMARD_UTILS::isHypo(obj))
560 { homardGen->DeleteHypo(_ObjectName.toStdString().c_str()); }
561 catch( SALOME::SALOME_Exception& S_ex )
563 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
564 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
565 getApp()->updateObjectBrowser();
569 // Suppression d'une iteration
570 else if (HOMARD_UTILS::isIter(obj))
573 { homardGen->DeleteIteration(_ObjectName.toStdString().c_str(), 1); }
574 catch( SALOME::SALOME_Exception& S_ex )
576 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
577 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
578 getApp()->updateObjectBrowser();
582 // Suppression d'un schema YACS
583 else if (HOMARD_UTILS::isYACS(obj))
586 { homardGen->DeleteYACS(_ObjectName.toStdString().c_str(), 1); }
587 catch( SALOME::SALOME_Exception& S_ex )
589 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
590 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
591 getApp()->updateObjectBrowser();
595 // Suppression d'une zone
596 else if (HOMARD_UTILS::isZone(obj))
599 { homardGen->DeleteZone(_ObjectName.toStdString().c_str()); }
600 catch( SALOME::SALOME_Exception& S_ex )
602 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
603 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
604 getApp()->updateObjectBrowser();
612 case 1301: // Information sur un maillage
614 MESSAGE("etape 1301")
615 MESSAGE("command " << theCommandID << " activated");
616 MonMeshInfo *aDlg = new MonMeshInfo( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ;
621 case 1302: // Affichage de fichier texte
623 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
624 _PTR(SObject) obj = chercheMonObjet();
625 if ( (obj) && ( HOMARD_UTILS::isFileType(obj,QString("log")) || HOMARD_UTILS::isFileType(obj,QString("Summary")) || HOMARD_UTILS::isFileType(obj,QString("xml")) ) )
627 MonEditFile *aDlg = new MonEditFile( 0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName, 0 ) ;
628 if ( aDlg->_codret == 0 ) { aDlg->show(); }
633 case 1401: // Création d'un schema YACS
635 MESSAGE("etape 1401")
636 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
637 MonCreateYACS *aDlg = new MonCreateYACS( true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
642 case 1402: // Ecriture d'un schéma YACS
644 MESSAGE("etape 1402")
645 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
646 try { homardGen->YACSWrite(_ObjectName.toStdString().c_str()); }
647 catch( SALOME::SALOME_Exception& S_ex )
649 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
650 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
651 getApp()->updateObjectBrowser();
658 getApp()->updateObjectBrowser();
662 //=============================================================================
666 //=============================================================================
668 // Module's engine IOR
669 //=============================================================================
670 QString HOMARDGUI::engineIOR() const
671 //=============================================================================
673 CORBA::String_var anIOR = getApp()->orb()->object_to_string( InitHOMARDGen(getApp()) );
674 return QString( anIOR.in() );
677 // Module's activation
678 //=============================================================================
679 bool HOMARDGUI::activateModule( SUIT_Study* theStudy )
680 //=============================================================================
682 bool bOk = SalomeApp_Module::activateModule( theStudy );
684 setMenuShown( true );
685 setToolShown( true );
690 // Module's deactivation
691 //=============================================================================
692 bool HOMARDGUI::deactivateModule( SUIT_Study* theStudy )
693 //=============================================================================
695 setMenuShown( false );
696 setToolShown( false );
698 return SalomeApp_Module::deactivateModule( theStudy );
702 //=============================================================================
703 void HOMARDGUI::windows( QMap<int, int>& theMap ) const
704 //=============================================================================
707 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
708 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
711 //=============================================================================
712 void HOMARDGUI::setOrb()
713 //=============================================================================
717 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
718 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
719 _orb = init( 0 , 0 );
723 INFOS("internal error : orb not found");
726 ASSERT(! CORBA::is_nil(_orb));
728 //========================================
729 _PTR(SObject) HOMARDGUI::chercheMonObjet()
730 //========================================
732 SALOMEDSClient_SObject* aSO = NULL;
735 getApp()->selectionMgr()->selectedObjects( lst );
736 if ( lst.Extent() == 1 )
738 Handle(SALOME_InteractiveObject) io = lst.First();
739 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
740 _PTR(Study) study = appStudy->studyDS();
741 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
742 _ObjectName = QString( obj->GetName().c_str() );
745 else { return _PTR(SObject)(aSO); }
747 //=============================================================================
748 void HOMARDGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
749 //=============================================================================
751 MESSAGE("Debut de contextMenuPopup");
752 _PTR(SObject) obj = chercheMonObjet();
755 title = QString( obj->GetName().c_str() );
757 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
760 bool DeleteObject = false ;
761 bool EditObject = false ;
763 if ( HOMARD_UTILS::isBoundaryAn(obj) )
766 DeleteObject = true ;
768 else if ( HOMARD_UTILS::isBoundaryDi(obj) )
771 DeleteObject = true ;
773 else if ( HOMARD_UTILS::isCase(obj) )
775 pix = resMgr->loadPixmap( "HOMARD", "table_view.png" );
776 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_YACS").toLatin1().data()), this, SLOT(YACSCreate()));
778 DeleteObject = true ;
780 else if ( HOMARD_UTILS::isHypo(obj) )
783 DeleteObject = true ;
785 else if ( HOMARD_UTILS::isIter(obj) )
787 pix = resMgr->loadPixmap( "HOMARD", "iter_next.png" );
788 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_NEW_ITERATION").toLatin1().data()), this, SLOT(NextIter()));
789 pix = resMgr->loadPixmap( "HOMARD", "mesh_compute.png" );
790 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_COMPUTE").toLatin1().data()), this, SLOT(LanceCalcul0()));
791 pix = resMgr->loadPixmap( "HOMARD", "mesh_compute.png" );
792 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_COMPUTE_PUBLISH").toLatin1().data()), this, SLOT(LanceCalcul1()));
793 pix = resMgr->loadPixmap( "HOMARD", "advanced_mesh_info.png" );
794 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_INFO").toLatin1().data()), this, SLOT(IterInfo()));
795 pix = resMgr->loadPixmap( "HOMARD", "mesh_tree_mesh.png" );
796 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_PUBLICATION").toLatin1().data()), this, SLOT(MeshPublish0()));
798 DeleteObject = true ;
800 else if ( HOMARD_UTILS::isYACS(obj) )
802 pix = resMgr->loadPixmap( "HOMARD", "write.png" );
803 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_WRITE").toLatin1().data()), this, SLOT(YACSWrite()));
805 DeleteObject = true ;
807 else if ( HOMARD_UTILS::isZone(obj) )
810 DeleteObject = true ;
812 else if ( HOMARD_UTILS::isFileType(obj,QString("log")) || HOMARD_UTILS::isFileType(obj,QString("Summary")) || HOMARD_UTILS::isFileType(obj,QString("xml")) )
814 pix = resMgr->loadPixmap( "HOMARD", "texte.png" );
815 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_EDIT_MESS_FILE").toLatin1().data()), this, SLOT(EditAsciiFile()));
817 else if ( HOMARD_UTILS::isFileType(obj,QString("Mesh")) )
819 pix = resMgr->loadPixmap( "HOMARD", "mesh_tree_mesh.png" );
820 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_PUBLICATION").toLatin1().data()), this, SLOT(MeshPublish1()));
822 // Ajout d'un menu d'edition pour les objets qui le proposent
825 pix = resMgr->loadPixmap( "HOMARD", "loop.png" );
826 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_EDIT").toLatin1().data()), this, SLOT(Edit()));
828 // Ajout d'un menu de destruction pour les objets qui le proposent
831 pix = resMgr->loadPixmap( "HOMARD", "delete.png" );
832 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_DELETE").toLatin1().data()), this, SLOT(Delete()));
837 void HOMARDGUI::NextIter()
839 this->OnGUIEvent(1103);
842 void HOMARDGUI::LanceCalcul0()
844 this->OnGUIEvent(1111);
847 void HOMARDGUI::LanceCalcul1()
849 this->OnGUIEvent(1112);
852 void HOMARDGUI::IterInfo()
854 this->OnGUIEvent(1121);
857 void HOMARDGUI::MeshPublish0()
859 this->OnGUIEvent(1131);
862 void HOMARDGUI::MeshPublish1()
864 this->OnGUIEvent(1132);
867 void HOMARDGUI::Edit()
869 this->OnGUIEvent(1201);
872 void HOMARDGUI::Delete()
874 this->OnGUIEvent(1211);
877 void HOMARDGUI::EditAsciiFile()
879 this->OnGUIEvent(1302);
882 void HOMARDGUI::YACSCreate()
884 this->OnGUIEvent(1401);
886 void HOMARDGUI::YACSWrite()
888 this->OnGUIEvent(1402);
893 //=============================================================================
895 //=============================================================================
897 Standard_EXPORT CAM_Module* createModule()
899 return new HOMARDGUI("");