TuttleOFX  1
ColorCubeViewerPluginFactory.cpp
Go to the documentation of this file.
00001 #include "ColorCubeViewerPluginFactory.hpp"
00002 #include "ColorCubeViewerPlugin.hpp"
00003 #include "ColorCubeViewerDefinitions.hpp"
00004 #include "ColorCubeViewerOverlay.hpp"
00005 #include "ofxsImageEffect.h"
00006 
00007 #include <limits>
00008 
00009 namespace tuttle {
00010 namespace plugin {
00011 namespace colorCubeViewer {
00012 
00013 /**
00014  * @brief Function called to describe the plugin main features.
00015  * @param[in, out] desc Effect descriptor
00016  */
00017 void ColorCubeViewerPluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00018 {
00019         //describe the plugin
00020         desc.setLabels( "TuttleColorCubeViewer", "ColorCubeViewer",
00021                             "ColorCubeViewer" );
00022         desc.setPluginGrouping( "tuttle/image/display" );
00023 
00024         desc.setDescription( "ColorCubeViewer\n"
00025                              "Plugin is used to ???." );
00026 
00027         // add the supported contexts, only filter at the moment
00028         desc.addSupportedContext( OFX::eContextFilter );
00029         desc.addSupportedContext( OFX::eContextGeneral );
00030 
00031         // add supported pixel depths
00032         desc.addSupportedBitDepth( OFX::eBitDepthUByte );
00033         desc.addSupportedBitDepth( OFX::eBitDepthUShort );
00034         desc.addSupportedBitDepth( OFX::eBitDepthFloat );
00035 
00036         // plugin flags
00037         desc.setSupportsTiles( true );
00038         desc.setHostFrameThreading( false );
00039 
00040         // Don't declare the plugin as fully safe: It's not a safety problem, but we need to compute common data.
00041         // So it's not interesting to compute the same thing on multiple threads.
00042 //      desc.setRenderThreadSafety( OFX::eRenderFullySafe );
00043         desc.setRenderThreadSafety( OFX::eRenderInstanceSafe );
00044         
00045         //Overlay class
00046         desc.setOverlayInteractDescriptor( new OFX::DefaultEffectOverlayWrap<ColorCubeViewerOverlayDescriptor>() );
00047 }
00048 
00049 /**
00050  * @brief Function called to describe the plugin controls and features.
00051  * @param[in, out]   desc       Effect descriptor
00052  * @param[in]        context    Application context
00053  */
00054 void ColorCubeViewerPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc,
00055                                                   OFX::EContext context )
00056 {
00057         OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName );
00058         srcClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00059         srcClip->addSupportedComponent( OFX::ePixelComponentRGB );
00060         srcClip->setSupportsTiles( true );
00061 
00062         OFX::ClipDescriptor* strongSelectionClip = desc.defineClip( kClipColorSelection );
00063         strongSelectionClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00064         strongSelectionClip->setOptional( true );
00065         strongSelectionClip->setSupportsTiles( false );
00066         
00067         OFX::ClipDescriptor* spillSelectionClip = desc.defineClip( kClipSpillSelection );
00068         spillSelectionClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00069         spillSelectionClip->setOptional( true );
00070         spillSelectionClip->setSupportsTiles( false );
00071         
00072         
00073         OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName );
00074         dstClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00075         dstClip->setSupportsTiles( true );
00076 
00077         //Group display
00078         OFX::GroupParamDescriptor* groupDisplay = desc.defineGroupParam(kGroupDisplay);
00079         groupDisplay->setLabel(kGroupDisplayLabel);
00080         groupDisplay->setAsTab(); //current group is a tab
00081         
00082         //Group settings
00083         OFX::GroupParamDescriptor* groupSettings = desc.defineGroupParam(kGroupSettings);
00084         groupSettings->setLabel(kGroupSettingsLabel); //add label
00085         groupSettings->setAsTab();//current group is a tab
00086         
00087         //Group process
00088         OFX::GroupParamDescriptor* groupProcess = desc.defineGroupParam(kGroupProcess);
00089         groupProcess->setLabel(kGroupProcessLabel); //add label
00090         groupProcess->setAsTab();//current group is a tab
00091         
00092         //Check-box display
00093         OFX::BooleanParamDescriptor* pointCloudDisplay = desc.defineBooleanParam( kPointCloudDisplay );
00094         pointCloudDisplay->setLabel( kPointCloudDisplayLabel );         //label
00095         pointCloudDisplay->setDefault(false);                                           //display overlay by default
00096         pointCloudDisplay->setEvaluateOnChange(false);                          //Don't render on change
00097         pointCloudDisplay->setParent(groupDisplay);                                     //add component to group display
00098         
00099         //Check-box discretization cloud point display
00100         OFX::BooleanParamDescriptor* pointCloudDiscretization = desc.defineBooleanParam( kBoolDiscretizationDisplay );
00101         pointCloudDiscretization->setLabel( kBoolDiscretizationDisplayLabel );          //label
00102         pointCloudDiscretization->setDefault(false);                                                            //display overlay by default
00103         pointCloudDiscretization->setLayoutHint( OFX::eLayoutHintNoNewLine );           //line is not finished
00104         pointCloudDiscretization->setEnabled(false);                                                            //Disabled by default (display cloud point is not selected)
00105         pointCloudDiscretization->setHint("Activate discretization point cloud.");
00106         pointCloudDiscretization->setEvaluateOnChange(false);                                           //Don't render on change
00107         pointCloudDiscretization->setParent(groupDisplay);                                                      //add component to group Display
00108         
00109         //Discretization int range
00110         OFX::IntParamDescriptor* discretizationDisplay = desc.defineIntParam(kIntDiscretizationDisplay);
00111         discretizationDisplay->setLabel(kIntDiscretizationDisplayLabel);                        //label
00112         discretizationDisplay->setRange(1,500);                                                                         //value range
00113         discretizationDisplay->setDisplayRange(1,30);                                                           //display value range
00114         discretizationDisplay->setDefault(10);                                                                          //default value
00115         discretizationDisplay->setEnabled(false);                                                                       //Disabled by default (display cloud point is not selected)
00116         discretizationDisplay->setHint("Change discretization point cloud step.");      
00117         discretizationDisplay->setEvaluateOnChange(false);                                                      //Don't render on change
00118         discretizationDisplay->setParent(groupDisplay);                                                         //add component to group display
00119         
00120         //Push button to reset transformation parameters
00121         OFX::PushButtonParamDescriptor* resetTransformationParameters = desc.definePushButtonParam(kPushButtonResetTransformationParameters);
00122         resetTransformationParameters->setLabel(kPushButtonResetTransformationParametersLabel); //label
00123         resetTransformationParameters->setHint("Reset view parameters");                                                //help
00124         resetTransformationParameters->setParent(groupDisplay);                                                                 //add component to group display
00125         
00126         //Number of divison Geodesic form
00127         OFX::IntParamDescriptor* nbDivisionsGeodesicForm = desc.defineIntParam(kIntNumberOfDivisonGeodesicForm);
00128         nbDivisionsGeodesicForm->setLabel(kIntNumberOfDivisonGeodesicFormLabel);        //label
00129         nbDivisionsGeodesicForm->setRange(2,50);                                                                        //value range
00130         nbDivisionsGeodesicForm->setDisplayRange(2,15);                                                         //display range values
00131         nbDivisionsGeodesicForm->setDefault(4);                                 //default value
00132         nbDivisionsGeodesicForm->setHint("Change precision of treatment (can make process slower)"); //help
00133         nbDivisionsGeodesicForm->setParent(groupSettings);                                                      //add component to settings group
00134         
00135         //Selection average mode
00136         OFX::ChoiceParamDescriptor* averageMode = desc.defineChoiceParam(kColorAverageMode);
00137         averageMode->setLabel(kColorAverageModeLabel);
00138         averageMode->setHint("Average mode :\n -automatic : average of color selection \n -manual : choose average separately from selection");
00139         averageMode->appendOption(kColorAverageMode1);
00140         averageMode->appendOption(kColorAverageMode2);
00141         averageMode->setParent(groupSettings);  
00142         
00143         //Selection average selection
00144         OFX::RGBAParamDescriptor* colorAverage = desc.defineRGBAParam(kColorAverageSelection);
00145         colorAverage->setLabel(kColorAverageSelectionLabel);                            //label
00146         colorAverage->setHint("Select the average of the selection");           //help
00147         colorAverage->setEnabled(false);                                                                        //Disabled by default
00148         colorAverage->setLayoutHint( OFX::eLayoutHintNoNewLine );                       //line is not finished
00149         colorAverage->setParent(groupSettings);                                                         //add to settings group
00150         
00151         //Selection average compute
00152         OFX::PushButtonParamDescriptor* colorAverageCompute = desc.definePushButtonParam(kColorAverageComputing);
00153         colorAverageCompute->setLabel(kColorAverageComputingLabel); //label
00154         colorAverageCompute->setEnabled(false);                                         //Disabled by default
00155         colorAverageCompute->setParent(groupSettings);                          //add to settings group
00156         
00157         //Check-box only selection color
00158         OFX::BooleanParamDescriptor* onlySelectionColor = desc.defineBooleanParam(kBoolOnlySelection);
00159         onlySelectionColor->setLabel(kBoolOnlySelectionLabel);                  //add label
00160         onlySelectionColor->setDefault(false);                                                  //check box is not checked by default
00161         onlySelectionColor->setEvaluateOnChange(false);                                 //don't need to recompute on change
00162         onlySelectionColor->setHint("see color process form");                  //help
00163         onlySelectionColor->setLayoutHint( OFX::eLayoutHintNoNewLine ); //line is not finished
00164         onlySelectionColor->setParent(groupDisplay);                                    //add to display group
00165         
00166         //Check-box only selection color
00167         OFX::BooleanParamDescriptor* displaySpillGF = desc.defineBooleanParam(kBoolDisplaySpillGF);
00168         displaySpillGF->setLabel(kBoolDisplaySpillGFLabel);                             //add label
00169         displaySpillGF->setDefault(false);                                                              //check box is not checked by default
00170         displaySpillGF->setEvaluateOnChange(false);                                             //don't need to recompute on change
00171         displaySpillGF->setHint("see spill process form");                              //help
00172         displaySpillGF->setParent(groupDisplay);                                                //add to display group
00173         
00174         //Check box see color selection
00175         OFX::BooleanParamDescriptor* seeSelection = desc.defineBooleanParam(kBoolColorSelectionDisplay);
00176         seeSelection->setLabel(kBoolColorSelectionDisplayLabel);                //add label
00177         seeSelection->setDefault(false);                                                                //check box is checked by default
00178         seeSelection->setEvaluateOnChange(false);                                               //don't need to recompute on change
00179         seeSelection->setHint("Do not see color selection");                    //help
00180         seeSelection->setLayoutHint( OFX::eLayoutHintNoNewLine );               //line is not finished
00181         seeSelection->setParent(groupDisplay);                                                  //add to display group
00182         
00183         //Check box see spill selection
00184         OFX::BooleanParamDescriptor* seeSpillSelection = desc.defineBooleanParam(kBoolSpillSelectionDisplay);
00185         seeSpillSelection->setLabel(kBoolSpillSelectionDisplayLabel);   //add label
00186         seeSpillSelection->setDefault(false);                                                   //check box is checked by default
00187         seeSpillSelection->setEvaluateOnChange(false);                                  //don't need to recompute on change
00188         seeSpillSelection->setHint("Do not see spill selection");               //help
00189         seeSpillSelection->setParent(groupDisplay);                                             //add to display group
00190         
00191         
00192         //Double parameters scale (scale geodesic form)
00193         OFX::DoubleParamDescriptor* scaleGF = desc.defineDoubleParam(kDoubleScaleGeodesicForm);
00194         scaleGF->setLabel(kDoubleScaleGeodesicFormLabel);                               //add label
00195         scaleGF->setDefault(1.0);                                                                               //default value
00196         scaleGF->setRange(0,5.0);                                                                               //scale range
00197         scaleGF->setDisplayRange(0,2);                                                                  //set display range
00198         scaleGF->setHint("Scale geodesic form");                                                //help
00199         scaleGF->setParent(groupProcess);                                                               //add to process group  
00200 }
00201 
00202 /**
00203  * @brief Function called to create a plugin effect instance
00204  * @param[in] handle  Effect handle
00205  * @param[in] context Application context
00206  * @return  plugin instance
00207  */
00208 OFX::ImageEffect* ColorCubeViewerPluginFactory::createInstance( OfxImageEffectHandle handle,
00209                                                             OFX::EContext context )
00210 {
00211         return new ColorCubeViewerPlugin( handle );
00212 }
00213 
00214 }
00215 }
00216 }
00217