xs2file.c File Reference

#include "xs2file.h"
#include "stack-c.h"
#include "Xcall1.h"
#include "GetProperty.h"
#include "SetProperty.h"
#include "periScreen.h"
#include "graphicSession.h"
#include "DrawObjects.h"
#include "ColorMapManagement.h"
#include "MALLOC.h"
#include "CurrentObjectsManagement.h"

Include dependency graph for xs2file.c:

Go to the source code of this file.

Functions

int xs2file (char *fname, char *dr, unsigned long fname_len, unsigned long dr_len)
int scig_toPs (integer win_num, integer colored, char *bufname, char *driver)
int C2F() xg2psofig (char *fname, integer *len, integer *iwin, integer *color, char *driver, long int l1, long int l2)


Function Documentation

int scig_toPs ( integer  win_num,
integer  colored,
char *  bufname,
char *  driver 
)

send recorded graphics to file bufname in ``driver'' syntax ( Pos or Fig )

Parameters:
win_num the number of the window,
colored 1 if color is wanted
[in] bufname string the name of the file
[in] driver driver for code generation

Definition at line 47 of file xs2file.c.

References C2F, closeGraphicSession(), convertColorMap2BW(), cur, dr(), FREE, GetDriver1(), GetDriverId(), ierr, isGraphicSessionOpened(), L, MALLOC, na, name, NULL, openGraphicSession(), PD0, PI0, sciDrawObj(), sciGetBackground(), sciGetColormap(), sciGetCurrentFigure(), sciGetNumColors(), sciSetColormap(), sciSetCurrentFigure(), and SwitchWindow().

Referenced by Print(), PrintPs(), SavePs(), and xg2psofig().

