2. Reenter of Arc operation for arc by 3 point mode led to crash.
#include <QString>
-PartSet_ExternalObjectsMgr::PartSet_ExternalObjectsMgr(const std::string& theExternal, const bool theDefaultValue)
-: myUseExternal(theDefaultValue)
+PartSet_ExternalObjectsMgr::PartSet_ExternalObjectsMgr(const std::string& theExternal,
+ const std::string& theCanCreateExternal,
+ const bool theDefaultValue)
+: myUseExternal(theDefaultValue), myCanCreateExternal(true)
{
QString aIsExternal(theExternal.c_str());
if (!aIsExternal.isEmpty()) {
QString aStr = aIsExternal.toUpper();
myUseExternal = (aStr == "TRUE") || (aStr == "YES");
}
+
+ QString aCanCreateExternal(theCanCreateExternal.c_str());
+ if (!aCanCreateExternal.isEmpty()) {
+ QString aStr = aCanCreateExternal.toUpper();
+ myCanCreateExternal = (aStr == "TRUE") || (aStr == "YES");
+ }
}
bool PartSet_ExternalObjectsMgr::isValidObject(const ObjectPtr& theObject)
public:
/// Constructor
/// \param theExternal the external state
+ /// \param theCanCreateExternal the state if it can and should create external features
/// \param theDefaultValue the default value for the external object using
- PartSet_ExternalObjectsMgr(const std::string& theExternal, const bool theDefaultValue);
+ PartSet_ExternalObjectsMgr(const std::string& theExternal,
+ const std::string& theCanCreateExternal,
+ const bool theDefaultValue);
virtual ~PartSet_ExternalObjectsMgr() {}
/// Returns the state whether the external object is used
bool useExternal() const { return myUseExternal; }
+ /// Returns if new external objects can be created
+ /// \return boolean value
+ bool canCreateExternal() { return myCanCreateExternal;}
+
/// Checks validity of the given object
/// \param theObject an object to check
/// \return valid or not valid
/// Boolean value about the neccessity of the external object use
bool myUseExternal;
+ /// Boolean value about the necessity of a new external object creation
+ bool myCanCreateExternal;
};
#endif
\ No newline at end of file
if (!anError.isEmpty()) {
aFOperation->setEditOperation(false);
//workshop()->operationMgr()->updateApplyOfOperations();
- beforeStopInternalEdit();
myIsInternalEditOperation = false;
updateAcceptAllAction();
}
const Config_WidgetAPI* theData)
: ModuleBase_WidgetMultiSelector(theParent, theWorkshop, theData)
{
- myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"), false);
+ myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"),
+ theData->getProperty("can_create_external"), false);
}
PartSet_WidgetMultiSelector::~PartSet_WidgetMultiSelector()
// TODO: unite with the same functionality in PartSet_WidgetShapeSelector
if (aSPFeature.get() == NULL) {
ObjectPtr anExternalObject = ObjectPtr();
+ GeomShapePtr anExternalShape = GeomShapePtr();
if (myExternalObjectMgr->useExternal()) {
- GeomShapePtr aShape = theShape;
- if (!aShape.get()) {
- ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
- if (aResult.get())
- aShape = aResult->shape();
+ if (myExternalObjectMgr->canCreateExternal()) {
+ GeomShapePtr aShape = theShape;
+ if (!aShape.get()) {
+ ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+ if (aResult.get())
+ aShape = aResult->shape();
+ }
+ if (aShape.get() != NULL && !aShape->isNull())
+ anExternalObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate);
+ }
+ else {
+ anExternalObject = theObject;
+ anExternalShape = theShape;
}
- if (aShape.get() != NULL && !aShape->isNull())
- anExternalObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate);
}
/// the object is null if the selected feature is "external"(not sketch entity feature of the
/// current sketch) and it is not created by object manager
theObject = anExternalObject;
+ theShape = anExternalShape;
}
}
: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData)
{
myUseSketchPlane = theData->getBooleanAttribute("use_sketch_plane", true);
- myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"), true);
+ myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"),
+ theData->getProperty("can_create_external"), true);
}
PartSet_WidgetShapeSelector::~PartSet_WidgetShapeSelector()
// TODO: unite with the same functionality in PartSet_WidgetShapeSelector
if (aSPFeature.get() == NULL) {
ObjectPtr anExternalObject = ObjectPtr();
+ GeomShapePtr anExternalShape = GeomShapePtr();
if (myExternalObjectMgr->useExternal()) {
- GeomShapePtr aShape = theShape;
- if (!aShape.get()) {
- ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
- if (aResult.get())
- aShape = aResult->shape();
+ if (myExternalObjectMgr->canCreateExternal()) {
+ GeomShapePtr aShape = theShape;
+ if (!aShape.get()) {
+ ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+ if (aResult.get())
+ aShape = aResult->shape();
+ }
+ if (aShape.get() != NULL && !aShape->isNull())
+ anExternalObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate);
+ }
+ else { /// use objects of found selection
+ anExternalObject = theObject;
+ anExternalShape = theShape;
}
- if (aShape.get() != NULL && !aShape->isNull())
- anExternalObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate);
}
/// the object is null if the selected feature is "external"(not sketch entity feature of the
/// current sketch) and it is not created by object manager
theObject = anExternalObject;
+ theShape = anExternalShape;
}
}
std::shared_ptr<GeomAPI_Pnt> aLineLoc = aLine->location();
double aDot = aNormal->dot(aLineDir);
double aDist = aLineLoc->xyz()->decreased(anOrigin->xyz())->dot(aNormal->xyz());
- return (fabs(aDot) >= tolerance && fabs(aDot) < 1.0 - tolerance) ||
+ bool aValid = (fabs(aDot) >= tolerance && fabs(aDot) < 1.0 - tolerance) ||
(fabs(aDot) < tolerance && fabs(aDist) > tolerance);
+ if (!aValid)
+ theError = "Error: Edge is already in the sketch plane.";
+ return aValid;
}
else if (anEdge->isCircle() || anEdge->isArc()) {
std::shared_ptr<GeomAPI_Circ> aCircle = anEdge->circle();
std::shared_ptr<GeomAPI_Pnt> aCircCenter = aCircle->center();
double aDot = fabs(aNormal->dot(aCircNormal));
double aDist = aCircCenter->xyz()->decreased(anOrigin->xyz())->dot(aNormal->xyz());
- return fabs(aDot - 1.0) < tolerance * tolerance && fabs(aDist) > tolerance;
+ bool aValid = fabs(aDot - 1.0) < tolerance * tolerance && fabs(aDist) > tolerance;
+ if (!aValid)
+ theError.arg(anEdge->isCircle() ? "Error: Cirlce is already in the sketch plane."
+ : "Error: Arc is already in the sketch plane.");
+ return aValid;
}
+ theError = "Error: Selected object is not line, circle or arc.";
return false;
}
label="Edge"
tooltip="Select external edge."
shape_types="edge"
- use_external="false"
+ use_external="true"
+ can_create_external="false"
use_sketch_plane="false">
<validator id="SketchPlugin_ProjectionValidator"/>
</sketch_shape_selector>