PyAnnotationAttributes.C 52.7 KB
Newer Older
hrchilds's avatar
hrchilds committed
1 2
/*****************************************************************************
*
3
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
hrchilds's avatar
hrchilds committed
4
* Produced at the Lawrence Livermore National Laboratory
5
* LLNL-CODE-442911
hrchilds's avatar
hrchilds committed
6 7
* All rights reserved.
*
8
* This file is  part of VisIt. For  details, see https://visit.llnl.gov/.  The
hrchilds's avatar
hrchilds committed
9 10 11 12 13 14 15 16 17 18
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution  and  use  in  source  and  binary  forms,  with  or  without
* modification, are permitted provided that the following conditions are met:
*
*  - Redistributions of  source code must  retain the above  copyright notice,
*    this list of conditions and the disclaimer below.
*  - Redistributions in binary form must reproduce the above copyright notice,
*    this  list of  conditions  and  the  disclaimer (as noted below)  in  the
19 20 21
*    documentation and/or other materials provided with the distribution.
*  - Neither the name of  the LLNS/LLNL nor the names of  its contributors may
*    be used to endorse or promote products derived from this software without
hrchilds's avatar
hrchilds committed
22 23 24 25 26
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR  IMPLIED WARRANTIES, INCLUDING,  BUT NOT  LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND  FITNESS FOR A PARTICULAR  PURPOSE
27 28 29
* ARE  DISCLAIMED. IN  NO EVENT  SHALL LAWRENCE  LIVERMORE NATIONAL  SECURITY,
* LLC, THE  U.S.  DEPARTMENT OF  ENERGY  OR  CONTRIBUTORS BE  LIABLE  FOR  ANY
* DIRECT,  INDIRECT,   INCIDENTAL,   SPECIAL,   EXEMPLARY,  OR   CONSEQUENTIAL
hrchilds's avatar
hrchilds committed
30 31 32 33 34 35 36 37 38
* DAMAGES (INCLUDING, BUT NOT  LIMITED TO, PROCUREMENT OF  SUBSTITUTE GOODS OR
* SERVICES; LOSS OF  USE, DATA, OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER
* CAUSED  AND  ON  ANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT
* LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY  WAY
* OUT OF THE  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/

hrchilds's avatar
hrchilds committed
39 40
#include <PyAnnotationAttributes.h>
#include <ObserverToCallback.h>
41
#include <stdio.h>
hrchilds's avatar
hrchilds committed
42
#include <snprintf.h>
whitlocb's avatar
whitlocb committed
43 44 45 46
#include <PyAxes2D.h>
#include <PyAxes3D.h>
#include <PyFontAttributes.h>
#include <PyFontAttributes.h>
hrchilds's avatar
hrchilds committed
47 48 49 50
#include <ColorAttribute.h>
#include <ColorAttribute.h>
#include <ColorAttribute.h>
#include <ColorAttribute.h>
51
#include <PyAxesArray.h>
hrchilds's avatar
hrchilds committed
52 53 54 55 56 57 58 59 60 61

// ****************************************************************************
// Module: PyAnnotationAttributes
//
// Purpose: 
//   This class contains the attributes controlling annotations.
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
62
// Creation:   omitted
hrchilds's avatar
hrchilds committed
63 64 65 66 67 68 69 70 71 72
//
// ****************************************************************************

//
// This struct contains the Python type information and a AnnotationAttributes.
//
struct AnnotationAttributesObject
{
    PyObject_HEAD
    AnnotationAttributes *data;
hrchilds's avatar
hrchilds committed
73 74
    bool        owns;
    PyObject   *parent;
hrchilds's avatar
hrchilds committed
75 76 77 78 79
};

//
// Internal prototypes
//
hrchilds's avatar
hrchilds committed
80
static PyObject *NewAnnotationAttributes(int);
hrchilds's avatar
hrchilds committed
81

hrchilds's avatar
hrchilds committed
82
std::string
hrchilds's avatar
hrchilds committed
83
PyAnnotationAttributes_ToString(const AnnotationAttributes *atts, const char *prefix)
hrchilds's avatar
hrchilds committed
84
{
hrchilds's avatar
hrchilds committed
85 86
    std::string str; 
    char tmpStr[1000]; 
hrchilds's avatar
hrchilds committed
87

whitlocb's avatar
whitlocb committed
88 89 90 91
    { // new scope
        std::string objPrefix(prefix);
        objPrefix += "axes2D.";
        str += PyAxes2D_ToString(&atts->GetAxes2D(), objPrefix.c_str());
hrchilds's avatar
hrchilds committed
92
    }
whitlocb's avatar
whitlocb committed
93 94 95 96
    { // new scope
        std::string objPrefix(prefix);
        objPrefix += "axes3D.";
        str += PyAxes3D_ToString(&atts->GetAxes3D(), objPrefix.c_str());
hrchilds's avatar
hrchilds committed
97
    }
whitlocb's avatar
whitlocb committed
98 99
    if(atts->GetUserInfoFlag())
        SNPRINTF(tmpStr, 1000, "%suserInfoFlag = 1\n", prefix);
hrchilds's avatar
hrchilds committed
100
    else
whitlocb's avatar
whitlocb committed
101
        SNPRINTF(tmpStr, 1000, "%suserInfoFlag = 0\n", prefix);
hrchilds's avatar
hrchilds committed
102
    str += tmpStr;
whitlocb's avatar
whitlocb committed
103 104 105 106
    { // new scope
        std::string objPrefix(prefix);
        objPrefix += "userInfoFont.";
        str += PyFontAttributes_ToString(&atts->GetUserInfoFont(), objPrefix.c_str());
hrchilds's avatar
hrchilds committed
107
    }
whitlocb's avatar
whitlocb committed
108 109
    if(atts->GetDatabaseInfoFlag())
        SNPRINTF(tmpStr, 1000, "%sdatabaseInfoFlag = 1\n", prefix);
hrchilds's avatar
hrchilds committed
110
    else
whitlocb's avatar
whitlocb committed
111 112
        SNPRINTF(tmpStr, 1000, "%sdatabaseInfoFlag = 0\n", prefix);
    str += tmpStr;
113 114 115 116 117
    if(atts->GetTimeInfoFlag())
        SNPRINTF(tmpStr, 1000, "%stimeInfoFlag = 1\n", prefix);
    else
        SNPRINTF(tmpStr, 1000, "%stimeInfoFlag = 0\n", prefix);
    str += tmpStr;
whitlocb's avatar
whitlocb committed
118 119 120 121
    { // new scope
        std::string objPrefix(prefix);
        objPrefix += "databaseInfoFont.";
        str += PyFontAttributes_ToString(&atts->GetDatabaseInfoFont(), objPrefix.c_str());
hrchilds's avatar
hrchilds committed
122
    }
whitlocb's avatar
whitlocb committed
123
    const char *databaseInfoExpansionMode_names = "File, Directory, Full, Smart, SmartDirectory";
124
    switch (atts->GetDatabaseInfoExpansionMode())
hrchilds's avatar
hrchilds committed
125
    {
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
      case AnnotationAttributes::File:
          SNPRINTF(tmpStr, 1000, "%sdatabaseInfoExpansionMode = %sFile  # %s\n", prefix, prefix, databaseInfoExpansionMode_names);
          str += tmpStr;
          break;
      case AnnotationAttributes::Directory:
          SNPRINTF(tmpStr, 1000, "%sdatabaseInfoExpansionMode = %sDirectory  # %s\n", prefix, prefix, databaseInfoExpansionMode_names);
          str += tmpStr;
          break;
      case AnnotationAttributes::Full:
          SNPRINTF(tmpStr, 1000, "%sdatabaseInfoExpansionMode = %sFull  # %s\n", prefix, prefix, databaseInfoExpansionMode_names);
          str += tmpStr;
          break;
      case AnnotationAttributes::Smart:
          SNPRINTF(tmpStr, 1000, "%sdatabaseInfoExpansionMode = %sSmart  # %s\n", prefix, prefix, databaseInfoExpansionMode_names);
          str += tmpStr;
          break;
      case AnnotationAttributes::SmartDirectory:
          SNPRINTF(tmpStr, 1000, "%sdatabaseInfoExpansionMode = %sSmartDirectory  # %s\n", prefix, prefix, databaseInfoExpansionMode_names);
          str += tmpStr;
          break;
      default:
          break;
hrchilds's avatar
hrchilds committed
148
    }
hrchilds's avatar
hrchilds committed
149

150 151 152 153
    SNPRINTF(tmpStr, 1000, "%sdatabaseInfoTimeScale = %g\n", prefix, atts->GetDatabaseInfoTimeScale());
    str += tmpStr;
    SNPRINTF(tmpStr, 1000, "%sdatabaseInfoTimeOffset = %g\n", prefix, atts->GetDatabaseInfoTimeOffset());
    str += tmpStr;
whitlocb's avatar
whitlocb committed
154 155
    if(atts->GetLegendInfoFlag())
        SNPRINTF(tmpStr, 1000, "%slegendInfoFlag = 1\n", prefix);
hrchilds's avatar
hrchilds committed
156
    else
whitlocb's avatar
whitlocb committed
157
        SNPRINTF(tmpStr, 1000, "%slegendInfoFlag = 0\n", prefix);
hrchilds's avatar
hrchilds committed
158 159 160 161 162 163 164 165
    str += tmpStr;
    const unsigned char *backgroundColor = atts->GetBackgroundColor().GetColor();
    SNPRINTF(tmpStr, 1000, "%sbackgroundColor = (%d, %d, %d, %d)\n", prefix, int(backgroundColor[0]), int(backgroundColor[1]), int(backgroundColor[2]), int(backgroundColor[3]));
    str += tmpStr;
    const unsigned char *foregroundColor = atts->GetForegroundColor().GetColor();
    SNPRINTF(tmpStr, 1000, "%sforegroundColor = (%d, %d, %d, %d)\n", prefix, int(foregroundColor[0]), int(foregroundColor[1]), int(foregroundColor[2]), int(foregroundColor[3]));
    str += tmpStr;
    const char *gradientBackgroundStyle_names = "TopToBottom, BottomToTop, LeftToRight, RightToLeft, Radial";
166
    switch (atts->GetGradientBackgroundStyle())
hrchilds's avatar
hrchilds committed
167
    {
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
      case AnnotationAttributes::TopToBottom:
          SNPRINTF(tmpStr, 1000, "%sgradientBackgroundStyle = %sTopToBottom  # %s\n", prefix, prefix, gradientBackgroundStyle_names);
          str += tmpStr;
          break;
      case AnnotationAttributes::BottomToTop:
          SNPRINTF(tmpStr, 1000, "%sgradientBackgroundStyle = %sBottomToTop  # %s\n", prefix, prefix, gradientBackgroundStyle_names);
          str += tmpStr;
          break;
      case AnnotationAttributes::LeftToRight:
          SNPRINTF(tmpStr, 1000, "%sgradientBackgroundStyle = %sLeftToRight  # %s\n", prefix, prefix, gradientBackgroundStyle_names);
          str += tmpStr;
          break;
      case AnnotationAttributes::RightToLeft:
          SNPRINTF(tmpStr, 1000, "%sgradientBackgroundStyle = %sRightToLeft  # %s\n", prefix, prefix, gradientBackgroundStyle_names);
          str += tmpStr;
          break;
      case AnnotationAttributes::Radial:
          SNPRINTF(tmpStr, 1000, "%sgradientBackgroundStyle = %sRadial  # %s\n", prefix, prefix, gradientBackgroundStyle_names);
          str += tmpStr;
          break;
      default:
          break;
hrchilds's avatar
hrchilds committed
190
    }
hrchilds's avatar
hrchilds committed
191

hrchilds's avatar
hrchilds committed
192 193 194 195 196 197
    const unsigned char *gradientColor1 = atts->GetGradientColor1().GetColor();
    SNPRINTF(tmpStr, 1000, "%sgradientColor1 = (%d, %d, %d, %d)\n", prefix, int(gradientColor1[0]), int(gradientColor1[1]), int(gradientColor1[2]), int(gradientColor1[3]));
    str += tmpStr;
    const unsigned char *gradientColor2 = atts->GetGradientColor2().GetColor();
    SNPRINTF(tmpStr, 1000, "%sgradientColor2 = (%d, %d, %d, %d)\n", prefix, int(gradientColor2[0]), int(gradientColor2[1]), int(gradientColor2[2]), int(gradientColor2[3]));
    str += tmpStr;
198
    const char *backgroundMode_names = "Solid, Gradient, Image, ImageSphere";
199
    switch (atts->GetBackgroundMode())
200
    {
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
      case AnnotationAttributes::Solid:
          SNPRINTF(tmpStr, 1000, "%sbackgroundMode = %sSolid  # %s\n", prefix, prefix, backgroundMode_names);
          str += tmpStr;
          break;
      case AnnotationAttributes::Gradient:
          SNPRINTF(tmpStr, 1000, "%sbackgroundMode = %sGradient  # %s\n", prefix, prefix, backgroundMode_names);
          str += tmpStr;
          break;
      case AnnotationAttributes::Image:
          SNPRINTF(tmpStr, 1000, "%sbackgroundMode = %sImage  # %s\n", prefix, prefix, backgroundMode_names);
          str += tmpStr;
          break;
      case AnnotationAttributes::ImageSphere:
          SNPRINTF(tmpStr, 1000, "%sbackgroundMode = %sImageSphere  # %s\n", prefix, prefix, backgroundMode_names);
          str += tmpStr;
          break;
      default:
          break;
219
    }
hrchilds's avatar
hrchilds committed
220

221 222 223 224 225 226
    SNPRINTF(tmpStr, 1000, "%sbackgroundImage = \"%s\"\n", prefix, atts->GetBackgroundImage().c_str());
    str += tmpStr;
    SNPRINTF(tmpStr, 1000, "%simageRepeatX = %d\n", prefix, atts->GetImageRepeatX());
    str += tmpStr;
    SNPRINTF(tmpStr, 1000, "%simageRepeatY = %d\n", prefix, atts->GetImageRepeatY());
    str += tmpStr;
227 228 229 230 231
    { // new scope
        std::string objPrefix(prefix);
        objPrefix += "axesArray.";
        str += PyAxesArray_ToString(&atts->GetAxesArray(), objPrefix.c_str());
    }
hrchilds's avatar
hrchilds committed
232 233 234 235 236 237 238 239 240 241 242 243
    return str;
}

static PyObject *
AnnotationAttributes_Notify(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
244 245
/*static*/ PyObject *
AnnotationAttributes_SetAxes2D(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
246 247 248
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

whitlocb's avatar
whitlocb committed
249 250 251 252 253
    PyObject *newValue = NULL;
    if(!PyArg_ParseTuple(args, "O", &newValue))
        return NULL;
    if(!PyAxes2D_Check(newValue))
    {
254
        fprintf(stderr, "The axes2D field can only be set with Axes2D objects.\n");
hrchilds's avatar
hrchilds committed
255
        return NULL;
whitlocb's avatar
whitlocb committed
256
    }
hrchilds's avatar
hrchilds committed
257

whitlocb's avatar
whitlocb committed
258
    obj->data->SetAxes2D(*PyAxes2D_FromPyObject(newValue));
hrchilds's avatar
hrchilds committed
259 260 261 262 263

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
264 265
/*static*/ PyObject *
AnnotationAttributes_GetAxes2D(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
266
{
hrchilds's avatar
hrchilds committed
267
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
whitlocb's avatar
whitlocb committed
268 269 270
    // Since the new object will point to data owned by this object,
    // we need to increment the reference count.
    Py_INCREF(self);
hrchilds's avatar
hrchilds committed
271

whitlocb's avatar
whitlocb committed
272 273 274 275
    PyObject *retval = PyAxes2D_Wrap(&obj->data->GetAxes2D());
    // Set the object's parent so the reference to the parent can be decref'd
    // when the child goes out of scope.
    PyAxes2D_SetParent(retval, self);
hrchilds's avatar
hrchilds committed
276 277 278 279

    return retval;
}

whitlocb's avatar
whitlocb committed
280 281
/*static*/ PyObject *
AnnotationAttributes_SetAxes3D(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
282 283 284
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

whitlocb's avatar
whitlocb committed
285 286 287 288 289
    PyObject *newValue = NULL;
    if(!PyArg_ParseTuple(args, "O", &newValue))
        return NULL;
    if(!PyAxes3D_Check(newValue))
    {
290
        fprintf(stderr, "The axes3D field can only be set with Axes3D objects.\n");
hrchilds's avatar
hrchilds committed
291
        return NULL;
whitlocb's avatar
whitlocb committed
292
    }
hrchilds's avatar
hrchilds committed
293

whitlocb's avatar
whitlocb committed
294
    obj->data->SetAxes3D(*PyAxes3D_FromPyObject(newValue));
hrchilds's avatar
hrchilds committed
295 296 297 298 299

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
300 301
/*static*/ PyObject *
AnnotationAttributes_GetAxes3D(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
302 303
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
whitlocb's avatar
whitlocb committed
304 305 306 307 308 309 310 311 312
    // Since the new object will point to data owned by this object,
    // we need to increment the reference count.
    Py_INCREF(self);

    PyObject *retval = PyAxes3D_Wrap(&obj->data->GetAxes3D());
    // Set the object's parent so the reference to the parent can be decref'd
    // when the child goes out of scope.
    PyAxes3D_SetParent(retval, self);

hrchilds's avatar
hrchilds committed
313 314 315
    return retval;
}

whitlocb's avatar
whitlocb committed
316 317
/*static*/ PyObject *
AnnotationAttributes_SetUserInfoFlag(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
318 319 320 321 322 323 324
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    int ival;
    if(!PyArg_ParseTuple(args, "i", &ival))
        return NULL;

whitlocb's avatar
whitlocb committed
325 326
    // Set the userInfoFlag in the object.
    obj->data->SetUserInfoFlag(ival != 0);
hrchilds's avatar
hrchilds committed
327 328 329 330 331

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
332 333
/*static*/ PyObject *
AnnotationAttributes_GetUserInfoFlag(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
334 335
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
whitlocb's avatar
whitlocb committed
336
    PyObject *retval = PyInt_FromLong(obj->data->GetUserInfoFlag()?1L:0L);
hrchilds's avatar
hrchilds committed
337 338 339
    return retval;
}

whitlocb's avatar
whitlocb committed
340 341
/*static*/ PyObject *
AnnotationAttributes_SetUserInfoFont(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
342 343 344
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

whitlocb's avatar
whitlocb committed
345 346
    PyObject *newValue = NULL;
    if(!PyArg_ParseTuple(args, "O", &newValue))
hrchilds's avatar
hrchilds committed
347
        return NULL;
whitlocb's avatar
whitlocb committed
348 349
    if(!PyFontAttributes_Check(newValue))
    {
350
        fprintf(stderr, "The userInfoFont field can only be set with FontAttributes objects.\n");
whitlocb's avatar
whitlocb committed
351 352
        return NULL;
    }
hrchilds's avatar
hrchilds committed
353

whitlocb's avatar
whitlocb committed
354
    obj->data->SetUserInfoFont(*PyFontAttributes_FromPyObject(newValue));
hrchilds's avatar
hrchilds committed
355 356 357 358 359

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
360 361
/*static*/ PyObject *
AnnotationAttributes_GetUserInfoFont(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
362 363
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
whitlocb's avatar
whitlocb committed
364 365 366 367 368 369 370 371 372
    // Since the new object will point to data owned by this object,
    // we need to increment the reference count.
    Py_INCREF(self);

    PyObject *retval = PyFontAttributes_Wrap(&obj->data->GetUserInfoFont());
    // Set the object's parent so the reference to the parent can be decref'd
    // when the child goes out of scope.
    PyFontAttributes_SetParent(retval, self);

hrchilds's avatar
hrchilds committed
373 374 375
    return retval;
}

whitlocb's avatar
whitlocb committed
376 377
/*static*/ PyObject *
AnnotationAttributes_SetDatabaseInfoFlag(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
378 379 380 381 382 383 384
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    int ival;
    if(!PyArg_ParseTuple(args, "i", &ival))
        return NULL;

whitlocb's avatar
whitlocb committed
385 386
    // Set the databaseInfoFlag in the object.
    obj->data->SetDatabaseInfoFlag(ival != 0);
hrchilds's avatar
hrchilds committed
387 388 389 390 391

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
392 393
/*static*/ PyObject *
AnnotationAttributes_GetDatabaseInfoFlag(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
394 395
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
whitlocb's avatar
whitlocb committed
396
    PyObject *retval = PyInt_FromLong(obj->data->GetDatabaseInfoFlag()?1L:0L);
hrchilds's avatar
hrchilds committed
397 398 399
    return retval;
}

400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
/*static*/ PyObject *
AnnotationAttributes_SetTimeInfoFlag(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    int ival;
    if(!PyArg_ParseTuple(args, "i", &ival))
        return NULL;

    // Set the timeInfoFlag in the object.
    obj->data->SetTimeInfoFlag(ival != 0);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
AnnotationAttributes_GetTimeInfoFlag(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetTimeInfoFlag()?1L:0L);
    return retval;
}

whitlocb's avatar
whitlocb committed
424 425
/*static*/ PyObject *
AnnotationAttributes_SetDatabaseInfoFont(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
426 427 428
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

whitlocb's avatar
whitlocb committed
429 430
    PyObject *newValue = NULL;
    if(!PyArg_ParseTuple(args, "O", &newValue))
hrchilds's avatar
hrchilds committed
431
        return NULL;
whitlocb's avatar
whitlocb committed
432
    if(!PyFontAttributes_Check(newValue))
hrchilds's avatar
hrchilds committed
433
    {
434
        fprintf(stderr, "The databaseInfoFont field can only be set with FontAttributes objects.\n");
hrchilds's avatar
hrchilds committed
435 436 437
        return NULL;
    }

whitlocb's avatar
whitlocb committed
438 439
    obj->data->SetDatabaseInfoFont(*PyFontAttributes_FromPyObject(newValue));

hrchilds's avatar
hrchilds committed
440 441 442 443
    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
444 445
/*static*/ PyObject *
AnnotationAttributes_GetDatabaseInfoFont(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
446 447
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
whitlocb's avatar
whitlocb committed
448 449 450 451 452 453 454 455 456
    // Since the new object will point to data owned by this object,
    // we need to increment the reference count.
    Py_INCREF(self);

    PyObject *retval = PyFontAttributes_Wrap(&obj->data->GetDatabaseInfoFont());
    // Set the object's parent so the reference to the parent can be decref'd
    // when the child goes out of scope.
    PyFontAttributes_SetParent(retval, self);

hrchilds's avatar
hrchilds committed
457 458 459
    return retval;
}

whitlocb's avatar
whitlocb committed
460 461
/*static*/ PyObject *
AnnotationAttributes_SetDatabaseInfoExpansionMode(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
462 463 464 465 466 467 468
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    int ival;
    if(!PyArg_ParseTuple(args, "i", &ival))
        return NULL;

whitlocb's avatar
whitlocb committed
469 470 471 472 473 474 475 476
    // Set the databaseInfoExpansionMode in the object.
    if(ival >= 0 && ival < 5)
        obj->data->SetDatabaseInfoExpansionMode(AnnotationAttributes::PathExpansionMode(ival));
    else
    {
        fprintf(stderr, "An invalid databaseInfoExpansionMode value was given. "
                        "Valid values are in the range of [0,4]. "
                        "You can also use the following names: "
477 478
                        "File, Directory, Full, Smart, SmartDirectory"
                        ".");
whitlocb's avatar
whitlocb committed
479 480
        return NULL;
    }
hrchilds's avatar
hrchilds committed
481 482 483 484 485

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
486 487
/*static*/ PyObject *
AnnotationAttributes_GetDatabaseInfoExpansionMode(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
488 489
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
whitlocb's avatar
whitlocb committed
490
    PyObject *retval = PyInt_FromLong(long(obj->data->GetDatabaseInfoExpansionMode()));
hrchilds's avatar
hrchilds committed
491 492 493
    return retval;
}

494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
/*static*/ PyObject *
AnnotationAttributes_SetDatabaseInfoTimeScale(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    double dval;
    if(!PyArg_ParseTuple(args, "d", &dval))
        return NULL;

    // Set the databaseInfoTimeScale in the object.
    obj->data->SetDatabaseInfoTimeScale(dval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
AnnotationAttributes_GetDatabaseInfoTimeScale(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetDatabaseInfoTimeScale());
    return retval;
}

/*static*/ PyObject *
AnnotationAttributes_SetDatabaseInfoTimeOffset(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    double dval;
    if(!PyArg_ParseTuple(args, "d", &dval))
        return NULL;

    // Set the databaseInfoTimeOffset in the object.
    obj->data->SetDatabaseInfoTimeOffset(dval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
AnnotationAttributes_GetDatabaseInfoTimeOffset(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->GetDatabaseInfoTimeOffset());
    return retval;
}

whitlocb's avatar
whitlocb committed
542 543
/*static*/ PyObject *
AnnotationAttributes_SetLegendInfoFlag(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
544 545 546 547 548 549 550
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    int ival;
    if(!PyArg_ParseTuple(args, "i", &ival))
        return NULL;

whitlocb's avatar
whitlocb committed
551 552
    // Set the legendInfoFlag in the object.
    obj->data->SetLegendInfoFlag(ival != 0);
hrchilds's avatar
hrchilds committed
553 554 555 556 557

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
558 559
/*static*/ PyObject *
AnnotationAttributes_GetLegendInfoFlag(PyObject *self, PyObject *args)
hrchilds's avatar
hrchilds committed
560 561
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
whitlocb's avatar
whitlocb committed
562
    PyObject *retval = PyInt_FromLong(obj->data->GetLegendInfoFlag()?1L:0L);
hrchilds's avatar
hrchilds committed
563 564 565
    return retval;
}

whitlocb's avatar
whitlocb committed
566
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
567 568 569 570
AnnotationAttributes_SetBackgroundColor(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

hrchilds's avatar
hrchilds committed
571 572
    int c[4];
    if(!PyArg_ParseTuple(args, "iiii", &c[0], &c[1], &c[2], &c[3]))
hrchilds's avatar
hrchilds committed
573
    {
hrchilds's avatar
hrchilds committed
574 575
        c[3] = 255;
        if(!PyArg_ParseTuple(args, "iii", &c[0], &c[1], &c[2]))
hrchilds's avatar
hrchilds committed
576
        {
hrchilds's avatar
hrchilds committed
577 578
            double dr, dg, db, da;
            if(PyArg_ParseTuple(args, "dddd", &dr, &dg, &db, &da))
hrchilds's avatar
hrchilds committed
579
            {
hrchilds's avatar
hrchilds committed
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = int(da);
            }
            else if(PyArg_ParseTuple(args, "ddd", &dr, &dg, &db))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = 255;
            }
            else
            {
                PyObject *tuple = NULL;
                if(!PyArg_ParseTuple(args, "O", &tuple))
                    return NULL;

                if(!PyTuple_Check(tuple))
                    return NULL;

                // Make sure that the tuple is the right size.
                if(PyTuple_Size(tuple) < 3 || PyTuple_Size(tuple) > 4)
                    return NULL;

                // Make sure that all elements in the tuple are ints.
                for(int i = 0; i < PyTuple_Size(tuple); ++i)
                {
                    PyObject *item = PyTuple_GET_ITEM(tuple, i);
                    if(PyInt_Check(item))
                        c[i] = int(PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, i)));
                    else if(PyFloat_Check(item))
                        c[i] = int(PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(tuple, i)));
                    else
                        return NULL;
                }
hrchilds's avatar
hrchilds committed
616 617 618 619 620 621
            }
        }
        PyErr_Clear();
    }

    // Set the backgroundColor in the object.
hrchilds's avatar
hrchilds committed
622
    ColorAttribute ca(c[0], c[1], c[2], c[3]);
hrchilds's avatar
hrchilds committed
623 624 625 626 627 628
    obj->data->SetBackgroundColor(ca);

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
629
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
630 631 632 633 634 635 636 637 638 639 640 641 642
AnnotationAttributes_GetBackgroundColor(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the backgroundColor.
    PyObject *retval = PyTuple_New(4);
    const unsigned char *backgroundColor = obj->data->GetBackgroundColor().GetColor();
    PyTuple_SET_ITEM(retval, 0, PyInt_FromLong(long(backgroundColor[0])));
    PyTuple_SET_ITEM(retval, 1, PyInt_FromLong(long(backgroundColor[1])));
    PyTuple_SET_ITEM(retval, 2, PyInt_FromLong(long(backgroundColor[2])));
    PyTuple_SET_ITEM(retval, 3, PyInt_FromLong(long(backgroundColor[3])));
    return retval;
}

whitlocb's avatar
whitlocb committed
643
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
644 645 646 647
AnnotationAttributes_SetForegroundColor(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

hrchilds's avatar
hrchilds committed
648 649
    int c[4];
    if(!PyArg_ParseTuple(args, "iiii", &c[0], &c[1], &c[2], &c[3]))
hrchilds's avatar
hrchilds committed
650
    {
hrchilds's avatar
hrchilds committed
651 652
        c[3] = 255;
        if(!PyArg_ParseTuple(args, "iii", &c[0], &c[1], &c[2]))
hrchilds's avatar
hrchilds committed
653
        {
hrchilds's avatar
hrchilds committed
654 655
            double dr, dg, db, da;
            if(PyArg_ParseTuple(args, "dddd", &dr, &dg, &db, &da))
hrchilds's avatar
hrchilds committed
656
            {
hrchilds's avatar
hrchilds committed
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = int(da);
            }
            else if(PyArg_ParseTuple(args, "ddd", &dr, &dg, &db))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = 255;
            }
            else
            {
                PyObject *tuple = NULL;
                if(!PyArg_ParseTuple(args, "O", &tuple))
                    return NULL;

                if(!PyTuple_Check(tuple))
                    return NULL;

                // Make sure that the tuple is the right size.
                if(PyTuple_Size(tuple) < 3 || PyTuple_Size(tuple) > 4)
                    return NULL;

                // Make sure that all elements in the tuple are ints.
                for(int i = 0; i < PyTuple_Size(tuple); ++i)
                {
                    PyObject *item = PyTuple_GET_ITEM(tuple, i);
                    if(PyInt_Check(item))
                        c[i] = int(PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, i)));
                    else if(PyFloat_Check(item))
                        c[i] = int(PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(tuple, i)));
                    else
                        return NULL;
                }
hrchilds's avatar
hrchilds committed
693 694 695 696 697 698
            }
        }
        PyErr_Clear();
    }

    // Set the foregroundColor in the object.
hrchilds's avatar
hrchilds committed
699
    ColorAttribute ca(c[0], c[1], c[2], c[3]);
hrchilds's avatar
hrchilds committed
700 701 702 703 704 705
    obj->data->SetForegroundColor(ca);

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
706
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
707 708 709 710 711 712 713 714 715 716 717 718 719
AnnotationAttributes_GetForegroundColor(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the foregroundColor.
    PyObject *retval = PyTuple_New(4);
    const unsigned char *foregroundColor = obj->data->GetForegroundColor().GetColor();
    PyTuple_SET_ITEM(retval, 0, PyInt_FromLong(long(foregroundColor[0])));
    PyTuple_SET_ITEM(retval, 1, PyInt_FromLong(long(foregroundColor[1])));
    PyTuple_SET_ITEM(retval, 2, PyInt_FromLong(long(foregroundColor[2])));
    PyTuple_SET_ITEM(retval, 3, PyInt_FromLong(long(foregroundColor[3])));
    return retval;
}

whitlocb's avatar
whitlocb committed
720
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
AnnotationAttributes_SetGradientBackgroundStyle(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    int ival;
    if(!PyArg_ParseTuple(args, "i", &ival))
        return NULL;

    // Set the gradientBackgroundStyle in the object.
    if(ival >= 0 && ival < 5)
        obj->data->SetGradientBackgroundStyle(AnnotationAttributes::GradientStyle(ival));
    else
    {
        fprintf(stderr, "An invalid gradientBackgroundStyle value was given. "
                        "Valid values are in the range of [0,4]. "
                        "You can also use the following names: "
737 738
                        "TopToBottom, BottomToTop, LeftToRight, RightToLeft, Radial"
                        ".");
hrchilds's avatar
hrchilds committed
739 740 741 742 743 744 745
        return NULL;
    }

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
746
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
747 748 749 750 751 752 753
AnnotationAttributes_GetGradientBackgroundStyle(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetGradientBackgroundStyle()));
    return retval;
}

whitlocb's avatar
whitlocb committed
754
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
755 756 757 758
AnnotationAttributes_SetGradientColor1(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

hrchilds's avatar
hrchilds committed
759 760
    int c[4];
    if(!PyArg_ParseTuple(args, "iiii", &c[0], &c[1], &c[2], &c[3]))
hrchilds's avatar
hrchilds committed
761
    {
hrchilds's avatar
hrchilds committed
762 763
        c[3] = 255;
        if(!PyArg_ParseTuple(args, "iii", &c[0], &c[1], &c[2]))
hrchilds's avatar
hrchilds committed
764
        {
hrchilds's avatar
hrchilds committed
765 766
            double dr, dg, db, da;
            if(PyArg_ParseTuple(args, "dddd", &dr, &dg, &db, &da))
hrchilds's avatar
hrchilds committed
767
            {
hrchilds's avatar
hrchilds committed
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = int(da);
            }
            else if(PyArg_ParseTuple(args, "ddd", &dr, &dg, &db))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = 255;
            }
            else
            {
                PyObject *tuple = NULL;
                if(!PyArg_ParseTuple(args, "O", &tuple))
                    return NULL;

                if(!PyTuple_Check(tuple))
                    return NULL;

                // Make sure that the tuple is the right size.
                if(PyTuple_Size(tuple) < 3 || PyTuple_Size(tuple) > 4)
                    return NULL;

                // Make sure that all elements in the tuple are ints.
                for(int i = 0; i < PyTuple_Size(tuple); ++i)
                {
                    PyObject *item = PyTuple_GET_ITEM(tuple, i);
                    if(PyInt_Check(item))
                        c[i] = int(PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, i)));
                    else if(PyFloat_Check(item))
                        c[i] = int(PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(tuple, i)));
                    else
                        return NULL;
                }
hrchilds's avatar
hrchilds committed
804 805 806 807 808 809
            }
        }
        PyErr_Clear();
    }

    // Set the gradientColor1 in the object.
