Skip to content

Commit

Permalink
added processoldversions for categoryname and also fixed comment in c…
Browse files Browse the repository at this point in the history
…tattr (#17820)
  • Loading branch information
JustinPrivitera committed Jun 27, 2022
1 parent 75a8ec6 commit 79a85d3
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 2 deletions.
46 changes: 46 additions & 0 deletions src/common/state/ColorControlPointList.C
Original file line number Diff line number Diff line change
Expand Up @@ -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 <visit-config.h>
#ifdef VIEWER
#include <avtCallback.h>
#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
}

96 changes: 96 additions & 0 deletions src/common/state/ColorControlPointList.code
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
Target: xml2python
Code: PyColorControlPointList_getattr
Prefix:
#include <visit-config.h>
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 <visit-config.h>
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:
Expand Down Expand Up @@ -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 <visit-config.h>
#ifdef VIEWER
#include <avtCallback.h>
#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
}
1 change: 1 addition & 0 deletions src/common/state/ColorControlPointList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/common/state/ColorControlPointList.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@
</Function>
<Function name="ColorControlPointList_SetNumControlPoints" user="true" member="true">
</Function>
<Function name="ProcessOldVersions" user="true" member="true">
</Function>
</Attribute>
3 changes: 2 additions & 1 deletion src/common/state/ColorTableAttributes.code
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -838,6 +838,7 @@ ColorTableAttributes::SetAllActive()
}
}

Target: xml2atts
Function: ProcessOldVersions
Declaration: virtual void ProcessOldVersions(DataNode *parentNode, const char *configVersion);
Definition:
Expand Down
1 change: 1 addition & 0 deletions src/test/tests/plots/volumePlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 36 additions & 0 deletions src/visitpy/visitpy/PyColorControlPointList.C
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ static PyObject *ColorControlPointList_richcompare(PyObject *self, PyObject *oth
PyObject *
PyColorControlPointList_getattr(PyObject *self, char *name)
{
#include <visit-config.h>
if(strcmp(name, "controlPoints") == 0)
return ColorControlPointList_GetControlPoints(self, NULL);
if(strcmp(name, "smoothing") == 0)
Expand All @@ -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__"))
Expand All @@ -566,6 +584,7 @@ PyColorControlPointList_getattr(PyObject *self, char *name)
int
PyColorControlPointList_setattr(PyObject *self, char *name, PyObject *args)
{
#include <visit-config.h>
PyObject NULL_PY_OBJ;
PyObject *obj = &NULL_PY_OBJ;

Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/visitpy/visitpy/PyColorTableAttributes.C
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 79a85d3

Please sign in to comment.