PropertyPlacement: Convert x, y, z values to Quantities when using them in expressions.

This commit is contained in:
Eivind Kvedalen 2016-03-20 00:03:43 +01:00 committed by wmayer
parent d6052a5a27
commit c861505bc9
2 changed files with 14 additions and 0 deletions

View File

@ -594,6 +594,18 @@ void PropertyPlacement::setPathValue(const ObjectIdentifier &path, const boost::
Property::setPathValue(path, value); Property::setPathValue(path, value);
} }
const boost::any PropertyPlacement::getPathValue(const ObjectIdentifier &path) const
{
std::string p = path.getSubPathStr();
if (p == ".Base.x" || p == ".Base.y" || p == ".Base.z") {
// Convert double to quantity
return Base::Quantity(boost::any_cast<double>(Property::getPathValue(path)), Unit::Length);
}
else
return Property::getPathValue(path);
}
PyObject *PropertyPlacement::getPyObject(void) PyObject *PropertyPlacement::getPyObject(void)
{ {
return new Base::PlacementPy(new Base::Placement(_cPos)); return new Base::PlacementPy(new Base::Placement(_cPos));

View File

@ -265,6 +265,8 @@ public:
void setPathValue(const ObjectIdentifier &path, const boost::any &value); void setPathValue(const ObjectIdentifier &path, const boost::any &value);
const boost::any getPathValue(const ObjectIdentifier &path) const;
const char* getEditorName(void) const { const char* getEditorName(void) const {
return "Gui::PropertyEditor::PropertyPlacementItem"; return "Gui::PropertyEditor::PropertyPlacementItem";
} }