- \b tiny_edge_length (real) - the length below which en edge is considered as nano for the topology processing.
By default this option is \f$10^{-5}\f$.
+\note Moreover, user can choose "<Other option>" item in these two pop-up menus
+(MG-CADSurf and PreCAD) to be able to specify both the option name and the option value.
+
\ref blsurf_top "Back to top"
\section blsurf_local_size Local size
void UnsetOption(in string optionName);
void UnsetPreCADOption(in string optionName);
+ /*!
+ * Adds custom advanced option and its value
+ */
+ void AddOption(in string optionName, in string optionValue);
+ void AddPreCADOption(in string optionName, in string optionValue);
+ string GetOption(in string optionName);
+ string GetPreCADOption(in string optionName);
+
/*!
* Return array of strings each of which is option name concatenated
- * with option value devided by semicolon - "option_name:option_value".
+ * with option value devided by semicolon - "option_name:option_value:option_type".
* Option value is empty if an option is not set.
* Note: the method is mostly for interaction with GUI.
*/
string_array GetPreCADOptionValues();
/*!
- * Set option values each in the form "option_name[:option_value]".
+ * Set option values each in the form "option_name[:option_value][:option_type]".
* Note: the method is mostly for interaction with GUI.
*/
void SetOptionValues(in string_array options) raises (SALOME::SALOME_Exception);
SetPreCADOptionValue,
UnsetOption,
UnsetPreCADOption,
+ AddOption,
+ AddPreCADOption,
SetSizeMap,
SetConstantSizeMap,
UnsetSizeMap,
self.SetTopology(PreCAD)
self.Parameters().SetPreCADOptionValue(optionName,optionValue)
pass
+
+ ## Adds custom advanced option value.
+ # @param optionName custom advanced option name
+ # @param level custom advanced option value
+ def AddOption(self, optionName, level):
+ self.Parameters().AddOption(optionName,level)
+ pass
+
+ ## Adds custom advanced PreCAD option value.
+ # @param optionName custom name of the option
+ # @param optionValue value of the option
+ def AddPreCADOption(self, optionName, optionValue):
+ if self.Parameters().GetTopology() != PreCAD:
+ self.SetTopology(PreCAD)
+ self.Parameters().AddPreCADOption(optionName,optionValue)
+ pass
## Sets GMF file for export at computation
# @param fileName GMF file name
_precadProcess3DTopology = hyp->GetPreCADProcess3DTopology();
_precadDiscardInput = hyp->GetPreCADDiscardInput();
- const BLSURFPlugin_Hypothesis::TOptionValues & opts = hyp->GetOptionValues();
+ const BLSURFPlugin_Hypothesis::TOptionValues& opts = hyp->GetOptionValues();
BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt;
for ( opIt = opts.begin(); opIt != opts.end(); ++opIt )
if ( !opIt->second.empty() ) {
set_param(css, opIt->first.c_str(), opIt->second.c_str());
}
- const BLSURFPlugin_Hypothesis::TOptionValues & preCADopts = hyp->GetPreCADOptionValues();
+ const BLSURFPlugin_Hypothesis::TOptionValues& custom_opts = hyp->GetCustomOptionValues();
+ for ( opIt = custom_opts.begin(); opIt != custom_opts.end(); ++opIt )
+ if ( !opIt->second.empty() ) {
+ MESSAGE("cadsurf_set_param(): " << opIt->first << " = " << opIt->second);
+ set_param(css, opIt->first.c_str(), opIt->second.c_str());
+ }
+
+ const BLSURFPlugin_Hypothesis::TOptionValues& preCADopts = hyp->GetPreCADOptionValues();
for ( opIt = preCADopts.begin(); opIt != preCADopts.end(); ++opIt )
if ( !opIt->second.empty() ) {
*use_precad = true;
MESSAGE("precad_set_param(): " << opIt->first << " = " << opIt->second);
precad_set_param(pcs, opIt->first.c_str(), opIt->second.c_str());
}
+
+ const BLSURFPlugin_Hypothesis::TOptionValues& custom_preCADopts = hyp->GetCustomPreCADOptionValues();
+ for ( opIt = custom_preCADopts.begin(); opIt != custom_preCADopts.end(); ++opIt )
+ if ( !opIt->second.empty() ) {
+ *use_precad = true;
+ MESSAGE("precad_set_param(): " << opIt->first << " = " << opIt->second);
+ precad_set_param(pcs, opIt->first.c_str(), opIt->second.c_str());
+ }
}
// else {
// //0020968: EDF1545 SMESH: Problem in the creation of a mesh group on geometry
//=============================================================================
void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) {
- TOptionValues::iterator op_val = _option2value.find(optionName);
- if (op_val != _option2value.end())
- op_val->second.clear();
+ TOptionValues::iterator op_val = _customOption2value.find(optionName);
+ if (op_val != _customOption2value.end())
+ _customOption2value.erase(op_val);
+ else {
+ op_val = _option2value.find(optionName);
+ if (op_val != _option2value.end())
+ op_val->second.clear();
+ }
}
//=============================================================================
void BLSURFPlugin_Hypothesis::ClearPreCADOption(const std::string& optionName) {
+ TOptionValues::iterator op_val = _customPreCADOption2value.find(optionName);
+ if (op_val != _customPreCADOption2value.end())
+ _customPreCADOption2value.erase(op_val);
+ else {
+ op_val = _preCADoption2value.find(optionName);
+ if (op_val != _preCADoption2value.end())
+ op_val->second.clear();
+ }
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::AddOption(const std::string& optionName, const std::string& optionValue)
+{
+ TOptionValues::iterator op_val = _option2value.find(optionName);
+ if (op_val != _option2value.end()) {
+ if (op_val->second != optionValue)
+ op_val->second = optionValue;
+ }
+ else {
+ op_val = _customOption2value.find(optionName);
+ if (op_val == _customOption2value.end())
+ _customOption2value[optionName] = optionValue;
+ else if (op_val->second != optionValue)
+ op_val->second = optionValue;
+ }
+ NotifySubMeshesHypothesisModification();
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::AddPreCADOption(const std::string& optionName, const std::string& optionValue)
+{
TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
- if (op_val != _preCADoption2value.end())
- op_val->second.clear();
+ if (op_val != _preCADoption2value.end()) {
+ if (op_val->second != optionValue)
+ op_val->second = optionValue;
+ }
+ else {
+ op_val = _customPreCADOption2value.find(optionName);
+ if (op_val == _customPreCADOption2value.end())
+ _customPreCADOption2value[optionName] = optionValue;
+ else if (op_val->second != optionValue)
+ op_val->second = optionValue;
+ }
+ NotifySubMeshesHypothesisModification();
+}
+
+//=============================================================================
+std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName)
+{
+ TOptionValues::iterator op_val = _customOption2value.find(optionName);
+ if (op_val != _customOption2value.end())
+ return op_val->second;
+ else
+ return "";
+}
+
+//=============================================================================
+std::string BLSURFPlugin_Hypothesis::GetPreCADOption(const std::string& optionName)
+{
+ TOptionValues::iterator op_val = _customPreCADOption2value.find(optionName);
+ if (op_val != _customPreCADOption2value.end())
+ return op_val->second;
+ else
+ return "";
}
//=======================================================================
save << " " << "__OPTIONS_END__";
}
+ op_val = _customOption2value.begin();
+ if (op_val != _customOption2value.end()) {
+ save << " " << "__CUSTOM_OPTIONS_BEGIN__";
+ for (; op_val != _customOption2value.end(); ++op_val) {
+ if (!op_val->second.empty())
+ save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
+ }
+ save << " " << "__CUSTOM_OPTIONS_END__";
+ }
+
op_val = _preCADoption2value.begin();
if (op_val != _preCADoption2value.end()) {
save << " " << "__PRECAD_OPTIONS_BEGIN__";
save << " " << "__PRECAD_OPTIONS_END__";
}
+ op_val = _customPreCADOption2value.begin();
+ if (op_val != _customPreCADOption2value.end()) {
+ save << " " << "__CUSTOM_PRECAD_OPTIONS_BEGIN__";
+ for (; op_val != _customPreCADOption2value.end(); ++op_val) {
+ if (!op_val->second.empty())
+ save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
+ }
+ save << " " << "__CUSTOM_PRECAD_OPTIONS_END__";
+ }
+
TSizeMap::iterator it_sm = _sizeMap.begin();
if (it_sm != _sizeMap.end()) {
save << " " << "__SIZEMAP_BEGIN__";
bool hasCADSurfOptions = false;
bool hasOptions = false;
+ bool hasCustomOptions = false;
bool hasPreCADOptions = false;
+ bool hasCustomPreCADOptions = false;
bool hasSizeMap = false;
bool hasAttractor = false;
bool hasNewAttractor = false;
}
if (option_or_sm == "__OPTIONS_BEGIN__")
hasOptions = true;
+ else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
+ hasCustomOptions = true;
else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
hasPreCADOptions = true;
+ else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
+ hasCustomPreCADOptions = true;
else if (option_or_sm == "__SIZEMAP_BEGIN__")
hasSizeMap = true;
else if (option_or_sm == "__ATTRACTORS_BEGIN__")
if (isOK)
if (option_or_sm == "__OPTIONS_BEGIN__")
hasOptions = true;
+ else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
+ hasCustomOptions = true;
else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
hasPreCADOptions = true;
+ else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
+ hasCustomPreCADOptions = true;
else if (option_or_sm == "__SIZEMAP_BEGIN__")
hasSizeMap = true;
else if (option_or_sm == "__ATTRACTORS_BEGIN__")
}
if (hasOptions) {
+ isOK = (load >> option_or_sm);
+ if (isOK)
+ if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
+ hasCustomOptions = true;
+ else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
+ hasPreCADOptions = true;
+ else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
+ hasCustomPreCADOptions = true;
+ else if (option_or_sm == "__SIZEMAP_BEGIN__")
+ hasSizeMap = true;
+ else if (option_or_sm == "__ATTRACTORS_BEGIN__")
+ hasAttractor = true;
+ else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
+ hasNewAttractor = true;
+ else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
+ hasEnforcedVertex = true;
+ else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
+ hasPreCADFacesPeriodicity = true;
+ else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+ hasPreCADEdgesPeriodicity = true;
+ else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+ hasFacesPeriodicity = true;
+ else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+ hasEdgesPeriodicity = true;
+ else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+ hasVerticesPeriodicity = true;
+ }
+
+ while (isOK && hasCustomOptions) {
+ isOK = (load >> optName);
+ if (isOK) {
+ if (optName == "__CUSTOM_OPTIONS_END__")
+ break;
+ isOK = (load >> optValue);
+ }
+ if (isOK) {
+ std::string& value = optValue;
+ int len = value.size();
+ // continue reading until "%#" encountered
+ while (value[len - 1] != '#' || value[len - 2] != '%') {
+ isOK = (load >> optValue);
+ if (isOK) {
+ value += " ";
+ value += optValue;
+ len = value.size();
+ } else {
+ break;
+ }
+ }
+ _customOption2value[optName] = value.substr(0,len-2);
+ value[len - 2] = '\0'; //cut off "%#"
+ }
+ }
+
+ if (hasCustomOptions) {
isOK = (load >> option_or_sm);
if (isOK)
if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
hasPreCADOptions = true;
+ else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
+ hasCustomPreCADOptions = true;
else if (option_or_sm == "__SIZEMAP_BEGIN__")
hasSizeMap = true;
else if (option_or_sm == "__ATTRACTORS_BEGIN__")
}
if (hasPreCADOptions) {
+ isOK = (load >> option_or_sm);
+ if (isOK)
+ if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
+ hasCustomPreCADOptions = true;
+ else if (option_or_sm == "__SIZEMAP_BEGIN__")
+ hasSizeMap = true;
+ else if (option_or_sm == "__ATTRACTORS_BEGIN__")
+ hasAttractor = true;
+ else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
+ hasNewAttractor = true;
+ else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
+ hasEnforcedVertex = true;
+ else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
+ hasPreCADFacesPeriodicity = true;
+ else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+ hasPreCADEdgesPeriodicity = true;
+ else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+ hasFacesPeriodicity = true;
+ else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+ hasEdgesPeriodicity = true;
+ else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+ hasVerticesPeriodicity = true;
+ }
+
+ while (isOK && hasCustomPreCADOptions) {
+ isOK = (load >> optName);
+ if (isOK) {
+ if (optName == "__CUSTOM_PRECAD_OPTIONS_END__")
+ break;
+ isOK = (load >> optValue);
+ }
+ if (isOK) {
+ std::string& value = optValue;
+ int len = value.size();
+ // continue reading until "%#" encountered
+ while (value[len - 1] != '#' || value[len - 2] != '%') {
+ isOK = (load >> optValue);
+ if (isOK) {
+ value += " ";
+ value += optValue;
+ len = value.size();
+ } else {
+ break;
+ }
+ }
+ _customPreCADOption2value[optName] = value.substr(0,len-2);
+ value[len - 2] = '\0'; //cut off "%#"
+ }
+ }
+
+ if (hasCustomPreCADOptions) {
isOK = (load >> option_or_sm);
if (isOK)
if (option_or_sm == "__SIZEMAP_BEGIN__")
void ClearPreCADOption(const std::string& optionName);
const TOptionValues& GetOptionValues() const { return _option2value; }
const TOptionValues& GetPreCADOptionValues() const { return _preCADoption2value; }
+ const TOptionValues& GetCustomOptionValues() const { return _customOption2value; }
+ const TOptionValues& GetCustomPreCADOptionValues() const { return _customPreCADOption2value; }
+
+ void AddOption(const std::string& optionName, const std::string& optionValue);
+ void AddPreCADOption(const std::string& optionName, const std::string& optionValue);
+ std::string GetOption(const std::string& optionName);
+ std::string GetPreCADOption(const std::string& optionName);
/*!
* Sets the file for export resulting mesh in GMF format
double _preCADEpsNano;
TOptionValues _option2value, _preCADoption2value;
+ TOptionValues _customOption2value, _customPreCADOption2value;
TOptionNames _doubleOptions, _charOptions;
TOptionNames _preCADdoubleOptions, _preCADcharOptions;
TSizeMap _sizeMap;
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();
}
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 += ":";
- 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();
}
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());
}
}
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);
void SetOptionValues(const BLSURFPlugin::string_array& options) throw (SALOME::SALOME_Exception);
void SetPreCADOptionValues(const BLSURFPlugin::string_array& options) throw (SALOME::SALOME_Exception);
+ void AddOption(const char* optionName, const char* optionValue);
+ void AddPreCADOption(const char* optionName, const char* optionValue);
+ char* GetOption(const char* optionName);
+ char* GetPreCADOption(const char* optionName);
+
void SetSizeMapEntry(const char* entry, const char* sizeMap) throw (SALOME::SALOME_Exception);
void SetConstantSizeMapEntry(const char* entry, GEOM::shape_type shapeType, CORBA::Double sizeMap) throw (SALOME::SALOME_Exception);
{
QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
QString value = myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
- if ( !value.isEmpty() ) {
+ bool custom = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->data(Qt::UserRole).toBool();
+ if ( !value.isEmpty() && !custom ) {
try {
QString optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().trimmed();
if (optionType == "PRECAD")
myTabWidget->setCurrentIndex( STD_TAB );
- connect( myAdvWidget->addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
- connect( myAdvWidget->addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
- connect( myAdvWidget->rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
- connect( myStdWidget->myAllowQuadrangles, SIGNAL( stateChanged( int )),this, SLOT( onStateChange() ));
+ connect( myAdvWidget->addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
+ connect( myAdvWidget->addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
+ connect( myAdvWidget->rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
+ connect( myAdvWidget->myOptionTable, SIGNAL( cellPressed( int, int ) ), this, SLOT( onEditOption( int, int ) ) );
+ connect( myAdvWidget->myOptionTable, SIGNAL( cellChanged( int, int ) ), this, SLOT( onChangeOptionName( int, int ) ) );
+ connect( myStdWidget->myAllowQuadrangles, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChange() ));
// Size Maps
connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
// MESSAGE("retrieveParams():myOptions->length() = " << myOptions->length());
for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
QString option = that->myOptions[i].in();
- QStringList name_value = option.split( ":", QString::KeepEmptyParts );
- if ( name_value.count() > 1 ) {
+ QStringList name_value_type = option.split( ":", QString::KeepEmptyParts );
+ bool custom = ( name_value_type.size() == 3 ) ? name_value_type[2].toInt() : false;
+ if ( name_value_type.count() > 1 ) {
QString idStr = QString("%1").arg( i );
int row = myAdvWidget->myOptionTable->rowCount();
myAdvWidget->myOptionTable->setRowCount( row+1 );
myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "BLSURF" ) );
myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
- myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
- myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
- myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
+ myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value_type[0] ) );
+ if ( custom ) {
+ myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( Qt::ItemIsSelectable |
+ Qt::ItemIsEditable |
+ Qt::ItemIsEnabled );
+ myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setData( Qt::UserRole, QVariant(true) );
+ }
+ else
+ myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
+ myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value_type[1] ) );
myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
Qt::ItemIsEditable |
Qt::ItemIsEnabled );
// MESSAGE("retrieveParams():myPreCADOptions->length() = " << myPreCADOptions->length());
for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) {
QString option = that->myPreCADOptions[i].in();
- QStringList name_value = option.split( ":", QString::KeepEmptyParts );
- if ( name_value.count() > 1 ) {
+ QStringList name_value_type = option.split( ":", QString::KeepEmptyParts );
+ bool custom = ( name_value_type.size() == 3 ) ? name_value_type[2].toInt() : false;
+ if ( name_value_type.count() > 1 ) {
QString idStr = QString("%1").arg( i );
int row = myAdvWidget->myOptionTable->rowCount();
myAdvWidget->myOptionTable->setRowCount( row+1 );
myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "PRECAD" ) );
myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
- myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
- myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
- myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
+ myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value_type[0] ) );
+ if ( custom ) {
+ myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( Qt::ItemIsSelectable |
+ Qt::ItemIsEditable |
+ Qt::ItemIsEnabled );
+ myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setData( Qt::UserRole, QVariant(true) );
+ }
+ else
+ myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
+ myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value_type[1] ) );
myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
Qt::ItemIsEditable |
Qt::ItemIsEnabled );
{
int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
std::string optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().toStdString();
- if ( id >= 0 && ( ( optionType == "BLSURF" && id < myOptions->length() ) || ( optionType == "PRECAD" && id < myPreCADOptions->length() ) ) )
+ bool custom = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->data(Qt::UserRole).toBool();
+ if ( optionType == "BLSURF" && custom ) {
+ id = that->myOptions->length();
+ that->myOptions->length( that->myOptions->length() + 1 );
+ }
+ if ( optionType == "PRECAD" && custom ) {
+ id = that->myPreCADOptions->length();
+ that->myPreCADOptions->length( that->myPreCADOptions->length() + 1 );
+ }
+ if ( custom || ( id >= 0 && ( ( optionType == "BLSURF" && id < myOptions->length() ) || ( optionType == "PRECAD" && id < myPreCADOptions->length() ) ) ) )
{
QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
QString value = myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
if ( value.isNull() )
value = "";
if (optionType == "PRECAD")
- that->myPreCADOptions[ id ] = ( name + ":" + value).toLatin1().constData();
+ that->myPreCADOptions[ id ] = ( name + ":" + value + ":" + ( custom ? "1" : "0" ) ).toLatin1().constData();
else
- that->myOptions[ id ] = ( name + ":" + value).toLatin1().constData();
+ that->myOptions[ id ] = ( name + ":" + value + ":" + ( custom ? "1" : "0" ) ).toLatin1().constData();
if ( value != "" ) {
if (optionType == "PRECAD")
QMenu* menu = (QMenu*)sender();
// fill popup with option names
menu->clear();
- QString name_value, name;
+ QStringList name_value_type;
if ( myOptions.operator->() ) {
QMenu* blsurfMenu = menu->addMenu(tr("OPTION_MENU_BLSURF"));
for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
- name_value = myOptions[i].in();
- name = name_value.split( ":", QString::KeepEmptyParts )[0];
- blsurfMenu->addAction( name );
+ name_value_type = QString( myOptions[i].in() ).split( ":", QString::KeepEmptyParts );
+ bool custom = ( name_value_type.size() == 3 ) ? name_value_type[2].toInt() : false;
+ if ( !custom && !name_value_type[0].isEmpty() )
+ blsurfMenu->addAction( name_value_type[0] );
}
+ // this user-customized action must be last in the menu
+ blsurfMenu->addAction( QString( "<" + tr("BLSURF_OTHER_OPTION") + ">" ) );
}
if ( myPreCADOptions.operator->() ) {
QMenu* preCADmenu = menu->addMenu(tr("OPTION_MENU_PRECAD"));
for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) {
- name_value = myPreCADOptions[i].in();
- name = name_value.split( ":", QString::KeepEmptyParts )[0];
- preCADmenu->addAction( name );
+ name_value_type = QString( myPreCADOptions[i].in() ).split( ":", QString::KeepEmptyParts );
+ bool custom = ( name_value_type.size() == 3 ) ? name_value_type[2].toInt() : false;
+ if ( !custom && !name_value_type[0].isEmpty() )
+ preCADmenu->addAction( name_value_type[0] );
}
+ // this user-customized action must be last in the menu
+ preCADmenu->addAction( QString( "<" + tr("BLSURF_OTHER_OPTION") + ">" ) );
}
}
QMenu* menu = (QMenu*)( a->parent() );
int idx = menu->actions().indexOf( a );
+ bool custom = menu->actions().last() == a;
+
QString idStr = QString("%1").arg( idx );
QString option, optionType;
if (menu->title() == tr("OPTION_MENU_BLSURF")) {
- option = myOptions[idx].in();
+ if (idx < myOptions->length())
+ option = myOptions[idx].in();
optionType = "BLSURF";
}
else if (menu->title() == tr("OPTION_MENU_PRECAD")) {
- option = myPreCADOptions[idx].in();
+ if (idx < myPreCADOptions->length())
+ option = myPreCADOptions[idx].in();
optionType = "PRECAD";
}
QString optionName = option.split( ":", QString::KeepEmptyParts )[0];
if ( myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
if ( myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text() == optionType )
break;
+ if (custom)
+ row = nbRows;
// add a row if not found
if ( row == nbRows ) {
myAdvWidget->myOptionTable->setRowCount( row+1 );
myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( optionType ) );
myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
- myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
- myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
+ if (custom) {
+ myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( "" ) );
+ myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( Qt::ItemIsSelectable |
+ Qt::ItemIsEditable |
+ Qt::ItemIsEnabled );
+ myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setData( Qt::UserRole, QVariant(true) );
+ }
+ else {
+ myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
+ myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
+ }
myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
Qt::ItemIsEditable |
myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
}
myAdvWidget->myOptionTable->clearSelection();
- myAdvWidget->myOptionTable->scrollToItem( myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
- //myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setSelected( true );
- myAdvWidget->myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN );
- //myAdvWidget->myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
+ int activeColumn = custom ? OPTION_NAME_COLUMN : OPTION_VALUE_COLUMN;
+ myAdvWidget->myOptionTable->scrollToItem( myAdvWidget->myOptionTable->item( row, activeColumn ) );
+ //myAdvWidget->myOptionTable->item( row, activeColumn )->setSelected( true );
+ myAdvWidget->myOptionTable->setCurrentCell( row, activeColumn );
+ //myAdvWidget->myOptionTable->openPersistentEditor( myOptionTable->item( row, activeColumn ) );
}
void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
{
+ BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
+ BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
// clear option values and remember selected row
QList<int> selectedRows;
QList<QTableWidgetItem*> selected = myAdvWidget->myOptionTable->selectedItems();
selectedRows.append( row );
int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
QString optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text();
+ bool custom = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->data(Qt::UserRole).toBool();
+ QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
if ( id >= 0 )
- if (optionType == "BLSURF" && id < myOptions->length() )
- myOptions[ id ] = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
- else if (optionType == "PRECAD" && id < myPreCADOptions->length() )
- myPreCADOptions[ id ] = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
+ if ( optionType == "BLSURF" && id < myOptions->length() )
+ if ( custom ) {
+ h->UnsetOption( name.toLatin1().constData() );
+ myOptions[id] = "";
+ }
+ else
+ myOptions[id] = name.toLatin1().constData();
+ else if ( optionType == "PRECAD" && id < myPreCADOptions->length() )
+ if ( custom ) {
+ h->UnsetPreCADOption( name.toLatin1().constData() );
+ myPreCADOptions[id] = "";
+ }
+ else
+ myPreCADOptions[id] = name.toLatin1().constData();
}
}
qSort( selectedRows );
myAdvWidget->myOptionTable->removeRow( it.previous() );
}
+void BLSURFPluginGUI_HypothesisCreator::onEditOption( int row, int column )
+{
+ if ( column != OPTION_NAME_COLUMN )
+ return;
+ bool custom = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->data(Qt::UserRole).toBool();
+ if ( !custom )
+ return;
+
+ BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
+ BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
+
+ int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
+ QString optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().trimmed();
+ QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
+ if ( optionType == "PRECAD" && id < myPreCADOptions->length() ) {
+ h->UnsetPreCADOption(name.toLatin1().constData());
+ myPreCADOptions[id] = "";
+ }
+ else if ( optionType == "BLSURF" && id < myOptions->length() ) {
+ h->UnsetOption(name.toLatin1().constData());
+ myOptions[id] = "";
+ }
+}
+
+void BLSURFPluginGUI_HypothesisCreator::onChangeOptionName( int row, int column )
+{
+ if ( column != OPTION_NAME_COLUMN )
+ return;
+ myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
+}
// **********************
// *** BEGIN SIZE MAP ***
// **********************
// Advanced tab
void onAddOption();
void onDeleteOption();
+ void onEditOption( int, int );
+ void onChangeOptionName( int, int );
void onOptionChosenInPopup( QAction* );
// Sizemap tab
void onMapGeomContentModified();
<source>BLSURF_REMOVE_OPTION</source>
<translation>Clear option</translation>
</message>
+ <message>
+ <source>BLSURF_OTHER_OPTION</source>
+ <translation>Other option</translation>
+ </message>
<message>
<source>BLSURF_GMF_FILE</source>
<translation>Export GMF</translation>
<source>BLSURF_REMOVE_OPTION</source>
<translation>Effacer l'option</translation>
</message>
+ <message>
+ <source>BLSURF_OTHER_OPTION</source>
+ <translation>L'autre option</translation>
+ </message>
<message>
<source>BLSURF_GMF_FILE</source>
<translation>Export GMF</translation>
<source>BLSURF_REMOVE_OPTION</source>
<translation>オプションを削除します。</translation>
</message>
+ <message>
+ <source>BLSURF_OTHER_OPTION</source>
+ <translation type="unfinished">Other option</translation>
+ </message>
<message>
<source>BLSURF_GMF_FILE</source>
<translation>エクスポート グループ</translation>