void onSelectionTypeChanged();
/// Slot is called on selection changed
- void onSelectionChanged();
+ virtual void onSelectionChanged();
protected slots:
/// Slot for copy command in a list pop-up menu
return aSelectedObject;
}
+//********************************************************************
+ObjectPtr PartSet_ExternalObjectsMgr::externalObjectValidated(const ObjectPtr& theSelectedObject,
+ const GeomShapePtr& theShape,
+ const CompositeFeaturePtr& theSketch)
+{
+ // TODO(nds): unite with externalObject()
+ ObjectPtr aSelectedObject = PartSet_Tools::findFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
+ theSelectedObject, theSketch);
+ if (!aSelectedObject.get()) {
+ // Processing of external (non-sketch) object
+ aSelectedObject = PartSet_Tools::createFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
+ theSelectedObject, theSketch);
+ if (aSelectedObject.get())
+ myExternalObjectValidated = aSelectedObject;
+ }
+ return aSelectedObject;
+}
+
//********************************************************************
void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSketch,
const FeaturePtr& theFeature)
XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures);
}
}
+ //removeExternalObject(anObject, theSketch, theFeature);
}
myExternalObjects.clear();
}
+
+//********************************************************************
+void PartSet_ExternalObjectsMgr::removeUnusedExternalObjects(const QObjectPtrList& theIgnoreObjects,
+ const CompositeFeaturePtr& theSketch,
+ const FeaturePtr& theFeature)
+{
+ /*
+ // TODO(nds): unite with removeExternal(), remove parameters
+ QObjectPtrList aUsedExternalObjects;
+
+ QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end();
+ for (; anIt != aLast; anIt++) {
+ ObjectPtr anObject = *anIt;
+ if (theIgnoreObjects.contains(anObject))
+ aUsedExternalObjects.append(anObject);
+ else
+ removeExternalObject(anObject, theSketch, theFeature);
+ }*/
+ myExternalObjects.clear();
+ //if (!aUsedExternalObjects.empty())
+ // myExternalObjects = aUsedExternalObjects;
+}
+
+//********************************************************************
+void PartSet_ExternalObjectsMgr::removeExternalValidated(const CompositeFeaturePtr& theSketch,
+ const FeaturePtr& theFeature)
+{
+ // TODO(nds): unite with removeExternal(), remove parameters
+ removeExternalObject(myExternalObjectValidated, theSketch, theFeature);
+ myExternalObjectValidated = NULL;
+}
+
+void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject,
+ const CompositeFeaturePtr& theSketch,
+ const FeaturePtr& theFeature)
+{
+ if (theObject.get()) {
+ DocumentPtr aDoc = theObject->document();
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ if (aFeature.get() != NULL) {
+ QObjectPtrList anObjects;
+ anObjects.append(aFeature);
+ // the external feature should be removed with all references, sketch feature should be ignored
+ std::set<FeaturePtr> anIgnoredFeatures;
+ anIgnoredFeatures.insert(theSketch);
+ // the current feature should be ignored, because it can use the external feature in the
+ // attributes and, therefore have a references to it. So, the delete functionality tries
+ // to delete this feature. Test case is creation of a constraint on external point,
+ // use in this control after an external point, the point of the sketch.
+ anIgnoredFeatures.insert(theFeature);
+ XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures);
+ }
+ }
+}
ObjectPtr externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
const CompositeFeaturePtr& theSketch);
+ ObjectPtr externalObjectValidated(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
+ const CompositeFeaturePtr& theSketch);
+
+
// Removes the external presentation from the model
/// \param theSketch a current sketch
/// \param theFeature a current feature
void removeExternal(const CompositeFeaturePtr& theSketch,
const FeaturePtr& theFeature);
+ void removeExternalValidated(const CompositeFeaturePtr& theSketch,
+ const FeaturePtr& theFeature);
+
+ void removeUnusedExternalObjects(const QObjectPtrList& theIgnoreObjects,
+ const CompositeFeaturePtr& theSketch,
+ const FeaturePtr& theFeature);
+
+protected:
+ void removeExternalObject(const ObjectPtr& theObject,
+ const CompositeFeaturePtr& theSketch,
+ const FeaturePtr& theFeature);
+
protected:
/// An external object
QObjectPtrList myExternalObjects;
+ /// An external object
+ ObjectPtr myExternalObjectValidated;
+
/// Boolean value about the neccessity of the external object use
bool myUseExternal;
};
delete myExternalObjectMgr;
}
+//********************************************************************
+void PartSet_WidgetMultiSelector::onSelectionChanged()
+{
+ ModuleBase_WidgetMultiSelector::onSelectionChanged();
+ // TODO(nds): unite with externalObject(), remove parameters
+ //myFeature->execute();
+
+ DataPtr aData = myFeature->data();
+ AttributeSelectionListPtr aSelectionListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
+
+ QObjectPtrList aListOfAttributeObjects;
+ for (int i = 0; i < aSelectionListAttr->size(); i++) {
+ AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
+ aListOfAttributeObjects.append(anAttr->context());
+ }
+
+ myExternalObjectMgr->removeUnusedExternalObjects(aListOfAttributeObjects, sketch(), myFeature);
+}
+
+//********************************************************************
+void PartSet_WidgetMultiSelector::storeAttributeValue()
+{
+ myIsInVaildate = true;
+ ModuleBase_WidgetMultiSelector::storeAttributeValue();
+
+}
+
//********************************************************************
void PartSet_WidgetMultiSelector::restoreAttributeValue(const bool theValid)
{
+ myIsInVaildate = false;
ModuleBase_WidgetMultiSelector::restoreAttributeValue(theValid);
- myExternalObjectMgr->removeExternal(sketch(), myFeature);
+
+ myExternalObjectMgr->removeExternalValidated(sketch(), myFeature);
}
//********************************************************************
return false;
if (aSPFeature.get() == NULL && aShape.get() != NULL && !aShape->isNull() && myExternalObjectMgr->useExternal()) {
- aSelectedObject = myExternalObjectMgr->externalObject(theSelectedObject, theShape, sketch());
+ if (myIsInVaildate)
+ aSelectedObject = myExternalObjectMgr->externalObjectValidated(theSelectedObject, theShape, sketch());
+ else
+ aSelectedObject = myExternalObjectMgr->externalObject(theSelectedObject, theShape, sketch());
}
/// \param theOwner a selected owner
virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+public slots:
+ /// Slot is called on selection changed
+ virtual void onSelectionChanged();
+
protected:
+ /// Creates a backup of the current values of the attribute
+ /// It should be realized in the specific widget because of different
+ /// parameters of the current attribute
+ virtual void storeAttributeValue();
+
/// Creates a backup of the current values of the attribute
/// It should be realized in the specific widget because of different
/// parameters of the current attribute
PartSet_ExternalObjectsMgr* myExternalObjectMgr;
/// Pointer to a sketch
CompositeFeaturePtr mySketch;
+
+ bool myIsInVaildate;
};
#endif
\ No newline at end of file
{
AttributeSelectionListPtr aMirrorObjectRefs =
selectionList(SketchPlugin_ConstraintMirror::MIRROR_LIST_ID());
- if (!aMirrorObjectRefs->isInitialized())
- return;
std::shared_ptr<ModelAPI_Data> aData = data();
AttributeRefListPtr aRefListOfShapes = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(