Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > cd34bbe24503efb80ebebb7e33511ba0 > files > 119

libQGLViewer-doc-2.3.1-10.fc12.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>libQGLViewer: MouseGrabber Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="../images/qglviewer.ico" type="image/x-icon" /><link rel="icon" href="../images/qglviewer.icon.png" type="image/png" />
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="../index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>

    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
    </ul>
  </div>
  </div>
</div>
<div class="contents">
<h1>MouseGrabber Class Reference</h1><!-- doxytag: class="qglviewer::MouseGrabber" -->Abstract class for objects that grab mouse focus in a <a class="el" href="classQGLViewer.html" title="A versatile 3D OpenGL viewer based on QGLWidget.">QGLViewer</a>.  
<a href="#_details">More...</a>
<p>
Inherited by <a class="el" href="classqglviewer_1_1ManipulatedFrame.html">ManipulatedFrame</a>.
<p>

<p>
<a href="classqglviewer_1_1MouseGrabber-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Mouse grabbing detection</h2></td></tr>
<tr><td colspan="2"><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#6110636d4e031373ecebd42c6ea838ea">checkIfGrabsMouse</a> (int x, int y, const <a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const camera)=0</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse</a> () const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#9ecea0a9f8ce1b2d92bbd1dd6bdcd4f9">setGrabsMouse</a> (bool grabs)</td></tr>

<tr><td colspan="2"><br><h2>MouseGrabber pool</h2></td></tr>
<tr><td colspan="2"><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#958abc8c9ae9ea339f9765fddfc7dbdd">isInMouseGrabberPool</a> () const </td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#4ef00d9d2abb7b331a3c333649f6ff82">addInMouseGrabberPool</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#4ac2261aafd5f48f2d90c989cdd69369">removeFromMouseGrabberPool</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#23548e9ef41cf38913f6c642509a81ec">clearMouseGrabberPool</a> (bool autoDelete=false)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">static const QList<br>
&lt; MouseGrabber * &gt; &amp;&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool</a> ()</td></tr>

<tr><td colspan="2"><br><h2>Mouse event handlers</h2></td></tr>
<tr><td colspan="2"><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#56df172a6eff56ecc1a99d2e7d548d31">mousePressEvent</a> (QMouseEvent *const event, <a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const camera)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#7c092390bad31d7f73ea474667159859">mouseDoubleClickEvent</a> (QMouseEvent *const event, <a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const camera)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#2e07bf5f7c6c96f40e7f1d1fdb031b0c">mouseReleaseEvent</a> (QMouseEvent *const event, <a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const camera)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#6e2baf9735a27e4c8a928518cc273d5c">mouseMoveEvent</a> (QMouseEvent *const event, <a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const camera)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#07a7d880d107f0b532ef779b29884e08">wheelEvent</a> (QWheelEvent *const event, <a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const camera)</td></tr>

<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#eed1d659951e2bc8dbe0ffa3850c97e6">MouseGrabber</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classqglviewer_1_1MouseGrabber.html#acf14b5ce34121bce9fe5b75c54d666e">~MouseGrabber</a> ()</td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Abstract class for objects that grab mouse focus in a <a class="el" href="classQGLViewer.html" title="A versatile 3D OpenGL viewer based on QGLWidget.">QGLViewer</a>. 
<p>
<a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> are objects which react to the mouse cursor, usually when it hovers over them. This abstract class only provides an interface for all these objects: their actual behavior has to be defined in a derived class.<p>
<h3>How does it work ?</h3>
<p>
All the created <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> are grouped in a <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a>. The QGLViewers parse this pool, calling all the MouseGrabbers' <a class="el" href="classqglviewer_1_1MouseGrabber.html#6110636d4e031373ecebd42c6ea838ea">checkIfGrabsMouse()</a> methods that <a class="el" href="classqglviewer_1_1MouseGrabber.html#9ecea0a9f8ce1b2d92bbd1dd6bdcd4f9">setGrabsMouse()</a> if desired.<p>
When a <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a>, it becomes the <a class="el" href="classQGLViewer.html#6c834adafd727025b63741dd27cb6925">QGLViewer::mouseGrabber()</a>. All the mouse events (<a class="el" href="classqglviewer_1_1MouseGrabber.html#56df172a6eff56ecc1a99d2e7d548d31">mousePressEvent()</a>, <a class="el" href="classqglviewer_1_1MouseGrabber.html#2e07bf5f7c6c96f40e7f1d1fdb031b0c">mouseReleaseEvent()</a>, <a class="el" href="classqglviewer_1_1MouseGrabber.html#6e2baf9735a27e4c8a928518cc273d5c">mouseMoveEvent()</a>, <a class="el" href="classqglviewer_1_1MouseGrabber.html#7c092390bad31d7f73ea474667159859">mouseDoubleClickEvent()</a> and <a class="el" href="classqglviewer_1_1MouseGrabber.html#07a7d880d107f0b532ef779b29884e08">wheelEvent()</a>) are then transmitted to the <a class="el" href="classQGLViewer.html#6c834adafd727025b63741dd27cb6925">QGLViewer::mouseGrabber()</a> instead of being normally processed. This continues while <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a> (updated using <a class="el" href="classqglviewer_1_1MouseGrabber.html#6110636d4e031373ecebd42c6ea838ea">checkIfGrabsMouse()</a>) returns <code>true</code>.<p>
If you want to (temporarily) disable a specific MouseGrabbers, you can remove it from this pool using <a class="el" href="classqglviewer_1_1MouseGrabber.html#4ac2261aafd5f48f2d90c989cdd69369">removeFromMouseGrabberPool()</a>. You can also disable a <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> in a specific <a class="el" href="classQGLViewer.html" title="A versatile 3D OpenGL viewer based on QGLWidget.">QGLViewer</a> using <a class="el" href="classQGLViewer.html#3f0b956f948f469c095ff3c2c1b73494">QGLViewer::setMouseGrabberIsEnabled()</a>.<p>
<h3>Implementation details</h3>
<p>
In order to make <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> react to mouse events, mouse tracking has to be activated in the <a class="el" href="classQGLViewer.html" title="A versatile 3D OpenGL viewer based on QGLWidget.">QGLViewer</a> which wants to use MouseGrabbers: <div class="fragment"><pre class="fragment">  init() { setMouseTracking(<span class="keyword">true</span>); }
</pre></div> Call <code>QGLWidget::hasMouseTracking()</code> to get the current state of this flag.<p>
The <code>camera</code> parameter of the different mouse event methods is a pointer to the <a class="el" href="classQGLViewer.html#27a9e97573822d296b48e1c408b74042">QGLViewer::camera()</a> of the <a class="el" href="classQGLViewer.html" title="A versatile 3D OpenGL viewer based on QGLWidget.">QGLViewer</a> that uses the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a>. It can be used to compute 2D to 3D coordinates conversion using <a class="el" href="classqglviewer_1_1Camera.html#c4dc649d17bd2ae8664a7f4fdd50360f">Camera::projectedCoordinatesOf()</a> and <a class="el" href="classqglviewer_1_1Camera.html#42577d3077e22b4726d78b3db3bba50d">Camera::unprojectedCoordinatesOf()</a>.<p>
Very complex behaviors can be implemented using this framework: auto-selected objects (no need to press a key to use them), automatic drop-down menus, 3D GUI, spinners using the <a class="el" href="classqglviewer_1_1MouseGrabber.html#07a7d880d107f0b532ef779b29884e08">wheelEvent()</a>, and whatever your imagination creates. See the <a href="../examples/mouseGrabber.html">mouseGrabber example</a> for an illustration.<p>
Note that <a class="el" href="classqglviewer_1_1ManipulatedFrame.html" title="A ManipulatedFrame is a Frame that can be rotated and translated using the mouse...">ManipulatedFrame</a> are <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a>: see the <a href="../examples/keyFrames.html">keyFrame example</a> for an illustration. Every created <a class="el" href="classqglviewer_1_1ManipulatedFrame.html" title="A ManipulatedFrame is a Frame that can be rotated and translated using the mouse...">ManipulatedFrame</a> is hence present in the <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a> (note however that <a class="el" href="classqglviewer_1_1ManipulatedCameraFrame.html" title="The ManipulatedCameraFrame class represents a ManipulatedFrame with Camera specific...">ManipulatedCameraFrame</a> are not inserted).<p>
<h3>Example</h3>
<p>
Here is for instance a draft version of a MovableObject class. Instances of these class can freely be moved on screen using the mouse, as movable post-it-like notes: <div class="fragment"><pre class="fragment">  <span class="keyword">class </span>MovableObject : <span class="keyword">public</span> <a class="code" href="classqglviewer_1_1MouseGrabber.html#eed1d659951e2bc8dbe0ffa3850c97e6">MouseGrabber</a>
  {
  <span class="keyword">public</span>:
    MovableObject() : pos(0,0), moved(false) {};

    <span class="keywordtype">void</span> <a class="code" href="classqglviewer_1_1MouseGrabber.html#6110636d4e031373ecebd42c6ea838ea">checkIfGrabsMouse</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keyword">const</span> <a class="code" href="classqglviewer_1_1Camera.html" title="A perspective or orthographic camera.">qglviewer::Camera</a>* <span class="keyword">const</span>)
    {
      <span class="comment">// MovableObject is active in a region of 5 pixels around its pos.</span>
      <span class="comment">// May depend on the actual shape of the object. Customize as desired.</span>
      <span class="comment">// Once clicked (moved = true), it keeps grabbing mouse until button is released.</span>
      <a class="code" href="classqglviewer_1_1MouseGrabber.html#9ecea0a9f8ce1b2d92bbd1dd6bdcd4f9">setGrabsMouse</a>( moved || ((pos-QPoint(x,y)).manhattanLength() &lt; 5) );
    }

    <span class="keywordtype">void</span> <a class="code" href="classqglviewer_1_1MouseGrabber.html#56df172a6eff56ecc1a99d2e7d548d31">mousePressEvent</a>( QMouseEvent* <span class="keyword">const</span> e, Camera* <span class="keyword">const</span>) { prevPos = e-&gt;pos(); moved = <span class="keyword">true</span>; }

    <span class="keywordtype">void</span> <a class="code" href="classqglviewer_1_1MouseGrabber.html#6e2baf9735a27e4c8a928518cc273d5c">mouseMoveEvent</a>(QMouseEvent* <span class="keyword">const</span> e, <span class="keyword">const</span> Camera* <span class="keyword">const</span>)
    {
      <span class="keywordflow">if</span> (moved)
      {
        <span class="comment">// Add position delta to current pos</span>
        pos += e-&gt;pos() - prevPos;
        prevPos = e-&gt;pos();
      }
    }

    <span class="keywordtype">void</span> <a class="code" href="classqglviewer_1_1MouseGrabber.html#2e07bf5f7c6c96f40e7f1d1fdb031b0c">mouseReleaseEvent</a>(QMouseEvent* <span class="keyword">const</span>, Camera* <span class="keyword">const</span>) { moved = <span class="keyword">false</span>; }

    <span class="keywordtype">void</span> draw()
    {
      <span class="comment">// The object is drawn centered on its pos, with different possible aspects:</span>
      <span class="keywordflow">if</span> (<a class="code" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse</a>())
        <span class="keywordflow">if</span> (moved)
          <span class="comment">// Object being moved, maybe a transparent display</span>
        <span class="keywordflow">else</span>
          <span class="comment">// Object ready to be moved, maybe a highlighted visual feedback</span>
      <span class="keywordflow">else</span>
        <span class="comment">// Normal display</span>
    }

  <span class="keyword">private</span>:
    QPoint pos, prevPos;
    <span class="keywordtype">bool</span> moved;
  };
