PartDesign: Allow use of circle edge as axis in PolarPattern
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Face.hxx>
|
||||
# include <gp_Lin.hxx>
|
||||
# include <gp_Circ.hxx>
|
||||
# include <gp_Ax2.hxx>
|
||||
# include <BRepAdaptor_Curve.hxx>
|
||||
#endif
|
||||
@@ -140,12 +141,16 @@ const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
|
||||
if (refEdge.IsNull())
|
||||
throw Base::ValueError("Failed to extract axis edge");
|
||||
BRepAdaptor_Curve adapt(refEdge);
|
||||
if (adapt.GetType() != GeomAbs_Line)
|
||||
throw Base::TypeError("Axis edge must be a straight line");
|
||||
|
||||
axbase = adapt.Value(adapt.FirstParameter());
|
||||
axdir = adapt.Line().Direction();
|
||||
} else {
|
||||
if (adapt.GetType() == GeomAbs_Line) {
|
||||
axbase = adapt.Line().Location();
|
||||
axdir = adapt.Line().Direction();
|
||||
} else if (adapt.GetType() == GeomAbs_Circle) {
|
||||
axbase = adapt.Circle().Location();
|
||||
axdir = adapt.Circle().Axis().Direction();
|
||||
} else {
|
||||
throw Base::TypeError("Rotation edge must be a straight line, circle or arc of circle");
|
||||
}
|
||||
} else {
|
||||
throw Base::TypeError("Axis reference must be an edge");
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -129,7 +129,7 @@ void TaskPolarPatternParameters::setupUI()
|
||||
updateViewTimer->setInterval(getUpdateViewTimeout());
|
||||
connect(updateViewTimer, SIGNAL(timeout()),
|
||||
this, SLOT(onUpdateViewTimer()));
|
||||
|
||||
|
||||
connect(ui->comboAxis, SIGNAL(activated(int)),
|
||||
this, SLOT(onAxisChanged(int)));
|
||||
connect(ui->checkReverse, SIGNAL(toggled(bool)),
|
||||
@@ -249,7 +249,7 @@ void TaskPolarPatternParameters::removeObject(App::DocumentObject* obj)
|
||||
void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (selectionMode!=none && msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
|
||||
|
||||
if (originalSelected(msg)) {
|
||||
exitSelectionMode();
|
||||
}
|
||||
@@ -260,7 +260,7 @@ void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges&
|
||||
getReferencedSelection(pcPolarPattern, msg, selObj, axes);
|
||||
if(!selObj)
|
||||
return;
|
||||
|
||||
|
||||
if (selectionMode == reference || selObj->isDerivedFrom ( App::Line::getClassTypeId () ) ) {
|
||||
setupTransaction();
|
||||
pcPolarPattern->Axis.setValue(selObj, axes);
|
||||
@@ -321,7 +321,7 @@ void TaskPolarPatternParameters::onAxisChanged(int /*num*/)
|
||||
showBase();
|
||||
selectionMode = reference;
|
||||
Gui::Selection().clearSelection();
|
||||
addReferenceSelectionGate(true, false);
|
||||
addReferenceSelectionGate(true, false, false, false, true);
|
||||
} else {
|
||||
exitSelectionMode();
|
||||
pcPolarPattern->Axis.Paste(axesLinks.getCurrentLink());
|
||||
|
||||
@@ -205,7 +205,7 @@ void TaskTransformedParameters::checkVisibility() {
|
||||
auto inset = feat->getInListEx(true);
|
||||
inset.emplace(feat);
|
||||
for(auto o : body->Group.getValues()) {
|
||||
if(!o->Visibility.getValue()
|
||||
if(!o->Visibility.getValue()
|
||||
|| !o->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
|
||||
continue;
|
||||
if(inset.count(o))
|
||||
@@ -410,10 +410,10 @@ void TaskTransformedParameters::exitSelectionMode()
|
||||
}
|
||||
}
|
||||
|
||||
void TaskTransformedParameters::addReferenceSelectionGate(bool edge, bool face, bool planar, bool whole)
|
||||
void TaskTransformedParameters::addReferenceSelectionGate(bool edge, bool face, bool planar, bool whole, bool circle)
|
||||
{
|
||||
std::unique_ptr<Gui::SelectionFilterGate> gateRefPtr(
|
||||
new ReferenceSelection(getBaseObject(), edge, face, planar,false,whole));
|
||||
new ReferenceSelection(getBaseObject(), edge, face, planar, false, whole, circle));
|
||||
std::unique_ptr<Gui::SelectionFilterGate> gateDepPtr(new NoDependentsSelection(getTopTransformedObject()));
|
||||
Gui::Selection().addSelectionGate(new CombineSelectionFilterGates(gateRefPtr, gateDepPtr));
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
App::DocumentObject *getBaseObject() const;
|
||||
|
||||
/// Get the sketch object of the first original either of the object associated with this feature or with the parent feature (MultiTransform mode)
|
||||
App::DocumentObject* getSketchObject() const;
|
||||
App::DocumentObject* getSketchObject() const;
|
||||
|
||||
void exitSelectionMode();
|
||||
|
||||
@@ -188,7 +188,7 @@ protected:
|
||||
void hideBase();
|
||||
void showBase();
|
||||
|
||||
void addReferenceSelectionGate(bool edge, bool face, bool planar=true, bool whole=false);
|
||||
void addReferenceSelectionGate(bool edge, bool face, bool planar=true, bool whole=false, bool circle=false);
|
||||
|
||||
bool isViewUpdated() const;
|
||||
int getUpdateViewTimeout() const;
|
||||
@@ -221,7 +221,7 @@ protected:
|
||||
/// Flag indicating whether this object is a container for MultiTransform
|
||||
bool insideMultiTransform;
|
||||
/// Lock updateUI(), applying changes to the underlying feature and calling recomputeFeature()
|
||||
bool blockUpdate;
|
||||
bool blockUpdate;
|
||||
};
|
||||
|
||||
/// simulation dialog for the TaskView
|
||||
|
||||
Reference in New Issue
Block a user