diff --git a/src/Mod/Surface/App/FeatureBSplineSurf.cpp b/src/Mod/Surface/App/FeatureBSplineSurf.cpp index 3fb295f4bc..9f6c2c8884 100644 --- a/src/Mod/Surface/App/FeatureBSplineSurf.cpp +++ b/src/Mod/Surface/App/FeatureBSplineSurf.cpp @@ -57,6 +57,7 @@ BSplineSurf::BSplineSurf() : BSurf() App::DocumentObjectExecReturn *BSplineSurf::execute(void) { + correcteInvalidFillType(); //Begin Construction try{ Handle_Geom_BSplineCurve crvs[4]; diff --git a/src/Mod/Surface/App/FeatureBSurf.cpp b/src/Mod/Surface/App/FeatureBSurf.cpp index 497cc97aec..e4ddc6d3e3 100644 --- a/src/Mod/Surface/App/FeatureBSurf.cpp +++ b/src/Mod/Surface/App/FeatureBSurf.cpp @@ -141,3 +141,12 @@ void BSurf::createFace(const Handle_Geom_BoundedSurface &aSurface) if (aFace.IsNull()) { Standard_Failure::Raise("Resulting Face is null"); } this->Shape.setValue(aFace); } + +void BSurf::correcteInvalidFillType() +{ + int ftype = filltype.getValue(); + if(ftype == InvalidStyle) + { + filltype.setValue(StretchStyle); + } +} diff --git a/src/Mod/Surface/App/FeatureBSurf.h b/src/Mod/Surface/App/FeatureBSurf.h index 786d10f606..af95bdf69c 100644 --- a/src/Mod/Surface/App/FeatureBSurf.h +++ b/src/Mod/Surface/App/FeatureBSurf.h @@ -40,6 +40,7 @@ namespace Surface class BSurf : public Part::Feature { PROPERTY_HEADER(Surface::BSurf); + public: BSurf(); App::PropertyLinkSubList aBList; //curves to be turned into a face (2-4 curves allowed). @@ -56,6 +57,9 @@ protected: GeomFill_FillingStyle getFillingStyle(); void getWire(TopoDS_Wire& aWire); void createFace(const Handle_Geom_BoundedSurface &aSurface); + + // corrects the initially invalid fill type + void correcteInvalidFillType(); }; } diff --git a/src/Mod/Surface/App/FeatureBezSurf.cpp b/src/Mod/Surface/App/FeatureBezSurf.cpp index de2c34df5f..b67b4700d3 100644 --- a/src/Mod/Surface/App/FeatureBezSurf.cpp +++ b/src/Mod/Surface/App/FeatureBezSurf.cpp @@ -57,6 +57,7 @@ BezSurf::BezSurf() : BSurf() App::DocumentObjectExecReturn *BezSurf::execute(void) { + correcteInvalidFillType(); //Begin Construction try{ Handle_Geom_BezierCurve crvs[4]; diff --git a/src/Mod/Surface/FillType.h b/src/Mod/Surface/FillType.h index 5c5ea40ab2..5841ef13fc 100644 --- a/src/Mod/Surface/FillType.h +++ b/src/Mod/Surface/FillType.h @@ -3,7 +3,7 @@ enum filltype_t { - StretchStyle = 1, CoonsStyle, CurvedStyle + InvalidStyle = 0, StretchStyle, CoonsStyle, CurvedStyle }; #endif // SURAFCE_FILLTYPE_H diff --git a/src/Mod/Surface/Gui/BSurf.cpp b/src/Mod/Surface/Gui/BSurf.cpp index a942ca7e92..8d0e107a6c 100644 --- a/src/Mod/Surface/Gui/BSurf.cpp +++ b/src/Mod/Surface/Gui/BSurf.cpp @@ -92,19 +92,16 @@ BSurf::~BSurf() void BSurf::setEditedObject(Surface::BSurf* obj) { editedObject = obj; - filltype_t ft = (filltype_t)(editedObject->filltype.getValue()); - switch(ft) + oldFillType = (filltype_t)(editedObject->filltype.getValue()); + switch(oldFillType) { case StretchStyle: - oldFillType = ft; ui->fillType_stretch->setChecked(true); break; case CoonsStyle: - oldFillType = ft; ui->fillType_coons->setChecked(true); break; case CurvedStyle: - oldFillType = ft; ui->fillType_curved->setChecked(true); break; } @@ -143,13 +140,20 @@ void BSurf::accept() void BSurf::reject() { - // if the object fill type was changed, reset the old one - if(editedObject->filltype.getValue() != oldFillType) + if(oldFillType == InvalidStyle) { - editedObject->filltype.setValue(oldFillType); + Gui::Command::abortCommand(); + } + else + { + // if the object fill type was changed, reset the old one + if(editedObject->filltype.getValue() != oldFillType) + { + editedObject->filltype.setValue(oldFillType); + } + Gui::Command::commitCommand(); + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); } - Gui::Command::commitCommand(); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); } diff --git a/src/Mod/Surface/Gui/Command.cpp b/src/Mod/Surface/Gui/Command.cpp index b0fd46b37b..1e0a416c6a 100644 --- a/src/Mod/Surface/Gui/Command.cpp +++ b/src/Mod/Surface/Gui/Command.cpp @@ -253,7 +253,8 @@ void CmdSurfaceBSurf::createBezier() openCommand("Create Bezier surface"); doCommand(Doc,"FreeCAD.ActiveDocument.addObject(\"Surface::BezSurf\",\"%s\")", FeatName.c_str()); - doCommand(Doc, "FreeCAD.ActiveDocument.ActiveObject.filltype=1"); // TODO ask filltype from user and check it + // invalid fill type meaning the surface is just created and cancel should delete it + doCommand(Doc, "FreeCAD.ActiveDocument.ActiveObject.filltype=0"); doCommand(Doc, "Gui.ActiveDocument.setEdit('%s',0)", FeatName.c_str()); doCommand(Doc, bezListCmd.str().c_str()); updateActive(); @@ -273,7 +274,8 @@ void CmdSurfaceBSurf::createBSpline() openCommand("Create BSpline surface"); doCommand(Doc,"FreeCAD.ActiveDocument.addObject(\"Surface::BSplineSurf\",\"%s\")", FeatName.c_str()); - doCommand(Doc, "FreeCAD.ActiveDocument.ActiveObject.filltype=1"); + // invalid fill type meaning the surface is just created and cancel should delete it + doCommand(Doc, "FreeCAD.ActiveDocument.ActiveObject.filltype=0"); doCommand(Doc, bspListCmd.str().c_str()); doCommand(Doc, "Gui.ActiveDocument.setEdit('%s',0)", FeatName.c_str()); updateActive();