How to implement right-click context menu in paraview plugin way

Dear Experts,
I want to implement my own right-click context menu and hide paraview default one in paraview plugin way.
I read some paraview source code, I found I can create similar class like pqPipelineContextMenuBehavior, However, the difficult is i want to use paraview plugin to implement it, and must keep paraview source code untouched!

My question is: is it possible to use plugin to fulfill this? How to do?

Could you please help me out!

Thanks in advance!

this is not supported via plugins. Plugins are intentionally not intended to remove functionality.

Hi Utkarsh,
Thank you for your reply!
Then if it is impossible in plugin way, what is the suggested way?
I should create my own application?

Best Regards

Hi Sharon,

To remove functionnality, you are suposed to create a ParaView based application.
See Examples/Applications/ in ParaView source code.

In any case, contextual menu is always widget specific, so you won’t be able to change the behavior of the right click on the whole application.

What are you trying to achieve exactly ?

Hi Mathieu,
Thank you for your reply!

I want to have more control on context menu, like i want there are some specific menu actions when after right click.
For example, i want show information about each leaf type of a tree, how many leaves on this tree, how long of the longest tree trunk, How many trunk bifurcation points…

By the way, i also need to read each trunk from different files but into one vtkMultiBlockDataset, how can i achieve this?

Thanks in Advance!

Best Regards,
Sharon

In which widget ? The pipeline browser ? You can just reimplement a PipelineBrowser and define your own contextual menu.

Use GroupDataSet filter ?

Yes, in the pipeline browser.
Thank you, i will try!

i haven’s used GroupDataSet, this can be used in the reader?

Thank you for your prompt reply!

It is a filter in ParaView. But I’m not sure what you are trying to achieve here.

I want to read data from different files but want set all the data into one single vtkMultiBlockDataSet

  • Open ParaView
  • Read all your data with multiple readers, Apply
  • Select all your reader in the pipeline browser using the mouse and keeping “Ctrl” key pressed
  • Filter -> Alphabetical -> Group DataSet
  • Apply
1 Like

Thank you Mathieu!
This is clear!

Is it possible for me write my own reader that can achieve the same result?

Thanks a lot!

Sharon

There are multiple ways to achieve that :

  • Custom Filters (tools -> Create Custom Filters (GUI based))
  • Programmable Source ( source -> Programmable Source (Python based))
  • meta reader in a C++ plugin ( require compilation, C++ based)
1 Like

Hi Mathieu,
I prefer c++ plugin way, however, i found each reader can only read one file, the architecture already define inside the paraview, it is impossible for me to let one reader to read multiple files…

This is a secondary answer to the earlier question about reading all the data into a single vtkMultiBlockDataSet. ParaView allows several types of files to be read in as a time series if their files have a conventional numbering (e.g. file0.vtk, file1.vtk, file2.vtk, etc.). If your file type supports this, you can read the data as a time series and then run the Group Time Steps filter to combine the data from all time steps into a single vtkMultiBlockDataSet. That tends to be a lot easier than trying to open all the files separately.

1 Like

Thank you Kenneth for your reply!

Is it possible or how to write my own reader to achieve this?

Thanks in advance!
Best Regards,
Sharon

@mwestphal pretty much covered the options. The only addition I would add would be to build a python macro, which is usually my go-to solution. The only problem is that AFAIK there is no way to open the file dialog from a macro.

1 Like

@sharon Context-menus via plugins are coming soon to ParaView. This post describes the mechanism being added to allow user-provided menus. It will allow plugins to omit ParaView’s menu if needed, although this may not be advisable in all cases.

2 Likes

Hi David,
This is great!
Although i already wrote my own application, this still interested me, i will have a try later.
Thanks and best regards,
sharon