hrchilds's avatar
hrchilds committed
810
    ColorAttribute ca(c[0], c[1], c[2], c[3]);
hrchilds's avatar
hrchilds committed
811 812 813 814 815 816
    obj->data->SetGradientColor1(ca);

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
817
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
818 819 820 821 822 823 824 825 826 827 828 829 830
AnnotationAttributes_GetGradientColor1(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the gradientColor1.
    PyObject *retval = PyTuple_New(4);
    const unsigned char *gradientColor1 = obj->data->GetGradientColor1().GetColor();
    PyTuple_SET_ITEM(retval, 0, PyInt_FromLong(long(gradientColor1[0])));
    PyTuple_SET_ITEM(retval, 1, PyInt_FromLong(long(gradientColor1[1])));
    PyTuple_SET_ITEM(retval, 2, PyInt_FromLong(long(gradientColor1[2])));
    PyTuple_SET_ITEM(retval, 3, PyInt_FromLong(long(gradientColor1[3])));
    return retval;
}

whitlocb's avatar
whitlocb committed
831
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
832 833 834 835
AnnotationAttributes_SetGradientColor2(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

hrchilds's avatar
hrchilds committed
836 837
    int c[4];
    if(!PyArg_ParseTuple(args, "iiii", &c[0], &c[1], &c[2], &c[3]))
hrchilds's avatar
hrchilds committed
838
    {
hrchilds's avatar
hrchilds committed
839 840
        c[3] = 255;
        if(!PyArg_ParseTuple(args, "iii", &c[0], &c[1], &c[2]))
hrchilds's avatar
hrchilds committed
841
        {
hrchilds's avatar
hrchilds committed
842 843
            double dr, dg, db, da;
            if(PyArg_ParseTuple(args, "dddd", &dr, &dg, &db, &da))
hrchilds's avatar
hrchilds committed
844
            {
hrchilds's avatar
hrchilds committed
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = int(da);
            }
            else if(PyArg_ParseTuple(args, "ddd", &dr, &dg, &db))
            {
                c[0] = int(dr);
                c[1] = int(dg);
                c[2] = int(db);
                c[3] = 255;
            }
            else
            {
                PyObject *tuple = NULL;
                if(!PyArg_ParseTuple(args, "O", &tuple))
                    return NULL;

                if(!PyTuple_Check(tuple))
                    return NULL;

                // Make sure that the tuple is the right size.
                if(PyTuple_Size(tuple) < 3 || PyTuple_Size(tuple) > 4)
                    return NULL;

                // Make sure that all elements in the tuple are ints.
                for(int i = 0; i < PyTuple_Size(tuple); ++i)
                {
                    PyObject *item = PyTuple_GET_ITEM(tuple, i);
                    if(PyInt_Check(item))
                        c[i] = int(PyInt_AS_LONG(PyTuple_GET_ITEM(tuple, i)));
                    else if(PyFloat_Check(item))
                        c[i] = int(PyFloat_AS_DOUBLE(PyTuple_GET_ITEM(tuple, i)));
                    else
                        return NULL;
                }
hrchilds's avatar
hrchilds committed
881 882 883 884 885 886
            }
        }
        PyErr_Clear();
    }

    // Set the gradientColor2 in the object.
hrchilds's avatar
hrchilds committed
887
    ColorAttribute ca(c[0], c[1], c[2], c[3]);
hrchilds's avatar
hrchilds committed
888 889 890 891 892 893
    obj->data->SetGradientColor2(ca);

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
894
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
895 896 897 898 899 900 901 902 903 904 905 906 907
AnnotationAttributes_GetGradientColor2(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the gradientColor2.
    PyObject *retval = PyTuple_New(4);
    const unsigned char *gradientColor2 = obj->data->GetGradientColor2().GetColor();
    PyTuple_SET_ITEM(retval, 0, PyInt_FromLong(long(gradientColor2[0])));
    PyTuple_SET_ITEM(retval, 1, PyInt_FromLong(long(gradientColor2[1])));
    PyTuple_SET_ITEM(retval, 2, PyInt_FromLong(long(gradientColor2[2])));
    PyTuple_SET_ITEM(retval, 3, PyInt_FromLong(long(gradientColor2[3])));
    return retval;
}

whitlocb's avatar
whitlocb committed
908
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
909 910 911 912 913 914 915 916 917
AnnotationAttributes_SetBackgroundMode(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    int ival;
    if(!PyArg_ParseTuple(args, "i", &ival))
        return NULL;

    // Set the backgroundMode in the object.
918
    if(ival >= 0 && ival < 4)
hrchilds's avatar
hrchilds committed
919 920 921 922
        obj->data->SetBackgroundMode(AnnotationAttributes::BackgroundMode(ival));
    else
    {
        fprintf(stderr, "An invalid backgroundMode value was given. "
923
                        "Valid values are in the range of [0,3]. "
hrchilds's avatar
hrchilds committed
924
                        "You can also use the following names: "
925
                        "Solid, Gradient, Image, ImageSphere.");
hrchilds's avatar
hrchilds committed
926 927 928 929 930 931 932
        return NULL;
    }

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
933
/*static*/ PyObject *
hrchilds's avatar
hrchilds committed
934 935 936 937 938 939 940
AnnotationAttributes_GetBackgroundMode(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetBackgroundMode()));
    return retval;
}

