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
This commit is contained in:
balazs-bamer
2015-02-05 15:37:12 +01:00
committed by wmayer
parent 2d5119c266
commit d3fb21f93b
3 changed files with 19 additions and 8 deletions

View File

@@ -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<BoundaryList.getSize(); i++){
int boundaryListSize = BoundaryList.getSize();
if(boundaryListSize > 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

View File

@@ -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[];
};
}

View File

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