rllib  1
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
rlSvgAnimator Class Reference

#include <rlsvganimator.h>

Collaboration diagram for rlSvgAnimator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 rlSvgAnimator ()
virtual ~rlSvgAnimator ()
int setSocket (int *socket)
int setId (int Id)
int read (const char *infile, rlIniFile *inifile=NULL)
int writeSocket ()
 The following methods are for modifying a object within a SVG graphic identified by objectname.
int svgPrintf (const char *objectname, const char *tag, const char *format,...)
int svgRecursivePrintf (const char *objectname, const char *tag, const char *format,...)
int svgSearchAndReplace (const char *objectname, const char *tag, const char *before, const char *after)
int svgRecursiveSearchAndReplace (const char *objectname, const char *tag, const char *before, const char *after)
int svgTextPrintf (const char *objectname, const char *format,...)
int show (const char *objectname, int state)
int setMatrix (const char *objectname, float sx, float alpha, float x0, float y0, float cx, float cy)
int setMatrix (const char *objectname, rlSvgPosition &pos)
 The following methods are for moveing and zooming the whole SVG identified by mainObject. default: main.
int setMainObject (const char *main_object)
const char * mainObject ()
int setXY0 (float x0, float y0)
float x0 ()
float y0 ()
int setMouseXY0 (float x0, float y0)
float mouseX0 ()
float mouseY0 ()
int setMouseXY1 (float x1, float y1)
float mouseX1 ()
float mouseY1 ()
int setScale (float scale)
float scale ()
int zoomCenter (float newScale)
int zoomRect ()
int setMainObjectMatrix ()
int setWindowSize (int width, int height)
float windowWidth ()
float windowHeight ()
int moveMainObject (float x, float y)

Public Attributes

int isModified

Private Member Functions

int tcpsend (const char *buf, int len)
int fillIniFile (rlIniFile *inifile, const char *line)
int fileFillIniFile (const char *infile, rlIniFile *inifile)

Private Attributes

int inifileState
int inifileCount
rlSpreadsheetCell inifileID
rlSpreadsheetTable inifileTable
int * s
int id
float svgX0
float svgY0
float svgWindowWidth
float svgWindowHeight
float svgScale
float svgMouseX0
float svgMouseY0
float svgMouseX1
float svgMouseY1
rlString main_object_name

Detailed Description

This class allows you to animate SVG graphics within pvbrowser.
First the SVG is send to pvbrowser.
Then you may modify the SVG within the pvbrowser client.

Definition at line 48 of file rlsvganimator.h.


Constructor & Destructor Documentation

rlSvgAnimator::rlSvgAnimator ( )

Definition at line 113 of file rlsvganimator.cpp.

{
  s = NULL;
  id = 0;
  isModified = 1;

  // zoomer follows
  svgX0 = svgY0 = 0.0f;
  svgScale = 1.0f;
  svgWindowWidth  = 640.0f;
  svgWindowHeight = 480.0f;
  svgMouseX0 = svgMouseY0 = 0.0f;
  svgMouseX1 = svgMouseY1 = 0.0f;
  main_object_name.setText("main");
}
rlSvgAnimator::~rlSvgAnimator ( ) [virtual]

Definition at line 129 of file rlsvganimator.cpp.

{
}

Member Function Documentation

int rlSvgAnimator::fileFillIniFile ( const char *  infile,
rlIniFile inifile 
) [private]

Definition at line 597 of file rlsvganimator.cpp.

{
  char line[MAXLINE];
  FILE *fin;

  fin = fopen(infile,"r");
  if(fin == NULL) return -1;
  while(fgets(line,sizeof(line)-1,fin) != NULL)
  {
    fillIniFile(inifile, line);
  }
  fclose(fin);
  return 0;
}
int rlSvgAnimator::fillIniFile ( rlIniFile inifile,
const char *  line 
) [private]

Definition at line 539 of file rlsvganimator.cpp.

