//
#include "PartSet_ExternalObjectsMgr.h"
+
+#include "PartSet_CenterPrs.h"
#include "PartSet_Tools.h"
#include <XGUI_Workshop.h>
return aSelectedObject;
}
+ObjectPtr PartSet_ExternalObjectsMgr::externalCenterObject(const ModuleBase_ViewerPrsPtr& thePrs,
+ const CompositeFeaturePtr& theSketch,
+ const bool theTemporary)
+{
+ if (!thePrs.get() || thePrs->interactive().IsNull())
+ return ObjectPtr();
+
+ Handle(PartSet_CenterPrs) aAIS = Handle(PartSet_CenterPrs)::DownCast(thePrs->interactive());
+ if (aAIS.IsNull())
+ return ObjectPtr();
+
+ gp_Pnt aPntComp = aAIS->Component()->Pnt();
+ GeomVertexPtr aVertPtr(new GeomAPI_Vertex(aPntComp.X(), aPntComp.Y(), aPntComp.Z()));
+ TopoDS_Shape aShape = aVertPtr->impl<TopoDS_Shape>();
+
+ ResultPtr aSelectedObject =
+ PartSet_Tools::findFixedObjectByExternal(aShape, aAIS->object(), theSketch);
+ if (!aSelectedObject.get())
+ {
+ FeaturePtr aCreatedFeature;
+ aSelectedObject = PartSet_Tools::createFixedByExternalCenter(aAIS->object(), aAIS->edge(),
+ aAIS->centerType(), theSketch, theTemporary, aCreatedFeature);
+ if (aCreatedFeature.get() && theTemporary)
+ myExternalObjectValidated = aCreatedFeature;
+ }
+ return aSelectedObject;
+}
+
void PartSet_ExternalObjectsMgr::getGeomSelection(const ModuleBase_ViewerPrsPtr& thePrs,
- ObjectPtr& theObject,
- GeomShapePtr& theShape,
- ModuleBase_IWorkshop* theWorkshop,
- const CompositeFeaturePtr& theSketch,
- const bool isInValidate)
+ ObjectPtr& theObject,
+ GeomShapePtr& theShape,
+ ModuleBase_IWorkshop* theWorkshop,
+ const CompositeFeaturePtr& theSketch,
+ const bool isInValidate)
{
FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(theObject);
std::shared_ptr<SketchPlugin_Feature> aSPFeature =
if (aShape.get() != NULL && !aShape->isNull())
anExternalObject =
externalObject(theObject, aShape, theSketch, isInValidate);
+ if (!anExternalObject.get()) {
+ anExternalObject = externalCenterObject(thePrs, theSketch, isInValidate);
+ }
}
else { /// use objects of found selection
anExternalObject = theObject;
ObjectPtr externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape,
const CompositeFeaturePtr& theSketch, const bool theTemporary = false);
+ /// Finds or create and external object by selected circle center (PartSet_CenterPrs)
+ /// \param thePrs a selection
+ /// \param theSketch a current sketch
+ /// \param theTemporary the created external object is temporary, execute is not performed for it
+ /// \return the object
+ ObjectPtr externalCenterObject(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs,
+ const CompositeFeaturePtr& theSketch,
+ const bool theTemporary);
+
// Removes the external presentation from the model
/// \param theSketch a current sketch
/// \param theFeature a current feature
const std::shared_ptr<GeomAPI_Edge>& theEdge,
ModelAPI_AttributeSelection::CenterType theType,
const CompositeFeaturePtr& theSketch,
- bool theTemporary)
+ bool theTemporary,
+ FeaturePtr& theCreatedFeature)
{
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if (!aResult.get())
return ResultPtr();
FeaturePtr aProjectionFeature = theSketch->addFeature(SketchPlugin_Projection::ID());
+ theCreatedFeature = aProjectionFeature;
AttributeSelectionPtr anExternalAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(
aProjectionFeature->attribute(SketchPlugin_Projection::EXTERNAL_FEATURE_ID()));
anExternalAttr->setValueCenter(aResult, theEdge, theType, theTemporary);
const std::shared_ptr<GeomAPI_Edge>& theEdge,
ModelAPI_AttributeSelection::CenterType theType,
const CompositeFeaturePtr& theSketch,
- bool theTemporary = false);
+ bool theTemporary,
+ FeaturePtr& theCreatedFeature);
};
#include <Config_WidgetAPI.h>
+#include <PartSet_CenterPrs.h>
#include <PartSet_Tools.h>
#include <PartSet_ExternalObjectsMgr.h>
#include <SketchPlugin_Feature.h>
//********************************************************************
bool PartSet_WidgetMultiSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
{
- bool aValid = ModuleBase_WidgetMultiSelector::isValidSelectionCustom(thePrs);
+ bool aValid = false;
+ if (thePrs.get() && thePrs->interactive()->IsKind(STANDARD_TYPE(PartSet_CenterPrs)))
+ aValid = true; // we should not check acceptSubShape for such presentation
+ else
+ aValid = ModuleBase_WidgetMultiSelector::isValidSelectionCustom(thePrs);
+
if (aValid) {
ObjectPtr anObject = myWorkshop->selection()->getResult(thePrs);
aValid = myExternalObjectMgr->isValidObject(anObject);
ResultPtr aFixedObject =
PartSet_Tools::findFixedObjectByExternal(aShape, aAIS->object(), mySketch);
if (!aFixedObject.get())
+ {
+ FeaturePtr aCreatedFeature;
aFixedObject = PartSet_Tools::createFixedByExternalCenter(aAIS->object(), aAIS->edge(),
- aAIS->centerType(), mySketch);
+ aAIS->centerType(), mySketch, false, aCreatedFeature);
+ }
if (aFixedObject.get())
setConstraintToObject(aFixedObject);
// fignal updated should be flushed in order to visualize possible created
//
#include "PartSet_WidgetShapeSelector.h"
+
+#include "PartSet_CenterPrs.h"
#include "PartSet_Module.h"
#include "PartSet_SketcherMgr.h"
//********************************************************************
bool PartSet_WidgetShapeSelector::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
{
- bool aValid = ModuleBase_WidgetShapeSelector::isValidSelectionCustom(thePrs);
+ bool aValid = false;
+ if (thePrs.get() && thePrs->interactive()->IsKind(STANDARD_TYPE(PartSet_CenterPrs)))
+ aValid = true; // we should not check acceptSubShape for such presentation
+ else
+ aValid = ModuleBase_WidgetShapeSelector::isValidSelectionCustom(thePrs);
+
if (aValid) {
ObjectPtr anObject = myWorkshop->selection()->getResult(thePrs);
aValid = myExternalObjectMgr->isValidObject(anObject);