|
From: Bruce S. <ba...@an...> - 2000-12-27 17:08:12
|
--On Wednesday, December 27, 2000 8:26 AM -0800 Matthew Grimm
<mat...@ya...> wrote:
> Store the data (pos, axis, color, etc) for
> each individual component of a complex item
> in a database
Clearly a database issue, nothing particularly to do with Visual.
> Pull the data from the database and feed it
> into Visual
If as you say Visual is running on a different computer, you have the
problem of using a socket or some such mechanism for moving the data, and
your Visual program has to be checking that new data has arrived. It is my
understanding that Python has modules for doing this kind of
intercommunication, though I've never done anything of this kind myself.
Again, there isn't anything here particularly germane to Visual.
> Automate the process of refreshing the scene
> when changes are made to the data
There are three different issues: modify an existing object (change axis or
color, for example), create a new object, or delete an old object. Only
deletion involves "nuances of Visual's behavior". There is no direct delete
of a Visual object. Deletion is a two-step process:
1) Make the object invisible.
2) Assign the name of the object to something else, so that there is no
longer a valid reference to the object. Example:
ball = sphere()
.....
ball.visible = 0 # make invisible
ball = None # no Python name is associated with the sphere any more
Python automatically does "garbage collection" -- that is, Python
periodically checks to see whether any objects are no longer referenced,
and removes them from memory, freeing up this memory for other uses. When
you set ball = None, the number of names referencing the original sphere
drops to zero, and the memory set aside for keeping track of the sphere
becomes available to be reclaimed.
If however you set ball = None before making the sphere invisible, Visual
itself still refers to the sphere (since Visual has to keep displaying it,
and allowing the user to navigate around it), and Python can't delete the
sphere. Nor can you delete the sphere, because you no longer have a name of
the sphere to be able to say ball.visible = 0 (this statement would give an
error, since "None" doesn't have a visible attribute).
Bruce Sherwood
|