issue #0002673: Not memorize the rotation

This commit is contained in:
wmayer
2016-12-19 17:32:39 +01:00
parent b19a4246ab
commit 00a25d5998
3 changed files with 24 additions and 2 deletions

View File

@@ -160,6 +160,10 @@ bool PropertyItem::hasProperty(const App::Property* prop) const
return false;
}
void PropertyItem::assignProperty(const App::Property*)
{
}
bool PropertyItem::removeProperty(const App::Property* prop)
{
std::vector<App::Property*>::iterator it = std::find(propertyItems.begin(), propertyItems.end(), prop);
@@ -1835,6 +1839,21 @@ void PropertyPlacementItem::setPosition(const Base::Vector3d& pos)
setValue(QVariant::fromValue(val));
}
void PropertyPlacementItem::assignProperty(const App::Property* prop)
{
if (prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())) {
const Base::Placement& value = static_cast<const App::PropertyPlacement*>(prop)->getValue();
double angle;
Base::Vector3d dir;
value.getRotation().getValue(dir, angle);
Base::Vector3d cross = this->rot_axis.Cross(dir);
if (cross.Sqr() > Base::Vector3d::epsilon()) {
this->rot_axis = dir;
}
this->rot_angle = Base::toDegrees(angle);
}
}
QVariant PropertyPlacementItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId()));
@@ -1928,13 +1947,13 @@ QWidget* PropertyPlacementItem::createEditor(QWidget* parent, const QObject* rec
void PropertyPlacementItem::setEditorData(QWidget *editor, const QVariant& data) const
{
Gui::LabelButton *pe = qobject_cast<Gui::LabelButton*>(editor);
PlacementEditor *pe = qobject_cast<PlacementEditor*>(editor);
pe->setValue(data);
}
QVariant PropertyPlacementItem::editorData(QWidget *editor) const
{
Gui::LabelButton *pe = qobject_cast<Gui::LabelButton*>(editor);
PlacementEditor *pe = qobject_cast<PlacementEditor*>(editor);
return pe->value();
}

View File

@@ -114,6 +114,7 @@ public:
void updateData();
const std::vector<App::Property*>& getPropertyData() const;
bool hasProperty(const App::Property*) const;
virtual void assignProperty(const App::Property*);
bool removeProperty(const App::Property*);
App::Property* getFirstProperty();
const App::Property* getFirstProperty() const;
@@ -582,6 +583,7 @@ class GuiExport PropertyPlacementItem: public PropertyItem
virtual QVariant editorData(QWidget *editor) const;
virtual void propertyBound();
virtual void assignProperty(const App::Property*);
Base::Quantity getAngle() const;
void setAngle(Base::Quantity);

View File

@@ -268,6 +268,7 @@ void PropertyModel::updateProperty(const App::Property& prop)
child->updateData();
QModelIndex data = this->index(row, column, QModelIndex());
if (data.isValid()) {
child->assignProperty(&prop);
dataChanged(data, data);
updateChildren(child, column, data);
}