Salome HOME
Copyright update 2022
[modules/homard.git] / src / HOMARDGUI / MonEditHypothesis.cxx
index 0192379f8744632adba5dfb1116d756938468ba9..363d0aceb8e20f7dc5ccd6a4b2b31580a22a32d7 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2011-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2011-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-using namespace std;
-
 #include "MonEditHypothesis.h"
 #include "MonEditListGroup.h"
 
 #include "SalomeApp_Tools.h"
 #include "HOMARDGUI_Utils.h"
 #include "HomardQtCommun.h"
+#include "HOMARD.hxx"
 #include <utilities.h>
+
+using namespace std;
+
 // ----------------------------------------------------------------------------
 MonEditHypothesis::MonEditHypothesis( MonCreateIteration* parent, bool modal,
                                       HOMARD::HOMARD_Gen_var myHomardGen,
-                                      QString aHypothesisName,
+                                      QString Name,
                                       QString caseName,  QString aFieldFile ):
 // ----------------------------------------------------------------------------
 /* Constructs a MonEditHypothesis
     herite de MonCreateHypothesis
 */
-    MonCreateHypothesis(parent, modal,myHomardGen, aHypothesisName, caseName, aFieldFile)
+    MonCreateHypothesis(parent, modal,myHomardGen, Name, caseName, aFieldFile)
 {
-    MESSAGE("Hypothese " << aHypothesisName.toStdString().c_str());
+    MESSAGE("Hypothese " << Name.toStdString().c_str());
     setWindowTitle(QObject::tr("HOM_HYPO_EDIT_WINDOW_TITLE"));
-    _aHypothesis    = _myHomardGen->GetHypothesis(_aHypothesisName.toStdString().c_str());
-    if (caseName == QString("") ){ _aCaseName = _aHypothesis->GetCaseCreation();}
+    aHypothesis    = myHomardGen->GetHypothesis(_Name.toStdString().c_str());
+    if (caseName == QString("") ){ _aCaseName = aHypothesis->GetCaseCreation();}
     InitValEdit();
     InitGroupes();
 }
