LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

left mouse click generates too many (3) OGLRefresh events

I am working on a CVI application where I need multiple plot windows. I have choosen to create multiple panels, each with one OGL-control. From the CVI examples for an OpenGL control, I have:
1. a panel with a picture control
2. the picture converted to a OGL control
3. inserted a RedrawObject-activity in the control callback for event OGLEVENT_REFRESH

I have attached a test programme. Loading instrument drivers 'cviogl.fp' from CVI subdir toolslib\custctrl and loading 'toolbox.fp' from CVI subdir \toolslib\toolbox is needed.

I want to use left-mouse click to zoom 2x
I want to use right-mouse click to zoom 0.5x
With OGL-attribute enable-pan-zoom ON, the left-mouse click seems to generate an OGLEVENT
_REFRESH on mouse-down, an OGLEVENT_REFRESH on mouse-up and the CVI event EVENT_LEFT_CLICK. Therefore the draw-activity is repeated 3 times. With OGL-attribute for enable-pan-zoom OFF, the left-mouse click generates no events at all. In both cases, the right-mouse click generates one event just as I want to. As the actual application uses several seconds to calculate the RedrawObjects, I want to limit the RedrawObjects to once for each mouse click.

I tried to seperate the OGLRefresh and the actual object drawing by removing the ReDrawObjects from the control callback and calling the RedrawObjects seperately just before/after OGLRefresh; the screen stays empty. I have tried to insert an empty if-statement *wParam==WM_NCLBUTTONDOWN into the windows-callback "OpenglKeyboardActivity" to catch the bottondown event; I am not familiar with Windows SDK and this did not solve anything.

Please tell me how (if possible) to adapt the attached programme so the both left and right mousebuttons
, generate only one RedrawObjects,

Regards, Jos
0 Kudos
Message 1 of 2
(3,012 Views)
I have solved this problem, with a global housekeeping variable 'focus' for each panel. Default this focus-variable is off=0. When this variable is off and the control callback enters the switch for event OGLEVENT_REFRESH, no action is started. So mouse-up and mouse-down activities are ignored.
When the control callback enters the switch for the case of EVENT_LEFT_CLICK, the focus-variable is set to on=1. As a result of additional code for the EVENT_LEFT_CLICK, a call to OGLRefresh() ignites the next call for event OGLEVENT_REFRESH. As the focus-variable is on=1, the appropriate action is started. And within the case itself, the focus-variable is resetted back to off=0.
Not difficult and not elegant, but it works fine.
0 Kudos
Message 2 of 2
(3,012 Views)