{
  char myline[MAXLINE],*cptr, *cptr2;
  const char *id;
  int i;

  strcpy(myline,line);
  cptr = strchr(myline,'\n');
  if(cptr != NULL) *cptr = '\0';

  if(myline[0] == '>' || strncmp(myline,"/>",2) == 0)
  { // end of data -> fill inifile
    if(inifileState == 1) // if id was found
    {
      for(i=0; i<inifileCount; i++)
      {
        id = inifileID.text();
        inifile->setText(id, inifileTable.text(1,i+1), inifileTable.text(2,i+1));
      }
    }
    inifileState = 0;
    inifileCount = 0;
    inifileID.clear();
    inifileTable.clear();
  }
  else if(myline[0] == '<')
  { // ignore this
  }
  else if(strncmp(myline,"id=",3) == 0)
  { // remenber id
    cptr = strchr(myline,'=');
    if(cptr != NULL)
    {
      cptr++; cptr++;
      cptr2 = strchr(cptr,'\"');
      if(cptr2 != NULL) *cptr2 = '\0';
      inifileID.setText(cptr);
      inifileState = 1; // id was found
    }
  }
  else
  { // fill this in table
    cptr = strchr(myline,'=');
    if(cptr != NULL)
    {
      *cptr = '\0';
      cptr++; cptr++;
      cptr2 = strrchr(cptr,'\"');
      if(cptr2 != NULL) *cptr2 = '\0';
      inifileTable.setText(1,inifileCount+1,myline);
      inifileTable.setText(2,inifileCount+1,cptr);
      inifileCount++;
    }
  }

  return 0;
}
const char * rlSvgAnimator::mainObject ( )

Definition at line 622 of file rlsvganimator.cpp.

{
  return main_object_name.text();
}
float rlSvgAnimator::mouseX0 ( )

Definition at line 653 of file rlsvganimator.cpp.

{
  return svgMouseX0;
}
float rlSvgAnimator::mouseX1 ( )

Definition at line 671 of file rlsvganimator.cpp.

{
  return svgMouseX1;
}
float rlSvgAnimator::mouseY0 ( )

Definition at line 658 of file rlsvganimator.cpp.

{
  return svgMouseY0;
}
float rlSvgAnimator::mouseY1 ( )

Definition at line 676 of file rlsvganimator.cpp.

{
  return svgMouseY1;
}
int rlSvgAnimator::moveMainObject ( float  x,
float  y 
)

move MainObject to position

Definition at line 757 of file rlsvganimator.cpp.

{
  isModified = 1;
  float xx0 = x0() + (x - mouseX0());
  float yy0 = y0() + (y - mouseY0());
  setXY0(xx0,yy0);
  setMainObjectMatrix();
  return 0;
}
int rlSvgAnimator::read ( const char *  infile,
rlIniFile inifile = NULL 
)

read SVG file infile and load it into the pvbrowser client. if inifile is given inifile will be set with properties within the SVG XML file. The id's of the SVG objects will result in section names of the inifile.

Definition at line 171 of file rlsvganimator.cpp.

