Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Graphics Class Reference

Provides basic graphics capabilities for drawing into any bitmap, particularly FilterBankGenerators. More...

#include <Graphics.h>


Detailed Description

Provides basic graphics capabilities for drawing into any bitmap, particularly FilterBankGenerators.

Wherever possible, this should try to emulate the graphics API of Java 1 to minimize learning curve. For instance, the pen hangs down and to the right.

Definition at line 12 of file Graphics.h.

List of all members.

Public Member Functions

 Graphics (FilterBankGenerator &fbg, unsigned int layer, unsigned int channel)
 constructor, pass a FilterBankGenerator and layer/channel to draw into
 Graphics (FilterBankGenerator &fbg, unsigned int layer, unsigned int chan1, unsigned int chan2, unsigned int chan3)
 constructor, pass a FilterBankGenerator and layer/channel to draw into
 Graphics (unsigned char *base, unsigned int width, unsigned int height, unsigned int interval, unsigned int stride)
 constructor, directly specify an image buffer
void updateFBG ()
 If you want to reuse a graphics object across multiple frames from a FilterBankGenerator, call this after each new frame, but before you do any drawing.
void drawRect (int x, int y, int width, int height)
 Draws a rectange, upper left at x,y and extending right and down by width and height.
void drawRect (float x, float y, float width, float height)
 Draws a rectange, upper left at x,y and extending right and down by width and height.
void drawLine (int x1, int y1, int x2, int y2)
 Draws a line from (x1, y1) to (x2, y2).
void drawLine (float x1, float y1, float x2, float y2)
 Draws a line from (x1, y1) to (x2, y2).
void drawEllipse (float x, float y, float semimajor, float semiminor, AngPi orientation)
 Draws an ellipse at (x,y) with the specified parameters.
void drawEllipse (int x, int y, float semimajor, float semiminor, AngPi orientation)
 Draws an ellipse at (x,y) with the specified parameters.
void drawQuarterEllipse (int x, int y, float semimajor, float semiminor, AngPi orientation)
 Draws a quarter ellipse at (x,y) with the specified parameters; semimajor and/or semiminor may be negative.
void drawPoint (int x, int y)
 Draws a single point at (x1, y1).
void drawPoint (float x, float y)
 Draws a single point at (x1, y1).
void setColor (rgb _color)
 Sets the "color" of the pen.
void setColor (unsigned char _color)
 Sets the "color" of the pen when drawing into a SegCam buffer.
yuv getColor () const
 returns the "color" of the pen
void getPixelCoordinates (unsigned int &px, unsigned int &py, float x, float y) const
 sets the pixel-coordinate px and py parameters to the corresponding value of x and y
void getRealCoordinates (float &x, float &y, unsigned int px, unsigned int py) const
 sets the x and y parameters from the pixel-coordinates px and py

Protected Attributes

FilterBankGeneratorgen
 the filter bank generator we are drawing into, or NULL
unsigned int genLayer
 the layer within gen we are drawing into
unsigned int genChan1
 the channel within gen we are drawing into
unsigned int genChan2
 the channel within gen we are drawing into
unsigned int genChan3
 the channel within gen we are drawing into
unsigned char * img1
 the image we are currently drawing into (may need to be updated if gen is non-NULL, see updateFBG())
unsigned char * img2
 the image we are currently drawing into (may need to be updated if gen is non-NULL, see updateFBG())
unsigned char * img3
 the image we are currently drawing into (may need to be updated if gen is non-NULL, see updateFBG())
unsigned int w
 the width of img
unsigned int h
 the height of img
unsigned int xInc
 the number of bytes to skip to move horizontally one pixel in img
unsigned int yInc
 the number of bytes to skip to move vertically one pixel in img
yuv color
 the current pen color

Private Member Functions

 Graphics (const Graphics &)
 don't call (copy constructor)
Graphicsoperator= (const Graphics &)
 don't call (assignment operator)

Constructor & Destructor Documentation

Graphics::Graphics ( FilterBankGenerator fbg,
unsigned int  layer,
unsigned int  channel 
)

constructor, pass a FilterBankGenerator and layer/channel to draw into

Definition at line 20 of file Graphics.cc.

Graphics::Graphics ( FilterBankGenerator fbg,
unsigned int  layer,
unsigned int  chan1,
unsigned int  chan2,
unsigned int  chan3 
)

constructor, pass a FilterBankGenerator and layer/channel to draw into

Definition at line 26 of file Graphics.cc.

