[Paraview-developers] Changing context menu of a view from a plugin
Jérôme
jerome.velut at gmail.com
Fri Apr 22 02:32:10 EDT 2011
Hi again,
The solution that consists in overriding the
pqPipelineContextMenuBehaviour::buildPipeline in a derived class seems
to be fine. However, the original behaviour is still installed through
view->getProxy()->installEventFilter( ... ) in pqParaviewBehaviours.
Thus right clicking on a polydata triggers the call to my
buildPipeline AND the default one, yielding two contextual menus!! I
would have an instance of the original eventFilter, so that I can call
removeEventFilter( ... ) on my view proxy, but I didn't manage to
figure out how it is possible.
I also would like the buildMenu function to be called everytime, not
only when a pqDataRepresentation is picked. Should I submit a patch?
Subsidiary question: right clicking on an ImageSlice representation
makes the eventFilter to behave as nothing were found... Is it on
purpose?
Thanks !
Jerome
2011/4/21 Jérôme <jerome.velut at gmail.com>:
> Hi,
> I wrote a plugin that adds some item in the context menu when right
> clicking in a view. With PV-3.8, I just had to :
> view->GetWidget()->addAction( item )
>
> Since PV-3.10, the context menu is implemented through
> pqParaViewBehaviours, specifically pqPipelineContextMenuBehaviour. It
> seems that the menu is now created at run-time, at each right-click
> thanks to pqPipelineContextMenuBehaviour::eventFilter.
> Thus I tried to derive pqPipelineContextMenuBehaviour into
> pqModifiedContextMenu, overload eventFilter and call
> view->installEventFilter( modfiedContextMenu). But the menu is cleaned
> in the parent class, though I have to call the parent eventFilter !!
>
> I also tried to integrally copy the parent eventFilter, but with no
> luck : the event seems to not being recognize. I think I missed
> something in the derivation or instantiation process.
>
> One solution would be to overload
> pqPipelineContextMenuBehaviour::buildMenu(), but it is called only
> when a polydata repr is picked.
>
> Note that if I keep the pv-3.8 fashion, my plugin works but awkwardly
> : y context menu appears first, then I have to click once more to get
> the ParaView standard context menu (link camera or representation
> option)...
>
> How can I change the context menu of a view from a plugin ?
> Thanks a lot !
> Jerome
>
More information about the Paraview-developers
mailing list