#include <cstring>
#include "ofxsSupportPrivate.h"
#include "ofxParametricParam.h"
namespace OFX {
DummyParamDescriptor PageParamDescriptor::gSkipRow(kOfxParamPageSkipRow);
DummyParamDescriptor PageParamDescriptor::gSkipColumn(kOfxParamPageSkipColumn);
const char * mapParamTypeEnumToString(ParamTypeEnum v)
{
switch(v)
{
case eStringParam : return kOfxParamTypeString ;
case eIntParam : return kOfxParamTypeInteger ;
case eInt2DParam : return kOfxParamTypeInteger2D ;
case eInt3DParam : return kOfxParamTypeInteger3D ;
case eDoubleParam : return kOfxParamTypeDouble ;
case eDouble2DParam : return kOfxParamTypeDouble2D ;
case eDouble3DParam : return kOfxParamTypeDouble3D ;
case eRGBParam : return kOfxParamTypeRGB ;
case eRGBAParam : return kOfxParamTypeRGBA ;
case eBooleanParam : return kOfxParamTypeBoolean ;
case eChoiceParam : return kOfxParamTypeChoice ;
case eCustomParam : return kOfxParamTypeCustom ;
case eGroupParam : return kOfxParamTypeGroup ;
case ePageParam : return kOfxParamTypePage ;
case ePushButtonParam : return kOfxParamTypePushButton ;
case eParametricParam : return kOfxParamTypeParametric ;
default: assert(false);
}
return kOfxParamTypeInteger;
}
static
bool isEqual(const char* t1, const char* t2)
{
return strcmp(t1, t2)==0;
}
static
ParamTypeEnum mapParamTypeStringToEnum(const char * v)
{
if(isEqual(kOfxParamTypeString,v))
return eStringParam ;
else if(isEqual(kOfxParamTypeInteger,v))
return eIntParam ;
else if(isEqual(kOfxParamTypeInteger2D,v))
return eInt2DParam ;
else if(isEqual(kOfxParamTypeInteger3D,v))
return eInt3DParam ;
else if(isEqual(kOfxParamTypeDouble,v))
return eDoubleParam ;
else if(isEqual(kOfxParamTypeDouble2D,v))
return eDouble2DParam ;
else if(isEqual(kOfxParamTypeDouble3D,v))
return eDouble3DParam ;
else if(isEqual(kOfxParamTypeRGB,v))
return eRGBParam ;
else if(isEqual(kOfxParamTypeRGBA,v))
return eRGBAParam ;
else if(isEqual(kOfxParamTypeBoolean,v))
return eBooleanParam ;
else if(isEqual(kOfxParamTypeChoice,v))
return eChoiceParam ;
else if(isEqual(kOfxParamTypeCustom ,v))
return eCustomParam ;
else if(isEqual(kOfxParamTypeGroup,v))
return eGroupParam ;
else if(isEqual(kOfxParamTypePage,v))
return ePageParam ;
else if(isEqual(kOfxParamTypePushButton,v))
return ePushButtonParam ;
else if(isEqual(kOfxParamTypeParametric,v))
return eParametricParam ;
else
assert(false);
return ePushButtonParam ;
}
ParamDescriptor::ParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props)
: _paramName(name)
, _paramType(type)
, _paramProps(props)
{
if(type != eDummyParam)
OFX::Validation::validateParameterProperties(type, props, true);
}
ParamDescriptor::~ParamDescriptor()
{
}
void
ParamDescriptor::setLabel(const std::string &label)
{
_paramProps.propSetString(kOfxPropLabel, label);
}
void
ParamDescriptor::setLabels(const std::string &label, const std::string &shortLabel, const std::string &longLabel)
{
setLabel(label);
_paramProps.propSetString(kOfxPropShortLabel, shortLabel, false);
_paramProps.propSetString(kOfxPropLongLabel, longLabel, false);
}
void
ParamDescriptor::setHint(const std::string &v)
{
_paramProps.propSetString(kOfxParamPropHint, v, false);
}
void
ParamDescriptor::setScriptName(const std::string &v)
{
_paramProps.propSetString(kOfxParamPropScriptName, v, false);
}
void
ParamDescriptor::setIsSecret(bool v)
{
_paramProps.propSetInt(kOfxParamPropSecret, v);
}
void
ParamDescriptor::setEnabled(bool v)
{
_paramProps.propSetInt(kOfxParamPropEnabled, v);
}
void
ParamDescriptor::setParent(const GroupParamDescriptor &v)
{
_paramProps.propSetString(kOfxParamPropParent, v.getName());
}
void
ParamDescriptor::setIcon(const std::string &v, bool pngFormat)
{
_paramProps.propSetString(kOfxPropIcon, v, (int)pngFormat, false); }
bool
ParamDescriptor::getHostHasNativeOverlayHandle() const
{
bool v = _paramProps.propGetInt(kOfxParamPropHasHostOverlayHandle, 0, false) != 0; return v;
}
void
ParamDescriptor::setUseHostNativeOverlayHandle(bool use)
{
_paramProps.propSetInt(kOfxParamPropUseHostOverlayHandle, use, 0, false); }
ValueParamDescriptor::ValueParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props)
: ParamDescriptor(name, type, props)
{
}
ValueParamDescriptor::~ValueParamDescriptor()
{
}
void ValueParamDescriptor::setAnimates(bool v)
{
_paramProps.propSetInt(kOfxParamPropAnimates, v);
}
void ValueParamDescriptor::setIsPersistant(bool v)
{
_paramProps.propSetInt(kOfxParamPropPersistant, v);
}
void ValueParamDescriptor::setEvaluateOnChange(bool v)
{
_paramProps.propSetInt(kOfxParamPropEvaluateOnChange, v);
}
void ValueParamDescriptor::setCanUndo(bool v)
{
_paramProps.propSetInt(kOfxParamPropCanUndo, v, 0, false);
}
void ValueParamDescriptor::setCacheInvalidation(CacheInvalidationEnum v)
{
switch(v)
{
case eCacheInvalidateValueChange :
_paramProps.propSetString(kOfxParamPropCacheInvalidation, kOfxParamInvalidateValueChange);
break;
case eCacheInvalidateValueChangeToEnd :
_paramProps.propSetString(kOfxParamPropCacheInvalidation, kOfxParamInvalidateValueChangeToEnd);
break;
case eCacheInvalidateValueAll :
_paramProps.propSetString(kOfxParamPropCacheInvalidation, kOfxParamInvalidateAll);
break;
}
}
void ValueParamDescriptor::setInteractDescriptor(ParamInteractDescriptor* desc)
{
_interact.reset(desc);
_paramProps.propSetPointer(kOfxParamPropInteractV1, (void*)desc->getMainEntry());
desc->setParamName(getName());
}
IntParamDescriptor::IntParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ValueParamDescriptor(name, eIntParam, props)
{
}
void
IntParamDescriptor::setDefault(int v)
{
_paramProps.propSetInt(kOfxParamPropDefault, v);
}
void
IntParamDescriptor::setRange(int min, int max)
{
_paramProps.propSetInt(kOfxParamPropMin, min);
_paramProps.propSetInt(kOfxParamPropMax, max);
}
void
IntParamDescriptor::setDisplayRange(int min, int max)
{
_paramProps.propSetInt(kOfxParamPropDisplayMin, min);
_paramProps.propSetInt(kOfxParamPropDisplayMax, max);
}
Int2DParamDescriptor::Int2DParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ValueParamDescriptor(name, eInt2DParam, props)
{
}
void
Int2DParamDescriptor::setDefault(int x, int y)
{
_paramProps.propSetInt(kOfxParamPropDefault, x, 0);
_paramProps.propSetInt(kOfxParamPropDefault, y, 1);
}
void
Int2DParamDescriptor::setRange(int xmin, int ymin,
int xmax, int ymax)
{
_paramProps.propSetInt(kOfxParamPropMin, xmin, 0);
_paramProps.propSetInt(kOfxParamPropMin, ymin, 1);
_paramProps.propSetInt(kOfxParamPropMax, xmax, 0);
_paramProps.propSetInt(kOfxParamPropMax, ymax, 1);
}
void
Int2DParamDescriptor::setDisplayRange(int xmin, int ymin,
int xmax, int ymax)
{
_paramProps.propSetInt(kOfxParamPropDisplayMin, xmin, 0);
_paramProps.propSetInt(kOfxParamPropDisplayMin, ymin, 1);
_paramProps.propSetInt(kOfxParamPropDisplayMax, xmax, 0);
_paramProps.propSetInt(kOfxParamPropDisplayMax, ymax, 1);
}
void Int2DParamDescriptor::setDimensionLabels(const std::string& x, const std::string& y)
{
_paramProps.propSetString(kOfxParamPropDimensionLabel, x, 0, false);
_paramProps.propSetString(kOfxParamPropDimensionLabel, y, 1, false);
}
Int3DParamDescriptor::Int3DParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ValueParamDescriptor(name, eInt3DParam, props)
{
}
void
Int3DParamDescriptor::setDefault(int x, int y, int z)
{
_paramProps.propSetInt(kOfxParamPropDefault, x, 0);
_paramProps.propSetInt(kOfxParamPropDefault, y, 1);
_paramProps.propSetInt(kOfxParamPropDefault, z, 2);
}
void
Int3DParamDescriptor::setRange(int xmin, int ymin, int zmin,
int xmax, int ymax, int zmax)
{
_paramProps.propSetInt(kOfxParamPropMin, xmin, 0);
_paramProps.propSetInt(kOfxParamPropMin, ymin, 1);
_paramProps.propSetInt(kOfxParamPropMin, zmin, 2);
_paramProps.propSetInt(kOfxParamPropMax, xmax, 0);
_paramProps.propSetInt(kOfxParamPropMax, ymax, 1);
_paramProps.propSetInt(kOfxParamPropMax, zmax, 2);
}
void
Int3DParamDescriptor::setDisplayRange(int xmin, int ymin, int zmin,
int xmax, int ymax, int zmax)
{
_paramProps.propSetInt(kOfxParamPropDisplayMin, xmin, 0);
_paramProps.propSetInt(kOfxParamPropDisplayMin, ymin, 1);
_paramProps.propSetInt(kOfxParamPropDisplayMin, zmin, 2);
_paramProps.propSetInt(kOfxParamPropDisplayMax, xmax, 0);
_paramProps.propSetInt(kOfxParamPropDisplayMax, ymax, 1);
_paramProps.propSetInt(kOfxParamPropDisplayMax, zmax, 2);
}
void Int3DParamDescriptor::setDimensionLabels(const std::string& x, const std::string& y, const std::string& z)
{
_paramProps.propSetString(kOfxParamPropDimensionLabel, x, 0, false);
_paramProps.propSetString(kOfxParamPropDimensionLabel, y, 1, false);
_paramProps.propSetString(kOfxParamPropDimensionLabel, z, 2, false);
}
BaseDoubleParamDescriptor::BaseDoubleParamDescriptor(const std::string &name, ParamTypeEnum type, OfxPropertySetHandle props)
: ValueParamDescriptor(name, type, props)
{
}
void BaseDoubleParamDescriptor::setDoubleType(DoubleTypeEnum v)
{
switch(v)
{
case eDoubleTypePlain :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypePlain);
break;
case eDoubleTypeAngle :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeAngle);
break;
case eDoubleTypeScale :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeScale);
break;
case eDoubleTypeTime :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeTime);
break;
case eDoubleTypeAbsoluteTime :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeAbsoluteTime);
break;
case eDoubleTypeX :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeX);
break;
case eDoubleTypeXAbsolute :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeXAbsolute);
break;
case eDoubleTypeY :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeY);
break;
case eDoubleTypeYAbsolute :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeYAbsolute);
break;
case eDoubleTypeXY :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeXY);
break;
case eDoubleTypeXYAbsolute :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeXYAbsolute);
break;
#ifdef kOfxParamDoubleTypeNormalisedX
case eDoubleTypeNormalisedX :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeNormalisedX);
break;
case eDoubleTypeNormalisedY :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeNormalisedY);
break;
case eDoubleTypeNormalisedXAbsolute :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeNormalisedXAbsolute);
break;
case eDoubleTypeNormalisedYAbsolute :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeNormalisedYAbsolute);
break;
case eDoubleTypeNormalisedXY :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeNormalisedXY);
break;
case eDoubleTypeNormalisedXYAbsolute :
_paramProps.propSetString(kOfxParamPropDoubleType, kOfxParamDoubleTypeNormalisedXYAbsolute);
break;
#endif
}
}
void BaseDoubleParamDescriptor::setDefaultCoordinateSystem(DefaultCoordinateSystemEnum v)
{
try {
switch(v)
{
case eCoordinatesCanonical :
_paramProps.propSetString(kOfxParamPropDefaultCoordinateSystem, kOfxParamCoordinatesCanonical);
break;
case eCoordinatesNormalised :
_paramProps.propSetString(kOfxParamPropDefaultCoordinateSystem, kOfxParamCoordinatesNormalised);
break;
}
} catch (std::exception&) {
}
}
void BaseDoubleParamDescriptor::setIncrement(double v)
{
_paramProps.propSetDouble(kOfxParamPropIncrement, v);
}
void BaseDoubleParamDescriptor::setDigits(int v)
{
_paramProps.propSetInt(kOfxParamPropDigits, v);
}
DoubleParamDescriptor::DoubleParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: BaseDoubleParamDescriptor(name, eDoubleParam, props)
{
}
void
DoubleParamDescriptor::setDefault(double v)
{
_paramProps.propSetDouble(kOfxParamPropDefault, v);
}
void
DoubleParamDescriptor::setRange(double min, double max)
{
_paramProps.propSetDouble(kOfxParamPropMin, min);
_paramProps.propSetDouble(kOfxParamPropMax, max);
}
void
DoubleParamDescriptor::setDisplayRange(double min, double max)
{
_paramProps.propSetDouble(kOfxParamPropDisplayMin, min);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, max);
}
Double2DParamDescriptor::Double2DParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: BaseDoubleParamDescriptor(name, eDouble2DParam, props)
{
}
void
Double2DParamDescriptor::setDefault(double x, double y)
{
_paramProps.propSetDouble(kOfxParamPropDefault, x, 0);
_paramProps.propSetDouble(kOfxParamPropDefault, y, 1);
}
void
Double2DParamDescriptor::setRange(double xmin, double ymin,
double xmax, double ymax)
{
_paramProps.propSetDouble(kOfxParamPropMin, xmin, 0);
_paramProps.propSetDouble(kOfxParamPropMin, ymin, 1);
_paramProps.propSetDouble(kOfxParamPropMax, xmax, 0);
_paramProps.propSetDouble(kOfxParamPropMax, ymax, 1);
}
void
Double2DParamDescriptor::setDisplayRange(double xmin, double ymin,
double xmax, double ymax)
{
_paramProps.propSetDouble(kOfxParamPropDisplayMin, xmin, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMin, ymin, 1);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, xmax, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, ymax, 1);
}
void Double2DParamDescriptor::setDimensionLabels(const std::string& x, const std::string& y)
{
_paramProps.propSetString(kOfxParamPropDimensionLabel, x, 0);
_paramProps.propSetString(kOfxParamPropDimensionLabel, y, 1);
}
void Double2DParamDescriptor::setUseHostOverlayHandle(bool v)
{
_paramProps.propSetInt(kOfxParamPropUseHostOverlayHandle, v);
}
Double3DParamDescriptor::Double3DParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: BaseDoubleParamDescriptor(name, eDouble3DParam, props)
{
}
void
Double3DParamDescriptor::setDefault(double x, double y, double z)
{
_paramProps.propSetDouble(kOfxParamPropDefault, x, 0);
_paramProps.propSetDouble(kOfxParamPropDefault, y, 1);
_paramProps.propSetDouble(kOfxParamPropDefault, z, 2);
}
void
Double3DParamDescriptor::setRange(double xmin, double ymin, double zmin,
double xmax, double ymax, double zmax)
{
_paramProps.propSetDouble(kOfxParamPropMin, xmin, 0);
_paramProps.propSetDouble(kOfxParamPropMin, ymin, 1);
_paramProps.propSetDouble(kOfxParamPropMin, zmin, 2);
_paramProps.propSetDouble(kOfxParamPropMax, xmax, 0);
_paramProps.propSetDouble(kOfxParamPropMax, ymax, 1);
_paramProps.propSetDouble(kOfxParamPropMax, zmax, 2);
}
void
Double3DParamDescriptor::setDisplayRange(double xmin, double ymin, double zmin,
double xmax, double ymax, double zmax)
{
_paramProps.propSetDouble(kOfxParamPropDisplayMin, xmin, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMin, ymin, 1);
_paramProps.propSetDouble(kOfxParamPropDisplayMin, zmin, 2);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, xmax, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, ymax, 1);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, zmax, 2);
}
void Double3DParamDescriptor::setDimensionLabels(const std::string& x, const std::string& y, const std::string& z)
{
_paramProps.propSetString(kOfxParamPropDimensionLabel, x, 0);
_paramProps.propSetString(kOfxParamPropDimensionLabel, y, 1);
_paramProps.propSetString(kOfxParamPropDimensionLabel, z, 2);
}
RGBParamDescriptor::RGBParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ValueParamDescriptor(name, eRGBParam, props)
{
}
void RGBParamDescriptor::setDefault(double r, double g, double b)
{
_paramProps.propSetDouble(kOfxParamPropDefault, r, 0);
_paramProps.propSetDouble(kOfxParamPropDefault, g, 1);
_paramProps.propSetDouble(kOfxParamPropDefault, b, 2);
}
void
RGBParamDescriptor::setRange(double rmin, double gmin, double bmin,
double rmax, double gmax, double bmax)
{
_paramProps.propSetDouble(kOfxParamPropMin, rmin, 0);
_paramProps.propSetDouble(kOfxParamPropMin, gmin, 1);
_paramProps.propSetDouble(kOfxParamPropMin, bmin, 2);
_paramProps.propSetDouble(kOfxParamPropMax, rmax, 0);
_paramProps.propSetDouble(kOfxParamPropMax, gmax, 1);
_paramProps.propSetDouble(kOfxParamPropMax, bmax, 2);
}
void
RGBParamDescriptor::setDisplayRange(double rmin, double gmin, double bmin,
double rmax, double gmax, double bmax)
{
_paramProps.propSetDouble(kOfxParamPropDisplayMin, rmin, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMin, gmin, 1);
_paramProps.propSetDouble(kOfxParamPropDisplayMin, bmin, 2);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, rmax, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, gmax, 1);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, bmax, 2);
}
void RGBParamDescriptor::setDimensionLabels(const std::string& r, const std::string& g, const std::string& b)
{
_paramProps.propSetString(kOfxParamPropDimensionLabel, r, 0);
_paramProps.propSetString(kOfxParamPropDimensionLabel, g, 1);
_paramProps.propSetString(kOfxParamPropDimensionLabel, b, 2);
}
RGBAParamDescriptor::RGBAParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ValueParamDescriptor(name, eRGBAParam, props)
{
}
void RGBAParamDescriptor::setDefault(double r, double g, double b, double a)
{
_paramProps.propSetDouble(kOfxParamPropDefault, r, 0);
_paramProps.propSetDouble(kOfxParamPropDefault, g, 1);
_paramProps.propSetDouble(kOfxParamPropDefault, b, 2);
_paramProps.propSetDouble(kOfxParamPropDefault, a, 3);
}
void
RGBAParamDescriptor::setRange(double rmin, double gmin, double bmin, double amin,
double rmax, double gmax, double bmax, double amax)
{
_paramProps.propSetDouble(kOfxParamPropMin, rmin, 0);
_paramProps.propSetDouble(kOfxParamPropMin, gmin, 1);
_paramProps.propSetDouble(kOfxParamPropMin, bmin, 2);
_paramProps.propSetDouble(kOfxParamPropMin, amin, 3);
_paramProps.propSetDouble(kOfxParamPropMax, rmax, 0);
_paramProps.propSetDouble(kOfxParamPropMax, gmax, 1);
_paramProps.propSetDouble(kOfxParamPropMax, bmax, 2);
_paramProps.propSetDouble(kOfxParamPropMax, amax, 3);
}
void
RGBAParamDescriptor::setDisplayRange(double rmin, double gmin, double bmin, double amin,
double rmax, double gmax, double bmax, double amax)
{
_paramProps.propSetDouble(kOfxParamPropDisplayMin, rmin, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMin, gmin, 1);
_paramProps.propSetDouble(kOfxParamPropDisplayMin, bmin, 2);
_paramProps.propSetDouble(kOfxParamPropDisplayMin, amin, 3);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, rmax, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, gmax, 1);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, bmax, 2);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, amax, 3);
}
void RGBAParamDescriptor::setDimensionLabels(const std::string& r, const std::string& g, const std::string& b, const std::string& a)
{
_paramProps.propSetString(kOfxParamPropDimensionLabel, r, 0);
_paramProps.propSetString(kOfxParamPropDimensionLabel, g, 1);
_paramProps.propSetString(kOfxParamPropDimensionLabel, b, 2);
_paramProps.propSetString(kOfxParamPropDimensionLabel, a, 3);
}
BooleanParamDescriptor::BooleanParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ValueParamDescriptor(name, eBooleanParam, props)
{
}
void BooleanParamDescriptor::setDefault(bool v)
{
_paramProps.propSetInt(kOfxParamPropDefault, int(v));
}
ChoiceParamDescriptor::ChoiceParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ValueParamDescriptor(name, eChoiceParam, props)
{
}
void ChoiceParamDescriptor::setDefault(int v)
{
_paramProps.propSetInt(kOfxParamPropDefault, v);
}
int ChoiceParamDescriptor::getNOptions(void)
{
int nCurrentValues = _paramProps.propGetDimension(kOfxParamPropChoiceOption);
return nCurrentValues;
}
void ChoiceParamDescriptor::appendOption(const std::string &v, const std::string& label)
{
int nCurrentValues = _paramProps.propGetDimension(kOfxParamPropChoiceOption);
_paramProps.propSetString(kOfxParamPropChoiceOption, v, nCurrentValues);
if(!label.empty()) {
{
std::string hint = _paramProps.propGetString(kOfxParamPropHint);
if(!hint.empty()) {
hint += "\n";
if( nCurrentValues == 0 ) {
hint += "\n";
}
}
hint += v + ": " + label;
_paramProps.propSetString(kOfxParamPropHint, hint);
}
}
}
void ChoiceParamDescriptor::resetOptions(void)
{
_paramProps.propReset(kOfxParamPropChoiceOption);
}
StringParamDescriptor::StringParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ValueParamDescriptor(name, eStringParam, props)
{
}
void StringParamDescriptor::setDefault(const std::string &v)
{
_paramProps.propSetString(kOfxParamPropDefault, v);
}
void StringParamDescriptor::setStringType(StringTypeEnum v)
{
switch (v)
{
case eStringTypeSingleLine :
_paramProps.propSetString(kOfxParamPropStringMode, kOfxParamStringIsSingleLine);
break;
case eStringTypeMultiLine :
_paramProps.propSetString(kOfxParamPropStringMode, kOfxParamStringIsMultiLine);
break;
case eStringTypeFilePath :
_paramProps.propSetString(kOfxParamPropStringMode, kOfxParamStringIsFilePath);
break;
case eStringTypeDirectoryPath :
_paramProps.propSetString(kOfxParamPropStringMode, kOfxParamStringIsDirectoryPath);
break;
case eStringTypeLabel :
_paramProps.propSetString(kOfxParamPropStringMode, kOfxParamStringIsLabel);
break;
case eStringTypeRichTextFormat :
_paramProps.propSetString(kOfxParamPropStringMode, kOfxParamStringIsRichTextFormat);
break;
}
}
void StringParamDescriptor::setFilePathExists(bool v)
{
_paramProps.propSetInt(kOfxParamPropStringFilePathExists, int(v));
}
CustomParamDescriptor::CustomParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ValueParamDescriptor(name, eCustomParam, props)
{
}
void CustomParamDescriptor::setDefault(const std::string &v)
{
_paramProps.propSetString(kOfxParamPropDefault, v);
}
void CustomParamDescriptor::setCustomInterpolation(bool v)
{
_paramProps.propSetPointer(kOfxParamPropCustomInterpCallbackV1, v ? (void*)OFX::Private::customParamInterpolationV1Entry : NULL);
}
GroupParamDescriptor::GroupParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ParamDescriptor(name, eGroupParam, props)
{
}
void GroupParamDescriptor::setOpen(const bool v)
{
_paramProps.propSetInt(kOfxParamPropGroupOpen, v, false); }
PageParamDescriptor::PageParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ParamDescriptor(name, ePageParam, props)
{
}
void PageParamDescriptor::addChild(const ParamDescriptor &p)
{
int nKids = _paramProps.propGetDimension(kOfxParamPropPageChild);
_paramProps.propSetString(kOfxParamPropPageChild, p.getName(), nKids);
}
PushButtonParamDescriptor::PushButtonParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ParamDescriptor(name, ePushButtonParam, props)
{
}
ParametricParamDescriptor::ParametricParamDescriptor(const std::string &name, OfxPropertySetHandle props)
: ParamDescriptor(name, eParametricParam, props)
, _ofxParamHandle(0)
, _paramSet(0)
{
}
void ParametricParamDescriptor::setParamSet(ParamSetDescriptor& paramSet)
{
_paramSet = ¶mSet;
OFX::Private::gParamSuite->paramGetHandle(_paramSet->getParamSetHandle(), getName().c_str(), &_ofxParamHandle, 0);
}
void ParametricParamDescriptor::setRange(const double min, const double max)
{
_paramProps.propSetDouble(kOfxParamPropParametricRange, min, 0);
_paramProps.propSetDouble(kOfxParamPropParametricRange, max, 1);
}
void ParametricParamDescriptor::setDimension(const int dimension)
{
_paramProps.propSetInt(kOfxParamPropParametricDimension, dimension);
}
void ParametricParamDescriptor::setDimensionLabel(const std::string& label, const int id)
{
_paramProps.propSetString(kOfxParamPropDimensionLabel, label, id);
}
void ParametricParamDescriptor::setUIColour(const int id, const OfxRGBColourD& color)
{
_paramProps.propSetDouble(kOfxParamPropParametricUIColour, color.r, id*3 + 0);
_paramProps.propSetDouble(kOfxParamPropParametricUIColour, color.g, id*3 + 1);
_paramProps.propSetDouble(kOfxParamPropParametricUIColour, color.b, id*3 + 2);
}
void ParametricParamDescriptor::addControlPoint(const int id, const OfxTime time, const double x, const double y, const bool addKey)
{
OFX::Private::gParametricParameterSuite->parametricParamAddControlPoint(_ofxParamHandle, id, time, x, y, addKey);
}
void ParametricParamDescriptor::setIdentity(const int id)
{
addControlPoint(id, 0, 0, 0, false);
addControlPoint(id, 0, 1, 1, false);
}
void ParametricParamDescriptor::setIdentity()
{
const int nbCurves = _paramProps.propGetInt(kOfxParamPropParametricDimension);
for(int i = 0; i < nbCurves; ++i) {
setIdentity(i);
}
}
void ParametricParamDescriptor::setInteractDescriptor(ParamInteractDescriptor* desc)
{
_interact.reset(desc);
_paramProps.propSetPointer(kOfxParamPropParametricInteractBackground, (void*)desc->getMainEntry());
desc->setParamName(getName());
}
ParamSetDescriptor::ParamSetDescriptor(void)
: _paramSetHandle(0)
{
}
ParamDescriptor* ParamSetDescriptor::getParamDescriptor(const std::string& name) const
{
std::map<std::string, ParamDescriptor*>::const_iterator it = _definedParams.find(name);
if(it!=_definedParams.end())
return it->second;
return 0;
}
void
ParamSetDescriptor::setParamSetHandle(OfxParamSetHandle h)
{
_paramSetHandle = h;
if(h) {
OfxPropertySetHandle props;
OfxStatus stat = OFX::Private::gParamSuite->paramSetGetPropertySet(h, &props);
_paramSetProps.propSetHandle(props);
throwSuiteStatusException(stat);
}
else {
_paramSetProps.propSetHandle(0);
}
}
ParamSetDescriptor::~ParamSetDescriptor()
{
std::map<std::string, ParamDescriptor *>::iterator iter;
for(iter = _definedParams.begin(); iter != _definedParams.end(); ++iter) {
if(iter->second) {
delete iter->second;
iter->second = NULL;
}
}
}
void
ParamSetDescriptor::setPageParamOrder(PageParamDescriptor &p)
{
int nPages = _paramSetProps.propGetDimension(kOfxPluginPropParamPageOrder);
_paramSetProps.propSetString(kOfxPluginPropParamPageOrder, p.getName().c_str(), nPages);
}
void ParamSetDescriptor::defineRawParam(const std::string &name, ParamTypeEnum paramType, OfxPropertySetHandle &props)
{
OfxStatus stat = OFX::Private::gParamSuite->paramDefine(_paramSetHandle, mapParamTypeEnumToString(paramType), name.c_str(), &props);
throwSuiteStatusException(stat);
}
ParamDescriptor *
ParamSetDescriptor::findPreviouslyDefinedParam(const std::string &name)
{
std::map<std::string, ParamDescriptor *>::const_iterator search;
search = _definedParams.find(name);
if(search == _definedParams.end())
return NULL;
return search->second;
}
IntParamDescriptor *
ParamSetDescriptor::defineIntParam(const std::string &name)
{
IntParamDescriptor *param = NULL;
defineParamDescriptor(name, eIntParam, param);
return param;
}
Int2DParamDescriptor *ParamSetDescriptor::defineInt2DParam(const std::string &name)
{
Int2DParamDescriptor *param = NULL;
defineParamDescriptor(name, eInt2DParam, param);
return param;
}
Int3DParamDescriptor *ParamSetDescriptor::defineInt3DParam(const std::string &name)
{
Int3DParamDescriptor *param = NULL;
defineParamDescriptor(name, eInt3DParam, param);
return param;
}
DoubleParamDescriptor *
ParamSetDescriptor::defineDoubleParam(const std::string &name)
{
DoubleParamDescriptor *param = NULL;
defineParamDescriptor(name, eDoubleParam, param);
return param;
}
Double2DParamDescriptor *ParamSetDescriptor::defineDouble2DParam(const std::string &name)
{
Double2DParamDescriptor *param = NULL;
defineParamDescriptor(name, eDouble2DParam, param);
return param;
}
Double3DParamDescriptor *ParamSetDescriptor::defineDouble3DParam(const std::string &name)
{
Double3DParamDescriptor *param = NULL;
defineParamDescriptor(name, eDouble3DParam, param);
return param;
}
StringParamDescriptor *ParamSetDescriptor::defineStringParam(const std::string &name)
{
StringParamDescriptor *param = NULL;
defineParamDescriptor(name, eStringParam, param);
return param;
}
RGBAParamDescriptor *ParamSetDescriptor::defineRGBAParam(const std::string &name)
{
RGBAParamDescriptor *param = NULL;
defineParamDescriptor(name, eRGBAParam, param);
return param;
}
RGBParamDescriptor *ParamSetDescriptor::defineRGBParam(const std::string &name)
{
RGBParamDescriptor *param = NULL;
defineParamDescriptor(name, eRGBParam, param);
return param;
}
BooleanParamDescriptor *ParamSetDescriptor::defineBooleanParam(const std::string &name)
{
BooleanParamDescriptor *param = NULL;
defineParamDescriptor(name, eBooleanParam, param);
return param;
}
ChoiceParamDescriptor *ParamSetDescriptor::defineChoiceParam(const std::string &name)
{
ChoiceParamDescriptor *param = NULL;
defineParamDescriptor(name, eChoiceParam, param);
return param;
}
GroupParamDescriptor *ParamSetDescriptor::defineGroupParam(const std::string &name)
{
GroupParamDescriptor *param = NULL;
defineParamDescriptor(name, eGroupParam, param);
return param;
}
PageParamDescriptor *ParamSetDescriptor::definePageParam(const std::string &name)
{
PageParamDescriptor *param = NULL;
defineParamDescriptor(name, ePageParam, param);
return param;
}
PushButtonParamDescriptor *ParamSetDescriptor::definePushButtonParam(const std::string &name)
{
PushButtonParamDescriptor *param = NULL;
defineParamDescriptor(name, ePushButtonParam, param);
return param;
}
ParametricParamDescriptor* ParamSetDescriptor::defineParametricParam(const std::string &name)
{
ParametricParamDescriptor* param = NULL;
if (defineParamDescriptor(name, eParametricParam, param)) {
param->setParamSet(*this);
}
return param;
}
CustomParamDescriptor *ParamSetDescriptor::defineCustomParam(const std::string &name)
{
CustomParamDescriptor *param = NULL;
defineParamDescriptor(name, eCustomParam, param);
return param;
}
Param::Param(const ParamSet *paramSet, const std::string &name, ParamTypeEnum type, OfxParamHandle handle)
: _paramSet(paramSet)
, _paramName(name)
, _paramType(type)
, _paramHandle(handle)
{
OfxPropertySetHandle propHandle;
OfxStatus stat = OFX::Private::gParamSuite->paramGetPropertySet(handle, &propHandle);
throwSuiteStatusException(stat);
_paramProps.propSetHandle(propHandle);
OFX::Validation::validateParameterProperties(type, _paramProps, false);
}
Param::~Param()
{
}
const std::string &Param::getName(void) const
{
return _paramName;
}
void Param::setLabel(const std::string &label)
{
_paramProps.propSetString(kOfxPropLabel, label);
}
void Param::setLabels(const std::string &label, const std::string &shortLabel, const std::string &longLabel)
{
setLabel(label);
_paramProps.propSetString(kOfxPropShortLabel, shortLabel, false);
_paramProps.propSetString(kOfxPropLongLabel, longLabel, false);
}
void Param::setIsSecret(bool v)
{
_paramProps.propSetInt(kOfxParamPropSecret, v);
}
void Param::setHint(const std::string &v)
{
_paramProps.propSetString(kOfxParamPropHint, v, false);
}
void Param::setEnabled(bool v)
{
_paramProps.propSetInt(kOfxParamPropEnabled, v);
}
void Param::setDataPtr(void* ptr)
{
_paramProps.propSetPointer(kOfxParamPropDataPtr, ptr);
}
void Param::getLabel(std::string &label) const
{
label = _paramProps.propGetString(kOfxPropLabel);
}
void Param::getLabels(std::string &label, std::string &shortLabel, std::string &longLabel) const
{
getLabel(label);
shortLabel = _paramProps.propGetString(kOfxPropShortLabel, false);
longLabel = _paramProps.propGetString(kOfxPropLongLabel, false);
}
bool Param::getIsSecret(void) const
{
bool v = _paramProps.propGetInt(kOfxParamPropSecret) != 0;
return v;
}
bool Param::getIsEnable(void) const
{
bool v = _paramProps.propGetInt(kOfxParamPropEnabled) != 0;
return v;
}
void* Param::getDataPtr(void) const
{
return _paramProps.propGetPointer(kOfxParamPropDataPtr);
}
std::string Param::getHint(void) const
{
std::string v = _paramProps.propGetString(kOfxParamPropHint, false);
return v;
}
std::string Param::getScriptName(void) const
{
std::string v = _paramProps.propGetString(kOfxParamPropScriptName, false);
return v;
}
GroupParam *Param::getParent(void) const
{
std::string v = _paramProps.propGetString(kOfxParamPropParent);
if(v == "") return NULL;
return _paramSet->fetchGroupParam(v);
}
std::string Param::getIcon(bool pngFormat) const
{
std::string v = _paramProps.propGetString(kOfxPropIcon, (int)pngFormat, false); return v;
}
bool Param::getHostHasNativeOverlayHandle() const
{
bool v = _paramProps.propGetInt(kOfxParamPropHasHostOverlayHandle, 0, false) != 0; return v;
}
ValueParam::ValueParam(const ParamSet *paramSet, const std::string &name, ParamTypeEnum type, OfxParamHandle handle)
: Param(paramSet, name, type, handle)
{
}
ValueParam::~ValueParam()
{
}
void
ValueParam::setEvaluateOnChange(bool v)
{
_paramProps.propSetInt(kOfxParamPropEvaluateOnChange, v);
}
bool
ValueParam::getIsAnimating(void) const
{
return _paramProps.propGetInt(kOfxParamPropIsAnimating) != 0;
}
bool
ValueParam::getIsAutoKeying(void) const
{
return _paramProps.propGetInt(kOfxParamPropIsAutoKeying) != 0;
}
bool
ValueParam::getIsPersistant(void) const
{
return _paramProps.propGetInt(kOfxParamPropPersistant) != 0;
}
bool
ValueParam::getEvaluateOnChange(void) const
{
return _paramProps.propGetInt(kOfxParamPropEvaluateOnChange) != 0;
}
CacheInvalidationEnum
ValueParam::getCacheInvalidation(void) const
{
std::string v = _paramProps.propGetString(kOfxParamPropCacheInvalidation);
if(v == kOfxParamInvalidateValueChange)
return eCacheInvalidateValueChange;
else if(v == kOfxParamInvalidateValueChangeToEnd)
return eCacheInvalidateValueChangeToEnd;
else return eCacheInvalidateValueAll;
}
unsigned int
ValueParam::getNumKeys(void)
{
if(!OFX::Private::gParamSuite->paramGetNumKeys) throwHostMissingSuiteException("paramGetNumKeys");
unsigned int v = 0;
OfxStatus stat = OFX::Private::gParamSuite->paramGetNumKeys(_paramHandle, &v);
throwSuiteStatusException(stat);
return v;
}
double
ValueParam::getKeyTime(int nthKey) throw(OFX::Exception::Suite, std::out_of_range)
{
if(!OFX::Private::gParamSuite->paramGetKeyTime) throwHostMissingSuiteException("paramGetKeyTime");
double v = 0;
OfxStatus stat = OFX::Private::gParamSuite->paramGetKeyTime(_paramHandle, nthKey, &v);
if(stat == kOfxStatFailed) throw std::out_of_range("ValueParam::getKeyTime key index out of range");
throwSuiteStatusException(stat);
return v;
}
int
ValueParam::getKeyIndex(double time,
KeySearchEnum searchDir)
{
if(!OFX::Private::gParamSuite->paramGetKeyIndex) throwHostMissingSuiteException("paramGetKeyIndex");
int v = 0;
int dir = searchDir == eKeySearchBackwards ? -1 : (searchDir == eKeySearchNear ? 0 : 1);
OfxStatus stat = OFX::Private::gParamSuite->paramGetKeyIndex(_paramHandle, time, dir, &v);
if(stat == kOfxStatFailed) return -1; throwSuiteStatusException(stat);
return v;
}
void
ValueParam::deleteKeyAtTime(double time)
{
if(!OFX::Private::gParamSuite->paramDeleteKey) throwHostMissingSuiteException("paramDeleteKey");
OfxStatus stat = OFX::Private::gParamSuite->paramDeleteKey(_paramHandle, time);
if(stat == kOfxStatFailed) return; throwSuiteStatusException(stat);
}
void
ValueParam::deleteAllKeys(void)
{
if(!OFX::Private::gParamSuite->paramDeleteAllKeys) throwHostMissingSuiteException("paramDeleteAllKeys");
OfxStatus stat = OFX::Private::gParamSuite->paramDeleteAllKeys(_paramHandle);
throwSuiteStatusException(stat);
}
void ValueParam::copyFrom(const ValueParam& from, OfxTime dstOffset, const OfxRangeD *frameRange)
{
if(!OFX::Private::gParamSuite->paramCopy) throwHostMissingSuiteException("paramCopy");
OfxStatus stat = OFX::Private::gParamSuite->paramCopy(_paramHandle, from._paramHandle, dstOffset, frameRange);
throwSuiteStatusException(stat);
}
IntParam::IntParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: ValueParam(paramSet, name, eIntParam, handle)
{
}
void IntParam::setDefault(int v)
{
_paramProps.propSetInt(kOfxParamPropDefault, v);
}
void IntParam::setRange(int min, int max)
{
_paramProps.propSetInt(kOfxParamPropMin, min);
_paramProps.propSetInt(kOfxParamPropMax, max);
}
void IntParam::setDisplayRange(int min, int max)
{
_paramProps.propSetInt(kOfxParamPropDisplayMin, min);
_paramProps.propSetInt(kOfxParamPropDisplayMax, max);
}
void IntParam::getDefault(int &v)
{
v = _paramProps.propGetInt(kOfxParamPropDefault);
}
void IntParam::getRange(int &min, int &max)
{
min = _paramProps.propGetInt(kOfxParamPropMin);
max = _paramProps.propGetInt(kOfxParamPropMax);
}
void IntParam::getDisplayRange(int &min, int &max)
{
min = _paramProps.propGetInt(kOfxParamPropDisplayMin);
max = _paramProps.propGetInt(kOfxParamPropDisplayMax);
}
void IntParam::getValue(int &v)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &v);
throwSuiteStatusException(stat);
}
void IntParam::getValueAtTime(double t, int &v)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &v);
throwSuiteStatusException(stat);
}
void IntParam::setValue(int v)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, v);
throwSuiteStatusException(stat);
}
void IntParam::setValueAtTime(double t, int v)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, v);
throwSuiteStatusException(stat);
}
Int2DParam::Int2DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: ValueParam(paramSet, name, eInt2DParam, handle)
{
}
void Int2DParam::setDefault(int x, int y)
{
_paramProps.propSetInt(kOfxParamPropDefault, x, 0);
_paramProps.propSetInt(kOfxParamPropDefault, y, 1);
}
void
Int2DParam::setRange(int xmin, int ymin,
int xmax, int ymax)
{
_paramProps.propSetInt(kOfxParamPropMin, xmin, 0);
_paramProps.propSetInt(kOfxParamPropMin, ymin, 1);
_paramProps.propSetInt(kOfxParamPropMax, xmax, 0);
_paramProps.propSetInt(kOfxParamPropMax, ymax, 1);
}
void
Int2DParam::setDisplayRange(int xmin, int ymin,
int xmax, int ymax)
{
_paramProps.propSetInt(kOfxParamPropDisplayMin, xmin, 0);
_paramProps.propSetInt(kOfxParamPropDisplayMin, ymin, 1);
_paramProps.propSetInt(kOfxParamPropDisplayMax, xmax, 0);
_paramProps.propSetInt(kOfxParamPropDisplayMax, ymax, 1);
}
void Int2DParam::getDefault(int &x, int &y)
{
x = _paramProps.propGetInt(kOfxParamPropDefault, 0);
y = _paramProps.propGetInt(kOfxParamPropDefault, 1);
}
void
Int2DParam::getRange(int &xmin, int &ymin,
int &xmax, int &ymax)
{
xmin = _paramProps.propGetInt(kOfxParamPropMin, 0);
ymin = _paramProps.propGetInt(kOfxParamPropMin, 1);
xmax = _paramProps.propGetInt(kOfxParamPropMax, 0);
ymax = _paramProps.propGetInt(kOfxParamPropMax, 1);
}
void
Int2DParam::getDisplayRange(int &xmin, int &ymin,
int &xmax, int &ymax)
{
xmin = _paramProps.propGetInt(kOfxParamPropDisplayMin, 0);
ymin = _paramProps.propGetInt(kOfxParamPropDisplayMin, 1);
xmax = _paramProps.propGetInt(kOfxParamPropDisplayMax, 0);
ymax = _paramProps.propGetInt(kOfxParamPropDisplayMax, 1);
}
void Int2DParam::getValue(int &x, int &y)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &x, &y);
throwSuiteStatusException(stat);
}
void Int2DParam::getValueAtTime(double t, int &x, int &y)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &x, &y);
throwSuiteStatusException(stat);
}
void Int2DParam::setValue(int x, int y)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, x, y);
throwSuiteStatusException(stat);
}
void Int2DParam::setValueAtTime(double t, int x, int y)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, x, y);
throwSuiteStatusException(stat);
}
Int3DParam::Int3DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: ValueParam(paramSet, name, eInt3DParam, handle)
{
}
void Int3DParam::setDefault(int x, int y, int z)
{
_paramProps.propSetInt(kOfxParamPropDefault, x, 0);
_paramProps.propSetInt(kOfxParamPropDefault, y, 1);
_paramProps.propSetInt(kOfxParamPropDefault, z, 2);
}
void
Int3DParam::setRange(int xmin, int ymin, int zmin,
int xmax, int ymax, int zmax)
{
_paramProps.propSetInt(kOfxParamPropMin, xmin, 0);
_paramProps.propSetInt(kOfxParamPropMin, ymin, 1);
_paramProps.propSetInt(kOfxParamPropMin, zmin, 2);
_paramProps.propSetInt(kOfxParamPropMax, xmax, 0);
_paramProps.propSetInt(kOfxParamPropMax, ymax, 1);
_paramProps.propSetInt(kOfxParamPropMax, zmax, 2);
}
void
Int3DParam::setDisplayRange(int xmin, int ymin, int zmin,
int xmax, int ymax, int zmax)
{
_paramProps.propSetInt(kOfxParamPropDisplayMin, xmin, 0);
_paramProps.propSetInt(kOfxParamPropDisplayMin, ymin, 1);
_paramProps.propSetInt(kOfxParamPropDisplayMin, zmin, 2);
_paramProps.propSetInt(kOfxParamPropDisplayMax, xmax, 0);
_paramProps.propSetInt(kOfxParamPropDisplayMax, ymax, 1);
_paramProps.propSetInt(kOfxParamPropDisplayMax, zmax, 2);
}
void Int3DParam::getDefault(int &x, int &y, int &z)
{
x = _paramProps.propGetInt(kOfxParamPropDefault, 0);
y = _paramProps.propGetInt(kOfxParamPropDefault, 1);
z = _paramProps.propGetInt(kOfxParamPropDefault, 2);
}
void
Int3DParam::getRange(int &xmin, int &ymin, int &zmin,
int &xmax, int &ymax, int &zmax)
{
xmin = _paramProps.propGetInt(kOfxParamPropMin, 0);
ymin = _paramProps.propGetInt(kOfxParamPropMin, 1);
zmin = _paramProps.propGetInt(kOfxParamPropMin, 2);
xmax = _paramProps.propGetInt(kOfxParamPropMax, 0);
ymax = _paramProps.propGetInt(kOfxParamPropMax, 1);
zmax = _paramProps.propGetInt(kOfxParamPropMax, 2);
}
void
Int3DParam::getDisplayRange(int &xmin, int &ymin, int &zmin,
int &xmax, int &ymax, int &zmax)
{
xmin = _paramProps.propGetInt(kOfxParamPropDisplayMin, 0);
ymin = _paramProps.propGetInt(kOfxParamPropDisplayMin, 1);
zmin = _paramProps.propGetInt(kOfxParamPropDisplayMin, 2);
xmax = _paramProps.propGetInt(kOfxParamPropDisplayMax, 0);
ymax = _paramProps.propGetInt(kOfxParamPropDisplayMax, 1);
zmax = _paramProps.propGetInt(kOfxParamPropDisplayMax, 2);
}
void Int3DParam::getValue(int &x, int &y, int &z)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &x, &y, &z);
throwSuiteStatusException(stat);
}
void Int3DParam::getValueAtTime(double t, int &x, int &y, int &z)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &x, &y, &z);
throwSuiteStatusException(stat);
}
void Int3DParam::setValue(int x, int y, int z)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, x, y, z);
throwSuiteStatusException(stat);
}
void Int3DParam::setValueAtTime(double t, int x, int y, int z)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, x, y, z);
throwSuiteStatusException(stat);
}
BaseDoubleParam::BaseDoubleParam(const ParamSet *paramSet, const std::string &name, ParamTypeEnum type, OfxParamHandle handle)
: ValueParam(paramSet, name, type, handle)
{
}
void BaseDoubleParam::setIncrement(double v)
{
_paramProps.propSetDouble(kOfxParamPropIncrement, v);
}
void BaseDoubleParam::setDigits(int v)
{
_paramProps.propSetInt(kOfxParamPropDigits, v);
}
void BaseDoubleParam::getIncrement(double &v)
{
v = _paramProps.propGetDouble(kOfxParamPropIncrement);
}
void BaseDoubleParam::getDigits(int &v)
{
v = _paramProps.propGetInt(kOfxParamPropDigits);
}
void BaseDoubleParam::getDoubleType(DoubleTypeEnum &v)
{
std::string str = _paramProps.propGetString(kOfxParamPropDoubleType);
if(str == kOfxParamDoubleTypePlain)
v = eDoubleTypePlain;
else if(str == kOfxParamDoubleTypeAngle)
v = eDoubleTypeAngle;
else if(str == kOfxParamDoubleTypeScale)
v = eDoubleTypeScale;
else if(str == kOfxParamDoubleTypeTime)
v = eDoubleTypeTime;
else if(str == kOfxParamDoubleTypeAbsoluteTime)
v = eDoubleTypeAbsoluteTime;
else if(str == kOfxParamDoubleTypeX)
v = eDoubleTypeX;
else if(str == kOfxParamDoubleTypeXAbsolute)
v = eDoubleTypeXAbsolute;
else if(str == kOfxParamDoubleTypeY)
v = eDoubleTypeY;
else if(str == kOfxParamDoubleTypeYAbsolute)
v = eDoubleTypeYAbsolute;
else if(str == kOfxParamDoubleTypeXY)
v = eDoubleTypeXY;
else if(str == kOfxParamDoubleTypeXYAbsolute)
v = eDoubleTypeXYAbsolute;
#ifdef kOfxParamDoubleTypeNormalisedX
else if(str == kOfxParamDoubleTypeNormalisedX)
v = eDoubleTypeNormalisedX;
else if(str == kOfxParamDoubleTypeNormalisedY)
v = eDoubleTypeNormalisedY;
else if(str == kOfxParamDoubleTypeNormalisedXAbsolute)
v = eDoubleTypeNormalisedXAbsolute;
else if(str == kOfxParamDoubleTypeNormalisedYAbsolute)
v = eDoubleTypeNormalisedYAbsolute;
else if(str == kOfxParamDoubleTypeNormalisedXY)
v = eDoubleTypeNormalisedXY;
else if(str == kOfxParamDoubleTypeNormalisedXYAbsolute)
v = eDoubleTypeNormalisedXYAbsolute;
#endif
else
v = eDoubleTypePlain;
}
void BaseDoubleParam::getDefaultCoordinateSystem(DefaultCoordinateSystemEnum &v)
{
std::string str = _paramProps.propGetString(kOfxParamPropDefaultCoordinateSystem);
if(str == kOfxParamCoordinatesNormalised)
v = eCoordinatesNormalised;
else
v = eCoordinatesCanonical;
}
DoubleParam::DoubleParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: BaseDoubleParam(paramSet, name, eDoubleParam, handle)
{
}
void DoubleParam::setDefault(double v)
{
_paramProps.propSetDouble(kOfxParamPropDefault, v);
}
void DoubleParam::setRange(double min, double max)
{
_paramProps.propSetDouble(kOfxParamPropMin, min);
_paramProps.propSetDouble(kOfxParamPropMax, max);
}
void DoubleParam::setDisplayRange(double min, double max)
{
_paramProps.propSetDouble(kOfxParamPropDisplayMin, min);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, max);
}
void DoubleParam::getDefault(double &v)
{
v = _paramProps.propGetDouble(kOfxParamPropDefault);
}
void DoubleParam::getRange(double &min, double &max)
{
min = _paramProps.propGetDouble(kOfxParamPropMin);
max = _paramProps.propGetDouble(kOfxParamPropMax);
}
void DoubleParam::getDisplayRange(double &min, double &max)
{
min = _paramProps.propGetDouble(kOfxParamPropDisplayMin);
max = _paramProps.propGetDouble(kOfxParamPropDisplayMax);
}
void DoubleParam::getValue(double &v)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &v);
throwSuiteStatusException(stat);
}
void DoubleParam::getValueAtTime(double t, double &v)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &v);
throwSuiteStatusException(stat);
}
void DoubleParam::setValue(double v)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, v);
throwSuiteStatusException(stat);
}
void DoubleParam::setValueAtTime(double t, double v)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, v);
throwSuiteStatusException(stat);
}
void DoubleParam::differentiate(double t, double &v)
{
if(!OFX::Private::gParamSuite->paramGetDerivative) throwHostMissingSuiteException("paramGetDerivative");
OfxStatus stat = OFX::Private::gParamSuite->paramGetDerivative(_paramHandle, t, &v);
throwSuiteStatusException(stat);
}
void DoubleParam::integrate(double t1, double t2, double &v)
{
if(!OFX::Private::gParamSuite->paramGetIntegral) throwHostMissingSuiteException("paramGetIntegral");
OfxStatus stat = OFX::Private::gParamSuite->paramGetIntegral(_paramHandle, t1, t2, &v);
throwSuiteStatusException(stat);
}
Double2DParam::Double2DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: BaseDoubleParam(paramSet, name, eDouble2DParam, handle)
{
}
void Double2DParam::setDefault(double x, double y)
{
_paramProps.propSetDouble(kOfxParamPropDefault, x, 0);
_paramProps.propSetDouble(kOfxParamPropDefault, y, 1);
}
void
Double2DParam::setRange(double xmin, double ymin,
double xmax, double ymax)
{
_paramProps.propSetDouble(kOfxParamPropMin, xmin, 0);
_paramProps.propSetDouble(kOfxParamPropMin, ymin, 1);
_paramProps.propSetDouble(kOfxParamPropMax, xmax, 0);
_paramProps.propSetDouble(kOfxParamPropMax, ymax, 1);
}
void
Double2DParam::setDisplayRange(double xmin, double ymin,
double xmax, double ymax)
{
_paramProps.propSetDouble(kOfxParamPropDisplayMin, xmin, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMin, ymin, 1);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, xmax, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, ymax, 1);
}
void Double2DParam::getDefault(double &x, double &y)
{
x = _paramProps.propGetDouble(kOfxParamPropDefault, 0);
y = _paramProps.propGetDouble(kOfxParamPropDefault, 1);
}
void
Double2DParam::getRange(double &xmin, double &ymin,
double &xmax, double &ymax)
{
xmin = _paramProps.propGetDouble(kOfxParamPropMin, 0);
ymin = _paramProps.propGetDouble(kOfxParamPropMin, 1);
xmax = _paramProps.propGetDouble(kOfxParamPropMax, 0);
ymax = _paramProps.propGetDouble(kOfxParamPropMax, 1);
}
void
Double2DParam::getDisplayRange(double &xmin, double &ymin,
double &xmax, double &ymax)
{
xmin = _paramProps.propGetDouble(kOfxParamPropDisplayMin, 0);
ymin = _paramProps.propGetDouble(kOfxParamPropDisplayMin, 1);
xmax = _paramProps.propGetDouble(kOfxParamPropDisplayMax, 0);
ymax = _paramProps.propGetDouble(kOfxParamPropDisplayMax, 1);
}
void Double2DParam::getValue(double &x, double &y)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &x, &y);
throwSuiteStatusException(stat);
}
void Double2DParam::getValueAtTime(double t, double &x, double &y)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &x, &y);
throwSuiteStatusException(stat);
}
void Double2DParam::setValue(double x, double y)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, x, y);
throwSuiteStatusException(stat);
}
void Double2DParam::setValueAtTime(double t, double x, double y)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, x, y);
throwSuiteStatusException(stat);
}
void Double2DParam::differentiate(double t, double &x, double &y)
{
if(!OFX::Private::gParamSuite->paramGetDerivative) throwHostMissingSuiteException("paramGetDerivative");
OfxStatus stat = OFX::Private::gParamSuite->paramGetDerivative(_paramHandle, t, &x, &y);
throwSuiteStatusException(stat);
}
void Double2DParam::integrate(double t1, double t2, double &x, double &y)
{
if(!OFX::Private::gParamSuite->paramGetIntegral) throwHostMissingSuiteException("paramGetIntegral");
OfxStatus stat = OFX::Private::gParamSuite->paramGetIntegral(_paramHandle, t1, t2, &x, &y);
throwSuiteStatusException(stat);
}
Double3DParam::Double3DParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: BaseDoubleParam(paramSet, name, eDouble3DParam, handle)
{
}
void Double3DParam::setDefault(double x, double y, double z)
{
_paramProps.propSetDouble(kOfxParamPropDefault, x, 0);
_paramProps.propSetDouble(kOfxParamPropDefault, y, 1);
_paramProps.propSetDouble(kOfxParamPropDefault, z, 2);
}
void
Double3DParam::setRange(double xmin, double ymin, double zmin,
double xmax, double ymax, double zmax)
{
_paramProps.propSetDouble(kOfxParamPropMin, xmin, 0);
_paramProps.propSetDouble(kOfxParamPropMin, ymin, 1);
_paramProps.propSetDouble(kOfxParamPropMin, zmin, 2);
_paramProps.propSetDouble(kOfxParamPropMax, xmax, 0);
_paramProps.propSetDouble(kOfxParamPropMax, ymax, 1);
_paramProps.propSetDouble(kOfxParamPropMax, zmax, 2);
}
void
Double3DParam::setDisplayRange(double xmin, double ymin, double zmin,
double xmax, double ymax, double zmax)
{
_paramProps.propSetDouble(kOfxParamPropDisplayMin, xmin, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMin, ymin, 1);
_paramProps.propSetDouble(kOfxParamPropDisplayMin, zmin, 2);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, xmax, 0);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, ymax, 1);
_paramProps.propSetDouble(kOfxParamPropDisplayMax, zmax, 2);
}
void Double3DParam::getDefault(double &x, double &y, double &z)
{
x = _paramProps.propGetDouble(kOfxParamPropDefault, 0);
y = _paramProps.propGetDouble(kOfxParamPropDefault, 1);
z = _paramProps.propGetDouble(kOfxParamPropDefault, 2);
}
void
Double3DParam::getRange(double &xmin, double &ymin, double &zmin,
double &xmax, double &ymax, double &zmax)
{
xmin = _paramProps.propGetDouble(kOfxParamPropMin, 0);
ymin = _paramProps.propGetDouble(kOfxParamPropMin, 1);
zmin = _paramProps.propGetDouble(kOfxParamPropMin, 2);
xmax = _paramProps.propGetDouble(kOfxParamPropMax, 0);
ymax = _paramProps.propGetDouble(kOfxParamPropMax, 1);
zmax = _paramProps.propGetDouble(kOfxParamPropMax, 2);
}
void
Double3DParam::getDisplayRange(double &xmin, double &ymin, double &zmin,
double &xmax, double &ymax, double &zmax)
{
xmin = _paramProps.propGetDouble(kOfxParamPropDisplayMin, 0);
ymin = _paramProps.propGetDouble(kOfxParamPropDisplayMin, 1);
zmin = _paramProps.propGetDouble(kOfxParamPropDisplayMin, 2);
xmax = _paramProps.propGetDouble(kOfxParamPropDisplayMax, 0);
ymax = _paramProps.propGetDouble(kOfxParamPropDisplayMax, 1);
zmax = _paramProps.propGetDouble(kOfxParamPropDisplayMax, 2);
}
void Double3DParam::getValue(double &x, double &y, double &z)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &x, &y, &z);
throwSuiteStatusException(stat);
}
void Double3DParam::getValueAtTime(double t, double &x, double &y, double &z)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &x, &y, &z);
throwSuiteStatusException(stat);
}
void Double3DParam::setValue(double x, double y, double z)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, x, y, z);
throwSuiteStatusException(stat);
}
void Double3DParam::setValueAtTime(double t, double x, double y, double z)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, x, y, z);
throwSuiteStatusException(stat);
}
void Double3DParam::differentiate(double t, double &x, double &y, double &z)
{
if(!OFX::Private::gParamSuite->paramGetDerivative) throwHostMissingSuiteException("paramGetDerivative");
OfxStatus stat = OFX::Private::gParamSuite->paramGetDerivative(_paramHandle, t, &x, &y, &z);
throwSuiteStatusException(stat);
}
void Double3DParam::integrate(double t1, double t2, double &x, double &y, double &z)
{
if(!OFX::Private::gParamSuite->paramGetIntegral) throwHostMissingSuiteException("paramGetIntegral");
OfxStatus stat = OFX::Private::gParamSuite->paramGetIntegral(_paramHandle, t1, t2, &x, &y, &z);
throwSuiteStatusException(stat);
}
RGBParam::RGBParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: ValueParam(paramSet, name, eRGBParam, handle)
{
}
void RGBParam::setDefault(double r, double g, double b)
{
_paramProps.propSetDouble(kOfxParamPropDefault, r, 0);
_paramProps.propSetDouble(kOfxParamPropDefault, g, 1);
_paramProps.propSetDouble(kOfxParamPropDefault, b, 2);
}
void RGBParam::getDefault(double &r, double &g, double &b)
{
r = _paramProps.propGetDouble(kOfxParamPropDefault, 0);
g = _paramProps.propGetDouble(kOfxParamPropDefault, 1);
b = _paramProps.propGetDouble(kOfxParamPropDefault, 2);
}
void RGBParam::getValue(double &r, double &g, double &b)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &r, &g, &b);
throwSuiteStatusException(stat);
}
void RGBParam::getValueAtTime(double t, double &r, double &g, double &b)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &r, &g, &b);
throwSuiteStatusException(stat);
}
void RGBParam::setValue(double r, double g, double b)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, r, g, b);
throwSuiteStatusException(stat);
}
void RGBParam::setValueAtTime(double t, double r, double g, double b)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, r, g, b);
throwSuiteStatusException(stat);
}
RGBAParam::RGBAParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: ValueParam(paramSet, name, eRGBAParam, handle)
{
}
void RGBAParam::setDefault(double r, double g, double b, double a)
{
_paramProps.propSetDouble(kOfxParamPropDefault, r, 0);
_paramProps.propSetDouble(kOfxParamPropDefault, g, 1);
_paramProps.propSetDouble(kOfxParamPropDefault, b, 2);
_paramProps.propSetDouble(kOfxParamPropDefault, a, 3);
}
void RGBAParam::getDefault(double &r, double &g, double &b, double &a)
{
r = _paramProps.propGetDouble(kOfxParamPropDefault, 0);
g = _paramProps.propGetDouble(kOfxParamPropDefault, 1);
b = _paramProps.propGetDouble(kOfxParamPropDefault, 2);
a = _paramProps.propGetDouble(kOfxParamPropDefault, 3);
}
void RGBAParam::getValue(double &r, double &g, double &b, double &a)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &r, &g, &b, &a);
throwSuiteStatusException(stat);
}
void RGBAParam::getValueAtTime(double t, double &r, double &g, double &b, double &a)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &r, &g, &b, &a);
throwSuiteStatusException(stat);
}
void RGBAParam::setValue(double r, double g, double b, double a)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, r, g, b, a);
throwSuiteStatusException(stat);
}
void RGBAParam::setValueAtTime(double t, double r, double g, double b, double a)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, r, g, b, a);
throwSuiteStatusException(stat);
}
StringParam::StringParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: ValueParam(paramSet, name, eStringParam, handle)
{
}
void StringParam::setDefault(const std::string &v)
{
_paramProps.propSetString(kOfxParamPropDefault, v);
}
void StringParam::getDefault(std::string &v)
{
v = _paramProps.propGetString(kOfxParamPropDefault);
}
void StringParam::getValue(std::string &v)
{
char *cStr;
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &cStr);
throwSuiteStatusException(stat);
v = cStr;
}
void StringParam::getValueAtTime(double t, std::string &v)
{
char *cStr;
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &cStr);
throwSuiteStatusException(stat);
v = cStr;
}
void StringParam::setValue(const std::string &v)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, v.c_str());
throwSuiteStatusException(stat);
}
void StringParam::setValueAtTime(double t, const std::string &v)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, v.c_str());
throwSuiteStatusException(stat);
}
BooleanParam::BooleanParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: ValueParam(paramSet, name, eBooleanParam, handle)
{
}
void BooleanParam::setDefault(bool v)
{
_paramProps.propSetInt(kOfxParamPropDefault, v);
}
void BooleanParam::getDefault(bool &v)
{
v = _paramProps.propGetInt(kOfxParamPropDefault) != 0;
}
void BooleanParam::getValue(bool &v)
{
int iVal;
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &iVal);
throwSuiteStatusException(stat);
v = iVal != 0;
}
void BooleanParam::getValueAtTime(double t, bool &v)
{
int iVal;
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &iVal);
throwSuiteStatusException(stat);
v = iVal != 0;
}
void BooleanParam::setValue(bool v)
{
int iVal = v;
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, iVal);
throwSuiteStatusException(stat);
}
void BooleanParam::setValueAtTime(double t, bool v)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
int iVal = v;
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, iVal);
throwSuiteStatusException(stat);
}
ChoiceParam::ChoiceParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: ValueParam(paramSet, name, eChoiceParam, handle)
{
}
void ChoiceParam::setDefault(int v)
{
_paramProps.propSetInt(kOfxParamPropDefault, v);
}
void ChoiceParam::getDefault(int &v)
{
v = _paramProps.propGetInt(kOfxParamPropDefault);
}
void ChoiceParam::getValue(int &v)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &v);
throwSuiteStatusException(stat);
}
void ChoiceParam::getValueAtTime(double t, int &v)
{
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &v);
throwSuiteStatusException(stat);
}
void ChoiceParam::setValue(int v)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, v);
throwSuiteStatusException(stat);
}
void ChoiceParam::setValueAtTime(double t, int v)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, v);
throwSuiteStatusException(stat);
}
int ChoiceParam::getNOptions(void)
{
int nCurrentValues = _paramProps.propGetDimension(kOfxParamPropChoiceOption);
return nCurrentValues;
}
void ChoiceParam::getOption(int ix, std::string &v)
{
v = _paramProps.propGetString(kOfxParamPropChoiceOption, ix);
}
void ChoiceParam::appendOption(const std::string &v, const std::string& label)
{
int nCurrentValues = _paramProps.propGetDimension(kOfxParamPropChoiceOption);
_paramProps.propSetString(kOfxParamPropChoiceOption, v, nCurrentValues);
if(!label.empty()) {
{
std::string hint = _paramProps.propGetString(kOfxParamPropHint);
if(!hint.empty()) {
hint += "\n";
if( nCurrentValues == 0 ) {
hint += "\n";
}
}
hint += v + ": " + label;
_paramProps.propSetString(kOfxParamPropHint, hint);
}
}
}
void ChoiceParam::setOption(int item, const std::string &str)
{
_paramProps.propSetString(kOfxParamPropChoiceOption, str, item);
}
void ChoiceParam::resetOptions(void)
{
_paramProps.propReset(kOfxParamPropChoiceOption);
}
CustomParam::CustomParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: ValueParam(paramSet, name, eCustomParam, handle)
{
}
void CustomParam::setDefault(const std::string &v)
{
_paramProps.propSetString(kOfxParamPropDefault, v);
}
void CustomParam::getDefault(std::string &v)
{
v = _paramProps.propGetString(kOfxParamPropDefault);
}
void CustomParam::getValue(std::string &v)
{
char *cStr;
OfxStatus stat = OFX::Private::gParamSuite->paramGetValue(_paramHandle, &cStr);
throwSuiteStatusException(stat);
v = cStr;
}
void CustomParam::getValueAtTime(double t, std::string &v)
{
char *cStr;
OfxStatus stat = OFX::Private::gParamSuite->paramGetValueAtTime(_paramHandle, t, &cStr);
throwSuiteStatusException(stat);
v = cStr;
}
void CustomParam::setValue(const std::string &v)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, v.c_str());
throwSuiteStatusException(stat);
}
void CustomParam::setValue(const char* str)
{
OfxStatus stat = OFX::Private::gParamSuite->paramSetValue(_paramHandle, str);
throwSuiteStatusException(stat);
}
void CustomParam::setValueAtTime(double t, const std::string &v)
{
if(!OFX::Private::gParamSuite->paramSetValueAtTime) throwHostMissingSuiteException("paramSetValueAtTime");
OfxStatus stat = OFX::Private::gParamSuite->paramSetValueAtTime(_paramHandle, t, v.c_str());
throwSuiteStatusException(stat);
}
GroupParam::GroupParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: Param(paramSet, name, eGroupParam, handle)
{
}
bool GroupParam::getIsOpen()
{
bool v = _paramProps.propGetInt(kOfxParamPropGroupOpen) != 0;
return v;
}
PageParam::PageParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: Param(paramSet, name, ePageParam, handle)
{
}
PushButtonParam::PushButtonParam(const ParamSet *paramSet, const std::string &name, OfxParamHandle handle)
: Param(paramSet, name, ePushButtonParam, handle)
{
}
ParametricParam::ParametricParam(const ParamSet* paramSet, const std::string &name, OfxParamHandle handle)
: Param(paramSet, name, eParametricParam, handle)
{}
double ParametricParam::getValue(const int curveIndex,
const OfxTime time,
const double parametricPosition)
{
double returnValue = 0.0;
OfxStatus stat = OFX::Private::gParametricParameterSuite->parametricParamGetValue(_paramHandle,
curveIndex,
time,
parametricPosition,
&returnValue);
throwSuiteStatusException(stat);
return returnValue;
}
int ParametricParam::getNControlPoints(const int curveIndex,
const OfxTime time)
{
int returnValue = 0;
OfxStatus stat = OFX::Private::gParametricParameterSuite->parametricParamGetNControlPoints(_paramHandle,
curveIndex,
time,
&returnValue);
throwSuiteStatusException(stat);
return returnValue;
}
std::pair<double, double> ParametricParam::getNthControlPoint(const int curveIndex,
const OfxTime time,
const int nthCtl)
{
std::pair<double, double> returnValue;
OfxStatus stat = OFX::Private::gParametricParameterSuite->parametricParamGetNthControlPoint(_paramHandle,
curveIndex,
time,
nthCtl,
&returnValue.first,
&returnValue.second);
throwSuiteStatusException(stat);
return returnValue;
}
void ParametricParam::setNthControlPoints(const int curveIndex,
const OfxTime time,
const int nthCtl,
const double key,
const double value,
const bool addAnimationKey)
{
OfxStatus stat = OFX::Private::gParametricParameterSuite->parametricParamSetNthControlPoint(_paramHandle,
curveIndex,
time,
nthCtl,
key,
value,
addAnimationKey);
throwSuiteStatusException(stat);
}
void ParametricParam::setNthControlPoints(const int curveIndex,
const OfxTime time,
const int nthCtl,
const std::pair<double, double> ctrlPoint,
const bool addAnimationKey)
{
setNthControlPoints(curveIndex,
time,
nthCtl,
ctrlPoint.first,
ctrlPoint.second,
addAnimationKey);
}
void ParametricParam::addControlPoint(const int curveIndex,
const OfxTime time,
const double key,
const double value,
const bool addAnimationKey)
{
OfxStatus stat = OFX::Private::gParametricParameterSuite->parametricParamAddControlPoint(_paramHandle, curveIndex, time, key, value, addAnimationKey);
throwSuiteStatusException(stat);
}
void ParametricParam::deleteControlPoint(const int curveIndex,
const int nthCtl)
{
OfxStatus stat = OFX::Private::gParametricParameterSuite->parametricParamDeleteControlPoint(_paramHandle, curveIndex, nthCtl);
throwSuiteStatusException(stat);
}
void ParametricParam::deleteControlPoint(const int curveIndex)
{
OfxStatus stat = OFX::Private::gParametricParameterSuite->parametricParamDeleteAllControlPoints(_paramHandle, curveIndex);
throwSuiteStatusException(stat);
}
ParamSet::ParamSet(void)
: _paramSetHandle(0)
{
}
void
ParamSet::setParamSetHandle(OfxParamSetHandle h)
{
_paramSetHandle = h;
if(h) {
OfxPropertySetHandle props;
OfxStatus stat = OFX::Private::gParamSuite->paramSetGetPropertySet(h, &props);
_paramSetProps.propSetHandle(props);
throwSuiteStatusException(stat);
}
else {
_paramSetProps.propSetHandle(0);
}
}
ParamSet::~ParamSet()
{
std::map<std::string, Param *>::iterator iter;
for(iter = _fetchedParams.begin(); iter != _fetchedParams.end(); ++iter) {
if(iter->second) {
delete iter->second;
iter->second = NULL;
}
}
}
void ParamSet::fetchRawParam(const std::string &name, ParamTypeEnum paramType, OfxParamHandle &handle) const
{
OfxPropertySetHandle propHandle;
OfxStatus stat = OFX::Private::gParamSuite->paramGetHandle(_paramSetHandle, name.c_str(), &handle, &propHandle);
throwSuiteStatusException(stat);
PropertySet props(propHandle);
std::string paramTypeStr = props.propGetString(kOfxParamPropType);
if(paramTypeStr != mapParamTypeEnumToString(paramType)) {
throw OFX::Exception::TypeRequest("Parameter exists but is of the wrong type");
}
}
ParamTypeEnum ParamSet::getParamType(const std::string& name) const
{
OfxPropertySetHandle propHandle;
OfxParamHandle handle;
OfxStatus stat = OFX::Private::gParamSuite->paramGetHandle(_paramSetHandle, name.c_str(), &handle, &propHandle);
throwSuiteStatusException(stat);
PropertySet props(propHandle);
std::string paramTypeStr = props.propGetString(kOfxParamPropType);
return mapParamTypeStringToEnum(paramTypeStr.c_str());
}
bool ParamSet::paramExists(const std::string& name) const
{
OfxParamHandle handle;
OfxPropertySetHandle propHandle;
OfxStatus stat = OFX::Private::gParamSuite->paramGetHandle(_paramSetHandle, name.c_str(), &handle, &propHandle);
if(stat!=kOfxStatOK)
return false;
return true;
}
Param* ParamSet::getParam(const std::string& name) const
{
OfxParamHandle handle;
OfxPropertySetHandle propHandle;
OfxStatus stat = OFX::Private::gParamSuite->paramGetHandle(_paramSetHandle, name.c_str(), &handle, &propHandle);
throwSuiteStatusException(stat);
PropertySet props(propHandle);
std::string paramTypeStr = props.propGetString(kOfxParamPropType);
ParamTypeEnum t = mapParamTypeStringToEnum(paramTypeStr.c_str());
switch(t)
{
case eStringParam :
{
StringParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eIntParam :
{
IntParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eInt2DParam :
{
Int2DParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eInt3DParam :
{
Int3DParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eDoubleParam :
{
DoubleParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eDouble2DParam :
{
Double2DParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eDouble3DParam :
{
Double3DParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eRGBParam :
{
RGBParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eRGBAParam :
{
RGBAParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eBooleanParam :
{
BooleanParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eChoiceParam :
{
ChoiceParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eCustomParam :
{
CustomParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eGroupParam :
{
GroupParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case ePageParam :
{
PageParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case ePushButtonParam :
{
PushButtonParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
case eParametricParam :
{
ParametricParam* ptr = 0;
fetchParam(name, t, ptr);
return ptr;
}
default:
assert(false);
}
return 0;
}
Param *
ParamSet::findPreviouslyFetchedParam(const std::string &name) const
{
std::map<std::string, Param *>::const_iterator search;
search = _fetchedParams.find(name);
if(search == _fetchedParams.end())
return NULL;
return search->second;
}
IntParam *
ParamSet::fetchIntParam(const std::string &name) const
{
IntParam *param = NULL;
fetchParam(name, eIntParam, param);
return param;
}
Int2DParam *ParamSet::fetchInt2DParam(const std::string &name) const
{
Int2DParam *param = NULL;
fetchParam(name, eInt2DParam, param);
return param;
}
Int3DParam *ParamSet::fetchInt3DParam(const std::string &name) const
{
Int3DParam *param = NULL;
fetchParam(name, eInt3DParam, param);
return param;
}
DoubleParam *
ParamSet::fetchDoubleParam(const std::string &name) const
{
DoubleParam *param = NULL;
fetchParam(name, eDoubleParam, param);
return param;
}
Double2DParam *ParamSet::fetchDouble2DParam(const std::string &name) const
{
Double2DParam *param = NULL;
fetchParam(name, eDouble2DParam, param);
return param;
}
Double3DParam *ParamSet::fetchDouble3DParam(const std::string &name) const
{
Double3DParam *param = NULL;
fetchParam(name, eDouble3DParam, param);
return param;
}
StringParam *ParamSet::fetchStringParam(const std::string &name) const
{
StringParam *param = NULL;
fetchParam(name, eStringParam, param);
return param;
}
RGBAParam *ParamSet::fetchRGBAParam(const std::string &name) const
{
RGBAParam *param = NULL;
fetchParam(name, eRGBAParam, param);
return param;
}
RGBParam *ParamSet::fetchRGBParam(const std::string &name) const
{
RGBParam *param = NULL;
fetchParam(name, eRGBParam, param);
return param;
}
BooleanParam *ParamSet::fetchBooleanParam(const std::string &name) const
{
BooleanParam *param = NULL;
fetchParam(name, eBooleanParam, param);
return param;
}
ChoiceParam *ParamSet::fetchChoiceParam(const std::string &name) const
{
ChoiceParam *param = NULL;
fetchParam(name, eChoiceParam, param);
return param;
}
GroupParam *ParamSet::fetchGroupParam(const std::string &name) const
{
GroupParam *param = NULL;
fetchParam(name, eGroupParam, param);
return param;
}
PageParam *ParamSet::fetchPageParam(const std::string &name) const
{
PageParam *param = NULL;
fetchParam(name, ePageParam, param);
return param;
}
PushButtonParam *ParamSet::fetchPushButtonParam(const std::string &name) const
{
PushButtonParam *param = NULL;
fetchParam(name, ePushButtonParam, param);
return param;
}
CustomParam *ParamSet::fetchCustomParam(const std::string &name) const
{
CustomParam *param = NULL;
fetchParam(name, eCustomParam, param);
return param;
}
ParametricParam *ParamSet::fetchParametricParam(const std::string &name) const
{
ParametricParam *param = NULL;
fetchParam(name, eParametricParam, param);
return param;
}
void ParamSet::beginEditBlock(const std::string &name)
{
OfxStatus stat = OFX::Private::gParamSuite->paramEditBegin(_paramSetHandle, name.c_str());
(void)stat;
}
void ParamSet::endEditBlock()
{
OfxStatus stat = OFX::Private::gParamSuite->paramEditEnd(_paramSetHandle);
(void)stat;
}
};