From: Kadir H. <kha...@ya...> - 2010-07-18 08:08:10
|
I am not sure if I have misunderstood your requirement with oversimplification, or if this helps: LABEL object itself should provide what you want. If you place the label at pos = scene.center, then mouse operations (zoom, rotate, etc.) will not affect the label position. It will stay at the center of the screen. You may not wish to have the label at the center, as you may prefer to have your prime object at the center. Then, you can use xoffset, yoffset parameters to shift the label on the screen which are in pixel coordinates, not in space coordinates. So, pos = scene.center and the use of xoffset and yoffset serves as positioning the label on the screen with absolute pixel coordinates. For example, you can try the following simple code: # ============== from visual import * scene.center = (1,2,3) plane = pyramid(pos=(1,1,1), size=(2,1,3)) tlabel = label(pos=scene.center, xoffset=0, yoffset=-100, line=0, text="TIME") slabel = label(pos=scene.center, xoffset=100, yoffset=-100, line=0, text="SPEED") glabel = label(pos=scene.center, xoffset=-100, yoffset=-100, line=0, text="GFORCE") t = 0 while 1: plane.pos -= (plane.pos.x, plane.pos.y, t) t += 0.001 plane.rotate(axis=(0,0,1), angle=pi/64) rate(25) Was this what you needed? Kadir ________________________________ From: Robert French <rf...@rf...> To: C Anthony Risinger <an...@ex...> Cc: "vis...@li..." <vis...@li...> Sent: Sun, July 18, 2010 2:09:21 AM Subject: Re: [Visualpython-users] Keeping labels in one place Yes, C Anthony is correct. I want it to stay at an absolute pixel coordinate (2-D) in the window. Completely unaffected by any rotations or zooms. The existing objects all move with the frame. I had thought about the constantly-reposition option but was hoping there was something easier. This seems like it would be a common desire. For example, to put a title or timestamp or something in the display window. I'll try those suggestions and see if I can get it to work BTW, my application is orbit visualization of spacecraft. I just want the date and time to stay in one place. Thanks. On Jul 17, 2010, at 11:20 AM, C Anthony Risinger <an...@ex...> wrote: > > > On Sat, Jul 17, 2010 at 1:07 PM, Bruce Sherwood <bas...@nc...> wrote: >> The current version of VPython (5.32) offers a text object as well as a >> label object. The label object always faces the viewer, independent of >> rotation, whereas the (new) text object is extruded text that behaves like >> all other objects. Seems like one of these two should do what you want. The >> text object can have zero thickness. >> I'm not sure what you mean by a "time" display, but presumably you know >> about the graphing option. >> Bruce Sherwood > > i think what the OP is looking for is HUD functionality, ie. the > "time" display stays locked to the viewport, regardless of zoom or > rotation. > > AFIAK this is not currently supported in vpython. however, the same > effect can be achieved by using a "HUD frame" and constantly > recomputing it's position/zoom/rotation as the main frame moves. the > other option is to put your app into a "container" frame, and ensure > the main frame never moves... anything added to the main frame is a > part of the HUD; i think the issue with this was mouse grabs are sent > to the main frame (IIRC). sorry, i don't have any code examples on > hand :-( > > C Anthony > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first-- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > > > -- > Limited filtering has been provided due to external email forwarding. > For details please review: http://www.onlymyemail.com/faqs/forwarding.html > ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Visualpython-users mailing list Vis...@li... https://lists.sourceforge.net/lists/listinfo/visualpython-users |
From: Roberto S. <rsa...@bo...> - 2010-07-18 14:31:56
|
You could also update the text in the titlebar with scene.title. Rob |
From: Robert F. <rf...@rf...> - 2010-07-19 17:44:19
|
Brilliant! I should've figured that one out myself. Thanks, it will handle my needs for now. Also thanks to Symion for a different approach, which I have also learned a lot from. Rob On Sun, 18 Jul 2010 01:08:02 -0700 (PDT), Kadir Haldenbilen <kha...@ya...> wrote: > I am not sure if I have misunderstood your requirement with > oversimplification, > or if this helps: > > LABEL object itself should provide what you want. > > If you place the label at pos = scene.center, then mouse operations > (zoom, > rotate, etc.) will not affect the label position. It will stay at the > center of > the screen. > > You may not wish to have the label at the center, as you may prefer to > have > your prime object at the center. Then, you can use xoffset, yoffset > parameters > to shift the label on the screen which are in pixel coordinates, not in > space > coordinates. > > So, pos = scene.center and the use of xoffset and yoffset serves as > positioning > the label on the screen with absolute pixel coordinates. > > For example, you can try the following simple code: > > # ============== > from visual import * > > scene.center = (1,2,3) > > plane = pyramid(pos=(1,1,1), size=(2,1,3)) > > tlabel = label(pos=scene.center, xoffset=0, yoffset=-100, line=0, > text="TIME") > slabel = label(pos=scene.center, xoffset=100, yoffset=-100, line=0, > text="SPEED") > glabel = label(pos=scene.center, xoffset=-100, yoffset=-100, line=0, > text="GFORCE") > > t = 0 > while 1: > > plane.pos -= (plane.pos.x, plane.pos.y, t) > t += 0.001 > plane.rotate(axis=(0,0,1), angle=pi/64) > rate(25) > > > > Was this what you needed? > > Kadir > > > ________________________________ > From: Robert French <rf...@rf...> > To: C Anthony Risinger <an...@ex...> > Cc: "vis...@li..." > <vis...@li...> > Sent: Sun, July 18, 2010 2:09:21 AM > Subject: Re: [Visualpython-users] Keeping labels in one place > > Yes, C Anthony is correct. I want it to stay at an absolute pixel > coordinate > (2-D) in the window. Completely unaffected by any rotations or zooms. > The > existing objects all move with the frame. > > > I had thought about the constantly-reposition option but was hoping there > was > something easier. This seems like it would be a common desire. For > example, to > put a title or timestamp or something in the display window. > > I'll try those suggestions and see if I can get it to work > > BTW, my application is orbit visualization of spacecraft. I just want the > date > and time to stay in one place. > > Thanks. > > On Jul 17, 2010, at 11:20 AM, C Anthony Risinger <an...@ex...> wrote: > >> >> >> On Sat, Jul 17, 2010 at 1:07 PM, Bruce Sherwood <bas...@nc...> >> wrote: >>> The current version of VPython (5.32) offers a text object as well as a >>> label object. The label object always faces the viewer, independent of >>> rotation, whereas the (new) text object is extruded text that behaves >>> like >>> all other objects. Seems like one of these two should do what you >>> want. The >>> text object can have zero thickness. >>> I'm not sure what you mean by a "time" display, but presumably you know >>> about the graphing option. >>> Bruce Sherwood >> >> i think what the OP is looking for is HUD functionality, ie. the >> "time" display stays locked to the viewport, regardless of zoom or >> rotation. >> >> AFIAK this is not currently supported in vpython. however, the same >> effect can be achieved by using a "HUD frame" and constantly >> recomputing it's position/zoom/rotation as the main frame moves. the >> other option is to put your app into a "container" frame, and ensure >> the main frame never moves... anything added to the main frame is a >> part of the HUD; i think the issue with this was mouse grabs are sent >> to the main frame (IIRC). sorry, i don't have any code examples on >> hand :-( >> >> C Anthony >> >> > ------------------------------------------------------------------------------ >> This SF.net email is sponsored by Sprint >> What will you do first with EVO, the first 4G phone? >> Visit sprint.com/first-- http://p.sf.net/sfu/sprint-com-first >> _______________________________________________ >> Visualpython-users mailing list >> Vis...@li... >> https://lists.sourceforge.net/lists/listinfo/visualpython-users >> >> >> -- >> Limited filtering has been provided due to external email forwarding. >> For details please review: >> http://www.onlymyemail.com/faqs/forwarding.html >> > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > > > > > > > -- > Limited filtering has been provided due to external email forwarding. > For details please review: http://www.onlymyemail.com/faqs/forwarding.html |