TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/plugin/interact/PointInteract.cpp
Go to the documentation of this file.
00001 #include "PointInteract.hpp"
00002 
00003 #include "interact.hpp"
00004 #include "overlay.hpp"
00005 
00006 #include <terry/globals.hpp>
00007 #include <tuttle/plugin/ofxToGil/point.hpp>
00008 #include <tuttle/common/math/rectOp.hpp>
00009 
00010 #include <tuttle/plugin/global.hpp>
00011 
00012 namespace tuttle {
00013 namespace plugin {
00014 namespace interact {
00015 
00016 PointInteract::PointInteract( const InteractInfos& infos )
00017         : _infos( infos )
00018 {}
00019 
00020 PointInteract::~PointInteract() {}
00021 
00022 bool PointInteract::draw( const OFX::DrawArgs& args ) const
00023 {
00024         const double margeCanonical = getMarge() * args.pixelScale.x;
00025         const Point2 p( getPoint() );
00026 
00027         glEnable( GL_LINE_STIPPLE );
00028         glLineWidth( getSelected() ? 4.0 : 1.0 );
00029 
00030         glLineStipple( 1, 0xAAAA );
00031         overlay::displayPointRect( p, margeCanonical );
00032         glLineStipple( 1, 0xFFFF );
00033         overlay::displayCross( p, 3.0 * margeCanonical );
00034 
00035         glLineWidth( 1.0 );
00036         glDisable( GL_LINE_STIPPLE );
00037 
00038         return true;
00039 }
00040 
00041 MotionType PointInteract::intersect( const OFX::PenArgs& args )
00042 {
00043         const Point2 mouse = ofxToGil( args.penPosition );
00044         const Point2 p = getPoint();
00045 
00046         const double margeCanonical = getMarge() * args.pixelScale.x;
00047         MotionType m;
00048         m._mode = eMotionTranslate;
00049         m._axis = clicPoint( p, mouse, margeCanonical );
00050         return m;
00051 }
00052 
00053 bool PointInteract::isIn( const OfxRectD& rect )
00054 {
00055         return pointInRect( getPoint(), rect );
00056 }
00057 
00058 }
00059 }
00060 }