proj home

Files   Classes   Functions   Hierarchy  

zprmouse Class Reference

Conversion functions for mouse coordinate spaces. More...

#include <zprmouse.h>

Collaboration diagram for zprmouse:
Collaboration graph

List of all members.

Public Member Functions

 zprmouse (zpr &zz_)
 Constructor.
point2< uint > const mouse () const
 Get the screen coordinates.
point2< int > const mouseint () const
 Return the position as a point in integers.
template<typename T >
void mouse (T &p) const
point2< double > const mouseratio (point2< uint > const &p) const
 Convert screen point to ratio.
point2< double > const mouseratio () const
 Convert actual mouse screen point to ratio.
point2< uint > const mouseratioInv (point2< double > const &p) const
point3< double > const world (point2< uint > const &p) const
point3< double > const world (point2< double > const &p) const
 Convert ratio to pixel screen point, then to world.
point3< double > const world () const
 Convert actual mouse screen point to near world point.
void update ()

Public Attributes

zprzz
 Reference to actual mouse state.

Detailed Description

Conversion functions for mouse coordinate spaces.

Top left is origin. So positive y is downward direction.

Local pixel coordinate system, Local ratio coordinate system, world near plane supported.

The local ratio is the screen mapped to a unit square. So could specify a point in local ratio and this would have meaning in all different screen rectangles.

Definition at line 19 of file zprmouse.h.


Constructor & Destructor Documentation

zprmouse::zprmouse ( zpr zz_  )  [inline]

Constructor.

Definition at line 27 of file zprmouse.h.

00028     : zz(zz_) {}


Member Function Documentation

template<typename T >
void zprmouse::mouse ( T p  )  const [inline]

Definition at line 38 of file zprmouse.h.

References zpr::mouseX, zpr::mouseY, and zz.

00039     { p.x = zz.mouseX; p.y = zz.mouseY; }

point2<uint> const zprmouse::mouse (  )  const [inline]

Get the screen coordinates.

Definition at line 31 of file zprmouse.h.

References zpr::mouseX, zpr::mouseY, and zz.

00032     { return point2<uint>(zz.mouseX,zz.mouseY); }

point2<int> const zprmouse::mouseint (  )  const [inline]

Return the position as a point in integers.

Definition at line 34 of file zprmouse.h.

References zpr::mouseX, zpr::mouseY, and zz.

00035     { return point2<int>(zz.mouseX,zz.mouseY); }

point2< double > const zprmouse::mouseratio (  )  const

Convert actual mouse screen point to ratio.

Definition at line 18 of file zprmouse.cpp.

References zpr::mouseX, zpr::mouseY, and zz.

00019 {
00020   return mouseratio(point2<uint>(zz.mouseX,zz.mouseY));
00021 }

point2< double > const zprmouse::mouseratio ( point2< uint > const &  p  )  const

Convert screen point to ratio.

Definition at line 3 of file zprmouse.cpp.

References zpr::height, r, zpr::width, point2< T >::x, point2< T >::y, and zz.

00004 {
00005   assert(zz.width!=0);
00006   assert(zz.height!=0);
00007 
00008   point2<double> r(p.x,p.y);
00009   r.x /= (double)zz.width;
00010   r.y /= (double)zz.height;
00011 
00012   assert(r.x <= 1.0);
00013   assert(r.y <= 1.0);
00014 
00015   return r;
00016 }

point2<uint> const zprmouse::mouseratioInv ( point2< double > const &  p  )  const [inline]

Definition at line 46 of file zprmouse.h.

References zpr::height, zpr::width, point2< T >::x, point2< T >::y, and zz.

00047   {
00048     assert(p.x<=1.0);
00049     assert(p.y<=1.0);
00050     assert(p.x>=0.0);
00051     assert(p.y>=0.0);
00052     return point2<uint>(p.x*zz.width,p.y*zz.height);
00053   }

void zprmouse::update (  )  [inline]

Definition at line 63 of file zprmouse.h.

References zpr::update(), and zz.

Referenced by mazedisp03::mouseevent().

00064     { zz.update(); }

point3< double > const zprmouse::world (  )  const

Convert actual mouse screen point to near world point.

Definition at line 31 of file zprmouse.cpp.

References zpr::mouseXworld, zpr::mouseYworld, zpr::mouseZworld, and zz.

00032 {
00033   return point3<double>(zz.mouseXworld,zz.mouseYworld,zz.mouseZworld);
00034 }

point3< double > const zprmouse::world ( point2< double > const &  p  )  const

Convert ratio to pixel screen point, then to world.

Definition at line 49 of file zprmouse.cpp.

00052 {
00053   return world( mouseratioInv(p) );
00054 }

point3< double > const zprmouse::world ( point2< uint > const &  p  )  const

Definition at line 23 of file zprmouse.cpp.

References zpr::readMouse(), point2< T >::x, point3< T >::x, point2< T >::y, point3< T >::y, point3< T >::z, and zz.

Referenced by buttonpanel01::update().

00024 {
00025   point3<GLdouble> p2;
00026   zz.readMouse(&p2.x,&p2.y,&p2.z,p.x,p.y);
00027 
00028   return point3<double>(p2.x,p2.y,p2.z);
00029 }


Member Data Documentation

Reference to actual mouse state.

Definition at line 24 of file zprmouse.h.

Referenced by buttonpanel02::draw(), mazedisp03::f01(), mouse(), mouseint(), mouseratio(), mouseratioInv(), update(), buttonpanel02::update(), and world().


The documentation for this class was generated from the following files:

Generated on 27 Nov 2012 for Chelton Evans Source by  doxygen 1.6.1