-// Copyright (C) 2014-2020 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
myMainLayout = new QVBoxLayout(this);
ModuleBase_Tools::adjustMargins(myMainLayout);
- QStringList aIconsList = getIconsList(myShapeTypes);
+
+ QStringList aIconsList;
+ std::string aIcons = theData->getProperty("type_icons");
+ if (aIcons.size() > 0)
+ aIconsList = QString(aIcons.c_str()).split(' ', QString::SkipEmptyParts);
+
+ if (aIconsList.size() != myShapeTypes.size())
+ aIconsList = getIconsList(myShapeTypes);
+
myTypeCtrl = new ModuleBase_ChoiceCtrl(this, myShapeTypes, aIconsList);
myTypeCtrl->setLabel(tr("Type"));
if (!myShapeTypes.empty()) {
- myTypeCtrl->setValue(0);
- myDefMode = myShapeTypes.first().toStdString();
+ std::string aDefType = theData->getProperty("default_type");
+ if (aDefType.size() > 0) {
+ bool aOk = false;
+ int aId = QString(aDefType.c_str()).toInt(&aOk);
+ if (aOk) {
+ myTypeCtrl->setValue(aId);
+ myDefMode = myShapeTypes.at(aId).toStdString();
+ }
+ }
+ if (myDefMode.size() == 0) {
+ myTypeCtrl->setValue(0);
+ myDefMode = myShapeTypes.first().toStdString();
+ }
}
myMainLayout->addWidget(myTypeCtrl);
if (aSelectionType.empty())
aSelectionListAttr->setSelectionType(myDefMode);
else {
- setCurrentShapeType(ModuleBase_Tools::shapeType(aSelectionType.c_str()));
+ setCurrentShapeType(aSelectionType.c_str());
myDefMode = aSelectionType;
myIsFirst = false;
}
QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
{
QList<QWidget*> result;
+ if (myTypeCtrl->isVisible())
+ result << myTypeCtrl;
result << myListView->getControl();
return result;
}
restoreValue();
myWorkshop->setSelected(getAttributeSelection());
// may be the feature's result is not displayed, but attributes should be
- myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments,
- true); /// hope that something is redisplayed by object updated
+ // hope that something is redisplayed by object updated
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments, false);
+ myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeResults, true);
// clear history should follow after set selected to do not increase history by setSelected
clearSelectedHistory();
QIntList aShapeTypes;
if (myShapeTypes.length() > 1 && myIsUseChoice) {
- aShapeTypes.append(ModuleBase_Tools::shapeType(myTypeCtrl->textValue()));
+ QStringList aTypes = myTypeCtrl->textValue().split("|", QString::SkipEmptyParts);
+ for(QString aType: aTypes) {
+ aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
+ }
}
else {
foreach (QString aType, myShapeTypes) {
- aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
+ QStringList aSubTypes = aType.split("|", QString::SkipEmptyParts);
+ for(QString aSubType: aSubTypes) {
+ aShapeTypes.append(ModuleBase_Tools::shapeType(aSubType));
+ }
}
}
return aShapeTypes;
}
//********************************************************************
-void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const int theShapeType)
+void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const QString& theShapeType)
{
int idx = 0;
+ GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::shapeTypeByStr(theShapeType.toStdString());
foreach (QString aShapeTypeName, myShapeTypes) {
- int aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
- if(aRefType == theShapeType && idx != myTypeCtrl->value()) {
+ if(GeomAPI_Shape::shapeTypeByStr(aShapeTypeName.toStdString()) == aShapeType &&
+ idx != myTypeCtrl->value()) {
updateSelectionModesAndFilters(false);
bool isBlocked = myTypeCtrl->blockSignals(true);
myTypeCtrl->setValue(idx);
AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
for (int i = 0; i < aSelectionListAttr->size(); i++) {
AttributeSelectionPtr aAttr = aSelectionListAttr->value(i);
- myListView->addItem(aAttr->namingName().c_str(), i);
+ myListView->addItem(QString::fromStdWString(aAttr->namingName()), i);
}
}
else if (aType == ModelAPI_AttributeRefList::typeId()) {
for (int i = 0; i < aRefListAttr->size(); i++) {
ObjectPtr anObject = aRefListAttr->object(i);
if (anObject.get()) {
- myListView->addItem(anObject->data()->name().c_str(), i);
+ myListView->addItem(QString::fromStdWString(anObject->data()->name()), i);
}
}
}
AttributePtr anAttr = aRefAttrListAttr->attribute(i);
QString aName;
if (anAttr.get()) {
- std::string anAttrName = ModuleBase_Tools::generateName(anAttr, myWorkshop);
- aName = QString::fromStdString(anAttrName);
+ std::wstring anAttrName = ModuleBase_Tools::generateName(anAttr, myWorkshop);
+ aName = QString::fromStdWString(anAttrName);
}
else {
ObjectPtr anObject = aRefAttrListAttr->object(i);
if (anObject.get()) {
- aName = anObject->data()->name().c_str();
+ aName = QString::fromStdWString(anObject->data()->name());
}
}
myListView->addItem(aName, i);