TdkCoordTransformer Class Reference
[The Graphics Module]

Defines the TdkCoordTransformer class. This class implements a coordinate transformation service between Window (World) coordinate system and Device (Viewport) coordinate system. More...

#include <TdkCoordTransformer.h>

List of all members.

Auxliary Methods

These methods can be used to calculate aspect ratio between world coordinates area and device coordinates area.

const TdkTransformationTypegetTransformationType () const
 Gets transformation type.
void setTransformationType (const TdkTransformationType &transformationType)
 Sets transformation type. If your canvas is discrete (e.g., countable number of lines an columns), like QtCanvas, you should set as discrete and if you are using a device not discrete (e.g. PDF document) you should set it as not discrete.
static void adjustWindowBox (double &llxW, double &llyW, double &urxW, double &uryW, const double &llxV, const double &llyV, const double &urxV, const double &uryV, const TdkTransformationType &transformationType, const bool &centralized=false)
 Adjust the informed window (world) bounding box according to a device bounding box. This may be helpfull when you want to keep the aspect ratio during a drawing of a theme (layer). The box will be expaded in the correct direction, and you can choose to centralize the draw informaing the last paramenter as true.

Public Types

This enum specifies the possible transformation types.
enum  TdkTransformationType { TdkDiscrete = 1, TdkNotDiscrete = 2 }

Public Member Functions

Constructor and Destructor Methods
Methods related to instantiation and destruction.

 TdkCoordTransformer (const TdkTransformationType &transformationType=TdkDiscrete)
 Empty constructor.
 ~TdkCoordTransformer ()
 Destructor.
Window (World) and Viewport (Device) Set Methods
Methods used to set world and device coordinates area.

void setWindow (const double &llx, const double &lly, const double &urx, const double &ury)
 Adjusts world (or window) coordinates area (supposing a cartesian reference system).
void setWindow (const TeBox &box)
 Adjusts world (window) coordinates area (supposing a cartesian reference system).
void getWindow (double &llx, double &lly, double &urx, double &ury)
 Returns the world (window) coordinates area (supposing a cartesian reference system).
void setViewport (const double &llx, const double &lly, const double &urx, const double &ury)
 Adjusts device coordinates area (supposing a cartesian reference system).
void setViewport (const TeBox &box)
 Adjusts device coordinates area (supposing a cartesian reference system).
void getViewport (double &llx, double &lly, double &urx, double &ury)
 Returns the device coordinates area.
void window2Viewport (const double &wx, const double &wy, double &vx, double &vy)
 Transform world (or window) coordinates to device (or viewpoort) coordinates.
void window2Viewport (const TeCoord2D &wc, TeCoord2D &vc)
 Transform world (or window) value to device (or viewpoort) value.
void window2Viewport (const TdkPrimitiveCoord &wc, TdkPrimitiveCoord &vc)
 Transform world (or window) value to device (or viewpoort) value.
void window2Viewport (const TeBox &wbox, TeBox &vbox)
 Transform world (or window) value to device (or viewpoort) value.
void window2Viewport (const double &w, double &v, const bool &xdirection=true)
 Transform world (or window) value to device (or viewpoort) value according to one axis.
void window2Viewport (const TeLine2D &lineIn, TeLine2D &lineOut)
 Transform line world (or window) coordinates to device (or viewport) coordinates.
void window2Viewport (const TePolygon &polyIn, TePolygon &polyOut)
 Transform polygon world (or window) coordinates to device (or viewport) coordinates.
void window2Viewport (TdkPrimitiveCoord *inputCoords, TdkPrimitiveCoord *outputCoords, const int &numCoords)
 Transform the array of coordinates in world (or window) coordinates to device (or viewport) coordinates. You should pass an output array pre-allocated with the same size as inputCoords array.
void viewport2Window (const double &vx, const double &vy, double &wx, double &wy)
 Transform viewport (or device) coordinates to world (or window) coordinates.
void viewport2Window (const TdkPrimitiveCoord &vc, TdkPrimitiveCoord &wc)
 Transform viewport (or device) coordinates to world (or window) coordinates.
void viewport2Window (const double &v, double &w, const bool &xdirection=true)
 Transform device (or viewpoort) value to world (or window) value according to one axis.
void viewport2Window (const TeLine2D &lineIn, TeLine2D &lineOut)
 Transform line device (or viewport) coordinates to world (or window) coordinates.
