23 namespace SOP_AttribSwapEnums
35 using namespace UT::Literal;
55 using namespace UT::Literal;
74 using namespace UT::Literal;
104 srcattribs =
""_UTsh;
105 dstattribs =
""_UTsh;
112 if (enable != src.
enable)
return false;
113 if (method != src.
method)
return false;
114 if (_class != src.
_class)
return false;
115 if (srcattribs != src.
srcattribs)
return false;
116 if (dstattribs != src.
dstattribs)
return false;
117 if (typeinfo != src.
typeinfo)
return false;
133 for (
int i = 0; i < list.
entries(); i++)
139 buf.
appendSprintf(
"%s", (list(i).enable) ?
"true" :
"false");
161 myNumswaps.setSize(1);
174 if (myNumswaps != src.myNumswaps)
return false;
193 graph->
evalOpParm(length, nodeidx,
"numswaps", time, 0);
194 if (length < 0) length = 0;
195 myNumswaps.setSize(length);
202 auto && _curentry = myNumswaps(i);
204 _curentry.enable =
true;
206 graph->
evalOpParmInst(_curentry.enable, nodeidx,
"enable#", parmidx, offsets, time, 0, 2-1);
207 _curentry.method = 0;
209 graph->
evalOpParmInst(_curentry.method, nodeidx,
"method#", parmidx, offsets, time, 0, 2-1);
210 _curentry._class = 2;
212 graph->
evalOpParmInst(_curentry._class, nodeidx,
"class#", parmidx, offsets, time, 0, 2-1);
213 _curentry.srcattribs =
""_UTsh;
215 graph->
evalOpParmInst(_curentry.srcattribs, nodeidx,
"srcattribs#", parmidx, offsets, time, 0, 2-1);
216 _curentry.dstattribs =
""_UTsh;
218 graph->
evalOpParmInst(_curentry.dstattribs, nodeidx,
"dstattribs#", parmidx, offsets, time, 0, 2-1);
219 _curentry.typeinfo = 1;
221 graph->
evalOpParmInst(_curentry.typeinfo, nodeidx,
"typeinfo#", parmidx, offsets, time, 0, 2-1);
242 template <
typename T>
249 if (idx.
size() != instance.
size()+1)
255 coerceValue(value, myNumswaps.entries());
256 else if (instance[0] < myNumswaps.entries())
258 auto && _data = myNumswaps(instance[0]);
262 coerceValue(value, _data.enable);
265 coerceValue(value, _data.method);
268 coerceValue(value, _data._class);
271 coerceValue(value, _data.srcattribs);
274 coerceValue(value, _data.dstattribs);
277 coerceValue(value, _data.typeinfo);
297 { doGetParmValue(idx, instance, value); }
299 { doGetParmValue(idx, instance, value); }
301 { doGetParmValue(idx, instance, value); }
303 { doGetParmValue(idx, instance, value); }
305 { doGetParmValue(idx, instance, value); }
307 { doGetParmValue(idx, instance, value); }
309 { doGetParmValue(idx, instance, value); }
311 { doGetParmValue(idx, instance, value); }
313 { doGetParmValue(idx, instance, value); }
315 { doGetParmValue(idx, instance, value); }
317 { doGetParmValue(idx, instance, value); }
319 template <
typename T>
326 if (idx.
size() != instance.
size()+1)
334 coerceValue(newsize, value);
335 if (newsize < 0) newsize = 0;
336 myNumswaps.setSize(newsize);
342 myNumswaps.setSizeIfNeeded(instance[0]+1);
343 auto && _data = myNumswaps(instance[0]);
347 coerceValue(_data.enable, value);
350 coerceValue(_data.method, value);
353 coerceValue(_data._class, value);
356 coerceValue(_data.srcattribs, value);
359 coerceValue(_data.dstattribs, value);
362 coerceValue(_data.typeinfo, value);
373 { doSetParmValue(idx, instance, value); }
375 { doSetParmValue(idx, instance, value); }
377 { doSetParmValue(idx, instance, value); }
379 { doSetParmValue(idx, instance, value); }
381 { doSetParmValue(idx, instance, value); }
383 { doSetParmValue(idx, instance, value); }
385 { doSetParmValue(idx, instance, value); }
387 { doSetParmValue(idx, instance, value); }
389 { doSetParmValue(idx, instance, value); }
391 { doSetParmValue(idx, instance, value); }
393 { doSetParmValue(idx, instance, value); }
411 if (fieldnum.
size() < 1)
416 if (fieldnum.
size() == 1)
427 return "srcattribs#";
429 return "dstattribs#";
442 if (fieldnum.
size() < 1)
443 return PARM_UNSUPPORTED;
447 if (fieldnum.
size() == 1)
448 return PARM_MULTIPARM;
465 return PARM_UNSUPPORTED;
468 return PARM_UNSUPPORTED;
504 loadData(is, rampdata);
522 int typelen = colon - data.
buffer();
536 {
int64 iv =
v; UTwrite(os, &iv); }
538 { UTwrite<fpreal64>(os, &
v); }
540 { UTwrite<fpreal64>(os, &v.
x()); UTwrite<fpreal64>(os, &v.
y()); }
542 { UTwrite<fpreal64>(os, &v.
x()); UTwrite<fpreal64>(os, &v.
y());
543 UTwrite<fpreal64>(os, &v.
z()); }
545 { UTwrite<fpreal64>(os, &v.
x()); UTwrite<fpreal64>(os, &v.
y());
546 UTwrite<fpreal64>(os, &v.
z()); UTwrite<fpreal64>(os, &v.
w()); }
558 if (s) s->save(ostr);
560 saveData(os, result);
567 ostr << s->getDataTypeToken();
572 saveData(os, result);
576 void save(std::ostream &os)
const
582 UTwrite(os, &length);
585 auto && _curentry = myNumswaps(i);
587 saveData(os, _curentry.enable);
588 saveData(os, _curentry.method);
589 saveData(os, _curentry._class);
590 saveData(os, _curentry.srcattribs);
591 saveData(os, _curentry.dstattribs);
592 saveData(os, _curentry.typeinfo);
611 myNumswaps.setSize(length);
614 auto && _curentry = myNumswaps(i);
616 loadData(is, _curentry.enable);
617 loadData(is, _curentry.method);
618 loadData(is, _curentry._class);
619 loadData(is, _curentry.srcattribs);
620 loadData(is, _curentry.dstattribs);
621 loadData(is, _curentry.typeinfo);
634 if (!thissop)
return getNumswaps().entries();
636 OP_Utils::evalOpParm(result, thissop,
"numswaps", cookparms.
getCookTime(), 0);
640 {
return opinstNumswaps_enable(cookparms, &_idx); }
644 if (!thissop)
return (myNumswaps(_idx[0]).enable);
646 _parmidx[1-1] = _idx[1-1] + 1;
649 OP_Utils::evalOpParmInst(result, thissop,
"enable#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
653 {
return opinstNumswaps_method(cookparms, &_idx); }
657 if (!thissop)
return (myNumswaps(_idx[0]).method);
659 _parmidx[1-1] = _idx[1-1] + 1;
662 OP_Utils::evalOpParmInst(result, thissop,
"method#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
666 {
return opinstNumswaps__class(cookparms, &_idx); }
670 if (!thissop)
return (myNumswaps(_idx[0])._class);
672 _parmidx[1-1] = _idx[1-1] + 1;
675 OP_Utils::evalOpParmInst(result, thissop,
"class#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
679 {
return opinstNumswaps_srcattribs(cookparms, &_idx); }
683 if (!thissop)
return (myNumswaps(_idx[0]).srcattribs);
685 _parmidx[1-1] = _idx[1-1] + 1;
688 OP_Utils::evalOpParmInst(result, thissop,
"srcattribs#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
692 {
return opinstNumswaps_dstattribs(cookparms, &_idx); }
696 if (!thissop)
return (myNumswaps(_idx[0]).dstattribs);
698 _parmidx[1-1] = _idx[1-1] + 1;
701 OP_Utils::evalOpParmInst(result, thissop,
"dstattribs#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
705 {
return opinstNumswaps_typeinfo(cookparms, &_idx); }
709 if (!thissop)
return (myNumswaps(_idx[0]).typeinfo);
711 _parmidx[1-1] = _idx[1-1] + 1;
714 OP_Utils::evalOpParmInst(result, thissop,
"typeinfo#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
bool opNumswaps_enable(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
static void loadData(UT_IStream &is, UT_Vector3I &v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
bool load(UT_IStream &is)
GLenum GLuint GLenum GLsizei const GLchar * buf
static void saveData(std::ostream &os, bool v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
SOP_Node * getNode() const
static void saveData(std::ostream &os, int64 v)
static void loadData(UT_IStream &is, UT_StringHolder &v)
exint bread(int32 *buffer, exint asize=1)
GT_API const UT_StringHolder time
constexpr SYS_FORCE_INLINE T & y() noexcept
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
static void saveData(std::ostream &os, UT_Matrix2D v)
UT_StringHolder srcattribs
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
UT_StringHolder createString(const UT_Array< Numswaps > &list) const
UT_String makeQuotedString(char delimiter='\'', bool escape_nonprinting=false) const
const OP_Context & context() const
constexpr SYS_FORCE_INLINE T & z() noexcept
SYS_FORCE_INLINE const char * buffer() const
static void saveData(std::ostream &os, UT_Matrix4D v)
GLuint GLsizei GLsizei * length
An output stream object that owns its own string buffer storage.
static void loadData(UT_IStream &is, UT_Matrix3D &v)
**But if you need a result
int64 opinstNumswaps_method(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
bool operator==(const Numswaps &src) const
static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is)
const UT_WorkBuffer & str()
Returns a read-only reference to the underlying UT_WorkBuffer.
static void loadData(UT_IStream &is, int64 &v)
static void loadData(UT_IStream &is, UT_Matrix2D &v)
void setNumswaps(const UT_Array< Numswaps > &val)
constexpr SYS_FORCE_INLINE T & x() noexcept
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
void doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
GLuint GLsizei const GLuint const GLintptr * offsets
constexpr SYS_FORCE_INLINE T & x() noexcept
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
static void loadData(UT_IStream &is, UT_Vector2D &v)
static void saveData(std::ostream &os, PRM_DataItemHandle s)
const UT_Array< Numswaps > & getNumswaps() const
void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
bool operator!=(const Numswaps &src) const
UT_StringHolder opinstNumswaps_srcattribs(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
static void loadData(UT_IStream &is, UT_Vector4D &v)
SYS_FORCE_INLINE const char * buffer() const
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
UT_StringHolder dstattribs
constexpr SYS_FORCE_INLINE T & z() noexcept
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
exint read(bool *array, exint sz=1)
const OP_GraphProxy * graph() const
const char * getNestParmName(TempIndex fieldnum) const override
void save(std::ostream &os) const
bool operator==(const SOP_AttribSwapParms &src) const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr< UT_Ramp > &value) const override
virtual void evalOpParmInst(int64 &v, NodeIdx node, const char *parmname, const int *inst, const int *offsets, fpreal time, DEP_MicroNode *depnode, int nestlevel=1) const =0
void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
int64 opinstNumswaps_typeinfo(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
static void loadData(UT_IStream &is, UT_Vector3D &v)
static void loadData(UT_IStream &is, UT_Vector4I &v)
void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
virtual void evalOpParm(int64 &v, NodeIdx node, const char *parmname, fpreal time, DEP_MicroNode *depnode) const =0
static void loadData(UT_IStream &is, UT_Matrix4D &v)
static void saveData(std::ostream &os, fpreal64 v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
exint getNestNumParms(TempIndex idx) const override
SYS_FORCE_INLINE void strcat(const char *src)
void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
void saveBinary(std::ostream &os) const
Save string to binary stream.
static void saveData(std::ostream &os, UT_Matrix3D v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
GT_API const UT_StringHolder version
exint entries() const
Alias of size(). size() is preferred.
ParmType getNestParmType(TempIndex fieldnum) const override
int int appendSprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
bool operator!=(const SOP_AttribSwapParms &src) const
static void saveData(std::ostream &os, UT_Vector4D v)
DEP_MicroNode * depnode() const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr< UT_Ramp > &value) override
bool isParmColorRamp(exint idx) const override
LeafData & operator=(const LeafData &)=delete
Utility class for containing a color ramp.
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
constexpr SYS_FORCE_INLINE T & w() noexcept
SYS_FORCE_INLINE void append(char character)
static void saveData(std::ostream &os, UT_StringHolder s)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
int64 opNumswaps__class(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
void loadFromOpSubclass(const LoadParms &loadparms) override
static void loadData(UT_IStream &is, UT_Vector2I &v)
int64 opNumswaps_method(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
fpreal getCookTime() const
static void saveData(std::ostream &os, UT_Vector2D v)
const char * findChar(int c) const
static void saveData(std::ostream &os, UT_Vector3D v)
void doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
int64 opinstNumswaps__class(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
bool opinstNumswaps_enable(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
UT_StringHolder opNumswaps_srcattribs(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
constexpr SYS_FORCE_INLINE T & y() noexcept
UT_StringHolder opinstNumswaps_dstattribs(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
SYS_FORCE_INLINE UT_StringHolder getToken(Method enum_value)
int64 opNumswaps_typeinfo(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
void copyFrom(const OP_NodeParms *src) override
static void loadData(UT_IStream &is, fpreal64 &v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
static void loadData(UT_IStream &is, bool &v)
constexpr SYS_FORCE_INLINE T & y() noexcept
SYS_FORCE_INLINE bool isstring() const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
SYS_FORCE_INLINE void strncpy(const char *src, exint maxlen)
exint opNumswaps(const SOP_NodeVerb::CookParms &cookparms) const
UT_StringHolder opNumswaps_dstattribs(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
constexpr SYS_FORCE_INLINE T & x() noexcept