whitlocb's avatar
whitlocb committed
941
/*static*/ PyObject *
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956
AnnotationAttributes_SetBackgroundImage(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    char *str;
    if(!PyArg_ParseTuple(args, "s", &str))
        return NULL;

    // Set the backgroundImage in the object.
    obj->data->SetBackgroundImage(std::string(str));

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
957
/*static*/ PyObject *
958 959 960 961 962 963 964
AnnotationAttributes_GetBackgroundImage(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetBackgroundImage().c_str());
    return retval;
}

whitlocb's avatar
whitlocb committed
965
/*static*/ PyObject *
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980
AnnotationAttributes_SetImageRepeatX(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    int ival;
    if(!PyArg_ParseTuple(args, "i", &ival))
        return NULL;

    // Set the imageRepeatX in the object.
    obj->data->SetImageRepeatX((int)ival);

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
981
/*static*/ PyObject *
982 983 984 985 986 987 988
AnnotationAttributes_GetImageRepeatX(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetImageRepeatX()));
    return retval;
}

whitlocb's avatar
whitlocb committed
989
/*static*/ PyObject *
990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004
AnnotationAttributes_SetImageRepeatY(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    int ival;
    if(!PyArg_ParseTuple(args, "i", &ival))
        return NULL;

    // Set the imageRepeatY in the object.
    obj->data->SetImageRepeatY((int)ival);

    Py_INCREF(Py_None);
    return Py_None;
}

