[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mgp-users 00735] request and contribution



Fellow users, 

I am wondering about the possibility of getting a new feature into magic
point.  I am not a good enough programmer to do it myself. I find myself
wanting to have the ability, especially when teaching, to slowly reveal
an overhead transparency by overlaying a sheet of paper on top of the
transparency. I know that the pause command allows us to do this to a
great extent, but sometimes I scan in an image that I would also like to
do this with.  So I am wondering, is it possible to have the screen
blacked out initially and then with each press of some designated key on
the keyboard slowly reveal the image that is displayed by "scrolling"
the blackened portion towards the bottom of the screen? Suggestions?

Also, I am including two programs that I have written, as modifications
to another user's program, that allows the relatively simple
incorporation of latex expressions into magic point presentations.  The
first program takes flagged latex expressions and turns them into
encapsulated postscript images, but saves the original expressions in
the magic point file.  The second program provides for the reverse
operation so that you can edit these expressions and then simply rerun
the first program.  

Cheers, 
Will
-- 
W.G. Wilson
Department of Biology          
Box 90338        			   
Biological Sciences 033   	   
Duke University           
Durham, NC 27708

Phone: (919) 660-7346
Fax:   (919) 660-7293
http://www.biology.duke.edu/group/wilson/


/*  mgptex

  This program replaces

  \beginlatex
  eqn
  <LaTeX formula>
  \endlatex

  with

  %%\beginlatex
  %%eqn
  %%<LaTeX formula>
  %%\endlatex
  %image "eqn.eps" 0 200 200 1

  where n is the number of the formula and generates the formula
  as encapsulates postscript in "n.eps". IT DELETES ALL TEX AND DVI
  FILES FROM THE DIRECTORY!!!

  Anders Logg, logg@math.chalmers.se
  2000-03-15
  modified 9/19/2001 will wilson, wgw@duke.edu
  
cc -o mgptex mgptex.c
uses files  mgptexbackup.mgp mgptextemp.mgp 

example use with mgp file  "demofile.mgp":

mgptex demofile

  */

#include <stdio.h>
#include <stdlib.h>

#define IDENTIFIER_START       "\\beginlatex\n"
#define IDENTIFIER_END         "\\endlatex\n"
#define LINELENGTH             1024
#define DEFAULT                0
#define START                  1
#define READING                2
#define END                    3

