How to refresh the property editor?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
wandererfan
Veteran
Posts: 6265
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

How to refresh the property editor?

Post by wandererfan »

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
Veteran
Posts: 6265
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: How to refresh the property editor?

Post by wandererfan »

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

Re: How to refresh the property editor?

Post by wandererfan »

Post Reply