From 79a85d3489ee581466c32f3724ce80b84fa366ec Mon Sep 17 00:00:00 2001 From: Justin Privitera <35237779+JustinPrivitera@users.noreply.github.com> Date: Mon, 27 Jun 2022 12:55:03 -0700 Subject: [PATCH] added processoldversions for categoryname and also fixed comment in ctattr (#17820) --- src/common/state/ColorControlPointList.C | 46 +++++++++ src/common/state/ColorControlPointList.code | 96 +++++++++++++++++++ src/common/state/ColorControlPointList.h | 1 + src/common/state/ColorControlPointList.xml | 2 + src/common/state/ColorTableAttributes.code | 3 +- src/test/tests/plots/volumePlot.py | 1 + src/visitpy/visitpy/PyColorControlPointList.C | 36 +++++++ src/visitpy/visitpy/PyColorTableAttributes.C | 2 +- 8 files changed, 185 insertions(+), 2 deletions(-) diff --git a/src/common/state/ColorControlPointList.C b/src/common/state/ColorControlPointList.C index 1b11ea6f973..64a79649df6 100644 --- a/src/common/state/ColorControlPointList.C +++ b/src/common/state/ColorControlPointList.C @@ -1901,3 +1901,49 @@ void ColorControlPointList::SetNumControlPoints(const int n) Select(ID_controlPoints, (void*)&controlPoints); } +// **************************************************************************** +// Method: ColorControlPointList::ProcessOldVersions +// +// Purpose: +// This method allows handling of older config/session files that may +// contain fields that are no longer present or have been modified/renamed. +// +// Programmer: Justin Privitera +// Creation: June 27 2022 +// +// Modifications: +// +// **************************************************************************** +#include +#ifdef VIEWER +#include +#endif + +void +ColorControlPointList::ProcessOldVersions(DataNode *parentNode, + const char *configVersion) +{ +#if VISIT_OBSOLETE_AT_VERSION(3,5,0) +#error This code is obsolete in this version. Please remove it. +#else + if(parentNode == 0) + return; + + DataNode *searchNode = parentNode->GetNode("ColorControlPointList"); + if(searchNode == 0) + return; + + if (VersionLessThan(configVersion, "3.3.0")) + { + DataNode *k = 0; + if ((k = searchNode->GetNode("categoryName")) != 0) + { +#ifdef VIEWER + avtCallback::IssueWarning(DeprecationMessage("categoryName", "3.5.0")); +#endif + searchNode->RemoveNode(k); + } + } +#endif +} + diff --git a/src/common/state/ColorControlPointList.code b/src/common/state/ColorControlPointList.code index e37e6845908..e97f47b22ea 100644 --- a/src/common/state/ColorControlPointList.code +++ b/src/common/state/ColorControlPointList.code @@ -1,3 +1,50 @@ +Target: xml2python +Code: PyColorControlPointList_getattr +Prefix: +#include +Postfix: +#if VISIT_OBSOLETE_AT_VERSION(3,5,0) +#error This code is obsolete in this version. Please remove it. +#else + // Try and handle legacy fields in ColorControlPointList + + // + // Removed in 3.3.0 + // + if(strcmp(name, "categoryName") == 0) + { + PyErr_WarnEx(NULL, + "categoryName is no longer a valid ColorControlPointList " + "attribute.\nIt's value is being ignored, please remove " + "it from your script.\n", 3); + return PyString_FromString(""); + } +#endif + + +Code: PyColorControlPointList_setattr +Prefix: +#include +Postfix: +#if VISIT_OBSOLETE_AT_VERSION(3,5,0) +#error This code is obsolete in this version. Please remove it. +#else + // Try and handle legacy fields in ColorControlPointList + if(obj == &NULL_PY_OBJ) + { + // + // Removed in 3.3.0 + // + if(strcmp(name, "categoryName") == 0) + { + PyErr_WarnEx(NULL, "'categoryName' is obsolete. It is being ignored.", 3); + Py_INCREF(Py_None); + obj = Py_None; + } + } +#endif + +Target: xml2atts Function: EvalCubicSpline Declaration: float EvalCubicSpline(float t, const float *allX, const float *allY, int n) const; Definition: @@ -1028,3 +1075,52 @@ ColorControlPointList_SetNumControlPoints(PyObject *self, PyObject *args) return Py_None; } +Target: xml2atts +Function: ProcessOldVersions +Declaration: virtual void ProcessOldVersions(DataNode *parentNode, const char *configVersion); +Definition: +// **************************************************************************** +// Method: ColorControlPointList::ProcessOldVersions +// +// Purpose: +// This method allows handling of older config/session files that may +// contain fields that are no longer present or have been modified/renamed. +// +// Programmer: Justin Privitera +// Creation: June 27 2022 +// +// Modifications: +// +// **************************************************************************** +#include +#ifdef VIEWER +#include +#endif + +void +ColorControlPointList::ProcessOldVersions(DataNode *parentNode, + const char *configVersion) +{ +#if VISIT_OBSOLETE_AT_VERSION(3,5,0) +#error This code is obsolete in this version. Please remove it. +#else + if(parentNode == 0) + return; + + DataNode *searchNode = parentNode->GetNode("ColorControlPointList"); + if(searchNode == 0) + return; + + if (VersionLessThan(configVersion, "3.3.0")) + { + DataNode *k = 0; + if ((k = searchNode->GetNode("categoryName")) != 0) + { +#ifdef VIEWER + avtCallback::IssueWarning(DeprecationMessage("categoryName", "3.5.0")); +#endif + searchNode->RemoveNode(k); + } + } +#endif +} diff --git a/src/common/state/ColorControlPointList.h b/src/common/state/ColorControlPointList.h index e167570f01f..d57b3ff6864 100644 --- a/src/common/state/ColorControlPointList.h +++ b/src/common/state/ColorControlPointList.h @@ -121,6 +121,7 @@ class STATE_API ColorControlPointList : public AttributeSubject std::string GetTagsAsString(); bool HasTag(std::string tag); void SetNumControlPoints(const int n); + virtual void ProcessOldVersions(DataNode *parentNode, const char *configVersion); // IDs that can be used to identify fields in case statements enum { diff --git a/src/common/state/ColorControlPointList.xml b/src/common/state/ColorControlPointList.xml index 884b6031513..84bb95725ad 100644 --- a/src/common/state/ColorControlPointList.xml +++ b/src/common/state/ColorControlPointList.xml @@ -49,4 +49,6 @@ + + diff --git a/src/common/state/ColorTableAttributes.code b/src/common/state/ColorTableAttributes.code index f60097cffb1..84d882beabe 100644 --- a/src/common/state/ColorTableAttributes.code +++ b/src/common/state/ColorTableAttributes.code @@ -9,7 +9,7 @@ Postfix: // Try and handle legacy fields in ColorTableAttributes // - // Removed in 3.5.0 + // Removed in 3.3.0 // if(strcmp(name, "activeContinuous") == 0) { @@ -838,6 +838,7 @@ ColorTableAttributes::SetAllActive() } } +Target: xml2atts Function: ProcessOldVersions Declaration: virtual void ProcessOldVersions(DataNode *parentNode, const char *configVersion); Definition: diff --git a/src/test/tests/plots/volumePlot.py b/src/test/tests/plots/volumePlot.py index 81e21fa3572..93201d71069 100644 --- a/src/test/tests/plots/volumePlot.py +++ b/src/test/tests/plots/volumePlot.py @@ -502,6 +502,7 @@ def TestCommandRecording(): VolumeAtts.colorControlPoints.smoothing = VolumeAtts.colorControlPoints.Linear VolumeAtts.colorControlPoints.equalSpacingFlag = 0 VolumeAtts.colorControlPoints.discreteFlag = 0 + VolumeAtts.colorControlPoints.categoryName = "" VolumeAtts.opacityAttenuation = 1 VolumeAtts.opacityMode = VolumeAtts.GaussianMode VolumeAtts.opacityControlPoints.SetNumControlPoints(20) diff --git a/src/visitpy/visitpy/PyColorControlPointList.C b/src/visitpy/visitpy/PyColorControlPointList.C index 679ee1b7f66..4af87b905d6 100644 --- a/src/visitpy/visitpy/PyColorControlPointList.C +++ b/src/visitpy/visitpy/PyColorControlPointList.C @@ -528,6 +528,7 @@ static PyObject *ColorControlPointList_richcompare(PyObject *self, PyObject *oth PyObject * PyColorControlPointList_getattr(PyObject *self, char *name) { +#include if(strcmp(name, "controlPoints") == 0) return ColorControlPointList_GetControlPoints(self, NULL); if(strcmp(name, "smoothing") == 0) @@ -548,6 +549,23 @@ PyColorControlPointList_getattr(PyObject *self, char *name) if(strcmp(name, "tagNames") == 0) return ColorControlPointList_GetTagNames(self, NULL); +#if VISIT_OBSOLETE_AT_VERSION(3,5,0) +#error This code is obsolete in this version. Please remove it. +#else + // Try and handle legacy fields in ColorControlPointList + + // + // Removed in 3.3.0 + // + if(strcmp(name, "categoryName") == 0) + { + PyErr_WarnEx(NULL, + "categoryName is no longer a valid ColorControlPointList " + "attribute.\nIt's value is being ignored, please remove " + "it from your script.\n", 3); + return PyString_FromString(""); + } +#endif // Add a __dict__ answer so that dir() works if (!strcmp(name, "__dict__")) @@ -566,6 +584,7 @@ PyColorControlPointList_getattr(PyObject *self, char *name) int PyColorControlPointList_setattr(PyObject *self, char *name, PyObject *args) { +#include PyObject NULL_PY_OBJ; PyObject *obj = &NULL_PY_OBJ; @@ -578,6 +597,23 @@ PyColorControlPointList_setattr(PyObject *self, char *name, PyObject *args) else if(strcmp(name, "tagNames") == 0) obj = ColorControlPointList_SetTagNames(self, args); +#if VISIT_OBSOLETE_AT_VERSION(3,5,0) +#error This code is obsolete in this version. Please remove it. +#else + // Try and handle legacy fields in ColorControlPointList + if(obj == &NULL_PY_OBJ) + { + // + // Removed in 3.3.0 + // + if(strcmp(name, "categoryName") == 0) + { + PyErr_WarnEx(NULL, "'categoryName' is obsolete. It is being ignored.", 3); + Py_INCREF(Py_None); + obj = Py_None; + } + } +#endif if (obj != NULL && obj != &NULL_PY_OBJ) Py_DECREF(obj); diff --git a/src/visitpy/visitpy/PyColorTableAttributes.C b/src/visitpy/visitpy/PyColorTableAttributes.C index 1a8c5f82e4f..f855e6a5562 100644 --- a/src/visitpy/visitpy/PyColorTableAttributes.C +++ b/src/visitpy/visitpy/PyColorTableAttributes.C @@ -641,7 +641,7 @@ PyColorTableAttributes_getattr(PyObject *self, char *name) // Try and handle legacy fields in ColorTableAttributes // - // Removed in 3.5.0 + // Removed in 3.3.0 // if(strcmp(name, "activeContinuous") == 0) {