whitlocb's avatar
whitlocb committed
1005
/*static*/ PyObject *
1006 1007 1008 1009 1010 1011 1012
AnnotationAttributes_GetImageRepeatY(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetImageRepeatY()));
    return retval;
}

1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048
/*static*/ PyObject *
AnnotationAttributes_SetAxesArray(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;

    PyObject *newValue = NULL;
    if(!PyArg_ParseTuple(args, "O", &newValue))
        return NULL;
    if(!PyAxesArray_Check(newValue))
    {
        fprintf(stderr, "The axesArray field can only be set with AxesArray objects.\n");
        return NULL;
    }

    obj->data->SetAxesArray(*PyAxesArray_FromPyObject(newValue));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
AnnotationAttributes_GetAxesArray(PyObject *self, PyObject *args)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)self;
    // Since the new object will point to data owned by this object,
    // we need to increment the reference count.
    Py_INCREF(self);

    PyObject *retval = PyAxesArray_Wrap(&obj->data->GetAxesArray());
    // Set the object's parent so the reference to the parent can be decref'd
    // when the child goes out of scope.
    PyAxesArray_SetParent(retval, self);

    return retval;
}

hrchilds's avatar
hrchilds committed
1049 1050


1051
PyMethodDef PyAnnotationAttributes_methods[ANNOTATIONATTRIBUTES_NMETH] = {
hrchilds's avatar
hrchilds committed
1052
    {"Notify", AnnotationAttributes_Notify, METH_VARARGS},
whitlocb's avatar
whitlocb committed
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062
    {"SetAxes2D", AnnotationAttributes_SetAxes2D, METH_VARARGS},
    {"GetAxes2D", AnnotationAttributes_GetAxes2D, METH_VARARGS},
    {"SetAxes3D", AnnotationAttributes_SetAxes3D, METH_VARARGS},
    {"GetAxes3D", AnnotationAttributes_GetAxes3D, METH_VARARGS},
    {"SetUserInfoFlag", AnnotationAttributes_SetUserInfoFlag, METH_VARARGS},
    {"GetUserInfoFlag", AnnotationAttributes_GetUserInfoFlag, METH_VARARGS},
    {"SetUserInfoFont", AnnotationAttributes_SetUserInfoFont, METH_VARARGS},
    {"GetUserInfoFont", AnnotationAttributes_GetUserInfoFont, METH_VARARGS},
    {"SetDatabaseInfoFlag", AnnotationAttributes_SetDatabaseInfoFlag, METH_VARARGS},
    {"GetDatabaseInfoFlag", AnnotationAttributes_GetDatabaseInfoFlag, METH_VARARGS},
1063 1064
    {"SetTimeInfoFlag", AnnotationAttributes_SetTimeInfoFlag, METH_VARARGS},
    {"GetTimeInfoFlag", AnnotationAttributes_GetTimeInfoFlag, METH_VARARGS},
whitlocb's avatar
whitlocb committed
1065 1066 1067 1068
    {"SetDatabaseInfoFont", AnnotationAttributes_SetDatabaseInfoFont, METH_VARARGS},
    {"GetDatabaseInfoFont", AnnotationAttributes_GetDatabaseInfoFont, METH_VARARGS},
    {"SetDatabaseInfoExpansionMode", AnnotationAttributes_SetDatabaseInfoExpansionMode, METH_VARARGS},
    {"GetDatabaseInfoExpansionMode", AnnotationAttributes_GetDatabaseInfoExpansionMode, METH_VARARGS},
1069 1070 1071 1072
    {"SetDatabaseInfoTimeScale", AnnotationAttributes_SetDatabaseInfoTimeScale, METH_VARARGS},
    {"GetDatabaseInfoTimeScale", AnnotationAttributes_GetDatabaseInfoTimeScale, METH_VARARGS},
    {"SetDatabaseInfoTimeOffset", AnnotationAttributes_SetDatabaseInfoTimeOffset, METH_VARARGS},
    {"GetDatabaseInfoTimeOffset", AnnotationAttributes_GetDatabaseInfoTimeOffset, METH_VARARGS},
whitlocb's avatar
whitlocb committed
1073 1074
    {"SetLegendInfoFlag", AnnotationAttributes_SetLegendInfoFlag, METH_VARARGS},
    {"GetLegendInfoFlag", AnnotationAttributes_GetLegendInfoFlag, METH_VARARGS},
hrchilds's avatar
hrchilds committed
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086
    {"SetBackgroundColor", AnnotationAttributes_SetBackgroundColor, METH_VARARGS},
    {"GetBackgroundColor", AnnotationAttributes_GetBackgroundColor, METH_VARARGS},
    {"SetForegroundColor", AnnotationAttributes_SetForegroundColor, METH_VARARGS},
    {"GetForegroundColor", AnnotationAttributes_GetForegroundColor, METH_VARARGS},
    {"SetGradientBackgroundStyle", AnnotationAttributes_SetGradientBackgroundStyle, METH_VARARGS},
    {"GetGradientBackgroundStyle", AnnotationAttributes_GetGradientBackgroundStyle, METH_VARARGS},
    {"SetGradientColor1", AnnotationAttributes_SetGradientColor1, METH_VARARGS},
    {"GetGradientColor1", AnnotationAttributes_GetGradientColor1, METH_VARARGS},
    {"SetGradientColor2", AnnotationAttributes_SetGradientColor2, METH_VARARGS},
    {"GetGradientColor2", AnnotationAttributes_GetGradientColor2, METH_VARARGS},
    {"SetBackgroundMode", AnnotationAttributes_SetBackgroundMode, METH_VARARGS},
    {"GetBackgroundMode", AnnotationAttributes_GetBackgroundMode, METH_VARARGS},
1087 1088 1089 1090 1091 1092
    {"SetBackgroundImage", AnnotationAttributes_SetBackgroundImage, METH_VARARGS},
    {"GetBackgroundImage", AnnotationAttributes_GetBackgroundImage, METH_VARARGS},
    {"SetImageRepeatX", AnnotationAttributes_SetImageRepeatX, METH_VARARGS},
    {"GetImageRepeatX", AnnotationAttributes_GetImageRepeatX, METH_VARARGS},
    {"SetImageRepeatY", AnnotationAttributes_SetImageRepeatY, METH_VARARGS},
    {"GetImageRepeatY", AnnotationAttributes_GetImageRepeatY, METH_VARARGS},
1093 1094
    {"SetAxesArray", AnnotationAttributes_SetAxesArray, METH_VARARGS},
    {"GetAxesArray", AnnotationAttributes_GetAxesArray, METH_VARARGS},
hrchilds's avatar
hrchilds committed
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105
    {NULL, NULL}
};

