proj home

Files   Classes   Functions   Hierarchy  

Public Member Functions | Public Attributes | List of all members
zprmouse Class Reference

Conversion functions for mouse coordinate spaces. More...

#include <zprmouse.h>

Collaboration diagram for zprmouse:
Collaboration graph

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.

: zz(zz_) {}

Member Function Documentation

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.

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.

{ p.x = zz.mouseX; p.y = 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.

{ return point2<int>(zz.mouseX,zz.mouseY); }
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.

{
assert(zz.width!=0);
assert(zz.height!=0);
r.x /= (double)zz.width;
r.y /= (double)zz.height;
assert(r.x <= 1.0);
assert(r.y <= 1.0);
return r;
}
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.

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.

{
assert(p.x<=1.0);
assert(p.y<=1.0);
assert(p.x>=0.0);
assert(p.y>=0.0);
return point2<uint>(p.x*zz.width,p.y*zz.height);
}
void zprmouse::update ( )
inline

Definition at line 63 of file zprmouse.h.

References zpr::update(), and zz.

Referenced by mazedisp03::mouseevent().

{ zz.update(); }
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().

{
zz.readMouse(&p2.x,&p2.y,&p2.z,p.x,p.y);
return point3<double>(p2.x,p2.y,p2.z);
}
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.

{
return world( mouseratioInv(p) );
}
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.

Member Data Documentation

zpr& zprmouse::zz

Reference to actual mouse state.

Definition at line 24 of file zprmouse.h.

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


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