Skip to content

Commit

Permalink
PropertyPlacement: Fixed setting of angle (missing deg to radian conv…
Browse files Browse the repository at this point in the history
…ersion).
  • Loading branch information
eivindkv authored and wwmayer committed Dec 18, 2015
1 parent 7760c6a commit 6f39eed
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/App/PropertyGeo.cpp
Expand Up @@ -35,6 +35,7 @@
#include <Base/Stream.h>
#include <Base/Rotation.h>
#include <Base/Quantity.h>
#include <Base/Tools.h>
#include <Base/VectorPy.h>
#include <Base/MatrixPy.h>
#include <Base/PlacementPy.h>
Expand Down Expand Up @@ -567,6 +568,32 @@ void PropertyPlacement::getPaths(std::vector<ObjectIdentifier> &paths) const
<< ObjectIdentifier::Component::SimpleComponent(ObjectIdentifier::String("z")));
}

void PropertyPlacement::setPathValue(const ObjectIdentifier &path, const boost::any &value)
{
if (path.getSubPathStr() == ".Rotation.Angle") {
double avalue;

if (value.type() == typeid(Base::Quantity))
avalue = boost::any_cast<Base::Quantity>(value).getValue();
else if (value.type() == typeid(double))
avalue = boost::any_cast<double>(value);
else if (value.type() == typeid(int))
avalue = boost::any_cast<int>(value);
else if (value.type() == typeid(unsigned int))
avalue = boost::any_cast<unsigned int >(value);
else if (value.type() == typeid(short))
avalue = boost::any_cast<short>(value);
else if (value.type() == typeid(unsigned short))
avalue = boost::any_cast<unsigned short>(value);
else
throw std::bad_cast();

Property::setPathValue(path, Base::toRadians(avalue));
}
else
Property::setPathValue(path, value);
}

PyObject *PropertyPlacement::getPyObject(void)
{
return new Base::PlacementPy(new Base::Placement(_cPos));
Expand Down
2 changes: 2 additions & 0 deletions src/App/PropertyGeo.h
Expand Up @@ -263,6 +263,8 @@ class AppExport PropertyPlacement: public Property
/// Get valid paths for this property; used by auto completer
void getPaths(std::vector<ObjectIdentifier> &paths) const;

void setPathValue(const ObjectIdentifier &path, const boost::any &value);

const char* getEditorName(void) const {
return "Gui::PropertyEditor::PropertyPlacementItem";
}
Expand Down

0 comments on commit 6f39eed

Please sign in to comment.