Expressions: Integrate into the property editor

- basic infrastructure for handling of expressions
- port the unit properties editor to support expressions
- port placement editor to support expressions
- expressions for double spinbox
- expressions in sketch constraints
This commit is contained in:
Stefan Tröger
2015-10-06 08:45:15 +02:00
committed by wmayer
parent f037bf9f52
commit 96a586d04a
11 changed files with 467 additions and 62 deletions

View File

@@ -32,6 +32,7 @@
#include <Base/Tools.h>
#include <App/ObjectIdentifier.h>
#include <App/Document.h>
#include <boost/bind.hpp>
using namespace Gui;
using namespace App;
@@ -39,6 +40,7 @@ using namespace App;
ExpressionBinding::ExpressionBinding()
: iconLabel(0)
, iconHeight(-1)
, m_autoApply(false)
{
}
@@ -66,6 +68,9 @@ void Gui::ExpressionBinding::setExpression(boost::shared_ptr<Expression> expr)
lastExpression = getExpression();
docObj->ExpressionEngine.setValue(path, expr);
if(m_autoApply)
apply();
}
void ExpressionBinding::bind(const App::ObjectIdentifier &_path)
@@ -75,6 +80,10 @@ void ExpressionBinding::bind(const App::ObjectIdentifier &_path)
Q_ASSERT(prop != 0);
path = prop->canonicalPath(_path);
//connect to be informed about changes
DocumentObject * docObj = path.getDocumentObject();
connection = docObj->ExpressionEngine.expressionChanged.connect(boost::bind(&ExpressionBinding::expressionChange, this, _1));
}
void ExpressionBinding::bind(const Property &prop)
@@ -173,3 +182,9 @@ bool ExpressionBinding::apply()
return apply("App.ActiveDocument." + name + "." + std::string(prop->getName()));
}
void ExpressionBinding::expressionChange(const ObjectIdentifier& id) {
if(id==path)
onChange();
}