[Paraview] how to add custom filter to custom menu

FISSELL at pitt.edu FISSELL at pitt.edu
Wed Aug 31 17:55:48 EDT 2011


Hi Burlen,

Thanks so much !!!!  I tried your code and I do get my filter in
my menu.  Your code had changes from the Examples/SourceToolbar
code that I would not have figured out.
Unfortunately my filter does have 2 mandatory inputs, so I got
a runtime error
ERROR: In
/dist/pkg/ParaView-3.10.1-src/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
line 727
vtkPVCompositeDataPipeline (0x1843eca0): Input port 1 of algorithm
vtkIntersectRoi(0x1843db30) has 0 connections but is not optional.

as per your comment below, I think my call to builder->createFilter()
needs to be more complex
and list inputs.  Will try your snippet below.

thanks a lot for example code !
kate


> Hi,
>
> Since it was so straight forward I tested it. Here is an example adding
> the menu with a filter.
>
> Burlen
>
> On 08/31/2011 12:32 PM, Burlen Loring wrote:
>> Hi Kate,
>>
>> There's also an easy way to create a toolbar via xml (example below,
>> add "show_in_toolbar" and "icon"attributes).
>>
>> <ParaViewFilters>
>> <Category name="Common" menu_label="&amp;Common" preserve_order="1"
>>     show_in_toolbar="1">
>> <Proxy group="filters" name="Calculator"
>> icon=":/pqWidgets/Icons/pqCalculator24.png"/>
>> </Category>
>> </ParaViewFilters>
>>
>> But you are asking about menus...
>>
>> On the wiki there is some info about adding menus
>> http://www.itk.org/Wiki/Plugin_HowTo#Adding_a_Menu it's almost the
>> same as adding a toolbar.There is an example of a toolbar that creates
>> sources, Examples/Plugins/SourceToolbar to work from. That shows how
>> to create a source but you need a filter.
>>
>> The difference between creating sources and filters is that for
>> filters you have to specify the filters input (see
>> pqObjectBuilder::createFilter).
>>
>> here is a snippet that would locate the selected sources. I think you
>> could use this to get the source for your filter. Then it will be an
>> easy change to the SourceToolbar example.
>>
>>     pqApplicationCore* core = pqApplicationCore::instance();
>>     pqServerManagerSelection sels =
>> *core->getSelectionModel()->selectedItems();
>>     pqPipelineSource* source = 0;
>>     pqServerManagerModelItem* item = 0;
>>     if(sels.empty())
>>     {
>>         return NULL;
>>     }
>>     pqServerManagerSelection::ConstIterator iter = sels.begin();
>>
>>     item = *iter;
>>     source = dynamic_cast<pqPipelineSource*>(item);
>>
>> Sorry to be so imprecise, and note I have't tried this. Hope it helps
>> Burlen
>>
>> On 08/31/2011 11:14 AM, FISSELL at pitt.edu wrote:
>>> Hi Burlen,
>>>
>>> Thanks for getting back to me.  Yes, I am aware of the submenu option.
>>> That's plan B if I can't use a separate menu.
>>> It was so easy to create the menu, I would be sort of suprised if
>>> it wasn't equally easy to populate it...
>>>
>>> thanks
>>> Kate
>>>
>>>
>>>> Hi,
>>>>
>>>> Did you know that you could create a category in the filters menu by
>>>> way
>>>> of xml? That puts your filters in their own submenu making them easy
>>>> to
>>>> find. In your client xml you have something like:
>>>>
>>>> <ParaViewFilters>
>>>> <Category name="SciberQuestSciVis" menu_label="Sciber&amp;Quest">
>>>> <Proxy group="filters" name="vtkSQDistributedStreamTracer"/>
>>>> </Category>
>>>> </ParaViewFilters>
>>>>
>>>> Just checking.
>>>> Burlen
>>>>
>>>> On 08/31/2011 08:28 AM, FISSELL at pitt.edu wrote:
>>>>> Hi,
>>>>>
>>>>> I made a custom filter and added a new dropdown menu to the main
>>>>> Paraview menubar, as per wiki tutorials.
>>>>> My filter works in the filters menu, and I can call the OK dialog
>>>>> from
>>>>> my
>>>>> new menu.
>>>>> I would like to add my filter to my new menu and have Paraview
>>>>> understand
>>>>> it as,
>>>>> and treat it just like, filters in the filter menu.
>>>>> I saw this posting very relevant to my question:
>>>>> http://www.cmake.org/pipermail/paraview/2010-March/016211.html
>>>>> but I'd like a little more help.
>>>>>
>>>>> What program do I put that code snippet in ?  Do I make a special
>>>>> client side plugin just to get my filter in my toolbar ?
>>>>> Is there a way to do this just via XML specification ?
>>>>> Note I am not developing a standalone application, I am just adding
>>>>> plugins
>>>>> to ParaView.
>>>>> If I put my filter in my custom menu, not the ParaView filters menu,
>>>>> will ParaView know my plugin is a filter, eg should be added to
>>>>> pipeline
>>>>> when
>>>>> invoked, only be added if datatypes match, etc etc ?
>>>>>
>>>>> Is it a bad design to create an additional menu of filters rather
>>>>> than
>>>>> making a sub-section in the existing filters menu ?  I just think the
>>>>> current set of filters is so large it would be easier for our users
>>>>> to
>>>>> make
>>>>> a separate menu.
>>>>>
>>>>> thanks
>>>>> kate
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>
>>>
>>
>> _______________________________________________
>> 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