Graphics::Graphics ( unsigned char *  base,
unsigned int  width,
unsigned int  height,
unsigned int  interval,
unsigned int  stride 
)

constructor, directly specify an image buffer

Definition at line 32 of file Graphics.cc.

Graphics::Graphics ( const Graphics  )  [private]

don't call (copy constructor)


Member Function Documentation

void Graphics::drawEllipse ( int  x,
int  y,
float  semimajor,
float  semiminor,
AngPi  orientation 
)

Draws an ellipse at (x,y) with the specified parameters.

This expects direct-pixel coordinates, so make sure you check the width and height of the layer you are drawing into

Definition at line 271 of file Graphics.cc.

void Graphics::drawEllipse ( float  x,
float  y,
float  semimajor,
float  semiminor,
AngPi  orientation 
)

Draws an ellipse at (x,y) with the specified parameters.

Definition at line 289 of file Graphics.cc.

void Graphics::drawLine ( float  x1,
float  y1,
float  x2,
float  y2 
)

Draws a line from (x1, y1) to (x2, y2).

Definition at line 264 of file Graphics.cc.

void Graphics::drawLine ( int  ix1,
int  iy1,
int  ix2,
int  iy2 
)

Draws a line from (x1, y1) to (x2, y2).

This expects direct-pixel coordinates, so make sure you check the width and height of the layer you are drawing into

Todo:
I think this could be a little faster by writing two cases -- one that handles mostly-vertical lines, and one that handles mostly-horizontal ones. Then the primary loop could be over integer coordinates along that axis, and only the position along the other axis would have to be calculated as floating point

Definition at line 163 of file Graphics.cc.

Referenced by drawLine().

void Graphics::drawPoint ( float  x,
float  y 
)

Draws a single point at (x1, y1).

Definition at line 77 of file Graphics.h.

void Graphics::drawPoint ( int  x,
int  y 
)

Draws a single point at (x1, y1).

This expects direct-pixel coordinates, so make sure you check the width and height of the layer you are drawing into

Definition at line 67 of file Graphics.h.

Referenced by drawEllipse(), drawPoint(), and drawQuarterEllipse().

void Graphics::drawQuarterEllipse ( int  x,
int  y,
float  semimajor,
float  semiminor,
AngPi  orientation 
)

Draws a quarter ellipse at (x,y) with the specified parameters; semimajor and/or semiminor may be negative.

This expects direct-pixel coordinates, so make sure you check the width and height of the layer you are drawing into

Definition at line 295 of file Graphics.cc.

void Graphics::drawRect ( float  x,
float  y,
float  width,
float  height 
)

Draws a rectange, upper left at x,y and extending right and down by width and height.

Definition at line 151 of file Graphics.cc.

void Graphics::drawRect ( int  x,
int  y,
int  width,
int  height 
)

Draws a rectange, upper left at x,y and extending right and down by width and height.

This expects direct-pixel coordinates, so make sure you check the width and height of the layer you are drawing into

Definition at line 48 of file Graphics.cc.

Referenced by drawRect().

yuv Graphics::getColor (  )  const

returns the "color" of the pen

Currently we don't support multi-channel drawing, so you have to draw into each channel separately to do real color based drawing, but maybe someday we'll add a color class.
In the mean time, this is just the byte that's going to be used to fill in wherever the pen traces

Definition at line 100 of file Graphics.h.

void Graphics::getPixelCoordinates ( unsigned int &  px,
unsigned int &  py,
float  x,
float  y 
) const

sets the pixel-coordinate px and py parameters to the corresponding value of x and y

Parameters:
[out] px the pixel position, relative to left edge, positive right, ranges 0 through width-1
[out] py the pixel position, relative to top edge, positive down, ranges 0 through height-1
[in] x the horizontal position, relative to center of the image, left edge is -1 and right edge is 1; no boundary checking is done
[in] y the vertical pixel position, relative to center of the image, top edge is the negative aspect ratio, bottom edge is positive aspect ratio; no boundary checking is done

To keep the coordinate system square, the x is defined to range -1,1, but y's range depends on the aspect ratio of the image, height/width. Thus typically y will approx. -.75,.75

Definition at line 311 of file Graphics.cc.

Referenced by drawEllipse(), drawLine(), drawPoint(), and drawRect().

void Graphics::getRealCoordinates ( float x,
float y,
unsigned int  px,
unsigned int  py 
) const

sets the x and y parameters from the pixel-coordinates px and py

