|
ThreeB 1.1
|
Graphics class which draws information to the screen using OpenGL. More...
Public Member Functions | |
| GraphicsGL () | |
| virtual void | draw_pixels (const vector< ImageRef > &pix, float r, float g, float b, float a) |
| virtual void | draw_bbox (const BBox &bbox) |
| virtual void | draw_krap (const vector< Vector< 4 > > &spots, const Image< byte > &im, const BBox &box, int N, Vector< 4 > s) |
| virtual void | glDrawCross (const Vector< 2 > &p, int size) |
| virtual void | swap () |
| virtual void | init (ImageRef log_ratios_size) |
| virtual | ~GraphicsGL () |
| virtual void | init (CVD::ImageRef size)=0 |
| virtual void | draw_krap (const std::vector< TooN::Vector< 4 > > &spots, const CVD::Image< CVD::byte > &im, const BBox &box, int N, TooN::Vector< 4 > s=TooN::Ones *1e99)=0 |
| virtual void | draw_pixels (const std::vector< CVD::ImageRef > &pix, float r, float g, float b, float a=1)=0 |
| virtual void | glDrawCross (const TooN::Vector< 2 > &p, int size=3)=0 |
Private Member Functions | |
| GraphicsGL (const GraphicsGL &) | |
| void | glDrawCircle (const Vector< 2 > &p, float r) |
| void | set_GL_zoom_size (ImageRef size, double scale) |
Private Attributes | |
| std::auto_ptr< GLWindow > | win |
| int | debug_window_zoom |
Graphics class which draws information to the screen using OpenGL.
Definition at line 119 of file multispot5_gui.cc.
| GraphicsGL::GraphicsGL | ( | const GraphicsGL & | ) | [private] |
| GraphicsGL::GraphicsGL | ( | ) | [inline] |
Definition at line 172 of file multispot5_gui.cc.
{
debug_window_zoom = GV3::get<int>("debug.zoom", 3, 1);
}
| virtual GraphicsGL::~GraphicsGL | ( | ) | [inline, virtual] |
Definition at line 254 of file multispot5_gui.cc.
{
}
| void GraphicsGL::glDrawCircle | ( | const Vector< 2 > & | p, |
| float | r | ||
| ) | [inline, private] |
Generate circle linesegments as pair of vertices for GL_LINES.
| p | circle centre |
| r | circle radius |
Definition at line 129 of file multispot5_gui.cc.
{
float theta=0;
for(;;)
{
glVertex(p + r * makeVector(cos(theta), sin(theta)));
theta +=0.01;
if(theta > M_PI*2)
break;
glVertex(p + r * makeVector(cos(theta), sin(theta)));
}
glVertex(p + r * makeVector(1, 0));
}
| void GraphicsGL::set_GL_zoom_size | ( | ImageRef | size, |
| double | scale | ||
| ) | [inline, private] |
Set up a GL window so that glDrawPixels and glVertex line up and also so that glDrawPixels is zoomed.
| size | Window size |
| scale | Zoom level |
Definition at line 147 of file multispot5_gui.cc.
{
double right = size.x;
double bottom = size.y;
//double my_scale = scale;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0-.5, right-.5, bottom-.5, -.5, -1 , 1); // If the origin is the top left
glRasterPos2f(-.5, -.5);
// video is now the same way as upside down to graphics!
glPixelZoom(scale, -scale);
}
| virtual void GraphicsGL::draw_pixels | ( | const vector< ImageRef > & | pix, |
| float | r, | ||
| float | g, | ||
| float | b, | ||
| float | a | ||
| ) | [inline, virtual] |
Definition at line 177 of file multispot5_gui.cc.
{
glColor4f(r, g, b, a);
glPointSize(1.5);
glBegin(GL_POINTS);
glVertex(pix);
glEnd();
}
| virtual void GraphicsGL::draw_bbox | ( | const BBox & | bbox | ) | [inline, virtual] |
Draw a bounding box.
| bbox | Box corners |
Implements FitSpotsGraphics.
Definition at line 186 of file multispot5_gui.cc.
References draw_bbox().
{
::draw_bbox(bbox);
}
| virtual void GraphicsGL::draw_krap | ( | const vector< Vector< 4 > > & | spots, |
| const Image< byte > & | im, | ||
| const BBox & | box, | ||
| int | N, | ||
| Vector< 4 > | s | ||
| ) | [inline, virtual] |
Definition at line 192 of file multispot5_gui.cc.
References draw_bbox().
{
glDrawPixels(im);
glColor3f(1, 0, 0);
draw_bbox(box);
glLineWidth(0.3);
glBegin(GL_LINES);
for(unsigned int i=0; i < spots.size(); i++)
{
glColor4f(0, 1, 0, .3);
if((int)i == N && s[0] != 1e99)
glDrawCircle(s.slice<2, 2>(), s[1]);
else
glDrawCircle(spots[i].slice<2, 2>(), spots[i][1]);
}
glEnd();
glLineWidth(1.0);
glBegin(GL_LINES);
for(unsigned int i=0; i < spots.size(); i++)
{
glColor3f(1, 0, 0);
if((int) i == N)
glColor3f(1, 1, 0);
if((int)i == N && s[0] != 1e99)
glDrawCross(s.slice<2, 2>(), 1);
else
glDrawCross(spots[i].slice<2, 2>(), 1);
}
glEnd();
glFlush();
}
| virtual void GraphicsGL::glDrawCross | ( | const Vector< 2 > & | p, |
| int | size | ||
| ) | [inline, virtual] |
Definition at line 230 of file multispot5_gui.cc.
{
glVertex(p + makeVector(0, size));
glVertex(p + makeVector(0, -size));
glVertex(p + makeVector( size, 0));
glVertex(p + makeVector(-size, 0));
}
| virtual void GraphicsGL::swap | ( | ) | [inline, virtual] |
Swap buffers if double buffered.
Implements FitSpotsGraphics.
Definition at line 239 of file multispot5_gui.cc.
{
win->swap_buffers();
}
| virtual void GraphicsGL::init | ( | ImageRef | log_ratios_size | ) | [inline, virtual] |
Definition at line 245 of file multispot5_gui.cc.
{
win = auto_ptr<GLWindow>(new GLWindow(log_ratios_size*debug_window_zoom));
set_GL_zoom_size(log_ratios_size, debug_window_zoom);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
}
| virtual void FitSpotsGraphics::init | ( | CVD::ImageRef | size | ) | [pure virtual, inherited] |
| virtual void FitSpotsGraphics::draw_krap | ( | const std::vector< TooN::Vector< 4 > > & | spots, |
| const CVD::Image< CVD::byte > & | im, | ||
| const BBox & | box, | ||
| int | N, | ||
| TooN::Vector< 4 > | s = TooN::Ones *1e99 |
||
| ) | [pure virtual, inherited] |
Draw a bunch of stuff.
| spots | List of spots to draw |
| im | Background image |
| box | Bounding box of region |
| N | Spot to highlight |
| s | Extra spot to draw as a cross |
Implemented in NullGraphics.
| virtual void FitSpotsGraphics::draw_pixels | ( | const std::vector< CVD::ImageRef > & | pix, |
| float | r, | ||
| float | g, | ||
| float | b, | ||
| float | a = 1 |
||
| ) | [pure virtual, inherited] |
Draw the pixel mask in an (r,g,b,a) tuple colour.
| pix | mask |
| r | red |
| g | green |
| b | blue |
| a | alpha |
Implemented in NullGraphics.
| virtual void FitSpotsGraphics::glDrawCross | ( | const TooN::Vector< 2 > & | p, |
| int | size = 3 |
||
| ) | [pure virtual, inherited] |
std::auto_ptr<GLWindow> GraphicsGL::win [private] |
Definition at line 122 of file multispot5_gui.cc.
int GraphicsGL::debug_window_zoom [private] |
Definition at line 124 of file multispot5_gui.cc.
1.7.4