</pre></div> Note that the different event callback methods are called only once the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a>. <hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="eed1d659951e2bc8dbe0ffa3850c97e6"></a><!-- doxytag: member="qglviewer::MouseGrabber::MouseGrabber" ref="eed1d659951e2bc8dbe0ffa3850c97e6" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">MouseGrabber           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Default constructor.<p>
Adds the created <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> in the <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a>. <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a> is set to <code>false</code>. 
</div>
</div><p>
<a class="anchor" name="acf14b5ce34121bce9fe5b75c54d666e"></a><!-- doxytag: member="qglviewer::MouseGrabber::~MouseGrabber" ref="acf14b5ce34121bce9fe5b75c54d666e" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual ~MouseGrabber           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Virtual destructor. Removes the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> from the <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a>. 
</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="6110636d4e031373ecebd42c6ea838ea"></a><!-- doxytag: member="qglviewer::MouseGrabber::checkIfGrabsMouse" ref="6110636d4e031373ecebd42c6ea838ea" args="(int x, int y, const Camera *const camera)=0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void checkIfGrabsMouse           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>x</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>y</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const &nbsp;</td>
          <td class="paramname"> <em>camera</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Pure virtual method, called by the QGLViewers before they test if the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a>. Should <a class="el" href="classqglviewer_1_1MouseGrabber.html#9ecea0a9f8ce1b2d92bbd1dd6bdcd4f9">setGrabsMouse()</a> according to the mouse position.<p>
