From d3fb21f93b8ffc30536d93b759c6639fa0eefea4 Mon Sep 17 00:00:00 2001 From: balazs-bamer Date: Thu, 5 Feb 2015 15:37:12 +0100 Subject: [PATCH] PropertyEnumerator for fill type Fill type is now of type PropertyEnumerator, allowing enumerated names in the Data tab. However, it has 2 problems: 1. Invalid shows up 2. The user has the illusion to see the result after changing the value. However, the result gets updated only --- src/Mod/Surface/App/FeatureBSurf.cpp | 18 +++++++++++++----- src/Mod/Surface/App/FeatureBSurf.h | 5 ++++- src/Mod/Surface/Gui/Command.cpp | 4 ++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Mod/Surface/App/FeatureBSurf.cpp b/src/Mod/Surface/App/FeatureBSurf.cpp index 206da33453..559d8cf64c 100644 --- a/src/Mod/Surface/App/FeatureBSurf.cpp +++ b/src/Mod/Surface/App/FeatureBSurf.cpp @@ -44,10 +44,13 @@ using namespace Surface; PROPERTY_SOURCE(Surface::BSurf, Part::Feature) +const char* BSurf::FillTypeEnums[] = {"Invalid", "Sretched", "Coons", "Curved", NULL}; + BSurf::BSurf(): Feature() { - ADD_PROPERTY(FillType,(1)); - ADD_PROPERTY(BoundaryList,(0,"Dummy")); + ADD_PROPERTY_TYPE(FillType, ((long)0), "Surface", App::Prop_None, "Boundary of the surface"); + ADD_PROPERTY_TYPE(BoundaryList, (0,"Dummy"), "Surface", App::Prop_None, "Boundary of the surface"); + FillType.setEnums(FillTypeEnums); } @@ -78,10 +81,15 @@ void BSurf::getWire(TopoDS_Wire& aWire) Handle(ShapeFix_Wire) aShFW = new ShapeFix_Wire; Handle(ShapeExtend_WireData) aWD = new ShapeExtend_WireData; - if(BoundaryList.getSize()>4 || BoundaryList.getSize()<2){Standard_Failure::Raise("Only 2-4 curves are allowed");return;} - - for(int i=0; i 4 || boundaryListSize < 2) + { + Standard_Failure::Raise("Only 2-4 curves are allowed"); + return; + } + for(int i = 0; i < boundaryListSize; i++) + { Part::TopoShape ts; //Curve TopoShape TopoDS_Shape sub; //Curve TopoDS_Shape TopoDS_Edge etmp; //Curve TopoDS_Edge diff --git a/src/Mod/Surface/App/FeatureBSurf.h b/src/Mod/Surface/App/FeatureBSurf.h index 8d73633c03..287ae206de 100644 --- a/src/Mod/Surface/App/FeatureBSurf.h +++ b/src/Mod/Surface/App/FeatureBSurf.h @@ -44,7 +44,7 @@ class BSurf : public Part::Feature public: BSurf(); App::PropertyLinkSubList BoundaryList; //curves to be turned into a face (2-4 curves allowed). - App::PropertyInteger FillType; //Fill method (1, 2, or 3 for Stretch, Coons, and Curved) + App::PropertyEnumeration FillType; //Fill method (1, 2, or 3 for Stretch, Coons, and Curved) short mustExecute() const; @@ -60,6 +60,9 @@ protected: // corrects the initially invalid fill type void correcteInvalidFillType(); + +private: + static const char* FillTypeEnums[]; }; } diff --git a/src/Mod/Surface/Gui/Command.cpp b/src/Mod/Surface/Gui/Command.cpp index d6425fbc35..d83ecaf7c8 100644 --- a/src/Mod/Surface/Gui/Command.cpp +++ b/src/Mod/Surface/Gui/Command.cpp @@ -249,7 +249,7 @@ void CmdSurfaceBSurf::createSurface(const char *surfaceNamePrefix, const char *c std::string FeatName = getUniqueObjectName(surfaceNamePrefix); std::stringstream bspListCmd; - bspListCmd << "FreeCAD.ActiveDocument.ActiveObject.aBList = ["; + bspListCmd << "FreeCAD.ActiveDocument.ActiveObject.BoundaryList = ["; for (std::vector::iterator it = sel.begin(); it != sel.end(); ++it) { bspListCmd << "(App.activeDocument()." << it->getFeatName() << ", \'Edge1\'),"; } @@ -258,7 +258,7 @@ void CmdSurfaceBSurf::createSurface(const char *surfaceNamePrefix, const char *c openCommand(commandName); doCommand(Doc, pythonAddCommand, FeatName.c_str()); // invalid fill type meaning the surface is just created and cancel should delete it - doCommand(Doc, "FreeCAD.ActiveDocument.ActiveObject.filltype=0"); + doCommand(Doc, "FreeCAD.ActiveDocument.ActiveObject.FillType=0"); doCommand(Doc, bspListCmd.str().c_str()); doCommand(Doc, "Gui.ActiveDocument.setEdit('%s',0)", FeatName.c_str()); updateActive();