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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user