int main(int argc, char **argv)
{
  FILE *fp_in, *fp_out, *fp_tex;
  char cLine[LINELENGTH];
  char cCommand[LINELENGTH];
  char cOutFileName[LINELENGTH];
  char cTeXFile[LINELENGTH];
  char cTeXFileName[LINELENGTH];
  char c;
  int  iCounter = 1;
  int  iMode = DEFAULT;
  
  /* Check arguments */
  if ( argc != 2 ){
         printf("Usage: mgptex presentation\n");
         exit(0);
  } 
  
  
  /* Open files */
  sprintf(cOutFileName,"%s.mgp",argv[1]);
  fp_in  = fopen(cOutFileName,"r");
  sprintf(cCommand,"cp %s.mgp mgptexbackup.mgp\n",argv[1]);
  system(cCommand);
  
  sprintf(cOutFileName,"mgptextemp.mgp");
  fp_out = fopen(cOutFileName,"w");

  /* Go through the file */
  while ( (c=getc(fp_in)) != EOF ){
         
         /* Put the character pack */
         ungetc(c,fp_in);

         /* Read line */
         fgets(cLine,LINELENGTH,fp_in);

         /* Check for start */
         if ( strcasecmp(cLine,IDENTIFIER_START) == 0 )
                iMode = START;

         /* Check for end */
         if ( strcasecmp(cLine,IDENTIFIER_END) == 0 )
                iMode = END;

         /* Parse */
         switch (iMode){
         case START:
                /* A comment */
                fprintf(fp_out,"%%%%\\beginlatex\n");
                /* Read next line, which is the mgp specification for
the formula name */
/*                 fgets(cTeXFileName,LINELENGTH,fp_in);
 */             fscanf(fp_in,"%s\n",cTeXFileName);
                fprintf(fp_out,"%%%%%s\n",cTeXFileName);
                sprintf(cTeXFile,"%s.tex",cTeXFileName);
                 /* Start the latex file */
                fp_tex = fopen(cTeXFile,"w");
                fprintf(fp_tex,"\\documentclass[12pt]{article}\n");
                fprintf(fp_tex,"\\thispagestyle{empty}\n");
                fprintf(fp_tex,"\\begin{document}\n");
                fprintf(fp_tex,"\\huge\n");
                /* Change the mode to READING */
                iMode = READING;
                break;
         case READING:
                fprintf(fp_tex,"%s",cLine);
                fprintf(fp_out,"%%%%%s",cLine);
                break;
         case END:
                /* End the tex file */
                fprintf(fp_out,"%%%%\\endlatex\n");
                /* Put in the image */
                fprintf(fp_out,"%%image \"%s.eps\" 0 200 200
1\n",cTeXFileName);
                fprintf(fp_tex,"\\end{document}\n");
                fclose(fp_tex);
                /* Write a message */
                printf("\nGenerating LaTeX formula number
%d.\n",iCounter);
                /* Generate the eps file */
                sprintf(cCommand,"latex %s.tex; dvips -E -o %s.eps
%s.dvi\n",
                                 
cTeXFileName,cTeXFileName,cTeXFileName);
                system(cCommand);
                sprintf(cCommand,"rm %s.tex %s.dvi %s.log %s.aux\n",
                         
cTeXFileName,cTeXFileName,cTeXFileName,cTeXFileName);
                system(cCommand);
                /* Step the counter */
                iCounter += 1;
                /* Set the mode to DEFAULT */
                iMode = DEFAULT;
                break;
         default:
                fprintf(fp_out,"%s",cLine);
         }
           
  }
	if(iCounter>1)
	{
		sprintf(cCommand,"mv mgptextemp.mgp %s.mgp\n",argv[1]);
		system(cCommand);
	}
	else system("rm mgptextemp.mgp\n");

  /* Write a message */
  printf("\n%d formula(s) generated.\n",iCounter-1);
  
}






/*  mgpuntex

  This program replaces

  %%\beginlatexun
  %%name
  %%<LaTeX formula>
  %%\endlatex
  %image "name.eps"
  
  with
  
   \beginlatex
   name
   <LaTeX formula>
   \endlatex


  Will Wilson, wgw@duke.edu
  9/19/2001
  from the mgptex.c written by Anders Logg, logg@math.chalmers.se
  2000-03-15
  
cc -o mgpuntex mgpuntex.c
uses files  mgpuntexbackup.mgp mgpuntextemp.mgp 

example use with mgp file  "demofile.mgp":

mgpuntex demofile

  */

#include <stdio.h>
#include <stdlib.h>

#define IDENTIFIER_START       "%%\\beginlatexun\n"
#define IDENTIFIER_END         "%%\\endlatex\n"
#define LINELENGTH             1024
#define DEFAULT                0
#define START                  1
#define READING                2
#define END                    3

int main(int argc, char **argv)
{
  FILE *fp_in, *fp_out, *fp_tex;
  char cLine[LINELENGTH];
  char cCommand[LINELENGTH];
  char cOutFileName[LINELENGTH];
  char cTeXFile[LINELENGTH];
  char cTeXFileName[LINELENGTH];
  char c;
  int  iCounter = 1;
  int  iMode = DEFAULT;
  
  /* Check arguments */
  if ( argc != 2 ){
         printf("Usage: mgpuntex presentation\n");
         exit(0);
  } 
  
  
  /* Open files */
  sprintf(cOutFileName,"%s.mgp",argv[1]);
  fp_in  = fopen(cOutFileName,"r");
  sprintf(cCommand,"cp %s.mgp mgpuntexbackup.mgp\n",argv[1]);
  system(cCommand);
  
  sprintf(cOutFileName,"mgptextemp.mgp");
  fp_out = fopen(cOutFileName,"w");

  /* Go through the file */
  while ( (c=getc(fp_in)) != EOF ){
         
         /* Put the character pack */
         ungetc(c,fp_in);

         /* Read line */
         fgets(cLine,LINELENGTH,fp_in);

         /* Check for start */
         if ( strcasecmp(cLine,IDENTIFIER_START) == 0 )
                iMode = START;

         /* Check for end */
         if ( strcasecmp(cLine,IDENTIFIER_END) == 0 
		 			&& iMode==READING)
                iMode = END;

         /* Parse */
         switch (iMode){
         case START:
                /* A comment */
                fprintf(fp_out,"\\beginlatex\n");
                /* Read next line, which is the mgp specification for
the formula name */
/*                 fgets(cTeXFileName,LINELENGTH,fp_in);
 */             fscanf(fp_in,"%%%%%s\n",cTeXFileName);
                fprintf(fp_out,"%s\n",cTeXFileName);
                /* Change the mode to READING */
                iMode = READING;
                break;
         case READING:
                fprintf(fp_out,"%s",cLine+2);
                break;
         case END:
                /* End the tex file */
                fprintf(fp_out,"\\endlatex\n");
                /* Don't write the image call */
         		fgets(cLine,LINELENGTH,fp_in);
                /* Step the counter */
                iCounter += 1;
                /* Set the mode to DEFAULT */
                iMode = DEFAULT;
                break;
         default:
                fprintf(fp_out,"%s",cLine);
         }
           
  }
	if(iCounter>1)
	{
		sprintf(cCommand,"mv mgptextemp.mgp %s.mgp\n",argv[1]);
		system(cCommand);
	}
	else system("rm mgptextemp.mgp\n");

  /* Write a message */
  printf("\n%d formula(s) ungenerated.\n",iCounter-1);
  
}