I'm updating my custom plugin to the latest version of ParaView. Most
everything works as I would expect, however I have run into an issue.

My plugin has a reader and a filter each with a custom panel that follows
the same layout. The panel has a ComboBox and a ListBox with CheckBoxItems.
When the dropdown is changed in the ComboBox, the ListBox gets immediately
repopulated to show the change. Then you select some items and hit apply.

The reader is able to do that exactly as it did in the older version of
ParaView. However, the filter shows a ListBox without the option to Check
the items. The code between the reader/filter for the panel is almost
identical with the exception of the names. The function updateTitleList()
never gets called in the filter yet in the reader's version of the panel it
does. I can't figure out why it only works with one. I would assume it
would act the same for both.

Also, I believe with the new changes (in ParaViewCollaborationChanges.pdf),
a lot of my code can be simplified. From what I understand, I should not
need to call things like 'this->proxy()->UpdateProperty("cbType", 1) since
the vtkSMProperties can talk to the VTKObjects. Is this true?

Any help would be appreciated or if there is a more convenient way to do
what I'm doing that would be great.

I have attached my cxx for the panel and my XML.

Thanks,
Brian
#include "NetDMFStatisticPanel.h"

#include "pqProxy.h"
#include "pqSMAdaptor.h"
#include "vtkSMProxyManager.h"

#include "vtkSMStringVectorProperty.h"
#include "vtkSMDoubleVectorProperty.h"
#include "vtkSMIntVectorProperty.h"

#include <QComboBox>
#include <QLabel>
#include <QLayout>

NetDMFStatisticPanel::NetDMFStatisticPanel(pqProxy* proxy, QWidget* p)
    : pqNamedObjectPanel(proxy, p)
{
    this->widgets.setupUi(this);
    this->linkServerManagerProperties();

    QObject::connect(this->widgets.cbType,
        SIGNAL(currentIndexChanged(int)),
        this,
        SLOT(updateTitleList()));
    QObject::connect(this->widgets.lbTitle,
        SIGNAL(itemChanged(QListWidgetItem*)),
        this,
        SLOT(updateTitle()));
}

void
NetDMFStatisticPanel::updateTitleList()
{
    vtkSMStringVectorProperty* prop = dynamic_cast<vtkSMStringVectorProperty*>(
        this->proxy()->GetProperty("cbType"));
    prop->SetElement(0,
        this->widgets.cbType->currentText().toStdString().c_str());
    this->proxy()->UpdateProperty("cbType", 1);
    
    vtkSMStringVectorProperty* lb = dynamic_cast<vtkSMStringVectorProperty*>(
        this->proxy()->GetProperty("TitleList"));
    this->proxy()->UpdatePropertyInformation(lb);

    this->widgets.lbTitle->clear();
    for(int i = 0; i < lb->GetNumberOfElements(); i=i+2)
    { 
        QListWidgetItem *item = new QListWidgetItem();
        item->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
        item->setCheckState(Qt::Unchecked);
        item->setText(lb->GetElement(i));
        this->widgets.lbTitle->insertItem(i, item);
    }
}

void 
NetDMFStatisticPanel::updateTitle()
{
    this->setModified();
}

