From: Gavrie P. <ga...@ne...> - 2000-11-16 12:48:41
Attachments:
zoom_limit.patch
|
Hi, I needed a feature in VPython that would let me limit the amount that the user can zoom in with the mouse. After not finding a way of doing this, I have written a small patch to enable it. The patch adds a new attribute to "display" objects. The attribute is named "zoom_limit", and is a float value. In Python, you can now say: visual.scene.zoom_limit = 10.0, for example. The patch is attached. If others find it useful, maybe it can be added to the CVS? Gavrie. -- Gavrie Philipson Netmor Applied Modeling Research Ltd. |
From: Bruce S. <ba...@an...> - 2000-11-17 03:24:28
|
--On Thursday, November 16, 2000, 2:48 PM +0200 Gavrie Philipson <ga...@ne...> wrote: > The patch adds a new attribute to "display" objects. The attribute is > named "zoom_limit", and is a float value. > In Python, you can now say: visual.scene.zoom_limit = 10.0, for example. Could you please write a sentence or two of documentation? What does a limit of 10.0 mean? Thanks. Bruce Sherwood |
From: Gavrie P. <ga...@ne...> - 2000-11-19 09:17:18
|
Bruce Sherwood wrote: > > --On Thursday, November 16, 2000, 2:48 PM +0200 Gavrie Philipson > <ga...@ne...> wrote: > > > The patch adds a new attribute to "display" objects. The attribute is > > named "zoom_limit", and is a float value. > > In Python, you can now say: visual.scene.zoom_limit = 10.0, for example. > > Could you please write a sentence or two of documentation? What does a > limit of 10.0 mean? Thanks. Hi Bruce, The only documentation needed is the line you quoted above -- the change is pretty small. But, some more explanation: There is a parameter in the gldevice.cpp file named 'manual_scale'. There is no documentation for this parameter that I could find -- maybe the authors of VPython would like to put in a word. All my patch does is set a maximum limit for this parameter. A limit if 10.0 means that the maximum value this manul_scale parameter can attain is 10.0. I can't explain the exact physical meaning of this parameter. Cheers, Gavrie. -- Gavrie Philipson Netmor Applied Modeling Research Ltd. |
From: David S. <dsc...@cm...> - 2000-11-19 20:53:00
|
> > Could you please write a sentence or two of documentation? What does a > > limit of 10.0 mean? Thanks. > There is a parameter in the gldevice.cpp file named 'manual_scale'. > There is no documentation for this parameter that I could find -- maybe > the authors of VPython would like to put in a word. All my patch does is > set a maximum limit for this parameter. manual_scale isn't documented because it isn't exposed externally. A manual_scale of 10.0 means that scene.range is effectively *divided* by 10. This is intuitively the same as zooming in by a factor of 10 from the default provided by autoscale or by scene.range. I think both minimum and maximum zoom limits are a good idea, but I'm not sure if this is the right interface or not. An example alternative would be minimum and maximum ranges. What does everyone think? Dave |
From: Bruce S. <ba...@an...> - 2000-11-20 04:06:23
|
--On Sunday, November 19, 2000, 3:55 PM -0500 David Scherer <dsc...@CM...> wrote: > I think both minimum and maximum zoom limits are a good idea, but I'm not > sure if this is the right interface or not. An example alternative would > be minimum and maximum ranges. What does everyone think? I agree that control of manual_scale doesn't sound like a good idea. Since the standard Visual interface includes rotation around the center of the scene, would it make sense just to give minimum and maximum distances for the camera from the center? I'm not sure I understand what the significance would be of minimum and maximum ranges, which sound like cubes or boxes to me. Bruce |
From: David S. <dsc...@cm...> - 2000-11-20 13:50:27
|
> I agree that control of manual_scale doesn't sound like a good idea. Since > the standard Visual interface includes rotation around the center of the > scene, would it make sense just to give minimum and maximum distances for > the camera from the center? Definitely not! To make any sense of the camera position you need to know horrible things like the field of view angle and the aspect ratio of the window, not to mention some trig. Normally you control scale with scene.range, right? sphere(radius = 50) scene.range = 50 > I'm not sure I understand what the > significance > would be of minimum and maximum ranges, which sound like cubes or boxes to > me. These would place limits on how small or large the *effective* scene.range could get in response to manual control. Dave |
From: Bruce S. <ba...@an...> - 2000-11-20 18:42:02
|
Right. Got it. Makes sense. --On Monday, November 20, 2000, 8:52 AM -0500 David Scherer <dsc...@CM...> wrote: > Definitely not! To make any sense of the camera position you need to know > horrible things like the field of view angle and the aspect ratio of the > window, not to mention some trig. Normally you control scale with > scene.range, right? > > sphere(radius = 50) > scene.range = 50 > >> I'm not sure I understand what the >> significance >> would be of minimum and maximum ranges, which sound like cubes or boxes >> to me. > > These would place limits on how small or large the *effective* scene.range > could get in response to manual control. |
From: Mike M. <mmu...@dg...> - 2000-11-27 10:29:03
|
Hi, enclosed is a class WireBox which implements as box which edges. That is I tried to have an object that behaves just like box() but instead of colored side plains it only has a wire frame of the edges. The code works pretty much as I expected it to (just copy into an empty file and run it to see what I mean). The only problem is speed and memory consumption which is several orders of magnitude higher than for box(). Since I need several hundred or more boxes speed is kind of a problem. Is there as possibility to include an edged box whether: - by adding edgeColor and edgeRadius to the box object (default edgeColor = box().color --> no edge) and color = none to make the filled box() invisible or - by the means of an new object that inherits from box() but has the additional features (edgeColor, edgeRadius, color = none). Also making my implementation faster would be an option. Any ideas or hints are be appreciated. Thanks. Mike import time from visual import * class WireBox: """Wire frame box. Edges are implemented as curves. """ def __init__(self, pos=(0,0,0), length=1, height=1, width=1, color=color.white, radius = 0.005, visible = 1): # use of __dict__ because of __setattr__ # self.__dict__['frame'] = frame() instead of self.frame = frame() # --> avoid recursive refrences to __setattr__ self.__dict__['frame'] = frame() self.__dict__['pos'] = pos self.__dict__['length'] = length self.__dict__['height'] = height self.__dict__['width'] = width self.__dict__['color'] = color self.__dict__['radius'] = radius self.__dict__['visible'] = visible self.__dict__['x1'] = self.pos[0] - self.length/2.0 self.__dict__['x2'] = self.pos[0] + self.length/2.0 self.__dict__['y1'] = self.pos[1] - self.height/2.0 self.__dict__['y2'] = self.pos[1] + self.height/2.0 self.__dict__['z1'] = self.pos[2] - self.width/2.0 self.__dict__['z2'] = self.pos[2] + self.width/2.0 #lower plane self.__dict__['lplane'] = curve(frame = self.frame, pos=[(self.x1, self.y1, self.z1), (self.x2, self.y1, self.z1), (self.x2, self.y1, self.z2), (self.x1, self.y1, self.z2), (self.x1, self.y1, self.z1)], color = self.color, visible = self.visible, radius = self.radius) #upper plane self.__dict__['uplane'] = curve(frame = self.frame, pos=[(self.x1, self.y2, self.z1), (self.x2, self.y2, self.z1), (self.x2, self.y2, self.z2), (self.x1, self.y2, self.z2), (self.x1, self.y2, self.z1)], color = self.color, visible = self.visible, radius = self.radius) #vertical connector 1 self.__dict__['v1'] = curve(frame = self.frame, pos=[(self.x1, self.y1, self.z1), (self.x1, self.y2, self.z1)], color = self.color, visible = self.visible, radius = self.radius) #vertical connector 2 self.__dict__['v2'] = curve(frame = self.frame, pos=[(self.x2, self.y1, self.z1), (self.x2, self.y2, self.z1)], color = self.color, visible = self.visible, radius = self.radius) #vertical connector 3 self.__dict__['v3'] = curve(frame = self.frame, pos=[(self.x2, self.y1, self.z2), (self.x2, self.y2, self.z2)], color = self.color, visible = self.visible, radius = self.radius) #vertical connector 4 self.__dict__['v4'] = curve(frame = self.frame, pos=[(self.x1, self.y1, self.z2), (self.x1, self.y2, self.z2)], color = self.color, visible = self.visible, radius = self.radius) def __setattr__(self, attrname, value): if attrname == 'visible': self.lplane.visible = self.uplane.visible = value self.v1.visible = self.v2.visible = value self.v3.visible = self.v4.visible = value elif attrname == 'radius': self.lplane.radius = self.uplane.radius = value self.v1.radius = self.v2.radius = value self.v3.radius = self.v4.radius = value elif attrname == 'color': self.lplane.color = self.uplane.color = value self.v1.color = self.v2.color = value self.v3.color = self.v4.color = value else: raise AttributeError, attrname if __name__ == "__main__": """ Testing some different radii, colors, and visibilities for filled and empty wire frame box. """ myBox = box() myWire = WireBox(color = color.red) myWire.radius = 0.05 time.sleep(1) myBox.visible = 0 time.sleep(1) myWire.visible = 0 time.sleep(1) myBox.visible = 0 myWire.visible = 1 myWire.radius = 0.01 myWire.color = color.green time.sleep(1) myBox.visible = 1 myWire.visible = 0 time.sleep(1) myBox.visible = 1 myWire.visible = 1 |
From: David S. <dsc...@cm...> - 2000-11-27 13:53:34
|
> Also making my implementation faster would be an option. > Any ideas or hints are be appreciated. > Thanks. (1) If thick curves aren't essential to your application, using radius = 0 (thin curves) will probably make your program much faster. (2) Try using a smaller number of curves. You can merge your two planes and one of the vertical connectors, or you can let a few segments overlap and use a single curve for the entire box. Dave |