//
// Type functions
//

static void
AnnotationAttributes_dealloc(PyObject *v)
{
   AnnotationAttributesObject *obj = (AnnotationAttributesObject *)v;
hrchilds's avatar
hrchilds committed
1106 1107
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
hrchilds's avatar
hrchilds committed
1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119
   if(obj->owns)
       delete obj->data;
}

static int
AnnotationAttributes_compare(PyObject *v, PyObject *w)
{
    AnnotationAttributes *a = ((AnnotationAttributesObject *)v)->data;
    AnnotationAttributes *b = ((AnnotationAttributesObject *)w)->data;
    return (*a == *b) ? 0 : -1;
}

1120
PyObject *
1121
PyAnnotationAttributes_getattr(PyObject *self, char *name)
hrchilds's avatar
hrchilds committed
1122
{
whitlocb's avatar
whitlocb committed
1123 1124 1125 1126 1127 1128 1129 1130 1131 1132
    if(strcmp(name, "axes2D") == 0)
        return AnnotationAttributes_GetAxes2D(self, NULL);
    if(strcmp(name, "axes3D") == 0)
        return AnnotationAttributes_GetAxes3D(self, NULL);
    if(strcmp(name, "userInfoFlag") == 0)
        return AnnotationAttributes_GetUserInfoFlag(self, NULL);
    if(strcmp(name, "userInfoFont") == 0)
        return AnnotationAttributes_GetUserInfoFont(self, NULL);
    if(strcmp(name, "databaseInfoFlag") == 0)
        return AnnotationAttributes_GetDatabaseInfoFlag(self, NULL);
1133 1134
    if(strcmp(name, "timeInfoFlag") == 0)
        return AnnotationAttributes_GetTimeInfoFlag(self, NULL);
whitlocb's avatar
whitlocb committed
1135 1136 1137 1138 1139 1140
    if(strcmp(name, "databaseInfoFont") == 0)
        return AnnotationAttributes_GetDatabaseInfoFont(self, NULL);
    if(strcmp(name, "databaseInfoExpansionMode") == 0)
        return AnnotationAttributes_GetDatabaseInfoExpansionMode(self, NULL);
    if(strcmp(name, "File") == 0)
        return PyInt_FromLong(long(AnnotationAttributes::File));
1141
    if(strcmp(name, "Directory") == 0)
whitlocb's avatar
whitlocb committed
1142
        return PyInt_FromLong(long(AnnotationAttributes::Directory));
1143
    if(strcmp(name, "Full") == 0)
whitlocb's avatar
whitlocb committed
1144
        return PyInt_FromLong(long(AnnotationAttributes::Full));
1145
    if(strcmp(name, "Smart") == 0)
whitlocb's avatar
whitlocb committed
1146
        return PyInt_FromLong(long(AnnotationAttributes::Smart));
1147
    if(strcmp(name, "SmartDirectory") == 0)
whitlocb's avatar
whitlocb committed
1148 1149
        return PyInt_FromLong(long(AnnotationAttributes::SmartDirectory));

1150 1151 1152 1153
    if(strcmp(name, "databaseInfoTimeScale") == 0)
        return AnnotationAttributes_GetDatabaseInfoTimeScale(self, NULL);
    if(strcmp(name, "databaseInfoTimeOffset") == 0)
        return AnnotationAttributes_GetDatabaseInfoTimeOffset(self, NULL);
whitlocb's avatar
whitlocb committed
1154 1155
    if(strcmp(name, "legendInfoFlag") == 0)
        return AnnotationAttributes_GetLegendInfoFlag(self, NULL);
hrchilds's avatar
hrchilds committed
1156 1157 1158 1159 1160 1161 1162 1163
    if(strcmp(name, "backgroundColor") == 0)
        return AnnotationAttributes_GetBackgroundColor(self, NULL);
    if(strcmp(name, "foregroundColor") == 0)
        return AnnotationAttributes_GetForegroundColor(self, NULL);
    if(strcmp(name, "gradientBackgroundStyle") == 0)
        return AnnotationAttributes_GetGradientBackgroundStyle(self, NULL);
    if(strcmp(name, "TopToBottom") == 0)
        return PyInt_FromLong(long(AnnotationAttributes::TopToBottom));
1164
    if(strcmp(name, "BottomToTop") == 0)
hrchilds's avatar
hrchilds committed
1165
        return PyInt_FromLong(long(AnnotationAttributes::BottomToTop));
1166
    if(strcmp(name, "LeftToRight") == 0)
hrchilds's avatar
hrchilds committed
1167
        return PyInt_FromLong(long(AnnotationAttributes::LeftToRight));
1168
    if(strcmp(name, "RightToLeft") == 0)
hrchilds's avatar
hrchilds committed
1169
        return PyInt_FromLong(long(AnnotationAttributes::RightToLeft));
1170
    if(strcmp(name, "Radial") == 0)
hrchilds's avatar
hrchilds committed
1171 1172 1173 1174 1175 1176 1177 1178 1179 1180
        return PyInt_FromLong(long(AnnotationAttributes::Radial));

    if(strcmp(name, "gradientColor1") == 0)
        return AnnotationAttributes_GetGradientColor1(self, NULL);
    if(strcmp(name, "gradientColor2") == 0)
        return AnnotationAttributes_GetGradientColor2(self, NULL);
    if(strcmp(name, "backgroundMode") == 0)
        return AnnotationAttributes_GetBackgroundMode(self, NULL);
    if(strcmp(name, "Solid") == 0)
        return PyInt_FromLong(long(AnnotationAttributes::Solid));
1181
    if(strcmp(name, "Gradient") == 0)
hrchilds's avatar
hrchilds committed
1182
        return PyInt_FromLong(long(AnnotationAttributes::Gradient));
1183
    if(strcmp(name, "Image") == 0)
1184
        return PyInt_FromLong(long(AnnotationAttributes::Image));
1185
    if(strcmp(name, "ImageSphere") == 0)
1186
        return PyInt_FromLong(long(AnnotationAttributes::ImageSphere));
hrchilds's avatar
hrchilds committed
1187

1188 1189 1190 1191 1192 1193
    if(strcmp(name, "backgroundImage") == 0)
        return AnnotationAttributes_GetBackgroundImage(self, NULL);
    if(strcmp(name, "imageRepeatX") == 0)
        return AnnotationAttributes_GetImageRepeatX(self, NULL);
    if(strcmp(name, "imageRepeatY") == 0)
        return AnnotationAttributes_GetImageRepeatY(self, NULL);
1194 1195
    if(strcmp(name, "axesArray") == 0)
        return AnnotationAttributes_GetAxesArray(self, NULL);
hrchilds's avatar
hrchilds committed
1196

1197
    return Py_FindMethod(PyAnnotationAttributes_methods, self, name);
hrchilds's avatar
hrchilds committed
1198
}
hrchilds's avatar
hrchilds committed
1199

