#include <memory>
#include <string>
+//#define DEBUG_ATTRIBUTE_SELECTION
+
//#define DEBUG_SHAPE_VALIDATION_PREVIOUS
class CustomListWidget : public QListWidget
const Config_WidgetAPI* theData,
const std::string& theParentId)
: ModuleBase_WidgetSelector(theParent, theWorkshop, theData, theParentId),
- mySelectionType(""), mySelectionCount(0)
+ mySelectionCount(0)
{
QGridLayout* aMainLay = new QGridLayout(this);
ModuleBase_Tools::adjustMargins(aMainLay);
//********************************************************************
bool ModuleBase_WidgetMultiSelector::restoreValueCustom()
{
+ myIsInValidate = false;
+
// A rare case when plugin was not loaded.
if(!myFeature)
return false;
//********************************************************************
void ModuleBase_WidgetMultiSelector::storeAttributeValue()
{
+ myIsInValidate = true;
DataPtr aData = myFeature->data();
AttributeSelectionListPtr aSelectionListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
return;
mySelectionType = aSelectionListAttr->selectionType();
- mySelectionCount = aSelectionListAttr->size();
- /*mySelection.clear();
+#ifdef DEBUG_ATTRIBUTE_SELECTION
+ mySelection.clear();
int aSize = aSelectionListAttr->size();
for (int i = 0; i < aSelectionListAttr->size(); i++) {
AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
mySelection.append(GeomSelection(aSelectAttr->context(), aSelectAttr->value()));
- }*/
+ }
+#else
+ mySelectionCount = aSelectionListAttr->size();
+#endif
}
//********************************************************************
AttributeSelectionListPtr aSelectionListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
+ int aSelCount = aSelectionListAttr->size();
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
- aSelectionListAttr->append(aResult, theShape);
+ aSelectionListAttr->append(aResult, theShape/*, myIsInValidate*/);
}
//********************************************************************
void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool/* theValid*/)
{
- //clearAttribute();
+#ifdef DEBUG_ATTRIBUTE_SELECTION
+ clearAttribute();
// Store shape type
DataPtr aData = myFeature->data();
aSelectionListAttr->setSelectionType(mySelectionType);
// Store selection in the attribute
- //int aSize = mySelection.size();
- //foreach (GeomSelection aSelec, mySelection) {
- // setObject(aSelec.first, aSelec.second);
- //}
+ foreach (GeomSelection aSelec, mySelection) {
+ setObject(aSelec.first, aSelec.second);
+ }
+#else
+ // Store shape type
+ DataPtr aData = myFeature->data();
+ AttributeSelectionListPtr aSelectionListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
+ aSelectionListAttr->setSelectionType(mySelectionType);
- //int aCountAppened = aSelectionListAttr->size() - mySelectionCount;
- //for ( int i = 0; i < aCountAppened; i++)
- // aSelectionListAttr->removeLast();
+ // restore selection in the attribute
+ int aCountAppened = aSelectionListAttr->size() - mySelectionCount;
+ for ( int i = 0; i < aCountAppened; i++)
+ aSelectionListAttr->removeLast();
+#endif
}
//********************************************************************
return aValid;
}
-//********************************************************************
-void PartSet_WidgetMultiSelector::storeAttributeValue()
-{
- myIsInVaildate = true;
- ModuleBase_WidgetMultiSelector::storeAttributeValue();
-}
-
//********************************************************************
void PartSet_WidgetMultiSelector::restoreAttributeValue(const bool theValid)
{
- myIsInVaildate = false;
ModuleBase_WidgetMultiSelector::restoreAttributeValue(theValid);
myExternalObjectMgr->removeExternalValidated(sketch(), myFeature, myWorkshop);
aShape = aResult->shape();
}
if (aShape.get() != NULL && !aShape->isNull()) {
- if (myIsInVaildate)
+ if (myIsInValidate)
theObject = myExternalObjectMgr->externalObjectValidated(theObject, aShape, sketch());
else
theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch());