Parametric refinement feature
This commit is contained in:
@@ -474,6 +474,7 @@ PyMOD_INIT_FUNC(Part)
|
||||
Part::Offset ::init();
|
||||
Part::Offset2D ::init();
|
||||
Part::Thickness ::init();
|
||||
Part::Refine ::init();
|
||||
|
||||
// Geometry types
|
||||
Part::Geometry ::init();
|
||||
|
||||
@@ -673,3 +673,28 @@ App::DocumentObjectExecReturn *Thickness::execute(void)
|
||||
this->Shape.setValue(shape);
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
PROPERTY_SOURCE(Part::Refine, Part::Feature)
|
||||
|
||||
Refine::Refine()
|
||||
{
|
||||
ADD_PROPERTY_TYPE(Source,(0),"Refine",App::Prop_None,"Source shape");
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Refine::execute(void)
|
||||
{
|
||||
Part::Feature* source = Source.getValue<Part::Feature*>();
|
||||
if (!source)
|
||||
return new App::DocumentObjectExecReturn("No part object linked.");
|
||||
|
||||
try {
|
||||
TopoShape myShape = source->Shape.getShape();
|
||||
this->Shape.setValue(myShape.removeSplitter());
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
return new App::DocumentObjectExecReturn(e.GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +154,25 @@ private:
|
||||
static const char* JoinEnums[];
|
||||
};
|
||||
|
||||
class Refine : public Part::Feature
|
||||
{
|
||||
PROPERTY_HEADER(Part::Refine);
|
||||
|
||||
public:
|
||||
Refine();
|
||||
|
||||
App::PropertyLink Source;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartGui::ViewProviderRefine";
|
||||
}
|
||||
//@}
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
||||
|
||||
|
||||
@@ -171,6 +171,7 @@ PyMOD_INIT_FUNC(PartGui)
|
||||
PartGui::ViewProviderOffset ::init();
|
||||
PartGui::ViewProviderOffset2D ::init();
|
||||
PartGui::ViewProviderThickness ::init();
|
||||
PartGui::ViewProviderRefine ::init();
|
||||
PartGui::ViewProviderCustom ::init();
|
||||
PartGui::ViewProviderCustomPython ::init();
|
||||
PartGui::ViewProviderBoolean ::init();
|
||||
|
||||
@@ -235,21 +235,37 @@ CmdPartRefineShape::CmdPartRefineShape()
|
||||
void CmdPartRefineShape::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
|
||||
bool parametric = hGrp->GetBool("ParametricRefine", true);
|
||||
|
||||
Gui::WaitCursor wc;
|
||||
Base::Type partid = Base::Type::fromName("Part::Feature");
|
||||
std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType(partid);
|
||||
openCommand("Refine shape");
|
||||
for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) {
|
||||
try {
|
||||
doCommand(Doc,"App.ActiveDocument.addObject('Part::Feature','%s').Shape="
|
||||
"App.ActiveDocument.%s.Shape.removeSplitter()\n"
|
||||
"App.ActiveDocument.ActiveObject.Label="
|
||||
"App.ActiveDocument.%s.Label\n"
|
||||
"Gui.ActiveDocument.%s.hide()\n",
|
||||
(*it)->getNameInDocument(),
|
||||
(*it)->getNameInDocument(),
|
||||
(*it)->getNameInDocument(),
|
||||
(*it)->getNameInDocument());
|
||||
if (parametric) {
|
||||
doCommand(Doc,"App.ActiveDocument.addObject('Part::Refine','%s').Source="
|
||||
"App.ActiveDocument.%s\n"
|
||||
"App.ActiveDocument.ActiveObject.Label="
|
||||
"App.ActiveDocument.%s.Label\n"
|
||||
"Gui.ActiveDocument.%s.hide()\n",
|
||||
(*it)->getNameInDocument(),
|
||||
(*it)->getNameInDocument(),
|
||||
(*it)->getNameInDocument(),
|
||||
(*it)->getNameInDocument());
|
||||
}
|
||||
else {
|
||||
doCommand(Doc,"App.ActiveDocument.addObject('Part::Feature','%s').Shape="
|
||||
"App.ActiveDocument.%s.Shape.removeSplitter()\n"
|
||||
"App.ActiveDocument.ActiveObject.Label="
|
||||
"App.ActiveDocument.%s.Label\n"
|
||||
"Gui.ActiveDocument.%s.hide()\n",
|
||||
(*it)->getNameInDocument(),
|
||||
(*it)->getNameInDocument(),
|
||||
(*it)->getNameInDocument(),
|
||||
(*it)->getNameInDocument());
|
||||
}
|
||||
copyVisual("ActiveObject", "ShapeColor", (*it)->getNameInDocument());
|
||||
copyVisual("ActiveObject", "LineColor", (*it)->getNameInDocument());
|
||||
copyVisual("ActiveObject", "PointColor", (*it)->getNameInDocument());
|
||||
|
||||
@@ -667,3 +667,16 @@ bool ViewProviderThickness::onDelete(const std::vector<std::string> &)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
PROPERTY_SOURCE(PartGui::ViewProviderRefine, PartGui::ViewProviderPart)
|
||||
|
||||
ViewProviderRefine::ViewProviderRefine()
|
||||
{
|
||||
sPixmap = "Part_Refine_Shape";
|
||||
}
|
||||
|
||||
ViewProviderRefine::~ViewProviderRefine()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -193,6 +193,17 @@ protected:
|
||||
virtual void unsetEdit(int ModNum);
|
||||
};
|
||||
|
||||
class ViewProviderRefine : public ViewProviderPart
|
||||
{
|
||||
PROPERTY_HEADER(PartGui::ViewProviderRefine);
|
||||
|
||||
public:
|
||||
/// constructor
|
||||
ViewProviderRefine();
|
||||
/// destructor
|
||||
virtual ~ViewProviderRefine();
|
||||
};
|
||||
|
||||
} // namespace PartGui
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user