1200 1201
int
PyAnnotationAttributes_setattr(PyObject *self, char *name, PyObject *args)
hrchilds's avatar
hrchilds committed
1202 1203 1204 1205 1206 1207
{
    // Create a tuple to contain the arguments since all of the Set
    // functions expect a tuple.
    PyObject *tuple = PyTuple_New(1);
    PyTuple_SET_ITEM(tuple, 0, args);
    Py_INCREF(args);
whitlocb's avatar
whitlocb committed
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219
    PyObject *obj = NULL;

    if(strcmp(name, "axes2D") == 0)
        obj = AnnotationAttributes_SetAxes2D(self, tuple);
    else if(strcmp(name, "axes3D") == 0)
        obj = AnnotationAttributes_SetAxes3D(self, tuple);
    else if(strcmp(name, "userInfoFlag") == 0)
        obj = AnnotationAttributes_SetUserInfoFlag(self, tuple);
    else if(strcmp(name, "userInfoFont") == 0)
        obj = AnnotationAttributes_SetUserInfoFont(self, tuple);
    else if(strcmp(name, "databaseInfoFlag") == 0)
        obj = AnnotationAttributes_SetDatabaseInfoFlag(self, tuple);
1220 1221
    else if(strcmp(name, "timeInfoFlag") == 0)
        obj = AnnotationAttributes_SetTimeInfoFlag(self, tuple);
whitlocb's avatar
whitlocb committed
1222 1223 1224 1225
    else if(strcmp(name, "databaseInfoFont") == 0)
        obj = AnnotationAttributes_SetDatabaseInfoFont(self, tuple);
    else if(strcmp(name, "databaseInfoExpansionMode") == 0)
        obj = AnnotationAttributes_SetDatabaseInfoExpansionMode(self, tuple);
1226 1227 1228 1229
    else if(strcmp(name, "databaseInfoTimeScale") == 0)
        obj = AnnotationAttributes_SetDatabaseInfoTimeScale(self, tuple);
    else if(strcmp(name, "databaseInfoTimeOffset") == 0)
        obj = AnnotationAttributes_SetDatabaseInfoTimeOffset(self, tuple);
whitlocb's avatar
whitlocb committed
1230 1231
    else if(strcmp(name, "legendInfoFlag") == 0)
        obj = AnnotationAttributes_SetLegendInfoFlag(self, tuple);
hrchilds's avatar
hrchilds committed
1232
    else if(strcmp(name, "backgroundColor") == 0)
whitlocb's avatar
whitlocb committed
1233
        obj = AnnotationAttributes_SetBackgroundColor(self, tuple);
hrchilds's avatar
hrchilds committed
1234
    else if(strcmp(name, "foregroundColor") == 0)
whitlocb's avatar
whitlocb committed
1235
        obj = AnnotationAttributes_SetForegroundColor(self, tuple);
hrchilds's avatar
hrchilds committed
1236
    else if(strcmp(name, "gradientBackgroundStyle") == 0)
whitlocb's avatar
whitlocb committed
1237
        obj = AnnotationAttributes_SetGradientBackgroundStyle(self, tuple);
hrchilds's avatar
hrchilds committed
1238
    else if(strcmp(name, "gradientColor1") == 0)
whitlocb's avatar
whitlocb committed
1239
        obj = AnnotationAttributes_SetGradientColor1(self, tuple);
hrchilds's avatar
hrchilds committed
1240
    else if(strcmp(name, "gradientColor2") == 0)
whitlocb's avatar
whitlocb committed
1241
        obj = AnnotationAttributes_SetGradientColor2(self, tuple);
hrchilds's avatar
hrchilds committed
1242
    else if(strcmp(name, "backgroundMode") == 0)
whitlocb's avatar
whitlocb committed
1243
        obj = AnnotationAttributes_SetBackgroundMode(self, tuple);
1244
    else if(strcmp(name, "backgroundImage") == 0)
whitlocb's avatar
whitlocb committed
1245
        obj = AnnotationAttributes_SetBackgroundImage(self, tuple);
1246
    else if(strcmp(name, "imageRepeatX") == 0)
whitlocb's avatar
whitlocb committed
1247
        obj = AnnotationAttributes_SetImageRepeatX(self, tuple);
1248
    else if(strcmp(name, "imageRepeatY") == 0)
whitlocb's avatar
whitlocb committed
1249
        obj = AnnotationAttributes_SetImageRepeatY(self, tuple);
1250 1251
    else if(strcmp(name, "axesArray") == 0)
        obj = AnnotationAttributes_SetAxesArray(self, tuple);
whitlocb's avatar
whitlocb committed
1252 1253 1254

    if(obj != NULL)
        Py_DECREF(obj);
hrchilds's avatar
hrchilds committed
1255 1256

    Py_DECREF(tuple);
1257 1258
    if( obj == NULL)
        PyErr_Format(PyExc_RuntimeError, "Unable to set unknown attribute: '%s'", name);
whitlocb's avatar
whitlocb committed
1259
    return (obj != NULL) ? 0 : -1;
hrchilds's avatar
hrchilds committed
1260 1261
}

hrchilds's avatar
hrchilds committed
1262 1263
static int
AnnotationAttributes_print(PyObject *v, FILE *fp, int flags)
hrchilds's avatar
hrchilds committed
1264 1265
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)v;
hrchilds's avatar
hrchilds committed
1266 1267
    fprintf(fp, "%s", PyAnnotationAttributes_ToString(obj->data, "").c_str());
    return 0;
hrchilds's avatar
hrchilds committed
1268 1269
}

hrchilds's avatar
hrchilds committed
1270 1271 1272 1273 1274 1275
PyObject *
AnnotationAttributes_str(PyObject *v)
{
    AnnotationAttributesObject *obj = (AnnotationAttributesObject *)v;
    return PyString_FromString(PyAnnotationAttributes_ToString(obj->data,"").c_str());
}
hrchilds's avatar
hrchilds committed
1276

hrchilds's avatar
hrchilds committed
1277 1278 1279
//
// The doc string for the class.
//
1280
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
1281
static const char *AnnotationAttributes_Purpose = "This class contains the attributes controlling annotations.";
1282 1283 1284
#else
static char *AnnotationAttributes_Purpose = "This class contains the attributes controlling annotations.";
#endif
hrchilds's avatar
hrchilds committed
1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303

//
// The type description structure
//
static PyTypeObject AnnotationAttributesType =
{
    //
    // Type header
    //
    PyObject_HEAD_INIT(&PyType_Type)
    0,                                   // ob_size
    "AnnotationAttributes",                    // tp_name
    sizeof(AnnotationAttributesObject),        // tp_basicsize
    0,                                   // tp_itemsize
    //
    // Standard methods
    //
    (destructor)AnnotationAttributes_dealloc,  // tp_dealloc
    (printfunc)AnnotationAttributes_print,     // tp_print
1304 1305
    (getattrfunc)PyAnnotationAttributes_getattr, // tp_getattr
    (setattrfunc)PyAnnotationAttributes_setattr, // tp_setattr
hrchilds's avatar
hrchilds committed
1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318
    (cmpfunc)AnnotationAttributes_compare,     // tp_compare
    (reprfunc)0,                         // tp_repr
    //
    // Type categories
    //
    0,                                   // tp_as_number
    0,                                   // tp_as_sequence
    0,                                   // tp_as_mapping
    //
    // More methods
    //
    0,                                   // tp_hash
    0,                                   // tp_call
hrchilds's avatar
hrchilds committed
1319
    (reprfunc)AnnotationAttributes_str,        // tp_str
hrchilds's avatar
hrchilds committed
1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335
    0,                                   // tp_getattro
    0,                                   // tp_setattro
    0,                                   // tp_as_buffer
    Py_TPFLAGS_CHECKTYPES,               // tp_flags
    AnnotationAttributes_Purpose,              // tp_doc
    0,                                   // tp_traverse
    0,                                   // tp_clear
    0,                                   // tp_richcompare
    0                                    // tp_weaklistoffset
};

