Salome HOME
This commit was generated by cvs2git to create branch 'V4_1_0_maintainance'.
[modules/filter.git] / src / FILTERGUI / FilterGUI.cxx
index d78565512a04146bbc9255be49d83657d38829e7..5735dcddc28dcc6335a4219eff39ece3b2f90602 100644 (file)
@@ -57,6 +57,8 @@
 
 // QT Includes
 #include <qinputdialog.h>
+#include <qmessagebox.h>
+#include <qcursor.h>
 
 //VRV: porting on Qt 3.0.5
 #if QT_VERSION >= 0x030005
@@ -138,7 +140,7 @@ void FilterGUI::initialize( CAM_Application* app )
 {
   SalomeApp_Module::initialize( app );
 
-  QWidget* parent = application()->desktop();
+//   QWidget* parent = application()->desktop();
 
   createFilterAction(  111, "OPEN" );
 
@@ -164,12 +166,32 @@ void FilterGUI::contextMenuPopup( const QString& client, QPopupMenu* menu, QStri
   }
 }
 
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+SALOME_FILTER::FILTER_Gen_ptr FilterGUI::InitFilterGen() const
+{
+  SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
+  Engines::Component_var comp =
+    SALOME_LifeCycleCORBA(app->namingService()).FindOrLoad_Component( "FactoryServer", "FILTER" );
+
+  MESSAGE("_________________________________________");
+  SALOME_FILTER::FILTER_Gen_var clr = SALOME_FILTER::FILTER_Gen::_narrow(comp);
+  ASSERT(!CORBA::is_nil(clr));
+  return clr._retn();
+}
+
 QString FilterGUI::engineIOR() const
 {
-//   SALOME_FILTER::MED_Gen_ptr aMedGen = InitMedGen();
-//   if ( !CORBA::is_nil( aMedGen) )
-//     return QString( getApp()->orb()->object_to_string( aMedGen ));
-  return QString( "" );
+  QString anIOR( "" );
+  SALOME_FILTER::FILTER_Gen_ptr aFilterGen = InitFilterGen();
+  if ( !CORBA::is_nil( aFilterGen) ){
+    CORBA::String_var objStr = getApp()->orb()->object_to_string( aFilterGen );
+    anIOR = QString( objStr.in() );
+  }
+  return anIOR;
 }
 
 void FilterGUI::windows( QMap<int, int>& mappa ) const
@@ -280,12 +302,31 @@ bool FilterGUI::OnGUIEvent (int theCommandID)
       {
        MESSAGE("command " << theCommandID << " activated");
 
-       try {
-         SelectParams *filter = new SelectParams(_sel);
-         QFrame *fr = filter->buildFrame();
-         fr->show();
+       if(_sel){
+         SelectParams *filter;
+         try {
+           application()->desktop()->setCursor(QCursor(Qt::WaitCursor));
+           filter = new SelectParams(this,_sel);
+           filter->exec();
+           application()->desktop()->setCursor(QCursor(Qt::ArrowCursor));
+           _sel = NULL;
+         }
+         catch ( SALOME_Exception& S_ex ) {
+           delete _sel;
+           _sel=NULL;
+           MESSAGE("Select an input Field in MED file before filtering!!");
+           QMessageBox::information( application()->desktop(),
+                                     "Filtering",
+                                     "Unable to select parameters for filtering.\n"
+                                     "You must select a reference field in a MED file before." );
+         }
        }
-       catch ( SALOME_Exception& S_ex ) {
+       else{
+         MESSAGE("Select an input Field in MED file before filtering!!");
+         QMessageBox::information( application()->desktop(),
+                                   "Filtering",
+                                   "Unable to select parameters for filtering.\n"
+                                   "You must select a reference field in a MED file before." );
        }
        break;
       }
@@ -299,17 +340,14 @@ bool FilterGUI::OnGUIEvent (int theCommandID)
                                        filtersList,
                                        tr("FILTER_MEN_IMPORT"),
                                        true);
-       if (!file.isEmpty() )
-         {
-           if(_sel) delete _sel;
-           _sel = new SelectField(file);
-           QFrame *fr = _sel->buildFrame();
-           fr->show();
+       if (!file.isEmpty() ){
+         _sel = new SelectField(this,file);
+         if ( _sel->exec() == QDialog::Rejected ){
+           delete _sel;
+           _sel = NULL;
          }
-       else{
-         if(_sel) delete _sel;
-         _sel = NULL;
        }
+
         break;
       }
     }