[Paraview] List to select zones in object panel for a custom reader
burlen
burlen.loring at gmail.com
Wed Sep 1 19:57:07 EDT 2010
by the way, it is possible to send a variable length arrays of type
other than string from client to server, the trick is to use the first
element to send the total number of elements sent. This will work with
state, but using a string is probably more robust against future PV
changes since this relies on undocumented functionality.
Your panel has a method like this:
//-----------------------------------------------------------------------------
void pqXXXPanel::accept()
{
//...
// The first element is expected to be the length
vector<int> meshIds(1,0);
//
// walk your Qt widget & push selected mesh ids on the vector
//
meshIds[0]=meshIds.size(); // set length
vtkSMIntVectorProperty *meshProp
= dynamic_cast<vtkSMIntVectorProperty
*>(dbbProxy->GetProperty("SetMeshIds"));
meshProp->SetNumberOfElements(meshIds.size());
meshProp->SetElements(&meshIds[0]);
meshProp->Modified();
dbbProxy->UpdateProperty("SetMeshIds");
//...
}
Your reader has a method like this:
//-----------------------------------------------------------------------------
void vtkXXXReader::SetMeshIds(int *ids)
{
const int n=ids[0];
if (n>1)
{
this->MeshIds.assign(ids+1,ids+n);
}
else
{
this->MeshIds.clear();
}
this->SetNumberOfMeshes(n-1);
this->Modified();
}
burlen wrote:
> You don't necessarily need to do a lot of heavy coding.
>
> One simple way to transfer variable length data such as the list of
> selected zone ids from client to server is via a string vector
> property. On the client side you will need a custom panel that handles
> serialization of the list of zones into the string vector property. On
> the server side parse the string during request data phase. A format
> like:
>
> "nZoneIds Zone1Id Zone2Id ... ZoneNId".
>
> Would do the trick, and would be compatible with PV state.
>
> Burlen
>
> Paul Edwards wrote:
>> Hi,
>>
>> I have a reader and would like to have a list box in the object panel
>> to select which zones to read in from the file. The number of zones
>> can change depending on the file. Does anyone have any suggestions
>> for how to do this? My ideas were:
>>
>> * add a new vtkSM*Domain
>> o I don't think this is possible in a plugin because
>> pqSMAdaptor needs to be updated for any new class (is that
>> right?)
>> * create a custom panel and have one information only property to
>> get the number of zones and another property to set the zones
>> o would the set property need to be a string that I put
>> comma-separated zone indexes or is there a way to change
>> the number of elements in an integer vector?
>>
>> Thanks in advance,
>> Paul
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> 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
>>
>
More information about the ParaView
mailing list