+ 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,6 +240,7 @@ public:
unsetCursor();
resetPositionText();
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(),
@ -247,6 +248,11 @@ public:
geometryCreationMode==Construction?"True":"False");
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,8 +450,10 @@ public:
if (Mode==STATUS_End){
unsetCursor();
resetPositionText();
Gui::Command::openCommand("Add sketch box");
int firstCurve = getHighestCurveIndex() + 1;
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"
@ -480,6 +488,11 @@ public:
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,6 +1366,7 @@ public:
unsetCursor();
resetPositionText();
try {
Gui::Command::openCommand("Add sketch arc");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
@ -1362,6 +1378,11 @@ public:
geometryCreationMode==Construction?"True":"False"); //arcAngle > 0 ? 0 : 1);
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,6 +1669,7 @@ public:
unsetCursor();
resetPositionText();
try {
Gui::Command::openCommand("Add sketch arc");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.ArcOfCircle"
@ -1659,6 +1681,11 @@ public:
geometryCreationMode==Construction?"True":"False");
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,6 +1982,7 @@ public:
unsetCursor();
resetPositionText();
try {
Gui::Command::openCommand("Add sketch circle");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Circle"
@ -1965,6 +1993,11 @@ public:
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();
}
// add auto constraints for the center point
if (sugConstr1.size() > 0) {
@ -2751,6 +2784,7 @@ private:
int currentgeoid = getHighestCurveIndex(); // index of the ellipse we just created
try {
Gui::Command::openCommand("Add sketch ellipse");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Ellipse"
@ -2763,7 +2797,6 @@ private:
currentgeoid++;
try {
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.ExposeInternalGeometry(%d)",
sketchgui->getObject()->getNameInDocument(),
@ -3168,6 +3201,7 @@ public:
int currentgeoid = getHighestCurveIndex();
try {
Gui::Command::openCommand("Add sketch arc of ellipse");
Gui::Command::doCommand(Gui::Command::Doc,
@ -3183,7 +3217,6 @@ public:
currentgeoid++;
try {
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.ExposeInternalGeometry(%d)",
sketchgui->getObject()->getNameInDocument(),
@ -3563,6 +3596,8 @@ public:
if (Mode==STATUS_End) {
unsetCursor();
resetPositionText();
try {
Gui::Command::openCommand("Add sketch circle");
Gui::Command::doCommand(Gui::Command::Doc,
"App.ActiveDocument.%s.addGeometry(Part.Circle"
@ -3573,6 +3608,11 @@ public:
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();
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();
}
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,6 +4152,7 @@ public:
int currentgeoid= getHighestCurveIndex();
// create fillet at point
try {
Gui::Command::openCommand("Create fillet");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.fillet(%d,%d,%f)",
sketchgui->getObject()->getNameInDocument(),
@ -4119,6 +4166,11 @@ public:
}
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);
@ -4165,16 +4217,22 @@ public:
return false;
construction=lineSeg1->Construction && lineSeg2->Construction;
int currentgeoid= getHighestCurveIndex();
// create fillet between lines
try {
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();
}
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");