Parameters:
[out] x the horizontal position, relative to center of the image, left edge is -1 and right edge is 1; no boundary checking is done
[out] y the vertical pixel position, relative to center of the image, top edge is the negative aspect ratio, bottom edge is positive aspect ratio; no boundary checking is done
[in] px the pixel position, relative to left edge, positive right, ranges 0 through width-1
[in] py the pixel position, relative to top edge, positive down, ranges 0 through height-1

To keep the coordinate system square, the x is defined to range -1,1, but y's range depends on the aspect ratio of the image, height/width. Thus typically y will approx. -.75,.75

Definition at line 322 of file Graphics.cc.

Graphics& Graphics::operator= ( const Graphics  )  [private]

don't call (assignment operator)

void Graphics::setColor ( unsigned char  _color  ) 

Sets the "color" of the pen when drawing into a SegCam buffer.

Definition at line 92 of file Graphics.h.

void Graphics::setColor ( rgb  _color  ) 

Sets the "color" of the pen.

Currently we don't support multi-channel drawing, so you have to draw into each channel separately to do real color based drawing, but maybe someday we'll add a color class.
In the mean time, this is just the byte that's going to be used to fill in wherever the pen traces

Definition at line 89 of file Graphics.h.

void Graphics::updateFBG (  ) 

If you want to reuse a graphics object across multiple frames from a FilterBankGenerator, call this after each new frame, but before you do any drawing.

This is automatically called by the constructor, so you don't need to do it if you constructor a fresh Graphics object for each frame. But otherwise you'll need this to update img, w, h, xInc, and yInc from the current frame available in gen

Definition at line 36 of file Graphics.cc.

Referenced by Graphics().


Member Data Documentation

yuv Graphics::color [protected]

the current pen color

Definition at line 137 of file Graphics.h.

Referenced by drawLine(), drawPoint(), drawRect(), getColor(), and setColor().

the filter bank generator we are drawing into, or NULL

Definition at line 123 of file Graphics.h.

Referenced by getPixelCoordinates(), getRealCoordinates(), and updateFBG().

unsigned int Graphics::genChan1 [protected]

the channel within gen we are drawing into

Definition at line 125 of file Graphics.h.

Referenced by updateFBG().

unsigned int Graphics::genChan2 [protected]

the channel within gen we are drawing into

Definition at line 126 of file Graphics.h.

Referenced by updateFBG().

unsigned int Graphics::genChan3 [protected]

the channel within gen we are drawing into

Definition at line 127 of file Graphics.h.

Referenced by updateFBG().

unsigned int Graphics::genLayer [protected]

the layer within gen we are drawing into

Definition at line 124 of file Graphics.h.

Referenced by getPixelCoordinates(), getRealCoordinates(), and updateFBG().

unsigned int Graphics::h [protected]

the height of img

Definition at line 133 of file Graphics.h.

Referenced by drawLine(), drawPoint(), drawRect(), getPixelCoordinates(), getRealCoordinates(), and updateFBG().

unsigned char* Graphics::img1 [protected]

the image we are currently drawing into (may need to be updated if gen is non-NULL, see updateFBG())

Definition at line 129 of file Graphics.h.

Referenced by drawLine(), drawPoint(), drawRect(), and updateFBG().

unsigned char* Graphics::img2 [protected]

the image we are currently drawing into (may need to be updated if gen is non-NULL, see updateFBG())

Definition at line 130 of file Graphics.h.

Referenced by drawLine(), drawPoint(), drawRect(), and updateFBG().

unsigned char* Graphics::img3 [protected]

the image we are currently drawing into (may need to be updated if gen is non-NULL, see updateFBG())

Definition at line 131 of file Graphics.h.

Referenced by drawLine(), drawPoint(), drawRect(), and updateFBG().

unsigned int Graphics::w [protected]

the width of img

Definition at line 132 of file Graphics.h.

Referenced by drawLine(), drawPoint(), drawRect(), getPixelCoordinates(), getRealCoordinates(), and updateFBG().

unsigned int Graphics::xInc [protected]

the number of bytes to skip to move horizontally one pixel in img

Definition at line 134 of file Graphics.h.

Referenced by drawLine(), drawPoint(), drawRect(), and updateFBG().

unsigned int Graphics::yInc [protected]

the number of bytes to skip to move vertically one pixel in img

Definition at line 135 of file Graphics.h.

Referenced by drawLine(), drawPoint(), drawRect(), and updateFBG().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:08 2016 by Doxygen 1.6.3