[Paraview] source with optional input port
burlen
burlen.loring at gmail.com
Mon Jan 4 12:33:12 EST 2010
Happy New Year Utkarsh,
> What is the user wants the panel
> for (readers, MyReader) and (filters, MyFilter) but not (readers,
> MyFilter)?
To be honest I hadn't anticipated the situation but, as far as I can
tell this scenario is OK under the proposed change because the group is
tested first and if it doesn't match the search is terminated. So bottom
line, panels for objects with the same name but a different group can be
distinct and PV won't get confused.
Here is an example of how the proposed changes lets one associate the
same panel with both a source and a filter that is implemented with a
single vtk class. For example if the class is vtkSQHemisphereSource and
the panel is pqSQHemisphereSource, here is what the cmake lists look like:
# beginning of cmake lists
QT4_WRAP_CPP(MOC_SRCS pqSQHemisphereSource.h)
QT4_WRAP_UI(UI_SRCS pqSQHemisphereSourceForm.ui)
ADD_PARAVIEW_OBJECT_PANEL(
IFACES IFACE_SRCS
CLASS_NAME pqSQHemisphereSource
XML_NAME vtkSQHemisphereSource
XML_GROUP sources filters) # <----------------------THE PROPOSED
CHANGE GIVES YOU THIS
# end of cmake lists
Here is what the server manager XML looks like:
<!-- beginning of xml -->
<ServerManagerConfiguration>
<!--
*******************************************************************************
*
*
*
Sources *
*
*
*******************************************************************************
-->
<ProxyGroup name="sources">
<!--
==================================================================== -->
<Proxy name="SQHemisphereUI">
<!-- Out -->
<OutputPort name="Northern Hemisphere" index="0" />
<OutputPort name="Southern Hemisphere" index="1" />
<DoubleVectorProperty
name="GetCenter"
command="GetCenter"
information_only="1">
<SimpleDoubleInformationHelper/>
</DoubleVectorProperty>
<DoubleVectorProperty
name="Center"
command="SetCenter"
number_of_elements="3"
animateable="1"
default_values="0.0 0.0 0.0"
information_property="GetCenter">
<DoubleRangeDomain name="range"/>
<Documentation>
This property specifies the 3D coordinates for the center of the
sphere.
</Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty
name="GetRadius"
command="GetRadius"
information_only="1">
<SimpleDoubleInformationHelper/>
</DoubleVectorProperty>
<DoubleVectorProperty
name="Radius"
command="SetRadius"
number_of_elements="1"
animateable="1"
default_values="0.5"
information_property="GetRadius">
<DoubleRangeDomain name="range" min="1E-15"/>
<Documentation>
This property specifies the radius of the sphere.
</Documentation>
</DoubleVectorProperty>
<IntVectorProperty
name="GetResolution"
command="GetResolution"
information_only="1">
<SimpleIntInformationHelper/>
</IntVectorProperty>
<IntVectorProperty
name="Resolution"
command="SetResolution"
number_of_elements="1"
default_values="8"
information_property="GetResolution">
<IntRangeDomain name="range" min="3" max="1024" />
<Documentation>
The value of this property controls the number of lat-lon lines in
the output.
</Documentation>
</IntVectorProperty>
<!-- End Hemisphere UI -->
</Proxy>
<!--
==================================================================== -->
<SourceProxy
name="vtkSQHemisphereSource"
class="vtkSQHemisphereSource"
label="SQ Hemisphere"
base_proxyname="SQHemisphereUI"
base_proxygroup="sources">
<Documentation
long_help="Create a 3D sphere given a center and radius."
short_help="Create a 3D sphere">
The Hemisphere source can be used to add a polygonal sphere to the
3D scene. The output of the Hemisphere source is polygonal data with
point normals defined.
</Documentation>
<!-- End Hemisphere Source -->
</SourceProxy>
</ProxyGroup>
<!--
*******************************************************************************
*
*
*
Filters *
*
*
*******************************************************************************
-->
<ProxyGroup name="filters">
<!--
==================================================================== -->
<SourceProxy
name="vtkSQHemisphereSource"
class="vtkSQHemisphereSource"
label="SQ Hemisphere"
base_proxyname="SQHemisphereUI"
base_proxygroup="sources">
<Documentation
long_help="Create a 3D sphere given a center and radius."
short_help="Create a 3D sphere">
The Hemisphere source can be used to add a polygonal sphere to
the 3D scene. The output of the Hemisphere source is polygonal data with
point normals defined.
</Documentation>
<InputProperty
name="Input"
command="SetInputConnection">
<ProxyGroupDomain name="groups">
<Group name="sources"/>
<Group name="filters"/>
</ProxyGroupDomain>
<DataTypeDomain name="input_type">
<DataType value="vtkDataSet"/>
</DataTypeDomain>
</InputProperty>
<!-- End Hemisphere Source -->
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>
<!-- end xml -->
> Not sure if it's even worth the trouble -- but just in case
> you can think of a cleaner solution.
Taking a quick look at how it all works in pqObjectInspectorWidget it
doesn't look like there is a cleaner solution to be had easily. But you
know you are the expert here, so if there is a better way you probably
spot it better than I. I can say this though, this solution may not be
elegant but in most cases the change adds very little over head because
in the nested m*n loop, the outer m loop is the number of groups, will
almost always be 1 and when it's not m will most likely be 2, in the
worst case (I don't think it will ever come up) it could be 3 or 4
(sources,filters,readers, what else?). And, n the number of custom
panels, currently I will guess is at worst on the order of 100. So we're
not talking about adding a lot of work here.
Let me know if you have something better in mind
Burlen
Utkarsh Ayachit wrote:
> That sounds reasonable, but specification of multiple group names and
> xml names and the m*n matching between them seems funny. Any ideas on
> how we can make that more explicit? What is the user wants the panel
> for (readers, MyReader) and (filters, MyFilter) but not (readers,
> MyFilter)? Not sure if it's even worth the trouble -- but just in case
> you can think of a cleaner solution.
>
> Utkarsh
>
> On Fri, Dec 18, 2009 at 6:36 PM, burlen <burlen.loring at gmail.com> wrote:
>> Hi folks,
>>
>> I'd like to have a PV data source that can be used either as a
>> source(without an input dataset) or as a filter(with an input dataset).
>> Based on what I have observed, to accomplish it the source has to show up
>> both in the sources menu and the filters menu, which is easy to do with the
>> XML by adding an entry in both the sources and filters groups that points
>> back to the same class and base proxy. It all works except for sharing a
>> custom qt panel between them, specifically sharing the panel across proxy
>> groups isn't currently allowed.
>>
>> The attached patch enables a custom panel to be shared across the
>> sources/filters proxy groups. Assuming that this is the right way to
>> accomplish this can this patch be committed?
>>
>> Why would you want to do this? For one example:
>> a source with an optional input used like a filter can then extract spatial
>> bounds from the input dataset and then position itself automatically in the
>> scene. This makes the source faster/easier to use than if you have to type
>> in the coordinates to position it. There are plenty of other examples, with
>> one thing in common, the potential to make the source easier/faster to use.
>>
>> Burlen
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> 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