From: Flavio C. <fcc...@gm...> - 2005-01-20 23:13:40
|
Hello, Is there a way to destroy objects (not just make them invisible)? removing them from a scene? another question is there a way to let a part of an object get out of sight? for example, suppose I have a curve object that keeps growing in a given direction. How do i allow for the older parts of the curve to move out of the frame to avoid auto rescaling? --=20 Fl=E1vio Code=E7o Coelho --------------------------- Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence. Albert Einstein |
From: Jonathan B. <jbr...@ea...> - 2005-01-21 00:25:19
|
On Thu, 2005-01-20 at 21:13 -0200, Flavio Coelho wrote: > Hello, > > Is there a way to destroy objects (not just make them invisible)? > removing them from a scene? I'm not entirely sure what you are asking, but I'll give this one a shot(gun;) anyway. Python's memory management is a reference-counted system. When the reference count on an object drops to zero, it is immediately deleted/destroyed/freed. Internally, every visible primitive object's owning display owns one reference to the primitive. Making the object invisible is implemented by removing the object from its parent display, and removes the display's reference. This leaves only the references that might exist in your program. In general, every means of accessing the object counts as a reference. In the simplest case, you only have a single local or global name that refers to the object, and you just use the 'del' keyword to get rid of it, like this: x = sphere() x.visible = False del x # This step will raise an exception, since x does not exist: x.pos = vector(1,0,0) Or just assign a different object that name: x = sphere() x.q = 1.6e-19 x.visible = False x = sphere() print x.q # Error!, x.q does not exist, since this is a new object. > another question is there a way to let a part of an object get out of > sight? for example, suppose I have a curve object that keeps growing > in a given direction. How do i allow for the older parts of the curve > to move out of the frame to avoid auto rescaling? For the curve object, you can write your own special append() function that performs a shift+replace rather than a true append, like this: def append_nogrow( curve_object, new_pos): curve_object.pos[:-1] = curve_object.pos[1:] curve_object.pos[-1] = new_pos HTH, -Jonathan Brandmeyer |
From: Flavio C. <fcc...@gm...> - 2005-01-22 22:50:40
|
Hi Johnathan, While waiting for your response, I managed to fix most of the problems I had, including the keystrike catcher. I posted the updated version of my stripchart module here: http://www.procc.fiocruz.br:8080/procc/Members/flavio/codepy/stripch.py/fil= e_view Unfortunately, there is a pretty significant memory leak in my drawTickLabels function That I couldn't fix. Could it be originated from the label object? Have you had any issues concerning creating and destroying many labels continuously? because of this leak the call to this function in the plot function is commented. I would appreciate any ideas/ suggestions on this... On Fri, 21 Jan 2005 15:00:35 -0200, Flavio Coelho <fcc...@gm...> wrot= e: > Hi Johnathan, >=20 > Thanks for your reply, it was very useful. >=20 > I wrote a quick stripchart module for vpython (attached) that would be > glad to contribute to vpython if you think it may be of use. It still > need some polishing such as y-axis autoscaling plus adding more > features. >=20 --=20 Fl=E1vio Code=E7o Coelho --------------------------- Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence. Albert Einstein |
From: Jonathan B. <jbr...@ea...> - 2005-01-23 02:20:28
|
On Sat, 2005-01-22 at 20:50 -0200, Flavio Coelho wrote: > Hi Johnathan, > > While waiting for your response, I managed to fix most of the problems > I had, including the keystrike catcher. > > I posted the updated version of my stripchart module here: > > http://www.procc.fiocruz.br:8080/procc/Members/flavio/codepy/stripch.py/file_view > > Unfortunately, there is a pretty significant memory leak in my > drawTickLabels function That I couldn't fix. Could it be originated > from the label object? Have you had any issues concerning creating and > destroying many labels continuously? > > because of this leak the call to this function in the plot function is > commented. > > I would appreciate any ideas/ suggestions on this... Creating new renderable objects is one of the slowest things you can do in VPython, so I would suggest that after the initial creation of the labels, you should keep track of which ones represent what, and just update their content every update rather than destroy and recreate them. I am looking into the memory leak. -Jonathan |
From: Jonathan B. <jbr...@ea...> - 2005-01-23 03:38:06
|
On Sat, 2005-01-22 at 21:19 -0500, Jonathan Brandmeyer wrote: > On Sat, 2005-01-22 at 20:50 -0200, Flavio Coelho wrote: > > Unfortunately, there is a pretty significant memory leak in my > > drawTickLabels function That I couldn't fix. Could it be originated > > from the label object? > I am looking into the memory leak. > Found. It was an internal bug in Visual's label and font deletion code. The fix will be in the next release. Actually, I'm a little surprised that this hasn't affected anyone else before this. As far as I can tell, it has been in there since VPython's original release! Thank you for your useful reports and feedback. -Jonathan |
From: Flavio C. <fcc...@gm...> - 2005-01-23 17:37:43
|
Hi Johnatan, I followed your suggestion and no longer recreate the ticklabels, just update their "text" property. It is much faster now! Thanks! The memory leak is still there but much smaller now. I look forward to test my code again with the next release. As usual, I posted the latest version of the stripchart module along with a screenshot here: http://www.procc.fiocruz.br:8080/procc/Members/flavio/codepy/strip/file_vie= w If anyone on the list is interested in testing, please help yourselves, and notify me of any bugs. feature requests are also welcome. > Found. It was an internal bug in Visual's label and font deletion code. > The fix will be in the next release. >=20 > Actually, I'm a little surprised that this hasn't affected anyone else > before this. As far as I can tell, it has been in there since VPython's > original release! >=20 > Thank you for your useful reports and feedback. I am glad I could help! cheers, --=20 Fl=E1vio Code=E7o Coelho --------------------------- Great spirits have always found violent opposition from mediocrities. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence. Albert Einstein |