visualization - bar magnet

19 views
Skip to first unread message

Simonious Rex

unread,
Nov 20, 2017, 1:59:29 PM11/20/17
to wxPython-users
I've got this great example (included below) and I want to implement this sort of visualization as a function.
I'd love to be able to step forward and backward, as well as free run, but I don't need to start with that functionality.

I would like the visual elements to be shaped like bar magnet arrows and I'd like to be able to control their (x,y,z)position, color, orientation and (x,y,z)size.

My intention is to maintain an array of data, perform some calculations between the elements and generate a second array, this array will then call the above function to create a visualization, then the second set of data will become the first set of data and the process will repeat.

For a first example I'm hoping to program a 3D version of life, from there I will be adding some additional behaviors which will include the color and orientation.

Example code follows:

#Prabhu Ramachandran


import numpy as np

from mayavi import mlab

import time


def step(x, y, z):

  data = np.random.random(x.shape)

  cond = data > 0.75


return x[cond], y[cond], z[cond], data[cond]


#x, y, z = np.mgrid[0:10:50j, 0:10:50j, 0:4:20j]

x, y, z = np.mgrid[0:3:20j, 0:3:20j, 0:3:20j]


xn, yn, zn, sn = step(x, y, z)


# Will give you spheres, use mode='cube' for cubes.

pts = mlab.points3d(xn, yn, zn, sn, scale_mode='none', scale_factor=0.1)

#pts = mlab.points3d(xn, yn, zn, sn, mode='cube', scale_mode='none', scale_factor=0.1)



@mlab.animate

def anim():

  while True:

    xn, yn, zn, sn = step(x, y, z)

    pts.mlab_source.reset(x=xn, y=yn, z=zn, scalars=sn)


    # Do this if the scene does not update: needed for slightly older versions of Mayavi.

    pts.mlab_source.update()


    time.sleep(0.01)  # Slow things down a bit.

    yield


anim()


Chris Barker

unread,
Nov 20, 2017, 5:29:44 PM11/20/17
to wxpython-users
I think you're going to want mayavi for this :-)

wx itself provides nothing for 3D -- so you would have a lot of code to write :-)

you can embed an OpenGL Window in wx, but then you have to write all the OpenGL code...

BTW, if you can stick with 2D, then wx.lib.floatcanvas would help a lot.



-CHB


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov

Simon Goble

unread,
Nov 20, 2017, 5:33:55 PM11/20/17
to wxpytho...@googlegroups.com
I took a wrong turn, I thought this was where I ask Mayavi questions!

Thanks.

ima...@sina.com

unread,
Nov 20, 2017, 9:11:30 PM11/20/17
to chris....@noaa.gov, wxpytho...@googlegroups.com

mayavi doesnot support wxphonix, so I wrote a simple one named myvi, I think it will be help to you.

https://github.com/yxdragon/myvi

on windows is ok, but on mack and linux cannot build gl3.3 context. I think it is wx's bug, (my vi can run ok with qt on mac and linux) anyone can help?



--------------------------------

来自我的新浪邮箱android客户端




-------- 原始邮件 --------

发件人:Chris Barker
时    间:2017年11月21日 06:29(星期二)
收件人:wxpython-users
主题:Re: [wxPython-users] visualization - bar magnet
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages