Salome HOME
Deleted Study parameter
[plugins/ghs3dplugin.git] / src / GUI / GHS3DPluginGUI_HypothesisCreator.cxx
index 6dd1db9ddc388703ddb81549c0e62d31a8e421ce..051b40347b22f295b1187c3d74a117f099bd05a1 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2004-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2004-2016  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
 
 #include <boost/algorithm/string.hpp>
 
-namespace {
-
-#ifdef WIN32
-#include <windows.h>
-#else
-#include <sys/sysinfo.h>
-#endif
-
-  long maxAvailableMemory()
-  {
-#ifdef WIN32
-    // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
-    MEMORYSTATUSEX statex;
-    statex.dwLength = sizeof (statex);
-    long err = GlobalMemoryStatusEx (&statex);
-    if (err != 0) {
-      long totMB = 
-        statex.ullTotalPhys / 1024 / 1024 +
-        statex.ullTotalPageFile / 1024 / 1024 +
-        statex.ullTotalVirtual / 1024 / 1024;
-      return (long) ( 0.7 * totMB );
-    }
-#else
-    struct sysinfo si;
-    long err = sysinfo( &si );
-    if ( err == 0 ) {
-      long totMB =
-        si.totalram * si.mem_unit / 1024 / 1024 +
-        si.totalswap * si.mem_unit / 1024 / 1024 ;
-      return (long) ( 0.7 * totMB );
-    }
-#endif
-    return 0;
-  }
-}
-
 //
 // BEGIN EnforcedVertexTableWidgetDelegate
 //
@@ -345,14 +309,13 @@ GHS3DPluginGUI_HypothesisCreator::~GHS3DPluginGUI_HypothesisCreator()
 }
 
 /**
- * \brief {Get or create the geom selection tool for active study}
+ * \brief {Get or create the geom selection tool for study}
  * */
 GeomSelectionTools* GHS3DPluginGUI_HypothesisCreator::getGeomSelectionTool()
 {
   GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
-  _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
-  if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
-    that->GeomToolSelected = new GeomSelectionTools(aStudy);
+  if (that->GeomToolSelected == NULL) {
+    that->GeomToolSelected = new GeomSelectionTools();
   }
   return that->GeomToolSelected;
 }
@@ -441,8 +404,7 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
   myAdvWidget->boundaryRecoveryCheck         ->setText (tr( "RECOVERY_VERSION" ));
   myAdvWidget->FEMCorrectionCheck            ->setText (tr( "FEM_CORRECTION" ));
   myAdvWidget->gradationLabel                ->setText (tr( "GHS3D_GRADATION" ));
-  myAdvWidget->gradationSpinBox->RangeStepAndValidator(1.05, 5.0, 0.05, "length_precision");
-  myAdvWidget->textOptionLabel->setText(tr( "TEXT_OPTION" ));
+  myAdvWidget->gradationSpinBox->RangeStepAndValidator(0.0, 5.0, 0.05, "length_precision");
 
   // Enforced vertices parameters
   myEnfGroup = new QWidget();
@@ -464,7 +426,11 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
   myEnforcedTableWidget->setAlternatingRowColors(true);
   myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
   myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
   myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+#else
+  myEnforcedTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
+#endif
   myEnforcedTableWidget->resizeColumnsToContents();
   myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
   myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
@@ -551,7 +517,11 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
                       << tr( "GHS3D_ENF_GROUP_COLUMN" );
   myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
   myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
   myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+#else
+  myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
+#endif
   myEnforcedMeshTableWidget->setAlternatingRowColors(true);
   myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
   myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
@@ -775,7 +745,7 @@ void GHS3DPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
       return;
     if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
       GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
-      GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
+      GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( );
       if (CORBA::is_nil(measureOp))
         return;
       
@@ -1182,7 +1152,7 @@ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
   int elementType = myEnfMeshConstraint->currentIndex();
   
   
-  _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+  _PTR(Study) aStudy = SMESH::getStudy();
   _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
   QString meshEntry = myEnfMeshWdg->GetValue();
   MESSAGE("myEnfMeshWdg->GetValue()" << meshEntry.toStdString());
@@ -1193,7 +1163,7 @@ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
 //     myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
 //     std::string entry = myEnfMeshWdg->GetValue();
     aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
