TuttleOFX
1
|
00001 #ifndef _TUTTLE_PLUGIN_PARAMPOINT_HPP_ 00002 #define _TUTTLE_PLUGIN_PARAMPOINT_HPP_ 00003 00004 #include "Frame.hpp" 00005 #include "InteractInfos.hpp" 00006 #include "InteractObject.hpp" 00007 #include "PointInteract.hpp" 00008 #include "interact.hpp" 00009 #include <tuttle/plugin/ofxToGil/point.hpp> 00010 #include <tuttle/plugin/numeric/coordinateSystem.hpp> 00011 00012 #include <ofxsParam.h> 00013 00014 namespace tuttle { 00015 namespace plugin { 00016 namespace interact { 00017 00018 template<class TFrame, ECoordinateSystem coord> 00019 class ParamPoint : public PointInteract 00020 { 00021 public: 00022 ParamPoint( const InteractInfos& infos, OFX::Double2DParam* param, const TFrame& frame ) 00023 : PointInteract( infos ) 00024 , _param( *param ) 00025 , _frame( frame ) 00026 {} 00027 00028 virtual ~ParamPoint() {} 00029 00030 protected: 00031 OFX::Double2DParam& _param; 00032 const TFrame _frame; 00033 00034 public: 00035 Point2 getPoint() const 00036 { 00037 if( _frame.isEnabled() ) 00038 { 00039 OfxRectD rod = _frame.getFrame( this->getTime() ); 00040 Point2 rodSize( rod.x2 - rod.x1, rod.y2 - rod.y1 ); 00041 Point2 p = pointConvertCoordinateSystem<coord, eCoordinateSystemXY>( ofxToGil( _param.getValue() ), rodSize ); 00042 p += Point2( rod.x1, rod.y1 ); 00043 return p; 00044 } 00045 return Point2( 0, 0 ); 00046 } 00047 00048 void setPoint( const Scalar x, const Scalar y ) 00049 { 00050 if( _frame.isEnabled() ) 00051 { 00052 OfxRectD rod = _frame.getFrame( this->getTime() ); 00053 Point2 rodSize( rod.x2 - rod.x1, rod.y2 - rod.y1 ); 00054 Point2 p( x - rod.x1, y - rod.y1 ); 00055 p = pointConvertCoordinateSystem<eCoordinateSystemXY, coord>( p, rodSize ); 00056 _param.setValue( p.x, p.y ); 00057 return; 00058 } 00059 _param.setValue( 0, 0 ); 00060 } 00061 00062 }; 00063 00064 } 00065 } 00066 } 00067 00068 #endif 00069