{
  isModified = 1;
#ifdef RLUNIX
  rlSpawn rlsvg;
  int ret, use_stdout;
  char command[MAXLINE];
  const char *line;

  inifileState = 0;
  inifileCount = 0;
  if(inifile == NULL) use_stdout = 0;
  use_stdout = 0;
  if(s != NULL && *s == 1) use_stdout = 1;

  rlDebugPrintf("rlSvgAnimator step=1 infile=%s\n",infile);
  if(use_stdout == 0) 
  {
    sprintf(command,"rlsvgcat %s",infile);
    ret = rlsvg.spawn(command);
    if(ret < 0) return -1;
  }

  rlDebugPrintf("rlSvgAnimator step=2\n");

  if(id != 0 && s != NULL) // new style programming
  {
    sprintf(command,"gsvgRead(%d)\n",id);
    tcpsend(command,strlen(command));
    if(use_stdout == 0)
    {
      while((line = rlsvg.readLine()) != NULL)
      {
        tcpsend(line,strlen(line));
        if(inifile != NULL) fillIniFile(inifile, line);
      }
    }
    else
    {
      sprintf(command,"/usr/bin/rlsvgcat %s",infile);
      ret = system(command);
      if(ret == -1) return -1;
      if(inifile != NULL) 
      {
        char outfile[80];
        sprintf(outfile,"PVTMP%d.svg",*s);
        sprintf(command,"/usr/bin/rlsvgcat %s %s",infile,outfile);
        ret = system(command);
        if(ret == -1) return -1;
        fileFillIniFile(outfile, inifile);
        unlink(outfile);
      }  
    }
    sprintf(command,"\n<svgend></svgend>\n");
    tcpsend(command,strlen(command));
    return 0;
  }
  else 
  {
    return -1;
  }  
#else
  // Windows: use file instead of pipe
  FILE *fin;
  int  ret;
  char filename[1024];
  char cmd[1024];
  char command[MAXLINE];
  char line[MAXLINE];
  char *cptr;

  inifileState = 0;
  inifileCount = 0;
  if(s==NULL) sprintf(filename,"PVTEMP%s",infile);
  else        sprintf(filename,"PVTEMP%d%s",*s,infile);
  sprintf(cmd,"rlsvgcat %s %s",infile,filename);
  ret = system(cmd);
  if(ret < 0) return -1;
  fin = fopen(filename,"r");
  if(fin == NULL) return -1;
  sprintf(command,"gsvgRead(%d)\n",id);
  tcpsend(command,strlen(command));
  while(fgets(line,sizeof(line)-1,fin) != NULL)
  {
    cptr = strchr(line,0x0d);
    if(cptr != NULL) *cptr = '\0';
    cptr = strchr(line,0x0a);
    if(cptr != NULL) *cptr = '\0';
    tcpsend(line,strlen(line));
    tcpsend("\n",strlen("\n"));
    if(inifile != NULL) fillIniFile(inifile, line);
  }
  sprintf(command,"\n<svgend></svgend>\n");
  tcpsend(command, strlen(command));;
  unlink(filename);
  return 0;
#endif
}
float rlSvgAnimator::scale ( )

Definition at line 688 of file rlsvganimator.cpp.

{
  return svgScale;
}
int rlSvgAnimator::setId ( int  Id)

initialize the id with the pvbrowser object id

Definition at line 277 of file rlsvganimator.cpp.

{
  isModified = 1;
  id = _id;
  return 0;
}
int rlSvgAnimator::setMainObject ( const char *  main_object)

set/get the name of the MainObject . The object name holding the whole SVG graphic. default: main

Definition at line 614 of file rlsvganimator.cpp.

{
  isModified = 1;
  if(main_object == NULL) return -1; 
  main_object_name.setText(main_object);
  return 0;
}
int rlSvgAnimator::setMainObjectMatrix ( )

sets the MainObject matrix according to scale,x0,y0

Definition at line 732 of file rlsvganimator.cpp.

{
  isModified = 1;
  setMatrix(main_object_name.text(), svgScale, 0.0f, svgX0, svgY0, 0.0f, 0.0f);
  return 0;
}
int rlSvgAnimator::setMatrix ( const char *  objectname,
float  sx,
float  alpha,
float  x0,
float  y0,
float  cx,
float  cy 
)

set transformation matrix of object

Definition at line 464 of file rlsvganimator.cpp.

