}
}
}
- if (hasEventsToFlush && myGroups.empty()) { // no more messages left in the queue, so, finalize the sketch processing
+ if (hasEventsToFlush && myGroups.empty()) {
+ // no more messages left in the queue, so, finalize the sketch processing
static Events_ID anID = Events_Loop::eventByName("SketchPrepared");
std::shared_ptr<Events_Message> aMsg(new Events_Message(anID, this));
Events_Loop::loop()->send(aMsg, false);
return;
std::shared_ptr<GeomAPI_Circ2d> aCircleForArc(new GeomAPI_Circ2d(aCenter, aStart));
- bool aWasBlocked = data()->blockSendAttributeUpdated(true);
- // The Arc end point is projected
- // on the circle formed by center and start points
+ // Do not recalculate REVERSED flag if the arc is not consistent
std::shared_ptr<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(anEnd);
- if (aProjection && anEnd->distance(aProjection) > tolerance) {
- anEndAttr->setValue(aProjection);
- anEnd = aProjection;
- }
- data()->blockSendAttributeUpdated(aWasBlocked, false);
-
- double aParameterNew = 0.0;
- if(aCircleForArc->parameter(anEnd, paramTolerance, aParameterNew)) {
- bool aWasBlocked = data()->blockSendAttributeUpdated(true);
- if(myParamBefore <= PI / 2.0 && aParameterNew >= PI * 1.5) {
- if(!boolean(REVERSED_ID())->value()) {
- boolean(REVERSED_ID())->setValue(true);
- }
- } else if(myParamBefore >= PI * 1.5 && aParameterNew <= PI / 2.0) {
- if(boolean(REVERSED_ID())->value()) {
- boolean(REVERSED_ID())->setValue(false);
+ if (aProjection && anEnd->distance(aProjection) <= tolerance) {
+ double aParameterNew = 0.0;
+ if(aCircleForArc->parameter(anEnd, paramTolerance, aParameterNew)) {
+ bool aWasBlocked = data()->blockSendAttributeUpdated(true);
+ if(myParamBefore <= PI / 2.0 && aParameterNew >= PI * 1.5) {
+ if(!boolean(REVERSED_ID())->value()) {
+ boolean(REVERSED_ID())->setValue(true);
+ }
+ } else if(myParamBefore >= PI * 1.5 && aParameterNew <= PI / 2.0) {
+ if(boolean(REVERSED_ID())->value()) {
+ boolean(REVERSED_ID())->setValue(false);
+ }
}
+ data()->blockSendAttributeUpdated(aWasBlocked, false);
}
- data()->blockSendAttributeUpdated(aWasBlocked, false);
+ myParamBefore = aParameterNew;
}
- myParamBefore = aParameterNew;
}
double aRadius = 0;
aSession.startOperation()
anArcCenter.setValue(aCenter[0], aCenter[1])
aSession.finishOperation()
-verifyLastArc(aSketchFeature, aCenter, [], [])
+verifyLastArc(aSketchFeature, [], [], [])
# Move start point
deltaX, deltaY = 5., 2.
aStart = [anArcStartPoint.x() + deltaX, anArcStartPoint.y() + deltaY]
aSession.startOperation()
anArcStartPoint.setValue(aStart[0], aStart[1])
aSession.finishOperation()
-verifyLastArc(aSketchFeature, [], aStart, [])
+verifyLastArc(aSketchFeature, [], [], [])
# Move end point
aEnd = [anArcEndPoint.x() - deltaX, anArcEndPoint.y() - deltaY]
aSession.startOperation()
anArcEndPoint.setValue(aEnd[0], aEnd[1])
aSession.finishOperation()
-verifyLastArc(aSketchFeature, [], [], aEnd)
+verifyLastArc(aSketchFeature, [], [], [])
# Check that changing the radius does not affect arc
aSession.startOperation()
anArcRadius = aSketchArc.real("radius")
aPrevRadius = anArcRadius.value();
anArcRadius.setValue(aPrevRadius + 10.)
aSession.finishOperation()
-assert (math.fabs(anArcRadius.value - aPrevRadius) < TOLERANCE)
+assert (math.fabs(anArcRadius.value() - aPrevRadius) < TOLERANCE)
verifyLastArc(aSketchFeature, [], [], [])
# Check that changing the angle does not affect arc
aSession.startOperation()
aPrevAngle = anArcAngle.value()
anArcAngle.setValue(aPrevAngle + 10.)
aSession.finishOperation()
-assert (math.fabs(anArcAngle.value - aPrevAngle) < TOLERANCE)
+assert (math.fabs(anArcAngle.value() - aPrevAngle) < TOLERANCE)
verifyLastArc(aSketchFeature, [], [], [])
#=========================================================================
/// \brief Remove all features became invalid
virtual void removeInvalidEntities();
+ /// \brief Check the storage has constraints
+ virtual bool isEmpty() const
+ { return SketchSolver_Storage::isEmpty() && myArcConstraintMap.empty(); }
+
private:
/// \brief Convert feature using specified builder.
EntityWrapperPtr createFeature(const FeaturePtr& theFeature,
/// \brief Returns true if the group has no constraints yet
inline bool isEmpty() const
{
- return myConstraints.empty();
+ return myConstraints.empty() && myTempConstraints.empty();
}
/// \brief Check for valid sketch data
bool isConsistent() const;
/// \brief Check the storage has constraints
- bool isEmpty() const
+ virtual bool isEmpty() const
{ return myConstraintMap.empty(); }
/// \brief Shows the sketch should be resolved