rllib  1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
rlSvgAnimator Class Reference

#include <rlsvganimator.h>

Collaboration diagram for rlSvgAnimator:
Collaboration graph
[legend]

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 svgRemoveStyleOption (const char *objectname, const char *option)
 
int svgRecursiveRemoveStyleOption (const char *objectname, const char *option)
 
int svgChangeStyleOption (const char *objectname, const char *option, const char *value)
 
int svgRecursiveChangeStyleOption (const char *objectname, const char *option, const char *value)
 
int svgSetStyleOption (const char *objectname, const char *value)
 
int svgRecursiveSetStyleOption (const char *objectname, const char *value)
 
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;
// zoomer follows
svgX0 = svgY0 = 0.0f;
svgScale = 1.0f;
svgWindowWidth = 640.0f;
svgWindowHeight = 480.0f;
}
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 697 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 639 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));
}
}
inifileCount = 0;
}
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';
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 722 of file rlsvganimator.cpp.

{
}
float rlSvgAnimator::mouseX0 ( )

Definition at line 753 of file rlsvganimator.cpp.

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

Definition at line 771 of file rlsvganimator.cpp.

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

Definition at line 758 of file rlsvganimator.cpp.

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

Definition at line 776 of file rlsvganimator.cpp.

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

move MainObject to position

Definition at line 857 of file rlsvganimator.cpp.

{
float xx0 = x0() + (x - mouseX0());
float yy0 = y0() + (y - mouseY0());
setXY0(xx0,yy0);
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.

{
#ifdef RLUNIX
rlSpawn rlsvg;
int ret, use_stdout;
char command[MAXLINE];
const char *line;
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;
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 788 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.

{
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 714 of file rlsvganimator.cpp.

{
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 832 of file rlsvganimator.cpp.

{
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 564 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;
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 558 of file rlsvganimator.cpp.

{
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 745 of file rlsvganimator.cpp.

{
return 0;
}
int rlSvgAnimator::setMouseXY1 ( float  x1,
float  y1 
)

set/get mouse position 1 for the MainObject

Definition at line 763 of file rlsvganimator.cpp.

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

set/get the scaling factor for the MainObject

Definition at line 781 of file rlsvganimator.cpp.

{
return 0;
}
int rlSvgAnimator::setSocket ( int *  socket)

initialize the socket with pvbrowser p->s

Definition at line 270 of file rlsvganimator.cpp.

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

call this method when the widget is resized

Definition at line 839 of file rlsvganimator.cpp.

{
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 727 of file rlsvganimator.cpp.

{
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 541 of file rlsvganimator.cpp.

{
rlDebugPrintf("rlSvgAnimator.show state=%d objectname=%s\n",state,objectname);
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::svgChangeStyleOption ( const char *  objectname,
const char *  option,
const char *  value 
)

change a style option of "objectname". option must end with ':'. Example: option="stroke:" value="#000000"

Definition at line 473 of file rlsvganimator.cpp.

{
char buf[MAXBUF+40];
sprintf(buf,"gsvgChangeStyleOption(%d)\n",id);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",objectname);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n","style=");
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",option);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",value);
tcpsend(buf, strlen(buf));
return 0;
}
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);
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::svgRecursiveChangeStyleOption ( const char *  objectname,
const char *  option,
const char *  value 
)

recursively change a style option of "objectname". option must end with ':'. Example: option="stroke:" value="#000000"

Definition at line 491 of file rlsvganimator.cpp.

{
char buf[MAXBUF+40];
sprintf(buf,"gsvgRecursiveChangeStyleOption(%d)\n",id);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",objectname);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n","style=");
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",option);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",value);
tcpsend(buf, strlen(buf));
return 0;
}
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;
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::svgRecursiveRemoveStyleOption ( const char *  objectname,
const char *  option 
)

recursively remove a style option of "objectname". option must end with ':'. Example: option="stroke:"

Definition at line 457 of file rlsvganimator.cpp.

{
char buf[MAXBUF+40];
sprintf(buf,"gsvgRecursiveRemoveStyleOption(%d)\n",id);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",objectname);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n","style=");
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",option);
tcpsend(buf, strlen(buf));
return 0;
}
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];
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::svgRecursiveSetStyleOption ( const char *  objectname,
const char *  value 
)

recursively set a style option of "objectname". option must end with ':'. Example: value="fill:#9d9d9d;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"

Definition at line 525 of file rlsvganimator.cpp.

{
char buf[MAXBUF+40];
sprintf(buf,"gsvgRecursiveSetStyleOption(%d)\n",id);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",objectname);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n","style=");
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",value);
tcpsend(buf, strlen(buf));
return 0;
}
int rlSvgAnimator::svgRemoveStyleOption ( const char *  objectname,
const char *  option 
)

remove a style option of "objectname". option must end with ':'. Example: option="stroke:"

Definition at line 441 of file rlsvganimator.cpp.

{
char buf[MAXBUF+40];
sprintf(buf,"gsvgRemoveStyleOption(%d)\n",id);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",objectname);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n","style=");
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",option);
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];
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::svgSetStyleOption ( const char *  objectname,
const char *  value 
)

set a style option of "objectname". option must end with ':'. Example: value="fill:#9d9d9d;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"

Definition at line 509 of file rlsvganimator.cpp.

{
char buf[MAXBUF+40];
sprintf(buf,"gsvgSetStyleOption(%d)\n",id);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",objectname);
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n","style=");
tcpsend(buf, strlen(buf));
sprintf(buf,"%s\n",value);
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);
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 852 of file rlsvganimator.cpp.

{
}
float rlSvgAnimator::windowWidth ( )

Definition at line 847 of file rlsvganimator.cpp.

{
}
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];
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 735 of file rlsvganimator.cpp.

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

Definition at line 740 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 793 of file rlsvganimator.cpp.

{
float oldX0, oldY0;
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 811 of file rlsvganimator.cpp.

{
float newScale, scale1, scale2, rectWidth, rectHeight;
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 138 of file rlsvganimator.h.

int rlSvgAnimator::inifileCount
private

Definition at line 134 of file rlsvganimator.h.

rlSpreadsheetCell rlSvgAnimator::inifileID
private

Definition at line 135 of file rlsvganimator.h.

int rlSvgAnimator::inifileState
private

Definition at line 134 of file rlsvganimator.h.

rlSpreadsheetTable rlSvgAnimator::inifileTable
private

Definition at line 136 of file rlsvganimator.h.

int rlSvgAnimator::isModified

Definition at line 128 of file rlsvganimator.h.

rlString rlSvgAnimator::main_object_name
private

Definition at line 141 of file rlsvganimator.h.

int* rlSvgAnimator::s
private

Definition at line 137 of file rlsvganimator.h.

float rlSvgAnimator::svgMouseX0
private

Definition at line 140 of file rlsvganimator.h.

float rlSvgAnimator::svgMouseX1
private

Definition at line 140 of file rlsvganimator.h.

float rlSvgAnimator::svgMouseY0
private

Definition at line 140 of file rlsvganimator.h.

float rlSvgAnimator::svgMouseY1
private

Definition at line 140 of file rlsvganimator.h.

float rlSvgAnimator::svgScale
private

Definition at line 140 of file rlsvganimator.h.

float rlSvgAnimator::svgWindowHeight
private

Definition at line 140 of file rlsvganimator.h.

float rlSvgAnimator::svgWindowWidth
private

Definition at line 140 of file rlsvganimator.h.

float rlSvgAnimator::svgX0
private

Definition at line 140 of file rlsvganimator.h.

float rlSvgAnimator::svgY0
private

Definition at line 140 of file rlsvganimator.h.


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