{
  // sx    = scale x
  // alpha = rotation
  // x0,y0 = tranlation
  // cx,cy = rotation center
  //
  // matrix:
  // a11 a12 a13
  // a21 a22 a23
  // a31 a32 a33

  float a11, a12, a13, a21, a22, a23, a31, a32, a33, cx, cy;

  isModified = 1;
  cx = cx_in + x0;
  cy = cy_in + y0;

  a11 = sx*((float) cos(alpha));
  a12 = -sx*((float) sin(alpha));
  a13 = (x0 - cx)*((float) cos(alpha)) - (y0 - cy)*((float) sin(alpha)) + cx;
  a21 = sx*((float) sin(alpha));
  a22 = sx*((float) cos(alpha));
  a23 = (x0 - cx)*((float) sin(alpha)) + (y0 - cy)*((float) cos(alpha)) + cy;
  a31 = 0.0f;
  a32 = 0.0f;
  a33 = 1.0f;

  return svgPrintf(objectname,"transform=","matrix(%f,%f,%f,%f,%f,%f)",a11,a21,a12,a22,a13,a23);

/*********************************************************************************************

Definition
CTM := CurrentTransformationMatrix
t   := translate
r   := rotate
s   := scale

Equotiation
CTM = t(cx,cy)*r(a)*t(-cx,-cy)*t(x0,y0)*s(sx)

      |1 0 cx| |cos(a) -sin(a) 0| |1 0 -cx| |1 0 x0| |sx 0  0|
CTM = |0 1 cy|*|sin(a)  cos(a) 0|*|0 1 -cy|*|0 1 y0|*|0  sx 0|                            # OK
      |0 0 1 | |  0       0    1| |0 0  1 | |0 0 1 | |0  0  1|

      |1 0 cx| |cos(a) -sin(a) 0| |1 0 -cx| |sx 0  x0|
CTM = |0 1 cy|*|sin(a)  cos(a) 0|*|0 1 -cy|*|0  sx y0|                                    # OK
      |0 0 1 | |  0       0    1| |0 0  1 | |0  0  1 |

      |1 0 cx| |cos(a) -sin(a) 0| |sx 0  x0-cx|
CTM = |0 1 cy|*|sin(a)  cos(a) 0|*|0  sx y0-cy|                                           # OK
      |0 0 1 | |  0       0    1| |0  0  1    |

      |1 0 cx| |sx*cos(a) -sx*sin(a) (x0-cx)*cos(a)-(y0-cy)*sin(a)|
CTM = |0 1 cy|*|sx*sin(a)  sx*cos(a) (x0-cx)*sin(a)+(y0-cy)*cos(a)|                       # OK
      |0 0 1 | |  0          0                        1           |

      |sx*cos(a) -sx*sin(a) (x0-cx)*cos(a)-(y0-cy)*sin(a)+cx|
CTM = |sx*sin(a)  sx*cos(a) (x0-cx)*sin(a)+(y0-cy)*cos(a)+cy|                             # OK
      |  0          0                     1                 |

Check
with sx = 1 and a,x0,y0,cx,cy = 0

      |1 0 0|
CTM = |0 1 0|                                                                             # OK
      |0 0 1|

|x'|         |x|   |sx*cos(a)*x-sx*sin(a)*y+(x0-cx)*cos(a)-(y0-cy)*sin(a)+cx|   |1*x-0*y|
|y'| = CTM * |y| = |sx*sin(a)*x+sx*cos(a)*y+(x0-cx)*sin(a)+(y0-cy)*cos(a)+cy| = |0*x+1*y| # OK
|0 |         |0|   |                       0                                |   |   0   |

**********************************************************************************************/
}
int rlSvgAnimator::setMatrix ( const char *  objectname,
rlSvgPosition pos 
)

The following methods are for moveing and zooming the whole SVG identified by mainObject. default: main.

set transformation matrix of object

Definition at line 458 of file rlsvganimator.cpp.

{
  isModified = 1;
  return setMatrix(objectname, pos.sx, pos.alpha, pos.x0, pos.y0, pos.cx, pos.cy);
}
int rlSvgAnimator::setMouseXY0 ( float  x0,
float  y0 
)

set/get mouse position 0 for the MainObject

Definition at line 645 of file rlsvganimator.cpp.

{
  isModified = 1;
  svgMouseX0 = x0;
  svgMouseY0 = y0;
  return 0;
}
int rlSvgAnimator::setMouseXY1 ( float  x1,
float  y1 
)

set/get mouse position 1 for the MainObject

Definition at line 663 of file rlsvganimator.cpp.

{
  isModified = 1;
  svgMouseX1 = x1;
  svgMouseY1 = y1;
  return 0;
}
int rlSvgAnimator::setScale ( float  scale)

set/get the scaling factor for the MainObject

Definition at line 681 of file rlsvganimator.cpp.

