Axes.c

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *    Graphic library
00003  *    Copyright (C) 1998-2000 Enpc/Jean-Philippe Chancelier
00004  *    Copyright (C) 2006      INRIA/Jean-Baptiste Silvy
00005  *    jpc@cereve.enpc.fr 
00006  --------------------------------------------------------------------------*/
00007 /*------------------------------------------------------------------------
00008  * Axis drawing for 2d plots 
00009  *--------------------------------------------------------------------------*/
00010 
00011 #include <math.h>
00012 #include <string.h>
00013 #include <stdio.h>
00014 #include "math_graphics.h"
00015 #include "PloEch.h"
00016 #include "Axes.h"
00017 #include "DestroyObjects.h"
00018 #include "DrawObjects.h"
00019 #include "InitObjects.h"
00020 #include "Xcall1.h"
00021 #include "SetProperty.h"
00022 #include "handleDrawing/drawTextEntity.h"
00023 #include "sciprint.h"
00024 #include "Format.h"
00025 #include "Plo3d.h"
00026 #include "axesScale.h"
00027 #include "CurrentObjectsManagement.h"
00028 
00029 
00030 #include "MALLOC.h" /* MALLOC */
00031 
00032 #include "GetProperty.h"
00033 
00034 static double  x_convert __PARAMS((char xy_type,double x[] ,int i));
00035 static double  y_convert __PARAMS((char xy_type,double x[] ,int i));
00036 
00037 
00038 static void axesplot(char* ,sciPointObj*);
00039 static int SciAxisNew(char pos,sciPointObj *psubwin, double xy,int fontsize,int fontstyle,int textcolor,int ticscolor, int seg);
00040 
00041 static void DrawXTics(char pos, sciPointObj * psubwin, double xy, char * c_format, int * fontid, int textcolor,int ticscolor,int color_kp, int *logrect, int smallersize);
00042 static void DrawYTics(char pos, sciPointObj * psubwin, double xy, char * c_format, int * fontid, int textcolor,int ticscolor,int color_kp, int *logrect, int smallersize);
00043 static int XDrawAxisLine(double xminval,double xmaxval,double xy, int ticscolor, int color_kp);
00044 static int YDrawAxisLine(double yminval,double ymaxval,double xy, int ticscolor, int color_kp);
00045 static void FindXYMinMaxAccordingTL(sciPointObj * psubwin, double *xminval,double *yminval,double *xmaxval,double *ymaxval);
00046 
00047 static int DrawXSubTics(char pos, sciPointObj * psubwin, double xy,int ticscolor,int color_kp);
00048 static int DrawYSubTics(char pos, sciPointObj * psubwin, double xy,int ticscolor,int color_kp);
00049 
00050 static int DrawXGrid(sciPointObj * psubwin);
00051 static int DrawYGrid(sciPointObj * psubwin);
00052 
00053 static void YGradPosition(sciPointObj * psubwin, int xx, int rect2);
00054 static void XGradPosition(sciPointObj * psubwin, int yy, int rect3);
00055 
00056 int SciDrawLines(char pos, sciPointObj * psubwin, double xy, int textcolor,int ticscolor);
00057 
00058 /*--------------------------------------------------------------
00059  * Draw Axis or only rectangle
00060  *----------------------------------------------------------------*/
00061 
00062 void axis_draw(char strflag[])
00063 { 
00064         static sciPointObj * psubwin;
00065   /* using foreground to draw axis */
00066   integer verbose=0,narg,xz[10],fg,i,ixbox[5],iybox[5],p=5,n=1,color,color_kp; 
00067  /*  int isoflag = -1; */
00068   char c = (strlen(strflag) >= 3) ? strflag[2] : '1';
00069   C2F(dr)("xget","foreground",&verbose,&fg,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00070   C2F(dr)("xget","line style",&verbose,xz,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00071   C2F(dr)("xset","line style",(i=1,&i),PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00072   C2F(dr)("xget","color",&verbose,xz+1,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00073   C2F(dr)("xset","color",&fg,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); 
00074 
00075 
00076   psubwin = sciGetCurrentSubWin();
00077   
00078   /* F.Leray test on color here*/
00079   color=sciGetBackground(psubwin);
00080   
00081 
00082   ixbox[0]=ixbox[4]=Cscale.WIRect1[0];iybox[0]=iybox[4]=Cscale.WIRect1[1];
00083   ixbox[1]=ixbox[0];iybox[1]=Cscale.WIRect1[1]+Cscale.WIRect1[3];
00084   ixbox[2]=Cscale.WIRect1[0]+Cscale.WIRect1[2];iybox[2]=iybox[1];
00085   ixbox[3]=ixbox[2];iybox[3]=iybox[0];
00086   C2F(dr)("xget","pattern",&verbose,&color_kp,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00087   C2F(dr)("xset","pattern",&color,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00088   C2F(dr)("xarea", "v", &p, ixbox, iybox, &n, PI0, PI0, PD0, PD0, PD0, PD0, 5L,0L);
00089   C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00090 
00091   switch ( c) 
00092     {
00093     case '0' :
00094       break ;
00095     case '2' :
00096       pSUBWIN_FEATURE (psubwin)->axes.rect = BT_ON;  /* NG */
00097       C2F(dr)("xrect","xv",&Cscale.WIRect1[0],&Cscale.WIRect1[1],&Cscale.WIRect1[2],&Cscale.WIRect1[3]
00098               ,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00099       break;
00100     default :
00101       axesplot(strflag,psubwin);
00102       break;
00103     }
00104 
00105 
00106 
00107   C2F(dr)("xset","line style",xz,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00108   C2F(dr)("xset","color",xz+1,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00109 
00110 
00111 }
00112 
00113 /* F.Leray 16.12.04 */
00114 /* Same thing as axis_draw without the background area set */
00115 /* Only used in NG mode */
00116 void axis_draw2(char strflag[])
00117 { 
00118         static sciPointObj * psubwin;
00119   /* using foreground to draw axis */
00120   integer verbose=0,narg,xz[10],fg,i,color; 
00121   /*  int isoflag = -1; */
00122   char c = (strlen(strflag) >= 3) ? strflag[2] : '1';
00123   C2F(dr)("xget","foreground",&verbose,&fg,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00124   C2F(dr)("xget","line style",&verbose,xz,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00125   C2F(dr)("xset","line style",(i=1,&i),PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00126   C2F(dr)("xget","color",&verbose,xz+1,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00127   C2F(dr)("xset","color",&fg,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); 
00128   
00129   psubwin = sciGetCurrentSubWin();
00130   
00131   /* F.Leray test on color here*/
00132   color=sciGetBackground(psubwin);
00133   
00134   switch ( c) 
00135     {
00136       /*case '0' :
00137         break ;*/
00138     case '2' :
00139       pSUBWIN_FEATURE (psubwin)->axes.rect = BT_ON;
00140       
00141       C2F(dr)("xrect","xv",&Cscale.WIRect1[0],&Cscale.WIRect1[1],&Cscale.WIRect1[2],&Cscale.WIRect1[3]
00142               ,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00143       break;
00144     default :
00145       axesplot(strflag,psubwin);
00146       break;
00147     }
00148 
00149   C2F(dr)("xset","line style",xz,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00150   C2F(dr)("xset","color",xz+1,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00151 }
00152 
00153 /* Only paint the area of the axes */
00154 /* ans does not draw any graduations or ticks, lines... */
00155 void DrawAxesBackground( void )
00156 { 
00157         static sciPointObj * psubwin;
00158   /* using foreground to draw axis */
00159   integer verbose=0,narg,xz[10],fg,i,ixbox[5],iybox[5],p=5,n=1,color,color_kp; 
00160  /*  int isoflag = -1; */
00161   C2F(dr)("xget","foreground",&verbose,&fg,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00162   C2F(dr)("xget","line style",&verbose,xz,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00163   C2F(dr)("xset","line style",(i=1,&i),PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00164   C2F(dr)("xget","color",&verbose,xz+1,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00165   C2F(dr)("xset","color",&fg,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); 
00166 
00167   psubwin = sciGetCurrentSubWin();
00168     
00169   /* F.Leray test on color here*/
00170   color=sciGetBackground(psubwin);
00171   
00172   ixbox[0]=ixbox[4]=Cscale.WIRect1[0];iybox[0]=iybox[4]=Cscale.WIRect1[1];
00173   ixbox[1]=ixbox[0];iybox[1]=Cscale.WIRect1[1]+Cscale.WIRect1[3];
00174   ixbox[2]=Cscale.WIRect1[0]+Cscale.WIRect1[2];iybox[2]=iybox[1];
00175   ixbox[3]=ixbox[2];iybox[3]=iybox[0]; 
00176   C2F(dr)("xget","pattern",&verbose,&color_kp,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00177   C2F(dr)("xset","pattern",&color,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);    
00178   C2F(dr)("xarea", "v", &p, ixbox, iybox, &n, PI0, PI0, PD0, PD0, PD0, PD0, 5L,0L);
00179   C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);          
00180 
00181   C2F(dr)("xset","line style",xz,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00182   C2F(dr)("xset","color",xz+1,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00183 
00184 
00185 }
00186 
00187 
00188 /*-------------------------------------------------------------
00189  * Sci_Axis : 
00190  *   Drawing axis 
00191  *   pos = 'r' | 'l' | 'u' | 'd' : gives the tics directions 
00192  *         'r' and 'l' are used for vertical axis 
00193  *         'u' and 'd' for horizontal axis 
00194  *   xy_type = 'v' (for vector) or 'r' (for range) 
00195  *         'v' means that tics position are given by a vector 
00196  *         'r' means that tics position are in a range i.e given by a vector of size 3 
00197  *             [min,max,number_of_intervals] 
00198  *         'i' means that tics positions are in a range given by four number (integers) 
00199  *             [k1,k2,e,number_of intervale] -> [k1*10^e,k2*10^e] 
00200  *   x vector of size nx 
00201  *   y vector of size ny 
00202  *         if pos = 'r' or 'l' then x must be of size 1 
00203  *              the size of y i.e ny must be 3 if xy_type == 'r' or 4 if xy_type == 'i'
00204  *              str if non null gives the string to be used at ticks marks 
00205  *              it must be then of size ny or of size y[3]+1 (if xy_type == 'r') 
00206  *              or y[4]+1 (if xy_type == 'i') 
00207  *         if pos = 'u' or 'd  ' then y must be of size 1 
00208  *              the size of x i.e nx must be 3 if xy_type == 'r' or 4 if xy_type == 'i'
00209  *              str if non null gives the string to be used at ticks marks 
00210  *              it must be then of size ny or of size y[3]+1 (if xy_type == 'r')
00211  *              or y[4]+1 (if xy_type == 'i') 
00212  *   str = char *str[] string vector, see above for size constraints 
00213  *              Warning str must be null terminated 
00214  *   subtics or subints : number of sub intervals 
00215  *   format : format for tick marks.
00216  *            format is only used if str is NULL
00217  *            if format is null a format is computed else format is used 
00218  *   fontsize and textcolor : 
00219  *            XXXXX : to be done 
00220  *   seg_flag : 0 or 1, flag which control the drawing of the segment associated to the axis 
00221  *            if 1 the segment is drawn 
00222  *-------------------------------------------------------------*/
00223 
00224 void Sci_Axis(char pos, char xy_type, double *x, int *nx, double *y, int *ny,
00225               char *str[], int subtics, char *format, int fontsize, int textcolor, 
00226               int fontstyle, int ticscolor, char logflag, int seg_flag, int axisbuild_flag)
00227 {
00228   int Nx,Ny,j;
00229   double angle=0.0,vxx,vxx1;
00230   int vx[2],vy[2],xm[2],ym[2];
00231   char c_format[5];
00232   integer flag=0,xx=0,yy=0,posi[2],rect[4],dash[6],trois=3;
00233   integer i,barlength;
00234   int ns=2,iflag=0;
00235   integer fontid[2],fontsize_kp, narg,verbose=0,logrect[4],smallersize,color_kp; 
00236   integer pstyle;
00237   int x3, y3, xpassed = 0, ypassed = 0; /* for log. case management */
00238   /*** 01/07/2002 -> 11.05.04 ***/ /* F.Leray : Re-put the Djalel modif. for a better display 
00239                                    using tight_limits='on' and/or isoview='on' */
00240   double xmin,xmax,ymin, ymax; 
00241   sciPointObj * psubwin = NULL;
00242   double pas; /* used for logarithmic grid */
00243 
00244   fontid[0]= fontstyle;
00245 
00246   psubwin = sciGetCurrentSubWin();
00247 
00248   C2F(dr)("xget","font",&verbose,fontid,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00249   fontsize_kp = fontid[1] ;
00250   if ( fontsize == -1 )
00251   {
00252     fontid[0]= 0; fontid[1]= 1;  fontsize_kp = fontid[1] ;
00253     fontid[0]= fontstyle;
00254     C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00255   }
00256 
00257   if ( fontsize != -1 ) 
00258   {
00259     fontid[1] = fontsize ;
00260     fontid[0]= fontstyle;
00261     C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00262   }
00263   if ( textcolor != -1 || ticscolor != -1 ) 
00264   {
00265     C2F(dr)("xget","pattern",&verbose,&color_kp,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00266   }
00267 
00268   if (logflag == 'l' )
00269   {
00270     C2F(dr)("xstringl","10",&xx,&yy,logrect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); 
00271     smallersize=fontid[1]-2;
00272     C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00273   }
00274 
00275 
00276   /* Pb here, dim of x and y can be lesser than 4 (ie in example_eng.tst : nx = 6 and ny = 1) F.Leray 25.02.04
00277   x and y are either double x[3] (resp. y[3]) or simply a double !  F.Leray 05.03.04
00278   So a test on x[3] (resp. y[3]) is ALWAYS bad!!
00279   NO!! It depends on the xy_type as follow */
00280   /*
00281   *   xy_type = 'v' (for vector) or 'r' (for range) 
00282   *         'v' means that tics position are given by a vector 
00283   *         'r' means that tics position are in a range i.e given by a vector of size 3 
00284   *             [min,max,number_of_intervals] 
00285   *         'i' means that tics positions are in a range given by four number (integers) 
00286   *             [k1,k2,e,number_of intervals] -> [k1*10^e,k2*10^e] */
00287 
00288   if(xy_type == 'i')
00289   {     /* Adding F.Leray 05.03.04*/
00290     /*F.Leray Modification on 09.03.04*/
00291     switch ( pos ) {
00292       case 'u' : case 'd' :  
00293         if(pSUBWIN_FEATURE(psubwin)->logflags[0] == 'n')
00294           while (x[3]>10)  x[3]=floor(x[3]/2); 
00295         else{
00296           if(x[3] > 12){ /* F.Leray arbitrary value=12 for the moment */
00297             x3=(int)x[3];     /* if x[3]>12 algo is triggered to search a divisor */
00298             for(j=x3-1;j>1;j--)
00299             {
00300               if(x3%j == 0){
00301                 x[3]=j; 
00302                 xpassed = 1;
00303               }
00304             }
00305             if(xpassed != 1) { x[3] = 1; }
00306           }
00307         }
00308 
00309         break;
00310       case 'r' : case 'l' :
00311         if(pSUBWIN_FEATURE(psubwin)->logflags[1] == 'n')
00312           while (y[3]>10)  y[3]=floor(y[3]/2);
00313         else{
00314           if(y[3] > 12){
00315             y3=(int)y[3];
00316             for(j=y3-1;j>1;j--)
00317               if(y3%j == 0){
00318                 y[3]=j;
00319                 ypassed = 1;
00320               }
00321               if(ypassed != 1) y[3] = 1;
00322           }
00323 
00324           break;
00325         }
00326     }
00327 
00328 
00329   }
00330 
00331 
00333   switch ( xy_type ) 
00334   {
00335   case 'v' : Nx= *nx; Ny= *ny; break;
00336   case 'r' :
00337     switch ( pos ) {
00338   case 'u' : case 'd' : Nx = (int) x[2]+1; break;
00339   case 'r' : case 'l' : Ny = (int) y[2]+1; break;
00340     }
00341     break;
00342   case 'i' : 
00343     switch ( pos ) {
00344   case 'u' : case 'd' : Nx = (int) x[3]+1; break; 
00345   case 'r' : case 'l' : Ny = (int) y[3]+1; break;
00346     }
00347     break;
00348   default: 
00349     sciprint("Sci_Axis: wrong type argument xy_type\r\n");
00350   }
00351   switch (pos ) 
00352   {
00353   case 'u' : 
00354   case 'd' :
00356     barlength =  (integer) (Cscale.WIRect1[3]/50.0);
00358     if (str == NULL && format == NULL )  
00359       switch (xy_type ) {
00360   case 'v' : ChoixFormatE1(c_format,x,Nx);break;
00361   case 'r' : ChoixFormatE (c_format,x[0],x[1],(x[1]-x[0])/x[2]);break;
00362   case 'i' : 
00363     ChoixFormatE (c_format,
00364       (x[0] * exp10(x[2])),
00365       (x[1] * exp10(x[2])),
00366       ((x[1] * exp10(x[2])) - (x[0] * exp10(x[2])))/x[3]); break; /* Adding F.Leray 06.05.04 */
00367     }
00370     vx[0] =  XScale(x_convert(xy_type, x , 0)); /* C EST LA que se calcule les positions initiales et finales (en x et y) de la barre support de l'axe des abscisses */
00371     vx[1] =  XScale(x_convert(xy_type, x , Nx-1));
00372     vy[0]= vy[1] = ym[0] = YScale(y[0]);
00373     if ( seg_flag == 1) 
00374     {
00375       if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00376       C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00377       if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00378     }
00379     /******* 01/07/2002  -> 11.05.04 **********/
00380     psubwin = sciGetCurrentSubWin();
00381     if ((pSUBWIN_FEATURE (psubwin)->tight_limits == TRUE || pSUBWIN_FEATURE (psubwin)->isoview == TRUE )
00382       && axisbuild_flag == 0){{ 
00383         xmax=Cscale.frect[2];
00384         xmin=Cscale.frect[0];
00385 
00386         if(xy_type == 'i')
00387         {
00388 
00389 
00390           x[1] = floor(  Cscale.xtics[1] );
00391           x[0] =  ceil(  Cscale.xtics[0] );
00392           x[3]=inint(x[1]-x[0]);
00393           while (x[3]>10)  x[3]=floor(x[3]/2);
00394           Nx=(int)(x[3]+1);
00395 
00396           /* re-compute a format when tight_limits or isoview == ON */
00397           ChoixFormatE (c_format,
00398             (x[0] * exp10(x[2])),
00399             (x[1] * exp10(x[2])),
00400             ((x[1] * exp10(x[2])) - (x[0] * exp10(x[2])))/x[3]); /* Adding F.Leray 15.05.04 */
00401         }
00402         /* THESE 2 last cases are unreachable because we use the condition : */
00403         /* axisbuild_flag == 0 */
00404         else if (xy_type == 'r') /* normally unreachable */
00405         {
00406           sciprint(" Normally, unreachable case \n");
00407         }
00408         else if(xy_type == 'v') /* normally unreachable */
00409         {
00410           sciprint(" Normally, unavailable case  AAA \n");
00411         }
00412     }
00413 
00414 
00415     pas = ((double) Cscale.WIRect1[2]) / ((double) Cscale.Waaint1[1]);
00416 
00417     /**********************/
00419     if (Nx==1) break;
00420     for (i=0 ; i < Nx ; i++)
00421     {  
00422       char foo[100];
00423       vxx = x_convert(xy_type,x,i);
00424       if ( str != NULL)  
00425         sprintf(foo,"%s",str[i]);
00426       else if ( format == NULL) 
00427       {
00428         /* defaults format */
00429         /*F.Leray 19.05.04 */
00430         /* When Sci_Axis is called by aplotv1, format is NULL : it can not be something else...*/
00431         /* format can also be NULL if non specified and coming from ConstructAxes method called in Objdrawaxis (see matdes.c) */
00432         sprintf(foo,c_format,vxx);
00433       }
00434       else {
00435         sprintf(foo,format,vxx);
00436       }
00437 
00438 
00439       C2F(dr)("xstringl",foo,&xx,&yy,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00440 
00441       /* tick is computed in vx,vy and string is displayed at posi[0],posi[1] position */
00442 
00443       vx[0] = vx[1] = xm[0] =  XScale(vxx);
00444       posi[0] = inint( xm[0] -rect[2]/2.0);
00445 
00446       if ( pos == 'd' ) 
00447       {
00448         posi[1]=inint( ym[0] + 1.2*barlength + rect[3]);
00449         vy[0]= ym[0];vy[1]= ym[0] + barlength ;
00450       }
00451       else 
00452       { 
00453         posi[1]=inint( ym[0] - 1.2*barlength);
00454         vy[0]= ym[0];vy[1]= ym[0] - barlength;
00455       }
00456       if ( textcolor != -1 ) C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00457       C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&angle, PD0,PD0,PD0,0L,0L);
00458       if ( logflag == 'l' )
00459       {
00460         C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00461         C2F(dr)("xstring","10",(posi[0] -= logrect[2],&posi[0]),
00462           (posi[1] += logrect[3],&posi[1]),
00463           PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
00464         C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00465       }
00466       if ( textcolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00467 
00468       if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00469       C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00470 
00471       /*** MAJ Djalel.A 21/01/2003 ***/ 
00472       if (pSUBWIN_FEATURE (psubwin)->grid[0] > -1) 
00473       { 
00474         if(pSUBWIN_FEATURE (psubwin)->logflags[0] == 'l')
00475         {
00476           if ((vx[0] != Cscale.WIRect1[0]) && (vx[0] != (Cscale.WIRect1[0]+ Cscale.WIRect1[2])))
00477           {
00478             pstyle=pSUBWIN_FEATURE (psubwin)->grid[0] ;
00479             C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00480             C2F (dr) ("xset", "line style",&trois,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00481             vy[0]=Cscale.WIRect1[1];
00482             vy[1]=Cscale.WIRect1[1]+Cscale.WIRect1[3];  
00483             C2F(dr)("xsegs","v", vx, vy, &ns,&pstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00484           }
00485 
00486           if(i < Nx -1 )
00487           {
00488             int jinit=1;
00489             /* In case there is a log. scale, add. sub-grid taking account of this special scale F.Leray 07.05.04 */
00490             pstyle=pSUBWIN_FEATURE (psubwin)->grid[0] ;
00491             C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00492             C2F (dr) ("xset", "line style",&trois,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00493             vy[0]=Cscale.WIRect1[1];
00494             vy[1]=Cscale.WIRect1[1]+Cscale.WIRect1[3];
00495 
00496             if ( i== 0 ) jinit=2; /* no grid on plot boundary */
00497             for (j= jinit; j < 10 ; j++)
00498             {
00499               vx[0]=vx[1]= Cscale.WIRect1[0] + inint( ((double) i)*pas)+ inint(log10(((double)j))*pas);
00500               C2F(dr)("xsegs","v", vx, vy, &ns,&pstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00501             }
00502             C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L) ;
00503           }
00504         }
00505         else if(pSUBWIN_FEATURE (psubwin)->logflags[0] == 'n')
00506         {
00507           if ((vx[0] != Cscale.WIRect1[0]) && (vx[0] != (Cscale.WIRect1[0]+ Cscale.WIRect1[2])))
00508           {
00509             pstyle=pSUBWIN_FEATURE (psubwin)->grid[0] ;
00510             C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00511             C2F (dr) ("xset", "line style",&trois,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00512             vy[0]=Cscale.WIRect1[1];
00513             vy[1]=Cscale.WIRect1[1]+Cscale.WIRect1[3];  
00514             C2F(dr)("xsegs","v", vx, vy, &ns,&pstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00515             C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00516           }
00517         }
00518       }
00519       /***/
00520       /* subtics */
00521       if ( i < Nx-1 ) 
00522       {
00523         double dx ; 
00524         vxx1= x_convert(xy_type,x,i+1);
00525         dx = (vxx1-vxx)/subtics;
00526         for ( j = 1 ; j < subtics; j++){ 
00527           vx[0] = vx[1] = XScale(vxx+dx*j);
00528           if ( pos == 'd' ) 
00529           { vy[0]= ym[0];vy[1]=  (integer) (ym[0] + barlength/2.0) ; }
00530           else 
00531           { vy[0]= ym[0];vy[1]=  (integer) (ym[0] - barlength/2.0) ; }
00532           C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00533         }
00534       } 
00535       /***   01/07/2002  -> 11.05.04 ****/
00536       psubwin = sciGetCurrentSubWin();
00537       if ( (pSUBWIN_FEATURE (psubwin)->tight_limits || pSUBWIN_FEATURE (psubwin)->isoview )
00538         && axisbuild_flag == 0)
00539       {  
00540         if ( i == 0 ) 
00541         {
00542           double dx ; 
00543           vxx1= x_convert(xy_type,x,i+1);
00544           dx = (vxx1-vxx)/subtics;
00545           for ( j = 1 ; j < subtics; j++) {  
00546             if ( vxx-dx*j > xmin){
00547               vx[0] = vx[1] = XScale(vxx-dx*j);
00548               if ( pos == 'd' ) 
00549               { vy[0]= ym[0];vy[1]=(int) (ym[0] + barlength/2.0) ; }
00550               else 
00551               { vy[0]= ym[0];vy[1]= (int)(ym[0] - barlength/2.0); }
00552               C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00553             }}
00554         } 
00555         if ( i == Nx-1 ) 
00556         {
00557           double dx ; 
00558           vxx1= x_convert(xy_type,x,i+1);
00559           dx = (vxx1-vxx)/subtics;
00560           for ( j = 1 ; j < subtics; j++) {  
00561             if ( vxx+dx*j < xmax){
00562               vx[0] = vx[1] = XScale(vxx+dx*j);
00563               if ( pos == 'd' ) 
00564               { vy[0]= ym[0];vy[1]= (int)(ym[0] + barlength/2.0) ; }
00565               else 
00566               { vy[0]= ym[0];vy[1]= (int)(ym[0] - barlength/2.0); }
00567               C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00568             }}
00569         } 
00570       }
00571       if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00572     }
00573     break;
00574   case 'r' : 
00575   case 'l' :
00576 
00578     barlength =  (integer) (Cscale.WIRect1[2]/75.0);
00579     if (str == NULL &&  format == NULL )  
00580       switch (xy_type ) {
00581   case 'v' : ChoixFormatE1(c_format,y,Ny);break;
00582   case 'r' : ChoixFormatE(c_format,y[0],y[1],(y[1]-y[0])/y[2]);break;
00583   case 'i' : 
00584     ChoixFormatE (c_format,
00585       (y[0] * exp10(y[2])),
00586       (y[1] * exp10(y[2])),
00587       ((y[1] * exp10(y[2])) - (y[0] * exp10(y[2])))/y[3]); break; /* Adding F.Leray 06.05.04 */
00588     }
00590     vy[0] =  YScale(y_convert(xy_type, y , 0));
00591     vy[1] =  YScale(y_convert(xy_type, y , Ny-1));
00592     vx[0]= vx[1] = xm[0]= XScale(x[0]);
00593     if ( seg_flag == 1) 
00594     {
00595       if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00596       C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00597       if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00598     }
00599 
00600     /***   01/07/2002 -> 11 and 12.05.04 ****/
00601     psubwin = sciGetCurrentSubWin();
00602     if ((pSUBWIN_FEATURE (psubwin)->tight_limits == TRUE || pSUBWIN_FEATURE (psubwin)->isoview == TRUE )
00603       && axisbuild_flag == 0){  
00604         ymax=Cscale.frect[3];
00605         ymin=Cscale.frect[1];
00606 
00607         if(xy_type == 'i')
00608         {
00609           /*   y[1] = floor(Cscale.frect[3] / (exp10( y[2]))) ;   */
00610           /*        y[0] =  ceil(Cscale.frect[1]  / (exp10( y[2]))) ;  */
00611 
00612           y[1] = floor( Cscale.ytics[1] );
00613           y[0] =  ceil( Cscale.ytics[0] );
00614 
00615           y[3]=inint(y[1]-y[0]);
00616           while (y[3]>10)  y[3]=floor(y[3]/2);
00617           Ny=(int)(y[3]+1);
00618 
00619           /* re-compute a format when tight_limits or isoview == ON */
00620           ChoixFormatE (c_format,
00621             (y[0] * exp10(y[2])),
00622             (y[1] * exp10(y[2])),
00623             ((y[1] * exp10(y[2])) - (y[0] * exp10(y[2])))/y[3]);
00624         }
00625         /* THESE 2 last cases are unreachable because we use the condition : */
00626         /* axisbuild_flag == 0 */
00627         else if (xy_type == 'r') /* normally unreachable */
00628         {
00629           sciprint(" Normally, unreachable case \n");
00630         }
00631         else if(xy_type == 'v')  /* normally unreachable */
00632         {
00633           sciprint(" Normally, unreachable case \n");
00634         }
00635     }
00636 
00637 
00638 
00639     pas = ((double) Cscale.WIRect1[3]) / ((double) Cscale.Waaint1[3]);
00641     if (Ny==1) break; /*D.Abdemouche 16/12/2003*/
00642     for (i=0 ; i < Ny ; i++)
00643     { 
00644       char foo[100];
00645       vxx = y_convert(xy_type,y,i);
00646       if ( str != NULL)  
00647         sprintf(foo,"%s",str[i]);
00648       else if ( format == NULL)
00649       { 
00650         /* defaults format */
00651         /*F.Leray 19.05.04 */
00652         /* When Sci_Axis is called by aplotv1, format is NULL : it can not be something else...*/
00653         /* format can also be NULL if non specified and coming from ConstructAxes method called in Objdrawaxis (see matdes.c) */
00654         sprintf(foo,c_format,vxx);
00655       }
00656       else{ 
00657         sprintf(foo,format,vxx);
00658       }
00659 
00660 
00661       C2F(dr)("xstringl",foo,&xx,&yy,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00662 
00663       /* tick is computed in vx,vy and string is displayed at posi[0],posi[1] position */
00664 
00665       vy[0]= vy[1] = ym[0] = YScale(vxx);
00666       posi[1]=inint( ym[0] +rect[3]/2.0);
00667       if ( pos == 'r' ) 
00668       {
00669         posi[0]=inint( xm[0] + 1.2*barlength);
00670         vx[0]= xm[0];vx[1]= xm[0]+barlength;
00671       }
00672       else 
00673       { 
00674         posi[0]=inint(xm[0] - 1.2*barlength - rect[2]);
00675         vx[0]= xm[0];vx[1]= xm[0] - barlength;
00676       }
00677       if ( textcolor != -1 ) C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00678       C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&angle, PD0,PD0,PD0,0L,0L);
00679       if ( logflag == 'l' )
00680       {
00681         C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00682         C2F(dr)("xstring","10",(posi[0] -= logrect[2],&posi[0]),
00683           (posi[1] += logrect[3],&posi[1]),
00684           PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
00685         C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00686       }
00687       if ( textcolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00688 
00689       if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00690       C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00691       /*** MAJ Djalel.A 21/01/2003 ***/ 
00692       if (pSUBWIN_FEATURE (psubwin)->grid[1] > -1 )
00693       { 
00694         if(pSUBWIN_FEATURE (psubwin)->logflags[1] == 'l')
00695         {
00696           if ((vy[0] != Cscale.WIRect1[1]) && (vy[0] != (Cscale.WIRect1[1]+ Cscale.WIRect1[3])))
00697           {
00698             pstyle=pSUBWIN_FEATURE (psubwin)->grid[1] ;
00699             vx[0]=Cscale.WIRect1[0];
00700             vx[1]=Cscale.WIRect1[0]+Cscale.WIRect1[2];  
00701             C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00702             C2F (dr) ("xset", "line style",&trois,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00703             C2F(dr)("xsegs","v", vx, vy, &ns,&pstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00704           }
00705 
00706           if(i < Ny -1 ){
00707             int jinit=1;
00708             /* In case there is a log. scale, add. sub-grid taking account of this special scale F.Leray 07.05.04 */
00709             pstyle=pSUBWIN_FEATURE (psubwin)->grid[1] ;
00710             C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00711             C2F (dr) ("xset", "line style",&trois,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00712             vx[0]=Cscale.WIRect1[0];
00713             vx[1]=Cscale.WIRect1[0]+Cscale.WIRect1[2]; 
00714 
00715             if ( i== Cscale.Waaint1[3]-1 ) jinit=2; /* no grid on plot boundary */
00716             for (j= jinit; j < 10 ; j++)
00717             {
00718               vy[0]=vy[1]= Cscale.WIRect1[1] + inint( ((double) i+1)*pas)- inint(log10(((double)j))*pas);
00719               C2F(dr)("xsegs","v", vx, vy, &ns,&pstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00720             }
00721             C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00722           }
00723         }
00724         else  if(pSUBWIN_FEATURE (psubwin)->logflags[1] == 'n'){
00725           if ((vy[0] != Cscale.WIRect1[1]) && (vy[0] != (Cscale.WIRect1[1]+ Cscale.WIRect1[3])))
00726           {
00727             pstyle=pSUBWIN_FEATURE (psubwin)->grid[1] ;
00728             vx[0]=Cscale.WIRect1[0];
00729             vx[1]=Cscale.WIRect1[0]+Cscale.WIRect1[2];  
00730             C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00731             C2F (dr) ("xset", "line style",&trois,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00732             C2F(dr)("xsegs","v", vx, vy, &ns,&pstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00733             C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00734           }
00735         }
00736       }
00737       /* subtics */
00738       if ( i < Ny-1 ) 
00739       {
00740         double dy ; 
00741         vxx1= y_convert(xy_type,y,i+1);
00742         dy = (vxx1-vxx)/subtics;
00743         for ( j = 1 ; j < subtics; j++) 
00744         {
00745           vy[0] = vy[1] = YScale(vxx+dy*j);
00746           if ( pos == 'r' ) 
00747           { vx[0]= xm[0];vx[1]= (integer) (xm[0] + barlength/2.0) ; }
00748           else 
00749           { vx[0]= xm[0];vx[1]= (integer) (xm[0] - barlength/2.0) ; }
00750           C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00751         }
00752       }
00753       /***   01/07/2002 -> 12.05.04 ****/
00754       psubwin = sciGetCurrentSubWin();
00755       if ( (pSUBWIN_FEATURE (psubwin)->tight_limits == TRUE || pSUBWIN_FEATURE (psubwin)->isoview == TRUE )
00756         && axisbuild_flag == 0){
00757           if ( i == 0 )  
00758           {
00759             double dy ; 
00760             vxx1= y_convert(xy_type,y,i+1);
00761             dy = (vxx1-vxx)/subtics;
00762             for ( j = 1 ; j < subtics; j++) {  
00763               if ( vxx-dy*j > ymin){
00764                 vy[0] = vy[1] = YScale(vxx-dy*j);
00765                 if ( pos == 'r' ) 
00766                 { vx[0]= xm[0];vx[1]= (int)(xm[0] + barlength/2.0) ; }
00767                 else 
00768                 { vx[0]= xm[0];vx[1]= (int) (xm[0] - barlength/2.0); }
00769                 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00770               }}
00771           }
00772           if ( i == Ny-1 )
00773           {
00774             double dy ; 
00775             vxx1= y_convert(xy_type,y,i+1);
00776             dy = (vxx1-vxx)/subtics;
00777             for ( j = 1 ; j < subtics; j++) {  
00778               if ( vxx+dy*j < ymax){
00779                 vy[0] = vy[1] = YScale(vxx+dy*j);
00780                 if ( pos == 'r' ) 
00781                 { vx[0]= xm[0];vx[1]= (int)(xm[0] + barlength/2.0) ; }
00782                 else 
00783                 { vx[0]= xm[0];vx[1]= (int)(xm[0] - barlength/2.0); }
00784                 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00785               }}
00786           }  
00787       }
00788       if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00789     }
00790     break;
00791     }
00792     /* reset font to its current size */ 
00793     if ( fontsize != -1 || logflag == 'l' )
00794     {
00795       fontid[1] = fontsize_kp;
00796       C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00797     }
00798     /* reset to current color */
00799     if ( textcolor != -1 || ticscolor != -1 ) 
00800     {
00801       C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00802     }
00803 
00804   }
00805 
00806 } 
00807 
00808 /* from double to pixel */ 
00809 
00810 static double  x_convert(char xy_type, double *x , int i)
00811 {
00812   switch ( xy_type ) { 
00813   case 'v' :  return x[i];
00814   case 'r' :  return x[0]+i*(x[1]-x[0])/x[2];
00815   case 'i' :  return exp10(x[2])*(x[0] + i*(x[1]-x[0])/x[3]);
00816   }
00817   return 0.0;
00818 }
00819 
00820 static double y_convert(char xy_type, double *y , int i)
00821 {
00822   switch ( xy_type ) { 
00823   case 'v' :  return y[i]; 
00824   case 'r' :  return y[0]+i*(y[1]-y[0])/y[2];
00825   case 'i' :  return exp10(y[2])*(y[0] + i*(y[1]-y[0])/y[3]); 
00826   }
00827   return 0.0; 
00828 }
00829 
00830 static void axesplot(char * strflag, sciPointObj * psubwin)
00831 {
00832   char dir = 'l';
00833   char c = (strlen(strflag) >= 3) ? strflag[2] : '1';
00834   int seg=0;
00835   int fontsize = -1 ,textcolor = -1 ,ticscolor = -1 ; /* default values */
00836   int fontstyle= 0;
00837   double  x1,y1_;
00838   char xstr,ystr; 
00839   char dirx = 'd';
00840 
00841 
00842   int lastxindex = 0, lastyindex = 0;
00843   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
00844 
00845   if( ppsubwin->tight_limits == TRUE || ppsubwin->isoview == TRUE)
00846     {
00847       switch ( c )
00848         {
00849         case '3' : /* right axis */
00850           x1= ppsubwin->axes.xlim[1];
00851           y1_= ppsubwin->axes.ylim[0];
00852           dir = 'r';
00853           break;
00854         case '4' : /* centred axis */
00855           seg=1;
00856           x1= (ppsubwin->axes.xlim[0]+ppsubwin->axes.xlim[1])/2.0;
00857           y1_= (ppsubwin->axes.ylim[0]+ppsubwin->axes.ylim[1])/2.0;
00858           break ;
00859         case '5': /* centred at (0,0) */
00860           seg=1;
00861           x1 = y1_ = 0.0;
00862           break;
00863         case '1' : /* left axis */
00864         default :
00865           x1=  ppsubwin->axes.xlim[0];
00866           y1_=  ppsubwin->axes.ylim[1];
00867           break;
00868         }
00869     }
00870   else  /* tight_limits == FALSE */
00871     {
00872       lastxindex = ppsubwin->axes.nxgrads - 1;
00873       lastyindex = ppsubwin->axes.nygrads - 1;
00874      
00875         switch ( c )
00876         {
00877         case '3' : /* right axis */
00878           x1= ppsubwin->axes.xgrads[lastxindex];
00879           y1_= ppsubwin->axes.ygrads[0];
00880           dir = 'r';
00881           break;
00882         case '4' : /* centred axis */
00883           seg=1;
00884           x1= (ppsubwin->axes.xgrads[0]+ppsubwin->axes.xgrads[lastxindex])/2.0;
00885           y1_= (ppsubwin->axes.ygrads[0]+ppsubwin->axes.ygrads[lastyindex])/2.0;
00886           break ;
00887         case '5': /* centred at (0,0) */
00888           seg=1;
00889           x1 = y1_ = 0.0;
00890           break;
00891         case '1' : /* left axis */
00892         default :
00893           x1= ppsubwin->axes.xgrads[0];
00894           y1_= ppsubwin->axes.ygrads[0];
00895         break;
00896         }
00897     }
00898        
00899 
00900 
00901   if(ppsubwin->tight_limits == TRUE || ppsubwin->isoview == TRUE)
00902     {
00903       if (c != '4')
00904         {
00905           xstr=ppsubwin->axes.xdir;
00906           if(ppsubwin->axes.reverse[1] == FALSE)
00907             { /* y reverse axis : NO */
00908               switch (xstr)
00909                 {
00910                 case 'u':
00911                   y1_= ppsubwin->axes.ylim[1];
00912                   dirx='u';
00913                   break;
00914                 case 'c':
00915                   y1_= (ppsubwin->axes.ylim[0]>0.0)?ppsubwin->axes.ylim[0]:0.0;
00916                   y1_= (ppsubwin->axes.ylim[1]<0.0)?ppsubwin->axes.ylim[0]:y1_;
00917                   seg =1;
00918                   dirx ='d';
00919                   break;
00920                 default :
00921                   y1_= ppsubwin->axes.ylim[0];
00922                   dirx ='d';
00923                   break;
00924                 }
00925             }
00926           else
00927             { /* y reverse axis : YES */
00928               switch (xstr)
00929                 {
00930                 case 'u':
00931                   y1_= ppsubwin->axes.ylim[0];
00932                   dirx='u';
00933                   break;
00934                 case 'c':
00935                   y1_= (ppsubwin->axes.ylim[0]>0.0)?ppsubwin->axes.ylim[0]:0.0;
00936                   y1_= (ppsubwin->axes.ylim[1]<0.0)?ppsubwin->axes.ylim[0]:y1_;
00937                   seg =1;
00938                   dirx ='d';
00939                   break;
00940                 default :
00941                   y1_= ppsubwin->axes.ylim[1];
00942                   dirx ='d';
00943                   break;
00944                 }
00945             }
00946 
00947           ystr=ppsubwin->axes.ydir;
00948           if(ppsubwin->axes.reverse[0] == FALSE)
00949             { /* x reverse axis : NO */
00950               switch (ystr)
00951                 {
00952                 case 'r':
00953                   x1= ppsubwin->axes.xlim[1];
00954                   dir='r';
00955                   break;
00956                 case 'c':
00957                   x1=(ppsubwin->axes.xlim[0]>0.0)?ppsubwin->axes.xlim[0]:0.0;
00958                   x1=(ppsubwin->axes.xlim[1]<0.0)?ppsubwin->axes.xlim[0]:x1;
00959                   seg =1;
00960                   dir ='l';
00961                   break;
00962                 default :
00963                   x1= ppsubwin->axes.xlim[0];
00964                   dir ='l';
00965                   break;
00966                 }
00967             }
00968           else
00969             { /* x reverse axis : YES */
00970               switch (ystr)
00971                 {
00972                 case 'r':
00973                   x1= ppsubwin->axes.xlim[0];
00974                   dir='r';
00975                   break;
00976                 case 'c':
00977                   x1=(ppsubwin->axes.xlim[0]>0.0)?ppsubwin->axes.xlim[0]:0.0;
00978                   x1=(ppsubwin->axes.xlim[1]<0.0)?ppsubwin->axes.xlim[0]:x1;
00979                   seg =1;
00980                   dir ='l';
00981                   break;
00982                 default :
00983                   x1= ppsubwin->axes.xlim[1];
00984                   dir ='l';
00985                   break;
00986                 }
00987             }
00988         }
00989     }
00990   else  /* tight_limits == FALSE */
00991     {
00992       lastxindex = ppsubwin->axes.nxgrads - 1;
00993       lastyindex = ppsubwin->axes.nygrads - 1;
00994       
00995       if (c != '4')
00996         {
00997           xstr=ppsubwin->axes.xdir;
00998           if(ppsubwin->axes.reverse[1] == FALSE)
00999             { /* y reverse axis : NO */
01000               switch (xstr)
01001                 {
01002                 case 'u':
01003                   y1_=ppsubwin->axes.ygrads[lastyindex];
01004                   dirx='u';
01005                   break;
01006                 case 'c':
01007                   y1_=(ppsubwin->axes.ygrads[0]>0.0)?ppsubwin->axes.ygrads[0]:0.0;
01008                   y1_=(ppsubwin->axes.ygrads[lastyindex]<0.0)?ppsubwin->axes.ygrads[0]:y1_;
01009                   seg =1;
01010                   dirx ='d';
01011               break;
01012                 default :
01013                   y1_= ppsubwin->axes.ygrads[0];
01014                   dirx ='d';
01015                   break;
01016                 }
01017             }
01018           else
01019             { /* y reverse axis : YES */
01020               switch (xstr)
01021                 {
01022                 case 'u':
01023                   y1_=ppsubwin->axes.ygrads[0];
01024                   dirx='u';
01025                   break;
01026                 case 'c':
01027                   y1_=(ppsubwin->axes.ygrads[0]>0.0)?ppsubwin->axes.ygrads[0]:0.0;
01028                   y1_=(ppsubwin->axes.ygrads[lastyindex]<0.0)?ppsubwin->axes.ygrads[0]:y1_;
01029                   seg =1;
01030                   dirx ='d';
01031                   break;
01032                 default :
01033                   y1_= ppsubwin->axes.ygrads[lastyindex];
01034                   dirx ='d';
01035                   break;
01036                 }
01037             }
01038           
01039           ystr=ppsubwin->axes.ydir;
01040           if(ppsubwin->axes.reverse[0] == FALSE)
01041             { /* x reverse axis : NO */
01042               switch (ystr)
01043                 {
01044                 case 'r':
01045                   x1= ppsubwin->axes.xgrads[lastxindex];
01046                   dir='r';
01047                   break;
01048                 case 'c':
01049                   x1=(ppsubwin->axes.xgrads[0]>0.0)?ppsubwin->axes.xgrads[0]:0.0;
01050                   x1=(ppsubwin->axes.xgrads[lastxindex]<0.0)?ppsubwin->axes.xgrads[0]:x1;
01051                   seg =1;
01052                   dir ='l';
01053                   break;
01054                 default :
01055                   x1= ppsubwin->axes.xgrads[0];
01056                   dir ='l';
01057                   break;
01058                 }
01059             }
01060           else
01061             { /* x reverse axis : YES */
01062               switch (ystr)
01063                 {
01064                 case 'r':
01065                   x1= ppsubwin->axes.xgrads[0];
01066                   dir='r';
01067                   break;
01068                 case 'c':
01069                   x1=(ppsubwin->axes.xgrads[0]>0.0)?ppsubwin->axes.xgrads[0]:0.0;
01070                   x1=(ppsubwin->axes.xgrads[lastxindex]<0.0)?ppsubwin->axes.xgrads[0]:x1;
01071                   seg =1;
01072                   dir ='l';
01073                   break;
01074                 default :
01075                   x1= ppsubwin->axes.xgrads[lastxindex];
01076                   dir ='l';
01077                   break;
01078                 }
01079             }
01080         }
01081     }
01082   
01083   ticscolor=sciGetForeground(psubwin);
01084   textcolor=sciGetFontForeground(psubwin);
01085   fontsize=sciGetFontDeciWidth(psubwin)/100;
01086   fontstyle=sciGetFontStyle(psubwin);
01087  
01089   SciAxisNew(dirx,psubwin,y1_,fontsize,fontstyle,textcolor,ticscolor,seg);
01090   
01092   SciAxisNew(dir,psubwin,x1,fontsize,fontstyle,textcolor,ticscolor,seg);
01093 
01094   /* Once the 2 axes are plotted, we can draw :
01095      1. the axes lines
01096      2. the box lines over if necessary (i.e. seg == 1) */
01097   if ( ppsubwin->axes.axes_visible[0] )
01098   {
01099     SciDrawLines(dirx,psubwin,y1_,textcolor,ticscolor);
01100   }
01101   SciDrawLines(dir, psubwin,x1,textcolor,ticscolor);
01102   
01103   
01104   if ( c != '4' && c != '5' )
01105   {
01106     if ( sciGetBoxType(psubwin) == BT_OFF || sciGetBoxType(psubwin) == BT_HIDDEN_AXIS )
01107     {
01108       seg = 1 ;
01109     }
01110     else
01111     {
01113       C2F(dr)("xrect","v",&Cscale.WIRect1[0],&Cscale.WIRect1[1],&Cscale.WIRect1[2],&Cscale.WIRect1[3], 
01114               PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01115     }
01116   }
01117 }
01118 
01119 
01120 /****************************************************************************/
01121 /********************************** COMMON to X and Y ***********************/
01122 /****************************************************************************/
01123 
01124 
01125 int SciDrawLines(char pos, sciPointObj * psubwin, double xy, int textcolor,int ticscolor)
01126 {
01127   double xminval, yminval, xmaxval, ymaxval;
01128   int verbose = 0, narg, color_kp;
01129 
01130   if ( textcolor != -1 || ticscolor != -1 ) 
01131     {
01132       C2F(dr)("xget","pattern",&verbose,&color_kp,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01133     }
01134   
01135   FindXYMinMaxAccordingTL(psubwin,&xminval,&yminval,&xmaxval,&ymaxval);
01136 
01137   if(pos=='u' || pos=='d'){ /* X */
01138     if( pSUBWIN_FEATURE (psubwin)->axes.axes_visible[0] == TRUE )
01139       XDrawAxisLine(xminval,xmaxval,xy,ticscolor,color_kp);
01140   } else if(pos=='l' || pos=='r'){ /* Y */
01141     if(pSUBWIN_FEATURE (psubwin)->axes.axes_visible[1] == TRUE)
01142       YDrawAxisLine(yminval,ymaxval,xy,ticscolor,color_kp);
01143   }
01144   
01145   
01146   
01147   
01148   return 0;
01149 }
01150 
01151 /****************************************************************************/
01152 /********************************** X ***************************************/
01153 /****************************************************************************/
01154 
01155 
01156 static int DrawXSubTics(char pos, sciPointObj * psubwin, double xy,int ticscolor,int color_kp)
01157 {
01158   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
01159   double xminval,yminval,xmaxval,ymaxval;
01160    
01161   int vx[2],vy[2],ym[2];
01162   int barlength = 0;
01163   int ns=2,iflag=0;
01164   
01165   int nbtics = 0,i,j;
01166   int nbsubtics = ppsubwin->axes.nbsubtics[0];
01167   char logflag = ppsubwin->logflags[0];
01168   
01169   double *grads = (double *) NULL;
01170 
01171   ym[0] = YScale(xy);
01172    
01173   barlength =  (integer) (Cscale.WIRect1[3]/50.0);
01174   
01175   FindXYMinMaxAccordingTL(psubwin,&xminval,&yminval,&xmaxval,&ymaxval); /* here i only need x data (ymin ymax are computed but not used after) */
01176  
01177 
01178   if(ppsubwin->axes.auto_ticks[0] == FALSE){
01179     grads =  ppsubwin->axes.u_xgrads;
01180     nbtics = ppsubwin->axes.u_nxgrads;
01181   }
01182   else{
01183     grads =  ppsubwin->axes.xgrads;
01184     nbtics = ppsubwin->axes.nxgrads;
01185   }
01186   
01187   
01188   if(logflag =='l')
01189     {
01190       double tmp[2];
01191       double pas=0;
01192       double * tmp_log_grads = (double *) NULL;
01193       
01194       for(i=0;i<nbtics-1;i++)
01195         {
01196           int k;
01197           tmp[0] = exp10(grads[i]);
01198           tmp[1] = exp10(grads[i+1]);
01199           pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
01200           
01201           if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
01202             sciprint("Error allocating tmp_log_grads\n");
01203             return -1;
01204           }
01205           
01206           for(k=0;k<nbsubtics;k++) tmp_log_grads[k] = log10(tmp[0]+(k)*pas);
01207           
01208           for(j=0;j<nbsubtics;j++)
01209             {
01210               double val = tmp_log_grads[j];
01211               /* the length of the ticks in pixels */
01212               /* minimum 2 pixels */
01213               /* use of integer division for speed */
01214               int ticksLength =  Max( ( 3 * barlength ) / 4,  2 ) ;
01215               vx[0] = vx[1] = XScale(val);
01216               
01217               if(val<xminval || val>xmaxval) continue;     
01218               
01219               if ( pos == 'd' ) 
01220               { 
01221                 vy[0] = ym[0] ;
01222                 vy[1] = ym[0] + ticksLength ; 
01223               }
01224               else 
01225               { 
01226                 vy[0] = ym[0] ; 
01227                 vy[1] = ym[0] - ticksLength ;
01228               }
01229               if ( ppsubwin->axes.axes_visible[0] )
01230               {
01231                 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01232               }
01233             }
01234           
01235           FREE(tmp_log_grads); tmp_log_grads = NULL;
01236         }
01237     }
01238   else
01239     {
01240       for(i=0;i<nbtics-1;i++)
01241         {
01242           double xtmp = grads[i];
01243           double dx = (grads[i+1]-grads[i]) / nbsubtics;
01244           for( j = 0 ; j < nbsubtics ; j++ )
01245             {
01246               double val = xtmp+dx*j;
01247               /* the length of the ticks in pixels */
01248               /* minimum 2 pixels */
01249               /* use of integer division for speed */
01250               int ticksLength =  Max( ( 3 * barlength ) / 4,  2 ) ;
01251               vx[0] = vx[1] = XScale(val);
01252               
01253               if(val<xminval || val>xmaxval) continue;     
01254               
01255               if ( pos == 'd' ) 
01256               {
01257                 
01258                 vy[0]= ym[0];
01259                 vy[1]= ym[0] + ticksLength ; 
01260               }
01261               else 
01262               { 
01263                 vy[0]= ym[0];
01264                 vy[1]= ym[0] - ticksLength ; 
01265               }
01266               if ( ppsubwin->axes.axes_visible[0] )
01267               {
01268                 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01269               }
01270             }
01271         }
01272     }
01273   
01274   return 0;
01275 }
01276 
01277 
01278 static int DrawXGrid(sciPointObj * psubwin)
01279 {
01280   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
01281   double xminval,yminval,xmaxval,ymaxval;
01282   int verbose=0,narg;
01283 
01284   int vx[2],vy[2],ym[2];
01285   int dash[6],lineMode=2;
01286   int ns=2,style=0,iflag=0;
01287   
01288   double * grads = (double *) NULL;
01289   int nbtics = 0,i,j;
01290   int nbsubtics = ppsubwin->axes.nbsubtics[0];
01291   char logflag = ppsubwin->logflags[0];
01292    
01293   FindXYMinMaxAccordingTL(psubwin,&xminval,&yminval,&xmaxval,&ymaxval);
01294   
01295   
01296   ym[0] = YScale(yminval);
01297   ym[1] = YScale(ymaxval);
01298 
01299   if(ppsubwin->axes.auto_ticks[0] == FALSE){
01300     grads =  ppsubwin->axes.u_xgrads;
01301     nbtics = ppsubwin->axes.u_nxgrads;
01302   }
01303   else{
01304     grads =  ppsubwin->axes.xgrads;
01305     nbtics = ppsubwin->axes.nxgrads;
01306   }
01307   
01308   /* Grid style */
01309   C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01310   C2F (dr) ("xset", "line style",&lineMode,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01311   style = ppsubwin->grid[0];
01312   
01313   /* Grid based on tics */
01314   for(i=0;i<nbtics;i++)
01315     {
01316       double xtmp = grads[i];
01317       vx[0] = vx[1] = XScale(xtmp);
01318       
01319       if(xtmp<xminval || xtmp>xmaxval) continue;           
01320       
01321       vy[0]= ym[0];vy[1]=  ym[1];
01322       if ( ppsubwin->axes.axes_visible[0] )
01323       {
01324         C2F(dr)("xsegs","v", vx, vy, &ns,&style,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01325       }
01326     }
01327   
01328   /* Grid based on subtics : ONLY for log. case */
01329   if(logflag =='l')
01330     {
01331       double tmp[2];
01332       double pas=0;
01333       double * tmp_log_grads = (double *) NULL;
01334       
01335       for(i=0;i<nbtics-1;i++)
01336         {
01337           int k;
01338           tmp[0] = exp10(grads[i]);
01339           tmp[1] = exp10(grads[i+1]);
01340           pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
01341           
01342           if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
01343             sciprint("Error allocating tmp_log_grads\n");
01344             return -1;
01345           }
01346           
01347           for(k=0;k<nbsubtics;k++) tmp_log_grads[k] = log10(tmp[0]+(k)*pas);
01348           
01349           for(j=0;j<nbsubtics;j++)
01350             {
01351               double val = tmp_log_grads[j];
01352               vx[0] = vx[1] = XScale(val);
01353               
01354               if(val<xminval || val>xmaxval) continue;    
01355               
01356               vy[0]= ym[0];vy[1]=  ym[1];
01357               if ( ppsubwin->axes.axes_visible[0] )
01358               {
01359                 C2F(dr)("xsegs","v", vx, vy, &ns,&style,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01360               }
01361             }
01362           
01363           FREE(tmp_log_grads); tmp_log_grads = NULL;
01364         }
01365     }
01366  
01367   /* return to solid mode (in default mode) */
01368   C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01369   
01370 
01371   return 0;
01372 }
01373 
01374 
01375 
01376 static void DrawXTics(char pos, sciPointObj * psubwin, double xy, char * c_format, int * fontid, int textcolor,int ticscolor,int color_kp, int *logrect, int smallersize)
01377 {
01378   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
01379   double xminval,yminval,xmaxval,ymaxval;
01380   int  flag=0,xx=0,yy=0,rect[4];
01381   
01382   int vx[2],vy[2],xm[2],ym[2];
01383   int barlength = 0;
01384   int posi[2];
01385   double angle=0.0;
01386   int ns=2,iflag=0;
01387   
01388   int nbtics = 0,i;
01389   char logflag = ppsubwin->logflags[0];
01390 
01391   ym[0] = YScale(xy);
01392  
01393   barlength =  Max( (integer) (Cscale.WIRect1[3]/50.0), 2 ) ;
01394   
01395   /*ppsubwin->firsttime_x = TRUE;*/
01396   
01397   if(ppsubwin->axes.auto_ticks[0] == FALSE)
01398     {
01399       /* we display the x tics specified by the user*/
01400       FindXYMinMaxAccordingTL(psubwin,&xminval,&yminval,&xmaxval,&ymaxval); /* here i only need x data (ymin ymax are computed but not used after) */
01401       nbtics = ppsubwin->axes.u_nxgrads;
01402       
01403       for(i=0;i<nbtics;i++)
01404         {
01405           double xtmp = ppsubwin->axes.u_xgrads[i];
01406           char *foo = ppsubwin->axes.u_xlabels[i];
01407           
01408           if(xtmp<xminval || xtmp>xmaxval) continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichées de tte facon */
01409                                                      /* donc autant ne pas aller plus loin dans l'algo... */
01410           
01411 
01412           /***************************************************************/
01413           /************************* COMMON PART *************************/
01414           /***************************************************************/
01415           
01416           C2F(dr)("xstringl",foo,&xx,&yy,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01417           /* tick is computed in vx,vy and string is displayed at posi[0],posi[1] position */
01418           
01419           vx[0] = vx[1] = xm[0] =  XScale(xtmp);
01420           posi[0] = inint( xm[0] -rect[2]/2.0);
01421           
01422           if ( pos == 'd')
01423             {
01424               posi[1]=inint( ym[0] + 1.2*barlength + rect[3]);
01425               vy[0]= ym[0];vy[1]= ym[0] + barlength ;
01426             }
01427           else 
01428             {
01429               posi[1]=inint( ym[0] - 1.2*barlength);
01430               vy[0]= ym[0];vy[1]= ym[0] - barlength;
01431             }
01432           
01433           if ( ppsubwin->axes.axes_visible[0] )
01434           {
01435             if ( textcolor != -1 ) C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01436           
01437             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01438             
01439             C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&angle, PD0,PD0,PD0,0L,0L);
01440           }
01441           XGradPosition(psubwin,posi[1],rect[3]);
01442 
01443           if ( ppsubwin->axes.axes_visible[0] )
01444           {
01445             if ( textcolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01446             if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01447             
01448             /* le tic proprement dit ("petit baton") */
01449             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01450           }
01451           if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01452           
01453           /***************************************************************/
01454           /************************* END COMMON PART *********************/
01455           /***************************************************************/
01456           
01457         }
01458       
01459     }
01460   else
01461     {
01462       
01463       FindXYMinMaxAccordingTL(psubwin,&xminval,&yminval,&xmaxval,&ymaxval); /* here i only need x data (ymin ymax are computed but not used after) */
01464       nbtics = ppsubwin->axes.nxgrads;
01465       
01466 
01467       for(i=0;i<nbtics;i++)
01468         {
01469           char foo[256]; 
01470           double xtmp = ppsubwin->axes.xgrads[i];
01471           
01472           /* chack that xtmp < xminval || xtmp > xmalval */
01473           /* but if xtmp is very close to xminval or xmaxval we display it */
01474           if ( !SAFE_LT( xminval, xtmp, EPSILON ) || !SAFE_LT( xtmp, xmaxval, EPSILON ) )
01475           {
01476             continue ;
01477           }
01478 
01479           sprintf(foo,c_format,xtmp);
01480           
01481           /***************************************************************/
01482           /************************* COMMON PART *************************/
01483           /***************************************************************/
01484 
01485           C2F(dr)("xstringl",foo,&xx,&yy,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01486           /* tick is computed in vx,vy and string is displayed at posi[0],posi[1] position */
01487           
01488           vx[0] = vx[1] = xm[0] =  XScale(xtmp);
01489           posi[0] = inint( xm[0] -rect[2]/2.0);
01490           
01491           if ( pos == 'd')
01492             {
01493               posi[1]=inint( ym[0] + 1.2*barlength + rect[3]);
01494               vy[0]= ym[0];vy[1]= ym[0] + barlength ;
01495             }
01496           else 
01497             {
01498               posi[1]=inint( ym[0] - 1.2*barlength);
01499               vy[0]= ym[0];vy[1]= ym[0] - barlength;
01500             }
01501           
01502           if ( ppsubwin->axes.axes_visible[0] )
01503           {
01504             if ( textcolor != -1 ) C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01505 
01506             
01507             C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&angle, PD0,PD0,PD0,0L,0L);
01508           }
01509           XGradPosition(psubwin,posi[1],rect[3]);
01510           if ( logflag == 'l' )
01511             {
01512               if ( ppsubwin->axes.axes_visible[0] )
01513               {
01514                 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01515                 
01516                 C2F(dr)("xstring","10",(posi[0] -= logrect[2],&posi[0]),
01517                         (posi[1] += logrect[3],&posi[1]),
01518                         PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
01519               }
01520               XGradPosition(psubwin,posi[1],rect[3]);
01521               if ( ppsubwin->axes.axes_visible[0] )
01522               {
01523                 C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01524               }
01525             }
01526           if ( ppsubwin->axes.axes_visible[0] )
01527           {
01528             if ( textcolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01529             if ( ticscolor != -1 )
01530             {
01531               C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01532             }
01533             
01534             /* le tic proprement dit ("petit baton") */
01535             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L); 
01536             
01537             if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01538           }
01539           /***************************************************************/
01540           /************************* END COMMON PART *********************/
01541           /***************************************************************/
01542 
01543 
01544         }
01545       
01546 
01547     }
01548 
01549 }
01550 
01551 
01552 /****************************************************************************/
01553 /********************************** Y ***************************************/
01554 /****************************************************************************/
01555 
01556 
01557 
01558 static int DrawYSubTics(char pos, sciPointObj * psubwin, double xy,int ticscolor,int color_kp)
01559 {
01560   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
01561   double xminval,yminval,xmaxval,ymaxval;
01562 
01563   int vx[2],vy[2],xm[2];
01564   int barlength = 0;
01565  int ns=2,iflag=0;
01566   
01567   int nbtics = 0,i,j;
01568   int nbsubtics = ppsubwin->axes.nbsubtics[1];
01569   char logflag = ppsubwin->logflags[1];
01570   
01571   double *grads = (double *) NULL;
01572 
01573   xm[0] = XScale(xy);
01574    
01575   barlength =  (integer) (Cscale.WIRect1[2]/75.0);
01576   
01577   FindXYMinMaxAccordingTL(psubwin,&xminval,&yminval,&xmaxval,&ymaxval); /* here i only need x data (ymin ymax are computed but not used after) */
01578  
01579 
01580   if(ppsubwin->axes.auto_ticks[1] == FALSE){
01581     grads =  ppsubwin->axes.u_ygrads;
01582     nbtics = ppsubwin->axes.u_nygrads;
01583   }
01584   else{
01585     grads =  ppsubwin->axes.ygrads;
01586     nbtics = ppsubwin->axes.nygrads;
01587   }
01588   
01589   
01590   if(logflag =='l')
01591     {
01592       double tmp[2];
01593       double pas=0;
01594       double * tmp_log_grads = (double *) NULL;
01595       
01596       for(i=0;i<nbtics-1;i++)
01597         {
01598           int k;
01599           tmp[0] = exp10(grads[i]);
01600           tmp[1] = exp10(grads[i+1]);
01601           pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
01602           
01603           if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
01604             sciprint("Error allocating tmp_log_grads\n");
01605             return -1;
01606           }
01607           
01608           for(k=0;k<nbsubtics;k++) tmp_log_grads[k] = log10(tmp[0]+(k)*pas);
01609           
01610           for(j=0;j<nbsubtics;j++)
01611             {
01612               double val = tmp_log_grads[j];
01613               /* the length of the ticks in pixels */
01614               /* minimum 2 pixels */
01615               /* use of integer division for speed */
01616               int ticksLength =  Max( ( 3 * barlength ) / 4,  1 ) ;
01617               vy[0] = vy[1] = YScale(val);
01618               
01619               if(val<yminval || val>ymaxval) continue;     
01620               
01621               if ( pos == 'r' ) 
01622               { 
01623                 vx[0] = xm[0] ;
01624                 vx[1] = xm[0] + ticksLength ; 
01625               }
01626               else 
01627               { 
01628                 vx[0] = xm[0] ;
01629                 vx[1] = xm[0] - ticksLength ; 
01630               }
01631               if ( ppsubwin->axes.axes_visible[1] )
01632               {
01633                 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01634               }
01635             }
01636           
01637           FREE(tmp_log_grads); tmp_log_grads = NULL;
01638         }
01639     }
01640   else
01641     {
01642       for(i=0;i<nbtics-1;i++)
01643         {
01644           double xtmp = grads[i];
01645           double dx = (grads[i+1]-grads[i]) / nbsubtics;
01646           for(j=0;j<nbsubtics;j++)
01647             {
01648               double val = xtmp+dx*j;
01649               /* the length of the ticks in pixels */
01650               /* minimum 2 pixels */
01651               /* use of integer division for speed */
01652               int ticksLength =  Max( ( 3 * barlength ) / 4, 1 ) ;
01653               vy[0] = vy[1] = YScale(val);
01654               
01655               if(val<yminval || val>ymaxval) continue;     
01656               
01657               if ( pos == 'r' ) 
01658               { 
01659                 vx[0] = xm[0] ;
01660                 vx[1]=  xm[0] + ticksLength ; 
01661               }
01662               else 
01663               { 
01664                 vx[0] = xm[0] ;
01665                 vx[1] = xm[0] - ticksLength ; 
01666               }
01667               if ( ppsubwin->axes.axes_visible[1] )
01668               {
01669                 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01670               }
01671             }
01672         }
01673     }
01674   
01675   return 0;
01676 }
01677 
01678 
01679 static int DrawYGrid(sciPointObj * psubwin)
01680 {
01681   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
01682   double xminval,yminval,xmaxval,ymaxval;
01683   int verbose=0,narg;
01684 
01685   int vx[2],vy[2],xm[2];
01686   int dash[6],lineMode=2;
01687   int ns=2,style=0,iflag=0;
01688   
01689   double * grads = (double *) NULL;
01690   int nbtics = 0,i,j;
01691   int nbsubtics = ppsubwin->axes.nbsubtics[1];
01692   char logflag = ppsubwin->logflags[1];
01693    
01694   FindXYMinMaxAccordingTL(psubwin,&xminval,&yminval,&xmaxval,&ymaxval);
01695   
01696   
01697   xm[0] = XScale(xminval);
01698   xm[1] = XScale(xmaxval);
01699 
01700   if(ppsubwin->axes.auto_ticks[1] == FALSE){
01701     grads =  ppsubwin->axes.u_ygrads;
01702     nbtics = ppsubwin->axes.u_nygrads;
01703   }
01704   else{
01705     grads =  ppsubwin->axes.ygrads;
01706     nbtics = ppsubwin->axes.nygrads;
01707   }
01708   
01709   /* Grid style */
01710   C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01711   C2F (dr) ("xset", "line style",&lineMode,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01712   style = ppsubwin->grid[1];
01713   
01714   /* Grid based on tics */
01715   for(i=0;i<nbtics;i++)
01716     {
01717       double xtmp = grads[i];
01718       vy[0] = vy[1] = YScale(xtmp);
01719       
01720       if(xtmp<yminval || xtmp>ymaxval) continue;           
01721       
01722       vx[0]= xm[0];vx[1]=  xm[1];
01723       if ( ppsubwin->axes.axes_visible[1] )
01724       {
01725         C2F(dr)("xsegs","v", vx, vy, &ns,&style,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01726       }
01727     }
01728   
01729   /* Grid based on subtics : ONLY for log. case */
01730   if(logflag =='l')
01731     {
01732       double tmp[2];
01733       double pas=0;
01734       double * tmp_log_grads = (double *) NULL;
01735       
01736       for(i=0;i<nbtics-1;i++)
01737         {
01738           int k;
01739           tmp[0] = exp10(grads[i]);
01740           tmp[1] = exp10(grads[i+1]);
01741           pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
01742           
01743           if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
01744             sciprint("Error allocating tmp_log_grads\n");
01745             return -1;
01746           }
01747           
01748           for(k=0;k<nbsubtics;k++) tmp_log_grads[k] = log10(tmp[0]+(k)*pas);
01749           
01750           for(j=0;j<nbsubtics;j++)
01751             {
01752               double val = tmp_log_grads[j];
01753               vy[0] = vy[1] = YScale(val);
01754               
01755               if(val<yminval || val>ymaxval) continue;    
01756               
01757               vx[0]= xm[0];vx[1]=  xm[1];
01758               if ( ppsubwin->axes.axes_visible[1] )
01759               {
01760                 C2F(dr)("xsegs","v", vx, vy, &ns,&style,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01761               }
01762             }
01763           
01764           FREE(tmp_log_grads); tmp_log_grads = NULL;
01765         }
01766     }
01767  
01768 
01769   /* return to solid mode (in default mode) */
01770   C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01771 
01772   return 0;
01773 }
01774 
01775 
01776 
01777 
01778 
01779 static void DrawYTics(char pos, sciPointObj * psubwin, double xy, char * c_format, int * fontid, int textcolor,int ticscolor,int color_kp, int *logrect, int smallersize)
01780 {
01781   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
01782   double xminval,yminval,xmaxval,ymaxval;
01783   int  flag=0,xx=0,yy=0,rect[4];
01784   
01785   int vx[2],vy[2],xm[2],ym[2];
01786   int barlength = 0;
01787   int posi[2];
01788   double angle=0.0;
01789   int ns=2,iflag=0;
01790   
01791   int nbtics = 0,i;
01792   char logflag = ppsubwin->logflags[1];
01793   
01794   xm[0] = XScale(xy); /* F.Leray modified le 28.09.04 */
01795   
01796   /* at least 1 pixels */
01797   barlength =  Max( (integer) (Cscale.WIRect1[2]/75.0), 2 ) ;
01798   
01799 
01800   if(ppsubwin->axes.auto_ticks[1] == FALSE)
01801     {
01802       /* we display the x tics specified by the user*/
01803       FindXYMinMaxAccordingTL(psubwin,&xminval,&yminval,&xmaxval,&ymaxval); /* here i only need y data (xmin xmax are computed but not used after) */
01804       nbtics = ppsubwin->axes.u_nygrads;
01805       
01806       for(i=0;i<nbtics;i++)
01807         {
01808           double ytmp = ppsubwin->axes.u_ygrads[i];
01809           char *foo = ppsubwin->axes.u_ylabels[i];
01810           
01811           if(ytmp<yminval || ytmp>ymaxval) continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichées de tte facon */
01812                                                      /* donc autant ne pas aller plus loin dans l'algo... */
01813 
01814 
01815           /***************************************************************/
01816           /************************* COMMON PART *************************/
01817           /***************************************************************/
01818           
01819           C2F(dr)("xstringl",foo,&xx,&yy,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01820           /* tick is computed in vx,vy and string is displayed at posi[0],posi[1] position */
01821           
01822           vy[0]= vy[1] = ym[0] = YScale(ytmp);
01823           posi[1]=inint( ym[0] +rect[3]/2.0);
01824           if ( pos == 'r' ) 
01825             {
01826               posi[0]=inint( xm[0] + 1.2*barlength);
01827               vx[0]= xm[0];vx[1]= xm[0]+barlength;
01828             }
01829           else 
01830             { 
01831               posi[0]=inint(xm[0] - 1.2*barlength - rect[2]);
01832               vx[0]= xm[0];vx[1]= xm[0] - barlength;
01833             }
01834 
01835 
01836 
01837 
01838           if ( ppsubwin->axes.axes_visible[1] )
01839           {
01840             if ( textcolor != -1 ) C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01841             
01842             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01843             
01844             C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&angle, PD0,PD0,PD0,0L,0L);
01845           }
01846           YGradPosition(psubwin,posi[0],rect[2]);
01847 
01848           if ( ppsubwin->axes.axes_visible[1] )
01849           {
01850             if ( textcolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01851             
01852             if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01853             
01854             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01855             
01856             if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01857           }
01858           
01859           /***************************************************************/
01860           /************************* END COMMON PART *********************/
01861           /***************************************************************/
01862           
01863         }
01864     }
01865   else
01866     {
01867 
01868       FindXYMinMaxAccordingTL(psubwin,&xminval,&yminval,&xmaxval,&ymaxval); /* here i only need y data (xmin xmax are computed but not used after) */
01869       nbtics = ppsubwin->axes.nygrads;
01870       
01871       for(i=0;i<nbtics;i++)
01872         {
01873           char foo[256];
01874           double ytmp = ppsubwin->axes.ygrads[i];
01875           
01876           
01877           /* chack that xtmp < xminval || xtmp > xmalval */
01878           /* but if xtmp is very close to xminval or xmaxval we display it */
01879           if ( !SAFE_LT( yminval, ytmp, EPSILON ) || !SAFE_LT( ytmp, ymaxval, EPSILON ) )
01880           {
01881             continue ;
01882           }
01883 
01884           sprintf(foo,c_format,ytmp);
01885           
01886           
01887           /***************************************************************/
01888           /************************* COMMON PART *************************/
01889           /***************************************************************/
01890           
01891           C2F(dr)("xstringl",foo,&xx,&yy,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01892           /* tick is computed in vx,vy and string is displayed at posi[0],posi[1] position */
01893 
01894           vy[0]= vy[1] = ym[0] = YScale(ytmp);
01895           posi[1]=inint( ym[0] +rect[3]/2.0);
01896 
01897           if ( pos == 'r' ) 
01898             {
01899               posi[0]=inint( xm[0] + 1.2*barlength);
01900               vx[0]= xm[0];vx[1]= xm[0]+barlength;
01901             }
01902           else 
01903             { 
01904               posi[0]=inint(xm[0] - 1.2*barlength - rect[2]);
01905               vx[0]= xm[0];vx[1]= xm[0] - barlength;
01906             }
01907           
01908           
01909           if ( ppsubwin->axes.axes_visible[1] )
01910           {
01911             if ( textcolor != -1 ) C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01912             
01913             C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&angle, PD0,PD0,PD0,0L,0L);
01914           }
01915           YGradPosition(psubwin,posi[0],rect[2]);
01916           
01917           if ( logflag == 'l' )
01918             {
01919               if ( ppsubwin->axes.axes_visible[1] )
01920               {
01921                 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01922                 
01923                 C2F(dr)("xstring","10",(posi[0] -= logrect[2],&posi[0]),
01924                         (posi[1] += logrect[3],&posi[1]),
01925                         PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
01926               }
01927               YGradPosition(psubwin,posi[0],rect[2]); /* adding F.Leray 04.08.05 */
01928               if ( ppsubwin->axes.axes_visible[1] )
01929               {
01930                 C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01931               }
01932             }
01933           if ( ppsubwin->axes.axes_visible[1] )
01934           {
01935             if ( textcolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01936             
01937             if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01938             
01939             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01940           
01941             if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01942           }
01943           /***************************************************************/
01944           /************************* END COMMON PART *********************/
01945           /***************************************************************/
01946           
01947         }
01948     }
01949 }
01950 
01951 static int XDrawAxisLine(double xminval,double xmaxval,double xy, int ticscolor, int color_kp)
01952 {
01953   int vx[2], vy[2];
01954   int ns=2, iflag=0;
01955   
01956   vx[0] =  XScale(xminval); /* C EST LA que se calcule les positions initiales et finales (en x et y) de la barre support de l'axe des abscisses */
01957   vx[1] =  XScale(xmaxval);
01958   vy[0]= vy[1] = YScale(xy);
01959   
01960   if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01961   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01962   if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01963 
01964 
01965   return 0;
01966 }
01967 
01968 static int YDrawAxisLine(double yminval,double ymaxval,double xy, int ticscolor, int color_kp)
01969 {
01970   int vx[2], vy[2];
01971   int ns=2, iflag=0;
01972 
01973   vy[0] =  YScale(yminval); /* C EST LA que se calcule les positions initiales et finales (en x et y) de la barre support de l'axe des abscisses */
01974   vy[1] =  YScale(ymaxval);
01975   vx[0]= vx[1] = XScale(xy);
01976   
01977   if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01978   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
01979   if ( ticscolor != -1 ) C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01980 
01981 
01982   return 0;
01983 }
01984 
01985 
01986 void FindXYMinMaxAccordingTL(sciPointObj * psubwin, double *xminval,double *yminval,double *xmaxval,double *ymaxval)
01987 {
01988   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
01989   
01990   *xminval = ppsubwin->axes.xlim[0];
01991   *yminval = ppsubwin->axes.ylim[0];
01992   
01993   *xmaxval = ppsubwin->axes.xlim[1];
01994   *ymaxval = ppsubwin->axes.ylim[1];
01995 }
01996 
01997 
01998 
01999 
02000 static int SciAxisNew(char pos,sciPointObj *psubwin, double xy, int fontsize,int fontstyle,int textcolor,int ticscolor,int seg)
02001 {
02002   int switchXY = -1;
02003   
02004   char c_format[5];
02005   integer xx=0,yy=0;
02006   integer barlength;
02007   integer fontid[2],fontsize_kp, narg,verbose=0,logrect[4],smallersize=0,color_kp; 
02008   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
02009   double xminval, yminval, xmaxval, ymaxval;
02010   
02011   char logflag ;
02012   /* int lastxindex, lastyindex; */
02013   BOOL auto_ticks;
02014 
02015 
02016   if(pos=='u' || pos=='d'){
02017     switchXY = 0;
02018     logflag = ppsubwin->logflags[0];
02019     auto_ticks = ppsubwin->axes.auto_ticks[0];
02020   }
02021   else if(pos=='l' || pos=='r'){
02022     switchXY = 1;
02023     logflag = ppsubwin->logflags[1];
02024     auto_ticks = ppsubwin->axes.auto_ticks[1];
02025   }
02026 
02027 
02028   fontid[0]= fontstyle;
02029   
02030   C2F(dr)("xget","font",&verbose,fontid,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02031   fontsize_kp = fontid[1] ;
02032   if (fontsize == -1 )
02033     { fontid[0]= 0; fontid[1]= 1;  fontsize_kp = fontid[1] ;
02034     fontid[0]= fontstyle;
02035     C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);}
02036   
02037   if ( fontsize != -1 ) 
02038     {
02039       fontid[1] = fontsize ;
02040       fontid[0]= fontstyle;
02041       C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02042     }
02043   if ( textcolor != -1 || ticscolor != -1 ) 
02044     {
02045       C2F(dr)("xget","pattern",&verbose,&color_kp,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02046     }
02047   
02048   if (logflag == 'l' && auto_ticks == TRUE)
02049     {
02050       C2F(dr)("xstringl","10",&xx,&yy,logrect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);       
02051       smallersize=fontid[1]-2;
02052       C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02053     }
02054   
02055 
02056 
02057   FindXYMinMaxAccordingTL(psubwin,&xminval,&yminval,&xmaxval,&ymaxval);
02058 
02059 
02060   switch (switchXY)
02061   {
02062   case 0: /* x horizontal axis */
02063     {
02066       char formatY[5] ;
02067       barlength =  (integer) (Cscale.WIRect1[3]/50.0);
02068       
02069       /* remove concealing tics labels */
02070       
02071       updateXaxesTics( psubwin, pos, xy, fontid, smallersize ) ;
02072       
02073       /* the format may have changed */
02074       findFormat( psubwin, c_format, formatY ) ;
02075 
02076       /* le "loop on the ticks" */
02077       DrawXTics(pos, psubwin, xy, c_format, fontid, textcolor, ticscolor, color_kp, logrect, smallersize);
02078       
02079       /* subtics display*/
02080       DrawXSubTics(pos, psubwin, xy, ticscolor, color_kp);
02081     }
02082     break;
02083   case 1: /* y vertical axis */
02084     {
02086       char formatX[5] ;
02087       
02088       /* int ticsDir[2] = {1,0} ; */
02089       barlength =  (integer) (Cscale.WIRect1[2]/75.0);
02090 
02091       /* remove concealing tics labels */
02092       updateYaxesTics( psubwin, pos, xy, fontid, smallersize ) ;
02093 
02094        /* the format may have changed */
02095       findFormat( psubwin, formatX, c_format ) ;
02096 
02097       /* le "loop on the ticks" */
02098       DrawYTics(pos, psubwin, xy, c_format, fontid, textcolor, ticscolor, color_kp, logrect, smallersize);
02099       
02100       /* subtics display*/
02101       DrawYSubTics(pos, psubwin, xy, ticscolor, color_kp);
02102     }
02103     
02104     break;
02105   default:
02106     sciprint("Axes.c : SciAxisNew : Impossible case");
02107     return -1;
02108   }
02109   
02110   return 0;
02111 }
02112 
02113 void YGradPosition(sciPointObj * psubwin, int xx, int rect2)
02114 {
02115   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
02116   
02117   if(ppsubwin->firsttime_y == TRUE)
02118     {
02119       ppsubwin->YGradMostOnLeft = xx;
02120       ppsubwin->YGradMostOnRight = xx + rect2;
02121       ppsubwin->firsttime_y = FALSE;
02122     }
02123   else
02124     {
02125       if(xx < ppsubwin->YGradMostOnLeft)  ppsubwin->YGradMostOnLeft  = xx;
02126       if(xx + rect2 > ppsubwin->YGradMostOnRight) ppsubwin->YGradMostOnRight = xx + rect2;
02127     }
02128 }
02129 
02130 void XGradPosition(sciPointObj * psubwin, int yy, int rect3)
02131 {
02132   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
02133   
02134   if( ppsubwin->firsttime_x )
02135   {
02136     ppsubwin->XGradMostOnTop = yy - rect3 ;
02137     ppsubwin->XGradMostOnBottom = yy ;
02138     ppsubwin->firsttime_x = FALSE;
02139   }
02140   else
02141   {
02142     if(yy > ppsubwin->XGradMostOnBottom)
02143     {
02144       ppsubwin->XGradMostOnBottom  = yy ;
02145     }
02146     if( yy - rect3 < ppsubwin->XGradMostOnTop)
02147     {
02148       ppsubwin->XGradMostOnTop = yy - rect3 ;
02149     }
02150   }
02151 }
02152 
02153 /*--------------------------------------------------------------------------------*/
02154 /* clear a subwindow from all of its children */
02155 void clearSubWin( sciPointObj * pSubWin )
02156 {
02157   sciSons * curSon = sciGetSons (pSubWin);
02158   
02159   while ( curSon != NULL && curSon->pointobj != NULL )
02160   {
02161     if ( curSon->pointobj->entitytype != SCI_LABEL )
02162     {
02163       DestroyAllGraphicsSons (curSon->pointobj) ;
02164       curSon = sciGetSons ( pSubWin ) ;
02165     }
02166     else
02167     {
02168       curSon = curSon->pnext ;
02169     }
02170     
02171   }
02172 }
02173 /*--------------------------------------------------------------------------------*/
02174 /* reinit a subwindow (but don't change position ) */
02175 void reinitSubWin( sciPointObj * pSubWin )
02176 {
02177   sciSubWindow * ppSubWin  = pSUBWIN_FEATURE (pSubWin) ;
02178   
02179   clearSubWin(   pSubWin ) ;
02180  
02181   initSubWinBounds( pSubWin ) ;
02182   ppSubWin->axes.xdir = 'd' ;
02183   ppSubWin->axes.ydir = 'l' ;
02184   
02185   ppSubWin->visible = TRUE;
02186   
02187   initSubWinAngles( pSubWin ) ;
02188   
02189   ppSubWin->surfcounter = 0 ;
02190   
02191   ppSubWin->FirstPlot = TRUE;
02192   
02193 
02194 }
02195 /*--------------------------------------------------------------------------------*/
02196 /* reinit the viewing angles of a subwindow */
02197 void initSubWinAngles( sciPointObj * pSubWin )
02198 {
02199   sciSubWindow * ppSubWin  = pSUBWIN_FEATURE (pSubWin ) ;
02200   sciSubWindow * ppAxesMdl = pSUBWIN_FEATURE (getAxesModel()) ;
02201   ppSubWin->is3d     = ppAxesMdl->is3d     ;
02202   ppSubWin->alpha_kp = ppAxesMdl->alpha_kp ;
02203   ppSubWin->theta_kp = ppAxesMdl->theta_kp ;
02204   ppSubWin->alpha    = ppAxesMdl->alpha    ;
02205   ppSubWin->theta    = ppAxesMdl->theta    ;
02206 }
02207 
02208 /*--------------------------------------------------------------------------------*/
02209 /* set the size and position of the subwindow to the default */
02210 void initSubWinSize( sciPointObj * pSubWin )
02211 {
02212   sciSubWindow * ppSubWin  = pSUBWIN_FEATURE (pSubWin ) ;
02213   sciSubWindow * ppAxesMdl = pSUBWIN_FEATURE (getAxesModel()) ;
02214   ppSubWin->WRect[0] = ppAxesMdl->WRect[0] ;
02215   ppSubWin->WRect[1] = ppAxesMdl->WRect[1] ;
02216   ppSubWin->WRect[2] = ppAxesMdl->WRect[2] ;
02217   ppSubWin->WRect[3] = ppAxesMdl->WRect[3] ;
02218 
02219 }
02220 /*--------------------------------------------------------------------------------*/
02221 /* set the data_bounds of the axes to the default value */
02222 void initSubWinBounds( sciPointObj * pSubWin )
02223 {
02224   sciSubWindow * ppSubWin  = pSUBWIN_FEATURE (pSubWin ) ;
02225   sciSubWindow * ppAxesMdl = pSUBWIN_FEATURE (getAxesModel()) ;
02226   ppSubWin->FRect[0] = ppAxesMdl->FRect[0] ;
02227   ppSubWin->FRect[1] = ppAxesMdl->FRect[1] ;
02228   ppSubWin->FRect[2] = ppAxesMdl->FRect[2] ;
02229   ppSubWin->FRect[3] = ppAxesMdl->FRect[3] ;
02230   ppSubWin->FRect[4] = ppAxesMdl->FRect[4] ;
02231   ppSubWin->FRect[5] = ppAxesMdl->FRect[5] ;
02232 
02233   ppSubWin->SRect[0] = ppAxesMdl->SRect[0] ;
02234   ppSubWin->SRect[1] = ppAxesMdl->SRect[1] ;
02235   ppSubWin->SRect[2] = ppAxesMdl->SRect[2] ;
02236   ppSubWin->SRect[3] = ppAxesMdl->SRect[3] ;
02237   ppSubWin->SRect[4] = ppAxesMdl->SRect[4] ;
02238   ppSubWin->SRect[5] = ppAxesMdl->SRect[5] ;
02239 }
02240 /*--------------------------------------------------------------------------------*/
02241 /* reinit the selected subwindow if the auto_clear property is set to on */
02242 /* return TRUE if the window has been redrawn */
02243 BOOL checkRedrawing( void )
02244 {
02245   
02246   sciPointObj * pSubWin = sciGetCurrentSubWin() ;
02247   if ( !sciGetAddPlot( pSubWin ) )
02248   {
02249       /* redraw the axis */
02250       reinitSubWin( pSubWin ) ;
02251       return TRUE ;
02252   }
02253   return FALSE ;
02254 }
02255 
02256 /*--------------------------------------------------------------------------------*/
02257 
02258 /* 1----------4 */
02259 /* |          | */
02260 /* |          | */
02261 /* |          | */
02262 /* 2----------3 */
02263 /* check if the graduation text foo is inside the old_rect */
02264 /* in this case it should not been displayed */
02265 /* taken from drawobject.c */
02266 BOOL CheckDisplay(double fact_h, double fact_w, char logflag, char *foo,int *posi,int *fontid,int *old_rect) 
02267 {
02268   int rect[4],i;
02269   int point[4][2];
02270   int logrect[4] ;
02271   int XX = 0 ;
02272   int YY = 0 ;
02273   
02274   if(old_rect[0] == 0 && old_rect[1] == 0 && old_rect[2] == 0 && old_rect[3] == 0)
02275   {
02276     return TRUE ;
02277   }
02278   
02279   C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
02280   
02281   /* compute bounding of "10"  string used for log scale ON and auto_ticks ON */
02282   C2F(dr)("xstringl","10",&XX,&YY,logrect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);   
02283  
02284   getTicksLabelBox( 1.0, 1.0, foo, posi, fontid, logflag, rect, TRUE ) ;
02285  
02286   point[0][0] = rect[0]; /* upper left point */
02287   point[0][1] = rect[1];
02288   
02289   point[1][0] = rect[0]; /* lower left point */
02290   point[1][1] = rect[1]+rect[3];
02291   
02292   point[2][0] = rect[0]+rect[2]; /* lower right point */
02293   point[2][1] = rect[1]+rect[3];
02294   
02295   point[3][0] = rect[0]+rect[2]; /* upper right point */
02296   point[3][1] = rect[1];
02297   
02298   for(i=0;i<4;i++)
02299   {
02300     if( !IsInsideRectangle(old_rect,point[i]) )
02301     {
02302       return FALSE; /* If one inside the old_rect, DO NOT display the graduation ! */
02303     }
02304   }
02305 
02306   return TRUE;
02307 }
02308 
02309 /*--------------------------------------------------------------------------------*/
02310 
02311 /* The unit is the pixel */
02312 /* return 0 if the point is inside the rect */
02313 /* 1 if it is actually outside the rect */
02314 /* (rect[0],rect[1]) : upper left point of the bounding box  in pixel */
02315 /* (rect[2],rect[3]) : width and height in pixel */
02316 /* point[0] : x component */
02317 /* point[1] : y component */
02318 BOOL IsInsideRectangle(int * rect, int *point)
02319 {
02320 
02321   if((point[0] >= rect[0] && point[0] <= rect[0]+rect[2]) &&
02322      (point[1] >= rect[1] && point[1] <= rect[1]+rect[3]))
02323     return FALSE;
02324   
02325   return TRUE;
02326 }
02327 
02328 /*--------------------------------------------------------------------------------*/
02329 
02330 /* get the bounding rectangle of a label of a ticks */
02331 /* similar to stringBoundingRect but only for ticks labels */
02332 void getTicksLabelBox( double   fact_h   ,
02333                        double   fact_w   , 
02334                        char   * label    ,
02335                        int      pos[2]   ,
02336                        int      fontId[2],
02337                        char     logflag  ,
02338                        int      bbox[4]  ,
02339                        BOOL     changeFont )
02340 {  
02341   int prevFontId[2] ;
02342   
02343   if ( changeFont )
02344   {
02345     int verbose = 0 ;
02346     int narg ;
02347     C2F(dr)("xget","font",&verbose,prevFontId,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L) ;
02348     C2F(dr)("xset","font",fontId,fontId+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L) ;
02349   }
02350   
02351   if ( logflag == 'n' )
02352   { 
02353     C2F(dr)("xstringl",label,&pos[0],&pos[1],bbox,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02354     bbox[3] = (int)(fact_h * bbox[3]);
02355     bbox[2] = (int)(fact_w * bbox[2]);
02356   }
02357   else
02358   {
02359     int smallersize = fontId[1]-2;
02360     int rect10[4];
02361     int posi10[2];
02362     int logrect[4] ;
02363     int XX = 1 ;
02364     int YY = 1 ;
02365     /* compute bounding of "10"  string used for log scale ON and auto_ticks ON */
02366     C2F(dr)("xstringl","10",&XX,&YY,logrect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); 
02367     
02368     posi10[0] = pos[0] - logrect[2];
02369     posi10[1] = pos[1] + logrect[3];
02370     
02371     /* get the bbox of the 10 */
02372     C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02373     
02374     pos[0] = rect10[0] + rect10[2];
02375     pos[1] = (int) (rect10[1] - rect10[3]*.1);
02376     
02377     C2F(dr)("xset","font",fontId,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02378     
02379     /* get the bbox of the exponent */
02380     C2F(dr)("xstringl",label,(&pos[0]),(&pos[1]),bbox,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02381     
02382     bbox[2] = (integer)(fact_w*(bbox[2] + rect10[2]));
02383     bbox[3] = (integer)(fact_h*(bbox[3] + rect10[3] + (int) (rect10[3]*.1))); /* added the 01.06.05 */
02384     bbox[0] = rect10[0];
02385     /* bbox[1] = bbox[1]; */
02386     
02387     C2F(dr)("xset","font",fontId,fontId+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02388   }
02389 
02390   if ( changeFont )
02391   {
02392     C2F(dr)("xset","font",prevFontId,prevFontId+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L) ;
02393   }
02394 }
02395 
02396 /*--------------------------------------------------------------------------------*/
02397 
02398 /* remove the concealed ticks before display on the X axis */
02399 BOOL checkXAxes2dTics( sciPointObj * psubwin  ,
02400                        char          side     ,
02401                        double        y        ,
02402                        char        * cFormat  ,
02403                        int           fontId[2],
02404                        int           smallersize )
02405 {
02406   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin) ;
02407   double xminval, yminval, xmaxval, ymaxval ;
02408   int  /* flag=0, */xx=0,yy=0,rect[4] ;
02409   int xm[2],ym[2];
02410   int barlength = 0;
02411   int posi[2];
02412   int prevFontId[2] ;
02413   int verbose = 0 ;
02414   int narg ;
02415   
02416   double factX = 1.2 ;
02417   double factY = 1.2 ;
02418   int nbtics = 0,i ;
02419   int prevRect[4] = { 0, 0, 0, 0 } ;
02420   
02421   /*--------*/
02422   /* x axis */
02423   /*--------*/
02424   
02425   ym[0] = YScale(y) ;
02426 
02427   barlength =  Max( (integer) (Cscale.WIRect1[3]/50.0), 2 ) ;
02428 
02429   ppsubwin->firsttime_x = TRUE ;
02430 
02431   /* suppose auto_ticks is off */
02432   /* here i only need x data (ymin ymax are computed but not used after) */
02433   FindXYMinMaxAccordingTL( psubwin, &xminval, &yminval, &xmaxval, &ymaxval ) ;
02434   nbtics = ppsubwin->axes.nxgrads ;
02435   
02436   C2F(dr)("xget","font",&verbose,prevFontId,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L) ;
02437   C2F(dr)("xset","font",fontId,fontId+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
02438   
02439   for( i = 0 ; i < nbtics; i++ )
02440   {
02441     
02442     char foo[256];
02443     double xtmp = ppsubwin->axes.xgrads[i] ;
02444 
02445     if( xtmp < xminval || xtmp > xmaxval ) 
02446     {
02447       continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichées de tte facon */
02448                 /* donc autant ne pas aller plus loin dans l'algo... */
02449     }
02450     
02451     sprintf(foo, cFormat,xtmp);
02452     
02453     /* compute the bounding box of the label */
02454    
02455     C2F(dr)("xstringl",foo,&xx,&yy,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02456     
02457     xm[0] = XScale(xtmp);
02458     posi[0] = inint( xm[0] - rect[2]/2.0 ) ;
02459     
02460     if ( side == 'd')
02461     {
02462       /* ticks are drawn under the axis */
02463       posi[1] = inint( ym[0] + 1.2 * barlength + rect[3] ) ;
02464     }
02465     else /* side = 'u' */
02466     {
02467       /* ticks are drawn above the axis */
02468       posi[1] = inint( ym[0] - 1.2 * barlength ) ;
02469     }
02470 
02471     /* check that the new display doesnot concealed the previous */
02472     if ( !CheckDisplay( factX, factY,
02473                         ppsubwin->logflags[0],
02474                         foo, posi,
02475                         fontId, prevRect ) )
02476     {
02477       /* put the font back */
02478       C2F(dr)("xset","font",prevFontId,prevFontId+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L) ;
02479       return FALSE ;
02480     }
02481     
02482     /* get the boundig rectangle of the new label */
02483     getTicksLabelBox( factX, factY, foo, posi, fontId, ppsubwin->logflags[0],  prevRect, FALSE ) ;
02484 
02485     XGradPosition(psubwin,posi[1],rect[3]) ;
02486     
02487   }
02488 
02489 
02490   /* put the font back */
02491   C2F(dr)("xset","font",prevFontId,prevFontId+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L) ;
02492 
02493   return TRUE ;    
02494 }
02495 
02496 /*--------------------------------------------------------------------------------*/
02497 
02498 /* remove the concealed ticks before display on the X axis */
02499 BOOL checkYAxes2dTics( sciPointObj * psubwin  ,
02500                        char          side     ,
02501                        double        x        ,
02502                        char        * cFormat  ,
02503                        int           fontId[2],
02504                        int           smallersize )
02505 {
02506   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin) ;
02507   double xminval, yminval, xmaxval, ymaxval ;
02508   int  /* flag=0, */xx=0,yy=0,rect[4] ;
02509   int xm[2],ym[2];
02510   int barlength = 0;
02511   int posi[2];
02512   int prevFontId[2] ;
02513   int verbose = 0 ;
02514   int narg ;
02515   double factX = 1.5 ;
02516   double factY = 1.5 ;
02517   int nbtics = 0,i ;
02518   int prevRect[4] = { 0, 0, 0, 0 } ;
02519   
02520   /*--------*/
02521   /* y axis */
02522   /*--------*/
02523   
02524   xm[0] = XScale(x) ;
02525 
02526   barlength =  Max( (integer) (Cscale.WIRect1[2]/75.0), 2 ) ;
02527 
02528   ppsubwin->firsttime_y = TRUE ;
02529 
02530   /* suppose auto_ticks is off */
02531   /* here i only need x data (ymin ymax are computed but not used after) */
02532   FindXYMinMaxAccordingTL( psubwin, &xminval, &yminval, &xmaxval, &ymaxval ) ;
02533   nbtics = ppsubwin->axes.nygrads ;
02534   
02535   C2F(dr)("xget","font",&verbose,prevFontId,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L) ;
02536   C2F(dr)("xset","font",fontId,fontId+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
02537   
02538   for( i = 0 ; i < nbtics; i++ )
02539   {
02540     
02541     char foo[256];
02542     double ytmp = ppsubwin->axes.ygrads[i] ;
02543 
02544     if( ytmp < yminval || ytmp > ymaxval ) 
02545     {
02546       continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichées de tte facon */
02547                 /* donc autant ne pas aller plus loin dans l'algo... */
02548     }
02549     
02550     sprintf(foo, cFormat,ytmp);
02551     
02552     /* compute the bounding box of the label */
02553    
02554     C2F(dr)("xstringl",foo,&xx,&yy,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02555     
02556     ym[0] = YScale(ytmp);
02557     posi[1] = inint( ym[0] + rect[2]/2.0 ) ;
02558     
02559     if ( side == 'r')
02560     {
02561       /* ticks are drawn under the axis */
02562       posi[0] = inint( xm[0] + 1.2 * barlength ) ;
02563     }
02564     else /* side = 'l' */
02565     {
02566       /* ticks are drawn above the axis */
02567       posi[0] = inint( xm[0] - 1.2 * barlength - rect[2] ) ;
02568     }
02569 
02570     /* check that the new display doesnot concealed the previous */
02571     if ( !CheckDisplay( factX, factY,
02572                         ppsubwin->logflags[1],
02573                         foo, posi,
02574                         fontId, prevRect ) )
02575     {
02576       /* put the font back */
02577       C2F(dr)("xset","font",prevFontId,prevFontId+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L) ;
02578       return FALSE ;
02579     }
02580     
02581     /* get the boundig rectangle of the new label */
02582     getTicksLabelBox( factX, factY, foo, posi, fontId, ppsubwin->logflags[1],  prevRect, FALSE ) ;
02583 
02584     YGradPosition(psubwin,posi[0],rect[2]) ;
02585     
02586   }
02587 
02588 
02589   /* put the font back */
02590   C2F(dr)("xset","font",prevFontId,prevFontId+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L) ;
02591   
02592   return TRUE ;
02593 }
02594 
02595 /*--------------------------------------------------------------------------------*/
02596 
02597 /* check if the ticks are not concealing each others */
02598 /* in this case some are removed until it's fit */
02599 void updateXaxesTics( sciPointObj * psubwin  ,
02600                       char          side     ,
02601                       double        y        ,
02602                       int           fontId[2] ,
02603                       int           smallersize )
02604 {
02605   sciSubWindow * ppSubWin = pSUBWIN_FEATURE( psubwin ) ;
02606   char labelXFormat[5] ;
02607   char labelYFormat[5] ;
02608   findFormat( psubwin, labelXFormat, labelYFormat ) ;
02609   
02610   /* check if the ticks are concealing or not */
02611   if ( !checkXAxes2dTics( psubwin, side, y, labelXFormat, fontId, smallersize ) ) 
02612   {
02613     double xMin ;
02614     double xMax ;
02615     double yMin ;
02616     double yMax ;
02617     double zMin ;
02618     double zMax ;
02619     int    ticksStatus = 0 ;
02620     
02621     sciGetDisplayedBounds( psubwin, &xMin, &xMax, &yMin, &yMax, &zMin, &zMax ) ;
02622     
02623     ppSubWin->axes.nxgrads = ( ppSubWin->axes.nxgrads + 1 ) / 2 ;
02624     
02625     /* recompute the ticks */
02626     if ( ppSubWin->logflags[0] == 'n' )
02627     {
02628       TheTicks( &xMin, &xMax, ppSubWin->axes.xgrads, &ppSubWin->axes.nxgrads, TRUE ) ;
02629     }
02630     else
02631     {
02632       GradLog( xMin, xMax, ppSubWin->axes.xgrads, &ppSubWin->axes.nxgrads, TRUE ) ;
02633     }
02634 
02635     findFormat( psubwin, labelXFormat, labelYFormat ) ;
02636 
02637     while( ticksStatus == 0 && !checkXAxes2dTics( psubwin, side, y, labelXFormat, fontId, smallersize ) )
02638     {
02639       ppSubWin->axes.nxgrads = ( ppSubWin->axes.nxgrads + 1 ) / 2 ;
02640       if (  ppSubWin->logflags[0] == 'n' )
02641       {
02642         ticksStatus = TheTicks( &xMin, &xMax, ppSubWin->axes.xgrads, &ppSubWin->axes.nxgrads, TRUE ) ;
02643       }
02644       else
02645       {
02646         GradLog( xMin, xMax, ppSubWin->axes.xgrads, &ppSubWin->axes.nxgrads, TRUE ) ;
02647       }
02648 
02649       findFormat( psubwin, labelXFormat, labelYFormat ) ;
02650 
02651     }
02652 
02653   }
02654   /* else everything ok */
02655 }
02656 
02657 /*--------------------------------------------------------------------------------*/
02658 
02659 /* check if the ticks are not concealing each others */
02660 /* in this case some are removed until it's fit */
02661 void updateYaxesTics( sciPointObj * psubwin  ,
02662                       char          side     ,
02663                       double        x        ,
02664                       int           fontId[2],
02665                       int           smallersize )
02666 {
02667   sciSubWindow * ppSubWin = pSUBWIN_FEATURE( psubwin ) ;
02668   char labelXFormat[5] ;
02669   char labelYFormat[5] ;
02670   findFormat( psubwin, labelXFormat, labelYFormat ) ;
02671   
02672   /* check if the ticks are concealing or not */
02673   if ( !checkYAxes2dTics( psubwin, side, x, labelYFormat, fontId, smallersize ) ) 
02674   {
02675     double xMin ;
02676     double xMax ;
02677     double yMin ;
02678     double yMax ;
02679     double zMin ;
02680     double zMax ;
02681     int    ticksStatus = 0 ;
02682     
02683     sciGetDisplayedBounds( psubwin, &xMin, &xMax, &yMin, &yMax, &zMin, &zMax ) ;
02684     
02685     ppSubWin->axes.nygrads = ( ppSubWin->axes.nygrads + 1 ) / 2 ;
02686     
02687     /* recompute the ticks */
02688     if ( ppSubWin->logflags[1] == 'n' )
02689     {
02690       TheTicks( &yMin, &yMax, ppSubWin->axes.ygrads, &ppSubWin->axes.nygrads, TRUE ) ;
02691     }
02692     else
02693     {
02694       GradLog( yMin, yMax, ppSubWin->axes.ygrads, &ppSubWin->axes.nygrads, TRUE ) ;
02695     }
02696 
02697     findFormat( psubwin, labelXFormat, labelYFormat ) ;
02698 
02699     while( ticksStatus == 0 && !checkYAxes2dTics( psubwin, side, x, labelYFormat, fontId, smallersize ) )
02700     {
02701       ppSubWin->axes.nygrads = ( ppSubWin->axes.nygrads + 1 ) / 2 ;
02702       if (  ppSubWin->logflags[1] == 'n' )
02703       {
02704         ticksStatus = TheTicks( &yMin, &yMax, ppSubWin->axes.ygrads, &ppSubWin->axes.nygrads, TRUE ) ;
02705       }
02706       else
02707       {
02708         GradLog( yMin, yMax, ppSubWin->axes.ygrads, &ppSubWin->axes.nygrads, TRUE ) ;
02709       }
02710 
02711       findFormat( psubwin, labelXFormat, labelYFormat ) ;
02712 
02713     }
02714 
02715   }
02716   /* else everything ok */
02717 }
02718 
02719 /*--------------------------------------------------------------------------------*/
02720  
02721 /* remove in the ticks array the indices i such as removedTicks[i] */
02722 /* is true. The value nbtics is an in-out variable */
02723 void removeBadTicks( double * ticks, BOOL * removedTicks, int * nbTicks )
02724 {
02725   int i ;
02726   for ( i = *nbTicks - 1 ; i >= 0 ; i-- )
02727   {
02728     if ( removedTicks[i] )
02729     {
02730       removeIndex( ticks, *nbTicks, i ) ;
02731       *nbTicks = *nbTicks - 1 ;
02732     }
02733   }
02734 }
02735 
02736 /*--------------------------------------------------------------------------------*/
02737 
02738 /* remove an element in the array from translating the next
02739    elements on step backward */
02740 void removeIndex( double * changedArray, int size, int ind )
02741 {
02742   int i ;
02743   for ( i = ind + 1 ; i < size ; i++ )
02744   {
02745     changedArray[i-1] = changedArray[i] ;
02746   } 
02747 }
02748 
02749 /*--------------------------------------------------------------------------------*/
02750 
02751 /* compute the needed formats to display the ticks of a subWin */
02752 void findFormat( sciPointObj * pSubWin, char formatX[5], char formatY[5] )
02753 {
02754   sciSubWindow * ppSubWin = pSUBWIN_FEATURE( pSubWin ) ;
02755   int lastIndex ;
02756 
02757   /* x axis */
02758   lastIndex = Max( ppSubWin->axes.nxgrads - 1, 0 ) ;
02759 
02760   ChoixFormatE( formatX,
02761                 ppSubWin->axes.xgrads[0],
02762                 ppSubWin->axes.xgrads[lastIndex],
02763                ( (ppSubWin->axes.xgrads[lastIndex])-(ppSubWin->axes.xgrads[0]))/(lastIndex)); /* Adding F.Leray 06.05.04 */
02764 
02765   /* y-axis */
02766   lastIndex = Max( ppSubWin->axes.nygrads - 1, 0 ) ;
02767   
02768   ChoixFormatE( formatY,
02769                 ppSubWin->axes.ygrads[0],
02770                 ppSubWin->axes.ygrads[lastIndex],
02771                 ((ppSubWin->axes.ygrads[lastIndex])-(ppSubWin->axes.ygrads[0]))/(lastIndex)); /* Adding F.Leray 06.05.04 */
02772   
02773 }
02774 
02775 /*--------------------------------------------------------------------------------*/
02776 void updateSubWinScale( sciPointObj * pSubWin )
02777 {
02778   double xBox[8] ;
02779   double yBox[8] ;
02780   double zBox[8] ;
02781   double dBox[6] ;
02782 
02783 
02784   set_scale ("tttftt", pSUBWIN_FEATURE(pSubWin)->WRect,
02785     pSUBWIN_FEATURE(pSubWin)->FRect,
02786     NULL, pSUBWIN_FEATURE(pSubWin)->logflags, 
02787     pSUBWIN_FEATURE(pSubWin)->ARect); 
02788 
02789   /* Scales are not be updated with an automatic drawing */
02790   if ( pSUBWIN_FEATURE(pSubWin)->is3d )
02791   {
02792     updateScale3d( pSubWin, dBox, xBox, yBox, zBox ) ;
02793   }
02794   else
02795   {
02796     sci_update_frame_bounds_2d( pSubWin ) ;
02797   }
02798 }
02799 /*-----------------------------------------------------------------------------------------*/
02800 void updateScaleIfRequired( sciPointObj * pSubWin )
02801 {
02802   if ( !sciGetIsAutoDrawable( pSubWin ) )
02803   {
02804     updateSubWinScale( pSubWin ) ;
02805   }
02806 }
02807 /*-----------------------------------------------------------------------------------------*/
02808 void drawAxesGrid( sciPointObj * psubwin )
02809 {
02810   if( pSUBWIN_FEATURE(psubwin)->grid[0] > -1 )
02811   {
02812     DrawXGrid(psubwin);
02813   }
02814 
02815   if( pSUBWIN_FEATURE(psubwin)->grid[1] > -1 )
02816   {
02817     DrawYGrid(psubwin);
02818   }
02819 }
02820 /*-----------------------------------------------------------------------------------------*/
02825 void axis_3ddraw(sciPointObj *pobj, double *xbox, double *ybox, double *zbox, integer *InsideU, integer *InsideD) 
02826 {
02827   double dbox[6];
02828   integer flag,i,p,n,pat,hiddencolor, x[5]; /* F. Leray : redimmensionnment (+1) du tableau x[4];*/
02829   static double Alpha, Teta;
02830   int verbose=0,narg;
02831   integer ixbox[8],iybox[8],xind[8],dash[6];
02832   integer background,zero=0, color_old; /* Adding color_old 04.03.04*/
02833   sciSubWindow * ppsubwin =  pSUBWIN_FEATURE (pobj);
02834   EAxesBoxType subWinBoxType = sciGetBoxType( pobj ) ;
02835 
02836   /* Initialisation phase for x (to detect bug): x set to -1000 F.Leray 05.03.04*/
02837   for(i=0;i<5;i++) { x[i] = -1000 ; }
02838 
02839   if(sciGetEntityType (pobj) == SCI_SUBWIN)
02840   {  
02841 
02842     updateScale3d( pobj, dbox, xbox, ybox, zbox ) ;
02843     /* Until here we have computed + reset the 3d scale*/
02844     Teta  = ppsubwin->theta  ;
02845     Alpha =  ppsubwin->alpha ;
02846     if( Abs( Teta ) < 0.1 )
02847     {
02848       /* to avoid bug at limit when theta == 0 */
02849       /* I recompute temp value xyzbox with theta == 0.1 */
02850       /* to have a correct xind, InsideU et InsideD */
02851       ComputeCorrectXindAndInsideUD( Teta, Alpha, dbox, xind, InsideU, InsideD ) ;
02852     }
02853     else
02854     {
02855       sciAxesVerticesIndices( InsideU, InsideD, xbox, ybox, xind ) ;
02856     }
02857 
02858     /* F.Leray Rajout 02.04.04 :*/
02859     background = sciGetBackground(pobj) ;
02860 
02861     for ( i = 0 ; i < 6 ; i++ )
02862     {
02863       ixbox[i]=XScale(xbox[xind[i]]);
02864       iybox[i]=YScale(ybox[xind[i]]);
02865     }
02866     ixbox[6] = ixbox[0] ;
02867     iybox[6] = iybox[0] ;
02868     p = 7 ;
02869     n = 1 ; 
02870 
02871     C2F(dr)("xget","pattern",&verbose,&color_old,&zero,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02872     C2F(dr)("xset","pattern",&background,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);     
02873     C2F (dr) ("xarea", "v", &p, ixbox, iybox, &n, PI0, PI0, PD0, PD0, PD0, PD0, 5L,0L);
02874     C2F(dr)("xset","pattern",&color_old,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02875     /***********/
02876     /***  hidden axis */
02877 
02878     flag = ppsubwin->axes.flag[2]; /* box drawing */
02879 
02880     if ( subWinBoxType != BT_OFF )
02881     { 
02882       x[2] = sciGetLineWidth (pobj);
02883       x[3] = sciGetLineStyle (pobj);
02884       C2F (dr) ("xset","thickness",x+2,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02885 
02886       hiddencolor = sciSetGoodIndex( pobj, ppsubwin->axes.hiddenAxisColor ) ;
02887 
02888       if (zbox[InsideU[0]] > zbox[InsideD[0]])
02889       {
02890         DrawAxis(xbox,ybox,InsideD,hiddencolor);
02891       }  
02892       else
02893       {
02894         DrawAxis(xbox,ybox,InsideU,hiddencolor);        
02895       }
02896       if (Ishidden(pobj))
02897       {
02898         ppsubwin->hiddenstate=(InsideU[0] % 4);
02899       }
02900       else
02901       {
02902         ppsubwin->hiddenstate=(InsideD[0] % 4);
02903       }
02904     }
02906     x[0] = sciGetForeground (pobj);      /* F.Leray 05.03.04 Useless or not?? because we used set pattern instead of set foreground (because Windows uses BRUSH and PEN...)*/
02907     /* Wrong explanation: We use sciGetForeground in NG mode and used set foreground in old graphic mode*/
02908     x[2] = sciGetLineWidth (pobj); /* Adding this line 05.03.04*/
02909     x[3] = sciGetLineStyle (pobj);
02910     x[4] = 0; 
02911     C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); 
02912     C2F(dr)("xget","pattern",&verbose,&pat,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02913     /* We are in axis_3ddraw() and sciGetEntityType (pobj) == SCI_SUBWIN*/
02914     C2F (dr) ("xset", "dashes", x, x, x+4, x+4, x+4,PI0,PD0,PD0,PD0,PD0, 5L, 6L);
02915     C2F (dr) ("xset","foreground",x,x,x+4,x+4,x+4,PI0,PD0,PD0,PD0,PD0,5L,4096); /* F.Leray 05.03.04 Useless too*/
02916     C2F (dr) ("xset","thickness",x+2,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02917     C2F (dr) ("xset", "line style", x+3,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02918 
02919     p = 7 ;
02920     n = 1 ;
02921     for ( i = 0 ; i < p ; i++ )
02922     {
02923       ixbox[i] = XScale( xbox[ xind[i] ] ) ;
02924       iybox[i] = YScale( ybox[ xind[i] ] ) ;
02925     }
02926     ixbox[p-1]=ixbox[0];iybox[p-1]=iybox[0]; 
02927 
02928     if ( subWinBoxType == BT_BACK_HALF || subWinBoxType == BT_ON )
02929     {
02930       C2F(dr)("xpolys","v",ixbox,iybox,x,&n,&p,PI0,PD0,PD0,PD0,PD0,0L,0L);
02931 
02932     }
02933     Axes3dStrings2(ixbox,iybox,xind) ;
02934 
02935     C2F(dr)("xset","pattern",&pat,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02936     C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02937   }
02938 }
02939 /*-----------------------------------------------------------------------------------------*/
02940 void triedre(sciPointObj *pobj, double *xbox, double *ybox, double *zbox, integer *InsideU, integer *InsideD)
02941 {
02942   integer  x[5],narg = 0;
02943   integer color_kp,verbose = 0,thick_kp ;
02944   integer style_kp[3] ;
02945 
02946   C2F(dr)("xget","pattern",&verbose,&color_kp,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /*F.Leray Replacement*/
02947   C2F(dr)("xget","thickness",&verbose,&thick_kp,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /*F.Leray addings here*/
02948   C2F(dr)("xget","line style",&verbose,style_kp,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /*F.Leray addings here*/
02949 
02950   if(sciGetEntityType (pobj) == SCI_SUBWIN)
02951   {
02952     if(pSUBWIN_FEATURE (pobj)->axes.rect == BT_ON)
02953     {
02954       x[0] = sciGetForeground (pobj);   
02955       x[2] = sciGetLineWidth (pobj);
02956       x[3] = sciGetLineStyle (pobj);
02957       x[4] = 0;
02958 
02959       /* C2F (dr) ("xset","foreground",x,x,x+4,x+4,x+4,PI0,PD0,PD0,PD0,PD0,5L,4096);*/
02960       C2F(dr)("xset","pattern",x,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);    
02961       C2F(dr)("xset","thickness",x+2,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02962       C2F(dr)("xset", "line style", x+3,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
02963 
02964       if (zbox[InsideU[0]] > zbox[InsideD[0]])
02965       {
02966         DrawAxis(xbox,ybox,InsideU,x[0]);
02967       }
02968       else
02969       {
02970         DrawAxis(xbox,ybox,InsideD,x[0]);
02971       }
02972     }
02973   }
02974   C2F(dr)("xset", "line style",&(style_kp[0]),PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);/*F.Leray addings here*/
02975   C2F(dr)("xset","thickness",&thick_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);/*F.Leray addings here*/
02976   C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /*F.Leray addings here*/
02977 
02978 }
02979 /*-----------------------------------------------------------------------------------------*/
02980 /* F.Leray 07.05.04 */
02981 /* This routine rebuild a needed strflag for axis_draw call in sciDrawObj*/
02982 /* It may be less complete than the original strflag given in plot2dn (or other 2D - plot function)
02983 due to less info. Nevertheless this new strflag is sufficient for axis_draw because
02984 tests are on strflag[1] (case =='5' or '6') and strflag[2] */
02985 void rebuild_strflag( sciPointObj * psubwin, char * STRFLAG)
02986 {
02987 
02988   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
02989   BOOL isaxes = GetIsAxes2D(psubwin);
02990 
02991   /* strflag[0]*/
02992   STRFLAG[0] = '0'; /* flag for caption display unused here so set to NULL by default */
02993   if( pSUBWIN_FEATURE (psubwin)->with_leg == 1)
02994     STRFLAG[0] = '0';
02995   else
02996     STRFLAG[0] = '1';
02997 
02998   /* strflag[1]*/
02999   /* Here isoview mode test is not needed because axis_draw do not use it */
03000   STRFLAG[1] = '0'; /* Init. to NULL <=> use the previous scale */
03001   if(ppsubwin->tight_limits == TRUE)
03002   {
03003     STRFLAG[1] = '8';
03004   }
03005   else /* using auto rescale : enlarged for pretty axes*/
03006   {
03007     STRFLAG[1] = '6';
03008   }
03009 
03010   /* strflag[2]*/
03011   STRFLAG[2] = '1'; /* Init with y-axis on the left AND axes is on*/
03012   if(isaxes == TRUE)
03013   {
03014     if(ppsubwin->axes.ydir =='l')
03015       STRFLAG[2] = '1';
03016     else if(ppsubwin->axes.ydir =='r')
03017       STRFLAG[2] = '3';
03018     else if((ppsubwin->axes.xdir =='c') && (ppsubwin->axes.ydir =='c'))
03019       STRFLAG[2] = '5';
03020   }
03021   else
03022   {
03023     if(ppsubwin->axes.rect == BT_ON)
03024       STRFLAG[2] = '2';
03025     else
03026       STRFLAG[2] = '0';
03027   }
03028 
03029   STRFLAG[3] = '\0';
03030 }
03031 /*-----------------------------------------------------------------------------------------*/
03032 
03033 /*----------------------------------------------------------------------------------*/
03034 /* draw the title and the two labels of a 2d axis                                 */
03035 /*----------------------------------------------------------------------------------*/
03036 int labels2D_draw( sciPointObj * psubwin )
03037 {
03038   /* Rewritten by jb Silvy 06/2006 */
03039 
03040   integer rect1[4] ;
03041   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (psubwin);
03042   int offset[2] ; /* vertical and horizontal offsets to move labels a little from axes */
03043 
03044   if ( !sciGetVisibility(psubwin) )
03045   {
03046     return 0 ;
03047   }
03048 
03049   /* get the size of the current subwin in pixels */
03050   rect1[0]= Cscale.WIRect1[0] ; /* upper left point of the axes x coordinate. */
03051   rect1[1]= Cscale.WIRect1[1] ; /* upper left point of the axes y coordinate. */
03052   rect1[2]= Cscale.WIRect1[2] ; /* width of the axes */
03053   rect1[3]= Cscale.WIRect1[3] ; /* height of the axes */
03054 
03055   /* the little displacment of the labels from the axes box */
03056   offset[0] = rect1[2] / 50 + 1 ;
03057   offset[1] = rect1[3] / 25 + 1 ;
03058 
03059 
03060   /*********/
03061   /* TITLE */
03062   /*********/
03063 
03064   if ( sciGetVisibility(ppsubwin->mon_title) )
03065   {
03066     /* get the pointer on the title */
03067     sciLabel * ppLabel = pLABEL_FEATURE( ppsubwin->mon_title ) ;
03068 
03069     /* get position and orientation of the title */
03070     if ( ppLabel->auto_rotation )
03071     {
03072       sciSetFontOrientation( ppsubwin->mon_title, 0 ) ;
03073     }
03074 
03075 
03076     if ( ppLabel->auto_position )
03077     {
03078       int segmentStart[2] = { rect1[0] + rect1[2], rect1[1] } ;
03079       int segmentEnd[2]   = { rect1[0]           , rect1[1] } ;
03080       computeLabelAutoPos( ppsubwin->mon_title, segmentStart, segmentEnd, offset ) ;
03081     }
03082     /* draw the label */
03083     drawTextEntity( ppLabel->text ) ;
03084 
03085   }
03086 
03087   /***********/
03088   /* x label */
03089   /***********/
03090 
03091   if( sciGetVisibility(ppsubwin->mon_x_label) )
03092   {
03093     /* get the pointer on the title */
03094     sciLabel * ppLabel = pLABEL_FEATURE( ppsubwin->mon_x_label ) ;
03095 
03096     if( ppLabel->auto_rotation )
03097     {
03098       sciSetFontOrientation(ppsubwin->mon_x_label, 0 ) ;
03099     }
03100 
03101 
03102     if( ppLabel->auto_position )
03103     {
03104       int segmentStart[2] ;
03105       int segmentEnd[2]   ;
03106 
03107       if(ppsubwin->axes.xdir == 'u')
03108       {
03109         segmentStart[0] = rect1[0] + rect1[2] ;
03110         segmentEnd[0]   = rect1[0] ;
03111 
03112         /* we add the size of the numbers to the height */
03113         segmentStart[1] = ppsubwin->XGradMostOnTop ;
03114         segmentEnd[1]   = ppsubwin->XGradMostOnTop ;
03115       }
03116       else
03117       {
03118         segmentStart[0] = rect1[0] ;
03119         segmentEnd[0]   = rect1[0] + rect1[2] ;
03120 
03121         segmentStart[1] = ppsubwin->XGradMostOnBottom ;
03122         segmentEnd[1]   = ppsubwin->XGradMostOnBottom ;
03123       }
03124       computeLabelAutoPos( ppsubwin->mon_x_label, segmentStart, segmentEnd, offset ) ;
03125     }
03126 
03127     drawTextEntity( ppLabel->text ) ;
03128 
03129   }
03130 
03131 
03132   /***********/
03133   /* y label */
03134   /***********/
03135 
03136 
03137   if ( sciGetVisibility(ppsubwin->mon_y_label) )
03138   {
03139     sciLabel * ppLabel = pLABEL_FEATURE( ppsubwin->mon_y_label ) ;
03140 
03141     if( ppLabel->auto_rotation )
03142     {
03143       sciInitFontOrientation( ppsubwin->mon_y_label, 270 * 10 ) ;
03144     }
03145 
03146     if( ppLabel->auto_position )
03147     {
03148       int segmentStart[2] ;
03149       int segmentEnd[2]   ;
03150 
03151       if(ppsubwin->axes.ydir == 'r')
03152       {
03153 
03154         /* we add the size of the numbers to the height */
03155         segmentStart[0] = ppsubwin->YGradMostOnRight ;
03156         segmentEnd[0]   = ppsubwin->YGradMostOnRight ;
03157 
03158         segmentStart[1] = rect1[1] + rect1[3] ;
03159         segmentEnd[1]   = rect1[1] ;
03160       }
03161       else
03162       {
03163         segmentStart[0] = ppsubwin->YGradMostOnLeft ;
03164         segmentEnd[0]   = ppsubwin->YGradMostOnLeft ;
03165 
03166         segmentStart[1] = rect1[1] ;
03167         segmentEnd[1]   = rect1[1] + rect1[3] ;
03168       }
03169       computeLabelAutoPos( ppsubwin->mon_y_label, segmentStart, segmentEnd, offset ) ;
03170     }
03171     drawTextEntity( ppLabel->text ) ;
03172   }
03173 
03174   return 0;
03175 }
03176 /*-----------------------------------------------------------------------------------------*/
03177 void DrawAxis(double xbox[8], double ybox[8], integer Indices[4], integer style)
03178 {
03179   integer ixbox[6],iybox[6],npoly=6,lstyle[6],verbose=0,narg_,hiddencolor;
03180   integer i, iflag=0, j=1;
03181   sciPointObj *psubwin;
03182   for ( i = 0 ; i <= 4 ; i=i+2)
03183   {
03184     ixbox[i]=XScale(xbox[Indices[0]]);iybox[i]=YScale(ybox[Indices[0]]);
03185   }
03186   ixbox[1]=XScale(xbox[Indices[1]]);iybox[1]=YScale(ybox[Indices[1]]);
03187   ixbox[3]=XScale(xbox[Indices[2]]);iybox[3]=YScale(ybox[Indices[2]]);
03188   ixbox[5]=XScale(xbox[Indices[3]]);iybox[5]=YScale(ybox[Indices[3]]);
03189   C2F(dr)("xget","line style",&verbose,lstyle,&narg_,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); 
03192   psubwin = sciGetCurrentSubWin(); 
03193   hiddencolor = pSUBWIN_FEATURE (psubwin)->hiddencolor;
03194   j = sciGetLineStyle (psubwin) ;
03195 
03196   C2F(dr)("xset","line style",&j,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03197   C2F(dr)("xsegs","v",ixbox,iybox,&npoly,&style,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03198   C2F(dr)("xset","line style",lstyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03199 
03200 }
03201 /*-----------------------------------------------------------------------------------------*/
03202 int Axes3dStrings2( integer * ixbox, integer * iybox, integer * xind )
03203 {
03204   integer verbose=0,narg,xz[2],fontid[2],fontsize_kp,color_kp,size;
03205   integer iof,barlengthx = 0,barlengthy = 0, posi[2]; 
03206   integer rect[4],flag=0,x=0,y=0;
03207   double ang=0.0, bbox[6];
03208   int fontsize=-1,textcolor=-1,ticscolor=-1;
03209   int fontstyle=0; /* F.Leray 08.04.04 */
03210   sciPointObj *psubwin = NULL;
03211   sciSubWindow * ppsubwin = NULL;
03212   int ns=2,iflag=0,gstyle,gridStyle=2,dash[6];
03213   double xx[4],yy[4],zz[4],vxx1,vyy1,vzz1;
03214   integer i,xm,ym,vx[2],vy[2],xg[2],yg[2],j;
03215   integer fontid_old[2], textcolor_old;
03216 
03217   int lastzindex = 0, lastxindex = 0, lastyindex = 0;
03218   double xminval, yminval, zminval, xmaxval, ymaxval, zmaxval;
03219   int nbtics = 0;
03220   int nbsubtics = 0;
03221 
03222   int logrect[4], XX = 0, YY = 0; /* see below */ /* ah ouais ou ca ? */
03223   double angle=0.0;
03224 
03225   int constOffset[2] ; /* displacment of labels from the axes segments. */
03226   int maxTicksLabelSize[2] ; /* for each axis the maximum size of ticks label */
03227 
03228 
03229   psubwin= sciGetCurrentSubWin();
03230   ppsubwin = pSUBWIN_FEATURE (psubwin);
03231 
03233   xz[0] = Cscale.WIRect1[2] ;
03234   xz[1] = Cscale.WIRect1[2] ;
03235   iof = (xz[0]+xz[1])/50;
03236 
03237   ticscolor = sciGetForeground(psubwin);
03238   textcolor=sciGetFontForeground(psubwin);
03239 
03240   fontsize=sciGetFontDeciWidth(psubwin)/100;
03241   fontstyle=sciGetFontStyle(psubwin);
03242 
03243   if(sciGetEntityType (psubwin) != SCI_SUBWIN) { 
03244     sciprint("Impossible case\n");
03245     return 0;
03246   }
03247 
03248 
03249   bbox[0] =  xminval = pSUBWIN_FEATURE (psubwin)->FRect[0]; /*xmin*/
03250   bbox[1] =  xmaxval = pSUBWIN_FEATURE (psubwin)->FRect[2]; /*xmax*/
03251   bbox[2] =  yminval = pSUBWIN_FEATURE (psubwin)->FRect[1]; /*ymin*/
03252   bbox[3] =  ymaxval = pSUBWIN_FEATURE (psubwin)->FRect[3]; /*ymax*/ 
03253   bbox[4] =  zminval = pSUBWIN_FEATURE (psubwin)->FRect[4]; /*zmin*/
03254   bbox[5] =  zmaxval = pSUBWIN_FEATURE (psubwin)->FRect[5]; /*zmax*/
03255 
03256   C2F(dr)("xget","font",&verbose,fontid,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03257 
03258   fontid[0]= fontstyle;
03259   fontsize_kp = fontid[1] ;
03260   if( fontsize == -1 ){ 
03261     fontid[1]= 1;
03262     C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03263   }
03264   else {
03265     fontid[1] = fontsize ;
03266     C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03267   }
03268   if ( textcolor != -1 || ticscolor != -1 ) 
03269     C2F(dr)("xget","pattern",&verbose,&color_kp,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);    
03270 
03271   for (i=0; i<3 ; i++) {
03272     xx[i]=pSUBWIN_FEATURE (psubwin)->axes.xlim[i];
03273     yy[i]=pSUBWIN_FEATURE (psubwin)->axes.ylim[i];
03274     zz[i]=pSUBWIN_FEATURE (psubwin)->axes.zlim[i];
03275   } 
03276 
03277   /* main title */ /* We fix the title always at the top */
03278   rect[0]= Cscale.WIRect1[0] ;
03279   rect[1]= Cscale.WIRect1[1] ;
03280   rect[2]= Cscale.WIRect1[2] ;
03281   rect[3]= Cscale.WIRect1[3]/6 ;
03282   textcolor_old = textcolor;
03283   fontid_old[0] = fontid[0];
03284   fontid_old[1] = fontid[1];
03285 
03286   constOffset[0] = Cscale.WIRect1[2] / 50 + 1 ;
03287   constOffset[1] = Cscale.WIRect1[3] / 25 + 1 ;
03288 
03289   if( sciGetVisibility(ppsubwin->mon_title) )
03290   {
03291     /* get the pointer on the title */
03292     sciLabel * ppLabel = pLABEL_FEATURE( ppsubwin->mon_title ) ;
03293 
03294     /* get position and orientation of the title */
03295     if ( ppLabel->auto_rotation )
03296     {
03297       sciSetFontOrientation( ppsubwin->mon_title, 0 ) ;
03298     }
03299 
03300     if ( ppLabel->auto_position )
03301     {
03302       /* same as in 2d */
03303       int segmentStart[2] = { rect[0] + rect[2], rect[1] } ;
03304       int segmentEnd[2]   = { rect[0]          , rect[1] } ;
03305       computeLabelAutoPos( ppsubwin->mon_title, segmentStart, segmentEnd, constOffset ) ;
03306     }
03307     /* draw the label */
03308     drawTextEntity( ppLabel->text ) ;
03309   }
03310 
03311   textcolor = textcolor_old;
03312   fontid[0] = fontid_old[0];
03313   fontid[1] = fontid_old[1];
03314 
03315   size = xz[0]>=xz[1] ? (integer) (xz[1]/50.0) : (integer) (xz[0]/50.0); 
03316 
03317   /* compute bounding of "10"  string used for log scale ON and auto_ticks ON */
03318   C2F(dr)("xstringl","10",&XX,&YY,logrect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);   
03319 
03320   /********************************************/
03321   /* draw the axis line if axes_visible is on */
03322   /********************************************/
03323   {
03324     int x2[5] ;
03325     int two = 2 ;
03326     int one = 1 ;
03327     int verbose2 = 0 ;
03328     int dash2[6] ;
03329     int pat ;
03330     int narg2 ;
03331     x2[0] = sciGetForeground (psubwin);
03332     x2[2] = sciGetLineWidth (psubwin) ;
03333     x2[3] = sciGetLineStyle (psubwin);
03334     x2[4] = 0;
03335     C2F(dr)("xget","line style",&verbose2,dash2,&narg2,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); 
03336     C2F(dr)("xget","pattern",&verbose2,&pat,&narg2,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03337     C2F (dr) ("xset", "dashes", x2, x2, x2+4, x2+4, x2+4,PI0,PD0,PD0,PD0,PD0, 5L, 6L);
03338     C2F (dr) ("xset","foreground",x2,x2,x2+4,x2+4,x2+4,PI0,PD0,PD0,PD0,PD0,5L,4096); /* F.Leray 05.03.04 Useless too*/
03339     C2F (dr) ("xset","thickness",x2+2,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03340     C2F (dr) ("xset", "line style", x2+3,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03341     if ( ppsubwin->axes.axes_visible[2] )
03342     {
03343       /* draw the line of the axis like in 2d */
03344       /* the two bounds are (ixbox[2],iybox[2]) and (ixbox[2],iybox[2]) */
03345       C2F(dr)("xpolys","v",&(ixbox[2]),&(iybox[2]),x2,&one,&two, PI0,PD0,PD0,PD0,PD0,0L,0L);
03346     }
03347     if ( ( xind[4]+xind[5] == 3) || ( xind[4]+xind[5] == 11 ) )
03348     {
03349       /* i copy this test but I don't know what it mean... jb Silvy 03/2006 */
03350       if ( ppsubwin->axes.axes_visible[1] )
03351       {
03352         /* draw the line of the axis like in 2d */
03353         /* the two bounds are (ixbox[3],iybox[3]) and (ixbox[3],iybox[3]) */
03354         C2F(dr)("xpolys","v",&(ixbox[3]),&(iybox[3]),x2,&one,&two, PI0,PD0,PD0,PD0,PD0,0L,0L);
03355       }
03356       if ( ppsubwin->axes.axes_visible[0] )
03357       {
03358         /* draw the line of the axis like in 2d */
03359         /* the two bounds are (ixbox[4],iybox[4]) and (ixbox[4],iybox[4]) */
03360         C2F(dr)("xpolys","v",&(ixbox[4]),&(iybox[4]),x2,&one,&two, PI0,PD0,PD0,PD0,PD0,0L,0L);
03361       }
03362     }
03363     else
03364     {
03365       if ( ppsubwin->axes.axes_visible[1] )
03366       {
03367         /* draw the line of the axis like in 2d */
03368         /* the two bounds are (ixbox[3],iybox[3]) and (ixbox[3],iybox[3]) */
03369         C2F(dr)("xpolys","v",&(ixbox[4]),&(iybox[4]),x2,&one,&two, PI0,PD0,PD0,PD0,PD0,0L,0L);
03370       }
03371       if ( ppsubwin->axes.axes_visible[0] )
03372       {
03373         /* draw the line of the axis like in 2d */
03374         /* the two bounds are (ixbox[4],iybox[4]) and (ixbox[4],iybox[4]) */
03375         C2F(dr)("xpolys","v",&(ixbox[3]),&(iybox[3]),x2,&one,&two, PI0,PD0,PD0,PD0,PD0,0L,0L);
03376       }
03377     }
03378     C2F(dr)("xset","pattern",&pat,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03379     C2F(dr)("xset","line style",dash2,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03380   }  
03381 
03382   /********************/
03383   /*** le z scaling ***/ /* DISPLAY Z graduations */
03384   /********************/
03385 
03386 
03387   if (pSUBWIN_FEATURE (psubwin)->project[2]==1)
03388   {
03389     double fx,fy,fz; 
03390     char c_format[5] ;
03391 
03392     integer Ticsdir[2];
03393     Ticsdir[0]=ixbox[3]-ixbox[4]; /* <=> en pixel direction/vecteur non norme(e)s des tics en x */
03394     Ticsdir[1]=iybox[3]-iybox[4]; /* <=> idem pour y */
03395     /* NB: for a default plot3d (simply calling plot3d in siclab console) */
03396     /* Ticsdir[0] & Ticsdir[1] are negative : we do min - max here... */
03397 
03398     BBoxToval(&fx,&fy,&fz,xind[3],bbox); /* xind[3] <=> en bas a gauche <=> zmin */
03399     x=ixbox[2]-(xz[0]+xz[1])/20;
03400     y=(iybox[3]+iybox[2])/2;
03401 
03402     /*       NumberFormat(str,((integer) zz[0]),((integer) zz[2])); */
03403 
03404 
03405     if( !ppsubwin->axes.auto_ticks[2] )
03406     {
03407       /* we display the z tics specified by the user*/
03408       nbtics = ppsubwin->axes.u_nzgrads;
03409       nbsubtics = ppsubwin->axes.nbsubtics[2];
03410 
03411       maxTicksLabelSize[0] = 0 ;
03412       maxTicksLabelSize[1] = 0 ;
03413 
03414       for(i=0;i<nbtics;i++)
03415       {
03416         char *foo = ppsubwin->axes.u_zlabels[i]; 
03417         double ztmp = ppsubwin->axes.u_zgrads[i];
03418 
03419         if(ztmp<zminval || ztmp>zmaxval) 
03420         {
03421           /*   sciprint("je rejete la valeur: %lf\n\n",xtmp); */
03422           continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
03423           /* donc autant ne pas aller plus loin dans l'algo... */
03424         }
03425 
03426 
03427         /***************************************************************/
03428         /************************* COMMON PART *************************/
03429         /***************************************************************/
03430 
03431         if( ppsubwin->axes.reverse[2] )
03432         {
03433           ztmp = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],ztmp);
03434         }
03435 
03436         ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&ztmp);
03437 
03438 
03439         vx[0]=xm;vy[0]=ym;
03440 
03441         barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
03442         barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
03443         vx[1]=vx[0]+barlengthx;
03444         vy[1]=vy[0]+barlengthy;
03445 
03446         /* foo is set above with sprintf(foo,c_format,xtmp); */
03447 
03448         C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
03449 
03450         /* get the size of ticks label */
03451         C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03452         maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
03453         maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
03454 
03455 
03456         posi[0] = inint( xm+2*barlengthx - rect[2]); 
03457         posi[1]=inint( ym + 2*barlengthy + rect[3]/2);
03458 
03459 
03460         if(ppsubwin->axes.axes_visible[2] == TRUE){
03461           C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03462           C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03463           C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
03464           C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03465           C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03466         }
03467         /* grid to put here */
03468         if ( ppsubwin->grid[2] > -1 && ppsubwin->axes.axes_visible[2] )
03469         {
03470           gstyle = pSUBWIN_FEATURE (psubwin)->grid[2];
03471 
03472           if((ppsubwin->logflags[2] =='l') && (i != nbtics-1))
03473           {
03474             double tmp[2];
03475             double pas=0;
03476             double * tmp_log_grads = (double *) NULL;
03477 
03478 
03479             double * grads = ppsubwin->axes.u_zgrads;
03480 
03481             tmp[0] = exp10(grads[i]);
03482             tmp[1] = exp10(grads[i+1]);
03483             pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
03484 
03485             if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
03486               sciprint("Error allocating tmp_log_grads\n");
03487               return -1;
03488             }
03489 
03490             for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
03491 
03492             for(j=0;j<nbsubtics;j++)
03493             {
03494               vzz1 = tmp_log_grads[j];
03495 
03496               if(vzz1<=zminval || vzz1>=zmaxval) continue;       
03497 
03498               if(ppsubwin->axes.reverse[2] == TRUE)
03499                 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
03500 
03501               ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
03502 
03503               /*  if ((ym != iybox[3]) && (ym != iybox[2])) */
03504               /*                            { */
03505               C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03506               C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03507               xg[0]= ixbox[3];yg[0]= ym;
03508               if (Ishidden(psubwin))
03509               {  xg[1]=ixbox[4];  yg[1]= iybox[4]- iybox[3]+ym;}
03510               else
03511               {xg[1]=ixbox[1];  yg[1]= iybox[1]- iybox[2]+ym;}
03512               C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03513               xg[0]=xg[1];  ; xg[1] =ixbox[0];
03514               yg[0]=yg[1]; yg[1]= ym- iybox[3]+ iybox[5];
03515               C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03516               C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03517               /*   } */
03518             }
03519             FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
03520           }
03521           else
03522           { 
03523             if(ztmp>zminval && ztmp<zmaxval) 
03524             {
03525               C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03526               C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03527               xg[0]= ixbox[3];yg[0]= ym;
03528               if (Ishidden(psubwin))
03529               {  xg[1]=ixbox[4];  yg[1]= iybox[4]- iybox[3]+ym;}
03530               else
03531               {xg[1]=ixbox[1];  yg[1]= iybox[1]- iybox[2]+ym;}
03532               C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03533               xg[0]=xg[1];  ; xg[1] =ixbox[0];
03534               yg[0]=yg[1]; yg[1]= ym- iybox[3]+ iybox[5];
03535               C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03536               C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03537             }
03538           }
03539         }
03540 
03541         /* and subtics */
03542         if(i != nbtics-1)
03543         {
03544           if(ppsubwin->logflags[2] =='l')
03545           {
03546             double tmp[2];
03547             double pas=0;
03548             double * tmp_log_grads = (double *) NULL;
03549 
03550 
03551             double * grads = ppsubwin->axes.u_zgrads;
03552 
03553             tmp[0] = exp10(grads[i]);
03554             tmp[1] = exp10(grads[i+1]);
03555             pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
03556 
03557             if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
03558               sciprint("Error allocating tmp_log_grads\n");
03559               return -1;
03560             }
03561 
03562             for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
03563 
03564             for(j=0;j<nbsubtics;j++)
03565             {
03566               vzz1 = tmp_log_grads[j];
03567 
03568               if(vzz1<zminval || vzz1>zmaxval) continue;
03569 
03570               if(ppsubwin->axes.reverse[2] == TRUE)
03571                 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
03572 
03573               ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
03574 
03575               vx[0]=xm;vy[0]=ym;
03576               vx[1]= (integer) (vx[0]+barlengthx/2.0);
03577               vy[1]= (integer) (vy[0]+barlengthy/2.0);
03578 
03579               if(ppsubwin->axes.axes_visible[2] == TRUE)
03580                 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03581             }
03582             FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
03583           } /* end NEW */
03584           else
03585           {
03586             double xtmp = ppsubwin->axes.u_zgrads[i];
03587             double dx = (ppsubwin->axes.u_zgrads[i+1] - ppsubwin->axes.u_zgrads[i]) / nbsubtics;
03588             for(j=0;j<nbsubtics;j++)
03589             {
03590               vzz1=xtmp+dx*j;
03591 
03592               if(vzz1<zminval || vzz1>zmaxval) continue;         
03593 
03594               if(ppsubwin->axes.reverse[2] == TRUE)
03595                 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
03596 
03597               ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
03598               /*                      trans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1); */
03599 
03600 
03601               vx[0]=xm;vy[0]=ym;
03602               vx[1]= (integer) (vx[0]+barlengthx/2.0);
03603               vy[1]= (integer) (vy[0]+barlengthy/2.0);
03604 
03605               if(ppsubwin->axes.axes_visible[2] == TRUE)
03606                 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03607             }
03608           } 
03609         }
03610 
03611         /***************************************************************/
03612         /************************* END OF COMMON PART ******************/
03613         /***************************************************************/
03614       }
03615     }
03616     else /* we display the computed tics */
03617     {
03618       AdaptGraduationsOnZ(x,y,size,Ticsdir,fontid,psubwin,zminval,zmaxval,fx,fy,0.);
03619 
03620       lastzindex = ppsubwin->axes.nzgrads - 1;
03621 
03622       if(lastzindex == 0)
03623         ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.zgrads[0]));
03624       else
03625         ChoixFormatE(c_format,
03626         ppsubwin->axes.zgrads[0],
03627         ppsubwin->axes.zgrads[lastzindex],
03628         ((ppsubwin->axes.zgrads[lastzindex])-(ppsubwin->axes.zgrads[0]))/(lastzindex));
03629 
03630       nbtics = ppsubwin->axes.nzgrads;
03631       nbsubtics = ppsubwin->axes.nbsubtics[2];
03632 
03633       maxTicksLabelSize[0] = 0 ;
03634       maxTicksLabelSize[1] = 0 ;
03635 
03636       for(i=0;i<nbtics;i++)
03637       {
03638         char foo[256]; 
03639         double ztmp = ppsubwin->axes.zgrads[i];
03640 
03641         if(ztmp<zminval || ztmp>zmaxval) 
03642         {
03643           /*   sciprint("je rejete la valeur: %lf\n\n",xtmp); */
03644           continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
03645           /* donc autant ne pas aller plus loin dans l'algo... */
03646         }
03647 
03648         sprintf(foo,c_format,ztmp);
03649 
03650         /***************************************************************/
03651         /************************* COMMON PART *************************/
03652         /***************************************************************/
03653         if(ppsubwin->axes.reverse[2] == TRUE)
03654           ztmp = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],ztmp);
03655 
03656         ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&ztmp);
03657 
03658         /*            trans3d(psubwin,1,&xm,&ym,&fx,&fy,&ztmp); */
03659 
03660 
03661         vx[0]=xm;vy[0]=ym;
03662 
03663         barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
03664         barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
03665         vx[1]=vx[0]+barlengthx;
03666         vy[1]=vy[0]+barlengthy;
03667 
03668         /* foo is set above with sprintf(foo,c_format,xtmp); */
03669 
03670         C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
03671 
03672         /* get the size of ticks label */
03673         C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03674         maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
03675         maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
03676 
03677         posi[0] = inint( xm+2*barlengthx - rect[2]); 
03678         posi[1]=inint( ym + 2*barlengthy + rect[3]/2);
03679 
03680         if(ppsubwin->axes.axes_visible[2] == TRUE){
03681           C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03682           C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03683           if ( ppsubwin->logflags[2] == 'l' )
03684           {
03685             int smallersize = fontid[1]-2;
03686             int old_rect10[4];
03687             /*              char str[2] = "xv"; */
03688             int posi10[2];
03689 
03690             posi10[0] = posi[0] - logrect[2];
03691             posi10[1] = posi[1] + logrect[3];
03692 
03693             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03694             C2F(dr)("xstring","10",(&posi10[0]),(&posi10[1]),PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
03695 
03696             C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03697 
03698             posi[0] = old_rect10[0] + old_rect10[2];
03699             posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
03700 
03701             C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03702             C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
03703 
03704             /* put back the current fontid */
03705             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03706           }
03707           else{
03708             C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
03709           }
03710 
03711           C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);   
03712           C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03713         }
03714         /* grid to put here */
03715         if ( ppsubwin->grid[2] > -1 && ppsubwin->axes.axes_visible[2] )
03716         {
03717           gstyle = pSUBWIN_FEATURE (psubwin)->grid[2];
03718 
03719           if((ppsubwin->logflags[2] =='l') && (i != nbtics-1))
03720           {
03721             double tmp[2];
03722             double pas=0;
03723             double * tmp_log_grads = (double *) NULL;
03724 
03725 
03726             double * grads = ppsubwin->axes.zgrads;
03727 
03728             tmp[0] = exp10(grads[i]);
03729             tmp[1] = exp10(grads[i+1]);
03730             pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
03731 
03732             if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
03733               sciprint("Error allocating tmp_log_grads\n");
03734               return -1;
03735             }
03736 
03737             for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
03738 
03739             for(j=0;j<nbsubtics;j++)
03740             {
03741               vzz1 = tmp_log_grads[j];
03742 
03743               if(vzz1<=zminval || vzz1>=zmaxval) continue;       
03744 
03745               if(ppsubwin->axes.reverse[2] == TRUE)
03746                 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
03747 
03748               ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
03749 
03750               /*  if ((ym != iybox[3]) && (ym != iybox[2])) */
03751               /*                            { */
03752               C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03753               C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03754               xg[0]= ixbox[3];yg[0]= ym;
03755               if (Ishidden(psubwin))
03756               {  xg[1]=ixbox[4];  yg[1]= iybox[4]- iybox[3]+ym;}
03757               else
03758               {xg[1]=ixbox[1];  yg[1]= iybox[1]- iybox[2]+ym;}
03759               C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03760               xg[0]=xg[1];  ; xg[1] =ixbox[0];
03761               yg[0]=yg[1]; yg[1]= ym- iybox[3]+ iybox[5];
03762               C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03763               C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03764               /*   } */
03765             }
03766             FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
03767           }
03768           else
03769           {
03770             if(ztmp>zminval && ztmp<zmaxval) 
03771             {
03772               C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03773               C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03774               xg[0]= ixbox[3];yg[0]= ym;
03775               if (Ishidden(psubwin))
03776               {  xg[1]=ixbox[4];  yg[1]= iybox[4]- iybox[3]+ym;}
03777               else
03778               {xg[1]=ixbox[1];  yg[1]= iybox[1]- iybox[2]+ym;}
03779               C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03780               xg[0]=xg[1];  ; xg[1] =ixbox[0];
03781               yg[0]=yg[1]; yg[1]= ym- iybox[3]+ iybox[5];
03782               C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03783               C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03784             }
03785           }
03786         }
03787 
03788         /* and subtics */
03789         if(i != nbtics-1)
03790         {
03791           if(ppsubwin->logflags[2] =='l')
03792           {
03793             double tmp[2];
03794             double pas=0;
03795             double * tmp_log_grads = (double *) NULL;
03796 
03797 
03798             double * grads = ppsubwin->axes.zgrads;
03799 
03800             tmp[0] = exp10(grads[i]);
03801             tmp[1] = exp10(grads[i+1]);
03802             pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
03803 
03804             if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
03805               sciprint("Error allocating tmp_log_grads\n");
03806               return -1;
03807             }
03808 
03809             for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
03810 
03811             for(j=0;j<nbsubtics;j++)
03812             {
03813               vzz1 = tmp_log_grads[j];
03814 
03815               if(vzz1<zminval || vzz1>zmaxval) continue;
03816 
03817               if(ppsubwin->axes.reverse[2] == TRUE)
03818                 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
03819 
03820               ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
03821 
03822               vx[0]=xm;vy[0]=ym;
03823               vx[1]= (integer) (vx[0]+barlengthx/2.0);
03824               vy[1]= (integer) (vy[0]+barlengthy/2.0);
03825 
03826               if(ppsubwin->axes.axes_visible[2] == TRUE)
03827                 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03828             }
03829             FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
03830           } /* end NEW */
03831           else
03832           {
03833             double ztmp2 = ppsubwin->axes.zgrads[i];
03834             double dz = (ppsubwin->axes.zgrads[i+1] - ppsubwin->axes.zgrads[i]) / nbsubtics;
03835             for(j=0;j<nbsubtics;j++)
03836             {
03837               vzz1=ztmp2+dz*j;
03838 
03839               if(vzz1<zminval || vzz1>zmaxval) continue;
03840 
03841               if(ppsubwin->axes.reverse[2] == TRUE)
03842                 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
03843 
03844               ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
03845               /*                      trans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1); */
03846 
03847 
03848               vx[0]=xm;vy[0]=ym;
03849               vx[1]= (integer) (vx[0]+barlengthx/2.0);
03850               vy[1]= (integer) (vy[0]+barlengthy/2.0);
03851 
03852               if(ppsubwin->axes.axes_visible[2] == TRUE)
03853                 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03854             }
03855           }
03856         }
03857         /***************************************************************/
03858         /************************* END OF COMMON PART ******************/
03859         /***************************************************************/
03860 
03861       }
03862     }
03863   }
03864 
03865   if ( sciGetVisibility(ppsubwin->mon_z_label) )
03866   {
03867     /* draw z label */
03868     sciLabel * ppLabel = pLABEL_FEATURE(ppsubwin->mon_z_label) ;
03869 
03870     if ( ppLabel->auto_rotation )
03871     {
03872       /* mult by 10 because */
03873       sciSetFontOrientation(ppsubwin->mon_z_label, 270 * 10 ) ;
03874     }
03875 
03876     if( ppLabel->auto_position )
03877     {
03878 
03879       int segmentStart[2] = { ixbox[2], iybox[2] } ;
03880       int segmentEnd[2]   = { ixbox[3], iybox[3] } ;
03881 
03882       /* add the bar size and ticks label size to the offset */
03883       int offset[2] = { constOffset[0] + maxTicksLabelSize[0] + abs( barlengthx ), 
03884         constOffset[1] + maxTicksLabelSize[1] + abs( barlengthy )  } ;
03885       computeLabelAutoPos( ppsubwin->mon_z_label, segmentStart, segmentEnd, offset ) ;
03886     }
03887     /* a trick to force the display with 2d scale */
03888     drawTextEntity( ppLabel->text ) ;
03889 
03890   }
03891 
03892 
03893   /***********************/ 
03894   /*** le  x-y scaling ***/ /* DISPLAY x or y graduations */
03895   /***********************/
03896 
03897 
03898   if (( xind[4]+xind[5] == 3) || ( xind[4]+xind[5] == 11))
03899   {
03900     if (pSUBWIN_FEATURE (psubwin)->project[0]==1) /* x HERE */
03901     {
03902       double fx,fy,fz;
03903       char c_format[5];
03904 
03905       integer Ticsdir[2]; 
03906       Ticsdir[0]=ixbox[4]-ixbox[3];
03907       Ticsdir[1]=iybox[4]-iybox[3];
03908       BBoxToval(&fx,&fy,&fz,xind[4],bbox);
03909       x=inint((ixbox[4]+ixbox[5])/2+1.5*rect[2] +iof);
03910       y=inint(((2/3.0)*iybox[4]+(1/3.0)*iybox[5])+1.5*rect[3]+iof);
03911 
03912       if( !ppsubwin->axes.auto_ticks[0] )
03913       {
03914         /* we display the x tics specified by the user*/
03915         nbtics = ppsubwin->axes.u_nxgrads;
03916         nbsubtics = ppsubwin->axes.nbsubtics[0];
03917 
03918         maxTicksLabelSize[0] = 0 ;
03919         maxTicksLabelSize[1] = 0 ;
03920 
03921         for(i=0;i<nbtics;i++)
03922         {
03923           char *foo = ppsubwin->axes.u_xlabels[i]; 
03924           double xtmp = ppsubwin->axes.u_xgrads[i];
03925 
03926           if(xtmp<xminval || xtmp>xmaxval) 
03927           {
03928             /*   sciprint("je rejete la valeur: %lf\n\n",xtmp); */
03929             continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
03930             /* donc autant ne pas aller plus loin dans l'algo... */
03931           }
03932 
03933           /***************************************************************/
03934           /************************* COMMON PART *************************/
03935           /***************************************************************/
03936 
03937           if(ppsubwin->axes.reverse[0] == TRUE)
03938             xtmp = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],xtmp);
03939 
03940           ComputeGoodTrans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz);
03941           /*   trans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz); */
03942 
03943 
03944           vx[0]=xm;vy[0]=ym;
03945 
03946           barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
03947           barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
03948 
03949           C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
03950 
03951           /* get the size of the icks label */
03952           C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03953           maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
03954           maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
03955 
03956 
03957           if (IsDownAxes(psubwin)){
03958             vx[1]=vx[0];
03959             vy[1]=vy[0]+iof/2;
03960             posi[0] = inint(xm-rect[2]/2); 
03961             posi[1]=inint( vy[0] + iof + rect[3]);}
03962           else{
03963             vx[1]=vx[0]+barlengthx;
03964             vy[1]=vy[0]+barlengthy;
03965             posi[0] = inint( xm+2*barlengthx);
03966             posi[1]=inint( ym + 2*barlengthy + rect[3]);}
03967 
03968           if( ppsubwin->axes.axes_visible[0] )
03969           {    
03970             C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03971             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
03972             C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
03973             C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);   
03974             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
03975           }
03976           /* grid to put here */
03977           if ( ppsubwin->grid[0] > -1 && ppsubwin->axes.axes_visible[0] )
03978           {
03979             gstyle = pSUBWIN_FEATURE (psubwin)->grid[0];
03980 
03981             if((ppsubwin->logflags[0] =='l') && (i != nbtics-1))
03982             {
03983               double tmp[2];
03984               double pas=0;
03985               double * tmp_log_grads = (double *) NULL;
03986 
03987 
03988               double * grads = ppsubwin->axes.u_xgrads;
03989 
03990               tmp[0] = exp10(grads[i]);
03991               tmp[1] = exp10(grads[i+1]);
03992               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
03993 
03994               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
03995                 sciprint("Error allocating tmp_log_grads\n");
03996                 return -1;
03997               }
03998 
03999               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
04000 
04001               for(j=0;j<nbsubtics;j++)
04002               {
04003                 vxx1 = tmp_log_grads[j];
04004 
04005                 if(vxx1<=xminval || vxx1>=xmaxval) continue;
04006 
04007                 if(ppsubwin->axes.reverse[0] == TRUE)
04008                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
04009 
04010                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
04011 
04012                 /*  if ((xm != ixbox[5]) && (xm != ixbox[4])) */
04013                 /*                              {  */
04014                 xg[0]= xm;  yg[0]= ym;  
04015                 if (Ishidden(psubwin)) 
04016                 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
04017                 else
04018                 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; } 
04019 
04020                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04021                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04022                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04023                 xg[0]= xg[1]; yg[0]= yg[1];
04024                 xg[1] = ixbox[3] - ixbox[4] +xm; 
04025                 yg[1]=  iybox[2] - iybox[4] +ym;
04026                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04027                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
04028                 /*      } */
04029               }
04030               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
04031             }
04032             else
04033             {
04034               if(xtmp>xminval && xtmp<xmaxval) 
04035               {
04036                 xg[0]= xm;  yg[0]= ym;  
04037                 if (Ishidden(psubwin)) 
04038                 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
04039                 else
04040                 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; } 
04041                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04042                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04043                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04044                 xg[0]= xg[1]; yg[0]= yg[1];
04045                 xg[1] = ixbox[3] - ixbox[4] +xm; 
04046                 yg[1]=  iybox[2] - iybox[4] +ym;
04047                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04048                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
04049               }
04050             }
04051           }
04052 
04053           /* and subtics */
04054           if(i != nbtics-1)
04055           {
04056             if(ppsubwin->logflags[0] =='l')
04057             {
04058               double tmp[2];
04059               double pas=0;
04060               double * tmp_log_grads = (double *) NULL;
04061 
04062 
04063               double * grads = ppsubwin->axes.u_xgrads;
04064 
04065               tmp[0] = exp10(grads[i]);
04066               tmp[1] = exp10(grads[i+1]);
04067               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
04068 
04069               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
04070                 sciprint("Error allocating tmp_log_grads\n");
04071                 return -1;
04072               }
04073 
04074               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
04075 
04076               for(j=0;j<nbsubtics;j++)
04077               {
04078                 vxx1 = tmp_log_grads[j];
04079 
04080                 if(vxx1<xminval || vxx1>xmaxval) continue;
04081 
04082                 if(ppsubwin->axes.reverse[0] == TRUE)
04083                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
04084 
04085                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
04086 
04087                 if (IsDownAxes(psubwin))
04088                 {
04089                   vx[1]=vx[0]=xm;
04090                   vy[0]=ym;
04091                   vy[1]=vy[0]+iof/4;
04092                 }
04093                 else
04094                 {
04095                   vx[0]=xm;vy[0]=ym;
04096                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
04097                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
04098                 }
04099 
04100                 if(ppsubwin->axes.axes_visible[0] == TRUE)
04101                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04102               }
04103 
04104               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
04105             } /* end NEW */
04106             else
04107             {
04108               double xtmp2 = ppsubwin->axes.u_xgrads[i];
04109               double dx = (ppsubwin->axes.u_xgrads[i+1] - ppsubwin->axes.u_xgrads[i]) / nbsubtics;
04110 
04111               for (j=1;j<nbsubtics;j++)
04112               {  
04113                 vxx1=xtmp2+dx*j;
04114 
04115                 if(vxx1<xminval || vxx1>xmaxval) continue;
04116 
04117                 if(ppsubwin->axes.reverse[0] == TRUE)
04118                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
04119 
04120                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
04121                 /*                        trans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz); */
04122 
04123 
04124                 if (IsDownAxes(psubwin))
04125                 {
04126                   vx[1]=vx[0]=xm;
04127                   vy[0]=ym;
04128                   vy[1]=vy[0]+iof/4;
04129                 }
04130                 else
04131                 {
04132                   vx[0]=xm;vy[0]=ym;
04133                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
04134                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
04135                 }
04136 
04137                 if(ppsubwin->axes.axes_visible[0] == TRUE)   
04138                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04139               }
04140             }
04141           }
04142           /***************************************************************/
04143           /************************* END OF COMMON PART ******************/
04144           /***************************************************************/
04145 
04146         }
04147       }
04148       else /* we display the computed tics */
04149       {
04150         AdaptGraduationsOnXBottomRight(iof,x,y,size,Ticsdir,fontid,psubwin,xminval,xmaxval,0.,fy,fz);
04151 
04152         lastxindex = ppsubwin->axes.nxgrads - 1;
04153 
04154         if(lastxindex == 0)
04155         {
04156           ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.xgrads[0]));
04157         }
04158         else
04159         {
04160           ChoixFormatE(c_format,
04161             ppsubwin->axes.xgrads[0],
04162             ppsubwin->axes.xgrads[lastxindex],
04163             ((ppsubwin->axes.xgrads[lastxindex])-(ppsubwin->axes.xgrads[0]))/(lastxindex));
04164         }
04165 
04166         nbtics = ppsubwin->axes.nxgrads;
04167         nbsubtics = ppsubwin->axes.nbsubtics[0];
04168 
04169         maxTicksLabelSize[0] = 0 ;
04170         maxTicksLabelSize[1] = 0 ;
04171 
04172         for(i=0;i<nbtics;i++)
04173         {
04174           char foo[256]; 
04175           double xtmp = ppsubwin->axes.xgrads[i];
04176 
04177           if(xtmp<xminval || xtmp>xmaxval) 
04178           {
04179             /*   sciprint("je rejete la valeur: %lf\n\n",xtmp); */
04180             continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
04181             /* donc autant ne pas aller plus loin dans l'algo... */
04182           }
04183 
04184           sprintf(foo,c_format,xtmp);
04185 
04186           /***************************************************************/
04187           /************************* COMMON PART *************************/
04188           /***************************************************************/
04189 
04190 
04191           /* F.Leray 03.11.04 Test if log scale to perform a : exp10(x) because trans3d will */
04192           /* re-do a log10() (that is needed for data computations) */
04193 
04194           if( ppsubwin->axes.reverse[0] )
04195           {
04196             xtmp = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],xtmp);
04197           }
04198 
04199           ComputeGoodTrans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz);
04200 
04201           vx[0]=xm;vy[0]=ym; 
04202 
04203           barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
04204           barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
04205 
04206           C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
04207 
04208           /* get the size of ticks label */
04209           C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04210           maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
04211           maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
04212 
04213           if (IsDownAxes(psubwin)){
04214             vx[1]=vx[0];
04215             vy[1]=vy[0]+iof/2;
04216             posi[0] = inint(xm-rect[2]/2); 
04217             posi[1]=inint( vy[0] + iof + rect[3]);}
04218           else{
04219             vx[1]=vx[0]+barlengthx;
04220             vy[1]=vy[0]+barlengthy;
04221             posi[0] = inint( xm+2*barlengthx);
04222             posi[1]=inint( ym + 2*barlengthy + rect[3]);}
04223 
04224           if( ppsubwin->axes.axes_visible[0] )
04225           {
04226             C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04227             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04228             if ( ppsubwin->logflags[0] == 'l' )
04229             {
04230               int smallersize = fontid[1]-2;
04231               int old_rect10[4];
04232               int posi10[2];
04233 
04234               posi10[0] = posi[0] - logrect[2];
04235               posi10[1] = posi[1] + logrect[3];
04236 
04237               C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04238               C2F(dr)("xstring","10",(&posi10[0]),(&posi10[1]),PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
04239 
04240               C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04241 
04242               posi[0] = old_rect10[0] + old_rect10[2];
04243               posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
04244 
04245               C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04246               C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
04247 
04248               /* put back the current fontid */
04249               C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04250             }
04251             else
04252             {
04253               C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
04254             }       
04255             C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);   
04256             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04257           }
04258           /* grid to put here */
04259           if ( ppsubwin->grid[0] > -1 && ppsubwin->axes.axes_visible[0]  )
04260           {
04261             gstyle = pSUBWIN_FEATURE (psubwin)->grid[0];
04262 
04263             if((ppsubwin->logflags[0] =='l') && (i != nbtics-1))
04264             {
04265               double tmp[2];
04266               double pas=0;
04267               double * tmp_log_grads = (double *) NULL;
04268 
04269 
04270               double * grads = ppsubwin->axes.xgrads;
04271 
04272               tmp[0] = exp10(grads[i]);
04273               tmp[1] = exp10(grads[i+1]);
04274               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
04275 
04276               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
04277                 sciprint("Error allocating tmp_log_grads\n");
04278                 return -1;
04279               }
04280 
04281               for(j=0;j<nbsubtics;j++)
04282               {
04283                 tmp_log_grads[j] = log10( tmp[0] + (j) * pas ) ;
04284               }
04285 
04286               for(j=0;j<nbsubtics;j++)
04287               {
04288                 vxx1 = tmp_log_grads[j];
04289 
04290                 if(vxx1<=xminval || vxx1>=xmaxval) continue;
04291 
04292                 if(ppsubwin->axes.reverse[0] == TRUE)
04293                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
04294 
04295                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
04296 
04297                 /*  if ((xm != ixbox[5]) && (xm != ixbox[4])) */
04298                 /*                              {  */
04299                 xg[0]= xm;  yg[0]= ym;  
04300                 if (Ishidden(psubwin)) 
04301                 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
04302                 else
04303                 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; } 
04304 
04305                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04306                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04307                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04308                 xg[0]= xg[1]; yg[0]= yg[1];
04309                 xg[1] = ixbox[3] - ixbox[4] +xm; 
04310                 yg[1]=  iybox[2] - iybox[4] +ym;
04311                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04312                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
04313                 /*      } */
04314               }
04315               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
04316             }
04317             else
04318             {
04319               if(xtmp>xminval && xtmp<xmaxval) 
04320               {
04321                 xg[0]= xm;  yg[0]= ym;  
04322                 if (Ishidden(psubwin)) 
04323                 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
04324                 else
04325                 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; } 
04326                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04327                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04328                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04329                 xg[0]= xg[1]; yg[0]= yg[1];
04330                 xg[1] = ixbox[3] - ixbox[4] +xm; 
04331                 yg[1]=  iybox[2] - iybox[4] +ym;
04332                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04333                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
04334               }
04335             }   
04336           }
04337 
04338           /* and subtics */
04339           if(i != nbtics-1) /* F.Leray NEW 03.11.04 */
04340           {
04341 
04342             if(ppsubwin->logflags[0] =='l')
04343             {
04344               double tmp[2];
04345               double pas=0;
04346               double * tmp_log_grads = (double *) NULL;
04347 
04348 
04349               double * grads = ppsubwin->axes.xgrads;
04350 
04351               tmp[0] = exp10(grads[i]);
04352               tmp[1] = exp10(grads[i+1]);
04353               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
04354 
04355               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
04356                 sciprint("Error allocating tmp_log_grads\n");
04357                 return -1;
04358               }
04359 
04360               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
04361 
04362               for(j=0;j<nbsubtics;j++)
04363               {
04364                 vxx1 = tmp_log_grads[j];
04365 
04366                 if(vxx1<xminval || vxx1>xmaxval) continue;
04367 
04368                 if(ppsubwin->axes.reverse[0] == TRUE)
04369                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
04370 
04371                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
04372 
04373                 if (IsDownAxes(psubwin))
04374                 {
04375                   vx[1]=vx[0]=xm;
04376                   vy[0]=ym;
04377                   vy[1]=vy[0]+iof/4;
04378                 }
04379                 else
04380                 {
04381                   vx[0]=xm;vy[0]=ym;
04382                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
04383                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
04384                 }
04385 
04386                 if( ppsubwin->axes.axes_visible[0] )
04387                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04388               }
04389 
04390               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
04391             } /* end NEW */
04392             else
04393             {
04394               double xtmp2 = ppsubwin->axes.xgrads[i];
04395               double dx = (ppsubwin->axes.xgrads[i+1] - ppsubwin->axes.xgrads[i]) / nbsubtics;
04396 
04397               for (j=1;j<nbsubtics;j++)
04398               {  
04399                 vxx1=xtmp2+dx*j;
04400 
04401                 if(vxx1<xminval || vxx1>xmaxval) continue;
04402 
04403                 if(ppsubwin->axes.reverse[0] == TRUE)
04404                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
04405 
04406                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
04407 
04408                 if (IsDownAxes(psubwin))
04409                 {
04410                   vx[1]=vx[0]=xm;
04411                   vy[0]=ym;
04412                   vy[1]=vy[0]+iof/4;
04413                 }
04414                 else
04415                 {
04416                   vx[0]=xm;vy[0]=ym;
04417                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
04418                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
04419                 }
04420 
04421                 if(ppsubwin->axes.axes_visible[0] == TRUE)
04422                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04423               }
04424             }
04425           }
04426 
04427           /***************************************************************/
04428           /************************* END OF COMMON PART ******************/
04429           /***************************************************************/
04430 
04431         }
04432       }
04433     }
04434     if ( sciGetVisibility(ppsubwin->mon_x_label) )
04435     {
04436       sciLabel * ppLabel = pLABEL_FEATURE( ppsubwin->mon_x_label ) ;
04437       if( ppLabel->auto_rotation )
04438       {
04439         sciSetFontOrientation(ppsubwin->mon_x_label, 0) ;
04440       }
04441 
04442 
04443       if( ppLabel->auto_position )
04444       {
04445 
04446         int segmentStart[2] = { ixbox[4], iybox[4] } ;
04447         int segmentEnd[2]   = { ixbox[5], iybox[5] } ;
04448 
04449         /* add the bar size and ticks label size to the offset */
04450         int offset[2] = { constOffset[0] + maxTicksLabelSize[0] + abs( barlengthx ), 
04451           constOffset[1] + maxTicksLabelSize[1] + abs( barlengthy )  } ;
04452         computeLabelAutoPos( ppsubwin->mon_x_label, segmentStart, segmentEnd, offset ) ;
04453       }
04454       /* a trick to force the display with 2d scale */
04455       drawTextEntity( ppLabel->text ) ;
04456 
04457     }
04458   }
04459   else
04460   {
04461 
04462     if ( pSUBWIN_FEATURE (psubwin)->project[1]==1) /* y is HERE */
04463     {
04464       double fx,fy,fz; 
04465       char c_format[5];
04466 
04467       integer Ticsdir[2];
04468       Ticsdir[0]=ixbox[4]-ixbox[3];
04469       Ticsdir[1]=iybox[4]-iybox[3];
04470       BBoxToval(&fx,&fy,&fz,xind[4],bbox);
04471 
04472       x=inint((ixbox[4]+ixbox[5])/2+1.5*rect[2] +iof);
04473       y=inint(((2/3.0)*iybox[4]+(1/3.0)*iybox[5])+1.5*rect[3]+iof);
04474 
04475       if(ppsubwin->axes.auto_ticks[1] == FALSE)
04476       {
04477         /* we display the y tics specified by the user*/
04478         nbtics = ppsubwin->axes.u_nygrads;
04479         nbsubtics = ppsubwin->axes.nbsubtics[1];
04480 
04481         maxTicksLabelSize[0] = 0 ;
04482         maxTicksLabelSize[1] = 0 ;
04483 
04484         for(i=0;i<nbtics;i++)
04485         {
04486           char *foo = ppsubwin->axes.u_ylabels[i]; 
04487           double ytmp = ppsubwin->axes.u_ygrads[i];
04488 
04489           if(ytmp<yminval || ytmp>ymaxval) 
04490           {
04491             /*   sciprint("je rejete la valeur: %lf\n\n",xtmp); */
04492             continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
04493             /* donc autant ne pas aller plus loin dans l'algo... */
04494           }
04495 
04496 
04497           /***************************************************************/
04498           /************************* COMMON PART *************************/
04499           /***************************************************************/
04500 
04501           if(ppsubwin->axes.reverse[1] == TRUE)
04502             ytmp = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ytmp);
04503 
04504           ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz);
04505           /*              trans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz); */
04506 
04507 
04508 
04509           vx[0]=xm;vy[0]=ym;
04510 
04511           barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
04512           barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
04513           /*    NumberFormat(foo,((integer) (yy[0] + i*ceil((yy[1]-yy[0])/yy[3]))), */
04514           /*                         ((integer) yy[2])); */
04515           C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
04516 
04517           /* get the size of the ticks */
04518           C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04519           maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
04520           maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
04521 
04522 
04523           if (IsDownAxes(psubwin)){
04524             vx[1]=vx[0];
04525             vy[1]=vy[0]+iof/2;
04526             posi[0] = inint(xm-rect[2]/2); 
04527             posi[1]=inint( vy[0] + iof + rect[3]);}
04528           else{ 
04529             vx[1]=vx[0]+barlengthx;
04530             vy[1]=vy[0]+barlengthy;
04531             /*              posi[0] = inint( xm+2*barlengthx - rect[2]/2); */
04532             /*              posi[0] = inint( xm+2*barlengthx - rect[2]); */
04533             posi[0] = inint( xm+2*barlengthx);
04534             posi[1]=inint( ym + 2*barlengthy + rect[3]);}
04535 
04536           if(ppsubwin->axes.axes_visible[1] == TRUE){
04537             C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04538             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04539             C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
04540             C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
04541             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04542           }
04543           /* grid to put here */
04544           if ( ppsubwin->grid[1] > -1 && ppsubwin->axes.axes_visible[1] )
04545           {
04546             gstyle = pSUBWIN_FEATURE (psubwin)->grid[1];
04547 
04548             if((ppsubwin->logflags[1] =='l') && (i != nbtics-1))
04549             {
04550               double tmp[2];
04551               double pas=0;
04552               double * tmp_log_grads = (double *) NULL;
04553 
04554 
04555               double * grads = ppsubwin->axes.u_ygrads;
04556 
04557               tmp[0] = exp10(grads[i]);
04558               tmp[1] = exp10(grads[i+1]);
04559               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
04560 
04561               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
04562                 sciprint("Error allocating tmp_log_grads\n");
04563                 return -1;
04564               }
04565 
04566               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
04567 
04568               for(j=0;j<nbsubtics;j++)
04569               {
04570                 vyy1 = tmp_log_grads[j];
04571 
04572                 if(vyy1<=yminval || vyy1>=ymaxval) continue;
04573 
04574                 if(ppsubwin->axes.reverse[1] == TRUE)
04575                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
04576 
04577                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
04578 
04579                 /*  if ((xm != ixbox[5]) && (xm != ixbox[4])) */
04580                 /*                              {  */
04581                 xg[0]= xm;  yg[0]= ym;  
04582                 if (Ishidden(psubwin))
04583                 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
04584                 else
04585                 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; } 
04586                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04587                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04588                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04589                 xg[0]= xg[1]; yg[0]= yg[1];
04590                 xg[1] = ixbox[3] - ixbox[4] +xm; 
04591                 yg[1]=  iybox[2] - iybox[4] +ym;
04592                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04593                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
04594                 /*      } */
04595               }
04596               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
04597             }
04598             else
04599             {
04600               if(ytmp>yminval && ytmp<ymaxval) 
04601               {
04602                 xg[0]= xm;  yg[0]= ym;  
04603                 if (Ishidden(psubwin))
04604                 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
04605                 else
04606                 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; } 
04607                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04608                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04609                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04610                 xg[0]= xg[1]; yg[0]= yg[1];
04611                 xg[1] = ixbox[3] - ixbox[4] +xm; 
04612                 yg[1]=  iybox[2] - iybox[4] +ym;
04613                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04614                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
04615               }
04616             }
04617           }
04618 
04619           /* and subtics */
04620           if(i != nbtics-1)
04621           {
04622             if(ppsubwin->logflags[1] =='l')
04623             {
04624               double tmp[2];
04625               double pas=0;
04626               double * tmp_log_grads = (double *) NULL;
04627 
04628 
04629               double * grads = ppsubwin->axes.u_ygrads;
04630 
04631               tmp[0] = exp10(grads[i]);
04632               tmp[1] = exp10(grads[i+1]);
04633               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
04634 
04635               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
04636                 sciprint("Error allocating tmp_log_grads\n");
04637                 return -1;
04638               }
04639 
04640               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
04641 
04642               for(j=0;j<nbsubtics;j++)
04643               {
04644                 vyy1 = tmp_log_grads[j];
04645 
04646                 if(vyy1<yminval || vyy1>ymaxval) continue;
04647 
04648                 if(ppsubwin->axes.reverse[1] == TRUE)
04649                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
04650 
04651                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
04652 
04653                 if (IsDownAxes(psubwin))
04654                 {
04655                   vx[1]=vx[0]=xm;
04656                   vy[0]=ym;
04657                   vy[1]=vy[0]+iof/4;
04658                 }
04659                 else
04660                 {
04661                   vx[0]=xm;vy[0]=ym;
04662                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
04663                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
04664                 }
04665 
04666                 if(ppsubwin->axes.axes_visible[1] == TRUE)
04667                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04668               }
04669               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
04670 
04671             } /* end NEW */
04672             else
04673             {
04674               double ytmp2 = ppsubwin->axes.u_ygrads[i];
04675               double dy = (ppsubwin->axes.u_ygrads[i+1] - ppsubwin->axes.u_ygrads[i]) / nbsubtics;
04676               for(j=0;j<nbsubtics;j++)
04677               {
04678                 vyy1=ytmp2+dy*j;
04679 
04680                 if(vyy1<yminval || vyy1>ymaxval) continue;
04681 
04682                 if(ppsubwin->axes.reverse[1] == TRUE)
04683                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
04684 
04685                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
04686 
04687                 if (IsDownAxes(psubwin))
04688                 {
04689                   vx[1]=vx[0]=xm;
04690                   vy[0]=ym;
04691                   vy[1]=vy[0]+iof/4;
04692                 }
04693                 else
04694                 {
04695                   vx[0]=xm;vy[0]=ym;
04696                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
04697                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
04698                 }
04699 
04700                 if(ppsubwin->axes.axes_visible[1] == TRUE)
04701                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04702               }
04703             }
04704           }
04705 
04706           /***************************************************************/
04707           /************************* END OF COMMON PART ******************/
04708           /***************************************************************/
04709         }
04710       }
04711       else /* we display the computed tics */
04712       {
04713         AdaptGraduationsOnYBottomRight(iof,x,y,size,Ticsdir,fontid,psubwin,yminval,ymaxval,fx,0.,fz);
04714 
04715         lastyindex = ppsubwin->axes.nygrads - 1;
04716 
04717         if(lastyindex == 0)
04718           ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.ygrads[0]));
04719         else
04720           ChoixFormatE(c_format,
04721           ppsubwin->axes.ygrads[0],
04722           ppsubwin->axes.ygrads[lastyindex],
04723           ((ppsubwin->axes.ygrads[lastyindex])-(ppsubwin->axes.ygrads[0]))/(lastyindex));
04724 
04725         nbtics = ppsubwin->axes.nygrads;
04726         nbsubtics = ppsubwin->axes.nbsubtics[1];
04727 
04728         maxTicksLabelSize[0] = 0 ;
04729         maxTicksLabelSize[1] = 0 ;
04730 
04731         for(i=0;i<nbtics;i++)
04732         {
04733           char foo[256]; 
04734           double ytmp2 = ppsubwin->axes.ygrads[i];
04735 
04736           if(ytmp2<yminval || ytmp2>ymaxval) 
04737           {
04738             /*   sciprint("je rejete la valeur: %lf\n\n",xtmp); */
04739             continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
04740             /* donc autant ne pas aller plus loin dans l'algo... */
04741           }
04742 
04743           sprintf(foo,c_format,ytmp2);
04744 
04745           /***************************************************************/
04746           /************************* COMMON PART *************************/
04747           /***************************************************************/
04748 
04749           /* F.Leray 03.11.04 Test if log scale to perform a : exp10(x) because trans3d will */
04750           /* re-do a log10() (that is needed for data computations) */
04751 
04752 
04753           if(ppsubwin->axes.reverse[1] == TRUE)
04754             ytmp2 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ytmp2);
04755 
04756           ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&ytmp2,&fz);
04757 
04758 
04759           vx[0]=xm;vy[0]=ym;
04760 
04761           barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
04762           barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
04763 
04764           C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
04765 
04766 
04767           C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04768           maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
04769           maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
04770 
04771           if (IsDownAxes(psubwin)){
04772             vx[1]=vx[0];
04773             vy[1]=vy[0]+iof/2;
04774             posi[0] = inint(xm-rect[2]/2); 
04775             posi[1]=inint( vy[0] + iof + rect[3]);}
04776           else{ 
04777             vx[1]=vx[0]+barlengthx;
04778             vy[1]=vy[0]+barlengthy;
04779             /*              posi[0] = inint( xm+2*barlengthx - rect[2]/2); */
04780             /*              posi[0] = inint( xm+2*barlengthx - rect[2]); */
04781             posi[0] = inint( xm+2*barlengthx);
04782             posi[1]=inint( ym + 2*barlengthy + rect[3]);}
04783 
04784           if(ppsubwin->axes.axes_visible[1] == TRUE){
04785             C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04786             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04787             if ( ppsubwin->logflags[1] == 'l' )
04788             {
04789               int smallersize = fontid[1]-2;
04790               int old_rect10[4];
04791               /*                    char str[2] = "xv"; */
04792               int posi10[2];
04793 
04794               posi10[0] = posi[0] - logrect[2];
04795               posi10[1] = posi[1] + logrect[3];
04796 
04797               C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04798               C2F(dr)("xstring","10",(&posi10[0]),(&posi10[1]),PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
04799 
04800               C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04801 
04802               posi[0] = old_rect10[0] + old_rect10[2];
04803               posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
04804 
04805               C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04806               C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
04807 
04808               /* put back the current fontid */
04809               C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04810             }
04811             else
04812               C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
04813 
04814             C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
04815             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04816           }
04817 
04818           /* grid to put here */
04819 
04820           if ( ppsubwin->grid[1] > -1 && ppsubwin->axes.axes_visible[1] )
04821           {
04822             gstyle = pSUBWIN_FEATURE (psubwin)->grid[1];
04823 
04824             if((ppsubwin->logflags[1] =='l') && (i != nbtics-1))
04825             {
04826               double tmp[2];
04827               double pas=0;
04828               double * tmp_log_grads = (double *) NULL;
04829 
04830 
04831               double * grads = ppsubwin->axes.ygrads;
04832 
04833               tmp[0] = exp10(grads[i]);
04834               tmp[1] = exp10(grads[i+1]);
04835               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
04836 
04837               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
04838                 sciprint("Error allocating tmp_log_grads\n");
04839                 return -1;
04840               }
04841 
04842               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
04843 
04844               for(j=0;j<nbsubtics;j++)
04845               {
04846                 vyy1 = tmp_log_grads[j];
04847 
04848                 if(vyy1<=yminval || vyy1>=ymaxval) continue;
04849 
04850                 if(ppsubwin->axes.reverse[1] == TRUE)
04851                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
04852 
04853                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
04854 
04855                 /*  if ((xm != ixbox[5]) && (xm != ixbox[4])) */
04856                 /*                              {  */
04857                 xg[0]= xm;  yg[0]= ym;  
04858                 if (Ishidden(psubwin))
04859                 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
04860                 else
04861                 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; } 
04862                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04863                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04864                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04865                 xg[0]= xg[1]; yg[0]= yg[1];
04866                 xg[1] = ixbox[3] - ixbox[4] +xm; 
04867                 yg[1]=  iybox[2] - iybox[4] +ym;
04868                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04869                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
04870                 /*      } */
04871               }
04872               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
04873             }
04874             else
04875             {
04876               if(ytmp2>yminval && ytmp2<ymaxval) 
04877               {
04878                 xg[0]= xm;  yg[0]= ym;  
04879                 if (Ishidden(psubwin))
04880                 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
04881                 else
04882                 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; } 
04883                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04884                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
04885                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04886                 xg[0]= xg[1]; yg[0]= yg[1];
04887                 xg[1] = ixbox[3] - ixbox[4] +xm; 
04888                 yg[1]=  iybox[2] - iybox[4] +ym;
04889                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04890                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
04891               }
04892             }
04893           }
04894 
04895           /* and subtics */
04896           if(i != nbtics-1)
04897           {
04898             if(ppsubwin->logflags[1] =='l')
04899             {
04900               double tmp[2];
04901               double pas=0;
04902               double * tmp_log_grads = (double *) NULL;
04903 
04904 
04905               double * grads = ppsubwin->axes.ygrads;
04906 
04907               tmp[0] = exp10(grads[i]);
04908               tmp[1] = exp10(grads[i+1]);
04909               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
04910 
04911               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
04912                 sciprint("Error allocating tmp_log_grads\n");
04913                 return -1;
04914               }
04915 
04916               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
04917 
04918               for(j=0;j<nbsubtics;j++)
04919               {
04920                 vyy1 = tmp_log_grads[j];
04921 
04922                 if(vyy1<yminval || vyy1>ymaxval) continue;
04923 
04924                 if(ppsubwin->axes.reverse[1] == TRUE)
04925                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
04926 
04927                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
04928 
04929                 if (IsDownAxes(psubwin))
04930                 {
04931                   vx[1]=vx[0]=xm;
04932                   vy[0]=ym;
04933                   vy[1]=vy[0]+iof/4;
04934                 }
04935                 else
04936                 {
04937                   vx[0]=xm;vy[0]=ym;
04938                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
04939                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
04940                 }
04941 
04942                 if(ppsubwin->axes.axes_visible[1] == TRUE)
04943                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04944               }
04945               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
04946 
04947             } /* end NEW */
04948             else
04949             {
04950               double ytmp3 = ppsubwin->axes.ygrads[i];
04951               double dy = (ppsubwin->axes.ygrads[i+1] - ppsubwin->axes.ygrads[i]) / nbsubtics;
04952               for(j=0;j<nbsubtics;j++)
04953               {
04954                 vyy1=ytmp3+dy*j;
04955 
04956                 if(vyy1<yminval || vyy1>ymaxval) continue;
04957 
04958                 if(ppsubwin->axes.reverse[1] == TRUE)
04959                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
04960 
04961                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
04962                 /*   trans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz); */
04963 
04964                 if (IsDownAxes(psubwin))
04965                 {
04966                   vx[1]=vx[0]=xm;
04967                   vy[0]=ym;
04968                   vy[1]=vy[0]+iof/4;
04969                 }
04970                 else
04971                 {
04972                   vx[0]=xm;vy[0]=ym;
04973                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
04974                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
04975                 }
04976 
04977                 if(ppsubwin->axes.axes_visible[1] == TRUE)
04978                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
04979               }
04980             }
04981           }
04982           /***************************************************************/
04983           /************************* END OF COMMON PART ******************/
04984           /***************************************************************/
04985 
04986         }
04987       }
04988     }
04989     if ( sciGetVisibility(ppsubwin->mon_y_label) )
04990     {
04991       sciLabel * ppLabel = pLABEL_FEATURE( ppsubwin->mon_y_label ) ;
04992       if( ppLabel->auto_rotation )
04993       {
04994         sciSetFontOrientation( ppsubwin->mon_y_label, 0 ) ;
04995       }
04996 
04997       if( ppLabel->auto_position )
04998       {
04999 
05000         int segmentStart[2] = { ixbox[4], iybox[4] } ;
05001         int segmentEnd[2]   = { ixbox[5], iybox[5] } ;
05002 
05003         /* add the bar size and ticks label size to the offset */
05004         int offset[2] = { constOffset[0] + maxTicksLabelSize[0] + abs( barlengthx ), 
05005           constOffset[1] + maxTicksLabelSize[1] + abs( barlengthy )  } ;
05006         computeLabelAutoPos( ppsubwin->mon_y_label, segmentStart, segmentEnd, offset ) ;
05007       }
05008       /* a trick to force the display with 2d scale */
05009       drawTextEntity( ppLabel->text ) ;
05010 
05011     }
05012   }
05013 
05014 
05015 
05016   /***********************/ 
05017   /*** le  x-y scaling ***/ /* DISPLAY x or y graduations */
05018   /***********************/
05019 
05020   if (( xind[3]+xind[4] == 3) || ( xind[3]+xind[4] == 11))
05021   {
05022     if (pSUBWIN_FEATURE (psubwin)->project[0]==1) /* x HERE */
05023     {
05024       double fx,fy,fz;
05025       char c_format[5];
05026 
05027 
05028       integer Ticsdir[2];
05029       Ticsdir[0]=ixbox[4]-ixbox[5];
05030       Ticsdir[1]=iybox[4]-iybox[5];
05031       BBoxToval(&fx,&fy,&fz,xind[3],bbox);
05032 
05033       x=inint((ixbox[3]+ixbox[4])/2.0 -rect[2] -iof);
05034       y=inint((1/3.0)*iybox[3]+(2/3.0)*iybox[4]+ iof+ 1.5*rect[3]); 
05035 
05036       if(ppsubwin->axes.auto_ticks[0] == FALSE)
05037       {
05038         /* we display the x tics specified by the user*/
05039         nbtics = ppsubwin->axes.u_nxgrads;
05040         nbsubtics = ppsubwin->axes.nbsubtics[0];
05041 
05042         maxTicksLabelSize[0] = 0 ;
05043         maxTicksLabelSize[1] = 0 ;
05044 
05045         for(i=0;i<nbtics;i++)
05046         {
05047           char *foo = ppsubwin->axes.u_xlabels[i]; 
05048           double xtmp = ppsubwin->axes.u_xgrads[i];
05049 
05050           if(xtmp<xminval || xtmp>xmaxval) 
05051           {
05052             /*   sciprint("je rejete la valeur: %lf\n\n",xtmp); */
05053             continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
05054             /* donc autant ne pas aller plus loin dans l'algo... */
05055           }
05056 
05057           /***************************************************************/
05058           /************************* COMMON PART *************************/
05059           /***************************************************************/
05060 
05061           if(ppsubwin->axes.reverse[0] == TRUE)
05062             xtmp = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],xtmp);
05063 
05064           ComputeGoodTrans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz);
05065           /*              trans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz); */
05066 
05067 
05068           vx[0]=xm;vy[0]=ym;
05069 
05070           barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
05071           barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
05072 
05073           C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
05074 
05075           C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05076           maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
05077           maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
05078 
05079 
05080           if (IsDownAxes(psubwin)){
05081             vx[1]=vx[0];
05082             vy[1]=vy[0]+iof/2;
05083             posi[0] = inint(xm-rect[2]/2); 
05084             posi[1]=inint( vy[0] + iof + rect[3]);}
05085           else{
05086             vx[1]=vx[0]+barlengthx;
05087             vy[1]=vy[0]+barlengthy;
05088             posi[0] = inint( xm+2*barlengthx-rect[2]); 
05089             posi[1]=inint( ym + 2*barlengthy + rect[3]);}
05090 
05091           if(ppsubwin->axes.axes_visible[0] == TRUE){
05092             C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05093             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05094             C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
05095             C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);   
05096             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05097           }
05098           /* grid to put here */
05099           if ( ppsubwin->grid[0] > -1 && ppsubwin->axes.axes_visible[0]  )
05100           {
05101             gstyle = pSUBWIN_FEATURE (psubwin)->grid[0];
05102 
05103             if((ppsubwin->logflags[0] =='l') && (i != nbtics-1))
05104             {
05105               double tmp[2];
05106               double pas=0;
05107               double * tmp_log_grads = (double *) NULL;
05108 
05109 
05110               double * grads = ppsubwin->axes.u_xgrads;
05111 
05112               tmp[0] = exp10(grads[i]);
05113               tmp[1] = exp10(grads[i+1]);
05114               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
05115 
05116               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
05117                 sciprint("Error allocating tmp_log_grads\n");
05118                 return -1;
05119               }
05120 
05121               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
05122 
05123               for(j=0;j<nbsubtics;j++)
05124               {
05125                 vxx1 = tmp_log_grads[j];
05126 
05127                 if(vxx1<=xminval || vxx1>=xmaxval) continue;
05128 
05129                 if(ppsubwin->axes.reverse[0] == TRUE)
05130                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
05131 
05132                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
05133 
05134                 /*   if ((xm != ixbox[3]) && (xm != ixbox[4])) */
05135                 /*                              {  */
05136                 xg[0]= xm;  yg[0]= ym;  
05137                 if (Ishidden(psubwin))
05138                 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
05139                 else
05140                 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; } 
05141                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05142                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05143                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05144                 xg[0]= xg[1]; yg[0]= yg[1];
05145                 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]=  iybox[0] - iybox[4] +ym;
05146                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05147                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
05148                 /*      } */
05149               }
05150               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
05151             }
05152             else
05153             {
05154               if(xtmp>xminval && xtmp<xmaxval) 
05155               {
05156                 xg[0]= xm;  yg[0]= ym;  
05157                 if (Ishidden(psubwin))
05158                 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
05159                 else
05160                 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; } 
05161                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05162                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05163                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05164                 xg[0]= xg[1]; yg[0]= yg[1];
05165                 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]=  iybox[0] - iybox[4] +ym;
05166                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05167                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
05168               }
05169             }
05170           }
05171 
05172           /* and subtics */
05173           if(i != nbtics-1)
05174           {
05175             if(ppsubwin->logflags[0] =='l')
05176             {
05177               double tmp[2];
05178               double pas=0;
05179               double * tmp_log_grads = (double *) NULL;
05180 
05181 
05182               double * grads = ppsubwin->axes.u_xgrads;
05183 
05184               tmp[0] = exp10(grads[i]);
05185               tmp[1] = exp10(grads[i+1]);
05186               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
05187 
05188               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
05189                 sciprint("Error allocating tmp_log_grads\n");
05190                 return -1;
05191               }
05192 
05193               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
05194 
05195               for(j=0;j<nbsubtics;j++)
05196               {
05197                 vxx1 = tmp_log_grads[j];
05198 
05199                 if(vxx1<xminval || vxx1>xmaxval) continue;
05200 
05201                 if(ppsubwin->axes.reverse[0] == TRUE)
05202                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
05203 
05204                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
05205 
05206                 if (IsDownAxes(psubwin))
05207                 {
05208                   vx[1]=vx[0]=xm;
05209                   vy[0]=ym;
05210                   vy[1]=vy[0]+iof/4;
05211                 }
05212                 else
05213                 {
05214                   vx[0]=xm;vy[0]=ym;
05215                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
05216                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
05217                 }
05218 
05219                 if(ppsubwin->axes.axes_visible[0] == TRUE)
05220                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05221               }
05222 
05223               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
05224             } /* end NEW */
05225             else
05226             {
05227               double xtmp2 = ppsubwin->axes.u_xgrads[i];
05228               double dx = (ppsubwin->axes.u_xgrads[i+1] - ppsubwin->axes.u_xgrads[i]) / nbsubtics;
05229 
05230               for (j=1;j<nbsubtics;j++)
05231               {  
05232                 vxx1=xtmp2+dx*j;
05233 
05234                 if(vxx1<xminval || vxx1>xmaxval) continue;
05235 
05236                 if(ppsubwin->axes.reverse[0] == TRUE)
05237                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
05238 
05239                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
05240                 /*                trans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz); */
05241 
05242 
05243                 if (IsDownAxes(psubwin))
05244                 {
05245                   vx[1]=vx[0]=xm;
05246                   vy[0]=ym;
05247                   vy[1]=vy[0]+iof/4;
05248                 }
05249                 else
05250                 {
05251                   vx[0]=xm;vy[0]=ym;
05252                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
05253                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
05254                 }
05255 
05256                 if(ppsubwin->axes.axes_visible[0] == TRUE)
05257                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05258               }
05259             }
05260           }
05261           /***************************************************************/
05262           /************************* COMMON PART *************************/
05263           /***************************************************************/
05264 
05265 
05266         }
05267 
05268       }
05269       else /* we display the computed tics */
05270       {
05271         AdaptGraduationsOnXBottomLeft(iof,x,y,size,Ticsdir,fontid,psubwin,xminval,xmaxval,0.,fy,fz);
05272 
05273         lastxindex = ppsubwin->axes.nxgrads - 1;
05274 
05275         if(lastxindex == 0)
05276           ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.xgrads[0]));
05277         else
05278           ChoixFormatE(c_format,
05279           ppsubwin->axes.xgrads[0],
05280           ppsubwin->axes.xgrads[lastxindex],
05281           ((ppsubwin->axes.xgrads[lastxindex])-(ppsubwin->axes.xgrads[0]))/(lastxindex));
05282 
05283         nbtics = ppsubwin->axes.nxgrads;
05284         nbsubtics = ppsubwin->axes.nbsubtics[0];
05285 
05286         maxTicksLabelSize[0] = 0 ;
05287         maxTicksLabelSize[1] = 0 ;
05288 
05289         for(i=0;i<nbtics;i++)
05290         {
05291           char foo[256]; 
05292           double xtmp = ppsubwin->axes.xgrads[i];
05293 
05294           if(xtmp<xminval || xtmp>xmaxval) 
05295           {
05296             /*   sciprint("je rejete la valeur: %lf\n\n",xtmp); */
05297             continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
05298             /* donc autant ne pas aller plus loin dans l'algo... */
05299           }
05300 
05301           sprintf(foo,c_format,xtmp);
05302 
05303           /***************************************************************/
05304           /************************* COMMON PART *************************/
05305           /***************************************************************/
05306 
05307           if(ppsubwin->axes.reverse[0] == TRUE)
05308             xtmp = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],xtmp);
05309 
05310           ComputeGoodTrans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz);
05311 
05312           vx[0]=xm;vy[0]=ym;
05313 
05314           barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
05315           barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
05316 
05317           C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
05318 
05319           C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05320           maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
05321           maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
05322 
05323           if (IsDownAxes(psubwin)){
05324             vx[1]=vx[0];
05325             vy[1]=vy[0]+iof/2;
05326             posi[0] = inint(xm-rect[2]/2); 
05327             posi[1]=inint( vy[0] + iof + rect[3]);}
05328           else{
05329             vx[1]=vx[0]+barlengthx;
05330             vy[1]=vy[0]+barlengthy;
05331             posi[0] = inint( xm+2*barlengthx-rect[2]); 
05332             posi[1]=inint( ym + 2*barlengthy + rect[3]);}
05333 
05334           if(ppsubwin->axes.axes_visible[0] == TRUE){
05335             C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05336             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05337             if ( ppsubwin->logflags[0] == 'l' )
05338             {
05339               int smallersize = fontid[1]-2;
05340               int old_rect10[4];
05341               int posi10[2];
05342 
05343               posi10[0] = posi[0] - logrect[2];
05344               posi10[1] = posi[1] + logrect[3];
05345 
05346               C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05347               C2F(dr)("xstring","10",(&posi10[0]),(&posi10[1]),PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
05348 
05349               C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05350 
05351               posi[0] = old_rect10[0] + old_rect10[2];
05352               posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
05353 
05354               C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05355               C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
05356 
05357               /* put back the current fontid */
05358               C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05359             }
05360             else
05361               C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
05362 
05363             C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);   
05364             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05365           }
05366           /* grid to put here */
05367           if ( ppsubwin->grid[0] > -1 && ppsubwin->axes.axes_visible[0] )
05368           {
05369             gstyle = pSUBWIN_FEATURE (psubwin)->grid[0];
05370 
05371             if((ppsubwin->logflags[0] =='l') && (i != nbtics-1))
05372             {
05373               double tmp[2];
05374               double pas=0;
05375               double * tmp_log_grads = (double *) NULL;
05376 
05377 
05378               double * grads = ppsubwin->axes.xgrads;
05379 
05380               tmp[0] = exp10(grads[i]);
05381               tmp[1] = exp10(grads[i+1]);
05382               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
05383 
05384               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
05385                 sciprint("Error allocating tmp_log_grads\n");
05386                 return -1;
05387               }
05388 
05389               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
05390 
05391               for(j=0;j<nbsubtics;j++)
05392               {
05393                 vxx1 = tmp_log_grads[j];
05394 
05395                 if(vxx1<=xminval || vxx1>=xmaxval) continue;
05396 
05397                 if(ppsubwin->axes.reverse[0] == TRUE)
05398                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
05399 
05400                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
05401 
05402 
05403                 xg[0]= xm;  yg[0]= ym;  
05404                 if (Ishidden(psubwin))
05405                 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
05406                 else
05407                 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; } 
05408                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05409                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05410                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05411                 xg[0]= xg[1]; yg[0]= yg[1];
05412                 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]=  iybox[0] - iybox[4] +ym;
05413                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05414                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
05415 
05416               }
05417               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
05418             }
05419             else
05420             {
05421               if(xtmp>xminval && xtmp<xmaxval) 
05422               {
05423                 xg[0]= xm;  yg[0]= ym;  
05424                 if (Ishidden(psubwin))
05425                 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
05426                 else
05427                 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; } 
05428                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05429                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05430                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05431                 xg[0]= xg[1]; yg[0]= yg[1];
05432                 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]=  iybox[0] - iybox[4] +ym;
05433                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05434                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
05435               }
05436             }
05437           }
05438 
05439           /* and subtics */
05440           if(i != nbtics-1)
05441           {
05442             if(ppsubwin->logflags[0] =='l')
05443             {
05444               double tmp[2];
05445               double pas=0;
05446               double * tmp_log_grads = (double *) NULL;
05447 
05448 
05449               double * grads = ppsubwin->axes.xgrads;
05450 
05451               tmp[0] = exp10(grads[i]);
05452               tmp[1] = exp10(grads[i+1]);
05453               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
05454 
05455               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
05456                 sciprint("Error allocating tmp_log_grads\n");
05457                 return -1;
05458               }
05459 
05460               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
05461 
05462               for(j=0;j<nbsubtics;j++)
05463               {
05464                 vxx1 = tmp_log_grads[j];
05465 
05466                 if(vxx1<xminval || vxx1>xmaxval) continue;
05467 
05468                 if(ppsubwin->axes.reverse[0] == TRUE)
05469                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
05470 
05471                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
05472 
05473                 if (IsDownAxes(psubwin))
05474                 {
05475                   vx[1]=vx[0]=xm;
05476                   vy[0]=ym;
05477                   vy[1]=vy[0]+iof/4;
05478                 }
05479                 else
05480                 {
05481                   vx[0]=xm;vy[0]=ym;
05482                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
05483                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
05484                 }
05485 
05486                 if(ppsubwin->axes.axes_visible[0] == TRUE)
05487                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05488               }
05489               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
05490             } /* end NEW */
05491             else
05492             {
05493               double xtmp2 = ppsubwin->axes.xgrads[i];
05494               double dx = (ppsubwin->axes.xgrads[i+1] - ppsubwin->axes.xgrads[i]) / nbsubtics;
05495 
05496               for (j=1;j<nbsubtics;j++)
05497               {  
05498                 vxx1=xtmp2+dx*j;
05499 
05500                 if(vxx1<xminval || vxx1>xmaxval) continue;
05501 
05502                 if(ppsubwin->axes.reverse[0] == TRUE)
05503                   vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
05504 
05505                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
05506                 /*                trans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz); */
05507 
05508 
05509                 if (IsDownAxes(psubwin))
05510                 {
05511                   vx[1]=vx[0]=xm;
05512                   vy[0]=ym;
05513                   vy[1]=vy[0]+iof/4;
05514                 }
05515                 else
05516                 {
05517                   vx[0]=xm;vy[0]=ym;
05518                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
05519                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
05520                 }
05521 
05522                 if(ppsubwin->axes.axes_visible[0] == TRUE)
05523                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05524               }
05525             }
05526           }
05527           /***************************************************************/
05528           /************************* COMMON PART *************************/
05529           /***************************************************************/
05530 
05531         }
05532       }
05533     }
05534 
05535     if ( sciGetVisibility(ppsubwin->mon_x_label) )
05536     { 
05537 
05538       sciLabel * ppLabel = pLABEL_FEATURE(ppsubwin->mon_x_label) ;
05539       if( ppLabel->auto_rotation )
05540       {
05541         sciSetFontOrientation(ppsubwin->mon_x_label, 0 ) ;
05542       }
05543 
05544 
05545       if( ppLabel->auto_position )
05546       {
05547 
05548         int segmentStart[2] = { ixbox[3], iybox[3] } ;
05549         int segmentEnd[2]   = { ixbox[4], iybox[4] } ;
05550 
05551         /* add the bar size and ticks label size to the offset */
05552         int offset[2] = { constOffset[0] + maxTicksLabelSize[0] + abs( barlengthx ), 
05553           constOffset[1] + maxTicksLabelSize[1] + abs( barlengthy )  } ;
05554         computeLabelAutoPos( ppsubwin->mon_x_label, segmentStart, segmentEnd, offset ) ;
05555       }
05556       /* a trick to force the display with 2d scale */
05557       drawTextEntity( ppLabel->text ) ;
05558 
05559     }
05560   }
05561   else 
05562   {
05563     if  (pSUBWIN_FEATURE (psubwin)->project[1]==1) /* y is HERE */
05564     {
05565       double fx,fy,fz;
05566       char c_format[5];
05567 
05568       integer Ticsdir[2];
05569       Ticsdir[0]=ixbox[4]-ixbox[5];
05570       Ticsdir[1]=iybox[4]-iybox[5];
05571       BBoxToval(&fx,&fy,&fz,xind[3],bbox);
05572 
05573       x=inint((ixbox[3]+ixbox[4])/2.0 -rect[2] -iof);
05574       y=inint((1/3.0)*iybox[3]+(2/3.0)*iybox[4]+ iof + 1.5*rect[3]);  
05575 
05576       if(ppsubwin->axes.auto_ticks[1] == FALSE)
05577       {
05578         /* we display the y tics specified by the user*/
05579         nbtics = ppsubwin->axes.u_nygrads;
05580         nbsubtics = ppsubwin->axes.nbsubtics[1];
05581 
05582         maxTicksLabelSize[0] = 0 ;
05583         maxTicksLabelSize[1] = 0 ;
05584 
05585         for(i=0;i<nbtics;i++)
05586         {
05587           char *foo = ppsubwin->axes.u_ylabels[i]; 
05588           double ytmp = ppsubwin->axes.u_ygrads[i];
05589 
05590           if(ytmp<yminval || ytmp>ymaxval) 
05591           {
05592             /*   sciprint("je rejete la valeur: %lf\n\n",xtmp); */
05593             continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
05594             /* donc autant ne pas aller plus loin dans l'algo... */
05595           }
05596 
05597           /***************************************************************/
05598           /************************* COMMON PART *************************/
05599           /***************************************************************/
05600 
05601           if(ppsubwin->axes.reverse[1] == TRUE)
05602             ytmp = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ytmp);
05603 
05604           ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz);
05605           /*              trans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz); */
05606 
05607 
05608           vx[0]=xm;vy[0]=ym; 
05609 
05610           barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
05611           barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
05612 
05613           C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
05614 
05615           C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05616           maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
05617           maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
05618 
05619           if (IsDownAxes(psubwin)){
05620             vx[1]=vx[0];
05621             vy[1]=vy[0]+iof/2;
05622             posi[0] = inint(xm-rect[2]/2); 
05623             posi[1]=inint( vy[0] + iof + rect[3]);}
05624           else{
05625             vx[1]=vx[0]+barlengthx;
05626             vy[1]=vy[0]+barlengthy;
05627             /*              posi[0] = inint( xm+2*barlengthx-rect[2]/2);  */
05628             posi[0] = inint( xm+2*barlengthx-rect[2]); 
05629             posi[1]=inint( ym + 2*barlengthy + rect[3]);}
05630 
05631 
05632           if(ppsubwin->axes.axes_visible[1] == TRUE){
05633             C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05634             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05635             C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
05636             C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);   
05637             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05638           }
05639           /* grid to put here */
05640           if ( ppsubwin->grid[1] > -1 && ppsubwin->axes.axes_visible[1] )
05641           {
05642             gstyle = pSUBWIN_FEATURE (psubwin)->grid[1];
05643 
05644             if((ppsubwin->logflags[1] =='l') && (i != nbtics-1))
05645             {
05646               double tmp[2];
05647               double pas=0;
05648               double * tmp_log_grads = (double *) NULL;
05649 
05650 
05651               double * grads = ppsubwin->axes.u_ygrads;
05652 
05653               tmp[0] = exp10(grads[i]);
05654               tmp[1] = exp10(grads[i+1]);
05655               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
05656 
05657               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
05658                 sciprint("Error allocating tmp_log_grads\n");
05659                 return -1;
05660               }
05661 
05662               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
05663 
05664               for(j=0;j<nbsubtics;j++)
05665               {
05666                 vyy1 = tmp_log_grads[j];
05667 
05668                 if(vyy1<=yminval || vyy1>=ymaxval) continue;
05669 
05670                 if(ppsubwin->axes.reverse[1] == TRUE)
05671                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
05672 
05673                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
05674 
05675                 /*   if ((xm != ixbox[3]) && (xm != ixbox[4])) */
05676                 /*                              { */ 
05677                 xg[0]= xm;  yg[0]= ym;  
05678                 if (Ishidden(psubwin))
05679                 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
05680                 else
05681                 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; } 
05682                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05683                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05684                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05685                 xg[0]= xg[1]; yg[0]= yg[1];
05686                 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]=  iybox[0] - iybox[4] +ym;
05687                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05688                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
05689                 /*      } */
05690               }
05691               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
05692             }
05693             else
05694             {
05695               if(ytmp>yminval && ytmp<ymaxval) 
05696               {
05697                 xg[0]= xm;  yg[0]= ym;  
05698                 if (Ishidden(psubwin))
05699                 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
05700                 else
05701                 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; } 
05702                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05703                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05704                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05705                 xg[0]= xg[1]; yg[0]= yg[1];
05706                 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]=  iybox[0] - iybox[4] +ym;
05707                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05708                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
05709               }
05710             }
05711           }
05712 
05713           /* and subtics */
05714           if(i != nbtics-1)
05715           {
05716             if(ppsubwin->logflags[1] =='l')
05717             {
05718               double tmp[2];
05719               double pas=0;
05720               double * tmp_log_grads = (double *) NULL;
05721 
05722 
05723               double * grads = ppsubwin->axes.u_ygrads;
05724 
05725               tmp[0] = exp10(grads[i]);
05726               tmp[1] = exp10(grads[i+1]);
05727               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
05728 
05729               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
05730                 sciprint("Error allocating tmp_log_grads\n");
05731                 return -1;
05732               }
05733 
05734               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
05735 
05736               for(j=0;j<nbsubtics;j++)
05737               {
05738                 vyy1 = tmp_log_grads[j];
05739 
05740                 if(vyy1<yminval || vyy1>ymaxval) continue;
05741 
05742                 if(ppsubwin->axes.reverse[1] == TRUE)
05743                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
05744 
05745                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
05746 
05747                 if (IsDownAxes(psubwin))
05748                 {
05749                   vx[1]=vx[0]=xm;
05750                   vy[0]=ym;
05751                   vy[1]=vy[0]+iof/4;
05752                 }
05753                 else
05754                 {
05755                   vx[0]=xm;vy[0]=ym;
05756                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
05757                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
05758                 }
05759 
05760                 if(ppsubwin->axes.axes_visible[1] == TRUE)
05761                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05762               }
05763               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
05764 
05765             } /* end NEW */
05766             else
05767             {
05768 
05769               double ytmp2 = ppsubwin->axes.u_ygrads[i];
05770               double dy = (ppsubwin->axes.u_ygrads[i+1] - ppsubwin->axes.u_ygrads[i]) / nbsubtics;
05771               for(j=0;j<nbsubtics;j++)
05772               {
05773                 vyy1=ytmp2+dy*j;
05774 
05775                 if(vyy1<yminval || vyy1>ymaxval) continue;
05776 
05777                 if(ppsubwin->axes.reverse[1] == TRUE)
05778                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
05779 
05780                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
05781                 /*                trans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz); */
05782 
05783 
05784                 if (IsDownAxes(psubwin))
05785                 {
05786                   vx[1]=vx[0]=xm;
05787                   vy[0]=ym;
05788                   vy[1]=vy[0]+iof/4;
05789                 }
05790                 else
05791                 {
05792                   vx[0]=xm;vy[0]=ym;
05793                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
05794                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
05795                 }
05796 
05797                 if(ppsubwin->axes.axes_visible[1] == TRUE)
05798                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05799               }
05800             }
05801           }
05802           /***************************************************************/
05803           /************************* COMMON PART *************************/
05804           /***************************************************************/
05805 
05806         }
05807       }
05808       else /* we display the computed tics */
05809       {
05810         AdaptGraduationsOnYBottomLeft(iof,x,y,size,Ticsdir,fontid,psubwin,yminval,ymaxval,fx,0.,fz);
05811 
05812         lastyindex = ppsubwin->axes.nygrads - 1;
05813 
05814         if(lastyindex == 0)
05815           ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.ygrads[0]));
05816         else
05817           ChoixFormatE(c_format,
05818           ppsubwin->axes.ygrads[0],
05819           ppsubwin->axes.ygrads[lastyindex],
05820           ((ppsubwin->axes.ygrads[lastyindex])-(ppsubwin->axes.ygrads[0]))/(lastyindex));
05821 
05822         nbtics = ppsubwin->axes.nygrads;
05823         nbsubtics = ppsubwin->axes.nbsubtics[1];
05824 
05825         maxTicksLabelSize[0] = 0 ;
05826         maxTicksLabelSize[1] = 0 ;
05827 
05828         for(i=0;i<nbtics;i++)
05829         {
05830           char foo[256]; 
05831           double ytmp = ppsubwin->axes.ygrads[i];
05832 
05833           if(ytmp<yminval || ytmp>ymaxval) 
05834           {
05835             /*   sciprint("je rejete la valeur: %lf\n\n",xtmp); */
05836             continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
05837             /* donc autant ne pas aller plus loin dans l'algo... */
05838           }
05839 
05840           sprintf(foo,c_format,ytmp);
05841 
05842           /***************************************************************/
05843           /************************* COMMON PART *************************/
05844           /***************************************************************/
05845 
05846           if(ppsubwin->axes.reverse[1] == TRUE)
05847             ytmp = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ytmp);
05848 
05849           ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz);
05850           /*              trans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz); */
05851 
05852 
05853           vx[0]=xm;vy[0]=ym; 
05854 
05855           barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
05856           barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
05857 
05858           C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
05859 
05860           C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05861           maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
05862           maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
05863 
05864           if (IsDownAxes(psubwin)){
05865             vx[1]=vx[0];
05866             vy[1]=vy[0]+iof/2;
05867             posi[0] = inint(xm-rect[2]/2); 
05868             posi[1]=inint( vy[0] + iof + rect[3]);}
05869           else{
05870             vx[1]=vx[0]+barlengthx;
05871             vy[1]=vy[0]+barlengthy;
05872             /*              posi[0] = inint( xm+2*barlengthx-rect[2]/2);  */
05873             posi[0] = inint( xm+2*barlengthx-rect[2]); 
05874             posi[1]=inint( ym + 2*barlengthy + rect[3]);}
05875 
05876           if(ppsubwin->axes.axes_visible[1] == TRUE){
05877             C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05878             C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05879             if ( ppsubwin->logflags[1] == 'l' )
05880             {
05881               int smallersize = fontid[1]-2;
05882               int old_rect10[4];
05883               /*                    char str[2] = "xv"; */
05884               int posi10[2];
05885 
05886               posi10[0] = posi[0] - logrect[2];
05887               posi10[1] = posi[1] + logrect[3];
05888 
05889               C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05890               C2F(dr)("xstring","10",(&posi10[0]),(&posi10[1]),PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
05891 
05892               C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05893 
05894               posi[0] = old_rect10[0] + old_rect10[2];
05895               posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
05896 
05897               C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05898               C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
05899 
05900               /* put back the current fontid */
05901               C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05902             }
05903             else
05904               C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
05905 
05906             C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);   
05907             C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05908           }
05909           /* grid to put here */
05910           if ( ppsubwin->grid[1] > -1 && ppsubwin->axes.axes_visible[1] )
05911           {
05912             gstyle = pSUBWIN_FEATURE (psubwin)->grid[1];
05913 
05914             if((ppsubwin->logflags[1] =='l') && (i != nbtics-1))
05915             {
05916               double tmp[2];
05917               double pas=0;
05918               double * tmp_log_grads = (double *) NULL;
05919 
05920 
05921               double * grads = ppsubwin->axes.ygrads;
05922 
05923               tmp[0] = exp10(grads[i]);
05924               tmp[1] = exp10(grads[i+1]);
05925               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
05926 
05927               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
05928                 sciprint("Error allocating tmp_log_grads\n");
05929                 return -1;
05930               }
05931 
05932               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
05933 
05934               for(j=0;j<nbsubtics;j++)
05935               {
05936                 vyy1 = tmp_log_grads[j];
05937 
05938                 if(vyy1<=yminval || vyy1>=ymaxval) continue;
05939 
05940                 if(ppsubwin->axes.reverse[1] == TRUE)
05941                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
05942 
05943                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
05944 
05945                 /*    if ((xm != ixbox[3]) && (xm != ixbox[4])) */
05946                 /*                              {  */
05947                 xg[0]= xm;  yg[0]= ym;  
05948                 if (Ishidden(psubwin))
05949                 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
05950                 else
05951                 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; } 
05952                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05953                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05954                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05955                 xg[0]= xg[1]; yg[0]= yg[1];
05956                 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]=  iybox[0] - iybox[4] +ym;
05957                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05958                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
05959                 /*      } */
05960               }
05961               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
05962             }
05963             else
05964             {
05965               if(ytmp>yminval && ytmp<ymaxval) 
05966               {
05967                 xg[0]= xm;  yg[0]= ym;  
05968                 if (Ishidden(psubwin))
05969                 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
05970                 else
05971                 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; } 
05972                 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05973                 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
05974                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05975                 xg[0]= xg[1]; yg[0]= yg[1];
05976                 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]=  iybox[0] - iybox[4] +ym;
05977                 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
05978                 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);  
05979               }
05980             }
05981           }
05982 
05983           /* and subtics */
05984           if(i != nbtics-1)
05985           {
05986             if(ppsubwin->logflags[1] =='l')
05987             {
05988               double tmp[2];
05989               double pas=0;
05990               double * tmp_log_grads = (double *) NULL;
05991 
05992 
05993               double * grads = ppsubwin->axes.ygrads;
05994 
05995               tmp[0] = exp10(grads[i]);
05996               tmp[1] = exp10(grads[i+1]);
05997               pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
05998 
05999               if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
06000                 sciprint("Error allocating tmp_log_grads\n");
06001                 return -1;
06002               }
06003 
06004               for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
06005 
06006               for(j=0;j<nbsubtics;j++)
06007               {
06008                 vyy1 = tmp_log_grads[j];
06009 
06010                 if(vyy1<yminval || vyy1>ymaxval) continue;
06011 
06012                 if(ppsubwin->axes.reverse[1] == TRUE)
06013                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
06014 
06015                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
06016 
06017                 if (IsDownAxes(psubwin))
06018                 {
06019                   vx[1]=vx[0]=xm;
06020                   vy[0]=ym;
06021                   vy[1]=vy[0]+iof/4;
06022                 }
06023                 else
06024                 {
06025                   vx[0]=xm;vy[0]=ym;
06026                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
06027                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
06028                 }
06029 
06030                 if(ppsubwin->axes.axes_visible[1] == TRUE)
06031                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
06032               }
06033               FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
06034 
06035             } /* end NEW */
06036             else
06037             {
06038 
06039               double ytmp2 = ppsubwin->axes.ygrads[i];
06040               double dy = (ppsubwin->axes.ygrads[i+1] - ppsubwin->axes.ygrads[i]) / nbsubtics;
06041               for(j=0;j<nbsubtics;j++)
06042               {
06043                 vyy1=ytmp2+dy*j;
06044 
06045                 if(vyy1<yminval || vyy1>ymaxval) continue;
06046 
06047                 if(ppsubwin->axes.reverse[1] == TRUE)
06048                   vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
06049 
06050                 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
06051 
06052                 if (IsDownAxes(psubwin))
06053                 {
06054                   vx[1]=vx[0]=xm;
06055                   vy[0]=ym;
06056                   vy[1]=vy[0]+iof/4;
06057                 }
06058                 else
06059                 {
06060                   vx[0]=xm;vy[0]=ym;
06061                   vx[1]= (integer) (vx[0]+barlengthx/2.0);
06062                   vy[1]= (integer) (vy[0]+barlengthy/2.0);
06063                 }
06064 
06065                 if(ppsubwin->axes.axes_visible[1] == TRUE)
06066                   C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
06067               }
06068             }
06069           }
06070 
06071           /***************************************************************/
06072           /************************* COMMON PART *************************/
06073           /***************************************************************/
06074         }
06075       }
06076     }
06077 
06078     if ( sciGetVisibility(ppsubwin->mon_y_label) )
06079     {  
06080       sciLabel * ppLabel =  pLABEL_FEATURE(ppsubwin->mon_y_label) ;
06081       if( ppLabel->auto_rotation )
06082       {
06083         sciSetFontOrientation(ppsubwin->mon_y_label, 0 ) ;
06084       }
06085 
06086       if( ppLabel->auto_position )
06087       {
06088 
06089         int segmentStart[2] = { ixbox[3], iybox[3] } ;
06090         int segmentEnd[2]   = { ixbox[4], iybox[4] } ;
06091 
06092         /* add the bar size and ticks label size to the offset */
06093         int offset[2] = { constOffset[0] + maxTicksLabelSize[0] + abs( barlengthx ), 
06094           constOffset[1] + maxTicksLabelSize[1] + abs( barlengthy )  } ;
06095         computeLabelAutoPos( ppsubwin->mon_y_label, segmentStart, segmentEnd, offset ) ;
06096       }
06097       /* a trick to force the display with 2d scale */
06098       drawTextEntity( ppLabel->text ) ;
06099 
06100     }
06101   }
06102   /* reset font to its current size & to current color*/ 
06103   if ( fontsize != -1 ){
06104     fontid[1] = fontsize_kp;
06105     C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
06106   }
06107   if ( textcolor != -1 || ticscolor != -1 ) 
06108     C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
06109   /***/
06110   /* FREE(loc); */
06111 
06112 
06113   return 0;
06114 }
06115 /*-----------------------------------------------------------------------------------------*/

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