void viewport2Window (const TePolygon &polyIn, TePolygon &polyOut)
 Transform polygon device (or viewport) coordinates to world (or window) coordinates.
void viewport2Window (TdkPrimitiveCoord *inputCoords, TdkPrimitiveCoord *outputCoords, const int &numCoords)
 Transform the array of coordinates in device (or viewport) coordinates to world (or window) coordinates. You should pass an output array pre-allocated with the same size as inputCoords array.

Protected Member Functions

Mapping Function Definition Methods
Methods that can be used to calculate the factor used in mapping from device to world and world to device.

void updateTransformation ()

Protected Attributes

double sX_
 Factor used in coordinate system transformation along "x" axis.
double sY_
 Factor used in coordinate system transformation along "y" axis.
double s_
double tX_
double tY_
double llxW_
 Window (World) lower left abscissa.
double llyW_
 Window (World) lower left ordinate.
double urxW_
 Window (World) upper right abscissa.
double uryW_
 Window (World) upper right ordinate.
double widthW_
 Window (World) width.
double heightW_
 Window (World) height.
double llxV_
 Viewport (Device) lower left abscissa.
double llyV_
 Viewport (Device) lower left abscissa.
double urxV_
 Viewport (Device) upper right abscissa.
double uryV_
 Viewport (Device) upper right abscissa.
double widthV_
 Viewport (Device) width.
double heightV_
 Viewport (Device) height.
TdkTransformationType transformationType_
 Indicates if it is a discrete transformation or not.


Detailed Description

Defines the TdkCoordTransformer class. This class implements a coordinate transformation service between Window (World) coordinate system and Device (Viewport) coordinate system.

This class has methods that transform a coordinate from window (world) system to a value in device coordinate system and in the opposite way.

See also:
TdkPrimitiveCoord, TeCoord2D, TeLine2D, TePolygon


Member Enumeration Documentation

enum TdkCoordTransformer::TdkTransformationType

Enumerator:
TdkDiscrete  Discrete transformation.
TdkNotDiscrete  Not a discrete transformation .


Constructor & Destructor Documentation

TdkCoordTransformer::TdkCoordTransformer ( const TdkTransformationType transformationType = TdkDiscrete  ) 

Empty constructor.

Tecgraf - GIS development team

Tdk Framework