void
NetDMFStatisticPanel::accept()
{
    vtkSMStringVectorProperty* lb = dynamic_cast<vtkSMStringVectorProperty*>(
        this->proxy()->GetProperty("lbTitle"));

    lb->SetNumberOfElements(this->widgets.lbTitle->count()*2); 
    for(int i = 1; i < this->widgets.lbTitle->count()+1; i++)
    {
        lb->SetElement(2*i-2, this->widgets.lbTitle->item(i-1)->text().toStdString().c_str()); 

        if(this->widgets.lbTitle->item(i-1)->checkState() == Qt::Checked)
        {   
            lb->SetElement(2*i-1, "1");
        }
        else
        {
            lb->SetElement(2*i-1, "0"); 
        }
    }
    
    this->proxy()->UpdateProperty("lbTitle", 1);

    Superclass::accept();
}
<ServerManagerConfiguration>
    <ProxyGroup name="representations">
        <RepresentationProxy name="NetDMFRepresentation"
            class="vtkNetDMFRepresentation"
            processes="client|renderserver|dataserver"
            base_proxygroup="representations"
            base_proxyname="SurfaceRepresentation">
            
            <IntVectorProperty
                name="cbGlyphLegend"
                command="SetShowGlyphLegend"
                number_of_elements="1"
                default_values="1">
                <BooleanDomain name="bool"/>
            </IntVectorProperty>
            
            <IntVectorProperty
                name="cbTubeLegend"
                command="SetShowTubeLegend"
                number_of_elements="1"
                default_values="1">
                <BooleanDomain name="bool"/>
            </IntVectorProperty>

            <IntVectorProperty
                name="cbDisplayMap"
                command="SetShowMap"
                number_of_elements="1"
                default_values="1">
                <BooleanDomain name="bool"/>
            </IntVectorProperty>

            <DoubleVectorProperty
                name="GlyphColorMin"
                command="GetGlyphColorMin"
                information_only="1">
                <SimpleDoubleInformationHelper />
            </DoubleVectorProperty>
            <DoubleVectorProperty
                name="dsbGlyphColorMin"
                command="SetGlyphColorMin"
                number_of_elements="1"
                default_values="1">
                <DoubleRangeDomain name="range"/>
            </DoubleVectorProperty>

            <DoubleVectorProperty
                name="GlyphColorMax"
                command="GetGlyphColorMax"
                information_only="1">
                <SimpleDoubleInformationHelper />
            </DoubleVectorProperty>
            <DoubleVectorProperty
                name="dsbGlyphColorMax"
                command="SetGlyphColorMax"
                number_of_elements="1"
                default_values="1">
                <DoubleRangeDomain name="range"/>
            </DoubleVectorProperty>
            
            <DoubleVectorProperty
                name="TubeColorMin"
                command="GetTubeColorMin"
                information_only="1">
                <SimpleDoubleInformationHelper />
            </DoubleVectorProperty>
            <DoubleVectorProperty
                name="dsbTubeColorMin"
                command="SetTubeColorMin"
                number_of_elements="1"
                default_values="1">
                <DoubleRangeDomain name="range"/>
            </DoubleVectorProperty>

            <DoubleVectorProperty
                name="TubeColorMax"
                command="GetTubeColorMax"
                information_only="1">
                <SimpleDoubleInformationHelper />
            </DoubleVectorProperty>
            <DoubleVectorProperty
                name="dsbTubeColorMax"
                command="SetTubeColorMax"
                number_of_elements="1"
                default_values="1">
                <DoubleRangeDomain name="range"/>
            </DoubleVectorProperty>
        </RepresentationProxy>
        
        <Extension name="GeometryRepresentation">      
            <RepresentationType subproxy="NetDMFRepresentation"
                text="NetDMF" subtype="Surface" />

            <SubProxy>
                <Proxy name="NetDMFRepresentation"
                    proxygroup="representations" 
                    proxyname="NetDMFRepresentation">
                </Proxy>
                <ShareProperties subproxy="SurfaceRepresentation">
                    <Exception name="Input" />
                    <Exception name="Visibility" />
                    <Exception name="Representation" />
                </ShareProperties>
                
                <ExposedProperties>
                    <Property name="cbGlyphLegend" />
                    <Property name="cbTubeLegend" />
                    <Property name="dsbGlyphColorMin" />
                    <Property name="dsbGlyphColorMax" />
                    <Property name="dsbTubeColorMin" />
                    <Property name="dsbTubeColorMax" />
                    <Property name="cbDisplayMap" />
                </ExposedProperties>
            </SubProxy>
        </Extension>
    </ProxyGroup>

    <ProxyGroup name="sources">
        <SourceProxy
            name="NetDMFReader"
            class="vtkNetDMFReader"
            label="NetDMF Reader">
            <StringVectorProperty
                name="FileName"
                command="SetFileName"
                number_of_elements="1">
                <FileListDomain name="files"/>
            </StringVectorProperty>

            <DoubleVectorProperty 
                name="TimestepValues"
                repeatable="1"
                information_only="1">
                <TimeStepsInformationHelper/>
                <Documentation>
                    Available timestep values.
                </Documentation>
            </DoubleVectorProperty>

            <DoubleVectorProperty
                name="TimeRange"
                information_only="1">
                <TimeRangeInformationHelper />
            </DoubleVectorProperty>

           <StringVectorProperty 
                name="SourceList"
                command="GetSourceList"
                information_only="1">
                <StringArrayHelper />
            </StringVectorProperty>
            <StringVectorProperty 
                name="cbSource"
                command="SetSource"
                immediate_update="1"
                number_of_elements="1"
                number_of_elements_per_command="1">
                <StringListDomain name="operation">
                    <RequiredProperties>
                        <Property name="SourceList" 
                            function="ArraySelection"/>
                    </RequiredProperties>
                </StringListDomain>
            </StringVectorProperty>

            <StringVectorProperty 
                name="SelectionList"
                information_only="1">
                <ArraySelectionInformationHelper attribute_name="Selection" />
            </StringVectorProperty>
            <StringVectorProperty 
                name="lbSelection"
                command="SetSelectionArrayStatus"
                immediate_update="0"
                number_of_elements="0"
                repeat_command="1"
                number_of_elements_per_command="2"
                element_types="2 0"
                information_property="SelectionList">
                <ArraySelectionDomain name="array_list">
                    <RequiredProperties>
                        <Property name="SelectionList" 
                            function="ArrayList"/>
                    </RequiredProperties>
                </ArraySelectionDomain>
            </StringVectorProperty>

          <DoubleVectorProperty
                name="sGlyphSize"
                command="SetGlyphSize"
                number_of_elements="1"
                default_values="25.0">
                <DoubleRangeDomain name="range" min="0.0" max="100.0" />
            </DoubleVectorProperty>
 
            <DoubleVectorProperty
                name="sTubeSize"
                command="SetTubeSize"
                number_of_elements="1"
                default_values="25.0">
                <DoubleRangeDomain name="range" min="0.0" max="100.0" />
            </DoubleVectorProperty>


            <DoubleVectorProperty
                name="TimeIntervalValue"
                command="GetTimeInterval"
                information_only="1">
            </DoubleVectorProperty>
            <DoubleVectorProperty
                name="leTimeInterval"
                command="SetTimeInterval"
                number_of_elements="1"
                default_values="1">
                <DoubleRangeDomain name="range"/>
            </DoubleVectorProperty>

            <Hints>
            </Hints>

        </SourceProxy>
    </ProxyGroup>
    <ProxyGroup name="filters">
        <SourceProxy name="NetDMFStatisticFilter" 
                     class="vtkNetDMFStatisticFilter" 
                     label="NetDMF Statistic">
             <InputProperty name="Input"
                            command="SetInputConnection">
                <ProxyGroupDomain name="groups">
                    <Group name="sources"/>
                    <Group name="filters"/>
                </ProxyGroupDomain>
                <DataTypeDomain name="input_type">
                    <DataType value="vtkMultiBlockDataSet"/>
                </DataTypeDomain>
            </InputProperty>

           <StringVectorProperty 
                name="TypeList"
                command="GetTypeList"
                information_only="1">
                <StringArrayHelper />
            </StringVectorProperty>
            <StringVectorProperty 
                name="cbType"
                command="SetType"
                immediate_update="1"
                number_of_elements="1"
                number_of_elements_per_command="1">
                <StringListDomain name="operation">
                    <RequiredProperties>
                        <Property name="TypeList" 
                            function="ArraySelection"/>
                    </RequiredProperties>
                </StringListDomain>
            </StringVectorProperty>

            <StringVectorProperty 
                name="TitleList"
                information_only="1">
                <ArraySelectionInformationHelper attribute_name="Title" />
            </StringVectorProperty>
            <StringVectorProperty 
                name="lbTitle"
                command="SetTitleArrayStatus"
                immediate_update="0"
                number_of_elements="0"
                repeat_command="1"
                number_of_elements_per_command="2"
                element_types="2 0"
                information_property="TitleList">
                <ArraySelectionDomain name="array_list">
                    <RequiredProperties>
                        <Property name="TitleList" 
                            function="ArrayList"/>
                    </RequiredProperties>
                </ArraySelectionDomain>
            </StringVectorProperty>

        <Hints>
            <View type="XYChartView" />
            <Plotable />
        </Hints>
        </SourceProxy>
    </ProxyGroup>
</ServerManagerConfiguration> 
_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to