PartDesign: fix spacing in several files
This commit is contained in:
parent
7e1a76eb37
commit
ad461fc472
|
@ -226,7 +226,7 @@ const bool Body::isAllowed(const App::DocumentObject* f)
|
|||
f->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()) ||
|
||||
f->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()) ||
|
||||
//f->getTypeId().isDerivedFrom(Part::FeaturePython::getClassTypeId()) // trouble with this line on Windows!? Linker fails to find getClassTypeId() of the Part::FeaturePython...
|
||||
f->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())
|
||||
f->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,6 @@ void Body::removeFeature(App::DocumentObject* feature)
|
|||
}
|
||||
|
||||
|
||||
|
||||
App::DocumentObjectExecReturn *Body::execute(void)
|
||||
{
|
||||
/*
|
||||
|
@ -369,7 +368,7 @@ App::DocumentObjectExecReturn *Body::execute(void)
|
|||
return App::DocumentObject::StdReturn;
|
||||
|
||||
Shape.setValue(TipShape);
|
||||
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
|
@ -420,7 +419,7 @@ PyObject *Body::getPyObject(void)
|
|||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new BodyPy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
short mustExecute() const;
|
||||
/// returns the type name of the view provider
|
||||
const char* getViewProviderName(void) const {
|
||||
return "PartDesignGui::ViewProviderBody";
|
||||
|
|
|
@ -27,7 +27,7 @@ PyObject *BodyPy::getCustomAttributes(const char* /*attr*/) const
|
|||
|
||||
int BodyPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* BodyPy::addFeature(PyObject *args)
|
||||
|
|
|
@ -110,7 +110,7 @@ void CmdPartDesignPart::activated(int iMsg)
|
|||
doCommand(Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr(PartName.c_str()).toStdString().c_str());
|
||||
PartDesignGui::Workbench::setUpPart(dynamic_cast<App::Part *>(getDocument()->getObject(PartName.c_str())));
|
||||
doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PARTKEY, PartName.c_str());
|
||||
|
||||
|
||||
updateActive();
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ void CmdPartDesignBody::activated(int iMsg)
|
|||
// first check if Part is already created:
|
||||
App::Part *actPart = getDocument()->Tip.getValue<App::Part *>();
|
||||
std::string PartName;
|
||||
|
||||
|
||||
if(!actPart){
|
||||
// if not, creating a part and set it up by calling the appropiated function in Workbench
|
||||
//if we create a new part we automaticly get a new body, there is no need to create a second one
|
||||
|
@ -568,9 +568,9 @@ const QString getReferenceString(Gui::Command* cmd)
|
|||
QString::fromAscii(",'')]");
|
||||
}
|
||||
}
|
||||
|
||||
//datum features task can start without reference, as every needed one can be set from
|
||||
//withing the task.
|
||||
|
||||
//datum features task can start without reference, as every needed one can be set from
|
||||
//withing the task.
|
||||
return QString::fromAscii("");
|
||||
}
|
||||
|
||||
|
@ -750,12 +750,12 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
|
||||
if (FaceFilter.match()) {
|
||||
obj = FaceFilter.Result[0][0].getObject();
|
||||
|
||||
|
||||
if(!obj->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
|
||||
|
||||
Part::Feature* feat = static_cast<Part::Feature*>(obj);
|
||||
|
||||
|
||||
// FIXME: Reject or warn about feature that is outside of active body, and feature
|
||||
// that comes after the current insert point (Tip)
|
||||
const std::vector<std::string> &sub = FaceFilter.Result[0][0].getSubNames();
|
||||
|
@ -816,7 +816,7 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
std::string FeatName = getUniqueObjectName("Sketch");
|
||||
|
||||
openCommand("Create a Sketch on Face");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Sketcher::SketchObject','%s')",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().addObject('Sketcher::SketchObject','%s')",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Support = %s",FeatName.c_str(),supportString.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)",
|
||||
pcActiveBody->getNameInDocument(), FeatName.c_str());
|
||||
|
@ -877,15 +877,15 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
}
|
||||
|
||||
auto accepter = [=](const std::vector<App::DocumentObject*>& features) -> bool {
|
||||
|
||||
|
||||
if(features.empty())
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
auto worker = [=](const std::vector<App::DocumentObject*>& features) {
|
||||
App::Plane* plane = static_cast<App::Plane*>(features.front());
|
||||
App::Plane* plane = static_cast<App::Plane*>(features.front());
|
||||
std::string FeatName = getUniqueObjectName("Sketch");
|
||||
std::string supportString = std::string("(App.activeDocument().") + plane->getNameInDocument() +
|
||||
", ['" + (false ? "back" : "front") + "'])";
|
||||
|
@ -899,11 +899,11 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
//doCommand(Gui,"Gui.activeDocument().activeView().setCamera('%s')",cam.c_str());
|
||||
Gui::Command::doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
};
|
||||
|
||||
|
||||
// If there is more than one possibility, show dialog and let user pick plane
|
||||
bool reversed = false;
|
||||
if (validPlanes > 1) {
|
||||
|
||||
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
PartDesignGui::TaskDlgFeaturePick *pickDlg = qobject_cast<PartDesignGui::TaskDlgFeaturePick *>(dlg);
|
||||
if (dlg && !pickDlg) {
|
||||
|
@ -918,7 +918,7 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
else
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(dlg)
|
||||
Gui::Control().closeDialog();
|
||||
|
||||
|
@ -980,7 +980,7 @@ void finishFeature(const Gui::Command* cmd, const std::string& FeatName, const b
|
|||
const unsigned validateSketches(std::vector<App::DocumentObject*>& sketches,
|
||||
std::vector<PartDesignGui::TaskFeaturePick::featureStatus>& status,
|
||||
std::vector<App::DocumentObject*>::iterator& firstValidSketch)
|
||||
{
|
||||
{
|
||||
// TODO: If the user previously opted to allow multiple use of sketches or use of sketches from other bodies,
|
||||
// then count these as valid sketches!
|
||||
unsigned validSketches = 0;
|
||||
|
@ -1040,7 +1040,7 @@ void finishFeature(const Gui::Command* cmd, const std::string& FeatName, const b
|
|||
return validSketches;
|
||||
}
|
||||
|
||||
void prepareSketchBased(Gui::Command* cmd, const std::string& which,
|
||||
void prepareSketchBased(Gui::Command* cmd, const std::string& which,
|
||||
boost::function<void (Part::Part2DObject*, std::string)> func)
|
||||
{
|
||||
PartDesign::Body *pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */true);
|
||||
|
@ -1051,7 +1051,7 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which,
|
|||
std::vector<PartDesignGui::TaskFeaturePick::featureStatus> status;
|
||||
std::vector<App::DocumentObject*>::iterator firstValidSketch;
|
||||
std::vector<App::DocumentObject*> sketches = cmd->getSelection().getObjectsOfType(Part::Part2DObject::getClassTypeId());
|
||||
// Next let the user choose from a list of all eligible objects
|
||||
// Next let the user choose from a list of all eligible objects
|
||||
unsigned validSketches = validateSketches(sketches, status, firstValidSketch);
|
||||
if (validSketches == 0) {
|
||||
status.clear();
|
||||
|
@ -1063,17 +1063,17 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which,
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto accepter = [=](const std::vector<App::DocumentObject*>& features) -> bool {
|
||||
|
||||
|
||||
if(features.empty())
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
auto worker = [which, cmd, func](std::vector<App::DocumentObject*> features) {
|
||||
|
||||
|
||||
auto firstValidSketch = features.begin();
|
||||
Part::Part2DObject* sketch = static_cast<Part::Part2DObject*>(*firstValidSketch);
|
||||
|
||||
|
@ -1089,10 +1089,10 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which,
|
|||
|
||||
func(sketch, FeatName);
|
||||
};
|
||||
|
||||
|
||||
// If there is more than one selection/possibility, show dialog and let user pick sketch
|
||||
if (validSketches > 1) {
|
||||
|
||||
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
PartDesignGui::TaskDlgFeaturePick *pickDlg = qobject_cast<PartDesignGui::TaskDlgFeaturePick *>(dlg);
|
||||
if (dlg && !pickDlg) {
|
||||
|
@ -1107,7 +1107,7 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which,
|
|||
else
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(dlg)
|
||||
Gui::Control().closeDialog();
|
||||
|
||||
|
@ -1117,7 +1117,7 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which,
|
|||
else {
|
||||
worker(sketches);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void finishSketchBased(const Gui::Command* cmd, const Part::Part2DObject* sketch, const std::string& FeatName)
|
||||
|
@ -1144,12 +1144,12 @@ CmdPartDesignPad::CmdPartDesignPad()
|
|||
}
|
||||
|
||||
void CmdPartDesignPad::activated(int iMsg)
|
||||
{
|
||||
{
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) {
|
||||
|
||||
|
||||
if (FeatName.empty()) return;
|
||||
|
||||
|
||||
// specific parameters for Pad
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.Length = 10.0",FeatName.c_str());
|
||||
App::DocumentObjectGroup* grp = sketch->getGroup();
|
||||
|
@ -1164,7 +1164,7 @@ void CmdPartDesignPad::activated(int iMsg)
|
|||
finishSketchBased(cmd, sketch, FeatName);
|
||||
cmd->adjustCameraPosition();
|
||||
};
|
||||
|
||||
|
||||
prepareSketchBased(this, "Pad", worker);
|
||||
}
|
||||
|
||||
|
@ -1194,14 +1194,14 @@ void CmdPartDesignPocket::activated(int iMsg)
|
|||
{
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) {
|
||||
|
||||
|
||||
if (FeatName.empty()) return;
|
||||
|
||||
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.Length = 5.0",FeatName.c_str());
|
||||
finishSketchBased(cmd, sketch, FeatName);
|
||||
cmd->adjustCameraPosition();
|
||||
};
|
||||
|
||||
|
||||
prepareSketchBased(this, "Pocket", worker);
|
||||
}
|
||||
|
||||
|
@ -1231,7 +1231,7 @@ void CmdPartDesignRevolution::activated(int iMsg)
|
|||
{
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) {
|
||||
|
||||
|
||||
if (FeatName.empty()) return;
|
||||
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.ReferenceAxis = (App.activeDocument().%s,['V_Axis'])",
|
||||
|
@ -1240,11 +1240,11 @@ void CmdPartDesignRevolution::activated(int iMsg)
|
|||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(cmd->getDocument()->getObject(FeatName.c_str()));
|
||||
if (pcRevolution && pcRevolution->suggestReversed())
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.Reversed = 1",FeatName.c_str());
|
||||
|
||||
|
||||
finishSketchBased(cmd, sketch, FeatName);
|
||||
cmd->adjustCameraPosition();
|
||||
};
|
||||
|
||||
|
||||
prepareSketchBased(this, "Revolution", worker);
|
||||
}
|
||||
|
||||
|
@ -1271,10 +1271,10 @@ CmdPartDesignGroove::CmdPartDesignGroove()
|
|||
}
|
||||
|
||||
void CmdPartDesignGroove::activated(int iMsg)
|
||||
{
|
||||
{
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) {
|
||||
|
||||
|
||||
if (FeatName.empty()) return;
|
||||
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.ReferenceAxis = (App.activeDocument().%s,['V_Axis'])",
|
||||
|
@ -1314,19 +1314,19 @@ CmdPartDesignAdditivePipe::CmdPartDesignAdditivePipe()
|
|||
}
|
||||
|
||||
void CmdPartDesignAdditivePipe::activated(int iMsg)
|
||||
{
|
||||
{
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) {
|
||||
|
||||
|
||||
if (FeatName.empty()) return;
|
||||
|
||||
|
||||
// specific parameters for pipe
|
||||
Gui::Command::updateActive();
|
||||
|
||||
finishSketchBased(cmd, sketch, FeatName);
|
||||
cmd->adjustCameraPosition();
|
||||
};
|
||||
|
||||
|
||||
prepareSketchBased(this, "AdditivePipe", worker);
|
||||
}
|
||||
|
||||
|
@ -1354,19 +1354,19 @@ CmdPartDesignSubtractivePipe::CmdPartDesignSubtractivePipe()
|
|||
}
|
||||
|
||||
void CmdPartDesignSubtractivePipe::activated(int iMsg)
|
||||
{
|
||||
{
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd](Part::Part2DObject* sketch, std::string FeatName) {
|
||||
|
||||
|
||||
if (FeatName.empty()) return;
|
||||
|
||||
|
||||
// specific parameters for pipe
|
||||
Gui::Command::updateActive();
|
||||
|
||||
finishSketchBased(cmd, sketch, FeatName);
|
||||
cmd->adjustCameraPosition();
|
||||
};
|
||||
|
||||
|
||||
prepareSketchBased(this, "SubtractivePipe", worker);
|
||||
}
|
||||
|
||||
|
@ -1472,7 +1472,7 @@ void makeChamferOrFillet(Gui::Command* cmd, const std::string& which)
|
|||
QObject::tr("Select an edge, face or body. Only one body is allowed."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
|
||||
if (!selection[0].isObjectTypeOf(Part::Feature::getClassTypeId())){
|
||||
|
@ -1794,19 +1794,19 @@ bool CmdPartDesignThickness::isActive(void)
|
|||
// Common functions for all Transformed features
|
||||
//===========================================================================
|
||||
|
||||
void prepareTransformed(Gui::Command* cmd, const std::string& which,
|
||||
void prepareTransformed(Gui::Command* cmd, const std::string& which,
|
||||
boost::function<void(std::string, std::vector<App::DocumentObject*>)> func)
|
||||
{
|
||||
std::string FeatName = cmd->getUniqueObjectName(which.c_str());
|
||||
|
||||
auto accepter = [=](std::vector<App::DocumentObject*> features) -> bool{
|
||||
|
||||
|
||||
if(features.empty())
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
auto worker = [=](std::vector<App::DocumentObject*> features) {
|
||||
std::stringstream str;
|
||||
str << "App.activeDocument()." << FeatName << ".Originals = [";
|
||||
|
@ -1821,10 +1821,10 @@ void prepareTransformed(Gui::Command* cmd, const std::string& which,
|
|||
// Exception (Thu Sep 6 11:52:01 2012): 'App.Document' object has no attribute 'Mirrored'
|
||||
Gui::Command::updateActive(); // Helps to ensure that the object already exists when the next command comes up
|
||||
Gui::Command::doCommand(Gui::Command::Doc, str.str().c_str());
|
||||
|
||||
|
||||
func(FeatName, features);
|
||||
};
|
||||
|
||||
|
||||
// Get a valid original from the user
|
||||
// First check selections
|
||||
std::vector<App::DocumentObject*> features = cmd->getSelection().getObjectsOfType(PartDesign::FeatureAddSub::getClassTypeId());
|
||||
|
@ -1836,7 +1836,7 @@ void prepareTransformed(Gui::Command* cmd, const std::string& which,
|
|||
std::vector<PartDesignGui::TaskFeaturePick::featureStatus> status;
|
||||
for (unsigned i = 0; i < features.size(); i++)
|
||||
status.push_back(PartDesignGui::TaskFeaturePick::validFeature);
|
||||
|
||||
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
PartDesignGui::TaskDlgFeaturePick *pickDlg = qobject_cast<PartDesignGui::TaskDlgFeaturePick *>(dlg);
|
||||
if (dlg && !pickDlg) {
|
||||
|
@ -1851,7 +1851,7 @@ void prepareTransformed(Gui::Command* cmd, const std::string& which,
|
|||
else
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(dlg)
|
||||
Gui::Control().closeDialog();
|
||||
|
||||
|
@ -1894,10 +1894,10 @@ void CmdPartDesignMirrored::activated(int iMsg)
|
|||
{
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd](std::string FeatName, std::vector<App::DocumentObject*> features) {
|
||||
|
||||
|
||||
if (features.empty())
|
||||
return;
|
||||
|
||||
|
||||
if(features.front()->isDerivedFrom(PartDesign::SketchBased::getClassTypeId())) {
|
||||
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
|
||||
if (sketch)
|
||||
|
@ -1911,8 +1911,8 @@ void CmdPartDesignMirrored::activated(int iMsg)
|
|||
|
||||
finishTransformed(cmd, FeatName);
|
||||
};
|
||||
|
||||
prepareTransformed(this, "Mirrored", worker);
|
||||
|
||||
prepareTransformed(this, "Mirrored", worker);
|
||||
}
|
||||
|
||||
bool CmdPartDesignMirrored::isActive(void)
|
||||
|
@ -1941,7 +1941,7 @@ void CmdPartDesignLinearPattern::activated(int iMsg)
|
|||
{
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd](std::string FeatName, std::vector<App::DocumentObject*> features) {
|
||||
|
||||
|
||||
if (features.empty())
|
||||
return;
|
||||
|
||||
|
@ -1960,7 +1960,8 @@ void CmdPartDesignLinearPattern::activated(int iMsg)
|
|||
|
||||
finishTransformed(cmd, FeatName);
|
||||
};
|
||||
prepareTransformed(this, "LinearPattern", worker);
|
||||
|
||||
prepareTransformed(this, "LinearPattern", worker);
|
||||
}
|
||||
|
||||
bool CmdPartDesignLinearPattern::isActive(void)
|
||||
|
@ -1986,13 +1987,13 @@ CmdPartDesignPolarPattern::CmdPartDesignPolarPattern()
|
|||
}
|
||||
|
||||
void CmdPartDesignPolarPattern::activated(int iMsg)
|
||||
{
|
||||
{
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd](std::string FeatName, std::vector<App::DocumentObject*> features) {
|
||||
|
||||
|
||||
if (features.empty())
|
||||
return;
|
||||
|
||||
|
||||
if(features.front()->isDerivedFrom(PartDesign::SketchBased::getClassTypeId())) {
|
||||
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
|
||||
if (sketch)
|
||||
|
@ -2003,14 +2004,14 @@ void CmdPartDesignPolarPattern::activated(int iMsg)
|
|||
doCommand(Doc,"App.activeDocument().%s.Axis = (App.activeDocument().%s, [\"\"])", FeatName.c_str(),
|
||||
App::Part::BaselineTypes[0]);
|
||||
}
|
||||
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.Angle = 360", FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Occurrences = 2", FeatName.c_str());
|
||||
|
||||
finishTransformed(cmd, FeatName);
|
||||
};
|
||||
|
||||
prepareTransformed(this, "PolarPattern", worker);
|
||||
|
||||
prepareTransformed(this, "PolarPattern", worker);
|
||||
}
|
||||
|
||||
bool CmdPartDesignPolarPattern::isActive(void)
|
||||
|
@ -2036,20 +2037,20 @@ CmdPartDesignScaled::CmdPartDesignScaled()
|
|||
}
|
||||
|
||||
void CmdPartDesignScaled::activated(int iMsg)
|
||||
{
|
||||
{
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd](std::string FeatName, std::vector<App::DocumentObject*> features) {
|
||||
|
||||
|
||||
if (features.empty())
|
||||
return;
|
||||
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.Factor = 2", FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Occurrences = 2", FeatName.c_str());
|
||||
|
||||
finishTransformed(cmd, FeatName);
|
||||
};
|
||||
|
||||
prepareTransformed(this, "Scaled", worker);
|
||||
|
||||
prepareTransformed(this, "Scaled", worker);
|
||||
}
|
||||
|
||||
bool CmdPartDesignScaled::isActive(void)
|
||||
|
@ -2127,10 +2128,10 @@ void CmdPartDesignMultiTransform::activated(int iMsg)
|
|||
Gui::Selection().clearSelection();
|
||||
} // otherwise the insert point remains at the new MultiTransform, which is fine
|
||||
} else {
|
||||
|
||||
|
||||
Gui::Command* cmd = this;
|
||||
auto worker = [cmd, pcActiveBody](std::string FeatName, std::vector<App::DocumentObject*> features) {
|
||||
|
||||
|
||||
if (features.empty())
|
||||
return;
|
||||
|
||||
|
@ -2143,8 +2144,8 @@ void CmdPartDesignMultiTransform::activated(int iMsg)
|
|||
}
|
||||
finishFeature(cmd, FeatName);
|
||||
};
|
||||
|
||||
prepareTransformed(this, "MultiTransform", worker);
|
||||
|
||||
prepareTransformed(this, "MultiTransform", worker);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2198,9 +2199,9 @@ void CmdPartDesignBoolean::activated(int iMsg)
|
|||
|
||||
openCommand("Create Boolean");
|
||||
|
||||
PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
// Make sure we are working on the selected body
|
||||
if (body != activeBody) {
|
||||
if (body != activeBody) {
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelection(body->getDocument()->getName(), body->Tip.getValue()->getNameInDocument());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"FreeCADGui.runCommand('PartDesign_MoveTip')");
|
||||
|
@ -2255,9 +2256,9 @@ void CreatePartDesignCommands(void)
|
|||
rcCmdMgr.addCommand(new CmdPartDesignSubtractiveLoft);
|
||||
|
||||
rcCmdMgr.addCommand(new CmdPartDesignFillet());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignDraft());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignDraft());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignChamfer());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignThickness());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignThickness());
|
||||
|
||||
rcCmdMgr.addCommand(new CmdPartDesignMirrored());
|
||||
rcCmdMgr.addCommand(new CmdPartDesignLinearPattern());
|
||||
|
|
|
@ -80,7 +80,7 @@ PartDesign::Body *getBody(bool messageIfNot)
|
|||
if (!activeBody && messageIfNot){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Body"),
|
||||
QObject::tr("In order to use PartDesign you need an active Body object in the document. "
|
||||
"Please make one active (double click) or create one. If you have a legacy document "
|
||||
"Please make one active (double click) or create one. If you have a legacy document "
|
||||
"with PartDesign objects without Body, use the transfer function in "
|
||||
"PartDesign to put them into a Body."
|
||||
));
|
||||
|
@ -93,7 +93,7 @@ PartDesign::Body *getBodyFor(App::DocumentObject* obj, bool messageIfNot)
|
|||
{
|
||||
if(!obj)
|
||||
return nullptr;
|
||||
|
||||
|
||||
PartDesign::Body * activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
if(activeBody && activeBody->hasFeature(obj))
|
||||
return activeBody;
|
||||
|
@ -102,14 +102,14 @@ PartDesign::Body *getBodyFor(App::DocumentObject* obj, bool messageIfNot)
|
|||
for(PartDesign::Body* b : obj->getDocument()->getObjectsOfType<PartDesign::Body>()) {
|
||||
if(b->hasFeature(obj)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (messageIfNot){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Feature is not in a body"),
|
||||
QObject::tr("In order to use this feature it needs to belong to a body object in the document."));
|
||||
}
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -117,23 +117,23 @@ App::Part* getPartFor(App::DocumentObject* obj, bool messageIfNot) {
|
|||
|
||||
if(!obj)
|
||||
return nullptr;
|
||||
|
||||
|
||||
PartDesign::Body* body = getBodyFor(obj, false);
|
||||
if(body)
|
||||
obj = body;
|
||||
|
||||
|
||||
//get the part every body should belong to
|
||||
for(App::Part* p : obj->getDocument()->getObjectsOfType<App::Part>()) {
|
||||
if(p->hasObject(obj)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (messageIfNot){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Feature is not in a part"),
|
||||
QObject::tr("In order to use this feature it needs to belong to a part object in the document."));
|
||||
}
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -164,33 +164,33 @@ static void buildDefaultPartAndBody(const App::Document* doc)
|
|||
|
||||
PartDesign::Body *Workbench::setUpPart(const App::Part *part)
|
||||
{
|
||||
// first do the general Part setup
|
||||
Gui::ViewProviderPart::setUpPart(part);
|
||||
// first do the general Part setup
|
||||
Gui::ViewProviderPart::setUpPart(part);
|
||||
|
||||
// check for Bodies
|
||||
std::vector<App::DocumentObject*> bodies = part->getObjectsOfType(PartDesign::Body::getClassTypeId());
|
||||
assert(bodies.size() == 0);
|
||||
|
||||
std::string PartName = part->getNameInDocument();
|
||||
std::string BodyName = part->getDocument()->getUniqueObjectName("MainBody");
|
||||
// check for Bodies
|
||||
std::vector<App::DocumentObject*> bodies = part->getObjectsOfType(PartDesign::Body::getClassTypeId());
|
||||
assert(bodies.size() == 0);
|
||||
|
||||
Gui::Command::addModule(Gui::Command::Doc, "PartDesign");
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().addObject('PartDesign::Body','%s')", BodyName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", part->getNameInDocument());
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PDBODYKEY, BodyName.c_str());
|
||||
Gui::Command::updateActive();
|
||||
std::string PartName = part->getNameInDocument();
|
||||
std::string BodyName = part->getDocument()->getUniqueObjectName("MainBody");
|
||||
|
||||
return NULL;
|
||||
Gui::Command::addModule(Gui::Command::Doc, "PartDesign");
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().addObject('PartDesign::Body','%s')", BodyName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", part->getNameInDocument());
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", PDBODYKEY, BodyName.c_str());
|
||||
Gui::Command::updateActive();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Workbench::_doMigration(const App::Document* doc)
|
||||
{
|
||||
bool groupCreated = false;
|
||||
bool groupCreated = false;
|
||||
|
||||
if(doc->countObjects() != 0) {
|
||||
// show a warning about the convertion
|
||||
Gui::Dialog::DlgCheckableMessageBox::showMessage(
|
||||
QString::fromLatin1("PartDesign conversion warning"),
|
||||
QString::fromLatin1("PartDesign conversion warning"),
|
||||
QString::fromLatin1(
|
||||
"<h2>Converting PartDesign features to new Body centric schema</h2>"
|
||||
"If you are unsure what that mean save the document under a new name.<br>"
|
||||
|
@ -209,7 +209,7 @@ void Workbench::_doMigration(const App::Document* doc)
|
|||
Gui::Command::openCommand("Migrate part to Body feature");
|
||||
|
||||
// Get the objects now, before adding the Body and the base planes
|
||||
std::vector<App::DocumentObject*> features = doc->getObjects();
|
||||
std::vector<App::DocumentObject*> features = doc->getObjects();
|
||||
|
||||
// Assign all non-PartDesign features to a new group
|
||||
for (std::vector<App::DocumentObject*>::iterator f = features.begin(); f != features.end(); ) {
|
||||
|
@ -250,7 +250,7 @@ void Workbench::_doMigration(const App::Document* doc)
|
|||
for (std::vector<App::DocumentObject*>::iterator r = roots.begin(); r != roots.end(); r++) {
|
||||
if (r != roots.begin()) {
|
||||
Gui::Command::runCommand(Gui::Command::Doc, "FreeCADGui.runCommand('PartDesign_Body')");
|
||||
activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
}
|
||||
|
||||
std::set<App::DocumentObject*> inList;
|
||||
|
@ -402,27 +402,26 @@ void Workbench::_switchToDocument(const App::Document* doc)
|
|||
bool groupCreated = false;
|
||||
|
||||
|
||||
if (doc == NULL) return;
|
||||
if (doc == NULL) return;
|
||||
|
||||
PartDesign::Body* activeBody = NULL;
|
||||
std::vector<App::DocumentObject*> bodies = doc->getObjectsOfType(PartDesign::Body::getClassTypeId());
|
||||
|
||||
// No tip, so build up structure or migrate
|
||||
if (!doc->Tip.getValue())
|
||||
if (!doc->Tip.getValue())
|
||||
{
|
||||
if (doc->countObjects() == 0){
|
||||
buildDefaultPartAndBody(doc);
|
||||
activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
assert(activeBody);
|
||||
|
||||
} else {
|
||||
// empty document with no tip, so do migration
|
||||
_doMigration(doc);
|
||||
if (doc->countObjects() == 0){
|
||||
buildDefaultPartAndBody(doc);
|
||||
activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
assert(activeBody);
|
||||
} else {
|
||||
// empty document with no tip, so do migration
|
||||
_doMigration(doc);
|
||||
activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
assert(activeBody);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
App::Part *docPart = dynamic_cast<App::Part *>(doc->Tip.getValue());
|
||||
assert(docPart);
|
||||
|
@ -431,7 +430,7 @@ void Workbench::_switchToDocument(const App::Document* doc)
|
|||
Gui::Application::Instance->activeView()->setActiveObject(docPart, "Part");
|
||||
if (docPart->countObjectsOfType(PartDesign::Body::getClassTypeId()) < 1)
|
||||
setUpPart(docPart);
|
||||
|
||||
|
||||
PartDesign::Body *tempBody = dynamic_cast<PartDesign::Body *> (docPart->getObjectsOfType(PartDesign::Body::getClassTypeId()).front());
|
||||
assert(tempBody);
|
||||
PartDesign::Body *viewBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
|
@ -440,7 +439,7 @@ void Workbench::_switchToDocument(const App::Document* doc)
|
|||
activeBody = tempBody;
|
||||
else if (!docPart->hasObject(viewBody))
|
||||
activeBody = tempBody;
|
||||
|
||||
|
||||
if (activeBody != viewBody)
|
||||
Gui::Application::Instance->activeView()->setActiveObject(activeBody, PDBODYKEY);
|
||||
}
|
||||
|
@ -464,7 +463,7 @@ void Workbench::slotNewDocument(const App::Document& Doc)
|
|||
}
|
||||
|
||||
void Workbench::slotFinishRestoreDocument(const App::Document& Doc)
|
||||
{
|
||||
{
|
||||
// _switchToDocument(&Doc);
|
||||
}
|
||||
|
||||
|
@ -529,7 +528,7 @@ void Workbench::activated()
|
|||
"Vertex tools",
|
||||
"Part_Box"
|
||||
));
|
||||
|
||||
|
||||
const char* Edge[] = {
|
||||
"PartDesign_Fillet",
|
||||
"PartDesign_Chamfer",
|
||||
|
@ -545,7 +544,7 @@ void Workbench::activated()
|
|||
));
|
||||
|
||||
const char* Face[] = {
|
||||
"PartDesign_NewSketch",
|
||||
"PartDesign_NewSketch",
|
||||
"PartDesign_Fillet",
|
||||
"PartDesign_Chamfer",
|
||||
"PartDesign_Draft",
|
||||
|
@ -729,7 +728,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
|||
Gui::MenuItem* cons = new Gui::MenuItem();
|
||||
cons->setCommand("Sketcher constraints");
|
||||
SketcherGui::addSketcherWorkbenchConstraints( *cons );
|
||||
|
||||
|
||||
Gui::MenuItem* consaccel = new Gui::MenuItem();
|
||||
consaccel->setCommand("Sketcher tools");
|
||||
SketcherGui::addSketcherWorkbenchTools(*consaccel);
|
||||
|
@ -844,7 +843,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
|||
Gui::ToolBarItem* consaccel = new Gui::ToolBarItem(root);
|
||||
consaccel->setCommand("Sketcher tools");
|
||||
SketcherGui::addSketcherWorkbenchTools( *consaccel );
|
||||
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class ViewProviderDocumentObject;
|
|||
}
|
||||
|
||||
namespace PartDesign {
|
||||
class Body;
|
||||
class Body;
|
||||
}
|
||||
|
||||
namespace App {
|
||||
|
@ -78,14 +78,14 @@ public:
|
|||
/// Add custom entries to the context menu
|
||||
virtual void setupContextMenu(const char* recipient, Gui::MenuItem*) const;
|
||||
|
||||
/** Setup a Part for PartDesign
|
||||
* This methode is use to populate a Part object with all
|
||||
* necesarry PartDesign and base objects to allow the use
|
||||
* in PartDesign. Its called from within PartDesign as well
|
||||
* as from other modules which wish to set up a Part for PartDesin
|
||||
* (e.g. Assembly):
|
||||
*/
|
||||
static PartDesign::Body *setUpPart(const App::Part *);
|
||||
/** Setup a Part for PartDesign
|
||||
* This methode is use to populate a Part object with all
|
||||
* necesarry PartDesign and base objects to allow the use
|
||||
* in PartDesign. Its called from within PartDesign as well
|
||||
* as from other modules which wish to set up a Part for PartDesin
|
||||
* (e.g. Assembly):
|
||||
*/
|
||||
static PartDesign::Body *setUpPart(const App::Part *);
|
||||
|
||||
/// Fix sketch support after moving a free sketch into a body
|
||||
static void fixSketchSupport(Sketcher::SketchObject* sketch);
|
||||
|
@ -115,4 +115,4 @@ private:
|
|||
} // namespace PartDesignGui
|
||||
|
||||
|
||||
#endif // PARTDESIGN_WORKBENCH_H
|
||||
#endif // PARTDESIGN_WORKBENCH_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user