00048 {
00049   char name[4];
00050   integer ierr;
00051   integer verb=0,cur,na ;
00052   int save_xinitxend_flag = isGraphicSessionOpened();
00053   sciPointObj * curFig = sciGetCurrentFigure ();
00054   integer bg ;
00055   double * curColorMap = NULL ;
00056   double * bwColorMap  = NULL ; /* allocated if black and white needed */
00057   int colorMapSize = sciGetNumColors( curFig ) ;
00058 
00059   ierr = 0;
00060   GetDriver1(name,PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0);
00061   C2F(dr)("xget","window",&verb,&cur,&na,PI0,PI0,PI0,PD0,PD0,PD0,PD0,5L,7L);  
00062   C2F(dr)("xset","window",&win_num,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,5L,7L);
00063 
00064   if( curFig == (sciPointObj *) NULL )
00065   {
00066     Scierror(999,"No current graphic window %d found for exporting to %s\r\n",win_num,driver);
00067     C2F(dr)("xsetdr",name, PI0, PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00068     C2F(dr)("xset","window",&cur,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00069     /* to force a reset in the graphic scales for the graphic window number cur */
00070     if(GetDriverId() == 1) { SwitchWindow(&cur); }
00071     return ierr;
00072   }
00073 
00074   C2F(dr)("xget","background",&verb,&bg,&na,PI0,PI0,PI0,PD0,PD0,PD0,PD0,5L,11L);
00075   /* Rajout F.Leray 06.04.04 */
00076   bg = sciGetBackground(curFig);
00077   C2F(dr)("xsetdr",driver,PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00078   /* xinit from screen (for the colormap definition) */
00079   C2F(dr)("xinit2",bufname,&win_num,&ierr,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00080 
00081   if (ierr != 0)
00082   {
00083     C2F(dr)("xsetdr",name, PI0, PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00084     C2F(dr)("xset","window",&cur,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00085     /* to force a reset in the graphic scales */
00086     SwitchWindow(&cur);
00087     return ierr ;
00088   }
00089 
00090   sciSetCurrentFigure(curFig);
00091 
00092   if ( colored == 0 )
00093   {
00094     /* change the colormap to a bw one */
00095     curColorMap = MALLOC( 3 * colorMapSize * sizeof(double) ) ;
00096     bwColorMap  = MALLOC( 3 * colorMapSize * sizeof(double) ) ;
00097     sciGetColormap( curFig, curColorMap ) ;
00098     convertColorMap2BW( bwColorMap, curColorMap, colorMapSize ) ;
00099     sciSetColormap( curFig, bwColorMap, colorMapSize, 3 ) ;
00100     FREE( bwColorMap ) ;
00101     bwColorMap = NULL ;
00102   }
00103 
00104   C2F(dr)("xset","background",&bg,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,5L,7L);
00105   closeGraphicSession() ; /* we force to draw */
00106   sciDrawObj(curFig);
00107 
00108 
00109   C2F(dr)("xend","v",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00110   if ( save_xinitxend_flag )
00111   {
00112     openGraphicSession() ;
00113   }
00114   else
00115   {
00116     closeGraphicSession() ;
00117   }
00118   C2F(dr)("xsetdr",name, PI0, PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00119 
00120   if ( colored == 0 )
00121   {
00122     sciSetColormap( curFig, curColorMap, colorMapSize, 3 ) ;
00123     FREE( curColorMap ) ;
00124     curColorMap = NULL ;
00125   }
00126   
00127 
00128   C2F(dr)("xset","window",&cur,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00129   /* to force a reset in the graphic scales */
00130   SwitchWindow(&cur);
00131   return ierr;
00132 }

Here is the call graph for this function:

Here is the caller graph for this function:

int C2F() xg2psofig ( char *  fname,
integer len,
integer iwin,
integer color,
char *  driver,
long int  l1,
long int  l2 
)

Definition at line 134 of file xs2file.c.

References fname, getcolordef(), and scig_toPs().

Referenced by xs2file().

00135 {
00136   int sc;
00137   if ( *color == -1 ) 
00138     getcolordef(&sc);
00139   else 
00140     sc= *color;
00141   /*scig_toPs(*iwin,sc,fname,driver);*/
00142   return scig_toPs(*iwin,sc,fname,driver); /* why twice ???? */
00143 }

Here is the call graph for this function:

Here is the caller graph for this function:

int xs2file ( char *  fname,
char *  dr,
unsigned long  fname_len,
unsigned long  dr_len 
)

Generic function to create either ps, fig, gif or ppm files.

Parameters:
[in] fname name of the routine (ie xs2ps, xs2fig,...)
[in] fname_len length of fname
[in] dr specify the file type. Must be oen of the following driver names "Pos", "Fig", "GIF" or "PPM".
in@ dr_len length of the dr string (without apparently.
Returns:
0 if success, -1 otherwise

Definition at line 23 of file xs2file.c.

References bsiz, C2F, CheckRhs, CheckScalar, cstk, flagx, GetRhsVar, LhsVar, m1, m2, n1, n2, Rhs, stk, and xg2psofig().

Referenced by sci_xg2ps(), sci_xs2fig(), sci_xs2gif(), sci_xs2ppm(), and sci_xs2ps().

00024 {
00025   integer m1,n1,l1,m2,n2,l2,m3,n3,l3,flagx = -1,iwin;
00026   CheckRhs(2,3);
00027 
00028   /* the window number */ 
00029   GetRhsVar(1,"d",&m1,&n1,&l1) ;
00030   CheckScalar(1,m1,n1) ;
00031   iwin = (integer) *stk(l1) ;
00032   /* the file name */ 
00033   GetRhsVar(2,"c",&m2,&n2,&l2);
00034   /* color or n & b */ 
00035   if ( Rhs >= 3 )
00036   {
00037     GetRhsVar(3,"d",&m3,&n3,&l3) ;
00038     CheckScalar(3,m3,n3) ;
00039     flagx = (integer) *stk(l3) ;
00040   }
00041   /* nouveau graphique ?????*/
00042   C2F(xg2psofig)(cstk(l2),&m2,&iwin,&flagx,dr,bsiz,dr_len);
00043   LhsVar(1)=0;
00044   return 0;
00045 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Sun Mar 4 15:55:51 2007 for Scilab [trunk] by  doxygen 1.5.1