Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

virtual void OglGui::ViewerPointCloud::MouseFunc ( int  msg,
int  btn,
int  state,
int  x,
int  y 
) [inline, virtual]

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 OglGui::OglWindow::H(), HandleWindowMouse(), mPtDocX, mPtDocY, mScale, Scale(), and OglGui::OglWindow::W().

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         if (msg == oglMouseWheelUp)
00486         {
00487             // mouse position based zooming, implemented as follows:
00488             // transform coordinates of window, mouse and nodes to -0.5 .. +0.5,
00489             // jump node under mouse to center, scale with 1.1f into center
00490             // and unjump. 
00491             float xd = (x / (float)W()) - 0.5f;
00492             float yd = (y / (float)H()) - 0.5f;
00493             float x = mPtDocX / W()-0.5f;
00494             float y = mPtDocY / H()-0.5f;
00495             x -= xd/mScale;
00496             y -= yd/mScale;
00497             int jumpX=mPtDocX, jumpY=mPtDocY;
00498             mPtDocX = (int)((x+0.5f) * W());
00499             mPtDocY = (int)((y+0.5f) * H());
00500             jumpX -= mPtDocX;
00501             jumpY -= mPtDocY;
00502             Scale(mScale * (1.1f));
00503             jumpX = (float)jumpX / 1.1f;
00504             jumpY = (float)jumpY / 1.1f;
00505             mPtDocX += jumpX;
00506             mPtDocY += jumpY;
00507         }
00508         if (msg == oglMouseWheelDown)
00509         {
00510             float xd = (x / (float)W()) - 0.5f;
00511             float yd = (y / (float)H()) - 0.5f;
00512             float x = mPtDocX / W()-0.5f;
00513             float y = mPtDocY / H()-0.5f;
00514             x -= xd/mScale;
00515             y -= yd/mScale;
00516             int jumpX=mPtDocX, jumpY=mPtDocY;
00517             mPtDocX = (int)((x+0.5f) * W());
00518             mPtDocY = (int)((y+0.5f) * H());
00519             jumpX -= mPtDocX;
00520             jumpY -= mPtDocY;
00521             Scale(mScale * (0.9f));
00522             jumpX = (float)jumpX / 0.9f;
00523             jumpY = (float)jumpY / 0.9f;
00524             mPtDocX += jumpX;
00525             mPtDocY += jumpY;
00526         }
00527 
00528         if (msg == oglMouseDown && btn == oglRightButton)
00529         {
00530             isDragging = true;
00531             markDocX = mPtDocX;
00532             markDocY = mPtDocY;
00533             markX = x;
00534             markY = y;
00535         }
00536         if (msg == oglMouseMove && isDragging)
00537         {
00538             if (state & oglShift)
00539                 Scale(mScale * (1.f+((x - lastX)/50.f)));
00540             else
00541             {
00542                 mPtDocX = markDocX + (x - markX)/mScale;
00543                 mPtDocY = markDocY + (y - markY)/mScale;
00544             }
00545         }
00546         if (msg == oglMouseUp)
00547             isDragging = false;
00548 
00549         HandleWindowMouse(msg, btn, state, x, y);
00550         lastX = x;
00551     }

Here is the call graph for this function:


Generated on Fri Mar 19 12:10:07 2010 for ImpalaSrc by  doxygen 1.5.1