myTypeCombo->setVisible(false);
}
- std::string aLabelText = theData->getProperty("label");
- QLabel* aListLabel = new QLabel(!aLabelText.empty() ? aLabelText.c_str()
- : tr("Selected objects:"), this);
+ QString aLabelText = translate(theData->getProperty("label"));
+ QLabel* aListLabel = new QLabel(aLabelText, this);
aMainLay->addWidget(aListLabel, 1, 0);
- // if the xml definition contains one type, an information label should be shown near to the latest
+ // if the xml definition contains one type, an information label
+ // should be shown near to the latest
if (aShapeTypes.size() <= 1) {
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
if (!aLabelIcon.isEmpty()) {
//********************************************************************
bool ModuleBase_WidgetMultiSelector::storeValueCustom()
{
- // the value is stored on the selection changed signal processing
- // A rare case when plugin was not loaded.
+ // the value is stored on the selection changed signal processing
+ // A rare case when plugin was not loaded.
if (!myFeature)
return false;
//********************************************************************
bool ModuleBase_WidgetMultiSelector::restoreValueCustom()
{
- // A rare case when plugin was not loaded.
+ // A rare case when plugin was not loaded.
if (!myFeature)
return false;
if (isDone) // may be the feature's result is not displayed, but attributes should be
myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
- true);/// hope that something is redisplayed by object updated
+ true);/// hope that something is redisplayed by object updated
return isDone;
}
// may be the feature's result is not displayed, but attributes should be
myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
- true); /// hope that something is redisplayed by object updated
+ true); /// hope that something is redisplayed by object updated
}
// Restore selection
void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
{
activateSelectionAndFilters(true);
- QList<ModuleBase_ViewerPrsPtr> anEmptyList;
- // This method will call Selection changed event which will call onSelectionChanged
- // To clear mySelection, myListControl and storeValue()
- // So, we don't need to call it
- myWorkshop->setSelected(anEmptyList);
+
+ if (!myFeature)
+ return;
+ /// store the selected type
+ AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
+ std::string aType = anAttribute->attributeType();
+ if (aType == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
+ aSelectionListAttr->setSelectionType(myTypeCombo->currentText().toStdString());
+ }
+
+ // clear attribute values
+ DataPtr aData = myFeature->data();
+ if (aType == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
+ aSelectionListAttr->clear();
+ }
+ else if (aType == ModelAPI_AttributeRefList::typeId()) {
+ AttributeRefListPtr aRefListAttr = aData->reflist(attributeID());
+ aRefListAttr->clear();
+ }
+ else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
+ AttributeRefAttrListPtr aRefAttrListAttr = aData->refattrlist(attributeID());
+ aRefAttrListAttr->clear();
+ }
+
+ // update object is necessary to flush update signal. It leads to objects references map update
+ // and the operation presentation will not contain deleted items visualized as parameters of
+ // the feature.
+ updateObject(myFeature);
+ restoreValue();
+ myWorkshop->setSelected(getAttributeSelection());
+ // may be the feature's result is not displayed, but attributes should be
+ myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeArguments,
+ true); /// hope that something is redisplayed by object updated
}
//********************************************************************
// it should be postponed to exit from the selectionChanged processing
static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent);
+ Events_Loop::loop()->flush(anEvent);
return;
}
}
void ModuleBase_WidgetMultiSelector::updateFocus()
{
- // Set focus to List control in order to make possible
+ // Set focus to List control in order to make possible
// to use Tab key for transfer the focus to next widgets
myListControl->setCurrentRow(myListControl->model()->rowCount() - 1);
ModuleBase_Tools::setFocus(myListControl,
void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const int theShapeType)
{
QString aShapeTypeName;
-
+
for (int idx = 0; idx < myTypeCombo->count(); ++idx) {
aShapeTypeName = myTypeCombo->itemText(idx);
int aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
return aType;
}
+//********************************************************************
+void ModuleBase_WidgetMultiSelector::clearSelection()
+{
+ bool isClearInNeutralPoint = myIsNeutralPointClear;
+ myIsNeutralPointClear = true;
+
+ QList<ModuleBase_ViewerPrsPtr> anEmptyList;
+ // This method will call Selection changed event which will call onSelectionChanged
+ // To clear mySelection, myListControl and storeValue()
+ // So, we don't need to call it
+ myWorkshop->setSelected(anEmptyList);
+
+ myIsNeutralPointClear = isClearInNeutralPoint;
+}
+
//********************************************************************
void ModuleBase_WidgetMultiSelector::onCopyItem()
{
QList<QListWidgetItem*> aItems = myListControl->selectedItems();
myCopyAction->setEnabled(!aItems.isEmpty());
myDeleteAction->setEnabled(!aItems.isEmpty());
-
+
myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects,
true);
}
}
void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set<int> theAttributeIds,
- QList<ModuleBase_ViewerPrsPtr>& theValues) const
+ QList<ModuleBase_ViewerPrsPtr>& theValues) const
{
if(myFeature.get() == NULL)
return;
}
else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
std::set<AttributePtr> anAttributes;
- QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator
+ anIt = theValues.begin(), aLast = theValues.end();
ObjectPtr anObject;
GeomShapePtr aShape;
for (; anIt != aLast; anIt++) {