Sketcher: Ellipse enhancement: All internal geometry is shown on creation
Elements that have internal geometry are created with the internal geometry on creation. It has been under discussion for a long time. Ulrich was in favour (asked for it several times). DeepSOIC implemented the focus because he hated the poor dragging of the ellipse when empty.
This commit is contained in:
@@ -441,7 +441,7 @@ int Sketch::addArcOfEllipse(const Part::GeomArcOfEllipse &ellipseSegment, bool f
|
||||
|
||||
// arcs require an ArcRules constraint for the end points
|
||||
if (!fixed)
|
||||
GCSsys.addConstraintArcOfEllipseRules(a); // TODO: ArcOfEllipse implementation.
|
||||
GCSsys.addConstraintArcOfEllipseRules(a);
|
||||
|
||||
// return the position of the newly added geometry
|
||||
return Geoms.size()-1;
|
||||
@@ -492,7 +492,7 @@ int Sketch::addCircle(const Part::GeomCircle &cir, bool fixed)
|
||||
|
||||
int Sketch::addEllipse(const Part::GeomEllipse &elip, bool fixed)
|
||||
{
|
||||
// TODO: Ellipse
|
||||
|
||||
std::vector<double *> ¶ms = fixed ? FixParameters : Parameters;
|
||||
|
||||
// create our own copy
|
||||
@@ -1040,7 +1040,7 @@ int Sketch::addPerpendicularConstraint(int geoId1, PointPos pos1, int geoId2)
|
||||
return ConstraintsCounter;
|
||||
}
|
||||
else if (Geoms[geoId2].type == Ellipse) {
|
||||
// TODO: Ellipse
|
||||
|
||||
GCS::Ellipse &c2 = Ellipses[Geoms[geoId2].index];
|
||||
GCS::Point &p2 = Points[Geoms[geoId2].midPointId];
|
||||
int tag = ++ConstraintsCounter;
|
||||
@@ -1059,7 +1059,6 @@ int Sketch::addPerpendicularConstraint(int geoId1, PointPos pos1, int geoId2)
|
||||
return ConstraintsCounter;
|
||||
}
|
||||
else if (Geoms[geoId2].type == Arc || Geoms[geoId2].type == Circle || Geoms[geoId2].type == Ellipse) {
|
||||
// TODO: ellipse real implementation
|
||||
int tag = ++ConstraintsCounter;
|
||||
GCS::Point ¢er = Points[Geoms[geoId2].midPointId];
|
||||
double *radius;
|
||||
@@ -1072,7 +1071,7 @@ int Sketch::addPerpendicularConstraint(int geoId1, PointPos pos1, int geoId2)
|
||||
radius = c2.rad;
|
||||
}
|
||||
else {
|
||||
// TODO: Ellipse
|
||||
|
||||
GCS::Ellipse &c2 = Ellipses[Geoms[geoId2].index];
|
||||
radius = c2.radmin;
|
||||
}
|
||||
@@ -1254,7 +1253,7 @@ int Sketch::addTangentConstraint(int geoId1, int geoId2)
|
||||
}
|
||||
} else if (Geoms[geoId1].type == Ellipse) {
|
||||
GCS::Ellipse &e = Ellipses[Geoms[geoId1].index];
|
||||
// TODO: Ellipse
|
||||
|
||||
if (Geoms[geoId2].type == Circle) {
|
||||
GCS::Circle &c = Circles[Geoms[geoId2].index];
|
||||
int tag = ++ConstraintsCounter;
|
||||
@@ -1274,7 +1273,7 @@ int Sketch::addTangentConstraint(int geoId1, int geoId2)
|
||||
GCSsys.addConstraintTangent(c, a, tag);
|
||||
return ConstraintsCounter;
|
||||
} else if (Geoms[geoId2].type == Ellipse) {
|
||||
// TODO: Ellipse
|
||||
|
||||
GCS::Ellipse &e = Ellipses[Geoms[geoId2].index];
|
||||
int tag = ++ConstraintsCounter;
|
||||
GCSsys.addConstraintTangent(e, a, tag);
|
||||
@@ -1329,7 +1328,7 @@ int Sketch::addTangentConstraint(int geoId1, PointPos pos1, int geoId2)
|
||||
return ConstraintsCounter;
|
||||
}
|
||||
else if (Geoms[geoId2].type == Ellipse) {
|
||||
// TODO: Ellipse
|
||||
|
||||
GCS::Ellipse &e = Ellipses[Geoms[geoId2].index];
|
||||
int tag = ++ConstraintsCounter;
|
||||
GCSsys.addConstraintPointOnEllipse(p1, e, tag);
|
||||
@@ -1366,7 +1365,7 @@ int Sketch::addTangentConstraint(int geoId1, PointPos pos1, int geoId2)
|
||||
return ConstraintsCounter;
|
||||
}
|
||||
} else if (Geoms[geoId2].type == Ellipse) {
|
||||
// TODO: Ellipse
|
||||
|
||||
GCS::Ellipse &e = Ellipses[Geoms[geoId2].index];
|
||||
if (pos1 == start) {
|
||||
int tag = ++ConstraintsCounter;
|
||||
@@ -1591,7 +1590,7 @@ int Sketch::addDistanceConstraint(int geoId1, PointPos pos1, int geoId2, PointPo
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Sketch::addRadiusConstraint(int geoId, double value, int radiusnumber)
|
||||
int Sketch::addRadiusConstraint(int geoId, double value)
|
||||
{
|
||||
geoId = checkGeoId(geoId);
|
||||
|
||||
@@ -1730,7 +1729,7 @@ int Sketch::addEqualConstraint(int geoId1, int geoId2)
|
||||
else
|
||||
std::swap(geoId1, geoId2);
|
||||
}
|
||||
// TODO: Ellipse
|
||||
|
||||
if (Geoms[geoId2].type == Ellipse) {
|
||||
if (Geoms[geoId1].type == Ellipse) {
|
||||
GCS::Ellipse &e1 = Ellipses[Geoms[geoId1].index];
|
||||
@@ -2108,7 +2107,7 @@ bool Sketch::updateGeometry()
|
||||
);
|
||||
circ->setRadius(*Circles[it->index].rad);
|
||||
} else if (it->type == Ellipse) {
|
||||
// TODO: Ellipse
|
||||
|
||||
GeomEllipse *ellipse = dynamic_cast<GeomEllipse*>(it->geo);
|
||||
|
||||
Base::Vector3d center = Vector3d(*Points[it->midPointId].x, *Points[it->midPointId].y, 0.0);
|
||||
@@ -2305,7 +2304,7 @@ int Sketch::initMove(int geoId, PointPos pos, bool fine)
|
||||
GCSsys.rescaleConstraint(i, 0.01);
|
||||
}
|
||||
} else if (Geoms[geoId].type == Ellipse) {
|
||||
// TODO: Ellipse
|
||||
|
||||
GCS::Point ¢er = Points[Geoms[geoId].midPointId];
|
||||
GCS::Point p0,p1;
|
||||
if (pos == mid | pos == none) {
|
||||
@@ -2317,7 +2316,7 @@ int Sketch::initMove(int geoId, PointPos pos, bool fine)
|
||||
GCSsys.addConstraintP2PCoincident(p0,center,-1);
|
||||
}
|
||||
} else if (Geoms[geoId].type == ArcOfEllipse) {
|
||||
// TODO: ArcOfEllipse
|
||||
|
||||
GCS::Point ¢er = Points[Geoms[geoId].midPointId];
|
||||
GCS::Point p0,p1;
|
||||
if (pos == mid || pos == none) {
|
||||
@@ -2328,7 +2327,7 @@ int Sketch::initMove(int geoId, PointPos pos, bool fine)
|
||||
*p0.y = *center.y;
|
||||
GCSsys.addConstraintP2PCoincident(p0,center,-1);
|
||||
} else if (pos == start || pos == end) {
|
||||
// TODO: Ellipse
|
||||
|
||||
MoveParameters.resize(4); // x,y,cx,cy
|
||||
if (pos == start || pos == end) {
|
||||
GCS::Point &p = (pos == start) ? Points[Geoms[geoId].startPointId]
|
||||
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
int addTangentConstraint(int geoId1, PointPos pos1, int geoId2);
|
||||
int addTangentConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2);
|
||||
/// add a radius constraint on a circle or an arc
|
||||
int addRadiusConstraint(int geoId, double value, int radiusnumber=0);
|
||||
int addRadiusConstraint(int geoId, double value);
|
||||
/// add an angle constraint on a line or between two lines
|
||||
int addAngleConstraint(int geoId, double value);
|
||||
int addAngleConstraint(int geoId1, int geoId2, double value);
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
Line = 2, // 2 Points(start,end), 4 Parameters(x1,y1,x2,y2)
|
||||
Arc = 3, // 3 Points(start,end,mid), (4)+5 Parameters((x1,y1,x2,y2),x,y,r,a1,a2)
|
||||
Circle = 4, // 1 Point(mid), 3 Parameters(x,y,r)
|
||||
Ellipse = 5, // 1 Point(mid), 5 Parameters(x,y,r1,r2,phi) phi=angle xaxis of elipse with respect of sketch xaxis// TODO: Ellipse
|
||||
Ellipse = 5, // 1 Point(mid), 5 Parameters(x,y,r1,r2,phi) phi=angle xaxis of elipse with respect of sketch xaxis
|
||||
ArcOfEllipse = 6
|
||||
};
|
||||
|
||||
|
||||
@@ -1311,8 +1311,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||
std::swap(GeoId1,GeoId2);
|
||||
std::swap(point1,point2);
|
||||
} else if (theta2 > 0.999*arcLength) {
|
||||
}
|
||||
else
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
#include "qp_eq.h"
|
||||
#include <Eigen/QR>
|
||||
|
||||
#define _GCS_DEBUG 1
|
||||
#undef _GCS_DEBUG
|
||||
#undef _GCS_DEBUG_SOLVER_JACOBIAN_QR_DECOMPOSITION_TRIANGULAR_MATRIX
|
||||
|
||||
#ifdef _GCS_DEBUG
|
||||
#if defined(_GCS_DEBUG) || defined(_GCS_DEBUG_SOLVER_JACOBIAN_QR_DECOMPOSITION_TRIANGULAR_MATRIX)
|
||||
#include <Base/Writer.h>
|
||||
#include <Base/Reader.h>
|
||||
#include <Base/Exception.h>
|
||||
@@ -716,7 +716,7 @@ int System::addConstraintTangentCircle2Arc(Circle &c, Arc &a, int tagId)
|
||||
|
||||
int System::addConstraintTangentEllipse2Arc(Ellipse &e, Arc &a, int tagId)
|
||||
{
|
||||
// TODO: Ellipse
|
||||
|
||||
/*addConstraintPointOnEllipse(a.start, e, tagId);
|
||||
double dx = *(a.start.x) - *(e.center.x);
|
||||
double dy = *(a.start.y) - *(e.center.y);
|
||||
@@ -740,7 +740,7 @@ int System::addConstraintTangentArc2Circle(Arc &a, Circle &c, int tagId)
|
||||
|
||||
int System::addConstraintTangentArc2Ellipse(Arc &a, Ellipse &e, int tagId)
|
||||
{
|
||||
// TODO: Ellipse
|
||||
|
||||
/*addConstraintPointOnEllipse(a.end, e, tagId);
|
||||
double dx = *(a.end.x) - *(e.center.x);
|
||||
double dy = *(a.end.y) - *(e.center.y);
|
||||
@@ -789,7 +789,7 @@ int System::addConstraintEqualRadius(Circle &c1, Circle &c2, int tagId)
|
||||
|
||||
int System::addConstraintEqualRadii(Ellipse &e1, Ellipse &e2, int tagId)
|
||||
{
|
||||
// TODO: Ellipse
|
||||
|
||||
//addConstraintEqual(e1.radmaj, e2.radmaj, tagId);
|
||||
addConstraintEqual(e1.radmin, e2.radmin, tagId);
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ bool isSimpleVertex(const Sketcher::SketchObject* Obj, int GeoId, PointPos PosId
|
||||
if (geo->getTypeId() == Part::GeomPoint::getClassTypeId())
|
||||
return true;
|
||||
else if (PosId == Sketcher::mid &&
|
||||
(geo->getTypeId() == Part::GeomCircle::getClassTypeId() || // TODO: ellipse
|
||||
(geo->getTypeId() == Part::GeomCircle::getClassTypeId() ||
|
||||
geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()))
|
||||
return true;
|
||||
else
|
||||
@@ -802,7 +802,7 @@ void CmdSketcherConstrainPointOnObject::activated(int iMsg)
|
||||
|
||||
// Currently only accepts line segments and circles
|
||||
if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() ||
|
||||
geom->getTypeId() == Part::GeomCircle::getClassTypeId() || // TODO: ellipse
|
||||
geom->getTypeId() == Part::GeomCircle::getClassTypeId() ||
|
||||
geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() ||
|
||||
geom->getTypeId() == Part::GeomEllipse::getClassTypeId() ||
|
||||
geom->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() ) {
|
||||
@@ -1289,7 +1289,7 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
|
||||
}
|
||||
else if (geo2->getTypeId() != Part::GeomLineSegment::getClassTypeId() &&
|
||||
geo2->getTypeId() != Part::GeomArcOfCircle::getClassTypeId() &&
|
||||
geo2->getTypeId() != Part::GeomCircle::getClassTypeId()) { // TODO: ellipse
|
||||
geo2->getTypeId() != Part::GeomCircle::getClassTypeId()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("The selected edge should be an arc, line or circle."));
|
||||
return;
|
||||
@@ -1765,7 +1765,7 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
|
||||
double radius = arc->getRadius();
|
||||
geoIdRadiusMap.push_back(std::make_pair(GeoId, radius));
|
||||
}
|
||||
else if (geom && geom->getTypeId() == Part::GeomCircle::getClassTypeId()) { // TODO: ellipse
|
||||
else if (geom && geom->getTypeId() == Part::GeomCircle::getClassTypeId()) {
|
||||
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle *>(geom);
|
||||
double radius = circle->getRadius();
|
||||
geoIdRadiusMap.push_back(std::make_pair(GeoId, radius));
|
||||
@@ -2113,9 +2113,9 @@ void CmdSketcherConstrainEqual::activated(int iMsg)
|
||||
arcSel = true;
|
||||
else if (geo->getTypeId() != Part::GeomCircle::getClassTypeId())
|
||||
circSel = true;
|
||||
else if (geo->getTypeId() != Part::GeomEllipse::getClassTypeId()) // TODO: ellipse
|
||||
else if (geo->getTypeId() != Part::GeomEllipse::getClassTypeId())
|
||||
ellipsSel = true;
|
||||
else if (geo->getTypeId() != Part::GeomArcOfEllipse::getClassTypeId()) // TODO: ellipse
|
||||
else if (geo->getTypeId() != Part::GeomArcOfEllipse::getClassTypeId())
|
||||
arcEllipsSel = true;
|
||||
else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
|
||||
@@ -1976,6 +1976,20 @@ public:
|
||||
minAxisPoint = EditCurve[0]+minAxisDir;
|
||||
}
|
||||
|
||||
Base::Vector3d center = Base::Vector3d(EditCurve[0].fX,EditCurve[0].fY,0);
|
||||
|
||||
Base::Vector3d majorpositiveend = center + a * Base::Vector3d(cos(phi),sin(phi),0);
|
||||
Base::Vector3d majornegativeend = center - a * Base::Vector3d(cos(phi),sin(phi),0);
|
||||
Base::Vector3d minorpositiveend = center + b * Base::Vector3d(-sin(phi),cos(phi),0);
|
||||
Base::Vector3d minornegativeend = center - b * Base::Vector3d(-sin(phi),cos(phi),0);
|
||||
|
||||
double cf = sqrt( abs(a*a - b*b) );//using abs, avoided using different formula for a>b/a<b cases
|
||||
|
||||
Base::Vector3d focus1P = center + cf * Base::Vector3d(cos(phi),sin(phi),0);
|
||||
Base::Vector3d focus2P = center - cf * Base::Vector3d(cos(phi),sin(phi),0);
|
||||
|
||||
int currentgeoid = getHighestCurveIndex();//index of the arc of ellipse we just created
|
||||
|
||||
Gui::Command::openCommand("Add sketch ellipse");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"App.ActiveDocument.%s.addGeometry(Part.Ellipse"
|
||||
@@ -1984,6 +1998,50 @@ public:
|
||||
majAxisPoint.fX, majAxisPoint.fY,
|
||||
minAxisPoint.fX, minAxisPoint.fY,
|
||||
EditCurve[0].fX, EditCurve[0].fY);
|
||||
|
||||
currentgeoid++;
|
||||
|
||||
try {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
|
||||
sketchgui->getObject()->getNameInDocument(),
|
||||
majorpositiveend.x,majorpositiveend.y,majornegativeend.x,majornegativeend.y); // create line for major axis
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+1);
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMajorDiameter',%d,%d)) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+1,currentgeoid); // constrain major axis
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
|
||||
sketchgui->getObject()->getNameInDocument(),
|
||||
minorpositiveend.x,minorpositiveend.y,minornegativeend.x,minornegativeend.y); // create line for minor axis
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+2);
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+2,currentgeoid); // constrain minor axis
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Point(App.Vector(%f,%f,0)))",
|
||||
sketchgui->getObject()->getNameInDocument(),
|
||||
focus1P.x,focus1P.y);
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus1',%d,%d,%d)) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+3,Sketcher::start,currentgeoid);
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Point(App.Vector(%f,%f,0)))",
|
||||
sketchgui->getObject()->getNameInDocument(),
|
||||
focus2P.x,focus2P.y);
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+4,Sketcher::start,currentgeoid);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::updateActive();
|
||||
return false;
|
||||
}
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
Gui::Command::updateActive();
|
||||
@@ -2290,14 +2348,19 @@ public:
|
||||
startAngle += M_PI/2;
|
||||
}
|
||||
|
||||
//calculate focus point vecF2
|
||||
double cf;//distance from center to focus
|
||||
cf = sqrt( abs(a*a - b*b) );//using abs, avoided using different formula for a>b/a<b cases
|
||||
Base::Vector2D vecCF;// a vector from center to focus2
|
||||
vecCF = majAxisDir;
|
||||
vecCF.Normalize();
|
||||
vecCF.Scale(-cf);//minus sign is because we want focus2 not focus1
|
||||
Base::Vector2D vecF2 = centerPoint + vecCF;
|
||||
Base::Vector3d center = Base::Vector3d(centerPoint.fX,centerPoint.fY,0);
|
||||
|
||||
Base::Vector3d majorpositiveend = center + a * Base::Vector3d(cos(phi),sin(phi),0);
|
||||
Base::Vector3d majornegativeend = center - a * Base::Vector3d(cos(phi),sin(phi),0);
|
||||
Base::Vector3d minorpositiveend = center + b * Base::Vector3d(-sin(phi),cos(phi),0);
|
||||
Base::Vector3d minornegativeend = center - b * Base::Vector3d(-sin(phi),cos(phi),0);
|
||||
|
||||
double cf = sqrt( abs(a*a - b*b) );//using abs, avoided using different formula for a>b/a<b cases
|
||||
|
||||
Base::Vector3d focus1P = center + cf * Base::Vector3d(cos(phi),sin(phi),0);
|
||||
Base::Vector3d focus2P = center - cf * Base::Vector3d(cos(phi),sin(phi),0);
|
||||
|
||||
int currentgeoid = getHighestCurveIndex();//index of the arc of ellipse we just created
|
||||
|
||||
Gui::Command::openCommand("Add sketch arc of ellipse");
|
||||
|
||||
@@ -2313,20 +2376,50 @@ public:
|
||||
minAxisPoint.fX, minAxisPoint.fY,
|
||||
centerPoint.fX, centerPoint.fY,
|
||||
startAngle, endAngle);
|
||||
int iAOE = getHighestCurveIndex();//index of the arc of ellipse we just created
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"App.ActiveDocument.%s.addGeometry(Part.Point(App.Vector(%f,%f,0)))",
|
||||
|
||||
currentgeoid++;
|
||||
|
||||
try {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
|
||||
sketchgui->getObject()->getNameInDocument(),
|
||||
vecF2.fX,vecF2.fY);
|
||||
int iPointF2 = getHighestCurveIndex();//index of the point we just created
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ",
|
||||
majorpositiveend.x,majorpositiveend.y,majornegativeend.x,majornegativeend.y); // create line for major axis
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+1);
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMajorDiameter',%d,%d)) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+1,currentgeoid); // constrain major axis
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))",
|
||||
sketchgui->getObject()->getNameInDocument(),
|
||||
iPointF2,Sketcher::start,iAOE);
|
||||
minorpositiveend.x,minorpositiveend.y,minornegativeend.x,minornegativeend.y); // create line for minor axis
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.toggleConstruction(%d) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+2);
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+2,currentgeoid); // constrain minor axis
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Point(App.Vector(%f,%f,0)))",
|
||||
sketchgui->getObject()->getNameInDocument(),
|
||||
focus1P.x,focus1P.y);
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus1',%d,%d,%d)) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+3,Sketcher::start,currentgeoid);
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Point(App.Vector(%f,%f,0)))",
|
||||
sketchgui->getObject()->getNameInDocument(),
|
||||
focus2P.x,focus2P.y);
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ",
|
||||
sketchgui->getObject()->getNameInDocument(),currentgeoid+4,Sketcher::start,currentgeoid);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::updateActive();
|
||||
return false;
|
||||
}
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
Gui::Command::updateActive();
|
||||
|
||||
@@ -242,7 +242,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
|
||||
}
|
||||
|
||||
} else if ((*it)->getTypeId() == Part::GeomEllipse::getClassTypeId()) {
|
||||
// TODO: Ellipse
|
||||
|
||||
const Part::GeomEllipse *ellipse = dynamic_cast<const Part::GeomEllipse *>((*it));
|
||||
|
||||
Base::Vector3d center = ellipse->getCenter();
|
||||
|
||||
@@ -718,7 +718,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
||||
geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() ||
|
||||
geo->getTypeId() == Part::GeomCircle::getClassTypeId() ||
|
||||
geo->getTypeId() == Part::GeomEllipse::getClassTypeId()||
|
||||
geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { // TODO: ellipse
|
||||
geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) {
|
||||
Gui::Command::openCommand("Drag Curve");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.movePoint(%i,%i,App.Vector(%f,%f,0),%i)"
|
||||
,getObject()->getNameInDocument()
|
||||
@@ -3133,7 +3133,7 @@ Restart:
|
||||
norm1 = Base::Vector3d(cos(midangle),sin(midangle),0);
|
||||
dir1 = Base::Vector3d(-norm1.y,norm1.x,0);
|
||||
midpos1 = arc->getCenter() + arc->getRadius() * norm1;
|
||||
} else if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId()) { // TODO: ellipse
|
||||
} else if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId()) {
|
||||
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle *>(geo1);
|
||||
norm1 = Base::Vector3d(cos(M_PI/4),sin(M_PI/4),0);
|
||||
dir1 = Base::Vector3d(-norm1.y,norm1.x,0);
|
||||
@@ -3154,7 +3154,7 @@ Restart:
|
||||
norm2 = Base::Vector3d(cos(midangle),sin(midangle),0);
|
||||
dir2 = Base::Vector3d(-norm2.y,norm2.x,0);
|
||||
midpos2 = arc->getCenter() + arc->getRadius() * norm2;
|
||||
} else if (geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) { // TODO: ellipse
|
||||
} else if (geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) {
|
||||
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle *>(geo2);
|
||||
norm2 = Base::Vector3d(cos(M_PI/4),sin(M_PI/4),0);
|
||||
dir2 = Base::Vector3d(-norm2.y,norm2.x,0);
|
||||
@@ -3201,7 +3201,7 @@ Restart:
|
||||
if (Constr->Type == Equal) {
|
||||
double r1a,r1b,r2a,r2b;
|
||||
double angle1,angle1plus=0., angle2, angle2plus=0.;//angle1 = rotation of object as a whole; angle1plus = arc angle (t parameter for ellipses).
|
||||
if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId()) { // TODO: ellipse
|
||||
if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId()) {
|
||||
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle *>(geo1);
|
||||
r1a = circle->getRadius();
|
||||
angle1 = M_PI/4;
|
||||
@@ -3463,7 +3463,7 @@ Restart:
|
||||
const Part::GeomLineSegment *lineSeg = dynamic_cast<const Part::GeomLineSegment *>(geo1);
|
||||
Base::Vector3d dir = (lineSeg->getEndPoint() - lineSeg->getStartPoint()).Normalize();
|
||||
Base::Vector3d norm(-dir.y, dir.x, 0);
|
||||
if (geo2->getTypeId()== Part::GeomCircle::getClassTypeId()) { // TODO: ellipse
|
||||
if (geo2->getTypeId()== Part::GeomCircle::getClassTypeId()) {
|
||||
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle *>(geo2);
|
||||
// tangency between a line and a circle
|
||||
float length = (circle->getCenter() - lineSeg->getStartPoint())*dir;
|
||||
@@ -3472,7 +3472,7 @@ Restart:
|
||||
relPos = norm * 1; //TODO Huh?
|
||||
}
|
||||
else if (geo2->getTypeId()== Part::GeomEllipse::getClassTypeId() ||
|
||||
geo2->getTypeId()== Part::GeomArcOfEllipse::getClassTypeId()) { // TODO: ellipse
|
||||
geo2->getTypeId()== Part::GeomArcOfEllipse::getClassTypeId()) {
|
||||
|
||||
Base::Vector3d center;
|
||||
if(geo2->getTypeId()== Part::GeomEllipse::getClassTypeId()){
|
||||
@@ -3499,7 +3499,7 @@ Restart:
|
||||
}
|
||||
}
|
||||
|
||||
if (geo1->getTypeId()== Part::GeomCircle::getClassTypeId() && // TODO: ellipse
|
||||
if (geo1->getTypeId()== Part::GeomCircle::getClassTypeId() &&
|
||||
geo2->getTypeId()== Part::GeomCircle::getClassTypeId()) {
|
||||
const Part::GeomCircle *circle1 = dynamic_cast<const Part::GeomCircle *>(geo1);
|
||||
const Part::GeomCircle *circle2 = dynamic_cast<const Part::GeomCircle *>(geo2);
|
||||
@@ -3508,12 +3508,12 @@ Restart:
|
||||
pos = circle1->getCenter() + dir * circle1->getRadius();
|
||||
relPos = dir * 1;
|
||||
}
|
||||
else if (geo2->getTypeId()== Part::GeomCircle::getClassTypeId()) { // TODO: ellipse
|
||||
else if (geo2->getTypeId()== Part::GeomCircle::getClassTypeId()) {
|
||||
std::swap(geo1,geo2);
|
||||
}
|
||||
|
||||
if (geo1->getTypeId()== Part::GeomCircle::getClassTypeId() &&
|
||||
geo2->getTypeId()== Part::GeomArcOfCircle::getClassTypeId()) { // TODO: ellipse
|
||||
geo2->getTypeId()== Part::GeomArcOfCircle::getClassTypeId()) {
|
||||
const Part::GeomCircle *circle = dynamic_cast<const Part::GeomCircle *>(geo1);
|
||||
const Part::GeomArcOfCircle *arc = dynamic_cast<const Part::GeomArcOfCircle *>(geo2);
|
||||
// tangency between a circle and an arc
|
||||
|
||||
Reference in New Issue
Block a user