{
  isModified = 1;
  svgScale = scale;
  return 0;
}
int rlSvgAnimator::setSocket ( int *  socket)

initialize the socket with pvbrowser p->s

Definition at line 270 of file rlsvganimator.cpp.

{
  isModified = 1;
  s = socket;
  return 0;
}
int rlSvgAnimator::setWindowSize ( int  width,
int  height 
)

call this method when the widget is resized

Definition at line 739 of file rlsvganimator.cpp.

{
  isModified = 1;
  svgWindowWidth  = (float) width;
  svgWindowHeight = (float) height;
  return 0;
}
int rlSvgAnimator::setXY0 ( float  x0,
float  y0 
)

set/get x0,y0 coordinates for the MainObject

Definition at line 627 of file rlsvganimator.cpp.

{
  isModified = 1;
  svgX0 = x0;
  svgY0 = y0;
  return 0;
}
int rlSvgAnimator::show ( const char *  objectname,
int  state 
)

hide/show object state := 0=hide 1=show

Definition at line 441 of file rlsvganimator.cpp.

{
  rlDebugPrintf("rlSvgAnimator.show state=%d objectname=%s\n",state,objectname);
  isModified = 1;
  if(id != 0)
  {
    char buf[MAXLINE];
    sprintf(buf,"gsvgShow(%d,%d)\n",id,state);
    printf("buf=%s",buf);
    tcpsend(buf, strlen(buf));
    sprintf(buf,"%s\n",objectname);
    tcpsend(buf, strlen(buf));
    return 0;
  }
  return -1;
}
int rlSvgAnimator::svgPrintf ( const char *  objectname,
const char *  tag,
const char *  format,
  ... 
)

change a property of tag = "name="

Definition at line 306 of file rlsvganimator.cpp.

{
  char buf[MAXBUF+40];
  char text[MAXBUF];
  int  len = strlen(objectname);

  isModified = 1;
  if(id != 0)
  {
    sprintf(buf,"gsvgPrintf(%d)\n",id);
    tcpsend(buf, strlen(buf));
    sprintf(buf,"%s\n",objectname);
    tcpsend(buf, strlen(buf));
    sprintf(buf,"%s\n",tag);
    tcpsend(buf, strlen(buf));
    va_list ap;
    va_start(ap,format);
#ifdef RLWIN32
    _vsnprintf(text, MAXBUF - 1, format, ap);
#endif
#ifdef __VMS
    vsprintf(text, format, ap);
#endif
#ifdef RLUNIX
    vsnprintf(text, MAXBUF - 1, format, ap);
#endif
    va_end(ap);
    strcat(text,"\n");
    len = strlen(text);
    tcpsend(text, len);
    return len;
  }
  return -1;
}
int rlSvgAnimator::svgRecursivePrintf ( const char *  objectname,
const char *  tag,
const char *  format,
  ... 
)

recursively change a property of tag = "name="

Definition at line 341 of file rlsvganimator.cpp.

{
  char buf[MAXBUF+40];
  char text[MAXBUF];
  int  len;

  isModified = 1;
  sprintf(buf,"gsvgRecursivePrintf(%d)\n",id);
  tcpsend(buf, strlen(buf));
  sprintf(buf,"%s\n",objectname);
  tcpsend(buf, strlen(buf));
  sprintf(buf,"%s\n",tag);
  tcpsend(buf, strlen(buf));
  va_list ap;
  va_start(ap,format);
#ifdef RLWIN32
  _vsnprintf(text, MAXBUF - 1, format, ap);
#endif
#ifdef __VMS
  vsprintf(text, format, ap);
#endif
#ifdef RLUNIX
  vsnprintf(text, MAXBUF - 1, format, ap);
#endif
  va_end(ap);
  strcat(text,"\n");
  len = strlen(text);
  tcpsend(text, len);
  return len;
}
int rlSvgAnimator::svgRecursiveSearchAndReplace ( const char *  objectname,
const char *  tag,
const char *  before,
const char *  after 
)

recursively search for "before" within "tag=" property and replace it with "after". You may use wildcards within "before"

