Cancelling the just created surface deletes it

Now if the user creates a surface, the cancel in the widget deletes it.
If an already existing one is opened for editing, cancel rejects the
user change in fill type, but the surface remains.
This commit is contained in:
balazs-bamer
2015-01-29 09:59:00 +01:00
committed by wmayer
parent 29eed4a3f6
commit 76c357ad70
7 changed files with 34 additions and 13 deletions

View File

@@ -57,6 +57,7 @@ BSplineSurf::BSplineSurf() : BSurf()
App::DocumentObjectExecReturn *BSplineSurf::execute(void)
{
correcteInvalidFillType();
//Begin Construction
try{
Handle_Geom_BSplineCurve crvs[4];

View File

@@ -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);
}
}

View File

@@ -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();
};
}

View File

@@ -57,6 +57,7 @@ BezSurf::BezSurf() : BSurf()
App::DocumentObjectExecReturn *BezSurf::execute(void)
{
correcteInvalidFillType();
//Begin Construction
try{
Handle_Geom_BezierCurve crvs[4];

View File

@@ -3,7 +3,7 @@
enum filltype_t
{
StretchStyle = 1, CoonsStyle, CurvedStyle
InvalidStyle = 0, StretchStyle, CoonsStyle, CurvedStyle
};
#endif // SURAFCE_FILLTYPE_H

View File

@@ -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()");
}

View File

@@ -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();