1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<META NAME="GENERATOR" CONTENT="Adobe FrameMaker 5.5/HTML Export Filter">
<LINK REL="STYLESHEET" HREF="VisualRef.css" CHARSET="ISO-8859-1" TYPE="text/css">
<TITLE> Description of Objects in VPython</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="frame.html"><img src="icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="index.html"><img src="icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="defaults.html"><img src="icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Visual Reference</td>
<td><A HREF="index.html"><img src="icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="icons/blank.gif" border="0" height="32"
alt="" width="32"></td>
<td><img src="icons/blank.gif" border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="faces.html">The faces
Object</A> <b class="navlabel">Up:</b> <a class="sectref" HREF="index.html">Contents</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="defaults.html">Convenient
Defaults</A> <br>
<hr>
</DIV>
<DIV>
<H1 CLASS="Heading-1"> <font color="#0000A0">Additional Attributes</font></H1>
</DIV>
<DIV>
<P CLASS="Normal"> The following attributes apply to all VPython objects:</P>
<P CLASS="attributes"> <span class="attribute">visible</span> If false (0),
object is not displayed; e.g. <span class="attribute">ball.visible = 0</span><EM CLASS="program"><BR>
</EM> Use <span class="attribute">ball.visible = 1</span> to make the ball
visible again.</P>
<P CLASS="attributes"><span class="attribute">frame</span> Place this object
into a specified frame, as in <span class="attribute">ball = sphere(frame
= f1)</span> </P>
<P CLASS="attributes"> <span class="attribute">display</span> When you start
a VPython program, for convenience Visual creates a display window and names
it <span class="attribute">scene</span>. By default, objects you create go
into that display window. You can choose to put an object in a different display
like this: </P>
</DIV>
<blockquote>
<blockquote>
<DIV><span class="program (unavailable)"><b> scene2
= display( title = "Act IV, Scene 2" ) </b></span></DIV>
<DIV><b><span class="program (unavailable)"> rod
= cylinder( display = scene2 )</span></b> </DIV>
<blockquote>
<DIV class="attributes">The function <font color="#FF0000">display.get_selected()</font>
returns a reference to the display in which objects are currently being
created.</DIV>
</blockquote>
</blockquote>
</blockquote>
<DIV>
<P CLASS="attributes"><span class="attribute">__class__</span> Name of the class
of object. For example, <span class="attribute">ball.__class__ is sphere</span>
is true if <span class="attribute">ball</span> is a sphere object. There are
two underscores before and after the word <span class="attribute">class</span>.
In a list of visible objects provided by <a href="display.html">scene.objects</a>,
if <span class="attribute">obj</span> is in this list you can determine the
class of the object with <span class="attribute">obj.__class__</span>. </P>
<P CLASS="attributes"><span class="attribute">__copy()__</span> Makes a copy
of an object. There are two underscores before and after the <span class="attribute">copy()</span>.
Without any arguments, this results in creating a second object in the exact
same position as the first, which is probably not what you want. The <font color="#FF0000">__copy__()</font>
function takes a list of keyword=value argument pairs which are applied to
the new object before making it visible. For example, to clone an object from
one display to another, you would execute: <font color="#FF0000">new_object
= old_object.__copy__( display=new_display)</font>. Restriction: If the original
object is within a frame, and the new object is on a different display, you
must supply both a new display and a new frame for the new object (the new
frame may be None). This is due to the restriction that an object may not
be located within a frame that is in a separate display. The attribute <font color="#FF0000">__members__</font>
used to give a list of all the object's attributes but is no longer available
in VPython. Its main use was in copying objects.</P>
<blockquote>
<p>Here is an example that uses the __copy()__ function. The following routine
copies all of the Visual objects currently existing in one display into
a previously defined second display:</p>
</blockquote>
</DIV>
<blockquote>
<DIV>
<p><b><span class="program (unavailable)">def clone_universe( new_display,
old_display):<br>
# Create a dictionary of
frames in the old display<br>
# to the corresponding frames
in the new display.<br>
frames = dict()<br>
# Initialize the lookup
dictionary<br>
for obj in old_display.objects:<br>
if
obj.__class__ == frame:<br>
frames[obj]
= obj.__copy__( frame=None, display=new_display)<br>
# For each old reference
frame that was within another reference frame,<br>
# place the new reference
frame within the appropriate frame in the new<br>
# display. Here old is an
object and new is its frame in the new display.<br>
for old, new in frames.iteritems():<br>
if
old.frame:<br>
new.frame
= frames[old.frame]<br>
# Copy over the universe.<br>
for obj in old_display.objects:<br>
if
obj.__class__ == frame:<br>
#
Already taken care of above.<br>
continue<br>
if
obj.frame:<br>
#
Then initialize with the corresponding reference frame in the new<br>
#
display.<br>
obj.__copy__(
display=new_display, frame=frames[obj.frame])<br>
else:<br>
#
Don't need to care about the frame attribute, since it is None.<br>
obj.__copy__(
display=new_display)</span></b></p>
</DIV>
</blockquote>
<DIV>
<P CLASS="Normal">See <a href="display.html">Controlling One or More Visual
Display Windows</a> for more information on creating and manipulating display
objects.</P>
<P CLASS="Normal"> </P>
</DIV>
<DIV> </DIV>
<hr>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="frame.html"><img src="icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="index.html"><img src="icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="defaults.html"><img src="icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Visual Reference</td>
<td><A HREF="index.html"><img src="icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="icons/blank.gif" border="0" height="32"
alt="" width="32"></td>
<td><img src="icons/blank.gif" border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="faces.html">The faces
Object</A> <b class="navlabel">Up:</b> <a class="sectref" HREF="index.html">Contents</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="defaults.html">Convenient
Defaults</A> <br>
<hr>
</DIV>
</BODY>
</HTML>
|