This is the core method of the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a>. It has to be overloaded in your derived class. Its goal is to update the <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a> flag according to the mouse and <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> current positions, using <a class="el" href="classqglviewer_1_1MouseGrabber.html#9ecea0a9f8ce1b2d92bbd1dd6bdcd4f9">setGrabsMouse()</a>.<p>
<a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a> is usually set to <code>true</code> when the mouse cursor is close enough to the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> position. It should also be set to <code>false</code> when the mouse cursor leaves this region in order to release the mouse focus.<p>
<code>x</code> and <code>y</code> are the mouse cursor coordinates (Qt coordinate system: (0,0) corresponds to the upper left corner).<p>
A typical implementation will look like: <div class="fragment"><pre class="fragment">    <span class="comment">// (posX,posY) is the position of the MouseGrabber on screen.</span>
    <span class="comment">// Here, distance to mouse must be less than 10 pixels to activate the MouseGrabber.</span>
    <a class="code" href="classqglviewer_1_1MouseGrabber.html#9ecea0a9f8ce1b2d92bbd1dd6bdcd4f9">setGrabsMouse</a>( sqrt((x-posX)*(x-posX) + (y-posY)*(y-posY)) &lt; 10);
</pre></div><p>
If the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> position is defined in 3D, use the <code>camera</code> parameter, corresponding to the calling <a class="el" href="classQGLViewer.html" title="A versatile 3D OpenGL viewer based on QGLWidget.">QGLViewer</a> <a class="el" href="classqglviewer_1_1Camera.html" title="A perspective or orthographic camera.">Camera</a>. Project on screen and then compare the projected coordinates: <div class="fragment"><pre class="fragment">    Vec proj = camera-&gt;projectedCoordinatesOf(myMouseGrabber-&gt;frame()-&gt;position());
    <a class="code" href="classqglviewer_1_1MouseGrabber.html#9ecea0a9f8ce1b2d92bbd1dd6bdcd4f9">setGrabsMouse</a>((fabs(x-proj.x) &lt; 5) &amp;&amp; (fabs(y-proj.y) &lt; 2)); <span class="comment">// Rectangular region</span>
</pre></div><p>
See examples in the <a href="#_details">detailed description</a> section and in the <a href="../examples/mouseGrabber.html">mouseGrabber example</a>. 
<p>Implemented in <a class="el" href="classqglviewer_1_1ManipulatedFrame.html#be537c0091ddf3c907ca0e32861d701d">ManipulatedFrame</a>.</p>

