1 // Copyright (C) 2011-2016 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 : Gerald NICOLAS, 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"
43 #include "SalomeApp_Application.h"
44 #include "SalomeApp_DataModel.h"
45 #include "SalomeApp_Study.h"
46 #include "LightApp_SelectionMgr.h"
47 #include "LightApp_Selection.h"
48 #include <LightApp_Preferences.h>
49 #include "SalomeApp_Module.h"
50 #include "SALOMEconfig.h"
51 #include <SALOME_LifeCycleCORBA.hxx>
53 #include <utilities.h>
58 #include "MonCreateCase.h"
59 #include "MonCreateIteration.h"
60 #include "MonPursueIteration.h"
61 #include "MonCreateYACS.h"
62 #include "MonEditBoundaryCAO.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 CAO
476 if (HOMARD_UTILS::isBoundaryCAO(obj))
478 MonEditBoundaryCAO *aDlg = new MonEditBoundaryCAO(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
481 // Edition d'une frontiere discrete
482 else if (HOMARD_UTILS::isBoundaryDi(obj))
484 MonEditBoundaryDi *aDlg = new MonEditBoundaryDi(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
487 // Edition d'une frontiere analytique
488 else if (HOMARD_UTILS::isBoundaryAn(obj))
490 MonEditBoundaryAn *aDlg = new MonEditBoundaryAn(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
494 else if (HOMARD_UTILS::isCase(obj))
496 MonEditCase *aDlg = new MonEditCase(true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
499 // Edition d'une hypothese
500 else if (HOMARD_UTILS::isHypo(obj))
502 MonEditHypothesis *aDlg = new MonEditHypothesis(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName, QString(""), QString("")) ;
505 // Edition d'une iteration
506 else if (HOMARD_UTILS::isIter(obj))
508 MonEditIteration *aDlg = new MonEditIteration(parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
511 // Edition d'un schema YACS
512 else if (HOMARD_UTILS::isYACS(obj))
514 MESSAGE("appel de MonEditYACS");
515 MonEditYACS *aDlg = new MonEditYACS(true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName) ;
518 // Edition d'une zone
519 else if (HOMARD_UTILS::isZone(obj))
521 MonEditZone *aDlg = new MonEditZone(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
528 case 1211: // Suppression d'un objet
530 MESSAGE("command " << theCommandID << " activated");
531 QString nomObjet = HOMARD_QT_COMMUN::SelectionArbreEtude(QString(""), 1);
532 if (nomObjet == QString("")) break;
533 _PTR(SObject) obj = chercheMonObjet();
536 // Suppression d'une frontiere
537 if ( HOMARD_UTILS::isBoundaryCAO(obj) || HOMARD_UTILS::isBoundaryDi(obj) || HOMARD_UTILS::isBoundaryAn(obj) )
540 { homardGen->DeleteBoundary(_ObjectName.toStdString().c_str()); }
541 catch( SALOME::SALOME_Exception& S_ex )
543 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
544 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
545 getApp()->updateObjectBrowser();
549 // Suppression d'un cas
550 else if (HOMARD_UTILS::isCase(obj))
553 { homardGen->DeleteCase(_ObjectName.toStdString().c_str(), 1); }
554 catch( SALOME::SALOME_Exception& S_ex )
556 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
557 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
558 getApp()->updateObjectBrowser();
562 // Suppression d'une hypothese
563 else if (HOMARD_UTILS::isHypo(obj))
566 { homardGen->DeleteHypo(_ObjectName.toStdString().c_str()); }
567 catch( SALOME::SALOME_Exception& S_ex )
569 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
570 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
571 getApp()->updateObjectBrowser();
575 // Suppression d'une iteration
576 else if (HOMARD_UTILS::isIter(obj))
579 { homardGen->DeleteIteration(_ObjectName.toStdString().c_str(), 1); }
580 catch( SALOME::SALOME_Exception& S_ex )
582 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
583 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
584 getApp()->updateObjectBrowser();
588 // Suppression d'un schema YACS
589 else if (HOMARD_UTILS::isYACS(obj))
592 { homardGen->DeleteYACS(_ObjectName.toStdString().c_str(), 1); }
593 catch( SALOME::SALOME_Exception& S_ex )
595 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
596 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
597 getApp()->updateObjectBrowser();
601 // Suppression d'une zone
602 else if (HOMARD_UTILS::isZone(obj))
605 { homardGen->DeleteZone(_ObjectName.toStdString().c_str()); }
606 catch( SALOME::SALOME_Exception& S_ex )
608 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
609 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
610 getApp()->updateObjectBrowser();
618 case 1301: // Information sur un maillage
620 MESSAGE("etape 1301")
621 MESSAGE("command " << theCommandID << " activated");
622 MonMeshInfo *aDlg = new MonMeshInfo( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ;
627 case 1302: // Affichage de fichier texte
629 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
630 _PTR(SObject) obj = chercheMonObjet();
631 if ( (obj) && ( HOMARD_UTILS::isFileType(obj,QString("log")) || HOMARD_UTILS::isFileType(obj,QString("Summary")) || HOMARD_UTILS::isFileType(obj,QString("xml")) ) )
633 MonEditFile *aDlg = new MonEditFile( 0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName, 0 ) ;
634 if ( aDlg->_codret == 0 ) { aDlg->show(); }
639 case 1401: // Création d'un schema YACS
641 MESSAGE("etape 1401")
642 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
643 MonCreateYACS *aDlg = new MonCreateYACS( true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
648 case 1402: // Ecriture d'un schéma YACS
650 MESSAGE("etape 1402")
651 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
652 try { homardGen->YACSWrite(_ObjectName.toStdString().c_str()); }
653 catch( SALOME::SALOME_Exception& S_ex )
655 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
656 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
657 getApp()->updateObjectBrowser();
664 getApp()->updateObjectBrowser();
668 //=============================================================================
672 //=============================================================================
674 // Module's engine IOR
675 //=============================================================================
676 QString HOMARDGUI::engineIOR() const
677 //=============================================================================
679 CORBA::String_var anIOR = getApp()->orb()->object_to_string( InitHOMARDGen(getApp()) );
680 return QString( anIOR.in() );
683 // Module's activation
684 //=============================================================================
685 bool HOMARDGUI::activateModule( SUIT_Study* theStudy )
686 //=============================================================================
688 bool bOk = SalomeApp_Module::activateModule( theStudy );
690 setMenuShown( true );
691 setToolShown( true );
696 // Module's deactivation
697 //=============================================================================
698 bool HOMARDGUI::deactivateModule( SUIT_Study* theStudy )
699 //=============================================================================
701 setMenuShown( false );
702 setToolShown( false );
704 return SalomeApp_Module::deactivateModule( theStudy );
708 //=============================================================================
709 void HOMARDGUI::windows( QMap<int, int>& theMap ) const
710 //=============================================================================
713 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
714 #ifndef DISABLE_PYCONSOLE
715 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
719 //=============================================================================
720 void HOMARDGUI::setOrb()
721 //=============================================================================
725 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
726 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
727 _orb = init( 0 , 0 );
731 INFOS("internal error : orb not found");
734 ASSERT(! CORBA::is_nil(_orb));
736 //========================================
737 _PTR(SObject) HOMARDGUI::chercheMonObjet()
738 //========================================
740 SALOMEDSClient_SObject* aSO = NULL;
743 getApp()->selectionMgr()->selectedObjects( lst );
744 if ( lst.Extent() == 1 )
746 Handle(SALOME_InteractiveObject) io = lst.First();
747 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
748 _PTR(Study) study = appStudy->studyDS();
749 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
750 _ObjectName = QString( obj->GetName().c_str() );
753 else { return _PTR(SObject)(aSO); }
755 //=============================================================================
756 void HOMARDGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
757 //=============================================================================
759 MESSAGE("Debut de contextMenuPopup");
760 _PTR(SObject) obj = chercheMonObjet();
763 title = QString( obj->GetName().c_str() );
765 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
768 bool DeleteObject = false ;
769 bool EditObject = false ;
771 if ( HOMARD_UTILS::isBoundaryCAO(obj) )
774 DeleteObject = true ;
776 else if ( HOMARD_UTILS::isBoundaryAn(obj) )
779 DeleteObject = true ;
781 else if ( HOMARD_UTILS::isBoundaryDi(obj) )
784 DeleteObject = true ;
786 else if ( HOMARD_UTILS::isCase(obj) )
788 pix = resMgr->loadPixmap( "HOMARD", "table_view.png" );
789 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_YACS").toLatin1().data()), this, SLOT(YACSCreate()));
791 DeleteObject = true ;
793 else if ( HOMARD_UTILS::isHypo(obj) )
796 DeleteObject = true ;
798 else if ( HOMARD_UTILS::isIter(obj) )
800 pix = resMgr->loadPixmap( "HOMARD", "iter_next.png" );
801 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_NEW_ITERATION").toLatin1().data()), this, SLOT(NextIter()));
802 pix = resMgr->loadPixmap( "HOMARD", "mesh_compute.png" );
803 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_COMPUTE").toLatin1().data()), this, SLOT(LanceCalcul0()));
804 pix = resMgr->loadPixmap( "HOMARD", "mesh_compute.png" );
805 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_COMPUTE_PUBLISH").toLatin1().data()), this, SLOT(LanceCalcul1()));
806 pix = resMgr->loadPixmap( "HOMARD", "advanced_mesh_info.png" );
807 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_INFO").toLatin1().data()), this, SLOT(IterInfo()));
808 pix = resMgr->loadPixmap( "HOMARD", "mesh_tree_mesh.png" );
809 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_PUBLICATION").toLatin1().data()), this, SLOT(MeshPublish0()));
811 DeleteObject = true ;
813 else if ( HOMARD_UTILS::isYACS(obj) )
815 pix = resMgr->loadPixmap( "HOMARD", "write.png" );
816 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_WRITE").toLatin1().data()), this, SLOT(YACSWrite()));
818 DeleteObject = true ;
820 else if ( HOMARD_UTILS::isZone(obj) )
823 DeleteObject = true ;
825 else if ( HOMARD_UTILS::isFileType(obj,QString("log")) || HOMARD_UTILS::isFileType(obj,QString("Summary")) || HOMARD_UTILS::isFileType(obj,QString("xml")) )
827 pix = resMgr->loadPixmap( "HOMARD", "texte.png" );
828 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_EDIT_MESS_FILE").toLatin1().data()), this, SLOT(EditAsciiFile()));
830 else if ( HOMARD_UTILS::isFileType(obj,QString("Mesh")) )
832 pix = resMgr->loadPixmap( "HOMARD", "mesh_tree_mesh.png" );
833 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_PUBLICATION").toLatin1().data()), this, SLOT(MeshPublish1()));
835 // Ajout d'un menu d'edition pour les objets qui le proposent
838 pix = resMgr->loadPixmap( "HOMARD", "loop.png" );
839 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_EDIT").toLatin1().data()), this, SLOT(Edit()));
841 // Ajout d'un menu de destruction pour les objets qui le proposent
844 pix = resMgr->loadPixmap( "HOMARD", "delete.png" );
845 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_DELETE").toLatin1().data()), this, SLOT(Delete()));
850 void HOMARDGUI::NextIter()
852 this->OnGUIEvent(1103);
855 void HOMARDGUI::LanceCalcul0()
857 this->OnGUIEvent(1111);
860 void HOMARDGUI::LanceCalcul1()
862 this->OnGUIEvent(1112);
865 void HOMARDGUI::IterInfo()
867 this->OnGUIEvent(1121);
870 void HOMARDGUI::MeshPublish0()
872 this->OnGUIEvent(1131);
875 void HOMARDGUI::MeshPublish1()
877 this->OnGUIEvent(1132);
880 void HOMARDGUI::Edit()
882 this->OnGUIEvent(1201);
885 void HOMARDGUI::Delete()
887 this->OnGUIEvent(1211);
890 void HOMARDGUI::EditAsciiFile()
892 this->OnGUIEvent(1302);
895 void HOMARDGUI::YACSCreate()
897 this->OnGUIEvent(1401);
899 void HOMARDGUI::YACSWrite()
901 this->OnGUIEvent(1402);
906 //=============================================================================
908 //=============================================================================
910 Standard_EXPORT CAM_Module* createModule()
912 return new HOMARDGUI("");