+ fixes #0001356: Error message displays value in Radians (adding reduntant/conflicting angle constraint)

This commit is contained in:
wmayer
2014-03-03 17:19:33 +01:00
parent 88c05dcbac
commit befb6ec6e8
3 changed files with 24 additions and 13 deletions

View File

@@ -12,6 +12,7 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}/..
${Boost_INCLUDE_DIRS}
${OCC_INCLUDE_DIR}
${QT_QTCORE_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${PYTHON_INCLUDE_PATH}
${XERCESC_INCLUDE_DIR}

View File

@@ -31,6 +31,8 @@
#include <Base/GeometryPyCXX.h>
#include <Base/VectorPy.h>
#include <Base/AxisPy.h>
#include <Base/Tools.h>
#include <Base/QuantityPy.h>
#include <App/Document.h>
// inclusion of the generated files (generated out of SketchObjectSFPy.xml)
@@ -239,8 +241,22 @@ PyObject* SketchObjectPy::setDatum(PyObject *args)
{
double Datum;
int Index;
if (!PyArg_ParseTuple(args, "id", &Index, &Datum))
return 0;
PyObject* object;
Base::Quantity Quantity;
if (PyArg_ParseTuple(args,"iO!", &Index, &(Base::QuantityPy::Type), &object)) {
Quantity = *(static_cast<Base::QuantityPy*>(object)->getQuantityPtr());
if (Quantity.getUnit() == Base::Unit::Angle)
//Datum = Quantity.getValueAs(Base::Quantity::Radian);
Datum = Base::toRadians<double>(Quantity.getValue());
else
Datum = Quantity.getValue();
}
else {
PyErr_Clear();
if (!PyArg_ParseTuple(args, "id", &Index, &Datum))
return 0;
Quantity.setValue(Datum);
}
int err=this->getSketchObjectPtr()->setDatum(Index, Datum);
if (err) {
@@ -250,13 +266,13 @@ PyObject* SketchObjectPy::setDatum(PyObject *args)
else if (err == -3)
str << "Cannot set the datum because the sketch contains conflicting constraints";
else if (err == -2)
str << "Datum " << Datum << " for the constraint with index " << Index << " is invalid";
str << "Datum " << (const char*)Quantity.getUserString().toUtf8() << " for the constraint with index " << Index << " is invalid";
else if (err == -4)
str << "Negative datum values are not valid for the constraint with index " << Index;
else if (err == -5)
str << "Zero is not a valid datum for the constraint with index " << Index;
else
str << "Unexpected problem at setting datum " << Datum << " for the constraint with index " << Index;
str << "Unexpected problem at setting datum " << (const char*)Quantity.getUserString().toUtf8() << " for the constraint with index " << Index;
PyErr_SetString(PyExc_ValueError, str.str().c_str());
return 0;
}

View File

@@ -124,13 +124,7 @@ void EditDatumDialog::exec(bool atCursor)
// save the value for the history
ui_ins_datum.labelEdit->pushToHistory();
double newDatum;
if (Constr->Type == Sketcher::Angle)
newDatum = Base::toRadians<double>(newQuant.getValue());
else
newDatum = newQuant.getValue();
double newDatum = newQuant.getValue();
if (Constr->Type == Sketcher::Angle ||
((Constr->Type == Sketcher::DistanceX || Constr->Type == Sketcher::DistanceY) &&
Constr->FirstPos == Sketcher::none || Constr->Second != Sketcher::Constraint::GeoUndef)) {
@@ -143,9 +137,9 @@ void EditDatumDialog::exec(bool atCursor)
try {
Gui::Command::openCommand("Modify sketch constraints");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setDatum(%i,%f)",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setDatum(%i,App.Units.Quantity('%f %s'))",
sketch->getNameInDocument(),
ConstrNbr, newDatum);
ConstrNbr, newDatum, (const char*)newQuant.getUnit().getString().toUtf8());
Gui::Command::commitCommand();
Gui::Command::updateActive();
}