Back to index

tetex-bin  3.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
GfxFunctionShading Class Reference

#include <GfxState.h>

Inheritance diagram for GfxFunctionShading:
Inheritance graph
[legend]
Collaboration diagram for GfxFunctionShading:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 GfxFunctionShading (double x0A, double y0A, double x1A, double y1A, double *matrixA, Function **funcsA, int nFuncsA)
 GfxFunctionShading (GfxFunctionShading *shading)
virtual ~GfxFunctionShading ()
virtual GfxShadingcopy ()
void getDomain (double *x0A, double *y0A, double *x1A, double *y1A)
double * getMatrix ()
void getColor (double x, double y, GfxColor *color)
int getType ()
GfxColorSpacegetColorSpace ()
GfxColorgetBackground ()
GBool getHasBackground ()
void getBBox (double *xMinA, double *yMinA, double *xMaxA, double *yMaxA)
GBool getHasBBox ()

Static Public Member Functions

static GfxFunctionShadingparse (Dict *dict)
static GfxShadingparse (Object *obj)

Protected Member Functions

GBool init (Dict *dict)

Protected Attributes

int type
GfxColorSpacecolorSpace
GfxColor background
GBool hasBackground
double xMin
double yMin
double xMax
double yMax
GBool hasBBox

Private Attributes

double x0
double y0
double x1
double y1
double matrix [6]
Functionfuncs [gfxColorMaxComps]
int nFuncs

Detailed Description

Definition at line 585 of file GfxState.h.


Constructor & Destructor Documentation

GfxFunctionShading::GfxFunctionShading ( double  x0A,
double  y0A,
double  x1A,
double  y1A,
double *  matrixA,
Function **  funcsA,
int  nFuncsA 
)

Definition at line 1519 of file GfxState.cc.

                                                                  :
  GfxShading(1)
{
  int i;

  x0 = x0A;
  y0 = y0A;
  x1 = x1A;
  y1 = y1A;
  for (i = 0; i < 6; ++i) {
    matrix[i] = matrixA[i];
  }
  nFuncs = nFuncsA;
  for (i = 0; i < nFuncs; ++i) {
    funcs[i] = funcsA[i];
  }
}

Here is the caller graph for this function:

Definition at line 1540 of file GfxState.cc.

                                                                 :
  GfxShading(shading)
{
  int i;

  x0 = shading->x0;
  y0 = shading->y0;
  x1 = shading->x1;
  y1 = shading->y1;
  for (i = 0; i < 6; ++i) {
    matrix[i] = shading->matrix[i];
  }
  nFuncs = shading->nFuncs;
  for (i = 0; i < nFuncs; ++i) {
    funcs[i] = shading->funcs[i]->copy();
  }
}

Here is the call graph for this function:

Definition at line 1558 of file GfxState.cc.

                                        {
  int i;

  for (i = 0; i < nFuncs; ++i) {
    delete funcs[i];
  }
}

Member Function Documentation

Implements GfxShading.

Definition at line 1647 of file GfxState.cc.

                                     {
  return new GfxFunctionShading(this);
}

Here is the call graph for this function:

GfxColor* GfxShading::getBackground ( ) [inline, inherited]

Definition at line 563 of file GfxState.h.

{ return &background; }
void GfxShading::getBBox ( double *  xMinA,
double *  yMinA,
double *  xMaxA,
double *  yMaxA 
) [inline, inherited]

Definition at line 565 of file GfxState.h.

    { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; }

Here is the caller graph for this function:

void GfxFunctionShading::getColor ( double  x,
double  y,
GfxColor color 
)

