+ fixes #0002117: problems with rendering an arc - NAN

This commit is contained in:
wmayer 2015-09-15 12:53:22 +02:00
parent 2a569497b9
commit 7dc59751cc

View File

@ -240,13 +240,19 @@ public:
unsetCursor();
resetPositionText();
Gui::Command::openCommand("Add sketch line");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)",
sketchgui->getObject()->getNameInDocument(),
EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY,
geometryCreationMode==Construction?"True":"False");
try {
Gui::Command::openCommand("Add sketch line");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)",
sketchgui->getObject()->getNameInDocument(),
EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY,
geometryCreationMode==Construction?"True":"False");
Gui::Command::commitCommand();
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to add line: %s\n", e.what());
Gui::Command::abortCommand();
}
// add auto constraints for the line segment start
if (sugConstr1.size() > 0) {
@ -444,42 +450,49 @@ public:
if (Mode==STATUS_End){
unsetCursor();
resetPositionText();
Gui::Command::openCommand("Add sketch box");
int firstCurve = getHighestCurveIndex() + 1;
Gui::Command::doCommand(Gui::Command::Doc,
"geoList = []\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"App.ActiveDocument.%s.addGeometry(geoList,%s)\n"
"conList = []\n"
"conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
"conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
"conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
"conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
"conList.append(Sketcher.Constraint('Horizontal',%i))\n"
"conList.append(Sketcher.Constraint('Horizontal',%i))\n"
"conList.append(Sketcher.Constraint('Vertical',%i))\n"
"conList.append(Sketcher.Constraint('Vertical',%i))\n"
"App.ActiveDocument.%s.addConstraint(conList)\n",
EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY, // line 1
EditCurve[1].fX,EditCurve[1].fY,EditCurve[2].fX,EditCurve[2].fY, // line 2
EditCurve[2].fX,EditCurve[2].fY,EditCurve[3].fX,EditCurve[3].fY, // line 3
EditCurve[3].fX,EditCurve[3].fY,EditCurve[0].fX,EditCurve[0].fY, // line 4
sketchgui->getObject()->getNameInDocument(), // the sketch
geometryCreationMode==Construction?"True":"False", // geometry as construction or not
firstCurve,firstCurve+1, // coincident1
firstCurve+1,firstCurve+2, // coincident2
firstCurve+2,firstCurve+3, // coincident3
firstCurve+3,firstCurve, // coincident4
firstCurve, // horizontal1
firstCurve+2, // horizontal2
firstCurve+1, // vertical1
firstCurve+3, // vertical2
sketchgui->getObject()->getNameInDocument()); // the sketch
Gui::Command::commitCommand();
try {
Gui::Command::openCommand("Add sketch box");
Gui::Command::doCommand(Gui::Command::Doc,
"geoList = []\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"geoList.append(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)))\n"
"App.ActiveDocument.%s.addGeometry(geoList,%s)\n"
"conList = []\n"
"conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
"conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
"conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
"conList.append(Sketcher.Constraint('Coincident',%i,2,%i,1))\n"
"conList.append(Sketcher.Constraint('Horizontal',%i))\n"
"conList.append(Sketcher.Constraint('Horizontal',%i))\n"
"conList.append(Sketcher.Constraint('Vertical',%i))\n"
"conList.append(Sketcher.Constraint('Vertical',%i))\n"
"App.ActiveDocument.%s.addConstraint(conList)\n",
EditCurve[0].fX,EditCurve[0].fY,EditCurve[1].fX,EditCurve[1].fY, // line 1
EditCurve[1].fX,EditCurve[1].fY,EditCurve[2].fX,EditCurve[2].fY, // line 2
EditCurve[2].fX,EditCurve[2].fY,EditCurve[3].fX,EditCurve[3].fY, // line 3
EditCurve[3].fX,EditCurve[3].fY,EditCurve[0].fX,EditCurve[0].fY, // line 4
sketchgui->getObject()->getNameInDocument(), // the sketch
geometryCreationMode==Construction?"True":"False", // geometry as construction or not
firstCurve,firstCurve+1, // coincident1
firstCurve+1,firstCurve+2, // coincident2
firstCurve+2,firstCurve+3, // coincident3
firstCurve+3,firstCurve, // coincident4
firstCurve, // horizontal1
firstCurve+2, // horizontal2
firstCurve+1, // vertical1
firstCurve+3, // vertical2
sketchgui->getObject()->getNameInDocument()); // the sketch
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to add box: %s\n", e.what());
Gui::Command::abortCommand();
}
// add auto constraints at the start of the first side
if (sugConstr1.size() > 0) {
@ -930,10 +943,10 @@ public:
if (Mode == STATUS_Do || Mode == STATUS_Close) {
bool addedGeometry = true;
if (SegmentMode == SEGMENT_MODE_Line) {
// open the transaction
Gui::Command::openCommand("Add line to sketch wire");
// issue the geometry
try {
// open the transaction
Gui::Command::openCommand("Add line to sketch wire");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Line(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)",
sketchgui->getObject()->getNameInDocument(),
@ -951,8 +964,9 @@ public:
Mode = STATUS_SEEK_Second;
return true;
}
Gui::Command::openCommand("Add arc to sketch wire");
try {
Gui::Command::openCommand("Add arc to sketch wire");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
"(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f),%s)",
@ -967,6 +981,7 @@ public:
Gui::Command::abortCommand();
}
}
int lastCurve = getHighestCurveIndex();
// issue the constraint
if (addedGeometry && (previousPosId != Sketcher::none)) {
@ -1351,17 +1366,23 @@ public:
unsetCursor();
resetPositionText();
Gui::Command::openCommand("Add sketch arc");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
"(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),"
"%f,%f),%s)",
sketchgui->getObject()->getNameInDocument(),
CenterPoint.fX, CenterPoint.fY, sqrt(rx*rx + ry*ry),
startAngle, endAngle,
geometryCreationMode==Construction?"True":"False"); //arcAngle > 0 ? 0 : 1);
try {
Gui::Command::openCommand("Add sketch arc");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
"(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),"
"%f,%f),%s)",
sketchgui->getObject()->getNameInDocument(),
CenterPoint.fX, CenterPoint.fY, sqrt(rx*rx + ry*ry),
startAngle, endAngle,
geometryCreationMode==Construction?"True":"False"); //arcAngle > 0 ? 0 : 1);
Gui::Command::commitCommand();
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to add arc: %s\n", e.what());
Gui::Command::abortCommand();
}
// Auto Constraint center point
if (sugConstr1.size() > 0) {
@ -1648,17 +1669,23 @@ public:
unsetCursor();
resetPositionText();
Gui::Command::openCommand("Add sketch arc");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
"(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),"
"%f,%f),%s)",
sketchgui->getObject()->getNameInDocument(),
CenterPoint.fX, CenterPoint.fY, radius,
startAngle, endAngle,
geometryCreationMode==Construction?"True":"False");
try {
Gui::Command::openCommand("Add sketch arc");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
"(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),"
"%f,%f),%s)",
sketchgui->getObject()->getNameInDocument(),
CenterPoint.fX, CenterPoint.fY, radius,
startAngle, endAngle,
geometryCreationMode==Construction?"True":"False");
Gui::Command::commitCommand();
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to add arc: %s\n", e.what());
Gui::Command::abortCommand();
}
// Auto Constraint first picked point
if (sugConstr1.size() > 0) {
@ -1955,16 +1982,22 @@ public:
unsetCursor();
resetPositionText();
Gui::Command::openCommand("Add sketch circle");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Circle"
"(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%s)",
sketchgui->getObject()->getNameInDocument(),
EditCurve[0].fX, EditCurve[0].fY,
sqrt(rx*rx + ry*ry),
geometryCreationMode==Construction?"True":"False");
try {
Gui::Command::openCommand("Add sketch circle");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Circle"
"(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%s)",
sketchgui->getObject()->getNameInDocument(),
EditCurve[0].fX, EditCurve[0].fY,
sqrt(rx*rx + ry*ry),
geometryCreationMode==Construction?"True":"False");
Gui::Command::commitCommand();
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to add circle: %s\n", e.what());
Gui::Command::abortCommand();
}
// add auto constraints for the center point
if (sugConstr1.size() > 0) {
@ -2751,19 +2784,19 @@ private:
int currentgeoid = getHighestCurveIndex(); // index of the ellipse we just created
Gui::Command::openCommand("Add sketch ellipse");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Ellipse"
"(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)",
sketchgui->getObject()->getNameInDocument(),
periapsis.fX, periapsis.fY,
positiveB.fX, positiveB.fY,
centroid.fX, centroid.fY,
geometryCreationMode==Construction?"True":"False");
currentgeoid++;
try {
Gui::Command::openCommand("Add sketch ellipse");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Ellipse"
"(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)",
sketchgui->getObject()->getNameInDocument(),
periapsis.fX, periapsis.fY,
positiveB.fX, positiveB.fY,
centroid.fX, centroid.fY,
geometryCreationMode==Construction?"True":"False");
currentgeoid++;
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.ExposeInternalGeometry(%d)",
sketchgui->getObject()->getNameInDocument(),
@ -3168,22 +3201,22 @@ public:
int currentgeoid = getHighestCurveIndex();
Gui::Command::openCommand("Add sketch arc of ellipse");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfEllipse"
"(Part.Ellipse(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0)),"
"%f,%f),%s)",
sketchgui->getObject()->getNameInDocument(),
majAxisPoint.fX, majAxisPoint.fY,
minAxisPoint.fX, minAxisPoint.fY,
centerPoint.fX, centerPoint.fY,
startAngle, endAngle,
geometryCreationMode==Construction?"True":"False");
currentgeoid++;
try {
Gui::Command::openCommand("Add sketch arc of ellipse");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfEllipse"
"(Part.Ellipse(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0)),"
"%f,%f),%s)",
sketchgui->getObject()->getNameInDocument(),
majAxisPoint.fX, majAxisPoint.fY,
minAxisPoint.fX, minAxisPoint.fY,
centerPoint.fX, centerPoint.fY,
startAngle, endAngle,
geometryCreationMode==Construction?"True":"False");
currentgeoid++;
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.ExposeInternalGeometry(%d)",
sketchgui->getObject()->getNameInDocument(),
@ -3563,16 +3596,23 @@ public:
if (Mode==STATUS_End) {
unsetCursor();
resetPositionText();
Gui::Command::openCommand("Add sketch circle");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Circle"
"(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%s)",
sketchgui->getObject()->getNameInDocument(),
CenterPoint.fX, CenterPoint.fY,
radius,
geometryCreationMode==Construction?"True":"False");
Gui::Command::commitCommand();
try {
Gui::Command::openCommand("Add sketch circle");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Circle"
"(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%s)",
sketchgui->getObject()->getNameInDocument(),
CenterPoint.fX, CenterPoint.fY,
radius,
geometryCreationMode==Construction?"True":"False");
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to add circle: %s\n", e.what());
Gui::Command::abortCommand();
}
// Auto Constraint first picked point
if (sugConstr1.size() > 0) {
@ -3827,12 +3867,18 @@ public:
unsetCursor();
resetPositionText();
Gui::Command::openCommand("Add sketch point");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Point(App.Vector(%f,%f,0)))",
sketchgui->getObject()->getNameInDocument(),
EditPoint.fX,EditPoint.fY);
try {
Gui::Command::openCommand("Add sketch point");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Point(App.Vector(%f,%f,0)))",
sketchgui->getObject()->getNameInDocument(),
EditPoint.fX,EditPoint.fY);
Gui::Command::commitCommand();
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to add point: %s\n", e.what());
Gui::Command::abortCommand();
}
// add auto constraints for the line segment start
if (sugConstr.size() > 0) {
@ -4106,19 +4152,25 @@ public:
int currentgeoid= getHighestCurveIndex();
// create fillet at point
Gui::Command::openCommand("Create fillet");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.fillet(%d,%d,%f)",
sketchgui->getObject()->getNameInDocument(),
GeoId, PosId, radius);
try {
Gui::Command::openCommand("Create fillet");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.fillet(%d,%d,%f)",
sketchgui->getObject()->getNameInDocument(),
GeoId, PosId, radius);
if(construction) {
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.toggleConstruction(%d) ",
sketchgui->getObject()->getNameInDocument(),
currentgeoid+1);
if(construction) {
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.toggleConstruction(%d) ",
sketchgui->getObject()->getNameInDocument(),
currentgeoid+1);
}
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to create fillet: %s\n", e.what());
Gui::Command::abortCommand();
}
Gui::Command::commitCommand();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
@ -4165,16 +4217,22 @@ public:
return false;
construction=lineSeg1->Construction && lineSeg2->Construction;
int currentgeoid= getHighestCurveIndex();
// create fillet between lines
Gui::Command::openCommand("Create fillet");
int currentgeoid= getHighestCurveIndex();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.fillet(%d,%d,App.Vector(%f,%f,0),App.Vector(%f,%f,0),%f)",
sketchgui->getObject()->getNameInDocument(),
firstCurve, secondCurve,
firstPos.fX, firstPos.fY,
secondPos.fX, secondPos.fY, radius);
Gui::Command::commitCommand();
try {
Gui::Command::openCommand("Create fillet");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.fillet(%d,%d,App.Vector(%f,%f,0),App.Vector(%f,%f,0),%f)",
sketchgui->getObject()->getNameInDocument(),
firstCurve, secondCurve,
firstPos.fX, firstPos.fY,
secondPos.fX, secondPos.fY, radius);
Gui::Command::commitCommand();
}
catch (const Base::Exception& e) {
Base::Console().Error("Failed to create fillet: %s\n", e.what());
Gui::Command::abortCommand();
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
@ -4360,7 +4418,8 @@ public:
Gui::Command::updateActive();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Base::Console().Error("Failed to trim edge: %s\n", e.what());
Gui::Command::abortCommand();
}
}
}
@ -4553,7 +4612,8 @@ public:
* right button of the mouse */
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Base::Console().Error("Failed to add external geometry: %s\n", e.what());
Gui::Command::abortCommand();
}
return true;
}
@ -4714,7 +4774,7 @@ public:
if (Mode==STATUS_End){
unsetCursor();
resetPositionText();
Gui::Command::openCommand("Add slot");
int firstCurve = getHighestCurveIndex() + 1;
// add the geometry to the sketch
double start, end;
@ -4732,6 +4792,7 @@ public:
}
try {
Gui::Command::openCommand("Add slot");
Gui::Command::doCommand(Gui::Command::Doc,
"geoList = []\n"
"geoList.append(Part.ArcOfCircle(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f))\n"
@ -4788,7 +4849,7 @@ public:
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Base::Console().Error("Failed to add slot: %s\n", e.what());
Gui::Command::abortCommand();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
@ -5022,7 +5083,7 @@ public:
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
}
catch (const Base::Exception& e) {
Base::Console().Error("%s\n", e.what());
Base::Console().Error("Failed to add hexagon: %s\n", e.what());
Gui::Command::abortCommand();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");