// Processing of external (non-sketch) object
aSelectedObject = PartSet_Tools::createFixedObjectByExternal(theShape->impl<TopoDS_Shape>(),
theSelectedObject, theSketch, theTemporary);
- if (aSelectedObject.get()) {
- if (theTemporary)
+ if (aSelectedObject.get() && theTemporary)
myExternalObjectValidated = aSelectedObject;
- else
- myExternalObjects.append(aSelectedObject);
- }
}
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,
{
if (theTemporary)
removeExternalObject(myExternalObjectValidated, theSketch, theFeature, theWorkshop);
- else{
- QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end();
- for (; anIt != aLast; anIt++) {
- ObjectPtr anObject = *anIt;
- removeExternalObject(anObject, theSketch, theFeature, theWorkshop);
- }
- 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,
- ModuleBase_IWorkshop* theWorkshop)
-{
- // TODO(nds): unite with removeExternal(), remove parameters
- removeExternalObject(myExternalObjectValidated, theSketch, theFeature, theWorkshop);
- myExternalObjectValidated = ObjectPtr();
-}*/
-
void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject,
- const CompositeFeaturePtr& theSketch,
+ const CompositeFeaturePtr& /*theSketch*/,
const FeaturePtr& theFeature,
ModuleBase_IWorkshop* theWorkshop)
{
ObjectPtr externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
const CompositeFeaturePtr& theSketch, const bool theTemporary = false);
- //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
- /// \param theFeature a current workshop
+ /// \param theWorkshop a current workshop
/// \param theTemporary if true, a temporary external object is removed overwise all ext objects
void removeExternal(const CompositeFeaturePtr& theSketch,
const FeaturePtr& theFeature,
ModuleBase_IWorkshop* theWorkshop,
const bool theTemporary);
- //void removeExternalVali+dated(const CompositeFeaturePtr& theSketch,
- // const FeaturePtr& theFeature,
- // ModuleBase_IWorkshop* theWorkshop);
-
- void removeUnusedExternalObjects(const QObjectPtrList& theIgnoreObjects,
- const CompositeFeaturePtr& theSketch,
- const FeaturePtr& theFeature);
-
protected:
+ /// Delete from the document the feature of the object. It deletes all objects, which refers to
+ /// the deleted one. The parameter feature is ignored even it refer to the deleted object.
+ /// \param theObject a removed object
+ /// \param theSketch a current sketch
+ /// \param theFeature a current feature
+ /// \param theWorkshop a current workshop
void removeExternalObject(const ObjectPtr& theObject,
const CompositeFeaturePtr& theSketch,
const FeaturePtr& theFeature,
static XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
protected:
- /// An external object
- QObjectPtrList myExternalObjects;
-
/// An external object
ObjectPtr myExternalObjectValidated;
delete myExternalObjectMgr;
}
-bool PartSet_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
- const bool theToValidate)
-{
- bool aSucceed = ModuleBase_WidgetMultiSelector::setSelection(theValues, theToValidate);
- if (aSucceed) {
- // TODO(nds): unite with externalObject(), remove parameters
- //myFeature->execute();
-
- QObjectPtrList aListOfAttributeObjects;
-
- AttributePtr anAttribute = myFeature->data()->attribute(attributeID());
- if (anAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) {
- AttributeSelectionListPtr aSelectionListAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(anAttribute);
- for (int i = 0; i < aSelectionListAttr->size(); i++) {
- AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
- aListOfAttributeObjects.append(anAttr->context());
- }
- }
- else if (anAttribute->attributeType() == ModelAPI_AttributeRefList::typeId()) {
- AttributeRefListPtr aRefListAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttribute);
- for (int i = 0; i < aRefListAttr->size(); i++) {
- aListOfAttributeObjects.append(aRefListAttr->object(i));
- }
- }
-
- myExternalObjectMgr->removeUnusedExternalObjects(aListOfAttributeObjects, sketch(), myFeature);
- }
- return aSucceed;
-}
-
//********************************************************************
bool PartSet_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
{
{
ModuleBase_WidgetMultiSelector::restoreAttributeValue(theValid);
- myExternalObjectMgr->removeExternal/*Validated*/(sketch(), myFeature, myWorkshop, true);
+ myExternalObjectMgr->removeExternal(sketch(), myFeature, myWorkshop, true);
}
void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrs& thePrs,
if (aResult.get())
aShape = aResult->shape();
}
- if (aShape.get() != NULL && !aShape->isNull()) {
- //if (myIsInValidate)
- // theObject = myExternalObjectMgr->externalObjectValidated(theObject, aShape, sketch());
- //else
+ if (aShape.get() != NULL && !aShape->isNull())
theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate);
- }
}
}
/// Retrurns installed sketcher
CompositeFeaturePtr sketch() const { return mySketch; }
- /// Set the given wrapped value to the current widget
- /// This value should be processed in the widget according to the needs
- /// \param theValues the wrapped selection values
- virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
- const bool theToValidate);
-
protected:
/// Checks the widget validity. By default, it returns true.
/// \param theValue a selected presentation in the view