Definition at line 390 of file rlsvganimator.cpp.

{
  char buf[MAXBUF+40];

  isModified = 1;
  sprintf(buf,"gsvgRecursiveSearchAndReplace(%d)\n",id);
  tcpsend(buf, strlen(buf));
  sprintf(buf,"%s\n",objectname);
  tcpsend(buf, strlen(buf));
  sprintf(buf,"%s\n",tag);
  tcpsend(buf, strlen(buf));
  sprintf(buf,"%s\n",before);
  tcpsend(buf, strlen(buf));
  sprintf(buf,"%s\n",after);
  tcpsend(buf, strlen(buf));
  return 0;
}
int rlSvgAnimator::svgSearchAndReplace ( const char *  objectname,
const char *  tag,
const char *  before,
const char *  after 
)

search for "before" within "tag=" property and replace it with "after". You may use wildcards whin "before"

Definition at line 372 of file rlsvganimator.cpp.

{
  char buf[MAXBUF+40];

  isModified = 1;
  sprintf(buf,"gsvgSearchAndReplace(%d)\n",id);
  tcpsend(buf, strlen(buf));
  sprintf(buf,"%s\n",objectname);
  tcpsend(buf, strlen(buf));
  sprintf(buf,"%s\n",tag);
  tcpsend(buf, strlen(buf));
  sprintf(buf,"%s\n",before);
  tcpsend(buf, strlen(buf));
  sprintf(buf,"%s\n",after);
  tcpsend(buf, strlen(buf));
  return 0;
}
int rlSvgAnimator::svgTextPrintf ( const char *  objectname,
const char *  format,
  ... 
)

change the text of "objectname"

Definition at line 408 of file rlsvganimator.cpp.

{
  char buf[MAXBUF+40];
  char text[MAXBUF];
  int  len = strlen(objectname);

  isModified = 1;
  if(id != 0)
  {
    sprintf(buf,"gsvgTextPrintf(%d)\n",id);
    tcpsend(buf, strlen(buf));
    sprintf(buf,"%s\n",objectname);
    tcpsend(buf, strlen(buf));
    va_list ap;
    va_start(ap,format);
#ifdef RLWIN32
    _vsnprintf(text, MAXBUF - 1, format, ap);
#endif
#ifdef __VMS
    vsprintf(text, format, ap);
#endif
#ifdef RLUNIX
    vsnprintf(text, MAXBUF - 1, format, ap);
#endif
    va_end(ap);
    strcat(text,"\n");
    len = strlen(text);
    tcpsend(text, len);
    return len;
  }
  return -1;
}
int rlSvgAnimator::tcpsend ( const char *  buf,
int  len 
) [private]

Definition at line 133 of file rlsvganimator.cpp.

{
  int ret,bytes_left,first_byte;

  if(s == NULL) return -1;
  //rlDebugPrintf("tcpsend len=%d buf=%s",len,buf);
  bytes_left = len;
  first_byte = 0;
  while(bytes_left > 0)
  {
    if(*s == 1) // use stdout
    {
#ifdef __VMS
      ret = send(1,&buf[first_byte],bytes_left,MSG_NOSIGNAL);
#else
      ret = write(1,&buf[first_byte],bytes_left);
#endif
      if(ret <= 0) 
      {
        *s = -1;
        return -1;
      }
    }
    else // use socket
    {
      ret = send(*s,&buf[first_byte],bytes_left,MSG_NOSIGNAL);
      if(ret <= 0) 
      {
        *s = -1;
        return -1;
      }
    }
    bytes_left -= ret;
    first_byte += ret;
  }
  return 0;
}
float rlSvgAnimator::windowHeight ( )

Definition at line 752 of file rlsvganimator.cpp.

{
  return svgWindowHeight;
}
float rlSvgAnimator::windowWidth ( )

Definition at line 747 of file rlsvganimator.cpp.

{
  return svgWindowWidth;
}
int rlSvgAnimator::writeSocket ( )

The following methods are for modifying a object within a SVG graphic identified by objectname.