//
// Helper functions for object allocation.
//

static AnnotationAttributes *defaultAtts = 0;
hrchilds's avatar
hrchilds committed
1336
static AnnotationAttributes *currentAtts = 0;
hrchilds's avatar
hrchilds committed
1337 1338

static PyObject *
hrchilds's avatar
hrchilds committed
1339
NewAnnotationAttributes(int useCurrent)
hrchilds's avatar
hrchilds committed
1340 1341 1342 1343 1344
{
    AnnotationAttributesObject *newObject;
    newObject = PyObject_NEW(AnnotationAttributesObject, &AnnotationAttributesType);
    if(newObject == NULL)
        return NULL;
hrchilds's avatar
hrchilds committed
1345 1346 1347
    if(useCurrent && currentAtts != 0)
        newObject->data = new AnnotationAttributes(*currentAtts);
    else if(defaultAtts != 0)
hrchilds's avatar
hrchilds committed
1348 1349 1350 1351
        newObject->data = new AnnotationAttributes(*defaultAtts);
    else
        newObject->data = new AnnotationAttributes;
    newObject->owns = true;
hrchilds's avatar
hrchilds committed
1352
    newObject->parent = 0;
hrchilds's avatar
hrchilds committed
1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364
    return (PyObject *)newObject;
}

static PyObject *
WrapAnnotationAttributes(const AnnotationAttributes *attr)
{
    AnnotationAttributesObject *newObject;
    newObject = PyObject_NEW(AnnotationAttributesObject, &AnnotationAttributesType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (AnnotationAttributes *)attr;
    newObject->owns = false;
hrchilds's avatar
hrchilds committed
1365
    newObject->parent = 0;
hrchilds's avatar
hrchilds committed
1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
AnnotationAttributes_new(PyObject *self, PyObject *args)
{
hrchilds's avatar
hrchilds committed
1378 1379 1380 1381 1382 1383 1384 1385 1386 1387
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewAnnotationAttributes(useCurrent);
hrchilds's avatar
hrchilds committed
1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef AnnotationAttributesMethods[] = {
    {"AnnotationAttributes", AnnotationAttributes_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *AnnotationAttributesObserver = 0;
hrchilds's avatar
hrchilds committed
1399 1400 1401 1402 1403 1404 1405 1406 1407

std::string
PyAnnotationAttributes_GetLogString()
{
    std::string s("AnnotationAtts = AnnotationAttributes()\n");
    if(currentAtts != 0)
        s += PyAnnotationAttributes_ToString(currentAtts, "AnnotationAtts.");
    return s;
}
hrchilds's avatar
hrchilds committed
1408 1409

static void
hrchilds's avatar
hrchilds committed
1410
PyAnnotationAttributes_CallLogRoutine(Subject *subj, void *data)
hrchilds's avatar
hrchilds committed
1411
{
1412
    AnnotationAttributes *atts = (AnnotationAttributes *)subj; (void) atts;
hrchilds's avatar
hrchilds committed
1413 1414
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;
hrchilds's avatar
hrchilds committed
1415

hrchilds's avatar
hrchilds committed
1416 1417 1418 1419 1420 1421
    if(cb != 0)
    {
        std::string s("AnnotationAtts = AnnotationAttributes()\n");
        s += PyAnnotationAttributes_ToString(currentAtts, "AnnotationAtts.");
        cb(s);
    }
hrchilds's avatar
hrchilds committed
1422 1423 1424
}

void
hrchilds's avatar
hrchilds committed
1425
PyAnnotationAttributes_StartUp(AnnotationAttributes *subj, void *data)
hrchilds's avatar
hrchilds committed
1426 1427 1428 1429
{
    if(subj == 0)
        return;

hrchilds's avatar
hrchilds committed
1430
    currentAtts = subj;
hrchilds's avatar
hrchilds committed
1431 1432 1433 1434 1435 1436 1437 1438
    PyAnnotationAttributes_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(AnnotationAttributesObserver == 0)
    {
        AnnotationAttributesObserver = new ObserverToCallback(subj,
hrchilds's avatar
hrchilds committed
1439
            PyAnnotationAttributes_CallLogRoutine,