Part: add Offset2D feature

derived from Part::Offset, to re-use task dialog easily
This commit is contained in:
DeepSOIC 2016-09-02 00:50:48 +03:00 committed by wmayer
parent 1f6174e3f2
commit e3ca28baa8
6 changed files with 84 additions and 0 deletions

View File

@ -301,6 +301,7 @@ PyMODINIT_FUNC initPart()
Part::Loft ::init();
Part::Sweep ::init();
Part::Offset ::init();
Part::Offset2D ::init();
Part::Thickness ::init();
// Geometry types

View File

@ -93,3 +93,52 @@ App::DocumentObjectExecReturn *Offset::execute(void)
}
//-------------------------------------------------------------------------------------------------------
PROPERTY_SOURCE(Part::Offset2D, Part::Offset)
Offset2D::Offset2D()
{
this->SelfIntersection.setStatus(App::Property::Status::Hidden, true);
this->Mode.setValue(1); //switch to Pipe mode by default, because skin mode does not function properly on closed profiles.
}
Offset2D::~Offset2D()
{
}
short Offset2D::mustExecute() const
{
if (Source.isTouched())
return 1;
if (Value.isTouched())
return 1;
if (Mode.isTouched())
return 1;
if (Join.isTouched())
return 1;
if (Fill.isTouched())
return 1;
if (Intersection.isTouched())
return 1;
return 0;
}
App::DocumentObjectExecReturn *Offset2D::execute(void)
{
App::DocumentObject* source = Source.getValue();
if (!(source && source->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())))
return new App::DocumentObjectExecReturn("No source shape linked.");
double offset = Value.getValue();
short mode = (short)Mode.getValue();
short join = (short)Join.getValue();
bool fill = Fill.getValue();
bool inter = Intersection.getValue();
if (mode == 2)
return new App::DocumentObjectExecReturn("Mode 'Recto-Verso' is not supported for 2D offset.");
const TopoShape& shape = static_cast<Part::Feature*>(source)->Shape.getShape();
this->Shape.setValue(shape.makeOffset2D(offset, join, fill, mode == 0, inter));
return App::DocumentObject::StdReturn;
}

View File

@ -61,5 +61,23 @@ private:
static const char* JoinEnums[];
};
class PartExport Offset2D : public Offset
{
PROPERTY_HEADER(Part::Offset2D);
public:
Offset2D();
~Offset2D();
/** @name methods override feature */
//@{
/// recalculate the feature
virtual App::DocumentObjectExecReturn *execute(void) override;
virtual short mustExecute() const override;
virtual const char* getViewProviderName(void) const override {
return "PartGui::ViewProviderOffset2D";
}
//@}
};
}
#endif // PART_FEATUREOFFSET_H

View File

@ -150,6 +150,7 @@ PyMODINIT_FUNC initPartGui()
PartGui::ViewProviderLoft ::init();
PartGui::ViewProviderSweep ::init();
PartGui::ViewProviderOffset ::init();
PartGui::ViewProviderOffset2D ::init();
PartGui::ViewProviderThickness ::init();
PartGui::ViewProviderCustom ::init();
PartGui::ViewProviderCustomPython ::init();

View File

@ -581,6 +581,11 @@ bool ViewProviderOffset::onDelete(const std::vector<std::string> &)
return true;
}
// ---------------------------------------
PROPERTY_SOURCE(PartGui::ViewProviderOffset2D, PartGui::ViewProviderOffset)
// ---------------------------------------
PROPERTY_SOURCE(PartGui::ViewProviderThickness, PartGui::ViewProviderPart)

View File

@ -163,6 +163,16 @@ protected:
virtual void unsetEdit(int ModNum);
};
class ViewProviderOffset2D : public ViewProviderOffset
{
PROPERTY_HEADER(PartGui::ViewProviderOffset2D);
public:
ViewProviderOffset2D(){
sPixmap = "Part_Offset2D";
}
};
class ViewProviderThickness : public ViewProviderPart
{
PROPERTY_HEADER(PartGui::ViewProviderThickness);