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. Reimplemented in Impala::Application::MediaTable::TableViewerPointCloud. Definition at line 479 of file ViewerPointCloud.h. References HandleWindowMouse(), mPtDocX, mPtDocY, mScale, and Scale(). Referenced by Impala::Application::MediaTable::TableViewerPointCloud::MouseFunc(), and OglGui::ViewerPointCloudNavigator::ToViewerPointCloudMouse(). 00480 { 00481 static bool isDragging = false; 00482 static float markX, markY, markDocX, markDocY; 00483 static int lastX; 00484 00485 /* RvB: Bogus code trying to scale around mouse x,y but not working 00486 if (msg == oglMouseWheelUp) 00487 { 00488 // mouse position based zooming, implemented as follows: 00489 // transform coordinates of window, mouse and nodes to -0.5 .. +0.5, 00490 // jump node under mouse to center, scale with 1.1f into center 00491 // and unjump. 00492 float xd = (x / (float)W()) - 0.5f; 00493 float yd = (y / (float)H()) - 0.5f; 00494 float x = mPtDocX / W()-0.5f; 00495 float y = mPtDocY / H()-0.5f; 00496 x -= xd/mScale; 00497 y -= yd/mScale; 00498 int jumpX=mPtDocX, jumpY=mPtDocY; 00499 mPtDocX = (int)((x+0.5f) * W()); 00500 mPtDocY = (int)((y+0.5f) * H()); 00501 jumpX -= mPtDocX; 00502 jumpY -= mPtDocY; 00503 Scale(mScale * (1.1f)); 00504 jumpX = (float)jumpX / 1.1f; 00505 jumpY = (float)jumpY / 1.1f; 00506 mPtDocX += jumpX; 00507 mPtDocY += jumpY; 00508 } 00509 if (msg == oglMouseWheelDown) 00510 { 00511 float xd = (x / (float)W()) - 0.5f; 00512 float yd = (y / (float)H()) - 0.5f; 00513 float x = mPtDocX / W()-0.5f; 00514 float y = mPtDocY / H()-0.5f; 00515 x -= xd/mScale; 00516 y -= yd/mScale; 00517 int jumpX=mPtDocX, jumpY=mPtDocY; 00518 mPtDocX = (int)((x+0.5f) * W()); 00519 mPtDocY = (int)((y+0.5f) * H()); 00520 jumpX -= mPtDocX; 00521 jumpY -= mPtDocY; 00522 Scale(mScale * (0.9f)); 00523 jumpX = (float)jumpX / 0.9f; 00524 jumpY = (float)jumpY / 0.9f; 00525 mPtDocX += jumpX; 00526 mPtDocY += jumpY; 00527 } 00528 */ 00529 // RvB: replaced code above with scaling around center, rather than 00530 // faulty scaling around mouse x,y 00531 if (msg == oglMouseWheelUp) 00532 Scale(mScale * (1.1f)); 00533 if (msg == oglMouseWheelDown) 00534 Scale(mScale * (0.9f)); 00535 00536 if (msg == oglMouseDown && btn == oglRightButton) 00537 { 00538 isDragging = true; 00539 markDocX = mPtDocX; 00540 markDocY = mPtDocY; 00541 markX = x; 00542 markY = y; 00543 } 00544 if (msg == oglMouseMove && isDragging) 00545 { 00546 if (state & oglShift) 00547 Scale(mScale * (1.f+((x - lastX)/50.f))); 00548 else 00549 { 00550 mPtDocX = markDocX + (x - markX)/mScale; 00551 mPtDocY = markDocY + (y - markY)/mScale; 00552 } 00553 } 00554 if (msg == oglMouseUp) 00555 isDragging = false; 00556 00557 HandleWindowMouse(msg, btn, state, x, y); 00558 lastX = x; 00559 }
Here is the call graph for this function: ![]()
|