listen for ctf otf changes with traits in mayavi volume rendering

回眸只為那壹抹淺笑 提交于 2019-12-24 16:15:09

问题


I would like to listen to changes in the transfer function in how the color and opacity (ctf/otf) of my data is represented.

Listening to sensible-sounding traits such as mayavi.modules.volume.Volume._ctf does not trigger my callback.

I would expect this to be changed by the user either through the "standard" mayavi pipeline display (as part of EngineRichView) or through including the Volume object's view directly. No such luck either way.

It is maybe telling that when you press the big red "record" button, the recorder also does not seem to notice user changes to the ctf.


回答1:


You are going to wade into dangerous territory. As you noted the recorder has idosyncratic behavior -- what that really means is that it uses features to programatically "disable" the trait notifications while it is doing things.

You can probably figure out a way to do it that way, but most likely you'll have to dig deeply into the code that assigns the vtk modules.

What would probably make the most sense, is for you to write a GUI that does exactly what you want. That is, instead of listening to something like Volume._ctf, and then opening up the menu and changing the color, you can make a GUI and add a button that says "Change volume color" that when clicked brings the user to a color wheel. Then it's just a matter of listening to the GUI elements that you explicitly code for.



来源:https://stackoverflow.com/questions/33642997/listen-for-ctf-otf-changes-with-traits-in-mayavi-volume-rendering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!