make origin work correct with multiple parts
This commit is contained in:
parent
ec68192fcf
commit
6347fe8c86
|
@ -67,6 +67,7 @@ ViewProviderPart::ViewProviderPart()
|
|||
|
||||
ViewProviderPart::~ViewProviderPart()
|
||||
{
|
||||
connection.disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,7 +81,7 @@ void ViewProviderPart::onChanged(const App::Property* prop)
|
|||
|
||||
void ViewProviderPart::attach(App::DocumentObject *pcObj)
|
||||
{
|
||||
pcObj->getDocument()->signalChangedObject.connect(boost::bind(&ViewProviderPart::onObjectChanged, this, _1, _2));
|
||||
connection = pcObj->getDocument()->signalChangedObject.connect(boost::bind(&ViewProviderPart::onObjectChanged, this, _1, _2));
|
||||
ViewProviderGeoFeatureGroup::attach(pcObj);
|
||||
}
|
||||
|
||||
|
@ -100,7 +101,7 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
|
|||
View3DInventorViewer* viewer = static_cast<View3DInventor*>(this->getActiveView())->getViewer();
|
||||
SoGetBoundingBoxAction bboxAction(viewer->getSoRenderManager()->getViewportRegion());
|
||||
|
||||
//calculate for everything but planes
|
||||
//calculate for everything but datums
|
||||
SbBox3f bbox(1e-9, 1e-9, 1e-9, 1e-9, 1e-9, 1e-9);
|
||||
for(App::DocumentObject* obj : part->getObjects()) {
|
||||
if(obj->getTypeId() != App::Origin::getClassTypeId() &&
|
||||
|
@ -139,11 +140,11 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
|
|||
|
||||
Gui::ViewProviderPlane* vp = dynamic_cast<Gui::ViewProviderPlane*>(Gui::Application::Instance->getViewProvider(*p));
|
||||
if(vp) {
|
||||
if (strcmp(App::Part::BaseplaneTypes[0], dynamic_cast<App::Plane*>(*p)->getNameInDocument()) == 0)
|
||||
if (strcmp(App::Part::BaseplaneTypes[0], dynamic_cast<App::Plane*>(*p)->PlaneType.getValue()) == 0)
|
||||
vp->Size.setValue(std::max(std::abs(std::min(min[0], min[1])),std::max(max[0], max[1])));
|
||||
else if (strcmp(App::Part::BaseplaneTypes[1], dynamic_cast<App::Plane*>(*p)->getNameInDocument()) == 0)
|
||||
else if (strcmp(App::Part::BaseplaneTypes[1], dynamic_cast<App::Plane*>(*p)->PlaneType.getValue()) == 0)
|
||||
vp->Size.setValue(std::max(std::abs(std::min(min[0], min[2])),std::max(max[0], max[2])));
|
||||
else if (strcmp(App::Part::BaseplaneTypes[2], dynamic_cast<App::Plane*>(*p)->getNameInDocument()) == 0)
|
||||
else if (strcmp(App::Part::BaseplaneTypes[2], dynamic_cast<App::Plane*>(*p)->PlaneType.getValue()) == 0)
|
||||
vp->Size.setValue(std::max(std::abs(std::min(min[1], min[2])),std::max(max[1], max[2])));
|
||||
}
|
||||
}
|
||||
|
@ -154,11 +155,11 @@ void ViewProviderPart::onObjectChanged(const App::DocumentObject& obj, const App
|
|||
|
||||
Gui::ViewProviderLine* vp = dynamic_cast<Gui::ViewProviderLine*>(Gui::Application::Instance->getViewProvider(*p));
|
||||
if(vp) {
|
||||
if (strcmp(App::Part::BaselineTypes[0], dynamic_cast<App::Line*>(*p)->getNameInDocument()) == 0)
|
||||
if (strcmp(App::Part::BaselineTypes[0], dynamic_cast<App::Line*>(*p)->LineType.getValue()) == 0)
|
||||
vp->Size.setValue(std::max(std::abs(std::min(min[0], min[1])),std::max(max[0], max[1])));
|
||||
else if (strcmp(App::Part::BaselineTypes[1], dynamic_cast<App::Line*>(*p)->getNameInDocument()) == 0)
|
||||
else if (strcmp(App::Part::BaselineTypes[1], dynamic_cast<App::Line*>(*p)->LineType.getValue()) == 0)
|
||||
vp->Size.setValue(std::max(std::abs(std::min(min[0], min[2])),std::max(max[0], max[2])));
|
||||
else if (strcmp(App::Part::BaselineTypes[2], dynamic_cast<App::Line*>(*p)->getNameInDocument()) == 0)
|
||||
else if (strcmp(App::Part::BaselineTypes[2], dynamic_cast<App::Line*>(*p)->LineType.getValue()) == 0)
|
||||
vp->Size.setValue(std::max(std::abs(std::min(min[1], min[2])),std::max(max[1], max[2])));
|
||||
}
|
||||
}
|
||||
|
@ -223,39 +224,52 @@ void ViewProviderPart::setUpPart(const App::Part *part)
|
|||
|
||||
if (!found) {
|
||||
// ... and put them in the 'Origin' group
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"Origin = App.activeDocument().addObject('App::Origin','%s')", "Origin");
|
||||
std::string oname = part->getDocument()->getUniqueObjectName("Origin");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"Origin = App.activeDocument().addObject('App::Origin','%s')", oname.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"Origin.Label = '%s'", QObject::tr("Origin").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(Origin)", part->getNameInDocument());
|
||||
|
||||
// Add the planes ...
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", App::Part::BaseplaneTypes[0]);
|
||||
std::string pname = part->getDocument()->getUniqueObjectName(App::Part::BaseplaneTypes[0]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", pname.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.PlaneType = '%s'", App::Part::BaseplaneTypes[0]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XY-Plane").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", App::Part::BaseplaneTypes[1]);
|
||||
pname = part->getDocument()->getUniqueObjectName(App::Part::BaseplaneTypes[1]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", pname.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(1,0,0),90))");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.PlaneType = '%s'", App::Part::BaseplaneTypes[1]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("XZ-Plane").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", App::Part::BaseplaneTypes[2]);
|
||||
pname = part->getDocument()->getUniqueObjectName(App::Part::BaseplaneTypes[2]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Plane','%s')", pname.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(1,1,1),120))");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.PlaneType = '%s'", App::Part::BaseplaneTypes[2]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("YZ-Plane").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
|
||||
|
||||
// Add the lines ...
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%s')", App::Part::BaselineTypes[0]);
|
||||
std::string lname = part->getDocument()->getUniqueObjectName(App::Part::BaselineTypes[0]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%s')", lname.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.LineType = '%s'", App::Part::BaselineTypes[0]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("X-Axis").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%s')", App::Part::BaselineTypes[1]);
|
||||
lname = part->getDocument()->getUniqueObjectName(App::Part::BaselineTypes[1]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%s')", lname.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(0,0,1),90))");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.LineType = '%s'", App::Part::BaselineTypes[1]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("Y-Axis").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%s')", App::Part::BaselineTypes[2]);
|
||||
lname = part->getDocument()->getUniqueObjectName(App::Part::BaselineTypes[2]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject('App::Line','%s')", lname.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Placement = App.Placement(App.Vector(),App.Rotation(App.Vector(0,1,0),90))");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.LineType = '%s'", App::Part::BaselineTypes[2]);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().ActiveObject.Label = '%s'", QObject::tr("Z-Axis").toStdString().c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().Origin.addObject(App.activeDocument().ActiveObject)");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().ActiveObject)", oname.c_str());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ protected:
|
|||
void onObjectChanged(const App::DocumentObject&, const App::Property&);
|
||||
|
||||
private:
|
||||
|
||||
boost::signals::connection connection;
|
||||
};
|
||||
|
||||
typedef ViewProviderPythonFeatureT<ViewProviderPart> ViewProviderPartPython;
|
||||
|
|
|
@ -342,11 +342,11 @@ void CoordinateSystem::onChanged(const App::Property *prop)
|
|||
if(!plane) {
|
||||
gp_Pnt base(0,0,0);
|
||||
gp_Dir dir(0,0,1);
|
||||
if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
dir = gp_Dir(0,0,1);
|
||||
else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
else if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
dir = gp_Dir(0,1,0);
|
||||
else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
else if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
dir = gp_Dir(1,0,0);
|
||||
|
||||
pln = gp_Pln(base, dir);
|
||||
|
@ -372,11 +372,11 @@ void CoordinateSystem::onChanged(const App::Property *prop)
|
|||
App::Line* p = static_cast<App::Line*>(refs[i]);
|
||||
gp_Pnt base(0,0,0);
|
||||
gp_Dir dir(0,0,1);
|
||||
if (strcmp(p->getNameInDocument(), App::Part::BaselineTypes[0]) == 0)
|
||||
if (strcmp(p->LineType.getValue(), App::Part::BaselineTypes[0]) == 0)
|
||||
dir = gp_Dir(1,0,0);
|
||||
else if (strcmp(p->getNameInDocument(), App::Part::BaselineTypes[1]) == 0)
|
||||
else if (strcmp(p->LineType.getValue(), App::Part::BaselineTypes[1]) == 0)
|
||||
dir = gp_Dir(0,1,0);
|
||||
else if (strcmp(p->getNameInDocument(), App::Part::BaselineTypes[2]) == 0)
|
||||
else if (strcmp(p->LineType.getValue(), App::Part::BaselineTypes[2]) == 0)
|
||||
dir = gp_Dir(0,0,1);
|
||||
|
||||
if(!line1) {
|
||||
|
|
|
@ -166,7 +166,7 @@ void Line::onChanged(const App::Property *prop)
|
|||
|
||||
std::set<QString> hint = getHint();
|
||||
if (!((hint.size() == 1) && (hint.find(QObject::tr("Done")) != hint.end())))
|
||||
throw Base::Exception("Incomplete References"); // incomplete references
|
||||
return; // incomplete references
|
||||
|
||||
// Extract the geometry of the references
|
||||
Base::Vector3d* base = NULL;
|
||||
|
@ -212,11 +212,11 @@ void Line::onChanged(const App::Property *prop)
|
|||
} else if (refs[i]->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
App::Line* l = static_cast<App::Line*>(refs[i]);
|
||||
gp_Dir ldir;
|
||||
if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[0]) == 0)
|
||||
if (strcmp(l->LineType.getValue(), App::Part::BaselineTypes[0]) == 0)
|
||||
ldir = gp_Dir(1,0,0);
|
||||
else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[1]) == 0)
|
||||
else if (strcmp(l->LineType.getValue(), App::Part::BaselineTypes[1]) == 0)
|
||||
ldir = gp_Dir(0,1,0);
|
||||
else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[2]) == 0)
|
||||
else if (strcmp(l->LineType.getValue(), App::Part::BaselineTypes[2]) == 0)
|
||||
ldir = gp_Dir(0,0,1);
|
||||
|
||||
if (s1.IsNull()) {
|
||||
|
@ -259,11 +259,11 @@ void Line::onChanged(const App::Property *prop)
|
|||
// Note: We only handle the three base planes here
|
||||
gp_Pnt base(0,0,0);
|
||||
gp_Dir normal;
|
||||
if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
normal = gp_Dir(0,0,1);
|
||||
else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
else if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
normal = gp_Dir(1,0,0);
|
||||
else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
else if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
normal = gp_Dir(0,1,0);
|
||||
|
||||
double offset1 = Offset.getValue();
|
||||
|
|
|
@ -226,11 +226,11 @@ void Plane::onChanged(const App::Property *prop)
|
|||
App::Line* l = static_cast<App::Line*>(refs[i]);
|
||||
Base::Vector3d base = Base::Vector3d(0,0,0);
|
||||
gp_Dir dir;
|
||||
if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[0]) == 0)
|
||||
if (strcmp(l->LineType.getValue(), App::Part::BaselineTypes[0]) == 0)
|
||||
dir = gp_Dir(1,0,0);
|
||||
else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[1]) == 0)
|
||||
else if (strcmp(l->LineType.getValue(), App::Part::BaselineTypes[1]) == 0)
|
||||
dir = gp_Dir(0,1,0);
|
||||
else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[2]) == 0)
|
||||
else if (strcmp(l->LineType.getValue(), App::Part::BaselineTypes[2]) == 0)
|
||||
dir = gp_Dir(0,0,1);
|
||||
line = new gp_Lin(gp_Pnt(base.x, base.y, base.z), gp_Dir(dir.X(), dir.Y(), dir.Z()));
|
||||
} else if (refs[i]->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
|
||||
|
@ -242,11 +242,11 @@ void Plane::onChanged(const App::Property *prop)
|
|||
// Note: We only handle the three base planes here
|
||||
p1 = new Base::Vector3d(0,0,0);
|
||||
normal = new Base::Vector3d;
|
||||
if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
*normal = Base::Vector3d(0,0,1);
|
||||
else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
else if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
*normal = Base::Vector3d(0,1,0);
|
||||
else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
else if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
*normal = Base::Vector3d(1,0,0);
|
||||
} else if (refs[i]->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
Part::Feature* feature = static_cast<Part::Feature*>(refs[i]);
|
||||
|
|
|
@ -205,11 +205,11 @@ void Point::onChanged(const App::Property* prop)
|
|||
// Note: We only handle the three base planes here
|
||||
gp_Pnt base(0,0,0);
|
||||
gp_Dir normal;
|
||||
if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[0]) == 0)
|
||||
if (strcmp(l->LineType.getValue(), App::Part::BaselineTypes[0]) == 0)
|
||||
normal = gp_Dir(1,0,0);
|
||||
else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[1]) == 0)
|
||||
else if (strcmp(l->LineType.getValue(), App::Part::BaselineTypes[1]) == 0)
|
||||
normal = gp_Dir(0,1,0);
|
||||
else if (strcmp(l->getNameInDocument(), App::Part::BaselineTypes[2]) == 0)
|
||||
else if (strcmp(l->LineType.getValue(), App::Part::BaselineTypes[2]) == 0)
|
||||
normal = gp_Dir(0,0,1);
|
||||
|
||||
if (s1.IsNull())
|
||||
|
@ -222,11 +222,11 @@ void Point::onChanged(const App::Property* prop)
|
|||
// Note: We only handle the three base planes here
|
||||
gp_Pnt base(0,0,0);
|
||||
gp_Dir normal;
|
||||
if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
normal = gp_Dir(0,0,1);
|
||||
else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
else if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
normal = gp_Dir(1,0,0);
|
||||
else if (strcmp(p->getNameInDocument(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
else if (strcmp(p->PlaneType.getValue(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
normal = gp_Dir(0,1,0);
|
||||
|
||||
if (s1.IsNull())
|
||||
|
|
|
@ -1048,11 +1048,11 @@ void SketchBased::getAxis(const App::DocumentObject *pcReferenceAxis, const std:
|
|||
else if (pcReferenceAxis->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
const App::Line* line = static_cast<const App::Line*>(pcReferenceAxis);
|
||||
base = Base::Vector3d(0,0,0);
|
||||
if( strcmp(line->getNameInDocument(), App::Part::BaselineTypes[0]) == 0)
|
||||
if( strcmp(line->LineType.getValue(), App::Part::BaselineTypes[0]) == 0)
|
||||
dir = Base::Vector3d(1,0,0);
|
||||
else if( strcmp(line->getNameInDocument(), App::Part::BaselineTypes[1]) == 0)
|
||||
else if( strcmp(line->LineType.getValue(), App::Part::BaselineTypes[1]) == 0)
|
||||
dir = Base::Vector3d(0,1,0);
|
||||
else if( strcmp(line->getNameInDocument(), App::Part::BaselineTypes[2]) == 0)
|
||||
else if( strcmp(line->LineType.getValue(), App::Part::BaselineTypes[2]) == 0)
|
||||
dir = Base::Vector3d(0,0,1);
|
||||
|
||||
// Check that axis is perpendicular with sketch plane!
|
||||
|
|
|
@ -732,10 +732,16 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
else if (FaceFilter.match() || PlaneFilter.match()) {
|
||||
// get the selected object
|
||||
std::string supportString;
|
||||
Part::Feature* feat;
|
||||
App::DocumentObject* obj;
|
||||
|
||||
if (FaceFilter.match()) {
|
||||
feat = static_cast<Part::Feature*>(FaceFilter.Result[0][0].getObject());
|
||||
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();
|
||||
|
@ -765,17 +771,20 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
|
||||
supportString = FaceFilter.Result[0][0].getAsPropertyLinkSubString();
|
||||
} else {
|
||||
feat = static_cast<Part::Feature*>(PlaneFilter.Result[0][0].getObject());
|
||||
obj = static_cast<Part::Feature*>(PlaneFilter.Result[0][0].getObject());
|
||||
// TODO: Find out whether the user picked front or back of this plane
|
||||
supportString = std::string("(App.activeDocument().") + feat->getNameInDocument() + ", ['front'])";
|
||||
supportString = std::string("(App.activeDocument().") + obj->getNameInDocument() + ", ['front'])";
|
||||
}
|
||||
|
||||
if (!pcActiveBody->hasFeature(feat)) {
|
||||
if (!pcActiveBody->hasFeature(obj)) {
|
||||
bool isBasePlane = false;
|
||||
for (unsigned i = 0; i < 3; i++) {
|
||||
if (strcmp(App::Part::BaseplaneTypes[i], feat->getNameInDocument()) == 0) {
|
||||
isBasePlane = true;
|
||||
break;
|
||||
if(obj->isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
App::Plane* pfeat = static_cast<App::Plane*>(obj);
|
||||
for (unsigned i = 0; i < 3; i++) {
|
||||
if (strcmp(App::Part::BaseplaneTypes[i], pfeat->PlaneType.getValue()) == 0) {
|
||||
isBasePlane = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isBasePlane) {
|
||||
|
@ -783,7 +792,7 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
QObject::tr("You have to select a face or plane from the active body!"));
|
||||
return;
|
||||
}
|
||||
} else if (pcActiveBody->isAfterTip(feat)) {
|
||||
} else if (pcActiveBody->isAfterTip(obj)) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection from inactive feature"),
|
||||
QObject::tr("You have to select a face or plane before the current insert point, or move the insert point"));
|
||||
return;
|
||||
|
@ -814,14 +823,17 @@ void CmdPartDesignNewSketch::activated(int iMsg)
|
|||
for (std::vector<App::DocumentObject*>::iterator p = planes.begin(); p != planes.end(); p++) {
|
||||
// Check whether this plane is a base plane
|
||||
bool base = false;
|
||||
for (unsigned i = 0; i < 3; i++) {
|
||||
if (strcmp(App::Part::BaseplaneTypes[i], (*p)->getNameInDocument()) == 0) {
|
||||
status.push_back(PartDesignGui::TaskFeaturePick::basePlane);
|
||||
if (firstValidPlane == planes.end())
|
||||
firstValidPlane = p;
|
||||
validPlanes++;
|
||||
base = true;
|
||||
break;
|
||||
if((*p)->isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
App::Plane* pfeat = static_cast<App::Plane*>(*p);
|
||||
for (unsigned i = 0; i < 3; i++) {
|
||||
if (strcmp(App::Part::BaseplaneTypes[i], pfeat->PlaneType.getValue()) == 0) {
|
||||
status.push_back(PartDesignGui::TaskFeaturePick::basePlane);
|
||||
if (firstValidPlane == planes.end())
|
||||
firstValidPlane = p;
|
||||
validPlanes++;
|
||||
base = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (base) continue;
|
||||
|
|
|
@ -189,20 +189,16 @@ TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *p
|
|||
updateUI();
|
||||
|
||||
//temporary show coordinate systems for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(DatumView->getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
static_cast<Gui::ViewProviderOrigin*>(origin)->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
static_cast<Gui::ViewProviderOrigin*>(origin)->setTemporaryVisibilityAxis(true);
|
||||
static_cast<Gui::ViewProviderOrigin*>(origin)->setTemporaryVisibilityPlanes(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
App::Part* part = getPartFor(DatumView->getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QString makeRefText(std::set<QString> hint)
|
||||
|
@ -669,17 +665,14 @@ QString TaskDatumParameters::getReference(const int idx) const
|
|||
TaskDatumParameters::~TaskDatumParameters()
|
||||
{
|
||||
//end temporary view mode of coordinate system
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(DatumView->getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
static_cast<Gui::ViewProviderOrigin*>(origin)->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
App::Part* part = getPartFor(DatumView->getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
delete ui;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <App/Document.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Origin.h>
|
||||
#include <App/Line.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
@ -105,19 +106,16 @@ TaskGrooveParameters::TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidge
|
|||
setFocus ();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(vp->getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
App::Part* part = getPartFor(vp->getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskGrooveParameters::updateUI()
|
||||
|
@ -145,11 +143,13 @@ void TaskGrooveParameters::updateUI()
|
|||
bool undefined = false;
|
||||
if (pcReferenceAxis != NULL) {
|
||||
|
||||
if(strcmp(pcReferenceAxis->getNameInDocument(), App::Part::BaselineTypes[0])==0)
|
||||
bool is_base_line = pcReferenceAxis->isDerivedFrom(App::Line::getClassTypeId());
|
||||
|
||||
if(is_base_line && strcmp(static_cast<App::Line*>(pcReferenceAxis)->LineType.getValue(), App::Part::BaselineTypes[0])==0)
|
||||
ui->axis->setCurrentIndex(0);
|
||||
else if(strcmp(pcReferenceAxis->getNameInDocument(), App::Part::BaselineTypes[1])==0)
|
||||
else if(is_base_line && strcmp(static_cast<App::Line*>(pcReferenceAxis)->LineType.getValue(), App::Part::BaselineTypes[1])==0)
|
||||
ui->axis->setCurrentIndex(1);
|
||||
else if(strcmp(pcReferenceAxis->getNameInDocument(), App::Part::BaselineTypes[2])==0)
|
||||
else if(is_base_line && strcmp(static_cast<App::Line*>(pcReferenceAxis)->LineType.getValue(), App::Part::BaselineTypes[2])==0)
|
||||
ui->axis->setCurrentIndex(2);
|
||||
else if (!sub.empty() && sub.front() == "H_Axis")
|
||||
ui->axis->setCurrentIndex(3);
|
||||
|
@ -228,15 +228,15 @@ void TaskGrooveParameters::onAxisChanged(int num)
|
|||
|
||||
int maxcount = pcSketch->getAxisCount()+2;
|
||||
if (num == 0) {
|
||||
pcGroove->ReferenceAxis.setValue(pcGroove->getDocument()->getObject(App::Part::BaselineTypes[0]),
|
||||
pcGroove->ReferenceAxis.setValue(getPartLines(App::Part::BaselineTypes[0]),
|
||||
std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 1) {
|
||||
pcGroove->ReferenceAxis.setValue(pcGroove->getDocument()->getObject(App::Part::BaselineTypes[1]),
|
||||
pcGroove->ReferenceAxis.setValue(getPartLines(App::Part::BaselineTypes[1]),
|
||||
std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 2) {
|
||||
pcGroove->ReferenceAxis.setValue(pcGroove->getDocument()->getObject(App::Part::BaselineTypes[2]),
|
||||
pcGroove->ReferenceAxis.setValue(getPartLines(App::Part::BaselineTypes[2]),
|
||||
std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 3) {
|
||||
|
@ -307,11 +307,11 @@ void TaskGrooveParameters::getReferenceAxis(App::DocumentObject*& obj, std::vect
|
|||
if (obj) {
|
||||
int num = ui->axis->currentIndex();
|
||||
if(num == 0)
|
||||
obj = pcGroove->getDocument()->getObject(App::Part::BaselineTypes[0]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[0]);
|
||||
else if(num == 1)
|
||||
obj = pcGroove->getDocument()->getObject(App::Part::BaselineTypes[1]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[1]);
|
||||
else if(num == 2)
|
||||
obj = pcGroove->getDocument()->getObject(App::Part::BaselineTypes[2]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[2]);
|
||||
else if (num == 3)
|
||||
sub[0] = "H_Axis";
|
||||
else if (num == 4)
|
||||
|
@ -345,18 +345,15 @@ bool TaskGrooveParameters::getReversed(void) const
|
|||
TaskGrooveParameters::~TaskGrooveParameters()
|
||||
{
|
||||
//hide the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(vp->getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
break;
|
||||
App::Part* part = getPartFor(vp->getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <App/Document.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Origin.h>
|
||||
#include <App/Line.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
@ -166,19 +167,16 @@ void TaskLinearPatternParameters::setupUI()
|
|||
updateUI();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskLinearPatternParameters::updateUI()
|
||||
|
@ -210,15 +208,17 @@ void TaskLinearPatternParameters::updateUI()
|
|||
|
||||
bool undefined = false;
|
||||
if (directionFeature != NULL && !directions.empty()) {
|
||||
bool is_base_line = directionFeature->isDerivedFrom(App::Line::getClassTypeId());
|
||||
|
||||
if (directions.front() == "H_Axis")
|
||||
ui->comboDirection->setCurrentIndex(0);
|
||||
else if (directions.front() == "V_Axis")
|
||||
ui->comboDirection->setCurrentIndex(1);
|
||||
else if (strcmp(directionFeature->getNameInDocument(), App::Part::BaselineTypes[0]) == 0)
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[0]) == 0)
|
||||
ui->comboDirection->setCurrentIndex( sketch ? 2 : 0);
|
||||
else if (strcmp(directionFeature->getNameInDocument(), App::Part::BaselineTypes[1]) == 0)
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[1]) == 0)
|
||||
ui->comboDirection->setCurrentIndex(sketch ? 3 : 1);
|
||||
else if (strcmp(directionFeature->getNameInDocument(), App::Part::BaselineTypes[2]) == 0)
|
||||
else if (is_base_line && strcmp(static_cast<App::Line*>(directionFeature)->LineType.getValue(), App::Part::BaselineTypes[2]) == 0)
|
||||
ui->comboDirection->setCurrentIndex(sketch ? 4 : 2);
|
||||
else if (directions.front().size() > (sketch ? 4 : 2) && directions.front().substr(0,4) == "Axis") {
|
||||
int pos = (sketch ? 5 : 3) + std::atoi(directions.front().substr(4,4000).c_str());
|
||||
|
@ -301,9 +301,9 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges
|
|||
ui->comboDirection->setCurrentIndex(maxcount);
|
||||
ui->comboDirection->addItem(tr("Select reference..."));
|
||||
}
|
||||
} else if( strcmp(msg.pObjectName, App::Part::BaselineTypes[0]) == 0 ||
|
||||
strcmp(msg.pObjectName, App::Part::BaselineTypes[1]) == 0 ||
|
||||
strcmp(msg.pObjectName, App::Part::BaselineTypes[2]) == 0) {
|
||||
} else if( strstr(msg.pObjectName, App::Part::BaselineTypes[0]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[1]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[2]) == nullptr) {
|
||||
|
||||
std::vector<std::string> directions;
|
||||
App::DocumentObject* selObj;
|
||||
|
@ -376,17 +376,17 @@ void TaskLinearPatternParameters::onDirectionChanged(int num) {
|
|||
}
|
||||
}
|
||||
if (num == (pcSketch ? 2 : 0)) {
|
||||
pcLinearPattern->Direction.setValue(getObject()->getDocument()->getObject(App::Part::BaselineTypes[0]),
|
||||
pcLinearPattern->Direction.setValue(getPartLines(App::Part::BaselineTypes[0]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == (pcSketch ? 3 : 1)) {
|
||||
pcLinearPattern->Direction.setValue(getObject()->getDocument()->getObject(App::Part::BaselineTypes[1]),
|
||||
pcLinearPattern->Direction.setValue(getPartLines(App::Part::BaselineTypes[1]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == (pcSketch ? 4 : 2)) {
|
||||
pcLinearPattern->Direction.setValue(getObject()->getDocument()->getObject(App::Part::BaselineTypes[2]),
|
||||
pcLinearPattern->Direction.setValue(getPartLines(App::Part::BaselineTypes[2]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
|
@ -457,11 +457,11 @@ void TaskLinearPatternParameters::getDirection(App::DocumentObject*& obj, std::v
|
|||
sub[0] = "V_Axis";
|
||||
}
|
||||
if (num == (obj ? 2 : 0))
|
||||
obj = getObject()->getDocument()->getObject(App::Part::BaselineTypes[0]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[0]);
|
||||
else if (num == (obj ? 3 : 1))
|
||||
obj = getObject()->getDocument()->getObject(App::Part::BaselineTypes[1]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[1]);
|
||||
else if (num == (obj ? 4 : 2))
|
||||
obj = getObject()->getDocument()->getObject(App::Part::BaselineTypes[2]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[2]);
|
||||
else if (num >= (obj ? 5 : 3) && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-(obj ? 5 : 3));
|
||||
sub[0] = buf.toStdString();
|
||||
|
@ -494,18 +494,15 @@ const unsigned TaskLinearPatternParameters::getOccurrences(void) const
|
|||
TaskLinearPatternParameters::~TaskLinearPatternParameters()
|
||||
{
|
||||
//hide the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
delete ui;
|
||||
if (proxy)
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Plane.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
@ -139,19 +140,16 @@ void TaskMirroredParameters::setupUI()
|
|||
updateUI();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityPlanes(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskMirroredParameters::updateUI()
|
||||
|
@ -180,15 +178,17 @@ void TaskMirroredParameters::updateUI()
|
|||
|
||||
bool undefined = false;
|
||||
if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) {
|
||||
bool is_base_plane = mirrorPlaneFeature->isDerivedFrom(App::Plane::getClassTypeId());
|
||||
|
||||
if (mirrorPlanes.front() == "H_Axis")
|
||||
ui->comboPlane->setCurrentIndex(0);
|
||||
else if (mirrorPlanes.front() == "V_Axis")
|
||||
ui->comboPlane->setCurrentIndex(1);
|
||||
else if (strcmp(mirrorPlaneFeature->getNameInDocument(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[0]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 2 : 0));
|
||||
else if (strcmp(mirrorPlaneFeature->getNameInDocument(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[1]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 3 : 1));
|
||||
else if (strcmp(mirrorPlaneFeature->getNameInDocument(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
else if (is_base_plane && strcmp(static_cast<App::Plane*>(mirrorPlaneFeature)->PlaneType.getValue(), App::Part::BaseplaneTypes[2]) == 0)
|
||||
ui->comboPlane->setCurrentIndex((sketch ? 4 : 2));
|
||||
else if (mirrorPlanes.front().size() > (sketch ? 4 : 2) && mirrorPlanes.front().substr(0,4) == "Axis") {
|
||||
int pos = (sketch ? 5 : 3) + std::atoi(mirrorPlanes.front().substr(4,4000).c_str());
|
||||
|
@ -257,9 +257,9 @@ void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg
|
|||
ui->comboPlane->setCurrentIndex(maxcount);
|
||||
ui->comboPlane->addItem(tr("Select reference..."));
|
||||
}
|
||||
} else if( strcmp(msg.pObjectName, App::Part::BaseplaneTypes[0]) == 0 ||
|
||||
strcmp(msg.pObjectName, App::Part::BaseplaneTypes[1]) == 0 ||
|
||||
strcmp(msg.pObjectName, App::Part::BaseplaneTypes[2]) == 0) {
|
||||
} else if( strstr(msg.pObjectName, App::Part::BaseplaneTypes[0]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaseplaneTypes[1]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaseplaneTypes[2]) == nullptr) {
|
||||
|
||||
std::vector<std::string> planes;
|
||||
App::DocumentObject* selObj;
|
||||
|
@ -405,18 +405,15 @@ void TaskMirroredParameters::apply()
|
|||
TaskMirroredParameters::~TaskMirroredParameters()
|
||||
{
|
||||
//hide the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
delete ui;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Line.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
@ -159,19 +160,16 @@ void TaskPolarPatternParameters::setupUI()
|
|||
updateUI();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskPolarPatternParameters::updateUI()
|
||||
|
@ -203,13 +201,15 @@ void TaskPolarPatternParameters::updateUI()
|
|||
|
||||
bool undefined = false;
|
||||
if (axisFeature != NULL && !axes.empty()) {
|
||||
bool is_base_line = axisFeature->isDerivedFrom(App::Line::getClassTypeId());
|
||||
|
||||
if (axes.front() == "N_Axis") {
|
||||
ui->comboAxis->setCurrentIndex(0);
|
||||
} else if (strcmp(axisFeature->getNameInDocument(), App::Part::BaselineTypes[0]) == 0) {
|
||||
} else if (is_base_line && strcmp(static_cast<App::Line*>(axisFeature)->LineType.getValue(), App::Part::BaselineTypes[0]) == 0) {
|
||||
ui->comboAxis->setCurrentIndex((sketch ? 1 : 0));
|
||||
} else if (strcmp(axisFeature->getNameInDocument(), App::Part::BaselineTypes[1]) == 0) {
|
||||
} else if (is_base_line && strcmp(static_cast<App::Line*>(axisFeature)->LineType.getValue(), App::Part::BaselineTypes[1]) == 0) {
|
||||
ui->comboAxis->setCurrentIndex((sketch ? 2 : 1));
|
||||
} else if (strcmp(axisFeature->getNameInDocument(), App::Part::BaselineTypes[2]) == 0) {
|
||||
} else if (is_base_line && strcmp(static_cast<App::Line*>(axisFeature)->LineType.getValue(), App::Part::BaselineTypes[2]) == 0) {
|
||||
ui->comboAxis->setCurrentIndex((sketch ? 3 : 2));
|
||||
} else if (axes.front().size() > (sketch ? 4 : 3) && axes.front().substr(0,4) == "Axis") {
|
||||
int pos = (sketch ? 4 : 3) + std::atoi(axes.front().substr(4,4000).c_str());
|
||||
|
@ -292,9 +292,9 @@ void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges&
|
|||
ui->comboAxis->setCurrentIndex(1);
|
||||
ui->comboAxis->addItem(tr("Select reference..."));
|
||||
}
|
||||
} else if( strcmp(msg.pObjectName, App::Part::BaselineTypes[0]) == 0 ||
|
||||
strcmp(msg.pObjectName, App::Part::BaselineTypes[1]) == 0 ||
|
||||
strcmp(msg.pObjectName, App::Part::BaselineTypes[2]) == 0) {
|
||||
} else if( strstr(msg.pObjectName, App::Part::BaselineTypes[0]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[1]) == nullptr ||
|
||||
strstr(msg.pObjectName, App::Part::BaselineTypes[2]) == nullptr) {
|
||||
|
||||
std::vector<std::string> axes;
|
||||
App::DocumentObject* selObj;
|
||||
|
@ -363,17 +363,17 @@ void TaskPolarPatternParameters::onAxisChanged(int num) {
|
|||
}
|
||||
}
|
||||
if (num == (pcSketch ? 1 : 0)) {
|
||||
pcPolarPattern->Axis.setValue(getObject()->getDocument()->getObject(App::Part::BaselineTypes[0]),
|
||||
pcPolarPattern->Axis.setValue(getPartLines(App::Part::BaselineTypes[0]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == (pcSketch ? 2 : 1)) {
|
||||
pcPolarPattern->Axis.setValue(getObject()->getDocument()->getObject(App::Part::BaselineTypes[1]),
|
||||
pcPolarPattern->Axis.setValue(getPartLines(App::Part::BaselineTypes[1]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
else if (num == (pcSketch ? 3 : 2)) {
|
||||
pcPolarPattern->Axis.setValue(getObject()->getDocument()->getObject(App::Part::BaselineTypes[2]),
|
||||
pcPolarPattern->Axis.setValue(getPartLines(App::Part::BaselineTypes[2]),
|
||||
std::vector<std::string>(1,""));
|
||||
exitSelectionMode();
|
||||
}
|
||||
|
@ -443,11 +443,11 @@ void TaskPolarPatternParameters::getAxis(App::DocumentObject*& obj, std::vector<
|
|||
}
|
||||
}
|
||||
if (num == (obj ? 1 : 0))
|
||||
obj = getObject()->getDocument()->getObject(App::Part::BaselineTypes[0]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[0]);
|
||||
else if (num == (obj ? 2 : 1))
|
||||
obj = getObject()->getDocument()->getObject(App::Part::BaselineTypes[1]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[1]);
|
||||
else if (num == (obj ? 3 : 2))
|
||||
obj = getObject()->getDocument()->getObject(App::Part::BaselineTypes[2]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[2]);
|
||||
else if (num >= (obj ? 4 : 3) && num < maxcount) {
|
||||
QString buf = QString::fromUtf8("Axis%1").arg(num-(obj ? 4 : 3));
|
||||
sub[0] = buf.toStdString();
|
||||
|
@ -481,18 +481,15 @@ const unsigned TaskPolarPatternParameters::getOccurrences(void) const
|
|||
TaskPolarPatternParameters::~TaskPolarPatternParameters()
|
||||
{
|
||||
//hide the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
App::Part* part = getPartFor(getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
delete ui;
|
||||
if (proxy)
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <App/Document.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Origin.h>
|
||||
#include <App/Line.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
@ -105,19 +106,16 @@ TaskRevolutionParameters::TaskRevolutionParameters(ViewProviderRevolution *Revol
|
|||
setFocus ();
|
||||
|
||||
//show the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(RevolutionView->getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
App::Part* part = getPartFor(vp->getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(true, Gui::Application::Instance->activeDocument());
|
||||
origin->setTemporaryVisibilityAxis(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskRevolutionParameters::updateUI()
|
||||
|
@ -144,11 +142,13 @@ void TaskRevolutionParameters::updateUI()
|
|||
|
||||
bool undefined = false;
|
||||
if (pcReferenceAxis != NULL) {
|
||||
if(strcmp(pcReferenceAxis->getNameInDocument(), App::Part::BaselineTypes[0])==0)
|
||||
bool is_base_line = pcReferenceAxis->isDerivedFrom(App::Line::getClassTypeId());
|
||||
|
||||
if(is_base_line && strcmp(static_cast<App::Line*>(pcReferenceAxis)->LineType.getValue(), App::Part::BaselineTypes[0])==0)
|
||||
ui->axis->setCurrentIndex(0);
|
||||
else if(strcmp(pcReferenceAxis->getNameInDocument(), App::Part::BaselineTypes[1])==0)
|
||||
else if(is_base_line && strcmp(static_cast<App::Line*>(pcReferenceAxis)->LineType.getValue(), App::Part::BaselineTypes[1])==0)
|
||||
ui->axis->setCurrentIndex(1);
|
||||
else if(strcmp(pcReferenceAxis->getNameInDocument(), App::Part::BaselineTypes[2])==0)
|
||||
else if(is_base_line && strcmp(static_cast<App::Line*>(pcReferenceAxis)->LineType.getValue(), App::Part::BaselineTypes[2])==0)
|
||||
ui->axis->setCurrentIndex(2);
|
||||
else if(!sub.empty() && sub.front() == "H_Axis")
|
||||
ui->axis->setCurrentIndex(3);
|
||||
|
@ -228,16 +228,13 @@ void TaskRevolutionParameters::onAxisChanged(int num)
|
|||
|
||||
int maxcount = pcSketch->getAxisCount()+5;
|
||||
if (num == 0) {
|
||||
pcRevolution->ReferenceAxis.setValue(pcRevolution->getDocument()->getObject(App::Part::BaselineTypes[0]),
|
||||
std::vector<std::string>(1,""));
|
||||
pcRevolution->ReferenceAxis.setValue(getPartLines(App::Part::BaselineTypes[0]), std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 1) {
|
||||
pcRevolution->ReferenceAxis.setValue(pcRevolution->getDocument()->getObject(App::Part::BaselineTypes[1]),
|
||||
std::vector<std::string>(1,""));
|
||||
pcRevolution->ReferenceAxis.setValue(getPartLines(App::Part::BaselineTypes[1]), std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 2) {
|
||||
pcRevolution->ReferenceAxis.setValue(pcRevolution->getDocument()->getObject(App::Part::BaselineTypes[2]),
|
||||
std::vector<std::string>(1,""));
|
||||
pcRevolution->ReferenceAxis.setValue(getPartLines(App::Part::BaselineTypes[2]), std::vector<std::string>(1,""));
|
||||
}
|
||||
else if (num == 3) {
|
||||
pcRevolution->ReferenceAxis.setValue(pcSketch, std::vector<std::string>(1,"H_Axis"));
|
||||
|
@ -307,11 +304,11 @@ void TaskRevolutionParameters::getReferenceAxis(App::DocumentObject*& obj, std::
|
|||
if (obj) {
|
||||
int num = ui->axis->currentIndex();
|
||||
if(num == 0)
|
||||
obj = pcRevolution->getDocument()->getObject(App::Part::BaselineTypes[0]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[0]);
|
||||
else if(num == 1)
|
||||
obj = pcRevolution->getDocument()->getObject(App::Part::BaselineTypes[1]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[1]);
|
||||
else if(num == 2)
|
||||
obj = pcRevolution->getDocument()->getObject(App::Part::BaselineTypes[2]);
|
||||
obj = getPartLines(App::Part::BaselineTypes[2]);
|
||||
else if (num == 3)
|
||||
sub[0] = "H_Axis";
|
||||
else if (num == 4)
|
||||
|
@ -345,18 +342,15 @@ bool TaskRevolutionParameters::getReversed(void) const
|
|||
TaskRevolutionParameters::~TaskRevolutionParameters()
|
||||
{
|
||||
//hide the parts coordinate system axis for selection
|
||||
for(App::Part* part : App::GetApplication().getActiveDocument()->getObjectsOfType<App::Part>()) {
|
||||
|
||||
if(part->hasObject(vp->getObject(), true)) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
App::Part* part = getPartFor(vp->getObject(), false);
|
||||
if(part) {
|
||||
auto app_origin = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(!app_origin.empty()) {
|
||||
ViewProviderOrigin* origin;
|
||||
origin = static_cast<ViewProviderOrigin*>(Gui::Application::Instance->activeDocument()->getViewProvider(app_origin[0]));
|
||||
origin->setTemporaryVisibilityMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Plane.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Origin.h>
|
||||
#include <App/Line.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
@ -192,6 +195,51 @@ void TaskSketchBasedParameters::recomputeFeature()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
App::DocumentObject* TaskSketchBasedParameters::getPartPlanes(const char* str) const {
|
||||
|
||||
//TODO: Adjust to GRAPH handling when available
|
||||
App::DocumentObject* obj = vp->getObject();
|
||||
App::Part* part = getPartFor(obj, true);
|
||||
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
return nullptr;
|
||||
|
||||
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
|
||||
auto planes = orig->getObjectsOfType(App::Plane::getClassTypeId());
|
||||
for(App::DocumentObject* plane : planes) {
|
||||
|
||||
if( strcmp(static_cast<App::Plane*>(plane)->PlaneType.getValue(), str) == 0)
|
||||
return plane;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
App::DocumentObject* TaskSketchBasedParameters::getPartLines(const char* str) const {
|
||||
|
||||
//TODO: Adjust to GRAPH handling when available
|
||||
App::DocumentObject* obj = vp->getObject();
|
||||
App::Part* part = getPartFor(obj, true);
|
||||
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
return nullptr;
|
||||
|
||||
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
|
||||
auto lines = orig->getObjectsOfType(App::Line::getClassTypeId());
|
||||
for(App::DocumentObject* line : lines) {
|
||||
|
||||
if( strcmp(static_cast<App::Line*>(line)->LineType.getValue(), str) == 0)
|
||||
return line;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
TaskSketchBasedParameters::~TaskSketchBasedParameters()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -54,6 +54,9 @@ protected:
|
|||
const QByteArray onFaceName(const QString& text);
|
||||
QString getFaceReference(const QString& obj, const QString& sub) const;
|
||||
void recomputeFeature();
|
||||
|
||||
App::DocumentObject* getPartPlanes(const char* str) const;
|
||||
App::DocumentObject* getPartLines(const char* str) const;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onUpdateView(bool on);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
# include <QListWidgetItem>
|
||||
# include <QListWidget>
|
||||
# include <TopoDS_Shape.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
|
@ -36,6 +36,10 @@
|
|||
#include "Workbench.h"
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/Part.h>
|
||||
#include <App/Origin.h>
|
||||
#include <App/Plane.h>
|
||||
#include <App/Line.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
@ -174,6 +178,49 @@ PartDesign::Transformed *TaskTransformedParameters::getObject() const
|
|||
return static_cast<PartDesign::Transformed*>(TransformedView->getObject());
|
||||
}
|
||||
|
||||
App::DocumentObject* TaskTransformedParameters::getPartPlanes(const char* str) const {
|
||||
|
||||
//TODO: Adjust to GRAPH handling when available
|
||||
App::DocumentObject* obj = getObject();
|
||||
App::Part* part = getPartFor(obj, true);
|
||||
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
return nullptr;
|
||||
|
||||
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
|
||||
auto planes = orig->getObjectsOfType(App::Plane::getClassTypeId());
|
||||
for(App::DocumentObject* plane : planes) {
|
||||
|
||||
if( strcmp(static_cast<App::Plane*>(plane)->PlaneType.getValue(), str) == 0)
|
||||
return plane;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
App::DocumentObject* TaskTransformedParameters::getPartLines(const char* str) const {
|
||||
|
||||
//TODO: Adjust to GRAPH handling when available
|
||||
App::DocumentObject* obj = getObject();
|
||||
App::Part* part = getPartFor(obj, true);
|
||||
|
||||
std::vector<App::DocumentObject*> origs = part->getObjectsOfType(App::Origin::getClassTypeId());
|
||||
if(origs.size()<1)
|
||||
return nullptr;
|
||||
|
||||
App::Origin* orig = static_cast<App::Origin*>(origs[0]);
|
||||
auto lines = orig->getObjectsOfType(App::Line::getClassTypeId());
|
||||
for(App::DocumentObject* line : lines) {
|
||||
|
||||
if( strcmp(static_cast<App::Line*>(line)->LineType.getValue(), str) == 0)
|
||||
return line;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::recomputeFeature()
|
||||
{
|
||||
if (insideMultiTransform) {
|
||||
|
|
|
@ -102,6 +102,9 @@ protected:
|
|||
virtual void clearButtons()=0;
|
||||
static void removeItemFromListWidget(QListWidget* widget, const char* itemstr);
|
||||
|
||||
App::DocumentObject* getPartPlanes(const char* str) const;
|
||||
App::DocumentObject* getPartLines(const char* str) const;
|
||||
|
||||
protected:
|
||||
QWidget* proxy;
|
||||
ViewProviderTransformed *TransformedView;
|
||||
|
|
|
@ -89,6 +89,49 @@ PartDesign::Body *getBody(bool messageIfNot)
|
|||
|
||||
}
|
||||
|
||||
PartDesign::Body *getBodyFor(App::DocumentObject* obj, bool messageIfNot)
|
||||
{
|
||||
PartDesign::Body * activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
if(activeBody && activeBody->hasFeature(obj))
|
||||
return activeBody;
|
||||
|
||||
//try to find the part the object is in
|
||||
for(PartDesign::Body* b : obj->getDocument()->getObjectsOfType<PartDesign::Body>()) {
|
||||
if(b->isFeature(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;
|
||||
}
|
||||
|
||||
App::Part* getPartFor(App::DocumentObject* obj, bool messageIfNot) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @namespace PartDesignGui @class Workbench
|
||||
|
|
|
@ -52,6 +52,8 @@ namespace PartDesignGui {
|
|||
|
||||
/// Return active body or show a warning message
|
||||
PartDesign::Body *getBody(bool messageIfNot);
|
||||
PartDesign::Body *getBodyFor(App::DocumentObject*, bool messageIfNot);
|
||||
App::Part *getPartFor(App::DocumentObject*, bool messageIfNot);
|
||||
|
||||
/**
|
||||
* @author Werner Mayer
|
||||
|
|
Loading…
Reference in New Issue
Block a user