-    CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
+    CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
     if (!CORBA::is_nil(anObj)) {
 //       SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
       addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
@@ -1206,7 +1176,7 @@ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
     QStringListIterator meshEntriesIt (meshEntries);
     while (meshEntriesIt.hasNext()) {
       aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
-      CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
+      CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
       if (!CORBA::is_nil(anObj)) {
 //         SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
         addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
@@ -1283,7 +1253,7 @@ void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()
     if ( CORBA::is_nil(getGeomEngine()))
       return;
 
-    GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
+    GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( );
     if (CORBA::is_nil(measureOp))
       return;
 
@@ -1435,7 +1405,7 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const
   myAdvWidget->boundaryRecoveryCheck          ->setChecked    ( data.myBoundaryRecovery );
   myAdvWidget->FEMCorrectionCheck             ->setChecked    ( data.myFEMCorrection );
   myAdvWidget->gradationSpinBox               ->setValue      ( data.myGradation );
-  myAdvWidget->textOptionLineEdit             ->setText       ( data.myTextOption );
+  myAdvWidget->advOptionTable                 ->SetCustomOptions( data.myTextOption );
   myAdvWidget->logInFileCheck                 ->setChecked    ( !data.myLogInStandardOutput );
   myAdvWidget->removeLogOnSuccessCheck        ->setChecked    ( data.myRemoveLogOnSuccess );
 
@@ -1679,14 +1649,14 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData&
   h_data.myBoundaryRecovery           = h->GetToUseBoundaryRecoveryVersion();
   h_data.myFEMCorrection              = h->GetFEMCorrection();
   h_data.myGradation                  = h->GetGradation();
-  h_data.myTextOption                 = h->GetTextOption();
+  h_data.myTextOption                 = h->GetAdvancedOption();
   h_data.myLogInStandardOutput        = h->GetStandardOutputLog();
   h_data.myRemoveLogOnSuccess         = h->GetRemoveLogOnSuccess();
   
   GHS3DPlugin::GHS3DEnforcedVertexList_var vertices = h->GetEnforcedVertices();
   MESSAGE("vertices->length(): " << vertices->length());
   h_data.myEnforcedVertices.clear();
-  for (int i=0 ; i<vertices->length() ; i++) {
+  for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
     TEnfVertex* myVertex = new TEnfVertex();
     myVertex->name = CORBA::string_dup(vertices[i].name.in());
     myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
@@ -1694,7 +1664,7 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData&
     myVertex->size = vertices[i].size;
     myVertex->isCompound = vertices[i].isCompound;
     if (vertices[i].coords.length()) {
-      for (int c = 0; c < vertices[i].coords.length() ; c++)
+      for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
         myVertex->coords.push_back(vertices[i].coords[c]);
       MESSAGE("Add enforced vertex ("<< myVertex->coords.at(0) << ","<< myVertex->coords.at(1) << ","<< myVertex->coords.at(2) << ") ="<< myVertex->size);
     }
@@ -1704,7 +1674,7 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData&
   GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
   MESSAGE("enfMeshes->length(): " << enfMeshes->length());
   h_data.myEnforcedMeshes.clear();
-  for (int i=0 ; i<enfMeshes->length() ; i++) {
+  for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
     TEnfMesh* myEnfMesh = new TEnfMesh();
     myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
     myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
@@ -1768,8 +1738,8 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD
       h->SetFEMCorrection    ( h_data.myFEMCorrection     );
     if ( h->GetGradation() != h_data.myGradation         )
       h->SetGradation        ( h_data.myGradation         );
-    if ( h->GetTextOption() != h_data.myTextOption       )
-      h->SetTextOption       ( h_data.myTextOption.toLatin1().constData() );
+    if ( h->GetAdvancedOption() != h_data.myTextOption       )
+      h->SetAdvancedOption       ( h_data.myTextOption.toLatin1().constData() );
     if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput   )
       h->SetStandardOutputLog( h_data.myLogInStandardOutput  );
      if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess   )
@@ -1816,7 +1786,7 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD
     
     TEnfMeshList::const_iterator itEnfMesh;
 
-    _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+    _PTR(Study) aStudy = SMESH::getStudy();
 
     for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
       TEnfMesh* enfMesh = (*itEnfMesh);
@@ -1873,7 +1843,7 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisDat
   h_data.myBoundaryRecovery           = myAdvWidget->boundaryRecoveryCheck->isChecked();
   h_data.myFEMCorrection              = myAdvWidget->FEMCorrectionCheck->isChecked();
   h_data.myGradation                  = myAdvWidget->gradationSpinBox->value();
-  h_data.myTextOption                 = myAdvWidget->textOptionLineEdit->text();
+  h_data.myTextOption                 = myAdvWidget->advOptionTable->GetCustomOptions();
   h_data.myLogInStandardOutput        = !myAdvWidget->logInFileCheck->isChecked();
   h_data.myRemoveLogOnSuccess         = myAdvWidget->removeLogOnSuccessCheck->isChecked();