How to refresh the property editor?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
wandererfan
Posts: 3651
Joined: Tue Nov 06, 2012 5:42 pm

How to refresh the property editor?

Postby wandererfan » Thu Jan 29, 2015 1:06 am

I have 2 Properties - ScaleType and Scale. Depending on the value of ScaleType, Scale is either read-only or editable.

Currently when ScaleType is changed, Scale retains it's read-only attribute until I unselect the object and reselect it. I've tried various "execute" and "touch" methods but I'm missing something.

Any suggestions?

wf

Code: Select all

App::DocumentObjectExecReturn *FeatureView::execute(void)
{
    if(strcmp(ScaleType.getValueAsString(), "Document") == 0) {
        Scale.StatusBits.set(2, true);

        Drawing::FeaturePage *page = findParentPage();
        if(page) {
            if(std::abs(page->Scale.getValue() - Scale.getValue()) > FLT_EPSILON) {
                Scale.setValue(page->Scale.getValue()); // Recalculate scale from page
                Scale.touch();
            }
        }
    } else if(strcmp(ScaleType.getValueAsString(), "Custom") == 0) {
        Scale.StatusBits.set(2, false);
        // something needs to happen here to update PropertyEditor?
    }
    return App::DocumentObject::execute();
}
User avatar
wandererfan
Posts: 3651
Joined: Tue Nov 06, 2012 5:42 pm

Re: How to refresh the property editor?

Postby wandererfan » Thu Jan 29, 2015 1:40 am

Looks like the C++ version of this: http://www.forum.freecadweb.org/viewtop ... =22&t=9499
User avatar
wandererfan
Posts: 3651
Joined: Tue Nov 06, 2012 5:42 pm

Re: How to refresh the property editor?

Postby wandererfan » Thu Jan 29, 2015 2:35 pm