1 // Copyright (C) 2011-2015 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();
371 HOMARD::HOMARD_Gen_var homardGen = HOMARDGUI::InitHOMARDGen(app);
373 if (!CORBA::is_nil(homardGen))
376 SalomeApp_Study* aSAStudy =dynamic_cast<SalomeApp_Study*>(app->activeStudy());
377 _PTR(Study) aStudy = aSAStudy->studyDS();
378 SALOMEDS::Study_ptr aStudyDS;
380 aStudyDS = _CAST(Study,aStudy)->GetStudy();
381 homardGen->SetCurrentStudy(aStudyDS);
383 getApp()->updateObjectBrowser();
385 // B. Choix selon les commandes
386 SCRUTE(theCommandID);
387 switch (theCommandID)
389 case 1101: // Creation d un Cas
391 MESSAGE("command " << theCommandID << " activated");
392 MonCreateCase *aDlg = new MonCreateCase( true,
393 HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ;
398 case 1102: // Poursuite d une iteration
400 MESSAGE("command " << theCommandID << " activated");
401 MonPursueIteration *aDlg = new MonPursueIteration( true,
402 HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ;
407 case 1103: // Creation d une Iteration
409 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
410 MonCreateIteration *IterDlg = new MonCreateIteration( parent, true,
411 HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
416 case 1111: // Compute une iteration
418 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
419 try { homardGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 1); }
420 catch( SALOME::SALOME_Exception& S_ex )
422 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
423 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
424 getApp()->updateObjectBrowser();
430 case 1112: // Compute une iteration et publication
432 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
433 try { homardGen->Compute(_ObjectName.toStdString().c_str(), 0, 1, -1, 2); }
434 catch( SALOME::SALOME_Exception& S_ex )
436 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
437 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
438 getApp()->updateObjectBrowser();
444 case 1121: // Information sur le maillage de l'iteration
446 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
447 MonIterInfo *IterDlg = new MonIterInfo( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
452 case 1131: // Publication du maillage de l'iteration
454 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
455 homardGen->PublishMeshIterInSmesh(_ObjectName.toStdString().c_str());
459 case 1132: // Publication du maillage de l'iteration a partir du fichier
461 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
462 homardGen->PublishResultInSmesh(_ObjectName.toStdString().c_str(), 1);
466 case 1201: // Edition d'un objet
468 MESSAGE("command " << theCommandID << " activated");
469 QString nomObjet = HOMARD_QT_COMMUN::SelectionArbreEtude(QString(""), 1);
470 if (nomObjet == QString("")) break;
471 _PTR(SObject) obj = chercheMonObjet();
474 // Edition d'une frontiere discrete
475 if (HOMARD_UTILS::isBoundaryDi(obj))
477 MonEditBoundaryDi *aDlg = new MonEditBoundaryDi(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
480 // Edition d'une frontiere analytique
481 else if (HOMARD_UTILS::isBoundaryAn(obj))
483 MonEditBoundaryAn *aDlg = new MonEditBoundaryAn(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
487 else if (HOMARD_UTILS::isCase(obj))
489 MonEditCase *aDlg = new MonEditCase(true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
492 // Edition d'une hypothese
493 else if (HOMARD_UTILS::isHypo(obj))
495 MonEditHypothesis *aDlg = new MonEditHypothesis(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName, QString(""), QString("")) ;
498 // Edition d'une iteration
499 else if (HOMARD_UTILS::isIter(obj))
501 MonEditIteration *aDlg = new MonEditIteration(parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
504 // Edition d'un schema YACS
505 else if (HOMARD_UTILS::isYACS(obj))
507 MESSAGE("appel de MonEditYACS");
508 MonEditYACS *aDlg = new MonEditYACS(true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName) ;
511 // Edition d'une zone
512 else if (HOMARD_UTILS::isZone(obj))
514 MonEditZone *aDlg = new MonEditZone(0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), QString(""), _ObjectName ) ;
521 case 1211: // Suppression d'un objet
523 MESSAGE("command " << theCommandID << " activated");
524 QString nomObjet = HOMARD_QT_COMMUN::SelectionArbreEtude(QString(""), 1);
525 if (nomObjet == QString("")) break;
526 _PTR(SObject) obj = chercheMonObjet();
529 // Suppression d'une frontiere
530 if ( HOMARD_UTILS::isBoundaryDi(obj) || HOMARD_UTILS::isBoundaryAn(obj) )
533 { homardGen->DeleteBoundary(_ObjectName.toStdString().c_str()); }
534 catch( SALOME::SALOME_Exception& S_ex )
536 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
537 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
538 getApp()->updateObjectBrowser();
542 // Suppression d'un cas
543 else if (HOMARD_UTILS::isCase(obj))
546 { homardGen->DeleteCase(_ObjectName.toStdString().c_str(), 1); }
547 catch( SALOME::SALOME_Exception& S_ex )
549 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
550 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
551 getApp()->updateObjectBrowser();
555 // Suppression d'une hypothese
556 else if (HOMARD_UTILS::isHypo(obj))
559 { homardGen->DeleteHypo(_ObjectName.toStdString().c_str()); }
560 catch( SALOME::SALOME_Exception& S_ex )
562 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
563 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
564 getApp()->updateObjectBrowser();
568 // Suppression d'une iteration
569 else if (HOMARD_UTILS::isIter(obj))
572 { homardGen->DeleteIteration(_ObjectName.toStdString().c_str(), 1); }
573 catch( SALOME::SALOME_Exception& S_ex )
575 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
576 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
577 getApp()->updateObjectBrowser();
581 // Suppression d'un schema YACS
582 else if (HOMARD_UTILS::isYACS(obj))
585 { homardGen->DeleteYACS(_ObjectName.toStdString().c_str(), 1); }
586 catch( SALOME::SALOME_Exception& S_ex )
588 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
589 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
590 getApp()->updateObjectBrowser();
594 // Suppression d'une zone
595 else if (HOMARD_UTILS::isZone(obj))
598 { homardGen->DeleteZone(_ObjectName.toStdString().c_str()); }
599 catch( SALOME::SALOME_Exception& S_ex )
601 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
602 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
603 getApp()->updateObjectBrowser();
611 case 1301: // Information sur un maillage
613 MESSAGE("etape 1301")
614 MESSAGE("command " << theCommandID << " activated");
615 MonMeshInfo *aDlg = new MonMeshInfo( parent, true, HOMARD::HOMARD_Gen::_duplicate(homardGen) ) ;
620 case 1302: // Affichage de fichier texte
622 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
623 _PTR(SObject) obj = chercheMonObjet();
624 if ( (obj) && ( HOMARD_UTILS::isFileType(obj,QString("log")) || HOMARD_UTILS::isFileType(obj,QString("Summary")) || HOMARD_UTILS::isFileType(obj,QString("xml")) ) )
626 MonEditFile *aDlg = new MonEditFile( 0, true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName, 0 ) ;
627 if ( aDlg->_codret == 0 ) { aDlg->show(); }
632 case 1401: // Création d'un schema YACS
634 MESSAGE("etape 1401")
635 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
636 MonCreateYACS *aDlg = new MonCreateYACS( true, HOMARD::HOMARD_Gen::_duplicate(homardGen), _ObjectName ) ;
641 case 1402: // Ecriture d'un schéma YACS
643 MESSAGE("etape 1402")
644 MESSAGE("command " << theCommandID << " activated avec objet " << _ObjectName.toStdString().c_str() );
645 try { homardGen->YACSWrite(_ObjectName.toStdString().c_str()); }
646 catch( SALOME::SALOME_Exception& S_ex )
648 QMessageBox::critical( 0, QObject::tr("HOM_ERROR"),
649 QObject::tr(CORBA::string_dup(S_ex.details.text)) );
650 getApp()->updateObjectBrowser();
657 getApp()->updateObjectBrowser();
661 //=============================================================================
665 //=============================================================================
667 // Module's engine IOR
668 //=============================================================================
669 QString HOMARDGUI::engineIOR() const
670 //=============================================================================
672 CORBA::String_var anIOR = getApp()->orb()->object_to_string( InitHOMARDGen(getApp()) );
673 return QString( anIOR.in() );
676 // Module's activation
677 //=============================================================================
678 bool HOMARDGUI::activateModule( SUIT_Study* theStudy )
679 //=============================================================================
681 bool bOk = SalomeApp_Module::activateModule( theStudy );
683 setMenuShown( true );
684 setToolShown( true );
689 // Module's deactivation
690 //=============================================================================
691 bool HOMARDGUI::deactivateModule( SUIT_Study* theStudy )
692 //=============================================================================
694 setMenuShown( false );
695 setToolShown( false );
697 return SalomeApp_Module::deactivateModule( theStudy );
701 //=============================================================================
702 void HOMARDGUI::windows( QMap<int, int>& theMap ) const
703 //=============================================================================
706 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
707 #ifndef DISABLE_PYCONSOLE
708 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
712 //=============================================================================
713 void HOMARDGUI::setOrb()
714 //=============================================================================
718 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
719 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
720 _orb = init( 0 , 0 );
724 INFOS("internal error : orb not found");
727 ASSERT(! CORBA::is_nil(_orb));
729 //========================================
730 _PTR(SObject) HOMARDGUI::chercheMonObjet()
731 //========================================
733 SALOMEDSClient_SObject* aSO = NULL;
736 getApp()->selectionMgr()->selectedObjects( lst );
737 if ( lst.Extent() == 1 )
739 Handle(SALOME_InteractiveObject) io = lst.First();
740 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
741 _PTR(Study) study = appStudy->studyDS();
742 _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
743 _ObjectName = QString( obj->GetName().c_str() );
746 else { return _PTR(SObject)(aSO); }
748 //=============================================================================
749 void HOMARDGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
750 //=============================================================================
752 MESSAGE("Debut de contextMenuPopup");
753 _PTR(SObject) obj = chercheMonObjet();
756 title = QString( obj->GetName().c_str() );
758 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
761 bool DeleteObject = false ;
762 bool EditObject = false ;
764 if ( HOMARD_UTILS::isBoundaryAn(obj) )
767 DeleteObject = true ;
769 else if ( HOMARD_UTILS::isBoundaryDi(obj) )
772 DeleteObject = true ;
774 else if ( HOMARD_UTILS::isCase(obj) )
776 pix = resMgr->loadPixmap( "HOMARD", "table_view.png" );
777 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_YACS").toLatin1().data()), this, SLOT(YACSCreate()));
779 DeleteObject = true ;
781 else if ( HOMARD_UTILS::isHypo(obj) )
784 DeleteObject = true ;
786 else if ( HOMARD_UTILS::isIter(obj) )
788 pix = resMgr->loadPixmap( "HOMARD", "iter_next.png" );
789 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_NEW_ITERATION").toLatin1().data()), this, SLOT(NextIter()));
790 pix = resMgr->loadPixmap( "HOMARD", "mesh_compute.png" );
791 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_COMPUTE").toLatin1().data()), this, SLOT(LanceCalcul0()));
792 pix = resMgr->loadPixmap( "HOMARD", "mesh_compute.png" );
793 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_COMPUTE_PUBLISH").toLatin1().data()), this, SLOT(LanceCalcul1()));
794 pix = resMgr->loadPixmap( "HOMARD", "advanced_mesh_info.png" );
795 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_INFO").toLatin1().data()), this, SLOT(IterInfo()));
796 pix = resMgr->loadPixmap( "HOMARD", "mesh_tree_mesh.png" );
797 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_PUBLICATION").toLatin1().data()), this, SLOT(MeshPublish0()));
799 DeleteObject = true ;
801 else if ( HOMARD_UTILS::isYACS(obj) )
803 pix = resMgr->loadPixmap( "HOMARD", "write.png" );
804 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_WRITE").toLatin1().data()), this, SLOT(YACSWrite()));
806 DeleteObject = true ;
808 else if ( HOMARD_UTILS::isZone(obj) )
811 DeleteObject = true ;
813 else if ( HOMARD_UTILS::isFileType(obj,QString("log")) || HOMARD_UTILS::isFileType(obj,QString("Summary")) || HOMARD_UTILS::isFileType(obj,QString("xml")) )
815 pix = resMgr->loadPixmap( "HOMARD", "texte.png" );
816 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_EDIT_MESS_FILE").toLatin1().data()), this, SLOT(EditAsciiFile()));
818 else if ( HOMARD_UTILS::isFileType(obj,QString("Mesh")) )
820 pix = resMgr->loadPixmap( "HOMARD", "mesh_tree_mesh.png" );
821 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_MESH_PUBLICATION").toLatin1().data()), this, SLOT(MeshPublish1()));
823 // Ajout d'un menu d'edition pour les objets qui le proposent
826 pix = resMgr->loadPixmap( "HOMARD", "loop.png" );
827 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_EDIT").toLatin1().data()), this, SLOT(Edit()));
829 // Ajout d'un menu de destruction pour les objets qui le proposent
832 pix = resMgr->loadPixmap( "HOMARD", "delete.png" );
833 menu->addAction(QIcon(pix), tr(QString("HOM_MEN_DELETE").toLatin1().data()), this, SLOT(Delete()));
838 void HOMARDGUI::NextIter()
840 this->OnGUIEvent(1103);
843 void HOMARDGUI::LanceCalcul0()
845 this->OnGUIEvent(1111);
848 void HOMARDGUI::LanceCalcul1()
850 this->OnGUIEvent(1112);
853 void HOMARDGUI::IterInfo()
855 this->OnGUIEvent(1121);
858 void HOMARDGUI::MeshPublish0()
860 this->OnGUIEvent(1131);
863 void HOMARDGUI::MeshPublish1()
865 this->OnGUIEvent(1132);
868 void HOMARDGUI::Edit()
870 this->OnGUIEvent(1201);
873 void HOMARDGUI::Delete()
875 this->OnGUIEvent(1211);
878 void HOMARDGUI::EditAsciiFile()
880 this->OnGUIEvent(1302);
883 void HOMARDGUI::YACSCreate()
885 this->OnGUIEvent(1401);
887 void HOMARDGUI::YACSWrite()
889 this->OnGUIEvent(1402);
894 //=============================================================================
896 //=============================================================================
898 Standard_EXPORT CAM_Module* createModule()
900 return new HOMARDGUI("");