Salome HOME
Enable C++0x/C++11 support
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis_i.cxx
index 1c3841a2c0dec161691ecd80a336b67b121f1ba8..beaddc1b30b9a60713a33f5d78db4ff812e72d7d 100644 (file)
@@ -808,16 +808,30 @@ BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() {
   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
 
   const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
-  result->length(opts.size());
+  const ::BLSURFPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomOptionValues();
+  result->length(opts.size()+custom_opts.size());
+  int i=0;
 
   ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
-  for (int i = 0; opIt != opts.end(); ++opIt, ++i) {
-    string name_value = opIt->first;
+  for (; opIt != opts.end(); ++opIt, ++i) {
+    string name_value_type = opIt->first;
     if (!opIt->second.empty()) {
-      name_value += ":";
-      name_value += opIt->second;
+      name_value_type += ":";
+      name_value_type += opIt->second;
+      name_value_type += ":0";
     }
-    result[i] = CORBA::string_dup(name_value.c_str());
+    result[i] = CORBA::string_dup(name_value_type.c_str());
+  }
+
+  opIt = custom_opts.begin();
+  for (; opIt != custom_opts.end(); ++opIt,++i) {
+    string name_value_type = opIt->first;
+    if (!opIt->second.empty()) {
+      name_value_type += ":";
+      name_value_type += opIt->second;
+      name_value_type += ":1";
+    }
+    result[i] = CORBA::string_dup(name_value_type.c_str());
   }
   return result._retn();
 }
@@ -829,16 +843,30 @@ BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetPreCADOptionValues() {
   BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
 
   const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetPreCADOptionValues();
-  result->length(opts.size());
+  const ::BLSURFPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomPreCADOptionValues();
+  result->length(opts.size()+custom_opts.size());
+  int i=0;
 
   ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
-  for (int i = 0; opIt != opts.end(); ++opIt, ++i) {
-    string name_value = opIt->first;
+  for (; opIt != opts.end(); ++opIt, ++i) {
+    string name_value_type = opIt->first;
+    if (!opIt->second.empty()) {
+      name_value_type += ":";
+      name_value_type += opIt->second;
+      name_value_type += ":0";
+    }
+    result[i] = CORBA::string_dup(name_value_type.c_str());
+  }
+
+  opIt = custom_opts.begin();
+  for (; opIt != custom_opts.end(); ++opIt,++i) {
+    string name_value_type = opIt->first;
     if (!opIt->second.empty()) {
-      name_value += ":";
-      name_value += opIt->second;
+      name_value_type += ":";
+      name_value_type += opIt->second;
+      name_value_type += ":1";
     }
-    result[i] = CORBA::string_dup(name_value.c_str());
+    result[i] = CORBA::string_dup(name_value_type.c_str());
   }
   return result._retn();
 }
@@ -849,17 +877,25 @@ void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array
     throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
   for (int i = 0; i < options.length(); ++i) {
-    string name_value = options[i].in();
-    int colonPos = name_value.find(':');
+    string name_value_type = options[i].in();
+    if(name_value_type.empty())
+      continue;
+    int colonPos = name_value_type.find(':');
     string name, value;
+    bool custom = false;
     if (colonPos == string::npos) // ':' not found
-      name = name_value;
+      name = name_value_type;
     else {
-      name = name_value.substr(0, colonPos);
-      if (colonPos < name_value.size() - 1 && name_value[colonPos] != ' ')
-        value = name_value.substr(colonPos + 1);
+      name = name_value_type.substr(0, colonPos);
+      if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
+        string value_type = name_value_type.substr(colonPos + 1);
+        colonPos = value_type.find(':');
+        value = value_type.substr(0, colonPos);
+        if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
+          custom = atoi((value_type.substr(colonPos + 1)).c_str());
+      }
     }
-    SetOptionValue(name.c_str(), value.c_str());
+    custom ? AddOption(name.c_str(), value.c_str()) : SetOptionValue(name.c_str(), value.c_str());
   }
 }
 
