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

(sharon) #1

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!

(Utkarsh Ayachit) #2

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

(sharon) #3

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

(Mathieu Westphal (Kitware)) #4

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 ?

(sharon) #5

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,

(Mathieu Westphal (Kitware)) #6

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

Use GroupDataSet filter ?

(sharon) #7

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

(sharon) #8

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

Thank you for your prompt reply!

(Mathieu Westphal (Kitware)) #9

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

(sharon) #10

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

(Mathieu Westphal (Kitware)) #11
  • 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
(sharon) #12

Thank you Mathieu!
This is clear!

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

Thanks a lot!


(Mathieu Westphal (Kitware)) #13

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
(sharon) #14

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…

(Kenneth Moreland) #15

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
(sharon) #16

Thank you Kenneth for your reply!

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

Thanks in advance!
Best Regards,

(Kenneth Moreland) #17

@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