@@ -53,7 +55,7 @@ MonEditHypothesis::~MonEditHypothesis()
 void MonEditHypothesis::InitGroupes()
 // ------------------------------
 {
-    HOMARD::ListGroupType_var maListe = _aHypothesis->GetGroups();
+    HOMARD::ListGroupType_var maListe = aHypothesis->GetGroups();
     for ( int i = 0; i < maListe->length(); i++ )
        _aListeGroupes << QString(maListe[i]);
 
@@ -65,9 +67,9 @@ void MonEditHypothesis::InitValEdit()
 // ------------------------------
 {
   MESSAGE("Debut de InitValEdit");
-  LEHypothesisName->setText(_aHypothesisName);
-  LEHypothesisName->setReadOnly(true);
-  HOMARD::listeTypes_var ListTypes (_aHypothesis->GetAdapRefinUnRef());
+  LEName->setText(_Name);
+  LEName->setReadOnly(true);
+  HOMARD::listeTypes_var ListTypes (aHypothesis->GetAdapRefinUnRef());
   ASSERT( ListTypes->length()==3) ;
   _aTypeAdap = ListTypes[0];
   _aTypeRaff = ListTypes[1];
@@ -82,7 +84,7 @@ void MonEditHypothesis::InitValEdit()
 
   InitFieldInterp();
 
-  if (_aTypeAdap == 1 or _TypeFieldInterp >= 1 )
+  if (_aTypeAdap == 1 || _TypeFieldInterp >= 1 )
   {
     if (_aFieldFile == QString("")) { GBFieldFile->setVisible(0); }
     else
@@ -98,18 +100,18 @@ void MonEditHypothesis::InitValEdit()
   }
 // Les options avancees (non modifiables)
   CBAdvanced->setVisible(0) ;
-  int NivMax = _aHypothesis->GetNivMax();
-  double DiamMin = _aHypothesis->GetDiamMin();
-  int AdapInit = _aHypothesis->GetAdapInit();
-  int LevelOutput = _aHypothesis->GetLevelOutput();
-  if ( NivMax > 0 or DiamMin > 0 or AdapInit != 0 or LevelOutput != 0 )
+  int NivMax = aHypothesis->GetNivMax();
+  double DiamMin = aHypothesis->GetDiamMin();
+  int AdapInit = aHypothesis->GetAdapInit();
+  int ExtraOutput = aHypothesis->GetExtraOutput();
+  if ( NivMax > 0 || DiamMin > 0 || AdapInit != 0 || ExtraOutput != 1 )
   { GBAdvancedOptions->setVisible(1);
     if ( NivMax > 0 )
-    { spinBoxNivMax->setValue(NivMax);
-      spinBoxNivMax->setDisabled(true); }
+    { SpinBoxNivMax->setValue(NivMax);
+      SpinBoxNivMax->setDisabled(true); }
     else
     { TLMaximalLevel->setVisible(0);
-      spinBoxNivMax->setVisible(0); }
+      SpinBoxNivMax->setVisible(0); }
     if ( DiamMin > 0 )
     { doubleSpinBoxDiamMin->setValue(DiamMin);
       doubleSpinBoxDiamMin->setDisabled(true); }
@@ -129,19 +131,40 @@ void MonEditHypothesis::InitValEdit()
     else
     { GBAdapInit->setVisible(0) ;
     }
-    if ( LevelOutput != 0 )
+    if ( ExtraOutput % 2 == 0 )
     {
-      CBLevelOutput->setChecked(true);
-      CBLevelOutput->setEnabled(false);
+      CBOutputLevel->setChecked(true);
+      CBOutputLevel->setEnabled(false);
     }
-    else
-    { CBLevelOutput->setVisible(0) ;
+    else { CBOutputLevel->setVisible(0) ; }
+    if ( ExtraOutput % 3 == 0 )
+    {
+      CBOutputQuality->setChecked(true);
+      CBOutputQuality->setEnabled(false);
+    }
+    else { CBOutputQuality->setVisible(0) ; }
+    if ( ExtraOutput % 5 == 0 )
+    {
+      CBOutputDiameter->setChecked(true);
+      CBOutputDiameter->setEnabled(false);
+    }
+    else { CBOutputDiameter->setVisible(0) ; }
+    if ( ExtraOutput % 7 == 0 )
+    {
+      CBOutputParent->setChecked(true);
+      CBOutputParent->setEnabled(false);
+    }
+    else { CBOutputParent->setVisible(0) ; }
+    if ( ExtraOutput % 11 == 0 )
+    {
+      CBOutputVoisins->setChecked(true);
+      CBOutputVoisins->setEnabled(false);
     }
+    else { CBOutputVoisins->setVisible(0) ; }
   }
   else
   { GBAdvancedOptions->setVisible(0); }
 //
-  adjustSize();
 }
 // ----------------------------------------
 void MonEditHypothesis::InitAdaptUniforme()
@@ -149,28 +172,29 @@ void MonEditHypothesis::InitAdaptUniforme()
 // Affichage des informations pour une adaptation uniforme
 {
 //  Choix des options generales
-    GBFieldManagement->setVisible(0);
-    GBAreaManagement->setVisible(0);
-    GBUniform->setVisible(1);
-    adjustSize();
-    RBUniforme->setChecked(true);
-    RBUniforme->setEnabled(false);
-    RBChamp->setEnabled(false);
-    RBZone->setEnabled(false);
+  GBFieldManagement->setVisible(0);
+  GBAreaManagement->setVisible(0);
+  GBUniform->setVisible(1);
+  RBUniforme->setChecked(true);
+  RBUniforme->setEnabled(false);
+  RBChamp->setEnabled(false);
+  RBZone->setEnabled(false);
 //
 // Raffinement ou deraffinement ?
-    if (_aTypeDera == 0)
-    {
-        ASSERT(_aTypeRaff==1);
-        RBUniDera->setChecked(false);
-        RBUniRaff->setChecked(true);
-    }
-    if (_aTypeDera == 1)
-    {
-        ASSERT(_aTypeRaff==0);
-        RBUniDera->setChecked(true);
-        RBUniRaff->setChecked(false);
-    }
+  if (_aTypeDera == 0)
+  {
+      VERIFICATION(_aTypeRaff==1);
+      RBUniDera->setChecked(false);
+      RBUniRaff->setChecked(true);
+  }
+  if (_aTypeDera == 1)
+  {
+      VERIFICATION(_aTypeRaff==0);
+      RBUniDera->setChecked(true);
+      RBUniRaff->setChecked(false);
+  }
+//
+  adjustSize();
 //
 }
 // -------------------------------------
@@ -178,52 +202,53 @@ void MonEditHypothesis::InitAdaptZone()
 // -------------------------------------
 // Affichage des informations pour une adaptation selon des zones :
 {
-    MESSAGE ("Debut de InitAdaptZone");
+  MESSAGE ("Debut de InitAdaptZone");
 //  Choix des options generales
-    GBUniform->setVisible(0);
-    GBFieldManagement->setVisible(0);
-    GBAreaManagement->setVisible(1);
-    adjustSize();
-    RBZone->setChecked(true);
-    RBChamp->setEnabled(false);
-    RBUniforme->setEnabled(false);
-    RBZone->setEnabled(false);
+  GBUniform->setVisible(0);
+  GBFieldManagement->setVisible(0);
+  GBAreaManagement->setVisible(1);
+  RBZone->setChecked(true);
+  RBChamp->setEnabled(false);
+  RBUniforme->setEnabled(false);
+  RBZone->setEnabled(false);
 
 //  Recuperation de toutes les zones decrites et notation de celles retenues
-    GetAllZones();
-    HOMARD::listeZonesHypo_var mesZonesAvant = _aHypothesis->GetZones();
-    for (int i=0; i<mesZonesAvant->length(); i++)
-    {
+  GetAllZones();
+  HOMARD::listeZonesHypo_var mesZonesAvant = aHypothesis->GetZones();
+  for (int i=0; i<mesZonesAvant->length(); i++)
+  {
     MESSAGE ("i"<<i<<", zone :"<<string(mesZonesAvant[i])<<", type :"<<string(mesZonesAvant[i+1]));
-      for ( int j =0 ; j < TWZone->rowCount(); j++)
+    for ( int j =0 ; j < TWZone->rowCount(); j++)
+    {
+      MESSAGE (". j"<<j<<", zone :"<<TWZone->item(j,2)->text().toStdString());
+      if ( TWZone->item(j,2)->text().toStdString() == string(mesZonesAvant[i]) )
       {
-    MESSAGE (". j"<<j<<", zone :"<<TWZone->item(j,2)->text().toStdString());
-        if ( TWZone->item(j,2)->text().toStdString() == string(mesZonesAvant[i]) )
+        MESSAGE ("OK avec "<<string(mesZonesAvant[i]));
+        if ( string(mesZonesAvant[i+1]) == "1" )
+        {
+          MESSAGE ("... RAFF");
+          TWZone->item( j,0 )->setCheckState( Qt::Checked );
+          TWZone->item( j,1 )->setCheckState( Qt::Unchecked ); }
+        else
         {
-    MESSAGE ("OK avec "<<string(mesZonesAvant[i]));
-          if ( string(mesZonesAvant[i+1]) == "1" )
-          {
-    MESSAGE ("... RAFF");
-            TWZone->item( j,0 )->setCheckState( Qt::Checked );
-            TWZone->item( j,1 )->setCheckState( Qt::Unchecked ); }
-          else
-          {
-    MESSAGE ("... DERA");
-            TWZone->item( j,0 )->setCheckState( Qt::Unchecked );
-            TWZone->item( j,1 )->setCheckState( Qt::Checked ); }
-          break;
-        }
+          MESSAGE ("... DERA");
+          TWZone->item( j,0 )->setCheckState( Qt::Unchecked );
+          TWZone->item( j,1 )->setCheckState( Qt::Checked ); }
+        break;
       }
-      i += 1 ;
     }
+    i += 1 ;
+  }
 //
 //  Inactivation des choix
-    for ( int j =0 ; j < TWZone->rowCount(); j++)
-    {
-      TWZone->item( j, 0 )->setFlags(0);
-      TWZone->item( j, 1 )->setFlags(0);
-    }
-    PBZoneNew->setVisible(0);
+  for ( int j =0 ; j < TWZone->rowCount(); j++)
+  {
+    TWZone->item( j, 0 )->setFlags(0);
+    TWZone->item( j, 1 )->setFlags(0);
+  }
+  PBZoneNew->setVisible(0);
+//
+  adjustSize();
 //
 }
 // -------------------------------------
@@ -240,15 +265,12 @@ void MonEditHypothesis::InitAdaptChamps()
     GBUniform->setVisible(0);
     GBAreaManagement->setVisible(0);
     GBFieldManagement->setVisible(1);
-    adjustSize();
     RBChamp->setChecked(true);
     RBUniforme->setEnabled(false);
     RBChamp->setEnabled(false);
     RBZone->setEnabled(false);
 
-
-
-    HOMARD::InfosHypo_var  aInfosHypo = _aHypothesis->GetField();
+    HOMARD::InfosHypo_var  aInfosHypo = aHypothesis->GetField();
     _aFieldName =  aInfosHypo->FieldName;
     _TypeThR = aInfosHypo->TypeThR;
     _ThreshR = aInfosHypo->ThreshR;
@@ -257,13 +279,12 @@ void MonEditHypothesis::InitAdaptChamps()
     _UsField = aInfosHypo->UsField;
     _UsCmpI  = aInfosHypo->UsCmpI;
 
-
     CBFieldName->insertItem(0,_aFieldName);
     CBFieldName->setCurrentIndex(0);
     CBFieldName->setEnabled(false);
     //SetFieldName(Qt::Unchecked);
 
-    HOMARD::listeComposantsHypo_var mesComposantsAvant = _aHypothesis->GetListComp();
+    HOMARD::listeComposantsHypo_var mesComposantsAvant = aHypothesis->GetComps();
     TWCMP->clear();
     TWCMP->setRowCount(0);
     TWCMP->resizeRowsToContents();
@@ -285,6 +306,7 @@ void MonEditHypothesis::InitAdaptChamps()
   RBRAbs->setEnabled(false) ;
   RBRRel->setEnabled(false) ;
   RBRPE->setEnabled(false) ;
+  RBRMuSigma->setEnabled(false) ;
   RBRNo->setEnabled(false) ;
   if (_aTypeRaff== 0 )
   {
@@ -296,12 +318,14 @@ void MonEditHypothesis::InitAdaptChamps()
     if ( _TypeThR == 1 ) { SpinBox_RAbs->setValue(_ThreshR); SetRAbs(); RBRAbs->setEnabled(true);}
     if ( _TypeThR == 2 ) { SpinBox_RRel->setValue(_ThreshR); SetRRel(); RBRRel->setEnabled(true);}
     if ( _TypeThR == 3 ) { SpinBox_RPE->setValue(_ThreshR);  SetRPE();  RBRPE->setEnabled(true);}
+    if ( _TypeThR == 4 ) { SpinBox_RMuSigma->setValue(_ThreshR);  SetRMS();  RBRMuSigma->setEnabled(true);}
   }
 
   // Les seuils de deraffinement
   RBCAbs->setEnabled(false) ;
   RBCRel->setEnabled(false) ;
   RBCPE->setEnabled(false) ;
+  RBCMuSigma->setEnabled(false) ;
   RBCNo->setEnabled(false) ;
   if (_aTypeDera== 0 )
   {
@@ -313,6 +337,7 @@ void MonEditHypothesis::InitAdaptChamps()
     if ( _TypeThC == 1 ) { SpinBox_CAbs->setValue(_ThreshC); SetCAbs(); RBCAbs->setEnabled(true);}
     if ( _TypeThC == 2 ) { SpinBox_CRel->setValue(_ThreshC); SetCRel(); RBCRel->setEnabled(true);}
     if ( _TypeThC == 3 ) { SpinBox_CPE->setValue(_ThreshC);  SetCPE(); RBCPE->setEnabled(true);}
+    if ( _TypeThC == 4 ) { SpinBox_CMuSigma->setValue(_ThreshC);  SetCMS();  RBCMuSigma->setEnabled(true);}
   }
   // Le choix de la prise en compte des composantes
   if ( TWCMP->rowCount() == 1 )
@@ -341,6 +366,8 @@ void MonEditHypothesis::InitAdaptChamps()
     RBInf->setChecked(true);
     RBInf->setEnabled(true);
   }
