Diff for dead/diplomovka/xgrafix/src/xgmovie.c between version 1.1 and 1.2
| version 1.1, 2001/09/20 14:12:00 |
version 1.2, 2002/07/07 23:57:58 |
| Line 19 void BXG_Write_2D(DataType theData, Labe |
|
| Line 19 void BXG_Write_2D(DataType theData, Labe |
|
| int i,n; |
int i,n; |
| double xscale, yscale; |
double xscale, yscale; |
| float theTime; |
float theTime; |
| char buf[512]; |
char *buf; |
| xscale = theLabel->X_Scale; |
xscale = theLabel->X_Scale; |
| yscale = theLabel->Y_Scale; |
yscale = theLabel->Y_Scale; |
| |
|
| |
buf = (char *) malloc(strlen(filename) * sizeof(char)); |
| strcpy(buf,filename); |
strcpy(buf,filename); |
| i = strlen(buf); |
sprintf(buf + strlen(buf) -3, "%s", "num"); |
| sprintf(buf +i -3,"%s","num"); |
|
| |
|
| if ((fp = fopen(buf,"r"))==NULL) { |
if ((fp = fopen(buf,"r"))==NULL) { |
| if ((fp = fopen(buf,"w")) == NULL) { |
if ((fp = fopen(buf,"w")) == NULL) { |
| fprintf(stderr,"Error, cannot open %s",buf); |
fprintf(stderr, "Error, cannot open %s", buf); |
| |
free(buf); |
| return; |
return; |
| } |
} |
| n=0; |
n=0; |
| Line 37 void BXG_Write_2D(DataType theData, Labe |
|
| Line 38 void BXG_Write_2D(DataType theData, Labe |
|
| fclose(fp); /* write the first file count */ |
fclose(fp); /* write the first file count */ |
| } |
} |
| else { |
else { |
| fscanf(fp,"%d",&n); |
fscanf(fp, "%d", &n); |
| n+=1; |
n+=1; |
| fclose(fp); |
fclose(fp); |
| fp=fopen(buf,"w"); |
fp=fopen(buf, "w"); |
| fprintf(fp,"%d",n); |
fprintf(fp, "%d", n); |
| fclose(fp); |
fclose(fp); |
| } |
} |
| |
free(buf); |
| |
|
| fp = fopen(filename,"a"); /* always append */ |
fp = fopen(filename,"a"); /* always append */ |
| |
|
| Line 56 void BXG_Write_2D(DataType theData, Labe |
|
| Line 58 void BXG_Write_2D(DataType theData, Labe |
|
| /* tag the file */ |
/* tag the file */ |
| XGWriteStructures(structs,filename); |
XGWriteStructures(structs,filename); |
| i = LINE_PLOT; |
i = LINE_PLOT; |
| if (Is_Scatter(theData)) i = SCATTER_PLOT; |
if (Is_Scatter(theData)) |
| XGWrite(&i,sizeof(int),1,fp,"int"); |
i = SCATTER_PLOT; |
| XGWriteLabel(theLabel,fp); |
XGWrite(&i, sizeof(int), 1, fp, "int"); |
| |
XGWriteLabel(theLabel, fp); |
| XGWrite(&theTime,sizeof(float), 1, fp, "float"); |
XGWrite(&theTime,sizeof(float), 1, fp, "float"); |
| |
|
| while (theData) { |
while (theData) { |
| Line 71 void BXG_Write_2D(DataType theData, Labe |
|
| Line 74 void BXG_Write_2D(DataType theData, Labe |
|
| i = theData->color; |
i = theData->color; |
| XGWrite(&i,sizeof(int), 1, fp, "int"); |
XGWrite(&i,sizeof(int), 1, fp, "int"); |
| |
|
| for (i=0;i<n;i++) { |
for (i = 0; i < n; i++) { |
| float x,y; |
float x,y; |
| x = xscale * CurveX(theData,i); |
x = xscale * CurveX(theData,i); |
| y = yscale * CurveY(theData,i); |
y = yscale * CurveY(theData,i); |
| Line 95 void BXG_Write_3D(DataType theData, Labe |
|
| Line 98 void BXG_Write_3D(DataType theData, Labe |
|
| /* DataType theData = theWindow->data; |
/* DataType theData = theWindow->data; |
| LabelType theLabel= theWindow->label;*/ |
LabelType theLabel= theWindow->label;*/ |
| int i,j,m,n; |
int i,j,m,n; |
| char buf[512]; |
char *buf; |
| double xscale, yscale, zscale; |
double xscale, yscale, zscale; |
| float x,y,z, theTime; |
float x,y,z, theTime; |
| xscale = theLabel->X_Scale; |
xscale = theLabel->X_Scale; |
| yscale = theLabel->Y_Scale; |
yscale = theLabel->Y_Scale; |
| zscale = theLabel->Z_Scale; |
zscale = theLabel->Z_Scale; |
| |
|
| |
buf = (char *) malloc(strlen(filename) * sizeof(char)); |
| strcpy(buf,filename); |
strcpy(buf,filename); |
| i = strlen(buf); |
sprintf(buf + strlen(buf) - 3, "%s", "num"); |
| sprintf(buf +i -3,"%s","num"); |
|
| |
|
| if ((fp = fopen(buf,"r"))==NULL) { |
if ((fp = fopen(buf,"r"))==NULL) { |
| if ((fp = fopen(buf,"w")) == NULL) { |
if ((fp = fopen(buf,"w")) == NULL) { |
| fprintf(stderr,"Error, cannot open %s",buf); |
fprintf(stderr,"Error, cannot open %s",buf); |
| |
free(buf); |
| return; |
return; |
| } |
} |
| n=0; |
n=0; |
| Line 123 void BXG_Write_3D(DataType theData, Labe |
|
| Line 127 void BXG_Write_3D(DataType theData, Labe |
|
| fprintf(fp,"%d",n); |
fprintf(fp,"%d",n); |
| fclose(fp); |
fclose(fp); |
| } |
} |
| |
free(buf); |
| fp = fopen(filename,"a"); |
fp = fopen(filename,"a"); |
| |
|
| if (fp == NULL) { |
if (fp == NULL) { |
| Line 211 void BXG_Write_Vector(DataType theData, |
|
| Line 216 void BXG_Write_Vector(DataType theData, |
|
| int i,j,m,n; |
int i,j,m,n; |
| float x,y,w,z; |
float x,y,w,z; |
| float theTime; |
float theTime; |
| char buf[512]; |
char *buf; |
| |
|
| |
|
| |
buf = (char *) malloc(strlen(filename) * sizeof(char)); |
| strcpy(buf,filename); |
strcpy(buf,filename); |
| i = strlen(buf); |
sprintf(buf + strlen(filename) - 3, "%s", "num"); |
| sprintf(buf +i -3,"%s","num"); |
|
| |
|
| if ((fp = fopen(buf,"r"))==NULL) { |
if ((fp = fopen(buf,"r"))==NULL) { |
| if ((fp = fopen(buf,"w")) == NULL) { |
if ((fp = fopen(buf,"w")) == NULL) { |
| fprintf(stderr,"Error, cannot open %s",buf); |
fprintf(stderr,"Error, cannot open %s",buf); |
| |
free(buf); |
| return; |
return; |
| } |
} |
| n=0; |
n=0; |
| Line 235 void BXG_Write_Vector(DataType theData, |
|
| Line 241 void BXG_Write_Vector(DataType theData, |
|
| fprintf(fp,"%d",n); |
fprintf(fp,"%d",n); |
| fclose(fp); |
fclose(fp); |
| } |
} |
| |
free(buf); |
| |
|
| fp = fopen(filename,"a"); |
fp = fopen(filename,"a"); |
| |
|
| Line 346 void XGWriteLabel(LabelType theLabel, FI |
|
| Line 353 void XGWriteLabel(LabelType theLabel, FI |
|
| void XGWriteStructures(StructType *s, char *filename) |
void XGWriteStructures(StructType *s, char *filename) |
| { |
{ |
| FILE *fp; |
FILE *fp; |
| char buf[512]; |
char *buf; |
| int l; |
int l; |
| float temp; |
float temp; |
| char *dest; |
char *dest; |
| Line 354 void XGWriteStructures(StructType *s, ch |
|
| Line 361 void XGWriteStructures(StructType *s, ch |
|
| |
|
| if (!s) |
if (!s) |
| return; |
return; |
| |
|
| |
/* alocate memeory to buf + (strlen(".str") - 1) */ |
| |
buf = (char *) malloc((strlen(filename) + 3) * sizeof(char)); |
| strcpy(buf,filename); |
strcpy(buf,filename); |
| if ((dest=strstr(buf,"_"))) /* if an underscore is found in the filename*/ { |
if ((dest=strstr(buf,"_"))) /* if an underscore is found in the filename*/ { |
| sprintf(dest,".str"); |
sprintf(dest,".str"); |
| } |
} |
| else { |
else |
| l = strlen(buf); |
sprintf(buf + strlen(buf) - 3, "%s", "str"); |
| sprintf(buf +l -3,"%s","str"); |
|
| } |
|
| /* if there's already a struct file return: we don't need to redo it. */ |
/* if there's already a struct file return: we don't need to redo it. */ |
| if ((fp=fopen(buf,"r"))) { |
if ((fp=fopen(buf,"r"))) { |
| fclose(fp); |
fclose(fp); |
| |
free(buf); |
| return; |
return; |
| } |
} |
| if ((fp=fopen(buf,"w"))==NULL) { |
if ((fp=fopen(buf,"w"))==NULL) { |
| fprintf(stderr,"\nError: cannot open file %s\n",buf); |
fprintf(stderr,"\nError: cannot open file %s\n",buf); |
| |
free(buf); |
| return; |
return; |
| } |
} |
| |
free(buf); |
| |
|
| while (s) { |
while (s) { |
| XGWrite(&(s->numberPoints),sizeof(int),1,fp,"int"); |
XGWrite(&(s->numberPoints),sizeof(int),1,fp,"int"); |
Platon Group <platon@platon.org> http://platon.org/
|
|