TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/plugin/interact/overlay.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_PLUGIN_OVERLAY_HPP_
00002 #define _TUTTLE_PLUGIN_OVERLAY_HPP_
00003 
00004 #include <ofxsInteract.h>
00005 #include <tuttle/plugin/opengl/gl.h>
00006 
00007 namespace tuttle {
00008 namespace plugin {
00009 namespace overlay {
00010 
00011 template<typename Point2>
00012 inline void displayCross( const Point2& p, const double marge )
00013 {
00014         glBegin( GL_LINES );
00015         glVertex2f( p.x - marge, p.y );
00016         glVertex2f( p.x + marge, p.y );
00017         glVertex2f( p.x, p.y - marge );
00018         glVertex2f( p.x, p.y + marge );
00019         glEnd();
00020 }
00021 
00022 template<typename Point2>
00023 inline void displayPointRect( const Point2& p, const Point2& size )
00024 {
00025         glBegin( GL_LINE_LOOP );
00026         glVertex2f( p.x - size.x, p.y - size.y );
00027         glVertex2f( p.x + size.x, p.y - size.y );
00028         glVertex2f( p.x + size.x, p.y + size.y );
00029         glVertex2f( p.x - size.x, p.y + size.y );
00030         glEnd();
00031 }
00032 
00033 template<typename Point2>
00034 inline void displayPointRect( const Point2& p, const double marge )
00035 {
00036         glBegin( GL_LINE_LOOP );
00037         glVertex2f( p.x - marge, p.y - marge );
00038         glVertex2f( p.x + marge, p.y - marge );
00039         glVertex2f( p.x + marge, p.y + marge );
00040         glVertex2f( p.x - marge, p.y + marge );
00041         glEnd();
00042 }
00043 
00044 template<typename Rect>
00045 inline void displayRect( const Rect& r, const double marge = 0 )
00046 {
00047         glBegin( GL_LINE_LOOP );
00048         glVertex2f( r.x1 - marge, r.y1 - marge );
00049         glVertex2f( r.x2 + marge, r.y1 - marge );
00050         glVertex2f( r.x2 + marge, r.y2 + marge );
00051         glVertex2f( r.x1 - marge, r.y2 + marge );
00052         glEnd();
00053 }
00054 
00055 template<typename Point2>
00056 inline void displayRect( const Point2& a, const Point2& b, const double marge = 0 )
00057 {
00058         glBegin( GL_LINE_STRIP );
00059         glVertex2f( a.x - marge, a.y - marge );
00060         glVertex2f( b.x + marge, a.y - marge );
00061         glVertex2f( b.x + marge, b.y + marge );
00062         glVertex2f( a.x - marge, b.y + marge );
00063         glVertex2f( a.x - marge, a.y - marge );
00064         glEnd();
00065 }
00066 
00067 template<typename Point2>
00068 inline void drawCurve( const std::vector<Point2>& vec )
00069 {
00070         glBegin( GL_LINE_STRIP );
00071         for( typename std::vector<Point2>::const_iterator it = vec.begin(), itEnd = vec.end();
00072              it != itEnd;
00073              ++it )
00074         {
00075                 glVertex2f( it->x, it->y );
00076         }
00077         glEnd();
00078 }
00079 
00080 template<typename Point2>
00081 inline void drawCurves( const std::vector<std::vector<Point2> >& vec )
00082 {
00083         for( typename std::vector<std::vector<Point2> >::const_iterator it = vec.begin(), itEnd = vec.end();
00084              it != itEnd;
00085              ++it )
00086         {
00087                 drawCurve( *it );
00088         }
00089 }
00090 
00091 }
00092 }
00093 }
00094 
00095 #endif
00096