Commit 867340d2 authored by cyrush's avatar cyrush
Browse files

remove (broken) access by index use case for GetAnnotationObject()

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@14783 18c085ea-50e0-402c-830e-de6fd14e8384
parent 16ade6c4
......@@ -33,6 +33,9 @@ enhancements and bug-fixes that were added to this release.</p>
<p><b><font size="4">General features added in version 2.3</font></b></p>
<ul>
<li>The <b>Expression</b> window's <b>Load</b> button now causes expressions from XML files to be appended to the expression list instead of replacing the expressions in the list.</li>
<li> The cli method <i>GetAnnotationObject</i> now only accepts a string argument for the desired object's name.
To access an object by index, use the index in combination with the result of <i>GetAnnotationObjectNames</i>.
</li>
</ul>
<a name="Advanced_Features"></a>
......
......@@ -12744,6 +12744,9 @@ visit_CreateAnnotationObject(PyObject *self, PyObject *args)
// Brad Whitlock, Thu Mar 22 03:24:48 PDT 2007
// Rewrote for new annotation object scheme.
//
// Cyrus Harrison, Mon May 9 10:30:37 PDT 2011
// Remove fetch by index case (only support access by name - Issue #537).
//
// ****************************************************************************
STATIC PyObject *
......@@ -12755,12 +12758,12 @@ visit_GetAnnotationObject(PyObject *self, PyObject *args)
bool useIndex = true;
int annotIndex;
char *annotName = NULL;
if (!PyArg_ParseTuple(args, "i", &annotIndex))
if(!PyArg_ParseTuple(args, "s", &annotName))
{
if(!PyArg_ParseTuple(args, "s", &annotName))
return NULL;
PyErr_Clear();
useIndex = false;
const char *errMsg = "GetAnnotationObject() takes a single string argument.";
VisItErrorFunc(errMsg);
return NULL;
}
// Make sure the annotation object list is up to date.
......@@ -12770,96 +12773,59 @@ visit_GetAnnotationObject(PyObject *self, PyObject *args)
PyObject *retval = NULL;
if(useIndex)
debug1 << mName << "Look in the map for an object called "
<< annotName << endl;
std::map<std::string, AnnotationObjectRef>::iterator pos =
localObjectMap.find(annotName);
if(pos != localObjectMap.end())
{
if(annotIndex >= 0 &&
annotIndex < GetViewerState()->GetAnnotationObjectList()->GetNumAnnotations())
{
debug1 << mName << "Look in the map for an object that has index equal to "
<< annotIndex << endl;
for(std::map<std::string, AnnotationObjectRef>::iterator pos = localObjectMap.begin();
pos != localObjectMap.end(); ++pos)
{
if(pos->second.index == annotIndex)
{
debug1 << mName << "Found object called "
<< pos->second.object->GetObjectName()
<< " with an index of " << annotIndex
<< endl;
AnnotationObject *annot = pos->second.object;
retval = CreateAnnotationWrapper(annot);
AnnotationObject *annot = pos->second.object;
retval = CreateAnnotationWrapper(annot);
// Increase the object's reference count.
if(retval != 0)
++pos->second.refCount;
break;
}
}
}
else
{
const char *errMsg = "An invalid annotation object index was given!";
debug1 << mName << errMsg << endl;
VisItErrorFunc(errMsg);
}
// Increase the object's reference count.
if(retval != 0)
++pos->second.refCount;
}
else
{
debug1 << mName << "Look in the map for an object called "
<< annotName << endl;
std::map<std::string, AnnotationObjectRef>::iterator pos =
localObjectMap.find(annotName);
if(pos != localObjectMap.end())
{
AnnotationObject *annot = pos->second.object;
retval = CreateAnnotationWrapper(annot);
// Increase the object's reference count.
if(retval != 0)
++pos->second.refCount;
}
else
// The object was not in the map but see if we can add it.
int index = GetViewerState()->GetAnnotationObjectList()->
IndexForName(annotName);
if(index != -1)
{
// The object was not in the map but see if we can add it.
int index = GetViewerState()->GetAnnotationObjectList()->
IndexForName(annotName);
if(index != -1)
{
AnnotationObject &newObject = GetViewerState()->
GetAnnotationObjectList()->GetAnnotation(index);
AnnotationObject &newObject = GetViewerState()->
GetAnnotationObjectList()->GetAnnotation(index);
//
// Create a copy of the new annotation object that we'll keep in the
// module's own annotation object list.
//
AnnotationObject *localCopy = new AnnotationObject(newObject);
//
// Create a copy of the new annotation object that we'll keep in the
// module's own annotation object list.
//
AnnotationObject *localCopy = new AnnotationObject(newObject);
retval = CreateAnnotationWrapper(localCopy);
retval = CreateAnnotationWrapper(localCopy);
if(retval != 0)
{
// Cache references based on the object name.
AnnotationObjectRef ref;
ref.object = localCopy;
ref.refCount = 1;
ref.index = localObjectMap.size();
localObjectMap[newObject.GetObjectName()] = ref;
}
else
{
delete localCopy;
debug1 << mName << "CreateAnnotationWrapper returned 0!" << endl;
}
if(retval != 0)
{
// Cache references based on the object name.
AnnotationObjectRef ref;
ref.object = localCopy;
ref.refCount = 1;
ref.index = localObjectMap.size();
localObjectMap[newObject.GetObjectName()] = ref;
}
else
{
char msg[400];
SNPRINTF(msg, 400, "An unrecognized object name \"%s\" was requested.", annotName);
VisItErrorFunc(msg);
delete localCopy;
debug1 << mName << "CreateAnnotationWrapper returned 0!" << endl;
}
}
else
{
char msg[400];
SNPRINTF(msg, 400, "An unrecognized object name \"%s\" was requested.", annotName);
VisItErrorFunc(msg);
}
}
MUTEX_UNLOCK();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment