32 #define MSG_NOSIGNAL 0 35 #include <sys/socket.h> 36 #include <netinet/in.h> 37 #include <arpa/inet.h> 43 #define MSG_NOSIGNAL 0 47 #define MSG_NOSIGNAL 0 50 #define MAXLINE 256*256 135 int ret,bytes_left,first_byte;
137 if(
s == NULL)
return -1;
141 while(bytes_left > 0)
148 ret = write(1,&buf[first_byte],bytes_left);
182 if(inifile == NULL) use_stdout = 0;
184 if(
s != NULL && *
s == 1) use_stdout = 1;
189 sprintf(command,
"rlsvgcat %s",infile);
190 ret = rlsvg.
spawn(command);
191 if(ret < 0)
return -1;
196 if(
id != 0 &&
s != NULL)
198 sprintf(command,
"gsvgRead(%d)\n",
id);
199 tcpsend(command,strlen(command));
202 while((line = rlsvg.
readLine()) != NULL)
210 sprintf(command,
"/usr/bin/rlsvgcat %s",infile);
211 ret = system(command);
212 if(ret == -1)
return -1;
216 sprintf(outfile,
"PVTMP%d.svg",*
s);
217 sprintf(command,
"/usr/bin/rlsvgcat %s %s",infile,outfile);
218 ret = system(command);
219 if(ret == -1)
return -1;
224 sprintf(command,
"\n<svgend></svgend>\n");
225 tcpsend(command,strlen(command));
244 if(
s==NULL) sprintf(filename,
"PVTEMP%s",infile);
245 else sprintf(filename,
"PVTEMP%d%s",*
s,infile);
246 sprintf(cmd,
"rlsvgcat %s %s",infile,filename);
248 if(ret < 0)
return -1;
249 fin = fopen(filename,
"r");
250 if(fin == NULL)
return -1;
251 sprintf(command,
"gsvgRead(%d)\n",
id);
252 tcpsend(command,strlen(command));
253 while(fgets(line,
sizeof(line)-1,fin) != NULL)
255 cptr = strchr(line,0x0d);
256 if(cptr != NULL) *cptr =
'\0';
257 cptr = strchr(line,0x0a);
258 if(cptr != NULL) *cptr =
'\0';
263 sprintf(command,
"\n<svgend></svgend>\n");
264 tcpsend(command, strlen(command));;
292 printf(
"rlSvgAnimator: ERROR please use setSocket first\n");
297 sprintf(buf,
"gupdateSVG(%d)\n",
id);
310 int len = strlen(objectname);
315 sprintf(buf,
"gsvgPrintf(%d)\n",
id);
317 sprintf(buf,
"%s\n",objectname);
319 sprintf(buf,
"%s\n",tag);
324 _vsnprintf(text,
MAXBUF - 1, format, ap);
327 vsprintf(text, format, ap);
330 vsnprintf(text,
MAXBUF - 1, format, ap);
348 sprintf(buf,
"gsvgRecursivePrintf(%d)\n",
id);
350 sprintf(buf,
"%s\n",objectname);
352 sprintf(buf,
"%s\n",tag);
357 _vsnprintf(text,
MAXBUF - 1, format, ap);
360 vsprintf(text, format, ap);
363 vsnprintf(text,
MAXBUF - 1, format, ap);
377 sprintf(buf,
"gsvgSearchAndReplace(%d)\n",
id);
379 sprintf(buf,
"%s\n",objectname);
381 sprintf(buf,
"%s\n",tag);
383 sprintf(buf,
"%s\n",before);
385 sprintf(buf,
"%s\n",after);
395 sprintf(buf,
"gsvgRecursiveSearchAndReplace(%d)\n",
id);
397 sprintf(buf,
"%s\n",objectname);
399 sprintf(buf,
"%s\n",tag);
401 sprintf(buf,
"%s\n",before);
403 sprintf(buf,
"%s\n",after);
412 int len = strlen(objectname);
417 sprintf(buf,
"gsvgTextPrintf(%d)\n",
id);
419 sprintf(buf,
"%s\n",objectname);
424 _vsnprintf(text,
MAXBUF - 1, format, ap);
427 vsprintf(text, format, ap);
430 vsnprintf(text,
MAXBUF - 1, format, ap);
446 sprintf(buf,
"gsvgRemoveStyleOption(%d)\n",
id);
448 sprintf(buf,
"%s\n",objectname);
450 sprintf(buf,
"%s\n",
"style=");
452 sprintf(buf,
"%s\n",option);
462 sprintf(buf,
"gsvgRecursiveRemoveStyleOption(%d)\n",
id);
464 sprintf(buf,
"%s\n",objectname);
466 sprintf(buf,
"%s\n",
"style=");
468 sprintf(buf,
"%s\n",option);
478 sprintf(buf,
"gsvgChangeStyleOption(%d)\n",
id);
480 sprintf(buf,
"%s\n",objectname);
482 sprintf(buf,
"%s\n",
"style=");
484 sprintf(buf,
"%s\n",option);
486 sprintf(buf,
"%s\n",value);
496 sprintf(buf,
"gsvgRecursiveChangeStyleOption(%d)\n",
id);
498 sprintf(buf,
"%s\n",objectname);
500 sprintf(buf,
"%s\n",
"style=");
502 sprintf(buf,
"%s\n",option);
504 sprintf(buf,
"%s\n",value);
514 sprintf(buf,
"gsvgSetStyleOption(%d)\n",
id);
516 sprintf(buf,
"%s\n",objectname);
518 sprintf(buf,
"%s\n",
"style=");
520 sprintf(buf,
"%s\n",value);
530 sprintf(buf,
"gsvgRecursiveSetStyleOption(%d)\n",
id);
532 sprintf(buf,
"%s\n",objectname);
534 sprintf(buf,
"%s\n",
"style=");
536 sprintf(buf,
"%s\n",value);
543 rlDebugPrintf(
"rlSvgAnimator.show state=%d objectname=%s\n",state,objectname);
548 sprintf(buf,
"gsvgShow(%d,%d)\n",
id,state);
551 sprintf(buf,
"%s\n",objectname);
576 float a11, a12, a13, a21, a22, a23;
583 a11 = sx*((float) cos(alpha));
584 a12 = -sx*((float) sin(alpha));
585 a13 = (
x0 - cx)*((
float) cos(alpha)) - (
y0 - cy)*((float) sin(alpha)) + cx;
586 a21 = sx*((float) sin(alpha));
587 a22 = sx*((float) cos(alpha));
588 a23 = (
x0 - cx)*((
float) sin(alpha)) + (
y0 - cy)*((float) cos(alpha)) + cy;
593 return svgPrintf(objectname,
"transform=",
"matrix(%f,%f,%f,%f,%f,%f)",a11,a21,a12,a22,a13,a23);
642 char myline[
MAXLINE],*cptr, *cptr2;
647 cptr = strchr(myline,
'\n');
648 if(cptr != NULL) *cptr =
'\0';
650 if(myline[0] ==
'>' || strncmp(myline,
"/>",2) == 0)
665 else if(myline[0] ==
'<')
668 else if(strncmp(myline,
"id=",3) == 0)
670 cptr = strchr(myline,
'=');
674 cptr2 = strchr(cptr,
'\"');
675 if(cptr2 != NULL) *cptr2 =
'\0';
682 cptr = strchr(myline,
'=');
687 cptr2 = strrchr(cptr,
'\"');
688 if(cptr2 != NULL) *cptr2 =
'\0';
703 fin = fopen(infile,
"r");
704 if(fin == NULL)
return -1;
705 while(fgets(line,
sizeof(line)-1,fin) != NULL)
718 if(main_object == NULL)
return -1;
799 if (newScale > 1000) newScale = 1000.0f;
814 float newScale, scale1, scale2, rectWidth, rectHeight;
826 if(scale1 < scale2) newScale = scale1;
827 else newScale = scale2;
int rlDebugPrintf(const char *format,...)
int svgRecursiveRemoveStyleOption(const char *objectname, const char *option)
void moveRelative(float dx, float dy)
int tcpsend(const char *buf, int len)
const char * text(int column, int row)
int setSocket(int *socket)
int read(const char *infile, rlIniFile *inifile=NULL)
int svgRemoveStyleOption(const char *objectname, const char *option)
void setText(int column, int row, const char *text)
void rotate(float alpha, float cx, float cy)
int svgChangeStyleOption(const char *objectname, const char *option, const char *value)
rlSpreadsheetTable inifileTable
void move(float x, float y)
int setWindowSize(int width, int height)
int svgSetStyleOption(const char *objectname, const char *value)
const char * mainObject()
int setXY0(float x0, float y0)
int fillIniFile(rlIniFile *inifile, const char *line)
int svgRecursiveSearchAndReplace(const char *objectname, const char *tag, const char *before, const char *after)
void setText(const char *section, const char *name, const char *text)
int moveMainObject(float x, float y)
int svgPrintf(const char *objectname, const char *tag, const char *format,...)
int setText(const char *text)
int setMatrix(const char *objectname, float sx, float alpha, float x0, float y0, float cx, float cy)
int setMainObject(const char *main_object)
void setText(const char *text)
rlSpreadsheetCell inifileID
int svgSearchAndReplace(const char *objectname, const char *tag, const char *before, const char *after)
int zoomCenter(float newScale)
int setScale(float scale)
int svgTextPrintf(const char *objectname, const char *format,...)
rlString main_object_name
int svgRecursivePrintf(const char *objectname, const char *tag, const char *format,...)
int setMainObjectMatrix()
void setInit(float x0_init, float y0_init, float w_init, float h_init)
int fileFillIniFile(const char *infile, rlIniFile *inifile)
int show(const char *objectname, int state)
int svgRecursiveChangeStyleOption(const char *objectname, const char *option, const char *value)
int svgRecursiveSetStyleOption(const char *objectname, const char *value)
struct rlSvgPosition::rlPositionInit init
int writeSocket()
The following methods are for modifying a object within a SVG graphic identified by objectname...
int spawn(const char *command)
int setMouseXY0(float x0, float y0)
int setMouseXY1(float x1, float y1)
void scaleRelative(float ds)