Plo2dEch.c

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *    Graphic library
00003  *    Copyright (C) 1998-2000 Enpc
00004  *    Copyright INRIA 2006
00005  *    Authors Jean-Philippe Chancelier 1998-2000 jpc@cereve.enpc.fr 
00006  *            Jean-Baptiste Silvy      2005-xxxx
00007  --------------------------------------------------------------------------*/
00008 
00009 #include <string.h> /* in case of dbmalloc use */
00010 #include <stdio.h>
00011 #include <math.h>
00012 #include "math_graphics.h" 
00013 #include "PloEch.h"
00014 
00015 #include "GetProperty.h"
00016 #include "SetProperty.h"
00017 #include "BuildObjects.h"
00018 #include "Interaction.h"
00019 #include "DrawObjects.h"
00020 #include "Xcall1.h"
00021 #include "Plo2dEch.h"
00022 #include "Vertices.h"
00023 #include "GraphicZoom.h"
00024 #include "axesScale.h"
00025 #include "sciprint.h"
00026 #include "periScreen.h"
00027 #include "Format.h"
00028 #include "scirun.h"
00029 #include "CurrentObjectsManagement.h"
00030 
00031 #include "MALLOC.h" /* MALLOC */
00032 
00033 extern void xgetmouse2(char *fname, char *str, integer *ibutton, integer *iflag, integer *x1, integer *yy1, integer *x6, integer *x7, double *x, double *y, double *dx3, double *dx4, integer lx0, integer lx1);
00034 extern void xclick_2(char *fname, char *str, integer *ibutton, integer *iflag, integer *istr, integer *x1, integer *yy1, integer *x7, double *x, double *y, double *dx3, double *dx4, integer lx0, integer lx1);
00035 extern int StoreCommand( char *command);
00036 
00037 /*----------------------------------------------
00038  * A List for storing Window scaling information 
00039  *----------------------------------------------*/
00040 
00041 static void scale_copy __PARAMS((WCScaleList *s1, WCScaleList *s2));
00042 static integer curwin __PARAMS((void));
00043 static void zoom_rect2(int xpix_ini, int ypix_ini, int xpix_fin, int ypix_fin);
00044 static void set_scale_win __PARAMS((ScaleList **listptr, integer i, WCScaleList *s));
00045 static WCScaleList *new_wcscale __PARAMS(( WCScaleList *val));
00046 static WCScaleList *check_subwin_wcscale __PARAMS((WCScaleList *listptr, double *));
00047 static int same_subwin __PARAMS((double lsubwin_rect[4],double subwin_rect[4]));
00048 static void set_window_scale __PARAMS((integer i,WCScaleList  *scale));
00049 
00050 /* The scale List : one for each graphic window */
00051 
00052 static ScaleList *The_List = NULL;
00053 
00054 /* Current Scale */
00055 
00056 WCScaleList  Cscale = 
00057   { 
00058     0,
00059     {600,400},
00060     {0.0,0.0,1.0,1.0},
00061     {0.0,0.0,1.0,1.0},
00062     {1/8.0,1/8.0,1/8.0,1/8.0},
00063     {0.0,1.0,0.0,10},
00064     {0.0,1.0,0.0,10},
00065     75.0,53.0,450.0,318.0,
00066     {'n','n'},
00067     {75,53,450,318},
00068     {2,10,2,10},
00069     {{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}},
00070     {0.0,1.0,0.0,1.0,0.0,1.0},
00071     35.0,45.0,
00072     1,                 /* added by es */
00073     (WCScaleList *) 0, /*unused */
00074     (WCScaleList *) 0  /*unused */  
00075   };
00076 
00079 WCScaleList  Defscale = 
00080   { 
00081     0,
00082     {600,400},
00083     {0.0,0.0,1.0,1.0},
00084     {0.0,0.0,1.0,1.0},
00085     {1/8.0,1/8.0,1/8.0,1/8.0},
00086     {0.0,1.0,0.0,10},
00087     {0.0,1.0,0.0,10},
00088     75.0,53.0,450.0,318.0,
00089     {'n','n'},
00090     {75,53,450,318},
00091     {2,10,2,10},
00092     {{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}},
00093     {0.0,1.0,0.0,1.0,0.0,1.0},
00094     35.0,45.0,
00095     1,                 /* added by es */
00096     (WCScaleList *) 0, /*unused */
00097     (WCScaleList *) 0 /*unused */  
00098   };
00099 
00100 /*----------------------------------------------------------
00101  * Back to defaults values : fills current scale (Scale)
00102  * and curwin() scale with default scale.
00103  *----------------------------------------------------------*/
00104 
00105 void Cscale2default( void )
00106 {
00107   scale_copy(&Cscale,&Defscale);  set_window_scale(curwin(),&Cscale);
00108 }
00109 
00110 void set_window_scale_with_default( int i ) { set_window_scale(i,&Defscale);} 
00111 
00112 /*------------------------------------------------------------
00113  * void get_window_scale(i,subwin)
00114  *   if subwin == NULL : search for existing scale values of window i.
00115  *   if subwin != NULL : search for existing scale values of subwindow subwin of window i.
00116  *   If no scale are found we do nothing and return 0
00117  *   else the scale is copied into current scale Cscale ans we return 1.
00118  *   
00119  *-------------------------------------------------------------*/
00120 
00121 static int get_scale_win __PARAMS((ScaleList *listptr, integer wi, double *subwin));
00122 
00123 int get_window_scale( integer i, double * subwin )
00124 { 
00125   return get_scale_win(The_List,Max(0L,i),subwin);
00126 }
00127 
00128 static int get_scale_win(listptr, wi,subwin)
00129      ScaleList *listptr;
00130      integer wi;
00131      double *subwin;                                                          
00132 {
00133   if (listptr != (ScaleList  *) NULL)
00134     { 
00135       if ((listptr->Win) == wi)
00136         { 
00137           if ( subwin == NULL) 
00138             {
00139               scale_copy(&Cscale,listptr->scales);
00140               return 1;
00141             }
00142           else
00143             {
00144               WCScaleList *loc = check_subwin_wcscale(listptr->scales,subwin);
00145               if ( loc != NULL) 
00146                 {
00147                   scale_copy(&Cscale,loc);
00148                   return 1;
00149                 }
00150               else 
00151                 {
00152                   return 0;
00153                 }
00154             }
00155         }
00156       else 
00157         return get_scale_win(listptr->next,wi,subwin);
00158     }
00159   return 0;
00160 }
00161 
00162 /*------------------------------------------------------------
00163  * void set_window_scale(i,scale)
00164  * add the current scale at the begining of window i scale list 
00165  * (which is also modified) making Cscale the current scale of window i 
00166  *-------------------------------------------------------------*/
00167 
00168 static void set_window_scale(i,scale)
00169      integer i;
00170      WCScaleList  *scale;
00171 { 
00172   set_scale_win(&The_List,Max(0L,i),scale);
00173 }
00174 
00175 static void set_scale_win(listptr, i,scale)
00176      ScaleList **listptr;
00177      integer i;
00178      WCScaleList *scale;
00179 {
00180   if ( *listptr == (ScaleList  *) NULL)
00181     {
00182       /* window i does not exist add an entry for it */
00183       if ((*listptr = (ScaleList *) MALLOC( sizeof (ScaleList)))==0)
00184         {
00185           sciprint("AddWindowScale_ memory exhausted\n");
00186           return;
00187         }
00188       else 
00189         { 
00190           (*listptr)->Win  = i;
00191           (*listptr)->next = (ScaleList *) NULL ;
00192           (*listptr)->scales = new_wcscale(scale);
00193           if ( (*listptr)->scales == 0) 
00194             {
00195               *listptr = 0;
00196               sciprint("AddWindowScale_ memory exhausted\n");
00197             }
00198           return ;
00199         }
00200     }
00201   if ( (*listptr)->Win == i) 
00202     { 
00203       /* try to find a scale for Cscale.subwin_rect for window i */
00204       WCScaleList *loc = check_subwin_wcscale((*listptr)->scales,scale->subwin_rect); 
00205       if ( loc != NULL) 
00206         {
00207           /* subwin exists we update it */
00208           scale_copy(loc,scale);
00209           /* we move loc to the top of the list */
00210           if ( loc != (*listptr)->scales )
00211             {
00212               (loc->prev)->next = loc->next ;
00213               if ( loc->next != NULL) (loc->next)->prev = loc->prev ;
00214               loc->next = (*listptr)->scales;
00215               loc->next->prev = loc ;
00216               (*listptr)->scales = loc;
00217             }
00218         }
00219       else 
00220         {
00221           /* subwin does not exists we add it a the begining of the list */
00222           if (( loc = new_wcscale(scale))== NULL)
00223             {
00224               sciprint("AddWindowScale_ memory exhausted\n");
00225               return ;
00226             }
00227           else 
00228             {
00229               loc->next = (*listptr)->scales;
00230               if (loc->next != NULL) loc->next->prev = loc;
00231               (*listptr)->scales = loc;
00232             }
00233         }
00234     }
00235   else 
00236     set_scale_win( &((*listptr)->next),i,scale);
00237 }
00238  
00239 static WCScaleList *new_wcscale(val) 
00240      WCScaleList *val;
00241 {
00242   WCScaleList *new ;
00243   if ((new = (WCScaleList *) MALLOC( sizeof (WCScaleList))) == NULL) 
00244     return NULL;
00245   new->next = (WCScaleList *) 0;
00246   new->prev = (WCScaleList *) 0;
00247   scale_copy(new,val);
00248   return new;
00249 }
00250 
00251 static WCScaleList *check_subwin_wcscale(listptr,subwin_rect)
00252      WCScaleList *listptr;
00253      double subwin_rect[4];
00254 {
00255   if ( listptr == (WCScaleList  *) NULL)  return NULL;
00256   if ( same_subwin( listptr->subwin_rect,subwin_rect)) 
00257     return listptr;
00258   else 
00259     return check_subwin_wcscale(listptr->next,subwin_rect);
00260 }
00261 
00262 static int same_subwin( lsubwin_rect,subwin_rect)
00263      double lsubwin_rect[4],subwin_rect[4];
00264 {
00265   if ( Abs(lsubwin_rect[0] - subwin_rect[0]) < 1.e-8
00266        && Abs(lsubwin_rect[1] - subwin_rect[1]) < 1.e-8
00267        && Abs(lsubwin_rect[2] - subwin_rect[2]) < 1.e-8
00268        && Abs(lsubwin_rect[3] - subwin_rect[3]) < 1.e-8 ) 
00269     return 1;
00270   else 
00271     return 0;
00272 }
00273 
00274 /*------------------------------------------------------------
00275  * del_window_scale(i)
00276  * delete the scales associated to window i 
00277  *-------------------------------------------------------------*/
00278 
00279 static void DeleteWCScale __PARAMS((WCScaleList *l));
00280 
00281 void del_window_scale( integer i )
00282 { 
00283   ScaleList *loc, *loc1;
00284   /* check head of The_List */
00285   if ( The_List == NULL) return ;
00286   if ( The_List->Win == i) 
00287     {
00288       loc1= The_List ; 
00289       The_List = The_List->next;
00290       DeleteWCScale(loc1->scales);
00291       FREE(loc1);
00292       return;
00293     }
00294   loc1= The_List;
00295   loc = The_List->next;
00296   while ( loc != NULL) 
00297     {
00298       if ( loc->Win == i ) 
00299         {
00300           loc1->next = loc->next;
00301           DeleteWCScale(loc->scales);
00302           FREE(loc);
00303           return ;
00304         }
00305       else
00306         {
00307           loc1 = loc;
00308           loc  = loc->next;
00309         }
00310     }
00311 }
00312 
00313 static void DeleteWCScale(l) 
00314      WCScaleList *l;
00315 {
00316   if ( l != NULL) 
00317     {
00318       DeleteWCScale(l->next);
00319       FREE(l);
00320     }
00321 }
00322 
00323 /*-------------------------------------------
00324  * static void scale_copy(s1,s2) : s1=s2 
00325  * (only necessary for non ansi C compilers) 
00326  *-------------------------------------------*/
00327 
00328 static void scale_copy( WCScaleList * s1, WCScaleList * s2 ) 
00329 {
00330   int i,j;
00331   s1->flag=s2->flag;
00332   s1->wdim[0]=  s2->wdim[0];
00333   s1->wdim[1]=  s2->wdim[1];
00334   for ( i = 0 ; i < 4 ; i++ ) 
00335   {
00336     s1->subwin_rect[i]=s2->subwin_rect[i];
00337     s1->frect[i]=s2->frect[i];
00338     s1->WIRect1[i]=s2->WIRect1[i];
00339     s1->Waaint1[i]=s2->Waaint1[i];
00340     s1->xtics[i]=s2->xtics[i];
00341     s1->ytics[i]=s2->ytics[i];
00342     s1->axis[i]=s2->axis[i];
00343   }
00344   for ( i = 0 ; i < 3 ; i++ )
00345   {
00346     for ( j = 0 ; j < 3 ; j++ )
00347     {
00348       s1->m[i][j] = s2->m[i][j] ;
00349     }
00350   }
00351   for (i=0; i< 6; i++ )
00352   {
00353     s1->bbox1[i] = s2->bbox1[i] ;
00354   }
00355   s1->Wxofset1=s2->Wxofset1;
00356   s1->Wyofset1=s2->Wyofset1;
00357   s1->Wscx1=s2->Wscx1;
00358   s1->Wscy1=s2->Wscy1;
00359   s1->logflag[0] = s2->logflag[0];
00360   s1->logflag[1] = s2->logflag[1];
00361 }
00362 
00363 /*-------------------------------------------
00364  * return current window : ok if driver is Rec
00365  *-------------------------------------------*/
00366 
00367 static integer curwin( void )
00368 {
00369   integer verbose=0,narg,winnum;
00370   C2F(dr)("xget","window",&verbose,&winnum,&narg ,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00371   return(winnum);
00372 }
00373 
00374 /*-------------------------------------------
00375  * show the recorded scales 
00376  *-------------------------------------------*/
00377 
00378 static void show_scales __PARAMS((ScaleList *listptr));
00379 
00380 void ShowScales( void )
00381 { 
00382   sciprint("-----------scales-------------\r\n");
00383   show_scales(The_List);
00384   sciprint("----------current scale-------\r\n");
00385   sciprint("\tsubwin=[%5.2f,%5.2f,%5.2f,%5.2f], flag=%d\r\n",
00386            Cscale.subwin_rect[0],Cscale.subwin_rect[1],Cscale.subwin_rect[2],Cscale.subwin_rect[3],
00387            Cscale.flag);
00388   sciprint("-----------end----------------\r\n");
00389 }
00390 
00391 static void show_scales(listptr)
00392      ScaleList *listptr;
00393 {
00394   if (listptr != (ScaleList  *) NULL)
00395     { 
00396       WCScaleList *loc = listptr->scales;
00397       sciprint("Window %d \r\n",listptr->Win);
00398       while ( loc != NULL) 
00399         {
00400           sciprint("\tsubwin=[%5.2f,%5.2f,%5.2f,%5.2f], flag=%d\r\n",
00401                    loc->subwin_rect[0],loc->subwin_rect[1],loc->subwin_rect[2],loc->subwin_rect[3],
00402                    loc->flag);
00403           loc = loc->next ;
00404         }
00405       show_scales(listptr->next);
00406     }
00407 }
00408 
00409 
00410 /*-------------------------------------------
00411  * setscale2d 
00412  * uses WRect,FRect,logscale to update 
00413  * current scale (Cscale) 
00414  *  WRect gives the subwindow to use 
00415  *  FRect gives the bounds 
00416  *  WRect=[<x-upperleft>,<y-upperleft>,largeur,hauteur]
00417  *    example WRect=[0,0,1.0,1.0] we use all the window 
00418  *            WRect=[0.5,0.5,0.5,0.5] we use the down right 
00419  *            quarter of the window 
00420  *-------------------------------------------*/
00421 
00422 int C2F(setscale2d)(WRect,FRect,logscale,l1)
00423      double FRect[4], WRect[4];
00424      char *logscale;
00425      integer l1;
00426 {
00427   static integer aaint[]={2,10,2,10};
00428   if (logscale[0]=='l') 
00429     {
00430       FRect[0]=log10(FRect[0]);
00431       FRect[2]=log10(FRect[2]);
00432     }
00433   if (logscale[1]=='l') 
00434     {
00435       FRect[1]=log10(FRect[1]);
00436       FRect[3]=log10(FRect[3]);
00437     }
00438   set_scale("tttftf",WRect,FRect,aaint,logscale,NULL);
00439   return(0);
00440 }
00441 
00442 
00443 /*-------------------------------------------
00444  * setscale2d 
00445  * uses WRect,ARect,FRect,logscale to update 
00446  * current scale (Cscale) 
00447  *  WRect gives the subwindow to use 
00448  *  ARect gives the axis rectangle 
00449  *  FRect gives the bounds 
00450  *  WRect=[<x-upperleft>,<y-upperleft>,largeur,hauteur]
00451  *    example WRect=[0,0,1.0,1.0] we use all the window 
00452  *            WRect=[0.5,0.5,0.5,0.5] we use the down right 
00453  *            quarter of the window
00454  *  logscale : gives xy log axis flags 
00455  *  each argument can be a null pointer if they are 
00456  *  not to be changed from their current value 
00457  * 
00458  *  Each window can have a set of scales : one for each specified 
00459  *  subwindow. This routine must take care of properly 
00460  *  switching from one scale to an other.
00461  *  
00462  *-------------------------------------------*/
00463 
00464 int C2F(Nsetscale2d)( double    WRect[4],
00465                       double    ARect[4],
00466                       double    FRect[4],
00467                       char    * logscale,
00468                       integer   l1       )
00469 {
00470   /* if some arguments are null pointer we set them to 
00471    * the corresponding Cscale value. 
00472    * this is only important for StoreNEch which do not work with null arguments 
00473    */ 
00474   /* char flag[] = "tfffff";*/ /* flag to specify which arguments have changed*/
00475   /* 14/03/2002*/
00476   sciPointObj *masousfen;
00477         
00478   char flag[7];
00479   strcpy(flag,"tfffff");  
00480  
00482   if ( WRect != NULL) 
00483     {
00484       /* Ajout djalel */
00485     
00486       if (( masousfen = sciIsExistingSubWin (WRect)) != (sciPointObj *)NULL)
00487         sciSetSelectedSubWin(masousfen);
00488       else if ((masousfen = ConstructSubWin (sciGetCurrentFigure(), 0)) != NULL)
00489       {
00490         /* F.Leray Adding here 26.03.04*/
00491         sciSetCurrentObj(masousfen);
00492         sciSetSelectedSubWin(masousfen);
00493         pSUBWIN_FEATURE (masousfen)->WRect[0]   = WRect[0];
00494         pSUBWIN_FEATURE (masousfen)->WRect[1]   = WRect[1];
00495         pSUBWIN_FEATURE (masousfen)->WRect[2]   = WRect[2];
00496         pSUBWIN_FEATURE (masousfen)->WRect[3]   = WRect[3];
00497       }
00498       
00499       /* a subwindow is specified */
00500       flag[1]='t';
00501       if (! same_subwin( WRect, Cscale.subwin_rect))
00502         {
00503           /* we are using a new subwin we keep current state 
00504            * in scale list 
00505            */
00506           set_window_scale(curwin(),&Cscale);
00507           /* now we try to extract a previous scale with WRect as subwin 
00508            * which becomes the new Cscale if it is found 
00509            */
00510           if ( get_window_scale(curwin(),WRect) == 0 ) 
00511             {
00512               /* this is the first time WRect is used : we reset Cscale flag
00513                * Note also that if FRect is also specified in this call 
00514                * Cscale.flag will be set to 1 bellow 
00515                */
00516               Cscale.flag = 0;
00517             }
00518         }
00519     }
00520   else WRect = Cscale.subwin_rect; 
00521   if (FRect != NULL)
00522   {
00523     masousfen=sciGetCurrentSubWin();
00524     pSUBWIN_FEATURE (masousfen)->SRect[0]   = FRect[0];
00525     pSUBWIN_FEATURE (masousfen)->SRect[2]   = FRect[1];
00526     pSUBWIN_FEATURE (masousfen)->SRect[1]   = FRect[2];
00527     pSUBWIN_FEATURE (masousfen)->SRect[3]   = FRect[3];
00528   }
00529   if ( FRect != NULL) flag[2]='t'; else FRect = Cscale.frect;
00530 
00531 
00532   if (ARect != NULL)
00533   {
00534     masousfen=sciGetCurrentSubWin();
00535     pSUBWIN_FEATURE (masousfen)->ARect[0]   = ARect[0];
00536     pSUBWIN_FEATURE (masousfen)->ARect[1]   = ARect[1];
00537     pSUBWIN_FEATURE (masousfen)->ARect[2]   = ARect[2];
00538     pSUBWIN_FEATURE (masousfen)->ARect[3]   = ARect[3];
00539   }
00540 
00541   if ( ARect != NULL) flag[5]='t'; else ARect = Cscale.axis;
00542   if ( logscale != NULL) flag[4] ='t'; else logscale = Cscale.logflag;
00543   if ( flag[4] == 't' && flag[2] == 't' ) 
00544     {
00545       if (logscale[0]=='l') 
00546         {
00547           if ( FRect[0] <= 0 || FRect[2] <= 0 ) 
00548             {
00549               sciprint("Warning: negative boundaries on x scale with a log scale \n");
00550               FRect[0]=1.e-8;FRect[2]=1.e+8;
00551             } 
00552           FRect[0]=log10(FRect[0]);
00553           FRect[2]=log10(FRect[2]);
00554         }
00555       if (logscale[1]=='l') 
00556         {
00557           if ( FRect[1] <= 0 || FRect[3] <= 0 ) 
00558             {
00559               sciprint("Warning: negative boundaries on y scale with a log scale \n");
00560               FRect[1]=1.e-8;FRect[3]=1.e+8;
00561             } 
00562           FRect[1]=log10(FRect[1]);
00563           FRect[3]=log10(FRect[3]);
00564         }
00565     }
00566   set_scale(flag,WRect,FRect,NULL,logscale,ARect);  
00567   return(0);
00568 }
00569 
00570 /* used to send values to Scilab */
00571 int getscale2d( double WRect[4], double FRect[4], char * logscale, double ARect[4] )
00572 {
00573   integer i;
00574   static double ten=10.0;
00575   logscale[0] = Cscale.logflag[0];
00576   logscale[1] = Cscale.logflag[1];
00577   for ( i=0; i < 4 ; i++) 
00578     {
00579       WRect[i]=Cscale.subwin_rect[i];
00580       FRect[i]=Cscale.frect[i];
00581       ARect[i]=Cscale.axis[i];
00582     }
00583   if (logscale[0]=='l') 
00584     { 
00585       FRect[0]=pow(ten,FRect[0]);
00586       FRect[2]=pow(ten,FRect[2]);
00587     }
00588   if (logscale[1]=='l') 
00589     {
00590       FRect[1]=pow(ten,FRect[1]);
00591       FRect[3]=pow(ten,FRect[3]);
00592     }
00593   return(0);
00594 }
00595 
00596 void get_frame_in_pixel(integer WIRect[])
00597 {
00598   /* ajout bruno */
00599   WIRect[0] = Cscale.WIRect1[0];
00600   WIRect[1] = Cscale.WIRect1[1];
00601   WIRect[2] = Cscale.WIRect1[0] +  Cscale.WIRect1[2];
00602   WIRect[3] = Cscale.WIRect1[1] +  Cscale.WIRect1[3];
00603 }
00604 
00605 void get_margin_in_pixel(integer Margin[])
00606 {
00607   /* added by bruno 
00608    *       Margin[0]: left margin 
00609    *       Margin[1]: right margin
00610    *       Margin[2]: up margin
00611    *       Margin[3]: down margin
00612    */
00613   double coef_w = 1.0 - Cscale.axis[0] - Cscale.axis[1];
00614   double coef_h = 1.0 - Cscale.axis[2] - Cscale.axis[3];
00615   Margin[0] = (integer) ( Cscale.axis[0]/coef_w * (double) Cscale.WIRect1[2]);
00616   Margin[1] = (integer) ( Cscale.axis[1]/coef_w * (double) Cscale.WIRect1[2]);
00617   Margin[2] = (integer) ( Cscale.axis[2]/coef_h * (double) Cscale.WIRect1[3]);
00618   Margin[3] = (integer) ( Cscale.axis[3]/coef_h * (double) Cscale.WIRect1[3]);
00619 }
00620 
00621 /*-------------------------------------------
00622  * changes selected items in the current scale 
00623  * flag gives which component must be used for 
00624  *      upgrading or setting the current scale 
00625  * flag[0]   : used for window dim upgrade 
00626  * flag[1:5] : subwin,frame_values,aaint,logflag,axis_values
00627  * Result: Cscale is changed 
00628  * Warning : frame_values[i] must be log10(val[i]) 
00629  *           when using log scales 
00630  *-------------------------------------------*/
00631 
00632 void set_scale( char    flag[6]        ,
00633                 double  subwin[4]      ,
00634                 double  frame_values[4],
00635                 integer aaint[4]       ,
00636                 char    logflag[3]     ,
00637                 double  axis_values[4]  )
00638      /* flag[i] = 't' or 'f' */
00639      /* subwindow specification */ /* <=> WRect*/
00640      /* [xmin,ymin,xmax,ymax] */
00641      /* [xint,x_subint,y_int,y_subint]*/
00642      /* [xlogflag,ylogflag,zlogflag (NOT USED HERE)] */
00643      /* [mfact_xl, mfact_xr,mfact_yu,mfact_yd]; */
00644 {
00645   char c;
00646   char wdim_changed= 'f',subwin_changed='f';
00647   char frame_values_changed='f',aaint_changed='f';
00648   char logflag_changed='f';
00649   char axis_changed = 'f';
00650   integer  verbose=0,narg,wdim[2];
00651   int i;
00652   if ( flag[0] == 't'  ) 
00653     {
00654       C2F(dr)("xget","wdim",&verbose,wdim,&narg, PI0, PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00655       if ( Cscale.wdim[0] != wdim[0] || Cscale.wdim[1] != wdim[1]) 
00656         { 
00657           Cscale.wdim[0] = wdim[0]; Cscale.wdim[1] = wdim[1]; 
00658           wdim_changed='t';
00659         }
00660     }
00661   if ( flag[1] == 't' ) 
00662     {
00663       for (i=0; i < 4 ; i++ ) 
00664         if ( subwin[i] != Cscale.subwin_rect[i]) { subwin_changed='t' ; break;}
00665     }
00666   if ( flag[2] == 't' ) 
00667     {
00668       for (i=0; i < 4 ; i++ ) 
00669         if ( frame_values[i] != Cscale.frect[i]) { frame_values_changed='t' ; break;}
00670       /* if no scales were present and the values given are the same as the 
00671        * default frect values we must register that we are setting a scale 
00672        */
00673       if ( Cscale.flag == 0) frame_values_changed='t' ;
00674     }
00675   if ( flag[3] == 't' ) 
00676     {
00677       for (i=0; i < 4 ; i++ ) 
00678         if ( aaint[i] != Cscale.Waaint1[i]) { aaint_changed='t' ; break;}
00679     }
00680   if ( flag[4] == 't' ) 
00681     {
00682       for (i=0; i < 2 ; i++ ) 
00683         if ( logflag[i] != Cscale.logflag[i]) { logflag_changed='t' ; break;}
00684     }
00685   if ( flag[5] == 't' ) 
00686     {
00687       for (i=0; i < 4 ; i++ ) 
00688         if ( axis_values[i] != Cscale.axis[i]) { axis_changed='t' ; break;}
00689     }
00690   if ( axis_changed == 't') 
00691     {
00692       for (i=0; i < 4 ; i++ ) Cscale.axis[i] = axis_values[i];
00693     }
00694 
00695   if ( subwin_changed == 't' ) 
00696     {
00697       for (i=0; i < 4 ; i++ ) Cscale.subwin_rect[i] = subwin[i];
00698     }
00699   if ( frame_values_changed == 't' ) 
00700     {
00701       for (i=0; i < 4 ; i++) Cscale.frect[i]=frame_values[i]; 
00702       /* the scale is no more a default scale */
00703       Cscale.flag = 1;
00704     }
00705   if ( wdim_changed == 't' || subwin_changed == 't' || frame_values_changed == 't' 
00706        ||  axis_changed == 't' )
00707     {
00708       /* Upgrading constants for 2D transformation */
00709       double scx,scy,xoff,yoff,val;
00710 
00711       sciPointObj *pobj = sciGetCurrentSubWin();
00712       sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
00713 
00714       scx =  ((double) Cscale.wdim[0]*Cscale.subwin_rect[2]-Cscale.wdim[0]*Cscale.subwin_rect[2]
00715               *(Cscale.axis[0]+Cscale.axis[1]));
00716       scy =  ((double) Cscale.wdim[1]*Cscale.subwin_rect[3]-Cscale.wdim[1]*Cscale.subwin_rect[3]
00717               *(Cscale.axis[2]+Cscale.axis[3]));
00718       xoff= ((double) Cscale.wdim[0]*Cscale.subwin_rect[2])*(Cscale.axis[0]);
00719       yoff= ((double) Cscale.wdim[1]*Cscale.subwin_rect[3])*(Cscale.axis[2]);
00720       
00721       Cscale.Wxofset1= xoff+Cscale.subwin_rect[0]*((double)Cscale.wdim[0]);
00722       Cscale.Wyofset1= yoff+Cscale.subwin_rect[1]*((double)Cscale.wdim[1]);
00723       Cscale.Wscx1   = scx;
00724       Cscale.Wscy1   = scy;
00725 
00726       val = Abs(Cscale.frect[0]- Cscale.frect[2]);
00727       Cscale.Wscx1 = (val <=SMDOUBLE) ? Cscale.Wscx1/SMDOUBLE : Cscale.Wscx1/val; 
00728       val = Abs(Cscale.frect[1]- Cscale.frect[3]);
00729       Cscale.Wscy1 = (val <=SMDOUBLE) ? Cscale.Wscy1/SMDOUBLE : Cscale.Wscy1/val;
00730 
00731       /*          F.Leray 12.10.04 : MODIF named scale_modification*/
00732       if(ppsubwin->axes.reverse[0]==TRUE && ppsubwin->is3d == FALSE)
00733       {
00734         Cscale.WIRect1[0] = XScale( Cscale.frect[2]);
00735         Cscale.WIRect1[2] = Abs(XScale( Cscale.frect[2]) -  XScale( Cscale.frect[0]));
00736       }
00737       else
00738       {
00739         Cscale.WIRect1[0] = XScale( Cscale.frect[0]);
00740         Cscale.WIRect1[2] = Abs(XScale( Cscale.frect[2]) -  XScale( Cscale.frect[0]));
00741       }
00742 
00743       if(ppsubwin->axes.reverse[1]==TRUE && ppsubwin->is3d == FALSE)
00744       {
00745         Cscale.WIRect1[1] = YScale( Cscale.frect[1]);
00746         Cscale.WIRect1[3] = Abs(YScale( Cscale.frect[3]) -  YScale( Cscale.frect[1]));
00747       }
00748       else
00749       {
00750         Cscale.WIRect1[1] = YScale( Cscale.frect[3]);
00751         Cscale.WIRect1[3] = Abs(YScale( Cscale.frect[3]) -  YScale( Cscale.frect[1]));
00752       }
00753     }
00754   if (  aaint_changed== 't' ) 
00755     {
00756       for (i=0; i < 4 ; i++) Cscale.Waaint1[i]=aaint[i];
00757     }
00758   if ( logflag_changed== 't' ) 
00759     {
00760       Cscale.logflag[0]=logflag[0];      Cscale.logflag[1]=logflag[1];
00761     }
00762   if (  aaint_changed== 't' || frame_values_changed == 't')
00763     {
00764       Cscale.xtics[0] = Cscale.frect[0];
00765       Cscale.xtics[1] = Cscale.frect[2];
00766       Cscale.ytics[0] = Cscale.frect[1];
00767       Cscale.ytics[1] = Cscale.frect[3];
00768       Cscale.xtics[2] = 0.0;
00769       Cscale.ytics[2] = 0.0;
00770       Cscale.xtics[3] = Cscale.Waaint1[1];
00771       Cscale.ytics[3] = Cscale.Waaint1[3];
00772     }
00773  
00775   if ( (c=GetDriver()) == 'X' ||  c == 'R' || c == 'I' || c == 'G' || c == 'W' )
00776     {
00777       set_window_scale(curwin(),&Cscale);
00778     }  
00779 }
00780 
00781 /*--------------------------------------------------------------------
00782  * Get the current window dimensions.
00783  *--------------------------------------------------------------------*/
00784 
00785 void get_cwindow_dims(int wdims[2])
00786 {
00787   int verbose=0,narg;
00788   C2F(dr)("xget","wdim",&verbose,wdims,&narg, PI0, PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
00789 }
00790 
00791 /* for x only */
00792 
00793 int C2F(xechelle2d)(x,x1,n1,dir,lstr)
00794 double x[];
00795 integer x1[],*n1;
00796 char dir[];
00797 integer lstr;
00798 {
00799   integer i;
00800   if (strcmp("f2i",dir)==0) 
00801   {
00802 
00803     if (Cscale.logflag[0] == 'n') 
00804       for ( i=0 ; i < (*n1) ; i++) x1[i]= XScale(x[i]);
00805     else 
00806       for ( i=0 ; i < (*n1) ; i++) x1[i]= XLogScale(x[i]);
00807   }
00808   else if (strcmp("i2f",dir)==0) 
00809   {
00810     if (Cscale.logflag[0] == 'n') 
00811       for ( i=0 ; i < (*n1) ; i++) x[i]= XPi2R( x1[i] );
00812     else 
00813       for ( i=0 ; i < (*n1) ; i++) x[i]= exp10(XPi2R( x1[i]));
00814   }
00815   else 
00816     sciprint(" Wrong dir %s argument in echelle2d\r\n",dir);
00817 
00818   return(0);
00819 }
00820 
00821 /* for y only */
00822 
00823 int C2F(yechelle2d)(y,yy1,n2,dir,lstr)
00824 double y[];
00825 integer yy1[],*n2;
00826 char dir[];
00827 integer lstr;
00828 {
00829   integer i;
00830   if (strcmp("f2i",dir)==0) 
00831   {
00832     if (Cscale.logflag[1] == 'n') 
00833       for ( i=0 ; i < (*n2) ; i++) yy1[i]= YScale(y[i]);
00834     else 
00835       for ( i=0 ; i < (*n2) ; i++) yy1[i]= YLogScale(y[i]);
00836   }
00837   else if (strcmp("i2f",dir)==0) 
00838   {
00839     if (Cscale.logflag[1] == 'n') 
00840       for ( i=0 ; i < (*n2) ; i++)  y[i]= YPi2R( yy1[i] );
00841     else 
00842       for ( i=0 ; i < (*n2) ; i++)  y[i]= exp10(YPi2R( yy1[i]));
00843   }
00844   else 
00845     sciprint(" Wrong dir %s argument in echelle2d\r\n",dir); 
00846 
00847   return(0);
00848 }
00849 
00850 /*--------------------------------------------------------------------
00851  * Convert pixel<->double using current scale 
00852  * 
00853  *  C2F(echelle2d)(x,y,x1,y1,n1,n2,rect,dir)
00854  *    x,y,x1,y1 of size [n1*n2] 
00855  *    dir     : "f2i" -> double to integer (you give x and y and get x1,y1)
00856  *            : "i2f" -> integer to double (you give x1 and y1 and get x,y)
00857  *    lstr    : unused (Fortran/C) 
00858  * --------------------------------------------------------------------------*/
00859 
00860 int C2F(echelle2d)( double    x[]  ,
00861                     double    y[]  ,
00862                     integer   x1[] ,
00863                     integer   yy1[],
00864                     integer * n1   ,
00865                     integer * n2   ,
00866                     char      dir[],
00867                     integer   lstr )
00868 
00869 {
00870   int n=(*n1)*(*n2);
00871   C2F(xechelle2d)(x,x1,&n,dir,lstr);
00872   C2F(yechelle2d)(y,yy1,&n,dir,lstr);
00873   return(0);
00874 }
00875 
00876 
00877 
00878 /*--------------------------------------------------------------------
00879  * void C2F(echelle2dl)(x, y, x1, yy1, n1, n2,  dir)
00880  * like echelle2d but for length convertion 
00881  * Note that it cannot work in logarithmic scale 
00882  *--------------------------------------------------------------------*/
00883 
00884 void C2F(echelle2dl)( double    x[]  ,
00885                       double    y[]  ,
00886                       integer   x1[] ,
00887                       integer   yy1[],
00888                       integer * n1   ,
00889                       integer * n2   ,
00890                       char    * dir   )
00891 {
00892   integer i;
00893   if (strcmp("f2i",dir)==0) 
00894     {
00895       for ( i=0 ; i < (*n1)*(*n2) ; i++)
00896         {
00897           x1[i]=inint( Cscale.Wscx1*( x[i]));
00898           yy1[i]=inint( Cscale.Wscy1*( y[i]));
00899         }
00900     }
00901   else if (strcmp("i2f",dir)==0) 
00902     {
00903       for ( i=0 ; i < (*n1)*(*n2) ; i++)
00904         {
00905           x[i]=x1[i]/Cscale.Wscx1;
00906           y[i]=yy1[i]/Cscale.Wscy1;
00907         }
00908     }
00909   else 
00910     sciprint(" Wrong dir %s argument in echelle2d\r\n",dir);
00911 }
00912 
00915 void C2F(ellipse2d)( double x[], integer x1[], integer * n, char * dir)
00916 {
00917   integer i;
00918   if (strcmp("f2i",dir)==0) 
00919     {
00921       for ( i=0 ; i < (*n) ; i=i+6)
00922         {
00923           x1[i  ]= XScale(x[i]);
00924           x1[i+1]= YScale(x[i+1]);
00925           x1[i+2]= inint( Cscale.Wscx1*( x[i+2]));
00926           x1[i+3]= inint( Cscale.Wscy1*( x[i+3]));
00927           x1[i+4]= inint( x[i+4]);
00928           x1[i+5]= inint( x[i+5]);
00929         }
00930     }
00931   else if (strcmp("i2f",dir)==0) 
00932     {
00933       for ( i=0 ; i < (*n) ; i=i+6)
00934         {
00935           x[i]=   XPi2R(x1[i]); 
00936           x[i+1]= YPi2R( x1[i+1] ); 
00937           x[i+2]= x1[i+2]/Cscale.Wscx1;
00938           x[i+3]= x1[i+3]/Cscale.Wscy1;
00939           x[i+4]= x1[i+4];
00940           x[i+5]= x1[i+5];
00941         }
00942     }
00943   else 
00944     sciprint(" Wrong dir %s argument in echelle2d\r\n",dir);
00945 }
00946 
00949 void C2F(rect2d)( double x[], integer x1[], integer * n, char * dir)
00950 {
00951   integer i;
00952   if (strcmp("f2i",dir)==0) 
00953     {
00955       for ( i=0 ; i < (*n) ; i= i+4)
00956         {
00957           if ( Cscale.logflag[0] == 'n' ) 
00958             {
00959               x1[i]=  XScale(x[i]);
00960               x1[i+2]=inint( Cscale.Wscx1*( x[i+2]));
00961             }
00962           else 
00963             {
00964               x1[i]= XLogScale(x[i]);
00965               x1[i+2]=inint( Cscale.Wscx1*(log10((x[i]+x[i+2])/x[i])));
00966             } 
00967           if ( Cscale.logflag[1] == 'n' ) 
00968             {
00969               x1[i+1]= YScale(x[i+1]);
00970               x1[i+3]=inint( Cscale.Wscy1*( x[i+3]));
00971             }
00972           else 
00973             {
00974               x1[i+1]= YLogScale(x[i+1]);
00975               x1[i+3]=inint( Cscale.Wscy1*(log10(x[i+1]/(x[i+1]-x[i+3]))));
00976             }
00977         }
00978     } 
00979   else if (strcmp("i2f",dir)==0) 
00980     {
00981       for ( i=0 ; i < (*n) ; i=i+4)
00982         {
00983           if ( Cscale.logflag[0] == 'n' ) 
00984             {
00985               x[i]= XPi2R(x1[i] );
00986               x[i+2]=x1[i+2]/Cscale.Wscx1;
00987             }
00988           else
00989             {
00990               x[i]=exp10( XPi2R(x1[i]));
00991               x[i+2]=exp10(XPi2R( x1[i]+x1[i+2] ));
00992               x[i+2] -= x[i];
00993             }
00994           if ( Cscale.logflag[1] == 'n' ) 
00995             {
00996               x[i+1]= YPi2R( x1[i+1]);
00997               x[i+3]=x1[i+3]/Cscale.Wscy1;
00998             }
00999           else
01000             {
01001               x[i+1]=exp10( YPi2R( x1[i+1]));
01002               x[i+3]=exp10( YPi2R( x1[i+3]+x1[i+1])); 
01003               x[i+2] -= x[i+1];
01004             }
01005         }
01006     }
01007   else 
01008     sciprint(" Wrong dir %s argument in echelle2d\r\n",dir);
01009 }
01010 
01011  
01014 void C2F(axis2d)( double  * alpha     ,
01015                   double  * initpoint ,
01016                   double  * size      ,
01017                   integer * initpoint1,
01018                   double  * size1       )
01019 {
01020   double sina ,cosa;
01021   double xx,yy,scl;
01022   /* pour eviter des problemes numerique quand Cscale.scx1 ou Cscale.scy1 sont 
01023    *  tres petits et cosal ou sinal aussi 
01024    */
01025   if ( Abs(*alpha) == 90 ) 
01026     {
01027       scl=Cscale.Wscy1;
01028     }
01029   else 
01030     {
01031       if (Abs(*alpha) == 0) 
01032         {
01033           scl=Cscale.Wscx1;
01034         }
01035       else 
01036         {
01037           sina= sin(*alpha * M_PI/180.0);
01038           cosa= cos(*alpha * M_PI/180.0);
01039           xx= cosa*Cscale.Wscx1; xx *= xx;
01040           yy= sina*Cscale.Wscy1; yy *= yy;
01041           scl= sqrt(xx+yy);
01042         }
01043     }
01044   size1[0] = size[0]*scl;
01045   size1[1]=  size[1]*scl;
01046   size1[2]=  size[2];
01047   initpoint1[0]= XScale(initpoint[0]);
01048   initpoint1[1]= YScale(initpoint[1]);
01049 }
01050 
01053 extern int EchCheckSCPlots();
01054 
01057 int zoom_get_rectangle(double *bbox,int *x_pixel, int *y_pixel)
01058 {
01059   /* Using the mouse to get the new rectangle to fix boundaries */
01060   integer th,th1=1;
01061   integer pixmode,alumode,color,style[10],fg,verbose=0,narg;
01062   integer ibutton,in,iwait=0,istr=0;
01063   integer modes[2];
01064   double x0,yy0,x,y,xl,yl;
01065   int pixel_x, pixel_y;
01066   int pixel_x0, pixel_y0;
01067   /*   int i; */
01068 
01069   modes[0]=1;modes[1]=0; /* for xgemouse only get mouse mouvement*/
01070 
01071   C2F(dr)("xget","pixmap",&verbose,&pixmode,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01072   C2F(dr)("xget","alufunction",&verbose,&alumode,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01073   C2F(dr)("xget","thickness",&verbose,&th,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01074   C2F(dr)("xget","color",&verbose,&color,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01075   C2F(dr)("xget","line style",&verbose,style,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01076   C2F(dr)("xget","foreground",&verbose,&fg,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01077 
01078 #ifdef _MSC_VER
01079   SetWinhdc();
01080   SciMouseCapture();
01081 #endif 
01082   C2F(SetDriver)("X11",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0);
01083   C2F(dr)("xset","thickness",&th1,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01084   C2F(dr)("xset","line style",(in=1,&in),PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01085   C2F(dr)("xset","color",&fg,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01086  
01088   C2F(dr1)("xset","alufunction",(in=6,&in),PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01089   /*  C2F(dr1)("xclick","one",&ibutton,&iwait,&istr,PI0,PI0,PI0,&x0,&yy0,PD0,PD0,0L,0L); */
01090   xclick_2("xclick","one",&ibutton,&iwait,&istr,&x_pixel[0],&y_pixel[0],PI0,&x0,&yy0,PD0,PD0,0L,0L);
01091 
01092   
01093   if(ibutton == -100){
01094     sciprint("Error: window closed while zooming\t\n");
01095     return 1; /* error catch : no need to go further F.Leray 07.09.05 */
01096   }
01097   
01098   x=x0;y=yy0;
01099 
01100   pixel_x = pixel_x0 = x_pixel[0];
01101   pixel_y = pixel_y0 = y_pixel[0];
01102 
01103   ibutton=-1;
01104   while ( ibutton == -1 ) 
01105     {
01106       /* dessin d'un rectangle */
01107       /* following line commented to solve bug 1314 */
01108       /*       C2F (dr) ("xset", "color",&noir,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0, PD0,0L,0L); */
01109       zoom_rect2(pixel_x0,pixel_y0,pixel_x,pixel_y);
01110       if ( pixmode == 1) C2F(dr1)("xset","wshow",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01111       xgetmouse2("xgetmouse","one",&ibutton,&iwait,&x_pixel[1],&y_pixel[1],modes,PI0,&xl, &yl,PD0,PD0,0L,0L);
01112       
01113       if (ibutton==-100) return 1; /* the window has been closed */  /* error catch : no need to go further F.Leray 07.09.05 */
01114       /* effacement du rectangle */
01115       zoom_rect2(pixel_x0,pixel_y0,pixel_x,pixel_y);
01116       if ( pixmode == 1) C2F(dr1)("xset","wshow",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01117       x=xl;y=yl;
01118       
01119       pixel_x = x_pixel[1];
01120       pixel_y = y_pixel[1];
01121     }   
01122 #ifndef _MSC_VER
01123 
01124   C2F(dr1)("xset","alufunction",(in=3,&in),PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01125 #endif
01126   /* Back to the default driver which must be Rec and redraw the recorded
01127    * graphics with the new scales
01128    */
01129   /* F.Leray With the new graphic standard, driver has not to be Rec*/
01130 
01131 
01132   /*   printf("JE SORS et...\n"); */
01133  
01134   bbox[0]=Min(x0,x);
01135   bbox[1]=Min(yy0,y);
01136   bbox[2]=Max(x0,x);
01137   bbox[3]=Max(yy0,y);
01138 
01139 
01140   C2F(dr1)("xset","alufunction",&alumode,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01141   C2F(dr)("xset","thickness",&th,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01142   C2F(dr)("xset","line style",style,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01143   C2F(dr)("xset","color",&color,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01144 
01145 #ifdef _MSC_VER
01146   ReleaseWinHdc();
01147   SciMouseRelease();
01148 #endif
01149   return 0;
01150 }
01151 
01152 
01153 
01154 int zoom_box(double *bbox,int *x_pixel, int *y_pixel)
01155 {
01156   integer min,max,puiss,deux=2,dix=10,box[4],box1[4],section[4];
01157 
01158   double fmin,fmax,lmin,lmax;
01159   sciPointObj *psousfen,*tmpsousfen;
01160   sciPointObj * pfigure = NULL;
01161   sciSons *psonstmp;
01162   sciSubWindow * ppsubwin = NULL; /* debug */
01163 
01164   box[0]= Min(XDouble2Pixel(bbox[0]),XDouble2Pixel(bbox[2]));
01165   box[2]= Max(XDouble2Pixel(bbox[0]),XDouble2Pixel(bbox[2]));
01166   box[1]= Min(YDouble2Pixel(bbox[1]),YDouble2Pixel(bbox[3]));
01167   box[3]= Max(YDouble2Pixel(bbox[1]),YDouble2Pixel(bbox[3]));
01168 
01169   pfigure = sciGetCurrentFigure();
01170   tmpsousfen= sciGetCurrentSubWin();
01171   psonstmp = sciGetSons (sciGetCurrentFigure());
01172   while (psonstmp != (sciSons *) NULL)
01173   {
01174     if(sciGetEntityType (psonstmp->pointobj) == SCI_SUBWIN)
01175     {
01176       psousfen= (sciPointObj *)psonstmp->pointobj;
01177       if ( pSUBWIN_FEATURE (psousfen)->is3d == TRUE) {
01178         double xmin, ymin;
01179         double xmax, ymax;
01180         double zmin, zmax;
01181         sciSons *psonstmp2 = (sciSons *) NULL;
01182         double epsilon = 1e-16;
01183 
01184         int box3d[4];
01185         int section3d[4];
01186 
01187         sciSetSelectedSubWin(psousfen);
01188         ppsubwin = pSUBWIN_FEATURE (psousfen);
01189 
01190         box3d[0] = x_pixel[0];
01191         box3d[2] = x_pixel[1];
01192         box3d[1] = y_pixel[0];
01193         box3d[3] = y_pixel[1];
01194 
01195         box1[0]= Cscale.WIRect1[0];
01196         box1[2]= Cscale.WIRect1[2]+Cscale.WIRect1[0];
01197         box1[1]= Cscale.WIRect1[1];
01198         box1[3]= Cscale.WIRect1[3]+Cscale.WIRect1[1];
01199 
01200         if (sciIsAreaZoom(box3d,box1,section3d))
01201         {
01202           int tmp[4],i;
01203 
01204           for(i=0;i<4;i++) tmp[i] = section3d[i];
01205 
01206           section3d[0] = Min(tmp[0],tmp[2]);
01207           section3d[2] = Max(tmp[0],tmp[2]);
01208           section3d[1] = Min(tmp[1],tmp[3]);
01209           section3d[3] = Max(tmp[1],tmp[3]);
01210 
01211           /* determine how many vertices we will have to draw */
01212           /* this is used for 3d zoom (to know size of the global vector) */
01213           setVertexIndex( 0 ) ;
01214 
01215           /* this flag is used inside trans3d called many times by sciDrawObj */
01216           setZoom3dStatus( TRUE );
01217 
01218           psonstmp2 = sciGetLastSons (psousfen);
01219 
01220           sciDrawObj(psousfen); /* see GlobalFlag_Zoom3dOn impact flag in sciDrawObj & trans3d functions */
01221 
01222           setZoom3dStatus( FALSE );
01223 
01224           SetMinMaxVertices(pSUBWIN_FEATURE(psousfen)->vertices_list, &xmin, &ymin, &zmin, &xmax, &ymax, &zmax);
01225 
01226 
01227           for( i = 0 ; i < getVertexIndex() ; i++ )
01228           {
01229             int xp,yp;
01230             double x,y,z;
01231 
01232             if(GetVerticesAt(pSUBWIN_FEATURE(psousfen)->vertices_list, &xp, &yp, &x, &y, &z)==-1) 
01233               break; /* all the vertices have been scanned inside the current psubwin */
01234 
01235             if(xp >= section3d[0] && xp <= section3d[2] && yp >= section3d[1] && yp <= section3d[3])
01236             {
01237               /*                          printf("ICI => xp = %d \t yp = %d et x = %lf \t y = %lf \t z = %lf\n",xp,yp,x,y,z); */
01238               if(x < xmin) xmin=x; if(x > xmax) xmax=x;
01239               if(y < ymin) ymin=y; if(y > ymax) ymax=y;
01240               if(z < zmin) zmin=z; if(z > zmax) zmax=z;
01241             }
01242           }
01243 
01244           if(ppsubwin->axes.reverse[0] == TRUE) {
01245             double tmp2;
01246             tmp2 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],xmin);
01247             xmin = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],xmax);
01248             xmax = tmp2;
01249           }
01250 
01251           if(ppsubwin->axes.reverse[1] == TRUE) {
01252             double tmp2;
01253             tmp2 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ymin);
01254             ymin = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ymax);
01255             ymax = tmp2;
01256           }
01257 
01258           if(ppsubwin->axes.reverse[2] == TRUE) {
01259             double tmp2;
01260             tmp2 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],zmin);
01261             zmin = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],zmax);
01262             zmax = tmp2;
01263           }
01264 
01265           FreeVertices(psousfen);
01266 
01267           /* case where no vertex has been selected : */
01268           /* no zoom is performed */
01269           if(xmin > xmax || ymin > ymax || zmin > zmax)
01270           {
01271             xmin = ppsubwin->SRect[0];
01272             xmax = ppsubwin->SRect[1];
01273 
01274             ymin = ppsubwin->SRect[2];
01275             ymax = ppsubwin->SRect[3];
01276 
01277             zmin = ppsubwin->SRect[4];
01278             zmax = ppsubwin->SRect[5];
01279           }
01280 
01281           if (!(sciGetZooming(psousfen)))
01282             sciSetZooming(psousfen, 1);
01283 
01284 
01285           /* case where a 3d rotated plot2d is zoomed */
01286           if(fabs(zmin) < epsilon && fabs(zmax) < epsilon){
01287             zmin = pSUBWIN_FEATURE (psousfen)->SRect[4];
01288             zmax = pSUBWIN_FEATURE (psousfen)->SRect[5];
01289           }
01290 
01291           pSUBWIN_FEATURE (psousfen)->ZRect[0] = xmin;
01292           pSUBWIN_FEATURE (psousfen)->ZRect[2] = xmax;
01293 
01294           pSUBWIN_FEATURE (psousfen)->ZRect[1] = ymin;
01295           pSUBWIN_FEATURE (psousfen)->ZRect[3] = ymax;
01296 
01297           pSUBWIN_FEATURE (psousfen)->ZRect[4] = zmin;
01298           pSUBWIN_FEATURE (psousfen)->ZRect[5] = zmax;
01299 
01300         }
01301       }
01302       sciSetSelectedSubWin(psousfen);
01303       ppsubwin = pSUBWIN_FEATURE (psousfen);
01304 
01305       if ( pSUBWIN_FEATURE (psousfen)->is3d == FALSE) {
01306 
01307         box1[0]= Cscale.WIRect1[0];
01308         box1[2]= Cscale.WIRect1[2]+Cscale.WIRect1[0];
01309         box1[1]= Cscale.WIRect1[1];
01310         box1[3]= Cscale.WIRect1[3]+Cscale.WIRect1[1];
01311 
01312         if (sciIsAreaZoom(box,box1,section))
01313         {
01314           bbox[0]= Min(XPixel2Double(section[0]),XPixel2Double(section[2]));
01315           bbox[2]= Max(XPixel2Double(section[0]),XPixel2Double(section[2]));
01316           bbox[1]= Min(YPixel2Double(section[1]),YPixel2Double(section[3]));
01317           bbox[3]= Max(YPixel2Double(section[1]),YPixel2Double(section[3]));
01318 
01319           if (!(sciGetZooming(psousfen)))
01320             sciSetZooming(psousfen, 1);
01321 
01323           fmin=  bbox[0];
01324           fmax=  bbox[2];
01325           if(pSUBWIN_FEATURE (psousfen)->logflags[0] == 'n') {
01326             C2F(graduate)(&fmin, &fmax,&lmin,&lmax,&deux,&dix,&min,&max,&puiss) ;
01327             pSUBWIN_FEATURE(psousfen)->axes.xlim[2]=puiss;
01328             pSUBWIN_FEATURE (psousfen)->ZRect[0]=lmin;
01329             pSUBWIN_FEATURE (psousfen)->ZRect[2]=lmax;}
01330           else {
01331             pSUBWIN_FEATURE(psousfen)->axes.xlim[2]=0;
01332             pSUBWIN_FEATURE (psousfen)->ZRect[0]=fmin;
01333             pSUBWIN_FEATURE (psousfen)->ZRect[2]=fmax;
01334           }
01335 
01336 
01337           fmin= bbox[1]; 
01338           fmax= bbox[3];
01339           if(pSUBWIN_FEATURE (psousfen)->logflags[1] == 'n') {
01340             C2F(graduate)(&fmin, &fmax,&lmin,&lmax,&deux,&dix,&min,&max,&puiss) ;
01341             pSUBWIN_FEATURE(psousfen)->axes.ylim[2]=puiss;
01342             pSUBWIN_FEATURE (psousfen)->ZRect[1]=lmin;
01343             pSUBWIN_FEATURE (psousfen)->ZRect[3]=lmax;}
01344           else {
01345             pSUBWIN_FEATURE(psousfen)->axes.ylim[2]=0;
01346             pSUBWIN_FEATURE (psousfen)->ZRect[1]=fmin;
01347             pSUBWIN_FEATURE (psousfen)->ZRect[3]=fmax;}
01348         }
01349       }
01350     }
01351     psonstmp = psonstmp->pnext;
01352   }
01353   sciSetSelectedSubWin(tmpsousfen);
01354   sciDrawObj(sciGetCurrentFigure());
01355 
01356   return 0;
01357 }
01358 
01359 
01360 int zoom()
01361 {
01362   double bbox[4];
01363   int x_pixel[2], y_pixel[2];
01364 
01365   if ( zoom_get_rectangle(bbox,x_pixel,y_pixel) == 1 ) { return 1 ; }
01366   
01367   zoom_box(bbox,x_pixel,y_pixel);
01368   return 0;
01369 }
01370 
01371 
01372 extern void unzoom()
01373 {
01374   integer ww,verbose=0,narg;
01376   double fmin,fmax,lmin,lmax;
01377   integer min,max,puiss,deux=2,dix=10;
01378   sciPointObj *psousfen;
01379   sciSons *psonstmp;
01380 
01381 
01382   C2F(dr1)("xclear","v",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01383   C2F(dr1)("xget","window",&verbose,&ww,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01384   /***** 02/10/2002 ****/
01385   psonstmp = sciGetSons (sciGetCurrentFigure());
01386   while (psonstmp != (sciSons *) NULL)
01387   {
01388     if(sciGetEntityType (psonstmp->pointobj) == SCI_SUBWIN)
01389     {
01390       psousfen= (sciPointObj *)psonstmp->pointobj;
01391       if (sciGetZooming(psousfen))
01392       {
01393         sciSetZooming(psousfen, 0);
01394         /*   pSUBWIN_FEATURE (psousfen)->ZRect[0]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[0]; */
01395         /*                    pSUBWIN_FEATURE (psousfen)->ZRect[1]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[1]; */
01396         /*                    pSUBWIN_FEATURE (psousfen)->ZRect[2]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[2]; */
01397         /*                    pSUBWIN_FEATURE (psousfen)->ZRect[3]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[3]; */
01398 
01399         pSUBWIN_FEATURE (psousfen)->ZRect[0]   = pSUBWIN_FEATURE (psousfen)->SRect[0];
01400         pSUBWIN_FEATURE (psousfen)->ZRect[1]   = pSUBWIN_FEATURE (psousfen)->SRect[1];
01401         pSUBWIN_FEATURE (psousfen)->ZRect[2]   = pSUBWIN_FEATURE (psousfen)->SRect[2];
01402         pSUBWIN_FEATURE (psousfen)->ZRect[3]   = pSUBWIN_FEATURE (psousfen)->SRect[3];
01403 
01404         /*}  SS: moved below because if sciGetZooming(psousfen)==0 
01405         ZRect is undefined -> code may enter in infinite recursion loop to compute graduation
01406         and there is no use to regraduate */
01407 
01409         fmin= pSUBWIN_FEATURE (psousfen)->ZRect[0];
01410         fmax= pSUBWIN_FEATURE (psousfen)->ZRect[2];
01411         C2F(graduate)(&fmin, &fmax,&lmin,&lmax,&deux,&dix,&min,&max,&puiss) ;
01412         pSUBWIN_FEATURE(psousfen)->axes.xlim[2]=puiss;
01413 
01414         fmin= pSUBWIN_FEATURE (psousfen)->ZRect[1];
01415         fmax= pSUBWIN_FEATURE (psousfen)->ZRect[3];
01416         C2F(graduate)(&fmin, &fmax,&lmin,&lmax,&deux,&dix,&min,&max,&puiss) ;
01417         pSUBWIN_FEATURE(psousfen)->axes.ylim[2]=puiss;
01418         /*****/
01419       }
01420     }
01421     psonstmp = psonstmp->pnext;
01422   }
01423 
01424   sciDrawObj(sciGetCurrentFigure());
01425 }
01426 
01427 extern void unzoom_one_axes(sciPointObj *psousfen)
01428 {
01429   double fmin,fmax,lmin,lmax;
01430   integer min,max,puiss,deux=2,dix=10;
01431 
01432   if (sciGetEntityType (psousfen) == SCI_SUBWIN) {
01433     if (sciGetZooming(psousfen))        {
01434       sciSetZooming(psousfen, 0);
01435       /*   pSUBWIN_FEATURE (psousfen)->ZRect[0]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[0]; */
01436       /*          pSUBWIN_FEATURE (psousfen)->ZRect[1]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[1]; */
01437       /*          pSUBWIN_FEATURE (psousfen)->ZRect[2]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[2]; */
01438       /*          pSUBWIN_FEATURE (psousfen)->ZRect[3]   = pSUBWIN_FEATURE (psousfen)->ZRect_kp[3]; */
01439 
01440       pSUBWIN_FEATURE (psousfen)->ZRect[0]   = pSUBWIN_FEATURE (psousfen)->SRect[0];
01441       pSUBWIN_FEATURE (psousfen)->ZRect[1]   = pSUBWIN_FEATURE (psousfen)->SRect[1];
01442       pSUBWIN_FEATURE (psousfen)->ZRect[2]   = pSUBWIN_FEATURE (psousfen)->SRect[2];
01443       pSUBWIN_FEATURE (psousfen)->ZRect[3]   = pSUBWIN_FEATURE (psousfen)->SRect[3];
01444 
01445     }
01446 
01448     fmin= pSUBWIN_FEATURE (psousfen)->ZRect[0];
01449     fmax= pSUBWIN_FEATURE (psousfen)->ZRect[2];
01450     C2F(graduate)(&fmin, &fmax,&lmin,&lmax,&deux,&dix,&min,&max,&puiss) ;
01451     pSUBWIN_FEATURE(psousfen)->axes.xlim[2]=puiss;
01452 
01453     fmin= pSUBWIN_FEATURE (psousfen)->ZRect[1];
01454     fmax= pSUBWIN_FEATURE (psousfen)->ZRect[3];
01455     C2F(graduate)(&fmin, &fmax,&lmin,&lmax,&deux,&dix,&min,&max,&puiss) ;
01456     pSUBWIN_FEATURE(psousfen)->axes.ylim[2]=puiss;
01457 
01458     sciDrawObj(sciGetCurrentFigure());
01459   }
01460 }
01461 
01462 /* 
01463  *  FRectI=[xmin,ymin,xmax,ymax] est transforme de 
01464  *  facon a avoir une graduation simple et reguliere 
01465  *  Xdec,Ydec,xnax,ynax
01466  *  caracterisant cette graduation 
01467  *  (voir les fonctions qui suivent )
01468  */
01469 
01470 void Gr_Rescale(char *logFlags, double *FRectI, integer *Xdec, integer *Ydec, integer *xnax, integer *ynax)
01471 {
01472   double FRectO[4];
01473   sciPointObj *psubwin; 
01474   int i;
01475 
01477     psubwin = sciGetCurrentSubWin();
01478     for (i=0;i<4 ; i++)
01479       pSUBWIN_FEATURE (psubwin)->axes.limits[i+1]=FRectI[i];
01480      
01481     
01482   if (logFlags[0] == 'n') 
01483     { 
01484       if (!pSUBWIN_FEATURE (psubwin)->tight_limits )
01485         {
01486           C2F(graduate)(FRectI,FRectI+2,FRectO,FRectO+2,xnax,xnax+1,Xdec,Xdec+1,Xdec+2);
01487           FRectI[0]=FRectO[0];FRectI[2]=FRectO[2];
01488         }
01489         
01490       else
01491         {
01492           C2F(graduate)(FRectI,FRectI+2,FRectO,FRectO+2,xnax,xnax+1,Xdec,Xdec+1,Xdec+2);
01493         }
01494     }
01495   else
01496     {
01497       Xdec[0]=inint(FRectI[0]);
01498       Xdec[1]=inint(FRectI[2]);
01499       Xdec[2]=0;
01500     }
01501   if (logFlags[1] == 'n') 
01502     {
01503       if ( !pSUBWIN_FEATURE (psubwin)->tight_limits)
01504         {
01505           C2F(graduate)(FRectI+1,FRectI+3,FRectO+1,FRectO+3,ynax,ynax+1,Ydec,Ydec+1,Ydec+2);
01506           FRectI[1]=FRectO[1];FRectI[3]=FRectO[3];
01507         } 
01508       else
01509         {
01510           C2F(graduate)(FRectI+1,FRectI+3,FRectO+1,FRectO+3,ynax,ynax+1,Ydec,Ydec+1,Ydec+2);
01511         }
01512     }
01513   else
01514     {
01515       Ydec[0]=inint(FRectI[1]);Ydec[1]=inint(FRectI[3]);Ydec[2]=0;
01516     }
01517 
01518 
01519 }
01520 
01521 
01522 
01523 int XScale(double x)
01524 {
01525   /*F.Leray 12.10.04 : MODIF named scale_modification*/
01526 
01527   sciPointObj *pobj = sciGetCurrentSubWin();
01528   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
01529 
01530   if(ppsubwin->axes.reverse[0]==TRUE && ppsubwin->is3d == FALSE)
01531   {
01532 
01533     /* 2147483647 == 2^31 - 1 == INT32MAX */
01534     /*return inint( Max( Min(Cscale.Wscx1*(Cscale.frect[2] - (x)) + Cscale.Wxofset1, INT_MAX ), INT_MIN ) ) ;*/
01535     double dRes = Cscale.Wscx1 * (Cscale.frect[2] - (x)) + Cscale.Wxofset1 ;
01536     return FLOAT_2_INT( dRes ) ;
01537   }
01538   else
01539   {
01540     /*return inint( Max( Min(Cscale.Wscx1*((x) -Cscale.frect[0]) + Cscale.Wxofset1, INT_MAX ), INT_MIN ) );*/
01541     double dRes = Cscale.Wscx1 * ((x) -Cscale.frect[0]) + Cscale.Wxofset1 ;
01542     return FLOAT_2_INT( dRes ) ;
01543   }
01544   
01545 
01546   sciprint("Error in XScale\n");
01547   return -9000;
01548 }
01549 
01550 
01551 
01552 
01553 int XLogScale(double x)
01554 {
01555   /*F.Leray 12.10.04 : MODIF named scale_modification*/
01556 
01557   sciPointObj *pobj = sciGetCurrentSubWin();
01558   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
01559 
01560   if(ppsubwin->axes.reverse[0]==TRUE && ppsubwin->is3d == FALSE)
01561     return inint( Cscale.Wscx1*(Cscale.frect[2] - log10(x)) + Cscale.Wxofset1);
01562   else
01563     return inint( Cscale.Wscx1*(log10(x) -Cscale.frect[0]) + Cscale.Wxofset1);
01564         
01565 
01566   sciprint("Error in XLogScale\n");
01567   return -9000;
01568 }
01569 
01570 
01571 
01572 
01573 int YScale(double y)
01574 {
01575   /*F.Leray 12.10.04 : MODIF named scale_modification*/
01576 
01577   sciPointObj *pobj = sciGetCurrentSubWin();
01578   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
01579 
01580   if( ppsubwin->axes.reverse[1] && !ppsubwin->is3d )
01581   {
01582     double dRes = Cscale.Wscy1 * ( y - Cscale.frect[1] ) + Cscale.Wyofset1 ;
01583     return FLOAT_2_INT( dRes ) ;
01584   }
01585   else
01586   {
01587     double dRes = Cscale.Wscy1 * ( -y + Cscale.frect[3] ) + Cscale.Wyofset1 ;
01588     return FLOAT_2_INT( dRes ) ;
01589   }
01590 
01591   
01592   sciprint("Error in YScale\n");
01593   return -9000;
01594 }
01595 
01596 
01597 int YLogScale(double y)
01598 {
01599   /*F.Leray 12.10.04 : MODIF named scale_modification*/
01600   sciPointObj *pobj = sciGetCurrentSubWin();
01601   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
01602 
01603   if(ppsubwin->axes.reverse[1]==TRUE && ppsubwin->is3d == FALSE)
01604     return inint( Cscale.Wscy1*(log10(y)-Cscale.frect[1]) + Cscale.Wyofset1);
01605   else
01606     return inint( Cscale.Wscy1*(-log10(y)+Cscale.frect[3]) + Cscale.Wyofset1);
01607  
01608   
01609 
01610   sciprint("Error in YLogScale\n");
01611   return -9000;
01612 }
01613 
01614 
01615 
01616 double XPi2R(int x)
01617 {
01618   /*F.Leray 12.10.04 : MODIF named scale_modification*/
01619 
01620   sciPointObj *pobj = sciGetCurrentSubWin();
01621   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
01622 
01623   if(ppsubwin->axes.reverse[0]==TRUE && ppsubwin->is3d == FALSE)
01624     return Cscale.frect[2] - (1.0/Cscale.Wscx1)*((x) - Cscale.Wxofset1);
01625   else
01626     return Cscale.frect[0] + (1.0/Cscale.Wscx1)*((x) - Cscale.Wxofset1);
01627  
01628 
01629   sciprint("Error in XScale\n");
01630   return -9000;
01631 }
01632 
01633 
01634 double YPi2R(int y)
01635 {
01636   /*F.Leray 12.10.04 : MODIF named scale_modification*/
01637   sciPointObj *pobj = sciGetCurrentSubWin();
01638   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
01639 
01640   if(ppsubwin->axes.reverse[1]==TRUE && ppsubwin->is3d == FALSE)
01641     return Cscale.frect[1] + (1.0/Cscale.Wscy1)*((y) - Cscale.Wyofset1);
01642   else
01643     return Cscale.frect[3] - (1.0/Cscale.Wscy1)*((y) - Cscale.Wyofset1);
01644 
01645 
01646   sciprint("Error in YScale\n");
01647   return -9000;
01648 }
01649 
01650 double XDPi2R( double x )
01651 {
01652   /*F.Leray 12.10.04 : MODIF named scale_modification*/
01653   sciPointObj *pobj = sciGetCurrentSubWin();
01654   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
01655 
01656   if(ppsubwin->axes.reverse[0]==TRUE && ppsubwin->is3d == FALSE)
01657     return Cscale.frect[2] - (1.0/Cscale.Wscx1)*((x) - Cscale.Wxofset1);
01658   else
01659     return Cscale.frect[0] + (1.0/Cscale.Wscx1)*((x) - Cscale.Wxofset1);
01660 
01661 
01662   sciprint("Error in XScale\n");
01663   return -9000;
01664 }
01665 
01666 
01667 double YDPi2R( double y )
01668 {
01669   /*F.Leray 12.10.04 : MODIF named scale_modification*/
01670   sciPointObj *pobj = sciGetCurrentSubWin();
01671   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
01672 
01673   if(ppsubwin->axes.reverse[1]==TRUE && ppsubwin->is3d == FALSE)
01674     return Cscale.frect[1] + (1.0/Cscale.Wscy1)*((y) - Cscale.Wyofset1);
01675   else
01676     return Cscale.frect[3] - (1.0/Cscale.Wscy1)*((y) - Cscale.Wyofset1);
01677 
01678   
01679   
01680   sciprint("Error in YScale\n");
01681   return -9000;
01682 }
01683 
01684 double Zoom3d_XPi2R(int x)
01685 {
01686   /*F.Leray 12.10.04 : MODIF named scale_modification*/
01687   sciPointObj *pobj = sciGetCurrentSubWin();
01688   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
01689 
01690   if(ppsubwin->axes.reverse[0]==TRUE) /* difference is HERE */
01691     return Cscale.frect[2] - (1.0/Cscale.Wscx1)*((x) - Cscale.Wxofset1);
01692   else
01693     return Cscale.frect[0] + (1.0/Cscale.Wscx1)*((x) - Cscale.Wxofset1);
01694   
01695 
01696   sciprint("Error in Zoom3d_XScale\n");
01697   return -9000;
01698 }
01699 
01700 
01701 double Zoom3d_YPi2R(int y)
01702 {
01703   /*F.Leray 12.10.04 : MODIF named scale_modification*/
01704 
01705   sciPointObj *pobj = sciGetCurrentSubWin();
01706   sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
01707 
01708   if(ppsubwin->axes.reverse[1]==TRUE) /* difference is HERE */
01709     return Cscale.frect[1] + (1.0/Cscale.Wscy1)*((y) - Cscale.Wyofset1);
01710   else
01711     return Cscale.frect[3] - (1.0/Cscale.Wscy1)*((y) - Cscale.Wyofset1);
01712 
01713   
01714   
01715   sciprint("Error in Zoom3d_YScale\n");
01716   return -9000;
01717 }
01718 
01719 
01720 
01721 
01722 
01723 
01724 
01732 static void zoom_rect2(int xpix_ini, int ypix_ini, int xpix_fin, int ypix_fin)
01733 {
01734   int closeflag=0;
01735   int cinq=5;
01736   
01737   int xm[5], ym[5];
01738   
01739   #ifdef _MSC_VER
01740     integer verbose=0,pat,pat1=3,narg;
01741   #endif
01742 
01743   if(xpix_ini < xpix_fin){
01744     xm[0] = xpix_ini;
01745     xm[1] = xpix_ini;
01746     xm[4] = xpix_ini;
01747 
01748     xm[2] = xpix_fin;
01749     xm[3] = xpix_fin;
01750   }
01751   else{
01752     xm[0] = xpix_fin;
01753     xm[1] = xpix_fin;
01754     xm[4] = xpix_fin;
01755 
01756     xm[2] = xpix_ini;
01757     xm[3] = xpix_ini;
01758   }
01759 
01760   if(ypix_ini < ypix_fin){
01761     ym[0] = ypix_ini;
01762     ym[3] = ypix_ini;
01763     ym[4] = ypix_ini;
01764 
01765     ym[1] = ypix_fin;
01766     ym[2] = ypix_fin;
01767   }
01768   else{
01769     ym[0] = ypix_fin;
01770     ym[3] = ypix_fin;
01771     ym[4] = ypix_fin;
01772     
01773     ym[1] = ypix_ini;
01774     ym[2] = ypix_ini;
01775   }
01776   
01777 #ifdef _MSC_VER
01778   C2F(dr)("xget","pattern",&verbose,&pat,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01779   C2F(dr)("xset","pattern",&pat1,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01780 #endif
01781 
01782   /*   C2F(dr1)("xrect","v",PI0,PI0,PI0,PI0,PI0,PI0,&xi,&yi,&w,&h,0L,0L); */
01783 
01784 
01785   C2F (dr) ("xlines", "xv", &cinq, xm, ym, &closeflag, PI0, PI0, PD0, PD0, PD0, PD0,6L,2L);
01786 
01787 
01788 
01789 #ifdef _MSC_VER
01790   C2F(dr)("xset","pattern",&pat,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
01791 #endif
01792 }
01793 
01794 void scizoom( double bbox[4], sciPointObj * pobj )
01795 {
01796   sciPointObj *psousfen;
01797   double fmin,fmax,lmin,lmax;
01798   integer min,max,puiss,deux=2,dix=10;
01799   psousfen= pobj; /* ??? */
01800 
01801   if ( !( sciGetZooming(pobj) ) )
01802   {
01803     sciSetZooming(psousfen, 1);
01804   }
01806   fmin=  bbox[0];
01807   fmax=  bbox[2];
01808   if( pSUBWIN_FEATURE (psousfen)->logflags[0] == 'n' )
01809   {
01810     C2F(graduate)(&fmin, &fmax,&lmin,&lmax,&deux,&dix,&min,&max,&puiss) ;
01811     pSUBWIN_FEATURE(psousfen)->axes.xlim[2]=puiss;
01812     pSUBWIN_FEATURE (psousfen)->ZRect[0]=lmin;
01813     pSUBWIN_FEATURE (psousfen)->ZRect[2]=lmax;
01814   }
01815   else
01816   {
01817     pSUBWIN_FEATURE(psousfen)->axes.xlim[2]=0;
01818     pSUBWIN_FEATURE (psousfen)->ZRect[0]=fmin;
01819     pSUBWIN_FEATURE (psousfen)->ZRect[2]=fmax;
01820   }
01821 
01822   fmin= bbox[1]; 
01823   fmax= bbox[3];
01824   if ( pSUBWIN_FEATURE (psousfen)->logflags[1] == 'n' )
01825   {
01826     C2F(graduate)(&fmin, &fmax,&lmin,&lmax,&deux,&dix,&min,&max,&puiss) ;
01827     pSUBWIN_FEATURE(psousfen)->axes.ylim[2]=puiss;
01828     pSUBWIN_FEATURE (psousfen)->ZRect[1]=lmin;
01829     pSUBWIN_FEATURE (psousfen)->ZRect[3]=lmax;
01830   }
01831   else
01832   {
01833     pSUBWIN_FEATURE(psousfen)->axes.ylim[2]=0;
01834     pSUBWIN_FEATURE (psousfen)->ZRect[1]=fmin;
01835     pSUBWIN_FEATURE (psousfen)->ZRect[3]=fmax;
01836   }
01837 
01838   /* default values when zooming in 3d */
01839   /* and scizoom takes only xmin ymin xmax ymax AND not zmin zmax (for now at least) */
01840   /* F.Leray 29.09.05 */
01841   pSUBWIN_FEATURE (psousfen)->ZRect[4] = pSUBWIN_FEATURE (psousfen)->SRect[4];
01842   pSUBWIN_FEATURE (psousfen)->ZRect[5] = pSUBWIN_FEATURE (psousfen)->SRect[5];
01843 
01844 }
01845 /*-----------------------------------------------------------------------------------*/
01846 void getPixelCoordinates( sciPointObj * pSubWin, double coord3d[3], int pixCoord[2] )
01847 {
01848 
01849   if ( pSUBWIN_FEATURE (pSubWin)->is3d )
01850   {
01851     int n = 1 ;
01852 
01853     double xvect = coord3d[0] ;
01854     double yvect = coord3d[1] ;
01855     double zvect = coord3d[2] ;
01856 
01857     ReverseDataFor3D(pSubWin,&xvect,&yvect,&zvect,n);
01858     trans3d(pSubWin,n,&(pixCoord[0]),&(pixCoord[1]),&xvect,&yvect,&zvect ) ;
01859   }
01860   else 
01861   {
01862     pixCoord[0] = XDouble2Pixel( coord3d[0] ) ;
01863     pixCoord[1] = YDouble2Pixel( coord3d[1] ) ;
01864   }
01865 }
01866 /*-----------------------------------------------------------------------------------*/
01867 int PixelHeight2d( sciPointObj * parentSubWin, double posY, double height )
01868 {
01869   if ( pSUBWIN_FEATURE( parentSubWin )->logflags[1] == 'l' )
01870   {
01871     return HLogScale( posY, height ) ;
01872   }
01873 
01874   return HScale( height ) ;
01875 
01876 }
01877 /*-----------------------------------------------------------------------------------*/
01878 int PixelWidth2d( sciPointObj * parentSubWin, double posX, double width )
01879 {
01880   if ( pSUBWIN_FEATURE( parentSubWin )->logflags[0] == 'l' )
01881   {
01882     return WLogScale( posX, width ) ;
01883   }
01884 
01885   return WScale( width ) ;
01886 
01887 }
01888 /*-----------------------------------------------------------------------------------*/
01889 void rectangleDouble2Pixel( sciPointObj * parentSubWin ,
01890                            double        ulPoint[3]   ,
01891                            double        userSize[2]  ,
01892                            int           edgesX[4]    ,
01893                            int           edgesY[4]     )
01894 {
01895   sciSubWindow * ppSubWin = pSUBWIN_FEATURE( parentSubWin  ) ;
01896 
01897   if ( ppSubWin->is3d )
01898   {
01899     double rectx[4],recty[4],rectz[4];
01900     int n = 4 ;
01901     rectx[0] = rectx[3] = ulPoint[0] ;
01902     rectx[1] = rectx[2] = ulPoint[0] + userSize[0] ;   
01903     recty[0] = recty[1] = ulPoint[1] ;
01904     recty[2] = recty[3] = ulPoint[1] - userSize[1];
01905     rectz[0] = rectz[1] = rectz[2]= rectz[3] = ulPoint[2] ;
01906 
01907     ReverseDataFor3D( parentSubWin, rectx, recty, rectz, n);
01908 
01909     trans3d( parentSubWin,n,edgesX,edgesY,rectx,recty,rectz) ;
01910   }
01911   else
01912   {
01913     /* 2D mode */
01914     /* position of the upper left point of the rectangle with reverse axes. */
01915     double realPoint[2] ;
01916     int ulPointPix[2] ;
01917     int sizePix[2] ;
01918 
01919     if ( ppSubWin->axes.reverse[0] )
01920     {
01921       realPoint[0] = ulPoint[0] + userSize[0] ;
01922     }
01923     else
01924     {
01925       realPoint[0] = ulPoint[0] ;
01926     }
01927 
01928     if ( ppSubWin->axes.reverse[1] )
01929     {
01930       realPoint[1] = ulPoint[1] - userSize[1] ;
01931     }
01932     else
01933     {
01934       realPoint[1] = ulPoint[1] ;
01935     }
01936 
01937     ulPointPix[0] = XDouble2Pixel( realPoint[0] ) ; 
01938     ulPointPix[1] = YDouble2Pixel( realPoint[1] ) ;
01939 
01940     /* Nouvelles fonctions de changement d'echelle pour les longueurs --> voir PloEch.h */
01941     sizePix[0] = WDouble2Pixel( ulPoint[0], userSize[0] ) ;
01942     /* for y we take the length from the bottom left corner */
01943     sizePix[1] = HDouble2Pixel( ulPoint[1] - userSize[1], userSize[1] ) ;
01944 
01945     edgesX[0] = ulPointPix[0] ;
01946     edgesX[1] = ulPointPix[0] + sizePix[0]  ;
01947     edgesX[2] = ulPointPix[0] + sizePix[0]  ;
01948     edgesX[3] = ulPointPix[0] ;
01949 
01950     edgesY[0] = ulPointPix[1] ;
01951     edgesY[1] = ulPointPix[1] ;
01952     edgesY[2] = ulPointPix[1] + sizePix[1]  ;
01953     edgesY[3] = ulPointPix[1] + sizePix[1]  ;
01954 
01955   }
01956 }
01957 /*-----------------------------------------------------------------------------------*/
01958 void Plo2d2RealToPixel(integer *n1, integer *n2, double *x, double *y, integer *xm, integer *ym, char *xf)
01959 {
01960   integer i,j;
01962   if ((int)strlen(xf) >= 3 && xf[2]=='l')         
01963   {
01964     for ( i=0 ; i < (*n2) ; i++)
01965       for (j=0 ; j< (*n1) ; j++)
01966         ym[2*i+1+2*(*n2)*j]= ym[2*i+2*(*n2)*j]= YLogScale(y[i+(*n2)*j]);
01967   }
01968   else 
01969   {
01970     for ( i=0 ; i < (*n2) ; i++)
01971       for (j=0 ; j< (*n1) ; j++)
01972         ym[2*i+1+2*(*n2)*j]= ym[2*i+2*(*n2)*j]= YScale(y[i+(*n2)*j]);
01973   }
01974 
01976   switch (xf[0])
01977   {
01978   case 'e' :
01980     if ((int)strlen(xf) >= 2 && xf[1]=='l')
01981       for (j=0 ; j< (*n1) ; j++)
01982       {
01983         for ( i=1 ; i < (*n2) ; i++)
01984         {
01985           xm[2*i+2*(*n2)*j]= XLogScale(i+1.0);
01986           xm[2*i-1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
01987 
01988         }
01989         xm[2*(*n2)*j]= XScale(0);
01990         xm[2*(*n2)-1+ 2*(*n2)*j]= xm[2*(*n2-1)+ 2*(*n2)*j];
01991       }
01992     else 
01993       for (j=0 ; j< (*n1) ; j++)
01994       {
01995         for ( i=1 ; i < (*n2) ; i++)
01996         {
01997           xm[2*i+2*(*n2)*j]= XScale((i+1.0));
01998           xm[2*i-1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
01999 
02000         }
02001         xm[2*(*n2)*j]= XScale(1.0);
02002         xm[2*(*n2)-1+ 2*(*n2)*j]=        xm[2*(*n2-1)+ 2*(*n2)*j];
02003       }
02004       break ;
02005   case 'o' :
02006     if ((int)strlen(xf) >= 2 && xf[1]=='l')
02007       for (j=0 ; j< (*n1) ; j++)
02008       {
02009         for ( i=1 ; i < (*n2) ; i++)
02010         {
02011 
02012           xm[2*i+2*(*n2)*j]= XLogScale(x[i]);
02013           xm[2*i-1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
02014         }
02015         xm[2*(*n2)*j]= XLogScale(x[0]);
02016         xm[2*(*n2)-1+ 2*(*n2)*j]= xm[2*(*n2-1)+ 2*(*n2)*j];
02017       }
02018     else 
02019       for (j=0 ; j< (*n1) ; j++)
02020       {
02021         for ( i=1 ; i < (*n2) ; i++)
02022         {
02023           xm[2*i+2*(*n2)*j]= XScale(x[i]);
02024           xm[2*i-1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
02025 
02026         }
02027         xm[2*(*n2)*j]= XScale(x[0]);
02028         xm[2*(*n2)-1+ 2*(*n2)*j]= xm[2*(*n2-1)+ 2*(*n2)*j];
02029       }
02030       break;
02031   case 'g' :
02032   default:
02033     if ((int)strlen(xf) >= 2 && xf[1]=='l')
02034       for (j=0 ; j< (*n1) ; j++)
02035       {
02036         for ( i=1 ; i < (*n2) ; i++)
02037         {
02038           xm[2*i+2*(*n2)*j]= XLogScale(x[i+(*n2)*j]);
02039           xm[2*i-1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
02040 
02041         }
02042         xm[2*(*n2)*j]= XLogScale(x[(*n2)*j]);
02043         xm[2*(*n2)-1+ 2*(*n2)*j]= xm[2*(*n2-1)+ 2*(*n2)*j];
02044       }
02045     else 
02046       for (j=0 ; j< (*n1) ; j++)
02047       {
02048         for ( i=1 ; i < (*n2) ; i++)
02049         {
02050           xm[2*i+2*(*n2)*j]= XScale(x[i+(*n2)*j]);
02051           xm[2*i-1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
02052 
02053         }
02054         xm[2*(*n2)*j]= XScale(x[(*n2)*j]);
02055         xm[2*(*n2)-1+ 2*(*n2)*j]= xm[2*(*n2-1)+ 2*(*n2)*j];
02056       }
02057       break;
02058   }
02059 }
02060 /*-----------------------------------------------------------------------------------*/
02061 void Plo2d3RealToPixel(integer *n1, integer *n2, double *x, double *y, integer *xm, integer *ym, char *xf)
02062 {
02063   integer i,j;
02065   double y_zero = 0.;
02066   sciPointObj *  psubwin =  sciGetCurrentSubWin();
02067   sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
02068 
02069   if(ppsubwin->logflags[1]=='l')
02070   {
02071     y_zero = ppsubwin->FRect[1];
02072   }
02073 
02074 
02075 
02076   if ((int)strlen(xf) >= 3 && xf[2]=='l')         
02077   {
02078     for ( i=0 ; i < (*n2) ; i++)
02079       for (j=0 ; j< (*n1) ; j++)
02080       {
02081         ym[2*i+1+2*(*n2)*j]= YScale(y_zero);
02082         ym[2*i+2*(*n2)*j]= YLogScale(y[i+(*n2)*j]);
02083       }
02084   }
02085   else 
02086   {
02087     for ( i=0 ; i < (*n2) ; i++)
02088       for (j=0 ; j< (*n1) ; j++)
02089       {
02090         ym[2*i+1+2*(*n2)*j]= YScale(y_zero);
02091         ym[2*i+2*(*n2)*j]= YScale(y[i+(*n2)*j]);
02092       }
02093   }
02094 
02096   switch (xf[0])
02097   {
02098   case 'e' :
02100     if ((int)strlen(xf) >= 2 && xf[1]=='l')
02101       for (j=0 ; j< (*n1) ; j++)
02102       {
02103         for ( i=0 ; i < (*n2) ; i++)
02104         {
02105           xm[2*i+2*(*n2)*j]= XLogScale(i+1.0);
02106           xm[2*i+1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
02107 
02108         }
02109       }
02110     else 
02111       for (j=0 ; j< (*n1) ; j++)
02112       {
02113         for ( i=0 ; i < (*n2) ; i++)
02114         {
02115           xm[2*i+2*(*n2)*j]= XScale((i+1.0));
02116           xm[2*i+1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
02117 
02118         }
02119       }
02120       break ;
02121   case 'o' :
02122     if ((int)strlen(xf) >= 2 && xf[1]=='l')
02123       for (j=0 ; j< (*n1) ; j++)
02124       {
02125         for ( i=0 ; i < (*n2) ; i++)
02126         {
02127 
02128           xm[2*i+2*(*n2)*j]= XLogScale(x[i]);
02129           xm[2*i+1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
02130         }
02131       }
02132     else 
02133       for (j=0 ; j< (*n1) ; j++)
02134       {
02135         for ( i=0 ; i < (*n2) ; i++)
02136         {
02137           xm[2*i+2*(*n2)*j]= XScale(x[i]);
02138           xm[2*i+1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
02139 
02140         }
02141       }
02142       break;
02143   case 'g' :
02144   default:
02145     if ((int)strlen(xf) >= 2 && xf[1]=='l')
02146       for (j=0 ; j< (*n1) ; j++)
02147       {
02148         for ( i=0 ; i < (*n2) ; i++)
02149         {
02150           xm[2*i+2*(*n2)*j]= XLogScale(x[i+(*n2)*j]);
02151           xm[2*i+1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
02152 
02153         }
02154       }
02155     else 
02156       for (j=0 ; j< (*n1) ; j++)
02157       {
02158         for ( i=0 ; i < (*n2) ; i++)
02159         {
02160           xm[2*i+2*(*n2)*j]= XScale(x[i+(*n2)*j]);
02161           xm[2*i+1+2*(*n2)*j]=xm[2*i+2*(*n2)*j];
02162         }
02163       }
02164       break;
02165   }
02166 }
02167 /*-----------------------------------------------------------------------------------*/
02168 void Plo2d4RealToPixel(integer *n1, integer *n2, double *x, double *y, integer *xm, integer *ym, char *xf)
02169 {
02170   integer i,j;
02172   if ((int)strlen(xf) >= 3 && xf[2]=='l')         
02173   {
02174     for ( i=0 ; i < (*n2) ; i++)
02175       for (j=0 ; j< (*n1) ; j++)
02176         ym[2*i+2*(*n2)*j]= YLogScale(y[i+(*n2)*j]);
02177     for ( i=0 ; i < (*n2)-1 ; i++)
02178       for (j=0 ; j< (*n1) ; j++)
02179         ym[2*i+1+2*(*n2)*j]=      ym[2*i+2+2*(*n2)*j];
02180   }
02181   else 
02182   {
02183     for ( i=0 ; i < (*n2) ; i++)
02184       for (j=0 ; j< (*n1) ; j++)
02185         ym[2*i+2*(*n2)*j]= YScale(y[i+(*n2)*j]);
02186     for ( i=0 ; i < (*n2)-1 ; i++)
02187       for (j=0 ; j< (*n1) ; j++)
02188         ym[2*i+1+2*(*n2)*j]=      ym[2*i+2+2*(*n2)*j];
02189 
02190   }
02191 
02193   switch (xf[0])
02194   {
02195   case 'e' :
02197     if ((int)strlen(xf) >= 2 && xf[1]=='l')
02198     {
02199       for (j=0 ; j< (*n1) ; j++)
02200         for ( i=0 ; i < (*n2) ; i++)
02201           xm[2*i+2*(*n2)*j]= XLogScale(i+1.0);
02202       for (j=0 ; j< (*n1) ; j++)
02203         for ( i=0 ; i < (*n2)-1 ; i++)
02204           xm[2*i+1+2*(*n2)*j]=     xm[2*i+2+2*(*n2)*j];
02205     }
02206     else 
02207     {
02208       for (j=0 ; j< (*n1) ; j++)
02209         for ( i=0 ; i < (*n2) ; i++)
02210           xm[2*i+2*(*n2)*j]= XScale((i+1.0));
02211       for (j=0 ; j< (*n1) ; j++)
02212         for ( i=0 ; i < (*n2)-1 ; i++)
02213           xm[2*i+1+2*(*n2)*j]=     xm[2*i+2+2*(*n2)*j];
02214     }
02215     break ;
02216   case 'o' :
02217     if ((int)strlen(xf) >= 2 && xf[1]=='l')
02218     {
02219       for (j=0 ; j< (*n1) ; j++)
02220         for ( i=0 ; i < (*n2) ; i++)
02221           xm[2*i+2*(*n2)*j]= XLogScale(x[i]);
02222       for (j=0 ; j< (*n1) ; j++)
02223         for ( i=0 ; i < (*n2)-1 ; i++)
02224           xm[2*i+1+2*(*n2)*j]=     xm[2*i+2+2*(*n2)*j];
02225     }
02226     else 
02227 
02228     {
02229       for (j=0 ; j< (*n1) ; j++)
02230         for ( i=0 ; i < (*n2) ; i++)
02231           xm[2*i+2*(*n2)*j]= XScale(x[i]);
02232       for (j=0 ; j< (*n1) ; j++)
02233         for ( i=0 ; i < (*n2)-1 ; i++)
02234           xm[2*i+1+2*(*n2)*j]=     xm[2*i+2+2*(*n2)*j];
02235 
02236     }
02237     break;
02238   case 'g' :
02239   default:
02240     if ((int)strlen(xf) >= 2 && xf[1]=='l')
02241     {
02242       for (j=0 ; j< (*n1) ; j++)
02243         for ( i=0 ; i < (*n2) ; i++)
02244           xm[2*i+2*(*n2)*j]= XLogScale(x[i+(*n2)*j]);
02245       for (j=0 ; j< (*n1) ; j++)
02246         for ( i=0 ; i < (*n2)-1 ; i++)
02247           xm[2*i+1+2*(*n2)*j]=     xm[2*i+2+2*(*n2)*j];
02248 
02249     }
02250     else 
02251     {
02252       for (j=0 ; j< (*n1) ; j++)
02253         for ( i=0 ; i < (*n2) ; i++)
02254           xm[2*i+2*(*n2)*j]= XScale(x[i+(*n2)*j]);
02255       for (j=0 ; j< (*n1) ; j++)
02256         for ( i=0 ; i < (*n2)-1 ; i++)
02257           xm[2*i+1+2*(*n2)*j]=  xm[2*i+2+2*(*n2)*j];
02258 
02259     }
02260     break;
02261   }
02262 }
02263 /*-----------------------------------------------------------------------------------*/

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