Allow datum point and line from circular reference
This commit is contained in:
parent
b6932b0bdb
commit
cdb49c28e5
|
@ -79,6 +79,7 @@ using namespace PartDesign;
|
||||||
// Note: We don't distinguish between e.g. datum lines and edges here
|
// Note: We don't distinguish between e.g. datum lines and edges here
|
||||||
#define PLANE QObject::tr("DPLANE")
|
#define PLANE QObject::tr("DPLANE")
|
||||||
#define LINE QObject::tr("DLINE")
|
#define LINE QObject::tr("DLINE")
|
||||||
|
#define CIRCLE QObject::tr("DCIRCLE")
|
||||||
#define POINT QObject::tr("DPOINT")
|
#define POINT QObject::tr("DPOINT")
|
||||||
#define ANGLE QObject::tr("Angle")
|
#define ANGLE QObject::tr("Angle")
|
||||||
|
|
||||||
|
@ -94,6 +95,10 @@ void Line::initHints()
|
||||||
key.insert(LINE);
|
key.insert(LINE);
|
||||||
hints[key] = DONE; // LINE -> DONE. Line from another line or edge
|
hints[key] = DONE; // LINE -> DONE. Line from another line or edge
|
||||||
|
|
||||||
|
key.clear(); value.clear();
|
||||||
|
key.insert(CIRCLE);
|
||||||
|
hints[key] = DONE; // CIRCLE -> DONE. Line from center of circle or arc or axis of cylinder or cylinder segment
|
||||||
|
|
||||||
key.clear(); value.clear();
|
key.clear(); value.clear();
|
||||||
key.insert(POINT);
|
key.insert(POINT);
|
||||||
value.insert(POINT);
|
value.insert(POINT);
|
||||||
|
@ -167,6 +172,7 @@ void Line::onChanged(const App::Property *prop)
|
||||||
Base::Vector3d* p1 = NULL;
|
Base::Vector3d* p1 = NULL;
|
||||||
Base::Vector3d* p2 = NULL;
|
Base::Vector3d* p2 = NULL;
|
||||||
gp_Lin* line = NULL;
|
gp_Lin* line = NULL;
|
||||||
|
gp_Circ* circle = NULL;
|
||||||
Handle_Geom_Surface s1 = NULL;
|
Handle_Geom_Surface s1 = NULL;
|
||||||
Handle_Geom_Surface s2 = NULL;
|
Handle_Geom_Surface s2 = NULL;
|
||||||
Handle_Geom_Surface s3 = NULL;
|
Handle_Geom_Surface s3 = NULL;
|
||||||
|
|
|
@ -34,9 +34,11 @@
|
||||||
# include <gp_GTrsf.hxx>
|
# include <gp_GTrsf.hxx>
|
||||||
# include <gp_Lin.hxx>
|
# include <gp_Lin.hxx>
|
||||||
# include <gp_Pln.hxx>
|
# include <gp_Pln.hxx>
|
||||||
|
# include <gp_Circ.hxx>
|
||||||
# include <Geom_Line.hxx>
|
# include <Geom_Line.hxx>
|
||||||
# include <Geom_Plane.hxx>
|
# include <Geom_Plane.hxx>
|
||||||
# include <Geom_CylindricalSurface.hxx>
|
# include <Geom_CylindricalSurface.hxx>
|
||||||
|
# include <Geom_Circle.hxx>
|
||||||
# include <Geom2d_Line.hxx>
|
# include <Geom2d_Line.hxx>
|
||||||
# include <Handle_Geom_Curve.hxx>
|
# include <Handle_Geom_Curve.hxx>
|
||||||
# include <Handle_Geom_Surface.hxx>
|
# include <Handle_Geom_Surface.hxx>
|
||||||
|
@ -77,6 +79,7 @@ using namespace PartDesign;
|
||||||
#define CYLINDER QObject::tr("DCYLINDER")
|
#define CYLINDER QObject::tr("DCYLINDER")
|
||||||
#define LINE QObject::tr("DLINE")
|
#define LINE QObject::tr("DLINE")
|
||||||
#define POINT QObject::tr("DPOINT")
|
#define POINT QObject::tr("DPOINT")
|
||||||
|
#define CIRCLE QObject::tr("DCIRCLE")
|
||||||
#define ANGLE QObject::tr("Angle")
|
#define ANGLE QObject::tr("Angle")
|
||||||
|
|
||||||
// ================================ Initialize the hints =====================
|
// ================================ Initialize the hints =====================
|
||||||
|
@ -93,6 +96,10 @@ void Point::initHints()
|
||||||
key.insert(POINT);
|
key.insert(POINT);
|
||||||
hints[key] = DONE; // POINT -> DONE. Point from another point or vertex
|
hints[key] = DONE; // POINT -> DONE. Point from another point or vertex
|
||||||
|
|
||||||
|
key.clear(); value.clear();
|
||||||
|
key.insert(CIRCLE);
|
||||||
|
hints[key] = DONE; // CIRCLE -> DONE. Point from center of circle or arc
|
||||||
|
|
||||||
key.clear(); value.clear();
|
key.clear(); value.clear();
|
||||||
key.insert(LINE);
|
key.insert(LINE);
|
||||||
value.insert(LINE); value.insert(PLANE);
|
value.insert(LINE); value.insert(PLANE);
|
||||||
|
@ -166,6 +173,7 @@ void Point::onChanged(const App::Property* prop)
|
||||||
Handle_Geom_Surface s1 = NULL;
|
Handle_Geom_Surface s1 = NULL;
|
||||||
Handle_Geom_Surface s2 = NULL;
|
Handle_Geom_Surface s2 = NULL;
|
||||||
Handle_Geom_Surface s3 = NULL;
|
Handle_Geom_Surface s3 = NULL;
|
||||||
|
gp_Circ* circle = NULL;
|
||||||
|
|
||||||
for (int i = 0; i < refs.size(); i++) {
|
for (int i = 0; i < refs.size(); i++) {
|
||||||
if (refs[i]->getTypeId().isDerivedFrom(PartDesign::Point::getClassTypeId())) {
|
if (refs[i]->getTypeId().isDerivedFrom(PartDesign::Point::getClassTypeId())) {
|
||||||
|
@ -223,11 +231,16 @@ void Point::onChanged(const App::Property* prop)
|
||||||
point = new Base::Vector3d(p.X(), p.Y(), p.Z());
|
point = new Base::Vector3d(p.X(), p.Y(), p.Z());
|
||||||
} else if (subshape.ShapeType() == TopAbs_EDGE) {
|
} else if (subshape.ShapeType() == TopAbs_EDGE) {
|
||||||
TopoDS_Edge e = TopoDS::Edge(subshape);
|
TopoDS_Edge e = TopoDS::Edge(subshape);
|
||||||
Standard_Real first, last;
|
BRepAdaptor_Curve adapt(e);
|
||||||
if (c1.IsNull())
|
if (adapt.GetType() == GeomAbs_Circle) {
|
||||||
c1 = BRep_Tool::Curve(e, first, last);
|
circle = new gp_Circ(adapt.Circle());
|
||||||
else
|
} else {
|
||||||
c2 = BRep_Tool::Curve(e, first, last);
|
Standard_Real first, last;
|
||||||
|
if (c1.IsNull())
|
||||||
|
c1 = BRep_Tool::Curve(e, first, last);
|
||||||
|
else
|
||||||
|
c2 = BRep_Tool::Curve(e, first, last);
|
||||||
|
}
|
||||||
} else if (subshape.ShapeType() == TopAbs_FACE) {
|
} else if (subshape.ShapeType() == TopAbs_FACE) {
|
||||||
TopoDS_Face f = TopoDS::Face(subshape);
|
TopoDS_Face f = TopoDS::Face(subshape);
|
||||||
double offset1 = Offset.getValue();
|
double offset1 = Offset.getValue();
|
||||||
|
@ -337,6 +350,7 @@ void Point::onChanged(const App::Property* prop)
|
||||||
Placement.setValue(Base::Placement(*point, Base::Rotation()));
|
Placement.setValue(Base::Placement(*point, Base::Rotation()));
|
||||||
|
|
||||||
delete point;
|
delete point;
|
||||||
|
if (circle != NULL) delete circle;
|
||||||
}
|
}
|
||||||
|
|
||||||
Part::Datum::onChanged(prop);
|
Part::Datum::onChanged(prop);
|
||||||
|
@ -399,8 +413,14 @@ const QString getRefType(const App::DocumentObject* obj, const std::string& subn
|
||||||
else
|
else
|
||||||
throw Base::Exception("Part::Datum::getRefType(): Only planar and cylindrical faces are allowed");
|
throw Base::Exception("Part::Datum::getRefType(): Only planar and cylindrical faces are allowed");
|
||||||
} else if (subname.size() > 4 && subname.substr(0,4) == "Edge") {
|
} else if (subname.size() > 4 && subname.substr(0,4) == "Edge") {
|
||||||
// Note: For now, only linear references are possible
|
TopoDS_Shape edge = topShape.getSubShape(subname.c_str());
|
||||||
return LINE;
|
if (edge.IsNull() || (edge.ShapeType() != TopAbs_EDGE))
|
||||||
|
throw Base::Exception("Part::Datum::getRefType(): No valid subshape could be extracted");
|
||||||
|
BRepAdaptor_Curve adapt(TopoDS::Edge(edge));
|
||||||
|
if (adapt.GetType() == GeomAbs_Circle)
|
||||||
|
return CIRCLE;
|
||||||
|
else // We don't check for other types yet
|
||||||
|
return LINE;
|
||||||
} else if (subname.size() > 6 && subname.substr(0,6) == "Vertex") {
|
} else if (subname.size() > 6 && subname.substr(0,6) == "Vertex") {
|
||||||
return POINT;
|
return POINT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,6 +194,8 @@ const QString makeRefText(std::set<QString> hint)
|
||||||
tText = QObject::tr("Plane");
|
tText = QObject::tr("Plane");
|
||||||
else if (((*t) == QObject::tr("DLINE")) || ((*t) == QObject::tr("Line")))
|
else if (((*t) == QObject::tr("DLINE")) || ((*t) == QObject::tr("Line")))
|
||||||
tText = QObject::tr("Line");
|
tText = QObject::tr("Line");
|
||||||
|
else if (((*t) == QObject::tr("DCIRCLE")) || ((*t) == QObject::tr("Circle")))
|
||||||
|
tText = QObject::tr("Circle");
|
||||||
else if (((*t) == QObject::tr("DPOINT")) || ((*t) == QObject::tr("Point")))
|
else if (((*t) == QObject::tr("DPOINT")) || ((*t) == QObject::tr("Point")))
|
||||||
tText = QObject::tr("Point");
|
tText = QObject::tr("Point");
|
||||||
else if (((*t) == QObject::tr("DCYLINDER")) || ((*t) == QObject::tr("Cylinder")))
|
else if (((*t) == QObject::tr("DCYLINDER")) || ((*t) == QObject::tr("Cylinder")))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user