TuttleOFX
1
|
00001 #include "PinningPluginFactory.hpp" 00002 #include "PinningPlugin.hpp" 00003 #include "PinningDefinitions.hpp" 00004 #include "PinningOverlayInteract.hpp" 00005 00006 #include <tuttle/plugin/context/SamplerPluginFactory.hpp> 00007 00008 #include <tuttle/plugin/ImageGilProcessor.hpp> 00009 #include <tuttle/plugin/exceptions.hpp> 00010 00011 #include <ofxsMultiThread.h> 00012 00013 #include <boost/gil/gil_all.hpp> 00014 00015 #include <boost/scoped_ptr.hpp> 00016 00017 namespace tuttle { 00018 namespace plugin { 00019 namespace pinning { 00020 00021 static const bool kSupportTiles = false; 00022 00023 /** 00024 * @brief Function called to describe the plugin main features. 00025 * @param[in, out] desc Effect descriptor 00026 */ 00027 void PinningPluginFactory::describe( OFX::ImageEffectDescriptor& desc ) 00028 { 00029 desc.setLabels( 00030 "TuttlePinning", 00031 "Pinning", 00032 "Pinning" ); 00033 desc.setPluginGrouping( "tuttle/image/process/geometry" ); 00034 00035 // add the supported contexts, only filter at the moment 00036 desc.addSupportedContext( OFX::eContextFilter ); 00037 desc.addSupportedContext( OFX::eContextGeneral ); 00038 00039 // add supported pixel depths 00040 desc.addSupportedBitDepth( OFX::eBitDepthUByte ); 00041 desc.addSupportedBitDepth( OFX::eBitDepthUShort ); 00042 desc.addSupportedBitDepth( OFX::eBitDepthFloat ); 00043 00044 // plugin flags 00045 desc.setSupportsTiles( kSupportTiles ); 00046 00047 desc.setOverlayInteractDescriptor( new OFX::DefaultEffectOverlayWrap<PinningEffectOverlayDescriptor > ( ) ); 00048 } 00049 00050 /** 00051 * @brief Function called to describe the plugin controls and features. 00052 * @param[in, out] desc Effect descriptor 00053 * @param[in] context Application context 00054 */ 00055 void PinningPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc, 00056 OFX::EContext context ) 00057 { 00058 OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName ); 00059 srcClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00060 srcClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00061 srcClip->setSupportsTiles( kSupportTiles ); 00062 00063 // Create the mandated output clip 00064 OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName ); 00065 dstClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00066 dstClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00067 dstClip->setSupportsTiles( kSupportTiles ); 00068 00069 //////////////////// Options //////////////////// 00070 OFX::ChoiceParamDescriptor* method = desc.defineChoiceParam( kParamMethod ); 00071 method->setLabel( "Method" ); 00072 method->appendOption( kParamMethodAffine ); 00073 method->appendOption( kParamMethodPerspective ); 00074 method->appendOption( kParamMethodBilinear ); 00075 method->setDefault( 1 ); 00076 method->setHint( "Interpolation method" ); 00077 00078 // sampler parameters // 00079 describeSamplerParamsInContext( desc, context ); 00080 00081 OFX::PushButtonParamDescriptor* setToCornersIn = desc.definePushButtonParam( kParamSetToCornersIn); 00082 setToCornersIn->setLabel( "Set In" ); 00083 setToCornersIn->setHint("Set to corners in points"); 00084 00085 OFX::PushButtonParamDescriptor* setToCornersOut = desc.definePushButtonParam( kParamSetToCornersOut); 00086 setToCornersOut->setLabel( "Set Out" ); 00087 setToCornersOut->setHint("Set to corners out points"); 00088 00089 OFX::BooleanParamDescriptor* overlay = desc.defineBooleanParam( kParamOverlay ); 00090 overlay->setLabel( "Overlay" ); 00091 overlay->setDefault( true ); 00092 overlay->setEvaluateOnChange( false ); 00093 00094 OFX::BooleanParamDescriptor* inverse = desc.defineBooleanParam( kParamInverse ); 00095 inverse->setLabel( "Inverse" ); 00096 inverse->setDefault( false ); 00097 00098 /* 00099 //TODO-vince/////////// 00100 //////////////////// Transform Centre Point //////////////////// 00101 OFX::GroupParamDescriptor* groupCentre = desc.defineGroupParam( kParamGroupCentre ); 00102 groupCentre->setLabel( "Centre point" ); 00103 groupCentre->setOpen(false); 00104 00105 OFX::ChoiceParamDescriptor* manipulatorMode = desc.defineChoiceParam( kParamManipulatorMode ); 00106 manipulatorMode->appendOption( kParamManipulatorModeTranslate ); 00107 manipulatorMode->appendOption( kParamManipulatorModeRotate ); 00108 manipulatorMode->appendOption( kParamManipulatorModeScale ); 00109 00110 OFX::Double2DParamDescriptor* pCentre = desc.defineDouble2DParam( kParamPointCentre); 00111 pCentre->setLabel( "Centre point" ); 00112 pCentre->setHint( "Transform Centre point" ); 00113 pCentre->setDefault( 0.0, 0.0 ); 00114 pCentre->setParent( groupCentre ); 00115 00116 OFX::BooleanParamDescriptor* overlayCentre = desc.defineBooleanParam( kParamOverlayCentre ); 00117 overlayCentre->setLabel( "Overlay" ); 00118 overlayCentre->setDefault( true ); 00119 overlayCentre->setParent( groupCentre ); 00120 overlayCentre->setEvaluateOnChange( false ); 00121 00122 OFX::RGBParamDescriptor* ouverlayCentreColor = desc.defineRGBParam( kParamOverlayCentreColor ); 00123 ouverlayCentreColor->setLabel( "Color" ); 00124 ouverlayCentreColor->setHint( "Centre point overlay color" ); 00125 ouverlayCentreColor->setDefault( 0.0, 1.0, 0.0 ); 00126 ouverlayCentreColor->setParent( groupCentre ); 00127 ouverlayCentreColor->setEvaluateOnChange( false ); 00128 */ 00129 //////////////////// IN Points //////////////////// 00130 OFX::GroupParamDescriptor* groupIn = desc.defineGroupParam( kParamGroupIn ); 00131 groupIn->setLabel( "Input points" ); 00132 groupIn->setOpen(false); 00133 00134 OFX::Double2DParamDescriptor* pIn0 = desc.defineDouble2DParam( kParamPointIn + "0" ); 00135 pIn0->setLabel( "In 0" ); 00136 pIn0->setHint( "Input point 0" ); 00137 pIn0->setDefault( -0.5, -0.5 ); 00138 pIn0->setParent( groupIn ); 00139 00140 OFX::Double2DParamDescriptor* pIn1 = desc.defineDouble2DParam( kParamPointIn + "1" ); 00141 pIn1->setLabel( "In 1" ); 00142 pIn1->setHint( "Input point 1" ); 00143 pIn1->setDefault( 0.5, -0.5 ); 00144 pIn1->setParent( groupIn ); 00145 00146 OFX::Double2DParamDescriptor* pIn2 = desc.defineDouble2DParam( kParamPointIn + "2" ); 00147 pIn2->setLabel( "In 2" ); 00148 pIn2->setHint( "Input point 2" ); 00149 pIn2->setDefault( -0.5, 0.5 ); 00150 pIn2->setParent( groupIn ); 00151 00152 OFX::Double2DParamDescriptor* pIn3 = desc.defineDouble2DParam( kParamPointIn + "3" ); 00153 pIn3->setLabel( "In 3" ); 00154 pIn3->setHint( "Input point 3" ); 00155 pIn3->setDefault( 0.5, 0.5 ); 00156 pIn3->setParent( groupIn ); 00157 00158 OFX::BooleanParamDescriptor* overlayIn = desc.defineBooleanParam( kParamOverlayIn ); 00159 overlayIn->setLabel( "Overlay" ); 00160 overlayIn->setDefault( true ); 00161 overlayIn->setParent( groupIn ); 00162 overlayIn->setEvaluateOnChange( false ); 00163 00164 OFX::RGBParamDescriptor* ouverlayInColor = desc.defineRGBParam( kParamOverlayInColor ); 00165 ouverlayInColor->setLabel( "Color" ); 00166 ouverlayInColor->setHint( "Input point overlay color" ); 00167 ouverlayInColor->setDefault( 1.0, 0.0, 0.0 ); 00168 ouverlayInColor->setParent( groupIn ); 00169 ouverlayInColor->setEvaluateOnChange( false ); 00170 00171 //////////////////// OUT Points //////////////////// 00172 OFX::GroupParamDescriptor* groupOut = desc.defineGroupParam( kParamGroupOut ); 00173 groupOut->setLabel( "Output points" ); 00174 groupOut->setOpen(false); 00175 00176 OFX::Double2DParamDescriptor* pOut0 = desc.defineDouble2DParam( kParamPointOut + "0" ); 00177 pOut0->setLabel( "Out 0" ); 00178 pOut0->setHint( "Output point 0" ); 00179 pOut0->setDefault( -0.5, -0.5 ); 00180 pOut0->setParent( groupOut ); 00181 00182 OFX::Double2DParamDescriptor* pOut1 = desc.defineDouble2DParam( kParamPointOut + "1" ); 00183 pOut1->setLabel( "Out 1" ); 00184 pOut1->setHint( "Output point 1" ); 00185 pOut1->setDefault( 0.5, -0.5 ); 00186 pOut1->setParent( groupOut ); 00187 00188 OFX::Double2DParamDescriptor* pOut2 = desc.defineDouble2DParam( kParamPointOut + "2" ); 00189 pOut2->setLabel( "Out 2" ); 00190 pOut2->setHint( "Output point 2" ); 00191 pOut2->setDefault( -0.5, 0.5 ); 00192 pOut2->setParent( groupOut ); 00193 00194 OFX::Double2DParamDescriptor* pOut3 = desc.defineDouble2DParam( kParamPointOut + "3" ); 00195 pOut3->setLabel( "Out 3" ); 00196 pOut3->setHint( "Output point 3" ); 00197 pOut3->setDefault( 0.5, 0.5 ); 00198 pOut3->setParent( groupOut ); 00199 00200 OFX::BooleanParamDescriptor* overlayOut = desc.defineBooleanParam( kParamOverlayOut ); 00201 overlayOut->setLabel( "Overlay" ); 00202 overlayOut->setDefault( true ); 00203 overlayOut->setParent( groupOut ); 00204 overlayOut->setEvaluateOnChange( false ); 00205 00206 OFX::RGBParamDescriptor* overlayOutColor = desc.defineRGBParam( kParamOverlayOutColor ); 00207 overlayOutColor->setLabel( "Color" ); 00208 overlayOutColor->setHint( "Output point overlay color" ); 00209 overlayOutColor->setDefault( 0.0, 0.0, 1.0 ); 00210 overlayOutColor->setParent( groupOut ); 00211 overlayOutColor->setEvaluateOnChange( false ); 00212 00213 //////////////////// Persp Matrix //////////////////// 00214 OFX::GroupParamDescriptor* groupPerspMatrix = desc.defineGroupParam( kParamGroupPerspMatrix ); 00215 groupPerspMatrix->setLabel( "Perspective matrix" ); 00216 groupPerspMatrix->setHint( "Transformation matrix" ); 00217 00218 OFX::Double3DParamDescriptor* perspMatrixRow0 = desc.defineDouble3DParam( kParamPerspMatrixRow + "0" ); 00219 perspMatrixRow0->setLabel( "row 0" ); 00220 perspMatrixRow0->setDefault( 1.0, 0.0, 0.0 ); 00221 perspMatrixRow0->setParent( groupPerspMatrix ); 00222 00223 OFX::Double3DParamDescriptor* perspMatrixRow1 = desc.defineDouble3DParam( kParamPerspMatrixRow + "1" ); 00224 perspMatrixRow1->setLabel( "row 1" ); 00225 perspMatrixRow1->setDefault( 0.0, 1.0, 0.0 ); 00226 perspMatrixRow1->setParent( groupPerspMatrix ); 00227 00228 OFX::Double3DParamDescriptor* perspMatrixRow2 = desc.defineDouble3DParam( kParamPerspMatrixRow + "2" ); 00229 perspMatrixRow2->setLabel( "row 2" ); 00230 perspMatrixRow2->setDefault( 0.0, 0.0, 1.0 ); 00231 perspMatrixRow2->setParent( groupPerspMatrix ); 00232 00233 ////////////////// Bilinear Matrix //////////////////// 00234 OFX::GroupParamDescriptor* groupBilMatrix = desc.defineGroupParam( kParamGroupBilinearMatrix ); 00235 groupBilMatrix->setLabel( "Bilinear matrix" ); 00236 groupBilMatrix->setHint( "Billinear transformation matrix" ); 00237 00238 OFX::Double2DParamDescriptor* bilMatrixRow0 = desc.defineDouble2DParam( kParamBilinearMatrixRow + "0" ); 00239 bilMatrixRow0->setLabel( "row 0" ); 00240 bilMatrixRow0->setDefault( 1.0, 0.0 ); 00241 bilMatrixRow0->setParent( groupBilMatrix ); 00242 00243 OFX::Double2DParamDescriptor* bilMatrixRow1 = desc.defineDouble2DParam( kParamBilinearMatrixRow + "1" ); 00244 bilMatrixRow1->setLabel( "row 1" ); 00245 bilMatrixRow1->setDefault( 0.0, 1.0 ); 00246 bilMatrixRow1->setParent( groupBilMatrix ); 00247 00248 OFX::Double2DParamDescriptor* bilMatrixRow2 = desc.defineDouble2DParam( kParamBilinearMatrixRow + "2" ); 00249 bilMatrixRow2->setLabel( "row 2" ); 00250 bilMatrixRow2->setDefault( 0.0, 0.0 ); 00251 bilMatrixRow2->setParent( groupBilMatrix ); 00252 00253 OFX::Double2DParamDescriptor* bilMatrixRow3 = desc.defineDouble2DParam( kParamBilinearMatrixRow + "3" ); 00254 bilMatrixRow3->setLabel( "row 3" ); 00255 bilMatrixRow3->setDefault( 0.0, 0.0 ); 00256 bilMatrixRow3->setParent( groupBilMatrix ); 00257 } 00258 00259 /** 00260 * @brief Function called to create a plugin effect instance 00261 * @param[in] handle Effect handle 00262 * @param[in] context Application context 00263 * @return plugin instance 00264 */ 00265 OFX::ImageEffect* PinningPluginFactory::createInstance( OfxImageEffectHandle handle, 00266 OFX::EContext context ) 00267 { 00268 return new PinningPlugin( handle ); 00269 } 00270 00271 } 00272 } 00273 } 00274