@@ -869,26 +905,76 @@ void BLSURFPlugin_Hypothesis_i::SetPreCADOptionValues(const BLSURFPlugin::string
     throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
   for (int i = 0; i < options.length(); ++i) {
-    string name_value = options[i].in();
-    int colonPos = name_value.find(':');
+    string name_value_type = options[i].in();
+    if(name_value_type.empty())
+      continue;
+    int colonPos = name_value_type.find(':');
     string name, value;
+    bool custom = false;
     if (colonPos == string::npos) // ':' not found
-      name = name_value;
+      name = name_value_type;
     else {
-      name = name_value.substr(0, colonPos);
-      if (colonPos < name_value.size() - 1 && name_value[colonPos] != ' ')
-        value = name_value.substr(colonPos + 1);
+      name = name_value_type.substr(0, colonPos);
+      if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
+        string value_type = name_value_type.substr(colonPos + 1);
+        colonPos = value_type.find(':');
+        value = value_type.substr(0, colonPos);
+        if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
+          custom = atoi((value_type.substr(colonPos + 1)).c_str());
+      }
     }
-    SetPreCADOptionValue(name.c_str(), value.c_str());
+    custom ? AddPreCADOption(name.c_str(), value.c_str()) : SetPreCADOptionValue(name.c_str(), value.c_str());
+  }
+}
+
+//=============================================================================
+
+void BLSURFPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue)
+{
+  ASSERT(myBaseImpl);
+  bool valueChanged = (this->GetImpl()->GetOption(optionName) != optionValue);
+  if (valueChanged) {
+    this->GetImpl()->AddOption(optionName, optionValue);
+    SMESH::TPythonDump() << _this() << ".AddOption( '" << optionName << "', '" << optionValue << "' )";
+  }
+}
+
+//=============================================================================
+
+void BLSURFPlugin_Hypothesis_i::AddPreCADOption(const char* optionName, const char* optionValue)
+{
+  ASSERT(myBaseImpl);
+  bool valueChanged = (this->GetImpl()->GetPreCADOption(optionName) != optionValue);
+  if (valueChanged) {
+    this->GetImpl()->AddPreCADOption(optionName, optionValue);
+    SMESH::TPythonDump() << _this() << ".AddPreCADOption( '" << optionName << "', '" << optionValue << "' )";
   }
 }
 
 //=============================================================================
 
+char* BLSURFPlugin_Hypothesis_i::GetOption(const char* optionName)
+{
+  ASSERT(myBaseImpl);
+  return CORBA::string_dup(this->GetImpl()->GetOption(optionName).c_str());
+}
+
+//=============================================================================
+
+char* BLSURFPlugin_Hypothesis_i::GetPreCADOption(const char* optionName)
+{
+  ASSERT(myBaseImpl);
+  return CORBA::string_dup(this->GetImpl()->GetPreCADOption(optionName).c_str());
+}
+
+//=============================================================================
+
 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry, const char* sizeMap)
     throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
   MESSAGE("ENGINE : SETSIZEMAP START ENTRY : " << entry);
+  if ( !entry || !entry[0] )
+    THROW_SALOME_CORBA_EXCEPTION( "SetSizeMapEntry(): empty geom entry", SALOME::BAD_PARAM );
   bool valueChanged = false;
   try {
     valueChanged = (this->GetImpl()->GetSizeMapEntry(entry) != sizeMap);
@@ -994,8 +1080,8 @@ void BLSURFPlugin_Hypothesis_i::SetClassAttractorEntry(const char* entry, const
   }
   MESSAGE("ENGINE : SETATTRACTOR END ENTRY : " << entry);
   //if ( valueChanged )
-  SMESH::TPythonDump() << _this() << ".SetAttractorGeom( '"
-                       << entry << "', '" << att_entry << "', "<<StartSize<<", "<<EndSize<<", "<<ActionRadius<<", "<<ConstantRadius<<" )";
+  SMESH::TPythonDump() << _this() << ".SetAttractorGeom( "
+                       << entry << ", " << att_entry << ", "<<StartSize<<", "<<EndSize<<", "<<ActionRadius<<", "<<ConstantRadius<<" )";
 }
 
 //=============================================================================
@@ -1176,7 +1262,9 @@ void BLSURFPlugin_Hypothesis_i::ClearSizeMaps() {
 
 //=============================================================================
 
-void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap) {
+void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
+  throw (SALOME::SALOME_Exception)
+{
   ASSERT(myBaseImpl);
   string entry;
   entry = GeomObj->GetStudyEntry();