VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Gr::Scaler Class Reference

A class that allows for iterating over one integer range while accessing values from another, with no requirement for one range to be a multiple of the other, eg. More...

#include <grscaler.h>

+ Inheritance diagram for Gr::Scaler:

Public Member Functions

 Scaler (int dfirst, int dsecond)
 Constructor for iterating over the first range while calculating scaled values in the second. More...
 
int first () const
 Returns the current value in the first range. More...
 
int second () const
 Returns the corresponding value in the second range. More...
 
- Public Member Functions inherited from Gr::ScalerImp
 ScalerImp (int dfirst, int dsecond)
 Constructor for iterating over the first range. More...
 
 operator bool () const
 Returns true if the current iteration position is still in range.
 
bool operator! () const
 Returns false if the current iteration position is still in range.
 
int a () const
 Returns the current value in the first range.
 
int b () const
 Returns the calculated value in the second range.
 
void operator++ ()
 Moves on to the next position in the first range.
 

Detailed Description

A class that allows for iterating over one integer range while accessing values from another, with no requirement for one range to be a multiple of the other, eg.

for image scaling:

for( Scaler y_scaler(display.dy(),image.dy()) ; !!y_scaler ; ++y_scaler )
{
for( Scaler x_scaler(display.dx(),image.dx()) ; !!x_scaler ; ++x_scaler )
{
int display_x = x_scaler.first() ;
int display_y = y_scaler.first() ;
int image_x = x_scaler.second() ;
int image_y = y_scaler.second() ;
...
}
}

Note that the iteration methods are in the base class.

Definition at line 89 of file grscaler.h.

Constructor & Destructor Documentation

Gr::Scaler::Scaler ( int  dfirst,
int  dsecond 
)
inline

Constructor for iterating over the first range while calculating scaled values in the second.

Definition at line 115 of file grscaler.h.

Member Function Documentation

int Gr::Scaler::first ( ) const
inline

Returns the current value in the first range.

Postcondition: first() >= 0 && first() < dfirst

Definition at line 116 of file grscaler.h.

int Gr::Scaler::second ( ) const
inline

Returns the corresponding value in the second range.

Postcondition: second() >= 0 && second() < dsecond

Definition at line 117 of file grscaler.h.


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