Definition at line 1651 of file GfxState.cc.

                                                                     {
  double in[2];
  int i;

  in[0] = x;
  in[1] = y;
  for (i = 0; i < nFuncs; ++i) {
    funcs[i]->transform(in, &color->c[i]);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

GfxColorSpace* GfxShading::getColorSpace ( ) [inline, inherited]

Definition at line 562 of file GfxState.h.

{ return colorSpace; }

Here is the caller graph for this function:

void GfxFunctionShading::getDomain ( double *  x0A,
double *  y0A,
double *  x1A,
double *  y1A 
) [inline]

Definition at line 599 of file GfxState.h.

    { *x0A = x0; *y0A = y0; *x1A = x1; *y1A = y1; }

Here is the caller graph for this function:

GBool GfxShading::getHasBackground ( ) [inline, inherited]

Definition at line 564 of file GfxState.h.

{ return hasBackground; }
GBool GfxShading::getHasBBox ( ) [inline, inherited]

Definition at line 567 of file GfxState.h.

{ return hasBBox; }

Here is the caller graph for this function:

double* GfxFunctionShading::getMatrix ( ) [inline]

Definition at line 601 of file GfxState.h.

{ return matrix; }

Here is the caller graph for this function:

int GfxShading::getType ( ) [inline, inherited]

Definition at line 561 of file GfxState.h.

{ return type; }

Here is the caller graph for this function:

GBool GfxShading::init ( Dict dict) [protected, inherited]

Definition at line 1464 of file GfxState.cc.

                                 {
  Object obj1, obj2;
  int i;

  dict->lookup("ColorSpace", &obj1);
  if (!(colorSpace = GfxColorSpace::parse(&obj1))) {
    error(-1, "Bad color space in shading dictionary");
    obj1.free();
    return gFalse;
  }
  obj1.free();

  for (i = 0; i < gfxColorMaxComps; ++i) {
    background.c[i] = 0;
  }
  hasBackground = gFalse;
  if (dict->lookup("Background", &obj1)->isArray()) {
    if (obj1.arrayGetLength() == colorSpace->getNComps()) {
      hasBackground = gTrue;
      for (i = 0; i < colorSpace->getNComps(); ++i) {
       background.c[i] = obj1.arrayGet(i, &obj2)->getNum();
       obj2.free();
      }
    } else {
      error(-1, "Bad Background in shading dictionary");
    }
  }
  obj1.free();

  xMin = yMin = xMax = yMax = 0;
  hasBBox = gFalse;
  if (dict->lookup("BBox", &obj1)->isArray()) {
    if (obj1.arrayGetLength() == 4) {
      hasBBox = gTrue;
      xMin = obj1.arrayGet(0, &obj2)->getNum();
      obj2.free();
      yMin = obj1.arrayGet(1, &obj2)->getNum();
      obj2.free();
      xMax = obj1.arrayGet(2, &obj2)->getNum();
      obj2.free();
      yMax = obj1.arrayGet(3, &obj2)->getNum();
      obj2.free();
    } else {
      error(-1, "Bad BBox in shading dictionary");
    }
  }
  obj1.free();

  return gTrue;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GfxShading * GfxShading::parse ( Object obj) [static, inherited]

Definition at line 1421 of file GfxState.cc.

                                         {
  GfxShading *shading;
  Dict *dict;
  int typeA;
  Object obj1;

  if (obj->isDict()) {
    dict = obj->getDict();
  } else if (obj->isStream()) {
    dict = obj->streamGetDict();
  } else {
    return NULL;
  }

  if (!dict->lookup("ShadingType", &obj1)->isInt()) {
    error(-1, "Invalid ShadingType in shading dictionary");
    obj1.free();
    return NULL;
  }
  typeA = obj1.getInt();
  obj1.free();

  switch (typeA) {
  case 1:
    shading = GfxFunctionShading::parse(dict);
    break;
  case 2:
    shading = GfxAxialShading::parse(dict);
    break;
  case 3:
    shading = GfxRadialShading::parse(dict);
    break;
  default:
    error(-1, "Unimplemented shading type %d", typeA);
    goto err1;
  }

  return shading;

 err1:
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1566 of file GfxState.cc.

                                                        {
  GfxFunctionShading *shading;
  double x0A, y0A, x1A, y1A;
  double matrixA[6];
  Function *funcsA[gfxColorMaxComps];
  int nFuncsA;
  Object obj1, obj2;
  int i;

  x0A = y0A = 0;
  x1A = y1A = 1;
  if (dict->lookup("Domain", &obj1)->isArray() &&
      obj1.arrayGetLength() == 4) {
    x0A = obj1.arrayGet(0, &obj2)->getNum();
    obj2.free();
    y0A = obj1.arrayGet(1, &obj2)->getNum();
    obj2.free();
    x1A = obj1.arrayGet(2, &obj2)->getNum();
    obj2.free();
    y1A = obj1.arrayGet(3, &obj2)->getNum();
    obj2.free();
  }
  obj1.free();

  matrixA[0] = 1; matrixA[1] = 0;
  matrixA[2] = 0; matrixA[3] = 1;
  matrixA[4] = 0; matrixA[5] = 0;
  if (dict->lookup("Matrix", &obj1)->isArray() &&
      obj1.arrayGetLength() == 6) {
    matrixA[0] = obj1.arrayGet(0, &obj2)->getNum();
    obj2.free();
    matrixA[1] = obj1.arrayGet(1, &obj2)->getNum();
    obj2.free();
    matrixA[2] = obj1.arrayGet(2, &obj2)->getNum();
    obj2.free();
    matrixA[3] = obj1.arrayGet(3, &obj2)->getNum();
    obj2.free();
    matrixA[4] = obj1.arrayGet(4, &obj2)->getNum();
    obj2.free();
    matrixA[5] = obj1.arrayGet(5, &obj2)->getNum();
    obj2.free();
  }
  obj1.free();

  dict->lookup("Function", &obj1);
  if (obj1.isArray()) {
    nFuncsA = obj1.arrayGetLength();
    if (nFuncsA > gfxColorMaxComps) {
      error(-1, "Invalid Function array in shading dictionary");
      goto err1;
    }
    for (i = 0; i < nFuncsA; ++i) {
      obj1.arrayGet(i, &obj2);
      if (!(funcsA[i] = Function::parse(&obj2))) {
       goto err2;
      }
      obj2.free();
    }
  } else {
    nFuncsA = 1;
    if (!(funcsA[0] = Function::parse(&obj1))) {
      goto err1;
    }
  }
  obj1.free();

  shading = new GfxFunctionShading(x0A, y0A, x1A, y1A, matrixA,
                               funcsA, nFuncsA);
  if (!shading->init(dict)) {
    delete shading;
    return NULL;
  }
  return shading;

 err2:
  obj2.free();
 err1:
  obj1.free();
  return NULL;
}

Here is the call graph for this function:


Member Data Documentation

GfxColor GfxShading::background [protected, inherited]

Definition at line 575 of file GfxState.h.

GfxColorSpace* GfxShading::colorSpace [protected, inherited]

Definition at line 574 of file GfxState.h.

Definition at line 608 of file GfxState.h.

GBool GfxShading::hasBackground [protected, inherited]

Definition at line 576 of file GfxState.h.

GBool GfxShading::hasBBox [protected, inherited]

Definition at line 578 of file GfxState.h.

double GfxFunctionShading::matrix[6] [private]

Definition at line 607 of file GfxState.h.

Definition at line 609 of file GfxState.h.

int GfxShading::type [protected, inherited]

Definition at line 573 of file GfxState.h.

double GfxFunctionShading::x0 [private]

Definition at line 606 of file GfxState.h.

double GfxFunctionShading::x1 [private]

Definition at line 606 of file GfxState.h.

double GfxShading::xMax [protected, inherited]

Definition at line 577 of file GfxState.h.

double GfxShading::xMin [protected, inherited]

Definition at line 577 of file GfxState.h.

double GfxFunctionShading::y0 [private]

Definition at line 606 of file GfxState.h.

double GfxFunctionShading::y1 [private]

Definition at line 606 of file GfxState.h.

double GfxShading::yMax [protected, inherited]

Definition at line 577 of file GfxState.h.

double GfxShading::yMin [protected, inherited]

Definition at line 577 of file GfxState.h.


The documentation for this class was generated from the following files: