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 "MonEditBoundaryAn.h"
63 #include "MonEditBoundaryDi.h"
64 #include "MonEditCase.h"
65 #include "MonEditHypothesis.h"
66 #include "MonEditIteration.h"
67 #include "MonEditYACS.h"
68 #include "MonEditZone.h"
69 #include "MonMeshInfo.h"
70 #include "MonIterInfo.h"
71 #include "MonEditFile.h"
72 #include "HomardQtCommun.h"
75 #include <boost/shared_ptr.hpp>
78 #include "SALOMEDS_Study.hxx"
79 #include "HOMARDGUI_Utils.h"
83 static CORBA::ORB_var _orb;
85 //=======================================================================
86 // function : HOMARDGUI()
87 // purpose : Constructor
88 //=======================================================================
89 HOMARDGUI::HOMARDGUI(const QString&) :
90 SalomeApp_Module( "HOMARD" ) // default name
93 //=======================================================================
94 // function : ~HOMARDGUI()
95 // purpose : Destructor
96 //=======================================================================
97 HOMARDGUI::~HOMARDGUI()
101 //=======================================================================
102 // function : InitHOMARDGen
103 // launch HOMARD component and return a handle
104 //=======================================================================
105 HOMARD::HOMARD_Gen_var HOMARDGUI::InitHOMARDGen(SalomeApp_Application* app)
107 Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer","HOMARD" );
108 HOMARD::HOMARD_Gen_var clr = HOMARD::HOMARD_Gen::_narrow(comp);
109 ASSERT(!CORBA::is_nil(clr));
113 //=======================================================================
114 // Module's initialization
115 void HOMARDGUI::initialize( CAM_Application* app )
116 //=======================================================================
118 SalomeApp_Module::initialize( app );
119 InitHOMARDGen(dynamic_cast<SalomeApp_Application*>( app ));
126 //================================================
127 // function : createHOMARDAction
128 // create an item in status bar and Homard menu
129 //================================================
130 void HOMARDGUI::createHOMARDAction( const int id, const QString& po_id, const QString& icon_id, const int key, const bool toggle )
132 // MESSAGE("createHOMARDAction");
134 QWidget* parent = application()->desktop();
135 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
137 if ( icon_id.length() )
138 pix = resMgr->loadPixmap( "HOMARD", tr( icon_id .toLatin1().data()) );
140 pix = resMgr->loadPixmap( "HOMARD", tr( QString( "ICO_%1" ).arg( po_id ).toLatin1().data()), false );
144 QString tooltip = tr(QString( "HOM_TOP_%1" ).arg( po_id ).toLatin1().data()),
145 menu = tr(QString( "HOM_MEN_%1" ).arg( po_id ).toLatin1().data()),
146 status_bar = tr(QString( "HOM_STB_%1" ).arg( po_id ).toLatin1().data());
148 createAction( id, tooltip, icon, menu, status_bar, key, parent, toggle, this, SLOT( OnGUIEvent() ) );
151 //================================================
152 // function : createAction
153 // constructs Homard menu
154 // calls createHOMARDAction for each item
155 //================================================
156 void HOMARDGUI::createActions(){
158 createHOMARDAction( 1101, "NEW_CASE", "cas_calcule.png" );
159 createHOMARDAction( 1102, "PURSUE_ITERATION", "iter_poursuite.png" );
160 createHOMARDAction( 1103, "NEW_ITERATION", "iter_next.png" );
161 createHOMARDAction( 1111, "COMPUTE", "mesh_compute.png" );
162 createHOMARDAction( 1112, "COMPUTE_PUBLISH", "mesh_compute.png" );
163 createHOMARDAction( 1121, "MESH_INFO", "advanced_mesh_info.png" );
164 createHOMARDAction( 1131, "MESH_PUBLICATION", "mesh_tree_mesh.png" );
166 createHOMARDAction( 1201, "EDIT", "loop.png" );
167 createHOMARDAction( 1211, "DELETE", "delete.png" );
169 createHOMARDAction( 1301, "MESH_INFO", "advanced_mesh_info.png" );
170 createHOMARDAction( 1302, "EDIT_MESS_FILE", "texte.png" );
172 createHOMARDAction( 1401, "YACS", "table_view.png" );
176 //================================================
177 // function : createPreferences
178 //================================================
179 void HOMARDGUI::createPreferences()
181 MESSAGE("createPreferences")
183 int Onglet, Bloc, Pref ;
185 Onglet = addPreference( tr( "PREF_TAB_GENERAL" ) );
186 // Onglet = addPreference( tr( "PREF_TAB_SETTINGS" ) ) ;
188 Bloc = addPreference( tr( "PREF_PUBLICATION" ), Onglet );
189 setPreferenceProperty( Bloc, "columns", 1 );
191 Pref = addPreference( tr( "PREF_PUBLICATION_MAILLAGE_IN" ), Bloc, LightApp_Preferences::Bool, "HOMARD", "publish_mesh_in" );
193 Pref = addPreference( tr( "PREF_PUBLICATION_MAILLAGE_OUT" ), Bloc, LightApp_Preferences::Bool, "HOMARD", "publish_mesh_out" );
196 Onglet = addPreference( tr( "PREF_YACS" ) ) ;
198 Bloc = addPreference( tr( "PREF_YACS_MAX" ), Onglet );
199 setPreferenceProperty( Bloc, "columns", 1 );
201 Pref = addPreference( tr( "PREF_YACS_MAX_ITER" ), Bloc, LightApp_Preferences::IntSpin, "HOMARD", "yacs_max_iter" );
202 setPreferenceProperty( Pref, "min", 0 );
203 setPreferenceProperty( Pref, "max", 100000000 );
204 setPreferenceProperty( Pref, "step", 1 );
206 Pref = addPreference( tr( "PREF_YACS_MAX_NODE" ), Bloc, LightApp_Preferences::IntSpin, "HOMARD", "yacs_max_node" );
207 setPreferenceProperty( Pref, "min", 0 );
208 setPreferenceProperty( Pref, "max", 100000000 );
209 setPreferenceProperty( Pref, "step", 1000 );
211 Pref = addPreference( tr( "PREF_YACS_MAX_ELEM" ), Bloc, LightApp_Preferences::IntSpin, "HOMARD", "yacs_max_elem" );
212 setPreferenceProperty( Pref, "min", 0 );
213 setPreferenceProperty( Pref, "max", 100000000 );
214 setPreferenceProperty( Pref, "step", 1000 );
216 Bloc = addPreference( tr( "PREF_YACS_CONVERGENCE" ), Onglet );
217 setPreferenceProperty( Bloc, "columns", 1 );
219 Pref = addPreference( tr( "PREF_YACS_TYPE_TEST" ), Bloc, LightApp_Preferences::Selector, "HOMARD", "yacs_type_test" );
220 QStringList aListOfTypeTest;
221 aListOfTypeTest << "None";
222 aListOfTypeTest << "VTest > VRef";
223 aListOfTypeTest << "VTest < VRef";
224 setPreferenceProperty( Pref, "strings", aListOfTypeTest );
228 //================================================
229 // function : createMenus
230 //================================================
231 void HOMARDGUI::createMenus()
233 MESSAGE("createMenus")
235 int HOMARD_Id = createMenu( tr( "HOM_MEN_HOMARD" ), -1, 5, 10 );
236 createMenu( 1101, HOMARD_Id, -1 ); //Create_Case
237 createMenu( 1102, HOMARD_Id, -1 ); //Pursue_Iteration
238 createMenu( separator(), HOMARD_Id,-1);
239 createMenu( 1103, HOMARD_Id, -1 ); //Create_Iteration
240 createMenu( 1111, HOMARD_Id, -1 ); //Compute
241 createMenu( 1112, HOMARD_Id, -1 ); //Compute and publish
243 HOMARD_Id = createMenu( tr( "HOM_MEN_MODIFICATION" ), -1, 5, 10 );
244 createMenu( 1201, HOMARD_Id, -1 ); //Edit
245 createMenu( 1211, HOMARD_Id, -1 ); //Delete
247 HOMARD_Id = createMenu( tr( "HOM_MEN_INFORMATION" ), -1, 5, 10 );
248 createMenu( 1301, HOMARD_Id, -1 ); //Information sur un maillage
249 createMenu( 1131, HOMARD_Id, -1 ); //Mesh publication
250 createMenu( separator(), HOMARD_Id,-1);
251 createMenu( 1302, HOMARD_Id, -1 ); //EditAsciiFile pour le fichier listeStd ou bilan
252 createMenu( separator(), HOMARD_Id,-1);
253 createMenu( 1201, HOMARD_Id, -1 ); //Edit
254 createMenu( separator(), HOMARD_Id,-1);
256 HOMARD_Id = createMenu( tr( "HOM_MEN_YACS" ), -1, 5, 10 );
257 createMenu( 1401, HOMARD_Id, -1 ); // Création d'un schéma YACS
258 createMenu( separator(), HOMARD_Id,-1);
261 //================================================
262 // function : recupPreferences
263 // Pour chaque valeur, le defaut est la valeur definie dans HOMARD_Gen
264 // . Si la recuperation dans config/salome s'est bien passee a la creation de HOMARD_Gen,
265 // ces valeurs sont les valeurs definies.
266 // . Si cela ne s'est pas bien passe, ce sont les valeurs par defaut de HOMARD_Gen
267 //================================================
268 void HOMARDGUI::recupPreferences()
270 MESSAGE("recupPreferences")
274 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( application() );
275 HOMARD::HOMARD_Gen_var homardGen = HOMARDGUI::InitHOMARDGen(app);
277 std::string defaut_s ;
283 defaut_s = homardGen->GetLanguageShort();
284 SUIT_ResourceMgr* resMgr = getApp()->resourceMgr();
285 _LanguageShort = resMgr->stringValue("language", "language", QString(defaut_s.c_str()) );
287 // B.2. Les publications
290 _PublisMeshIN = homardGen->GetPublisMeshIN();
291 if ( _PublisMeshIN == 1 ) { publish_mesh = true ; }
292 else { publish_mesh = false ; }
293 publish_mesh = resMgr->booleanValue("HOMARD", "publish_mesh_in", publish_mesh );
294 if ( publish_mesh ) { _PublisMeshIN = 1 ; }
295 else { _PublisMeshIN = 0 ; }
297 _PublisMeshOUT = homardGen->GetPublisMeshOUT();
298 if ( _PublisMeshOUT == 1 ) { publish_mesh = true ; }
299 else { publish_mesh = false ; }
300 publish_mesh = resMgr->booleanValue("HOMARD", "publish_mesh_out", publish_mesh );
301 if ( publish_mesh ) { _PublisMeshOUT = 1 ; }
302 else { _PublisMeshOUT = 0 ; }
304 // B.3. Les maximum pour YACS
306 defaut_i = homardGen->GetYACSMaxIter();
307 _YACSMaxIter = resMgr->integerValue("HOMARD", "yacs_max_iter", defaut_i );
309 defaut_i = homardGen->GetYACSMaxNode();
310 _YACSMaxNode = resMgr->integerValue("HOMARD", "yacs_max_node", defaut_i );
312 defaut_i = homardGen->GetYACSMaxElem();
313 _YACSMaxElem = resMgr->integerValue("HOMARD", "yacs_max_elem", defaut_i );
315 // B.4. La convergence pour YACS
317 defaut_i = homardGen->GetYACSConvergenceType();
318 if ( defaut_i == 1 ) { QString_v = tr("VTest > VRef") ; }
319 else if ( defaut_i == 2 ) { QString_v = tr("VTest < VRef") ; }
320 else { QString_v = tr("None") ; }
321 QString_v = resMgr->stringValue ( "HOMARD", "yacs_type_test", QString_v );
322 if ( ( QString_v == "VTest > VRef" ) || ( QString_v == "VTest > VRef" ) ) { _YACSTypeTest = 1 ; }
323 else if ( ( QString_v == "VTest < VRef" ) || ( QString_v == "VTest < VRef" ) ) { _YACSTypeTest = 2 ; }
324 else { _YACSTypeTest = 0 ; }
326 // C. Enregistrement dans l'objet general
328 MESSAGE ("Enregistrement de LanguageShort = " << _LanguageShort.toStdString().c_str() );
329 MESSAGE ("Enregistrement de PublisMeshIN = " << _PublisMeshIN<<", PublisMeshOUT = "<< _PublisMeshOUT);
330 MESSAGE ("Enregistrement de YACSMaxIter = " << _YACSMaxIter<<", YACSMaxNode = "<< _YACSMaxNode<<", YACSMaxElem = "<< _YACSMaxElem);
331 MESSAGE ("Enregistrement de YACSTypeTest = " << _YACSTypeTest);
333 homardGen->SetLanguageShort(_LanguageShort.toStdString().c_str());
334 homardGen->SetPublisMesh(_PublisMeshIN, _PublisMeshOUT);
335 homardGen->SetYACSMaximum(_YACSMaxIter, _YACSMaxNode, _YACSMaxElem);
337 homardGen->SetYACSConvergenceType(_YACSTypeTest);
340 //================================================
341 void HOMARDGUI::OnGUIEvent()
342 //================================================
344 MESSAGE("OnGUIEvent()")
346 const QObject* obj = sender();
347 if ( !obj || !obj->inherits( "QAction" ) ) { return; }
348 int id = actionId((QAction*)obj);
349 if ( id != -1 ) { bool ret = OnGUIEvent( id ); }
350 MESSAGE("Fin de OnGUIEvent()");
353 //=======================================================================
354 // Method OnGUIEvent pour Homard
355 //=======================================================================
356 bool HOMARDGUI::OnGUIEvent (int theCommandID)
358 MESSAGE("OnGUIEvent avec theCommandID = "<<theCommandID);
360 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( application() );
361 if ( !app ) return false;
363 SalomeApp_Study* stud = dynamic_cast<SalomeApp_Study*> ( app->activeStudy() );
366 MESSAGE ( "FAILED to cast active study to SalomeApp_Study" );
370 SUIT_Desktop* parent = application()->desktop();
372 HOMARD::HOMARD_Gen_var homardGen = HOMARDGUI::InitHOMARDGen(app);
374 if (!CORBA::is_nil(homardGen))
375 homardGen->UpdateStudy();
377 getApp()->updateObjectBrowser();
379 // B. Choix selon les commandes
380 SCRUTE(theCommandID);
381 switch (theCommandID)
383 case 1101: // Creation d un Cas
385 MESSAGE("command " << theCommandID << " activated");
386 MonCreateCase *aDlg = new MonCreateCase( true,
387 HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ;
392 case 1102: // Poursuite d une iteration
394 MESSAGE("command " << theCommandID << " activated");
395 MonPursueIteration *aDlg = new MonPursueIteration( true,
396 HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ;
401 case 1103: // Creation d une Iteration
403 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
404 MonCreateIteration *IterDlg = new MonCreateIteration( parent, true,
405 HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
410 case 1111: // Compute une iteration
412 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
413 try { homardGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 1); }
414 catch( SALOME::SALOME_Exception& S_ex )
416 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
417 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
418 getApp()->updateObjectBrowser();
424 case 1112: // Compute une iteration et publication
426 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
427 try { homardGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 2); }
428 catch( SALOME::SALOME_Exception& S_ex )
430 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
431 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
432 getApp()->updateObjectBrowser();
438 case 1121: // Information sur le maillage de l'iteration
440 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
441 MonIterInfo *IterDlg = new MonIterInfo( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
446 case 1131: // Publication du maillage de l'iteration
448 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
449 homardGen->PublishMeshIterInSmesh(_ObjectName.toStdString().c_str());
453 case 1132: // Publication du maillage de l'iteration a partir du fichier
455 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
456 homardGen->PublishResultInSmesh(_ObjectName.toStdString().c_str(), 1);
460 case 1201: // Edition d'un objet
462 MESSAGE("command " << theCommandID << " activated");
463 QString nomObjet = HOMARD_QT_COMMUN::SelectionArbreEtude(QString(""), 1);
464 if (nomObjet == QString("")) break;
465 _PTR(SObject) obj = chercheMonObjet();
468 // Edition d'une frontiere discrete
469 if (HOMARD_UTILS::isBoundaryDi(obj))
471 MonEditBoundaryDi *aDlg = new MonEditBoundaryDi(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
474 // Edition d'une frontiere analytique
475 else if (HOMARD_UTILS::isBoundaryAn(obj))
477 MonEditBoundaryAn *aDlg = new MonEditBoundaryAn(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
481 else if (HOMARD_UTILS::isCase(obj))
483 MonEditCase *aDlg = new MonEditCase(true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
486 // Edition d'une hypothese
487 else if (HOMARD_UTILS::isHypo(obj))
489 MonEditHypothesis *aDlg = new MonEditHypothesis(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName, QString(""), QString("")) ;
492 // Edition d'une iteration
493 else if (HOMARD_UTILS::isIter(obj))
495 MonEditIteration *aDlg = new MonEditIteration(parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
498 // Edition d'un schema YACS
499 else if (HOMARD_UTILS::isYACS(obj))
501 MESSAGE("appel de MonEditYACS");
502 MonEditYACS *aDlg = new MonEditYACS(true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName) ;
505 // Edition d'une zone
506 else if (HOMARD_UTILS::isZone(obj))
508 MonEditZone *aDlg = new MonEditZone(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
515 case 1211: // Suppression d'un objet
517 MESSAGE("command " << theCommandID << " activated");
518 QString nomObjet = HOMARD_QT_COMMUN::SelectionArbreEtude(QString(""), 1);
519 if (nomObjet == QString("")) break;
520 _PTR(SObject) obj = chercheMonObjet();
523 // Suppression d'une frontiere
524 if ( HOMARD_UTILS::isBoundaryDi(obj) || HOMARD_UTILS::isBoundaryAn(obj) )
527 { homardGen->DeleteBoundary(_ObjectName.toStdString().c_str()); }
528 catch( SALOME::SALOME_Exception& S_ex )
530 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
531 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
532 getApp()->updateObjectBrowser();
536 // Suppression d'un cas
537 else if (HOMARD_UTILS::isCase(obj))
540 { homardGen->DeleteCase(_ObjectName.toStdString().c_str(), 1); }
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'une hypothese
550 else if (HOMARD_UTILS::isHypo(obj))
553 { homardGen->DeleteHypo(_ObjectName.toStdString().c_str()); }
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 iteration
563 else if (HOMARD_UTILS::isIter(obj))
566 { homardGen->DeleteIteration(_ObjectName.toStdString().c_str(), 1); }
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'un schema YACS
576 else if (HOMARD_UTILS::isYACS(obj))
579 { homardGen->DeleteYACS(_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'une zone
589 else if (HOMARD_UTILS::isZone(obj))
592 { homardGen->DeleteZone(_ObjectName.toStdString().c_str()); }
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();
605 case 1301: // Information sur un maillage
607 MESSAGE("etape 1301")
608 MESSAGE("command " << theCommandID << " activated");
609 MonMeshInfo *aDlg = new MonMeshInfo( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ;
614 case 1302: // Affichage de fichier texte
616 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
617 _PTR(SObject) obj = chercheMonObjet();
618 if ( (obj) && ( HOMARD_UTILS::isFileType(obj,QString("log")) || HOMARD_UTILS::isFileType(obj,QString("Summary")) || HOMARD_UTILS::isFileType(obj,QString("xml")) ) )
620 MonEditFile *aDlg = new MonEditFile( 0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName, 0 ) ;
621 if ( aDlg->_codret == 0 ) { aDlg->show(); }
626 case 1401: // Création d'un schema YACS
628 MESSAGE("etape 1401")
629 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
630 MonCreateYACS *aDlg = new MonCreateYACS( true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
635 case 1402: // Ecriture d'un schéma YACS
637 MESSAGE("etape 1402")
638 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
639 try { homardGen->YACSWrite(_ObjectName.toStdString().c_str()); }
640 catch( SALOME::SALOME_Exception& S_ex )
642 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
643 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
644 getApp()->updateObjectBrowser();
651 getApp()->updateObjectBrowser();
655 //=============================================================================
659 //=============================================================================
661 // Module's engine IOR
662 //=============================================================================
663 QString HOMARDGUI::engineIOR() const
664 //=============================================================================
666 CORBA::String_var anIOR = getApp()->orb()->object_to_string( InitHOMARDGen(getApp()) );
667 return QString( anIOR.in() );
670 // Module's activation
671 //=============================================================================
672 bool HOMARDGUI::activateModule( SUIT_Study* theStudy )
673 //=============================================================================
675 bool bOk = SalomeApp_Module::activateModule( theStudy );
677 setMenuShown( true );
678 setToolShown( true );
683 // Module's deactivation
684 //=============================================================================
685 bool HOMARDGUI::deactivateModule( SUIT_Study* theStudy )
686 //=============================================================================
688 setMenuShown( false );
689 setToolShown( false );
691 return SalomeApp_Module::deactivateModule( theStudy );
695 //=============================================================================
696 void HOMARDGUI::windows( QMap<int, int>& theMap ) const
697 //=============================================================================
700 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
701 #ifndef DISABLE_PYCONSOLE
702 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
706 //=============================================================================
707 void HOMARDGUI::setOrb()
708 //=============================================================================
712 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
713 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
714 _orb = init( 0 , 0 );
718 INFOS("internal error : orb not found");
721 ASSERT(! CORBA::is_nil(_orb));
723 //========================================
724 _PTR(SObject) HOMARDGUI::chercheMonObjet()
725 //========================================
727 SALOMEDSClient_SObject* aSO = NULL;
730 getApp()->selectionMgr()->selectedObjects( lst );
731 if ( lst.Extent() == 1 )
733 Handle(SALOME_InteractiveObject) io = lst.First();
734 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
735 _PTR(Study) study = appStudy->studyDS();
736 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
737 _ObjectName = QString( obj->GetName().c_str() );
740 else { return _PTR(SObject)(aSO); }
742 //=============================================================================
743 void HOMARDGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
744 //=============================================================================
746 MESSAGE("Debut de contextMenuPopup");
747 _PTR(SObject) obj = chercheMonObjet();
750 title = QString( obj->GetName().c_str() );
752 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
755 bool DeleteObject = false ;
756 bool EditObject = false ;
758 if ( HOMARD_UTILS::isBoundaryAn(obj) )
761 DeleteObject = true ;
763 else if ( HOMARD_UTILS::isBoundaryDi(obj) )
766 DeleteObject = true ;
768 else if ( HOMARD_UTILS::isCase(obj) )
770 pix = resMgr->loadPixmap( "HOMARD", "table_view.png" );
771 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_YACS").toLatin1().data()), this, SLOT(YACSCreate()));
773 DeleteObject = true ;
775 else if ( HOMARD_UTILS::isHypo(obj) )
778 DeleteObject = true ;
780 else if ( HOMARD_UTILS::isIter(obj) )
782 pix = resMgr->loadPixmap( "HOMARD", "iter_next.png" );
783 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_NEW_ITERATION").toLatin1().data()), this, SLOT(NextIter()));
784 pix = resMgr->loadPixmap( "HOMARD", "mesh_compute.png" );
785 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_COMPUTE").toLatin1().data()), this, SLOT(LanceCalcul0()));
786 pix = resMgr->loadPixmap( "HOMARD", "mesh_compute.png" );
787 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_COMPUTE_PUBLISH").toLatin1().data()), this, SLOT(LanceCalcul1()));
788 pix = resMgr->loadPixmap( "HOMARD", "advanced_mesh_info.png" );
789 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_INFO").toLatin1().data()), this, SLOT(IterInfo()));
790 pix = resMgr->loadPixmap( "HOMARD", "mesh_tree_mesh.png" );
791 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_PUBLICATION").toLatin1().data()), this, SLOT(MeshPublish0()));
793 DeleteObject = true ;
795 else if ( HOMARD_UTILS::isYACS(obj) )
797 pix = resMgr->loadPixmap( "HOMARD", "write.png" );
798 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_WRITE").toLatin1().data()), this, SLOT(YACSWrite()));
800 DeleteObject = true ;
802 else if ( HOMARD_UTILS::isZone(obj) )
805 DeleteObject = true ;
807 else if ( HOMARD_UTILS::isFileType(obj,QString("log")) || HOMARD_UTILS::isFileType(obj,QString("Summary")) || HOMARD_UTILS::isFileType(obj,QString("xml")) )
809 pix = resMgr->loadPixmap( "HOMARD", "texte.png" );
810 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_EDIT_MESS_FILE").toLatin1().data()), this, SLOT(EditAsciiFile()));
812 else if ( HOMARD_UTILS::isFileType(obj,QString("Mesh")) )
814 pix = resMgr->loadPixmap( "HOMARD", "mesh_tree_mesh.png" );
815 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_PUBLICATION").toLatin1().data()), this, SLOT(MeshPublish1()));
817 // Ajout d'un menu d'edition pour les objets qui le proposent
820 pix = resMgr->loadPixmap( "HOMARD", "loop.png" );
821 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_EDIT").toLatin1().data()), this, SLOT(Edit()));
823 // Ajout d'un menu de destruction pour les objets qui le proposent
826 pix = resMgr->loadPixmap( "HOMARD", "delete.png" );
827 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_DELETE").toLatin1().data()), this, SLOT(Delete()));
832 void HOMARDGUI::NextIter()
834 this->OnGUIEvent(1103);
837 void HOMARDGUI::LanceCalcul0()
839 this->OnGUIEvent(1111);
842 void HOMARDGUI::LanceCalcul1()
844 this->OnGUIEvent(1112);
847 void HOMARDGUI::IterInfo()
849 this->OnGUIEvent(1121);
852 void HOMARDGUI::MeshPublish0()
854 this->OnGUIEvent(1131);
857 void HOMARDGUI::MeshPublish1()
859 this->OnGUIEvent(1132);
862 void HOMARDGUI::Edit()
864 this->OnGUIEvent(1201);
867 void HOMARDGUI::Delete()
869 this->OnGUIEvent(1211);
872 void HOMARDGUI::EditAsciiFile()
874 this->OnGUIEvent(1302);
877 void HOMARDGUI::YACSCreate()
879 this->OnGUIEvent(1401);
881 void HOMARDGUI::YACSWrite()
883 this->OnGUIEvent(1402);
888 //=============================================================================
890 //=============================================================================
892 Standard_EXPORT CAM_Module* createModule()
894 return new HOMARDGUI("");