Add capability to label Axes

This commit is contained in:
Vince Weaver 2012-05-09 17:17:32 -04:00
parent a6aa19c8b9
commit e8fd1c403d
3 changed files with 97 additions and 5 deletions

View File

@ -148,6 +148,22 @@ struct slide_info {
#define LINES_PER_SLIDE 100
static void print_number(int line_num, int x, int y, char *string) {
int i,first=1,ourx=x;
printf("%d",line_num);
for(i=0;i<strlen(string);i++) {
printf("%s XDRAW %d AT %d,%d ",
first?" ":":",(string[i]-'0')+1,
ourx,y);
first=0;
ourx+=10;
}
printf("\n");
}
static void generate_slide(int num, int max, char*filename) {
int line_num;
@ -180,8 +196,11 @@ static void generate_slide(int num, int max, char*filename) {
int num_plots=0,plot,color;
double maxx,maxy,x,y;
int applex,appley,hplot_num,first=1;
int xpoints,ypoints;
int axesx,axesy;
char axes_string[BUFSIZ];
#define HPLOTS_ON_LINE 5
#define HPLOTS_ON_LINE 6
result=fgets(type,BUFSIZ,fff);
@ -202,6 +221,52 @@ static void generate_slide(int num, int max, char*filename) {
break;
}
/* Draw the Axes */
printf("%d HCOLOR=3:HPLOT 0,0 TO 0,159: HPLOT 1,1 TO 1,159\n",
line_num); line_num++;
printf("%d HPLOT 0,159 TO 279,159\n",
line_num); line_num++;
/* get the axes ticks */
while(1) {
result=fgets(string,BUFSIZ,fff);
if (result==NULL) break;
if ((string[0]=='#') || (string[0]=='\n')) continue;
sscanf(string,"%d %d",&xpoints,&ypoints);
break;
}
printf("%d FOR I=0 TO 279 STEP %d: "
"HPLOT I,155 TO I,159: NEXT I\n",
line_num,280/xpoints); line_num++;
printf("%d FOR I=159 TO 0 STEP -%d: "
"HPLOT 0,I TO 4,I: NEXT I\n",
line_num,160/ypoints); line_num++;
/* Look for START */
while(1) {
result=fgets(string,BUFSIZ,fff);
if (result==NULL) break;
if ((string[0]=='#') || (string[0]=='\n')) continue;
if (strstr(string,"START")) break;
}
/* Number the Axes */
while(1) {
result=fgets(string,BUFSIZ,fff);
if (result==NULL) break;
if ((string[0]=='#') || (string[0]=='\n')) continue;
if (strstr(string,"STOP")) break;
sscanf(string,"%d %d %s",&axesx,&axesy,axes_string);
print_number(line_num,axesx,axesy,axes_string); line_num++;
}
/* get number of plots */
while(1) {
result=fgets(string,BUFSIZ,fff);
@ -259,6 +324,16 @@ static void generate_slide(int num, int max, char*filename) {
printf("\n");
}
/* Print remaining text */
printf("%d VTAB 21\n",line_num); line_num++;
while(1) {
result=fgets(string,BUFSIZ,fff);
if (result==NULL) break;
string[strlen(string)-1]='\0';
printf("%d PRINT \"%s\"\n",line_num,string); line_num++;
}
}
else if (strstr(type,"HGR2")) {
printf("%d HGR2\n",line_num); line_num++;

View File

@ -23,5 +23,5 @@ demo.bas: ../asoft_presenter
../asoft_presenter . > demo.bas
clean:
rm -f *~ *.IMG *.bas PRESENTER_DEMO
rm -f *~ *.IMG *.bas PRESENTER_DEMO NUM.SHAPE

View File

@ -1,8 +1,25 @@
HGR_PLOT
# data x and y size
40 70
1
# Axes ticks
4 4
# Labels
START
65 150 10
135 150 20
205 150 30
#
11 40 60
11 80 40
11 120 20
STOP
# number of plots
1
# beginning of plot 1 (Power vs Time)
START
# Color of Plot (Red/Orange)
5
# Data
0 32.4
1 32.3
2 52.8
@ -44,6 +61,6 @@ START
38 35.4
39 35.1
STOP
WATTS TIME(seconds)
Average Power (W) versus Time (s)
Blah Blah Blah Measured
PLASMA Cholesky on Intel Core2