[Paraview] upgrading reader module/plugin
Utkarsh Ayachit
utkarsh.ayachit at kitware.com
Wed Jan 4 22:52:32 EST 2017
Mark,
As you can expect, connecting Qt widgets to vtkSMProperty's on proxies
in a two-way-link is common in ParaView panels and hence ParaView
provides quite a few ways for doing that. For your use-case, where
you're connecting a QCheckBox to an IntVectorProperty on the proxy,
your pqPropertyWidget subclass can do something like the following:
Assuming your XML for the group is as follows:
QCheckBox *checkbox = ...
vtkSMProperty* smProperty = smgroup->GetProperty("InterpolateFields");
this->addPropertyLink(checkbox, "checked", SIGNAL(toggled(bool), smProperty);
That should do it.
Utkarsh
On Wed, Jan 4, 2017 at 9:48 AM, Mark Olesen <Mark.Olesen at esi-group.com> wrote:
> I'm currently upgrading a reader module from using a pqAutoGeneratedObjectPanel to a using a property group widget (as per http://www.paraview.org/Wiki/Plugin_HowTo#Adding_Customizations_for_Properties_Panel).
>
> I have my bunch of properties in a PropertyGroup and have a panel_widget associated with them. Everything loads up, and using printf() I can verify that the property values are all being updated.
> However, not only does it seems rather clunky, I cannot get the "Apply" button on the property panel to notice when the property values have been updated.
>
> Here's a basic sketch of what I have:
>
> // Get the property from the group (with down-cast):
> interpolateFields_ = group->GetProperty("interpolate");
>
> // Provide a checkbox as widget for it - two-column layout.
> QCheckBox* b = new QCheckBox(prop->GetXMLLabel(), this);
> form->addWidget(b, row, col, Qt::AlignLeft);
>
> // Connect to slot:
> connect(b, SIGNAL(toggled(bool)), this, SLOT(interpolateFields(bool)));
>
> // This is ugly, but seems to be needed???
> interpolateFields_->SetImmediateUpdate(true);
>
> // And the slot itself
> void interpolateFields(bool checked)
> {
> interpolateFields_->SetElement(0, checked);
> // this->setModified();
> //^^^ used to work with pqAutoGeneratedObjectPanel
> }
>
> I used to rely on the setModified() method from the pqAutoGeneratedObjectPanel, but now can't seem to get from the SMproxy to the pqProxy or whatever.
>
> Or am I going about this entirely the wrong way?
> FWIW, here are the relevant sub-entries from the XML, in case there is something missing there:
>
> <IntVectorProperty
> name="InterpolateFields"
> command="SetInterpolateVolFields"
> number_of_elements="1"
> default_values="1"
> animateable="0">
> <BooleanDomain name="bool"/>
> <Documentation></Documentation>
> </IntVectorProperty>
>
> <PropertyGroup
> label="General Controls"
> panel_widget="my_reader_controls">
> <Property name="InterpolateFields"/>
> ...
> </PropertyGroup>
>
> Unfortunately, the Examples/Plugins/PropertyWidgets is a bit scanty here.
>
> Thanks for any advice,
>
> /mark
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
More information about the ParaView
mailing list