This function is called by the event handling system everytime the user has moved or clicked the mouse. So if you want a window which reacts to the mouse in a specific way, you can inherit a class from Window. Another method to implement mouse behaviour is to use a window listener (in this case you have to inherit a class from WindowListener and attach it to this window, see WindowListener for more details) Reimplemented from OglGui::Window. Definition at line 270 of file Plot.h. References mClickX, mClickY, mDragging, OglGui::OglWindow::mOglWnd, mPlottables, mRange, mUserPan, mUserPitch, mUserRoll, mUserZoom, and Pixel2Window(). 00271 { 00272 bool shift = (state & oglShift) != 0; 00273 bool control = (state & oglControl) != 0; 00274 00275 if (msg == oglMouseDown && but == oglRightButton) 00276 { 00277 //if(control) 00278 // mPerspective = !mPerspective; 00279 //else 00280 { 00281 for(int i=0 ; i<2 ; i++) 00282 { 00283 mUserPan[i] = 0; 00284 mUserZoom[i] = 0.9; 00285 } 00286 mUserRoll = mUserPitch = 0; 00287 } 00288 } 00289 00290 if (msg == oglMouseDown && but == oglLeftButton && (shift||control)) 00291 { 00292 mDragging = true; 00293 mClickX = x; 00294 mClickY = y; 00295 } 00296 00297 if (msg == oglMouseUp) 00298 mDragging = false; 00299 00300 if (msg == oglMouseMove && mDragging) 00301 { 00302 int dx = x - mClickX; 00303 int dy = y - mClickY; 00304 if(control) 00305 { 00306 mUserZoom[0] *= pow(1.02,(double)dx); 00307 mUserZoom[1] *= pow(1.02,(double)dy); 00308 for(int i=0 ; i<2 ; i++) 00309 if(mUserZoom[i] < 0.01) 00310 mUserZoom[i] = 0.01; 00311 } 00312 else 00313 //if(mPerspective && !control) 00314 //{ 00315 // mUserRoll -= dy; 00316 // if(mUserRoll > 90) 00317 // mUserRoll = 90; 00318 // if(mUserRoll < -90) 00319 // mUserRoll = -90; 00320 // mUserPitch += dx; 00321 //} 00322 //else 00323 { 00324 mUserPan[0] += (double)dx * mRange[0] / ((double)mOglWnd->width *mUserZoom[0]); 00325 mUserPan[1] += (double)dy * mRange[1] / ((double)mOglWnd->height*mUserZoom[1]); 00326 } 00327 mClickX = x; 00328 mClickY = y; 00329 } 00330 00331 double wx, wy; 00332 Pixel2Window(x, y, wx, wy); 00333 for(int i=0 ; i<mPlottables.size() ; i++) 00334 mPlottables[i]->OnMouse(wx, wy, msg, but, state); 00335 }
Here is the call graph for this function:
|