update the SVG graphic with: gBeginDraw(p,id); d->svgAnimator.writeSocket(); gEndDraw(p);

Definition at line 284 of file rlsvganimator.cpp.

{
  char buf[80];
  
  isModified = 0;

  if(s == NULL)
  {
    printf("rlSvgAnimator: ERROR please use setSocket first\n");
    return -1;
  }
  if(id != 0)
  {
    sprintf(buf,"gupdateSVG(%d)\n",id);
    tcpsend(buf, strlen(buf));
    return 0;
  }
  return -1;
}
float rlSvgAnimator::x0 ( )

Definition at line 635 of file rlsvganimator.cpp.

{
  return svgX0;
}
float rlSvgAnimator::y0 ( )

Definition at line 640 of file rlsvganimator.cpp.

{
  return svgY0;
}
int rlSvgAnimator::zoomCenter ( float  newScale)

zooms the whole SVG graphic keeping it centered to the viewport

Definition at line 693 of file rlsvganimator.cpp.

{
  float oldX0, oldY0;

  isModified = 1;
  if (newScale > 1000) newScale = 1000.0f;

  oldX0 = (svgX0 - ((svgWindowWidth) * (1.0f - svgScale)) / 2.0f) / svgScale;
  oldY0 = (svgY0 - ((svgWindowHeight) * (1.0f - svgScale)) / 2.0f) / svgScale;

  svgScale  = newScale;

  svgX0 = oldX0*svgScale + ((svgWindowWidth) * (1.0f - svgScale)) / 2.0f;
  svgY0 = oldY0*svgScale + ((svgWindowHeight) * (1.0f - svgScale)) / 2.0f;

  return 0;
}
int rlSvgAnimator::zoomRect ( )

zooms the whole SVG graphic so that the visible section is from x0,x0 to x1,y1

Definition at line 711 of file rlsvganimator.cpp.

{
  float newScale, scale1, scale2, rectWidth, rectHeight;

  isModified = 1;
  rectWidth  = svgMouseX1-svgMouseX0;
  rectHeight = svgMouseY1-svgMouseY0;
  svgX0 = svgX0 + svgWindowWidth/2  - (svgMouseX0 + rectWidth/2);
  svgY0 = svgY0 + svgWindowHeight/2 - (svgMouseY0 + rectHeight/2);
  rectWidth  = rectWidth  / svgScale;
  rectHeight = rectHeight / svgScale;
  scale1 = svgWindowWidth  / rectWidth;
  scale2 = svgWindowHeight / rectHeight;

  if(scale1 < scale2) newScale = scale1;
  else                newScale = scale2;
  zoomCenter(newScale);

  return 0;
}

Member Data Documentation

int rlSvgAnimator::id [private]

Definition at line 126 of file rlsvganimator.h.

Definition at line 122 of file rlsvganimator.h.

Definition at line 123 of file rlsvganimator.h.

Definition at line 122 of file rlsvganimator.h.

Definition at line 124 of file rlsvganimator.h.

Definition at line 116 of file rlsvganimator.h.

Definition at line 129 of file rlsvganimator.h.

int* rlSvgAnimator::s [private]

Definition at line 125 of file rlsvganimator.h.

float rlSvgAnimator::svgMouseX0 [private]

Definition at line 128 of file rlsvganimator.h.

float rlSvgAnimator::svgMouseX1 [private]

Definition at line 128 of file rlsvganimator.h.

float rlSvgAnimator::svgMouseY0 [private]

Definition at line 128 of file rlsvganimator.h.

float rlSvgAnimator::svgMouseY1 [private]

Definition at line 128 of file rlsvganimator.h.

float rlSvgAnimator::svgScale [private]

Definition at line 128 of file rlsvganimator.h.

Definition at line 128 of file rlsvganimator.h.

Definition at line 128 of file rlsvganimator.h.

float rlSvgAnimator::svgX0 [private]

Definition at line 128 of file rlsvganimator.h.

float rlSvgAnimator::svgY0 [private]

Definition at line 128 of file rlsvganimator.h.


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