From: CL <clc...@gm...> - 2009-01-15 01:26:28
|
If you are looking for integration with separated windows (not embedding vpython into a child window in wxpython, you can see if this can help: http://code.google.com/p/clrobotsim/ Basically you can just create a separated thread for the vpython object, use standard communication methods between wxpython and vpython. Dead lock may happen in the wxpython GUI thread if you do not handle it properly. You can check the code at the "robot executor" of the above simulator. > From: "Emanuele Gissi" <ema...@gm...> > Subject: [Visualpython-users] vpython and wxpython integration > To: vis...@li... > Message-ID: > <e00...@ma...> > Content-Type: text/plain; charset="iso-8859-1" > > I am developing a small multiplatform application for data visualisation. > Could someone point me to a simple example on how to integrate a wxpython > GUI with vpython 3d visualisation? > Thank you. > Emanuele Gissi |
From: CL <clc...@gm...> - 2009-01-15 05:54:48
|
It seems there are quite a number of developers looking for simple examples showing an integration of wxpython and vpython, I have just written two examples and put it here: http://code.google.com/p/vpythonex1/ (as my robot simulator is quite complicated). In these examples, I try to use the docking technique described in http://mientki.ruhosting.nl/data_www/pylab_works/pw_vpython_docking.html I use MoveWindow instead of SetWindowPos, in order to make it work on the new version of vPython. I have not tested them on previous verion of vPython. This examples only work on Windows platform because the docking technique is depending on win32 api. You can change it to non-docking version easily by removing some code in vWorld object. Example 1 is just the bounce2 sample program implemented in a wxdialog box. Example 2 is four bounce2 windows in a wxdialog box. Hope this can help you. |
From: Stef M. <s.m...@ru...> - 2009-01-15 20:24:06
|
CL wrote: > It seems there are quite a number of developers looking for simple > examples showing an integration of wxpython and vpython, I have just > written two examples and put it here: > http://code.google.com/p/vpythonex1/ (as my robot simulator is quite > complicated). > > In these examples, I try to use the docking technique described in > http://mientki.ruhosting.nl/data_www/pylab_works/pw_vpython_docking.html > > I use MoveWindow instead of SetWindowPos, in order to make it work on > the new version of vPython. I have not tested them on previous verion > of vPython. > > I just tried MoveWindow instead of SetWindowPos, but it crashes just as hard with VPython-5. Here is the essential part of the code: # get the handle of the dock container PP = self.p1.GetHandle () # Set Position and Size of the VPython window, # Before Docking it !! flags = win32con.SWP_SHOWWINDOW or \ win32con.SWP_FRAMECHANGED win32gui.SetWindowPos ( self.VP, win32con.HWND_TOPMOST, -4, -22, w+8, h+26, flags ) #win32gui.MoveWindow ( self.VP, -4, -22, w+8, h+26, True ) <===JUST AS BAD # Dock the VPython window win32gui.SetParent ( self.VP, PP ) Am I doing something wrong, or are you not testing hard enough ? cheers, Stef > This examples only work on Windows platform because the docking > technique is depending on win32 api. You can change it to non-docking > version easily by removing some code in vWorld object. > > Example 1 is just the bounce2 sample program implemented in a wxdialog box. > Example 2 is four bounce2 windows in a wxdialog box. > > Hope this can help you. > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > > > |
From: CL <clc...@gm...> - 2009-01-16 00:54:40
|
Hi Shef Since I only have one PC, I am not sure if my sample programs working well or not on other hardware. Are you able to run my sample programs on your side (or it also crashes) ? Anyone else can report the result if you have tried it ? About the crashes, can you show a bit more about the python code to do SetWindowPos / MoveWindow ? Technically speaking, I can see no reason why using these API will cause a crash in general. I tried SetWindowPos but it looks like it has no effect after the scene window is created, so I change it to MoveWindow. It works very well on my PC. best regards, CL > I just tried MoveWindow instead of SetWindowPos, but it crashes just as > hard with VPython-5. > Here is the essential part of the code: > > # get the handle of the dock container > PP = self.p1.GetHandle () > > # Set Position and Size of the VPython window, > # Before Docking it !! > flags = win32con.SWP_SHOWWINDOW or \ > win32con.SWP_FRAMECHANGED > win32gui.SetWindowPos ( self.VP, win32con.HWND_TOPMOST, > -4, -22, w+8, h+26, flags ) > #win32gui.MoveWindow ( self.VP, -4, -22, w+8, h+26, True ) > <===JUST AS BAD > > # Dock the VPython window > win32gui.SetParent ( self.VP, PP ) > > Am I doing something wrong, > or are you not testing hard enough ? > > cheers, > Stef > > > This examples only work on Windows platform because the docking > > technique is depending on win32 api. You can change it to non-docking > > version easily by removing some code in vWorld object. > > > > Example 1 is just the bounce2 sample program implemented in a wxdialog box. > > Example 2 is four bounce2 windows in a wxdialog box. > > > > Hope this can help you. > > > > ------------------------------------------------------------------------------ > > This SF.net email is sponsored by: > > SourcForge Community > > SourceForge wants to tell your story. > > http://p.sf.net/sfu/sf-spreadtheword > > _______________________________________________ > > Visualpython-users mailing list > > Vis...@li... > > https://lists.sourceforge.net/lists/listinfo/visualpython-users > > > > > > > > > > ------------------------------ > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > > ------------------------------ > > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > > > End of Visualpython-users Digest, Vol 32, Issue 11 > ************************************************** > |
From: Stef M. <s.m...@ru...> - 2009-01-16 09:18:57
|
hi Che ? CL wrote: > Hi Shef > > Since I only have one PC, I am not sure if my sample programs working > well or not on other hardware. Are you able to run my sample programs > on your side (or it also crashes) ? Anyone else can report the result > if you have tried it ? > aha, so you didn't try hard enough ;-) > About the crashes, can you show a bit more about the python code to do > SetWindowPos / MoveWindow ? Technically speaking, I can see no reason > why using these API will cause a crash in general. > > Looks something like VPython 5 is using absolute mouse coordinates instead of translating them to the position in the parent. > I tried SetWindowPos but it looks like it has no effect after the > scene window is created, so I change it to MoveWindow. It works very > well on my PC. > Now try this: - start the program - move the window more to the top of your screen - click and drag, from a bottom position in the VPython window, downwards in such a way that you virtual (you can't see the cursor) will leave the window, and I expect you get the following error: VPython ***CRITICAL ERROR***: ..\src\core\display_kernel.cpp:535: cvisual::display_kernel::world_to_view_transform: VPython degenerate projection: 1.#INF 1.#INF 0.57735 0.494872 cheers, Stef Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629. The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629. |
From: CL <clc...@gm...> - 2009-01-16 13:52:12
|
Hi Shef Now I understand more about the problem you described. Actually vPython uses client windows coordinates in its mouse management, but it has the assumption that it is the top-level window when restoring the mouse cursor position after dragging. Somehow it will cause a crash in some cases. I've fixed that portion and I am not able to crash it any more. (May be I am not trying hard enough 8-) In windisplay.cpp LRESULT display::on_mouse( WPARAM wParam, LPARAM lParam) ... if (mouse.is_mouse_locked() && ( mouse_x < 20 || mouse_x > view_width - 20 || mouse_y < 20 || mouse_y > view_height - 20 ) ) { mouse.report_setcursor( view_width/2, view_height/2 ); SetCursorPos( view_x + view_width/2, view_y + view_height/2 ); } if (was_locked && !mouse.is_mouse_locked()) { mouse.report_setcursor( old_x, old_y ); SetCursorPos( view_x + old_x, view_y + old_y ); } ... Both SetCursorPos call will move the mouse to an incorrect coordinate. It is because WM_MOVE message is not sending to vPython any more after it is reparented. (also, may be window_x and window_y shall be used instead of view_x, view_y). Changing it to: if (mouse.is_mouse_locked() && ( mouse_x < 20 || mouse_x > view_width - 20 || mouse_y < 20 || mouse_y > view_height - 20 ) ) { mouse.report_setcursor( view_width/2, view_height/2 ); //SetCursorPos( view_x + view_width/2, view_y + view_height/2 ); POINT pt; pt.x = pt.y = 0; ClientToScreen(widget_handle, &pt); SetCursorPos( pt.x + view_width/2, pt.y + view_height/2 ); } if (was_locked && !mouse.is_mouse_locked()) { mouse.report_setcursor( old_x, old_y ); //SetCursorPos( view_x + old_x, view_y + old_y ); POINT pt; pt.x = pt.y = 0; ClientToScreen(widget_handle, &pt); SetCursorPos( pt.x + old_x, pt.y + old_y ); } Now the mouse cursor is correctly positioned after dragging, no matter if it has been reparented or not. Seems no more crashes now. CL > > > Looks something like VPython 5 is using absolute mouse coordinates instead > of translating them to the position in the parent. > > I tried SetWindowPos but it looks like it has no effect after the > > scene window is created, so I change it to MoveWindow. It works very > > well on my PC. > > > Now try this: > - start the program > - move the window more to the top of your screen > - click and drag, from a bottom position in the VPython window, downwards > in such a way that you virtual (you can't see the cursor) will leave the > window, > and I expect you get the following error: > VPython ***CRITICAL ERROR***: ..\src\core\display_kernel.cpp:535: > cvisual::display_kernel::world_to_view_transform: VPython degenerate > projection: 1.#INF 1.#INF 0.57735 0.494872 > > cheers, > Stef > > > > Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629. > The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629. |
From: Stef M. <s.m...@ru...> - 2009-01-16 16:18:12
|
CL wrote: > Hi Shef > > Now I understand more about the problem you described. > > Actually vPython uses client windows coordinates in its mouse > management, but it has the assumption that it is the top-level window > when restoring the mouse cursor position after dragging. Somehow it > will cause a crash in some cases. I've fixed that portion and I am not > able to crash it any more. (May be I am not trying hard enough 8-) > > that's great news !! And I would love to try it, but the code below looks like C to me, and that's beyond my knowledge :-( cheers, Stef > In windisplay.cpp > > LRESULT > display::on_mouse( WPARAM wParam, LPARAM lParam) > ... > if (mouse.is_mouse_locked() && ( mouse_x < 20 || mouse_x > view_width > - 20 || mouse_y < 20 || mouse_y > view_height - 20 ) ) { > mouse.report_setcursor( view_width/2, view_height/2 ); > SetCursorPos( view_x + view_width/2, view_y + view_height/2 ); > } > if (was_locked && !mouse.is_mouse_locked()) { > mouse.report_setcursor( old_x, old_y ); > SetCursorPos( view_x + old_x, view_y + old_y ); > } > ... > > > Both SetCursorPos call will move the mouse to an incorrect coordinate. > It is because WM_MOVE message is not sending to vPython any more after > it is reparented. (also, may be window_x and window_y shall be used > instead of view_x, view_y). > > Changing it to: > > if (mouse.is_mouse_locked() && ( mouse_x < 20 || mouse_x > view_width > - 20 || mouse_y < 20 || mouse_y > view_height - 20 ) ) { > mouse.report_setcursor( view_width/2, view_height/2 ); > //SetCursorPos( view_x + view_width/2, view_y + view_height/2 ); > POINT pt; > pt.x = pt.y = 0; > ClientToScreen(widget_handle, &pt); > SetCursorPos( pt.x + view_width/2, pt.y + view_height/2 ); > } > if (was_locked && !mouse.is_mouse_locked()) { > mouse.report_setcursor( old_x, old_y ); > //SetCursorPos( view_x + old_x, view_y + old_y ); > POINT pt; > pt.x = pt.y = 0; > ClientToScreen(widget_handle, &pt); > SetCursorPos( pt.x + old_x, pt.y + old_y ); > } > > Now the mouse cursor is correctly positioned after dragging, no matter > if it has been reparented or not. Seems no more crashes now. > > CL > > > Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629. The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629. |
From: CL <clc...@gm...> - 2009-01-17 02:33:55
|
Hi Stef I've uploaded my version of cvisual.pyd for your testing, if you are interested. You can get it from http://code.google.com/p/vpythonex1 The cvisual.pyd-fix3 contains 3 fixes. Download and overwrite your C:\Python25\Lib\site-packages\visual\cvisual.pyd The three fixes are: 1. Fix the problem of my video card opengl extension library entry. It is not compatible with vpython 5.0. This fix shall not affecting you, I believe. 2. Fix the crash when opacity changed from 1.0 to below 1.0 3. The fix of mouse cursor positioning problem caused by re-parenting in the docking situation. CL |
From: Stef M. <s.m...@ru...> - 2009-01-17 11:11:29
|
THANKS ... ! It seems to work great, whatever I tried, I couldn't force an error. cheers, Stef CL wrote: > Hi Stef > > I've uploaded my version of cvisual.pyd for your testing, if you are > interested. You can get it from http://code.google.com/p/vpythonex1 > > The cvisual.pyd-fix3 contains 3 fixes. Download and overwrite your > C:\Python25\Lib\site-packages\visual\cvisual.pyd > > The three fixes are: > 1. Fix the problem of my video card opengl extension library entry. It > is not compatible with vpython 5.0. This fix shall not affecting you, > I believe. > > 2. Fix the crash when opacity changed from 1.0 to below 1.0 > > 3. The fix of mouse cursor positioning problem caused by re-parenting > in the docking situation. > > CL > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > > > |
From: CL <clc...@gm...> - 2009-01-17 02:54:35
|
Hi Shef I've uploaded my version of cvisual.pyd for your testing, if you are interested. You can get it from http://code.google.com/p/vpythonex1 The cvisual.pyd-fix3 contains 3 fixes. Download and overwrite your C:\Python25\Lib\site-packages\visual\cvisual.pyd The three fixes are: 1. Fix the problem of my video card opengl extension library entry. It is not compatible with vpython 5.0. This fix shall not affecting you, I believe. 2. Fix the crash when opacity changed from 1.0 to below 1.0 3. The fix of mouse cursor positioning problem caused by re-parenting in the docking situation. CL |