+//
+  adjustSize();
 }
 // -------------------------------------
 void MonEditHypothesis::InitFieldInterp()
@@ -349,7 +376,7 @@ void MonEditHypothesis::InitFieldInterp()
 {
     MESSAGE ("Debut de InitFieldInterp");
 //  Choix des options generales
-    _TypeFieldInterp = _aHypothesis->GetTypeFieldInterp();
+    _TypeFieldInterp = aHypothesis->GetTypeFieldInterp();
     MESSAGE ("_TypeFieldInterp = " << _TypeFieldInterp);
 //
 //  Aucune interpolation
@@ -370,19 +397,20 @@ void MonEditHypothesis::InitFieldInterp()
       RBFieldChosen->setChecked(true);
 //
       TWField->setVisible(1);
-      HOMARD::listFieldInterpHypo_var mesChampsAvant = _aHypothesis->GetListFieldInterp();
+      HOMARD::listeFieldInterpsHypo_var mesChampsAvant = aHypothesis->GetFieldInterps();
       TWField->clear();
       TWField->setRowCount(0);
       TWField->resizeRowsToContents();
-      for (int i=0; i<mesChampsAvant->length(); i++)
+      for (int iaux=0; iaux<mesChampsAvant->length(); iaux++)
       {
         TWField->insertRow(0);
         TWField->setItem( 0, 0, new QTableWidgetItem( QString ("") ) );
         TWField->item( 0, 0 )->setFlags( Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
         TWField->item( 0, 0 )->setCheckState(Qt::Checked );
         TWField->item( 0, 0 )->setFlags( 0 );
-        TWField->setItem( 0, 1, new QTableWidgetItem(QString(mesChampsAvant[i]).trimmed()));
+        TWField->setItem( 0, 1, new QTableWidgetItem(QString(mesChampsAvant[iaux]).trimmed()));
         TWField->item( 0, 1 )->setFlags( Qt::ItemIsEnabled |Qt::ItemIsSelectable );
+        iaux++;
       }
       TWField->resizeColumnsToContents();
       TWField->resizeRowsToContents();
@@ -405,17 +433,19 @@ bool MonEditHypothesis::PushOnApply()
       if (_TypeThR == 1) { _ThreshR = SpinBox_RAbs->value(); }
       if (_TypeThR == 2) { _ThreshR = SpinBox_RRel->value(); }
       if (_TypeThR == 3) { _ThreshR = SpinBox_RPE->value();  }
-      _aHypothesis->SetRefinThr(_TypeThR, _ThreshR) ;
+      if (_TypeThR == 4) { _ThreshR = SpinBox_RMuSigma->value();  }
+      aHypothesis->SetRefinThr(_TypeThR, _ThreshR) ;
     }
     if (_aTypeDera!= 0 )
     {
       if (_TypeThC == 1) { _ThreshC = SpinBox_CAbs->value() ; }
       if (_TypeThC == 2) { _ThreshC = SpinBox_CRel->value() ; }
       if (_TypeThC == 3) { _ThreshC = SpinBox_CPE->value() ; }
-      _aHypothesis->SetUnRefThr(_TypeThC, _ThreshC) ;
+      if (_TypeThC == 4) { _ThreshC = SpinBox_CMuSigma->value() ; }
+      aHypothesis->SetUnRefThr(_TypeThC, _ThreshC) ;
     }
 
-    _myHomardGen->InvalideHypo(_aHypothesisName.toStdString().c_str());
+    myHomardGen->InvalideHypo(_Name.toStdString().c_str());
     HOMARD_UTILS::updateObjBrowser();
   }
   return true;
@@ -426,7 +456,7 @@ void MonEditHypothesis::SetFiltrage()
 {
   if (CBGroupe->isChecked())
   {
-    MonEditListGroup *aDlg = new MonEditListGroup(this, NULL, TRUE, HOMARD::HOMARD_Gen::_duplicate(_myHomardGen),_aCaseName, _aListeGroupes) ;
+    MonEditListGroup *aDlg = new MonEditListGroup(this, NULL, true, HOMARD::HOMARD_Gen::_duplicate(myHomardGen),_aCaseName, _aListeGroupes) ;
     aDlg->show();
   }
 }