GCOP  1.0
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes
gcop::Viewer Class Reference

#include <viewer.h>

Collaboration diagram for gcop::Viewer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Viewer ()
virtual ~Viewer ()
void Init (int *argc, char **argv)
void Start ()
void Add (View &view)
void Remove (View &view)
void RenderViews ()
void DrawOrigin (GLUquadricObj *qobj=0)
void DrawAll ()
void SetColor (const float rgb[3])
void Reshape (int width, int height)
void Render ()
void Keyboard (unsigned char ch, int x, int y)
void Mouse (int button, int state, int x, int y)
void Motion (int x, int y)
void SaveImage (const char *name=0)
void SetCamera (float sphi, float stheta, float sx, float sy, float sz)
void SetCamera (const float params[5])

Static Public Member Functions

static void DrawFrame (GLUquadricObj *qobj=0)
static void DrawArrow (double l=1.0, GLUquadricObj *qobj=0)
static void DrawArrow (const double v[3], GLUquadricObj *qobj=0)
static void DrawText (const char *str, float size=.2)
static GLuint LoadTexture (const char *fname, int wrap=true)
static void DrawCircle (double x=0, double y=0, double r=1, int slices=20)
static void Cylinder (const double xa[3], const double xb[3], double r, int sd)
static void SetColor (float r, float g, float b, float alpha=0)
static void SetMaterial (GLfloat ambientR, GLfloat ambientG, GLfloat ambientB, GLfloat diffuseR, GLfloat diffuseG, GLfloat diffuseB, GLfloat specularR, GLfloat specularG, GLfloat specularB, GLfloat shininess)

Public Attributes

float sphi
float stheta
float sx
float sy
float sz
float zNear
float zFar
float aspect
float xcam
float ycam
int width
int height
float os
 origin scale (how long are the origin axes, default is 1)
float rgb [3]
 default background (clear) color
int window
bool animate
 whether to animate all trajectory frames
double animDelay
 animation delay (def. is 30 ms)
bool saveFrames
 whether to save frame images
const char * frameName
 frame image filename
bool saveDisplay
 whether to continuously save display images at every refresh
const char * displayName
 display image filename
int displayNo
 counter for display image filenames
bool saveSnapshot
 save a single snapshot
bool altLight

Static Public Attributes

static Viewerinstance = 0

Protected Attributes

int downX
int downY
int leftButton
int middleButton
int rightButton
pthread_mutex_t mut
std::map< int, View * > views
GLUquadricObj * aqobj
unsigned char * rgbimg
 rgb image used internally for saving
unsigned char * ppmimg
 ppm image used internally for saving

Detailed Description

Light-weight OpenGL viewer The viewer keeps a list of "views" of different objects and displays them. A view is simply defined as an object that "knows" how to be rendered: it provides its own Render() function

Author: Marin Kobilarov (mkobilar(at)robotics.usc.edu)


Constructor & Destructor Documentation

Viewer::~Viewer ( ) [virtual]

Member Function Documentation

void Viewer::Add ( View view)

Add a view

References gcop::View::id.

void Viewer::Cylinder ( const double  xa[3],
const double  xb[3],
double  r,
int  sd 
) [static]

Draw a cylinder between two points

Parameters:
xastarting point
xbend point
rradius
sdunused
void Viewer::DrawAll ( )

Draw all views and origin

void Viewer::DrawArrow ( double  l = 1.0,
GLUquadricObj *  qobj = 0 
) [static]

Draws an arrow with length l

Parameters:
llength of arrow
qobjquadratic object used for drawing (leave 0 to create a new one)

Referenced by gcop::Body2dView< c >::Render(), gcop::Body2dGraphView::RenderFrame(), gcop::Body3dTrackView::RenderFrame(), gcop::Body2dTrackView::RenderFrame(), and gcop::Kinbody3dTrackView< _nu >::RenderFrame().

void Viewer::DrawArrow ( const double  v[3],
GLUquadricObj *  qobj = 0 
) [static]

Draws an arrow aligned with vector v

Parameters:
v3x1 vector
qobjquadratic object used for drawing (leave 0 to create a new one)

References CROSS, DIV3, DOT3, and NORM3.

void Viewer::DrawCircle ( double  x = 0,
double  y = 0,
double  r = 1,
int  slices = 20 
) [static]

Draw a circle

Parameters:
xx-coord
yy-coord
rradius
slicesresolution in slices
void Viewer::DrawFrame ( GLUquadricObj *  qobj = 0) [static]

Draw frame at the origin with unit length axes

void Viewer::DrawOrigin ( GLUquadricObj *  qobj = 0)

Draw origin.

void Viewer::DrawText ( const char *  str,
float  size = .2 
) [static]

Draws text

Parameters:
strstring
sizefont size

Referenced by gcop::Body2dGraphView::RenderFrame(), and gcop::Posegraph2dView::RenderFrame().

void Viewer::Init ( int *  argc,
char **  argv 
)
void Viewer::Keyboard ( unsigned char  ch,
int  x,
int  y 
)
GLuint Viewer::LoadTexture ( const char *  fname,
int  wrap = true 
) [static]
void Viewer::Motion ( int  x,
int  y 
)
void Viewer::Mouse ( int  button,
int  state,
int  x,
int  y 
)
void Viewer::Remove ( View view)

Remove a view

References gcop::View::id.

void Viewer::Render ( )

Render all views. This is automatically called by graphics engine. You can call this method only if you want to render the views immediately

References gcop::View::Lock(), gcop::View::Render(), gcop::View::RenderFrame(), and gcop::View::Unlock().

void Viewer::Reshape ( int  width,
int  height 
)
void Viewer::SaveImage ( const char *  name = 0)

Save an image of the current display

Parameters:
namefile name (if omited then the name will be "%s_%04d.ppm" where s is Viewer::frameName and i is a global index
void Viewer::SetCamera ( float  sphi,
float  stheta,
float  sx,
float  sy,
float  sz 
)
void Viewer::SetCamera ( const float  params[5])
void Viewer::SetColor ( const float  rgb[3])
void Viewer::SetColor ( float  r,
float  g,
float  b,
float  alpha = 0 
) [static]
void Viewer::SetMaterial ( GLfloat  ambientR,
GLfloat  ambientG,
GLfloat  ambientB,
GLfloat  diffuseR,
GLfloat  diffuseG,
GLfloat  diffuseB,
GLfloat  specularR,
GLfloat  specularG,
GLfloat  specularB,
GLfloat  shininess 
) [static]
void Viewer::Start ( )

Start the viewer and loop until the program is killed NOTE: This should be done in the main process thread and not in a seperate thread!


Member Data Documentation

whether to animate all trajectory frames

animation delay (def. is 30 ms)

GLUquadricObj* gcop::Viewer::aqobj [protected]

display image filename

counter for display image filenames

int gcop::Viewer::downX [protected]
int gcop::Viewer::downY [protected]

frame image filename

Viewer * Viewer::instance = 0 [static]
int gcop::Viewer::leftButton [protected]
int gcop::Viewer::middleButton [protected]
pthread_mutex_t gcop::Viewer::mut [protected]

origin scale (how long are the origin axes, default is 1)

unsigned char* gcop::Viewer::ppmimg [protected]

ppm image used internally for saving

default background (clear) color

unsigned char* gcop::Viewer::rgbimg [protected]

rgb image used internally for saving

int gcop::Viewer::rightButton [protected]

whether to continuously save display images at every refresh

whether to save frame images

save a single snapshot

std::map<int, View*> gcop::Viewer::views [protected]

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