@(#) TdkCoordTransformer.cpp

TdkCoordTransformer::~TdkCoordTransformer (  )  [inline]

Destructor.


Member Function Documentation

void TdkCoordTransformer::setWindow ( const double &  llx,
const double &  lly,
const double &  urx,
const double &  ury 
)

Adjusts world (or window) coordinates area (supposing a cartesian reference system).

Parameters:
llx Lower left abscissa. (Input)
lly Lower left ordinate. (Input)
urx Upper left abscissa. (Input)
ury Upper left ordinate. (Input)

void TdkCoordTransformer::setWindow ( const TeBox &  box  ) 

Adjusts world (window) coordinates area (supposing a cartesian reference system).

Parameters:
box Bounding box of world. (Input)

void TdkCoordTransformer::getWindow ( double &  llx,
double &  lly,
double &  urx,
double &  ury 
)

Returns the world (window) coordinates area (supposing a cartesian reference system).

Parameters:
llx Lower left abscissa. (Output)
lly Lower left ordinate. (Output)
urx Upper left abscissa. (Output)
ury Upper left ordinate. (Output)

void TdkCoordTransformer::setViewport ( const double &  llx,
const double &  lly,
const double &  urx,
const double &  ury 
)

Adjusts device coordinates area (supposing a cartesian reference system).

Parameters:
llx Lower left abscissa. (Input)
lly Lower left ordinate. (Input)
urx Upper left abscissa. (Input)
ury Upper left ordinate. (Input)

void TdkCoordTransformer::setViewport ( const TeBox &  box  ) 

Adjusts device coordinates area (supposing a cartesian reference system).

Parameters:
box Device bounding box. (Input)

void TdkCoordTransformer::getViewport ( double &  llx,
double &  lly,
double &  urx,
double &  ury 
)

Returns the device coordinates area.

Parameters:
llx Lower left abscissa. (Output)
lly Lower left ordinate. (Output)
urx Upper left abscissa. (Output)
ury Upper left ordinate. (Output)

void TdkCoordTransformer::window2Viewport ( const double &  wx,
const double &  wy,
double &  vx,
double &  vy 
)

Transform world (or window) coordinates to device (or viewpoort) coordinates.

Parameters:
wx World (or window) abscissa. (Input)
wy World (or window) ordinate. (Input)
vx Viewport (or device) abscissa. (Output)
vy Viewport (or device) ordinate. (Output)

void TdkCoordTransformer::window2Viewport ( const TeCoord2D &  wc,
TeCoord2D &  vc 
)

Transform world (or window) value to device (or viewpoort) value.

Parameters:
wc World (or window) value. (Input)
vc Viewport (or device) value. (Output)

void TdkCoordTransformer::window2Viewport ( const TdkPrimitiveCoord wc,
TdkPrimitiveCoord vc 
)

Transform world (or window) value to device (or viewpoort) value.

Parameters:
wc World (or window) value. (Input)
vc Viewport (or device) value. (Output)

void TdkCoordTransformer::window2Viewport ( const TeBox &  wbox,
TeBox &  vbox 
)

Transform world (or window) value to device (or viewpoort) value.

Parameters:
wbox World (or window) value. (Input)
vbox Viewport (or device) value. (Output)

void TdkCoordTransformer::window2Viewport ( const double &  w,
double &  v,
const bool &  xdirection = true 
)

Transform world (or window) value to device (or viewpoort) value according to one axis.

Parameters:
w World (or window) value. (Input)
v Viewport (or device) value. (Output)
xdirection If world and device don't keep aspect ratio you should specify what axis to consider.

void TdkCoordTransformer::window2Viewport ( const TeLine2D &  lineIn,
TeLine2D &  lineOut 
)

Transform line world (or window) coordinates to device (or viewport) coordinates.

Parameters:
lineIn A line with vertexes in world (or window) coordinates. (Input)
lineOut A copy of the first line with vertexes in viewport (or device) coordinates. (Output)

void TdkCoordTransformer::window2Viewport ( const TePolygon &  polyIn,
TePolygon &  polyOut 
)

Transform polygon world (or window) coordinates to device (or viewport) coordinates.

Parameters:
polyIn A polygon with vertexes in world (or window) coordinates. (Input)
polyOut A copy of the first polygon with vertexes in viewport (or device) coordinates. (Output)

void TdkCoordTransformer::window2Viewport ( TdkPrimitiveCoord inputCoords,
TdkPrimitiveCoord outputCoords,
const int &  numCoords 
)

Transform the array of coordinates in world (or window) coordinates to device (or viewport) coordinates. You should pass an output array pre-allocated with the same size as inputCoords array.

Parameters:
inputCoords A pointer to an array of coordinates in world (or window) coordinates. (Input)
outputCoords A copy of the array with coordinates in viewport (or device) coordinates. (Output)
numCoords The number of coordinates of inputCoords array.
Note:
You should pass an output array pre-allocated with the same size as inputCoords array.

void TdkCoordTransformer::viewport2Window ( const double &  vx,
const double &  vy,
double &  wx,
double &  wy 
)

Transform viewport (or device) coordinates to world (or window) coordinates.

Parameters:
vx Viewport (or device) abscissa. (Input)
vy Viewport (or device) ordinate. (Input)
wx World (or window) abscissa. (Output)
wy World (or window) ordinate. (Output)

void TdkCoordTransformer::viewport2Window ( const TdkPrimitiveCoord vc,
TdkPrimitiveCoord wc 
)

Transform viewport (or device) coordinates to world (or window) coordinates.

Parameters:
vc Viewport (or device) value. (Input)
wc World (or window) value. (Output)

void TdkCoordTransformer::viewport2Window ( const double &  v,
double &  w,
const bool &  xdirection = true 
)

Transform device (or viewpoort) value to world (or window) value according to one axis.

Parameters:
v Viewport (or device) value. (Input)
w World (or window) value. (Output)
xdirection If world and device don't keep aspect ratio you should specify what axis to consider.

void TdkCoordTransformer::viewport2Window ( const TeLine2D &  lineIn,
TeLine2D &  lineOut 
)

Transform line device (or viewport) coordinates to world (or window) coordinates.

Parameters:
lineIn A line with vertexes in viewport (or device) coordinates. (Input)
lineOut A copy of the first line with vertexes in world (or window) coordinates. (Output)

void TdkCoordTransformer::viewport2Window ( const TePolygon &  polyIn,
TePolygon &  polyOut 
)

Transform polygon device (or viewport) coordinates to world (or window) coordinates.

Parameters:
polyIn A polygon with vertexes in device (or viewport) coordinates. (Input)
polyOut A copy of the first polygon with vertexes in world (or window) coordinates. (Output)

void TdkCoordTransformer::viewport2Window ( TdkPrimitiveCoord inputCoords,
TdkPrimitiveCoord outputCoords,
const int &  numCoords 
)

Transform the array of coordinates in device (or viewport) coordinates to world (or window) coordinates. You should pass an output array pre-allocated with the same size as inputCoords array.

Parameters:
inputCoords A pointer to an array of coordinates in viewport (or device) coordinates. (Input)
outputCoords A copy of the array with coordinates in world (or window) coordinates. (Output)
numCoords The number of coordinates of inputCoords array.
Note:
You should pass an output array pre-allocated with the same size as inputCoords array.

const TdkCoordTransformer::TdkTransformationType & TdkCoordTransformer::getTransformationType (  )  const

Gets transformation type.

void TdkCoordTransformer::setTransformationType ( const TdkTransformationType transformationType  ) 

Sets transformation type. If your canvas is discrete (e.g., countable number of lines an columns), like QtCanvas, you should set as discrete and if you are using a device not discrete (e.g. PDF document) you should set it as not discrete.

Parameters:
transformationType Transformation type. (Input)

void TdkCoordTransformer::adjustWindowBox ( double &  llxW,
double &  llyW,
double &  urxW,
double &  uryW,
const double &  llxV,
const double &  llyV,
const double &  urxV,
const double &  uryV,
const TdkTransformationType transformationType,
const bool &  centralized = false 
) [static]

Adjust the informed window (world) bounding box according to a device bounding box. This may be helpfull when you want to keep the aspect ratio during a drawing of a theme (layer). The box will be expaded in the correct direction, and you can choose to centralize the draw informaing the last paramenter as true.

Parameters:
llxW Window lower left abscissa. (Input and Output)
llyW Window lower left ordinate. (Input and Output)
urxW Window upper right abscissa. (Input and Output)
uryW Window upper right ordinate. (Input and Output)
llxV Viewport lower left abscissa. (Input)
llyV Viewport lower left ordinate. (Input)
urxV Viewport upper right abscissa. (Input)
uryV Viewport upper right ordinate. (Input)
transformationType Transformation type. (Input)
centralized Tells if the expanded bounding box will be in the middle.

void TdkCoordTransformer::updateTransformation (  )  [inline, protected]


Member Data Documentation

double TdkCoordTransformer::sX_ [protected]

Factor used in coordinate system transformation along "x" axis.

double TdkCoordTransformer::sY_ [protected]

Factor used in coordinate system transformation along "y" axis.

double TdkCoordTransformer::s_ [protected]

double TdkCoordTransformer::tX_ [protected]

double TdkCoordTransformer::tY_ [protected]

double TdkCoordTransformer::llxW_ [protected]

Window (World) lower left abscissa.

double TdkCoordTransformer::llyW_ [protected]

Window (World) lower left ordinate.

double TdkCoordTransformer::urxW_ [protected]

Window (World) upper right abscissa.

double TdkCoordTransformer::uryW_ [protected]

Window (World) upper right ordinate.

double TdkCoordTransformer::widthW_ [protected]

Window (World) width.

double TdkCoordTransformer::heightW_ [protected]

Window (World) height.

double TdkCoordTransformer::llxV_ [protected]

Viewport (Device) lower left abscissa.

double TdkCoordTransformer::llyV_ [protected]

Viewport (Device) lower left abscissa.

double TdkCoordTransformer::urxV_ [protected]

Viewport (Device) upper right abscissa.

double TdkCoordTransformer::uryV_ [protected]

Viewport (Device) upper right abscissa.

double TdkCoordTransformer::widthV_ [protected]

Viewport (Device) width.

double TdkCoordTransformer::heightV_ [protected]

Viewport (Device) height.

TdkTransformationType TdkCoordTransformer::transformationType_ [protected]

Indicates if it is a discrete transformation or not.


The documentation for this class was generated from the following files:
Generated on Fri Jun 15 16:54:31 2007 for TDK by  doxygen 1.5.2