</div>
</div><p>
<a class="anchor" name="4eb7e14d035ae255b77ac1711aef039e"></a><!-- doxytag: member="qglviewer::MouseGrabber::grabsMouse" ref="4eb7e14d035ae255b77ac1711aef039e" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool grabsMouse           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Returns <code>true</code> when the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> grabs the QGLViewer's mouse events.<p>
This flag is set with <a class="el" href="classqglviewer_1_1MouseGrabber.html#9ecea0a9f8ce1b2d92bbd1dd6bdcd4f9">setGrabsMouse()</a> by the <a class="el" href="classqglviewer_1_1MouseGrabber.html#6110636d4e031373ecebd42c6ea838ea">checkIfGrabsMouse()</a> method. 
</div>
</div><p>
<a class="anchor" name="9ecea0a9f8ce1b2d92bbd1dd6bdcd4f9"></a><!-- doxytag: member="qglviewer::MouseGrabber::setGrabsMouse" ref="9ecea0a9f8ce1b2d92bbd1dd6bdcd4f9" args="(bool grabs)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void setGrabsMouse           </td>
          <td>(</td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>grabs</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Sets the <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a> flag. Normally used by <a class="el" href="classqglviewer_1_1MouseGrabber.html#6110636d4e031373ecebd42c6ea838ea">checkIfGrabsMouse()</a>. 
</div>
</div><p>
<a class="anchor" name="e4eac355da73462080fe66243be5a286"></a><!-- doxytag: member="qglviewer::MouseGrabber::MouseGrabberPool" ref="e4eac355da73462080fe66243be5a286" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static const QList&lt;MouseGrabber*&gt;&amp; MouseGrabberPool           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Returns a list containing pointers to all the active MouseGrabbers.<p>
Used by the <a class="el" href="classQGLViewer.html" title="A versatile 3D OpenGL viewer based on QGLWidget.">QGLViewer</a> to parse all the MouseGrabbers and to check if any of them <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a> using <a class="el" href="classqglviewer_1_1MouseGrabber.html#6110636d4e031373ecebd42c6ea838ea">checkIfGrabsMouse()</a>.<p>
You should not have to directly use this list. Use <a class="el" href="classqglviewer_1_1MouseGrabber.html#4ac2261aafd5f48f2d90c989cdd69369">removeFromMouseGrabberPool()</a> and <a class="el" href="classqglviewer_1_1MouseGrabber.html#4ef00d9d2abb7b331a3c333649f6ff82">addInMouseGrabberPool()</a> to modify this list.<p>
<dl class="attention" compact><dt><b>Attention:</b></dt><dd>This method returns a <code>QPtrList&lt;MouseGrabber&gt;</code> with Qt 3 and a <code>QList&lt;MouseGrabber&gt;</code> with Qt 2. </dd></dl>

</div>
</div><p>
<a class="anchor" name="958abc8c9ae9ea339f9765fddfc7dbdd"></a><!-- doxytag: member="qglviewer::MouseGrabber::isInMouseGrabberPool" ref="958abc8c9ae9ea339f9765fddfc7dbdd" args="() const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool isInMouseGrabberPool           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"> const</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Returns <code>true</code> if the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> is currently in the <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a> list.<p>
Default value is <code>true</code>. When set to <code>false</code> using <a class="el" href="classqglviewer_1_1MouseGrabber.html#4ac2261aafd5f48f2d90c989cdd69369">removeFromMouseGrabberPool()</a>, the QGLViewers no longer <a class="el" href="classqglviewer_1_1MouseGrabber.html#6110636d4e031373ecebd42c6ea838ea">checkIfGrabsMouse()</a> on this <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a>. Use <a class="el" href="classqglviewer_1_1MouseGrabber.html#4ef00d9d2abb7b331a3c333649f6ff82">addInMouseGrabberPool()</a> to insert it back. 
</div>
</div><p>
<a class="anchor" name="4ef00d9d2abb7b331a3c333649f6ff82"></a><!-- doxytag: member="qglviewer::MouseGrabber::addInMouseGrabberPool" ref="4ef00d9d2abb7b331a3c333649f6ff82" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void addInMouseGrabberPool           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Adds the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> in the <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a>.<p>
All created <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> are automatically added in the <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a> by the constructor. Trying to add a <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> that already <a class="el" href="classqglviewer_1_1MouseGrabber.html#958abc8c9ae9ea339f9765fddfc7dbdd">isInMouseGrabberPool()</a> has no effect.<p>
Use <a class="el" href="classqglviewer_1_1MouseGrabber.html#4ac2261aafd5f48f2d90c989cdd69369">removeFromMouseGrabberPool()</a> to remove the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> from the list, so that it is no longer tested with <a class="el" href="classqglviewer_1_1MouseGrabber.html#6110636d4e031373ecebd42c6ea838ea">checkIfGrabsMouse()</a> by the <a class="el" href="classQGLViewer.html" title="A versatile 3D OpenGL viewer based on QGLWidget.">QGLViewer</a>, and hence can no longer grab mouse focus. Use <a class="el" href="classqglviewer_1_1MouseGrabber.html#958abc8c9ae9ea339f9765fddfc7dbdd">isInMouseGrabberPool()</a> to know the current state of the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a>. 
</div>
</div><p>
<a class="anchor" name="4ac2261aafd5f48f2d90c989cdd69369"></a><!-- doxytag: member="qglviewer::MouseGrabber::removeFromMouseGrabberPool" ref="4ac2261aafd5f48f2d90c989cdd69369" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void removeFromMouseGrabberPool           </td>
          <td>(</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Removes the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> from the <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a>.<p>
See <a class="el" href="classqglviewer_1_1MouseGrabber.html#4ef00d9d2abb7b331a3c333649f6ff82">addInMouseGrabberPool()</a> for details. Removing a <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> that is not in <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a> has no effect. 
</div>
</div><p>
<a class="anchor" name="23548e9ef41cf38913f6c642509a81ec"></a><!-- doxytag: member="qglviewer::MouseGrabber::clearMouseGrabberPool" ref="23548e9ef41cf38913f6c642509a81ec" args="(bool autoDelete=false)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void clearMouseGrabberPool           </td>
          <td>(</td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>autoDelete</em> = <code>false</code>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td width="100%"></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Clears the <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a>.<p>
Use this method only if it is faster to clear the <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a> and then to add back a few MouseGrabbers than to remove each one independently. Use QGLViewer::setMouseTracking(false) instead if you want to disable mouse grabbing.<p>
When <code>autoDelete</code> is <code>true</code>, the MouseGrabbers of the <a class="el" href="classqglviewer_1_1MouseGrabber.html#e4eac355da73462080fe66243be5a286">MouseGrabberPool()</a> are actually deleted (use this only if you're sure of what you do). 
</div>
</div><p>
<a class="anchor" name="56df172a6eff56ecc1a99d2e7d548d31"></a><!-- doxytag: member="qglviewer::MouseGrabber::mousePressEvent" ref="56df172a6eff56ecc1a99d2e7d548d31" args="(QMouseEvent *const event, Camera *const camera)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void mousePressEvent           </td>
          <td>(</td>
          <td class="paramtype">QMouseEvent *const &nbsp;</td>
          <td class="paramname"> <em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const &nbsp;</td>
          <td class="paramname"> <em>camera</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Callback method called when the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a> and a mouse button is pressed.<p>
The <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> will typically start an action or change its state when a mouse button is pressed. <a class="el" href="classqglviewer_1_1MouseGrabber.html#6e2baf9735a27e4c8a928518cc273d5c">mouseMoveEvent()</a> (called at each mouse displacement) will then update the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> accordingly and <a class="el" href="classqglviewer_1_1MouseGrabber.html#2e07bf5f7c6c96f40e7f1d1fdb031b0c">mouseReleaseEvent()</a> (called when the mouse button is released) will terminate this action.<p>
Use the <code>event</code> QMouseEvent::state() and QMouseEvent::button() to test the keyboard and button state and possibly change the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> behavior accordingly.<p>
See the <a href="#_details">detailed description section</a> and the <a href="../examples/mouseGrabber.html">mouseGrabber example</a> for examples.<p>
See the <code>QGLWidget::mousePressEvent()</code> and the <code>QMouseEvent</code> documentations for details. 
<p>Reimplemented in <a class="el" href="classqglviewer_1_1ManipulatedFrame.html#9b4cce9d77e0495202100a8f1055f1f3">ManipulatedFrame</a>.</p>

</div>
</div><p>
<a class="anchor" name="7c092390bad31d7f73ea474667159859"></a><!-- doxytag: member="qglviewer::MouseGrabber::mouseDoubleClickEvent" ref="7c092390bad31d7f73ea474667159859" args="(QMouseEvent *const event, Camera *const camera)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void mouseDoubleClickEvent           </td>
          <td>(</td>
          <td class="paramtype">QMouseEvent *const &nbsp;</td>
          <td class="paramname"> <em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const &nbsp;</td>
          <td class="paramname"> <em>camera</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Callback method called when the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a> and a mouse button is double clicked.<p>
See the <code>QGLWidget::mouseDoubleClickEvent()</code> and the <code>QMouseEvent</code> documentations for details. 
<p>Reimplemented in <a class="el" href="classqglviewer_1_1ManipulatedFrame.html#866619719201540ace1f05a1f8b1f156">ManipulatedFrame</a>.</p>

</div>
</div><p>
<a class="anchor" name="2e07bf5f7c6c96f40e7f1d1fdb031b0c"></a><!-- doxytag: member="qglviewer::MouseGrabber::mouseReleaseEvent" ref="2e07bf5f7c6c96f40e7f1d1fdb031b0c" args="(QMouseEvent *const event, Camera *const camera)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void mouseReleaseEvent           </td>
          <td>(</td>
          <td class="paramtype">QMouseEvent *const &nbsp;</td>
          <td class="paramname"> <em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const &nbsp;</td>
          <td class="paramname"> <em>camera</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Mouse release event callback method. See <a class="el" href="classqglviewer_1_1MouseGrabber.html#56df172a6eff56ecc1a99d2e7d548d31">mousePressEvent()</a>. 
<p>Reimplemented in <a class="el" href="classqglviewer_1_1ManipulatedCameraFrame.html#ec95b0f05a05c1cdfc940ef4621d5db3">ManipulatedCameraFrame</a>, and <a class="el" href="classqglviewer_1_1ManipulatedFrame.html#ec95b0f05a05c1cdfc940ef4621d5db3">ManipulatedFrame</a>.</p>

</div>
</div><p>
<a class="anchor" name="6e2baf9735a27e4c8a928518cc273d5c"></a><!-- doxytag: member="qglviewer::MouseGrabber::mouseMoveEvent" ref="6e2baf9735a27e4c8a928518cc273d5c" args="(QMouseEvent *const event, Camera *const camera)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void mouseMoveEvent           </td>
          <td>(</td>
          <td class="paramtype">QMouseEvent *const &nbsp;</td>
          <td class="paramname"> <em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const &nbsp;</td>
          <td class="paramname"> <em>camera</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Callback method called when the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a> and the mouse is moved while a button is pressed.<p>
This method will typically update the state of the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> from the mouse displacement. See the <a class="el" href="classqglviewer_1_1MouseGrabber.html#56df172a6eff56ecc1a99d2e7d548d31">mousePressEvent()</a> documentation for details. 
<p>Reimplemented in <a class="el" href="classqglviewer_1_1ManipulatedCameraFrame.html#609d287c3721aff697068efa3dfc4b4c">ManipulatedCameraFrame</a>, and <a class="el" href="classqglviewer_1_1ManipulatedFrame.html#609d287c3721aff697068efa3dfc4b4c">ManipulatedFrame</a>.</p>

</div>
</div><p>
<a class="anchor" name="07a7d880d107f0b532ef779b29884e08"></a><!-- doxytag: member="qglviewer::MouseGrabber::wheelEvent" ref="07a7d880d107f0b532ef779b29884e08" args="(QWheelEvent *const event, Camera *const camera)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void wheelEvent           </td>
          <td>(</td>
          <td class="paramtype">QWheelEvent *const &nbsp;</td>
          <td class="paramname"> <em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classqglviewer_1_1Camera.html">Camera</a> *const &nbsp;</td>
          <td class="paramname"> <em>camera</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td width="100%"><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Callback method called when the <a class="el" href="classqglviewer_1_1MouseGrabber.html" title="Abstract class for objects that grab mouse focus in a QGLViewer.">MouseGrabber</a> <a class="el" href="classqglviewer_1_1MouseGrabber.html#4eb7e14d035ae255b77ac1711aef039e">grabsMouse()</a> and the mouse wheel is used.<p>
See the <code>QGLWidget::wheelEvent()</code> and the <code>QWheelEvent</code> documentations for details. 
<p>Reimplemented in <a class="el" href="classqglviewer_1_1ManipulatedCameraFrame.html#e5e5914dbdcba274fc9f58c558ba6a36">ManipulatedCameraFrame</a>, and <a class="el" href="classqglviewer_1_1ManipulatedFrame.html#e5e5914dbdcba274fc9f58c558ba6a36">ManipulatedFrame</a>.</p>

</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>libQGLViewer 2.3.1 documentation generated by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address>
</body>
</html>