sciCall.c

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *    Graphic library 2001-2002
00003  *    Graphic subroutines interface
00004  *    Authors: Djalel ABDEMOUCHE, Jean-Baptiste Silvy
00005  --------------------------------------------------------------------------*/
00006 #include <math.h>
00007 #include <stdio.h>
00008 #include <string.h>
00009 
00010 #include "SetProperty.h"
00011 #include "GetProperty.h"
00012 #include "DrawObjects.h"
00013 #include "BuildObjects.h"
00014 #include "InitObjects.h"
00015 #include "BasicAlgos.h"
00016 #include "math_graphics.h"
00017 #include "PloEch.h"
00018 #include "Axes.h"
00019 #include "Xcall1.h"
00020 #include "sciprint.h"
00021 #include "Fec.h"
00022 #include "GrayPlot.h"
00023 #include "CurrentObjectsManagement.h"
00024 
00025 #include "MALLOC.h" /* MALLOC */
00026 
00027 #include "sciCall.h"
00028 
00029 extern BOOL update_specification_bounds(sciPointObj *psubwin, double *rect,int flag);
00030 
00031 int plot2dn(integer ptype,char *logflags,double *x,double *y,integer *n1,integer *n2,integer *style,char *strflag,char *legend,double *brect,integer *aaint, BOOL flagNax, integer lstr1,integer lstr2);
00032 
00033 /*------------------------------------------------
00034  * Objrect : 
00035  * On recupere la figure courante, puis on recupere la sous fenetre qui y est selectionnee
00036  *   puis on contruit le rectangle, qu on le place comme objet courant
00037  * ensuite il reste qu'appeler la fonction du dessin de l'objet 
00038  *-----------------------------------------------*/
00039 
00040 void Objrect ( double * x         ,
00041                double * y         ,
00042                double * width     ,
00043                double * height    ,
00044                int    * foreground,
00045                int    * background,
00046                BOOL     isfilled  ,
00047                BOOL     isline    ,
00048                int      n         ,
00049                long   * hdl       ,
00050                BOOL     flagstring )
00051 {
00052   sciPointObj * newObj = NULL ;
00053   BOOL redraw = FALSE ;
00054   sciPointObj *psubwin;
00055   psubwin = sciGetCurrentSubWin();
00056   
00057   /* check if the auto_clear property is on and then erase everything */
00058   redraw = checkRedrawing() ;
00059 
00060   newObj = ConstructRectangle(psubwin ,*x,*y,*height, *width, 0, 0,
00061                               foreground, background, isfilled, isline, n, flagstring) ;
00062     
00063   if ( newObj == NULL )
00064   {
00065     /* an error occured */
00066     *hdl = -1 ;
00067     return ;
00068   }
00069 
00070   sciSetCurrentObj( newObj ) ; 
00071   *hdl=sciGetHandle( newObj ) ; 
00072 
00073   /* if the window has been cleared we must redraw everything */
00074   if ( redraw )
00075   {
00076     sciDrawObjIfRequired( sciGetCurrentFigure() ) ;
00077   }
00078 
00079 }
00080 
00081 
00082 /*----------------------------------------------
00083  * Objarc : 
00084  *-----------------------------------------------*/
00085 
00086 void Objarc( int    * angle1    ,
00087              int    * angle2    ,
00088              double * x         ,
00089              double * y         ,
00090              double * width     ,
00091              double * height    ,
00092              int    * foreground,
00093              int    * background,
00094              BOOL     isfilled  ,
00095              BOOL     isline    ,
00096              long   * hdl        )
00097 { 
00098   BOOL redraw = FALSE ;
00099   sciPointObj *psubwin, *pobj;
00100   psubwin = sciGetCurrentSubWin() ;
00101 
00102   redraw = checkRedrawing() ;
00103   
00104   sciSetCurrentObj (ConstructArc
00105          (psubwin,*x,*y,
00106           *height, *width, *angle1, *angle2, foreground, background, isfilled, isline));
00107   pobj = sciGetCurrentObj();
00108  
00109   *hdl=sciGetHandle(pobj);
00110   
00111   /* if the window has been cleared we must redraw everything */
00112   if ( redraw )
00113   {
00114     sciDrawObjIfRequired( sciGetCurrentFigure() ) ;
00115   }
00116   else
00117   {
00118     sciDrawObjIfRequired( pobj ) ;
00119   }
00120 
00121  
00122 }
00123 
00124 /*------------------------------------------------
00125  * Objpoly : 
00126  *-----------------------------------------------*/
00127 
00128 void Objpoly ( double  * x     ,
00129                double  * y     ,
00130                integer   n     ,
00131                integer   closed,
00132                int       mark  ,
00133                long    * hdl    )
00134 { 
00135   BOOL redraw = FALSE ;
00136   sciPointObj *psubwin, *pobj;
00137   psubwin = sciGetCurrentSubWin();  
00138 
00139   redraw = checkRedrawing() ;
00140   
00141   if (mark <= 0)
00142     { 
00143       int absmark = abs(mark);
00144       sciSetCurrentObj (ConstructPolyline(psubwin,x,y,PD0,closed,n,1,1,
00145                                           NULL,NULL,&absmark,NULL,NULL,FALSE,FALSE,TRUE,FALSE));
00146     }
00147   else
00148     {
00149       sciSetCurrentObj (ConstructPolyline(psubwin,x,y,PD0,closed,n,1,1,
00150                                           &mark,NULL,NULL,NULL,NULL,TRUE,FALSE,FALSE,FALSE));
00151     }
00152   
00153    pobj = sciGetCurrentObj();
00154    *hdl=sciGetHandle(pobj);
00155 
00156    if ( redraw )
00157    {
00158      sciDrawObjIfRequired( sciGetCurrentFigure() ) ;
00159    }
00160 }
00161   
00162 
00163 /*------------------------------------------------
00164  * Objfpoly : 
00165  *-----------------------------------------------*/
00166 
00167 void Objfpoly ( double  * x    ,
00168                 double  * y    ,
00169                 integer   n    ,
00170                 integer * style,
00171                 long    * hdl  ,
00172                 integer   shading )
00173 { 
00174   BOOL redraw = FALSE ;
00175   int fillcolor, contourcolor;
00176   sciPointObj *psubwin, *pobj;
00177   int closed = 1; /* we close the polyline by default */
00178   psubwin = sciGetCurrentSubWin();
00179   
00180   redraw = checkRedrawing() ;
00181 
00182   if(shading == 2)
00183     {
00184       /* interpolated shading is "on" */
00185       sciSetCurrentObj (ConstructPolyline(psubwin,x,y,PD0,closed,n,
00186                                           1,1,NULL,style,NULL,NULL,NULL,FALSE,TRUE,FALSE,TRUE));
00187     }
00188   else
00189     {
00190       /* flat mode is "on" */
00191       if (*style < 0){
00192         fillcolor = abs(*style);
00193         sciSetCurrentObj (ConstructPolyline(psubwin,x,y,PD0,closed,n,
00194                                             1,1,NULL,&fillcolor,NULL,NULL,NULL,FALSE,TRUE,FALSE,FALSE));
00195       }
00196       else if (*style == 0){
00197         contourcolor = sciGetForeground(psubwin);
00198         sciSetCurrentObj (ConstructPolyline(psubwin,x,y,PD0,closed,n,
00199                                             1,1,&contourcolor,NULL,NULL,NULL,NULL,TRUE,FALSE,FALSE,FALSE));
00200       }
00201       else{ /* *style > 0*/
00202         fillcolor = *style;
00203         contourcolor = sciGetForeground(psubwin);
00204         sciSetCurrentObj (ConstructPolyline(psubwin,x,y,PD0,closed,n,
00205                                             1,1,&contourcolor,&fillcolor,NULL,NULL,NULL,TRUE,TRUE,FALSE,FALSE));
00206       }
00207       
00208       pobj = sciGetCurrentObj();
00209       *hdl=sciGetHandle(sciGetCurrentObj ());  
00210     }
00211   
00212   if ( redraw )
00213   {
00214     sciDrawObjIfRequired( sciGetCurrentFigure() ) ;
00215   }
00216 
00217 }
00218 
00219 
00220 /*-----------------------------------------------------------
00221  *   Objsegs :
00222  *-----------------------------------------------------------*/
00223 void Objsegs ( integer * style,
00224                integer   flag ,
00225                integer   n1   ,
00226                double  * x    ,
00227                double  * y    ,
00228                double    arsize )
00229 {
00230   BOOL redraw = FALSE ;
00231   integer type=0,n2, colored=0;
00232   double *fx,*fy,arfact=1.0;
00233   int typeofchamp = -1; /* no champ here, only segs ; this info is useless */
00234   sciPointObj *psubwin = sciGetCurrentSubWin();
00235 
00236   redraw = checkRedrawing() ;
00237 
00238   n2=n1;
00239   fx=x;fy=y;
00240   sciSetCurrentObj (ConstructSegs(psubwin,type,
00241                                   x,y,n1,n2,fx,fy,flag,style,arsize,colored,arfact,typeofchamp));
00242   if ( redraw )
00243   {
00244     sciDrawObjIfRequired( sciGetCurrentFigure() ) ;
00245   }
00246   else
00247   {
00248     sciDrawObjIfRequired(sciGetCurrentObj ());
00249   }
00250 }
00251 /*-----------------------------------------------------------
00252  * Objstring:
00253  *-----------------------------------------------------------*/
00254 
00255 /* box is an OUTPUT re-used inside matdes.c in scixstring */
00256 void Objstring( char            ** fname      ,
00257                 int                nbRow      ,
00258                 int                nbCol      ,
00259                 double             x          ,
00260                 double             y          ,
00261                 double           * angle      ,
00262                 double             box[4]     ,
00263                 BOOL               autoSize   ,
00264                 double             userSize[2],
00265                 long             * hdl        ,
00266                 BOOL               centerPos  ,
00267                 int              * foreground ,
00268                 int              * background ,
00269                 BOOL               isboxed    ,
00270                 BOOL               isline     ,
00271                 BOOL               isfilled   ,
00272                 sciTextAlignment   alignment   )
00273 {
00274   BOOL redraw = FALSE ;
00275   integer v;
00276   double dv;
00277   integer x1,yy1,n=1,rect1[4];
00278   sciPointObj *psubwin, *pobj;
00279   
00280    
00281   psubwin = sciGetCurrentSubWin();
00282 
00283   redraw = checkRedrawing() ;
00284 
00285   sciSetCurrentObj( ConstructText( psubwin   ,
00286                                    fname     ,
00287                                    nbRow     ,
00288                                    nbCol     ,
00289                                    x         ,
00290                                    y         ,
00291                                    autoSize  ,
00292                                    userSize  ,
00293                                    centerPos ,
00294                                    foreground,
00295                                    background,
00296                                    isboxed   ,
00297                                    isline    ,
00298                                    isfilled  ,
00299                                    alignment  ) ) ;
00300   pobj=sciGetCurrentObj ();
00301   *hdl= sciGetHandle(pobj);
00302   sciSetFontOrientation (pobj, (int) (*angle *  10)); 
00303 
00304   if ( redraw )
00305   {
00306     sciDrawObjIfRequired( sciGetCurrentFigure() ) ;
00307   }
00308   else
00309   {
00310     sciDrawObjIfRequired(pobj);
00311   }
00312 
00313   updateScaleIfRequired( sciGetParentSubwin( pobj ) ) ;
00314   x1 = XDouble2Pixel(x);
00315   yy1 = YDouble2Pixel(y);
00316   C2F(dr)("xstringl",fname[0],&x1,&yy1,rect1,&v,&v,&v,&dv,&dv,&dv,&dv,9L,0L);
00317   C2F(echelle2d)(box,box+1,rect1,rect1+1,&n,&n,"i2f",3L);
00318   C2F(echelle2dl)(box+2,box+3,rect1+2,rect1+3,&n,&n,"i2f");
00319  
00320 }
00321 /*-----------------------------------------------------------
00322  * Objtitle:
00323  *-----------------------------------------------------------*/
00324 
00325 void Objtitle( char * str,
00326                int    n  ,
00327                long * hdl )
00328 { 
00329   BOOL redraw = FALSE ;
00330   redraw = checkRedrawing() ;
00331   sciSetCurrentObj (ConstructTitle
00332                 (sciGetCurrentSubWin(),str,n));
00333   
00334   *hdl=sciGetHandle(sciGetCurrentObj ());
00335   if ( redraw )
00336   {
00337     sciDrawObjIfRequired( sciGetCurrentFigure() ) ;
00338   }
00339   else
00340   {
00341     sciDrawObjIfRequired(sciGetCurrentObj ()) ;
00342   }
00343 }
00344 
00345 
00346 /*------------------------------------------------
00347  *  plot2d 
00348  *-----------------------------------------------*/   
00349 
00350 void Objplot2d ( int       ptype     ,
00351                  char      logflags[],
00352                  double    x[]       ,
00353                  double    y[]       ,
00354                  integer * n1        ,
00355                  integer * n2        ,
00356                  integer   style[]   ,
00357                  char      strflag[] ,
00358                  char      legend[]  ,
00359                  double    brect[]   ,
00360                  integer   aaint[]   ,
00361                  BOOL      flagNax    )
00362 {
00363   plot2dn(ptype,logflags,x,y,n1,n2,style,strflag,legend,brect,aaint,flagNax,4L,bsiz);
00364 }
00365 
00366 /*------------------------------------------------
00367  *  grayplot
00368  *-----------------------------------------------*/   
00369 void Objgrayplot ( double    x[]      ,
00370                    double    y[]      ,
00371                    double    z[]      ,
00372                    integer * n1       ,
00373                    integer * n2       ,
00374                    char      strflag[],
00375                    double    brect[]  ,
00376                    integer   aaint[]  ,
00377                    BOOL      flagNax   ) 
00378 { 
00379   C2F(xgray)(x,y,z,n1,n2,strflag, brect, aaint, flagNax, bsiz );       
00380 }
00381 
00382 /*------------------------------------------------
00383  *  Matplot
00384  *-----------------------------------------------*/   
00385 void Objmatplot (double    z[]      ,
00386                  integer * n1       ,
00387                  integer * n2       ,
00388                  char      strflag[],
00389                  double    brect[]  ,
00390                  integer    aaint[]  ,
00391                  BOOL      flagNax   ) 
00392 { 
00393   C2F(xgray1)(z,n1,n2,strflag, brect, aaint, flagNax, bsiz);
00394 }
00395 
00396 /*------------------------------------------------
00397  *  Matplot1
00398  *-----------------------------------------------*/   
00399 void Objmatplot1 ( double    z[],
00400                    integer * n1 ,
00401                    integer * n2 ,
00402                    double    xrect[] ) 
00403 { 
00404   C2F(xgray2)(z, n1, n2,xrect);
00405 }
00406 
00407 /*------------------------------------------------
00408  *  plot3d 
00409  *-----------------------------------------------*/   
00410 void Objplot3d ( char    * fname ,
00411                  integer * isfac ,
00412                  integer * izcol ,
00413                  double    x[]   ,
00414                  double    y[]   ,
00415                  double    z[]   ,
00416                  double  * zcol  ,
00417                  integer * m     ,
00418                  integer * n     ,
00419                  double  * theta ,
00420                  double  * alpha ,
00421                  char    * legend,
00422                  integer * iflag ,
00423                  double  * ebox  ,
00424                  integer * m1    , /*Adding F.Leray 12.03.04 and 19.03.04*/
00425                  integer * n1    ,
00426                  integer * m2    ,
00427                  integer * n2    ,
00428                  integer * m3    ,
00429                  integer * n3    ,
00430                  integer * m3n   ,
00431                  integer * n3n    )
00432      /* F.Leray 25.04.05 : warning here legends means "X@Y@Z": it is labels writings!! */
00433      /* legends has not the same meaning than inside plot2dn (there, it is really the legends of the plotted curves)*/
00434 {
00435   sciTypeOf3D typeof3d;
00436   integer flagcolor;  
00437   long *hdltab;
00438   int i, mn;
00439   BOOL needMerge = FALSE ;
00440   sciPointObj *psubwin = NULL, *pobj = NULL;
00441   double drect[6];
00442   char * loc = NULL;
00443   char * legx = NULL;
00444   char * legy = NULL;
00445   char * legz = NULL;
00446   /*   char * buff = NULL; */
00447   int flag_x = 1;
00448   int flag_y = 1;
00449   int dimvectx = -1;
00450   int dimvecty = -1;
00451 
00452   sciPointObj  * pNewSurface = NULL ;
00453   sciSubWindow * ppsubwin = NULL;
00454   BOOL bounds_changed = FALSE; /* cannot be used here because we have to force redrawing since there is no way to avoid merge (=> complete redraaw) */
00455 
00456   /* Initialisation drect A.C pour debuggueur */
00457   drect[0]=0;
00458   drect[1]=0;
00459   drect[2]=0;
00460   drect[3]=0;
00461   drect[4]=0;
00462   drect[5]=0;
00463 
00464   /* =================================================
00465    * Force SubWindow properties according to arguments 
00466    * ================================================= */
00467 
00468   psubwin= sciGetCurrentSubWin();
00469 
00470   checkRedrawing() ;
00471   
00472   /* Force psubwin->is3d to TRUE: we are in 3D mode */
00473   pSUBWIN_FEATURE (psubwin)->is3d = TRUE;
00474   pSUBWIN_FEATURE (psubwin)->project[2] = 1; /* to force z axis display */
00475 
00476   ppsubwin = pSUBWIN_FEATURE(psubwin);
00477 
00478   if ( legend != NULL )
00479   {
00480     /* F.Leray 25.04.05 replace the default labels by the user labels if specified */
00481     loc=(char *) MALLOC( (strlen(legend)+1)*sizeof(char));
00482     if ( loc == NULL)    
00483       sciprint("Objplot3d : No more Place to store all the labels\n");
00484   
00485     strcpy(loc,legend);
00486   
00487     /*   legx=strtok_r(loc,"@",&buff); */
00488     legx=strtok(loc,"@");
00489   
00490     if (legx != NULL)
00491     {
00492       sciSetText( ppsubwin->mon_x_label, &legx , 1, 1 ) ;
00493     }
00494    
00495     /*   legy=strtok_r((char *)0,"@",&buff); */
00496     legy=strtok((char *)NULL,"@"); /* NULL to begin at the last read character */
00497     if ( legy != NULL )
00498     {
00499       sciSetText( ppsubwin->mon_y_label, &legy , 1, 1 ) ;
00500     }
00501  
00502     /*   legz=strtok_r((char *)0,"@",&buff); */
00503     legz=strtok((char *)NULL,"@");
00504     if ( legz != NULL )
00505     {
00506       sciSetText( ppsubwin->mon_z_label, &legz , 1, 1 ) ;
00507     }
00508   }
00509    
00510   /* Force psubwin->logflags to linear */
00511   pSUBWIN_FEATURE (psubwin)->logflags[0]='n';
00512   pSUBWIN_FEATURE (psubwin)->logflags[1]='n';
00513   pSUBWIN_FEATURE (psubwin)->logflags[2]='n'; /* add z logscale default here */
00514  
00515   
00516   pSUBWIN_FEATURE (psubwin)->axes.flag[0] = iflag[0]; /* mode: treatment of hidden parts */
00517   if (iflag[1] != 0){
00518     if (iflag[1]<7)
00519       pSUBWIN_FEATURE (psubwin)->axes.flag[1] = iflag[1]; /* type: scaling (no more useful)  */
00520     else
00521       pSUBWIN_FEATURE (psubwin)->axes.flag[1] = iflag[1]-6; /* type: scaling (no more useful)  */
00522   }
00523   
00524   if( pSUBWIN_FEATURE (psubwin)->FirstPlot == FALSE && (iflag[2] == 0 || iflag[2] == 1))
00525   { 
00526     /* Nothing to do: we leave as before */
00527   }
00528   else
00529   {
00530     pSUBWIN_FEATURE (psubwin)->axes.flag[2] = iflag[2]; /* box: frame around the plot      */
00531     
00532     if(iflag[2] == 0 || iflag[2] == 1)
00533     {
00534       
00535       if (pSUBWIN_FEATURE(psubwin)->FirstPlot)
00536       {
00537         pSUBWIN_FEATURE (psubwin)->axes.axes_visible[0] = FALSE;
00538         pSUBWIN_FEATURE (psubwin)->axes.axes_visible[1] = FALSE;
00539         pSUBWIN_FEATURE (psubwin)->axes.axes_visible[2] = FALSE;
00540         pSUBWIN_FEATURE (psubwin)->axes.rect = BT_OFF ;
00541 
00542         sciSetVisibility(pSUBWIN_FEATURE (psubwin)->mon_x_label,FALSE);
00543         sciSetVisibility(pSUBWIN_FEATURE (psubwin)->mon_y_label,FALSE);
00544         sciSetVisibility(pSUBWIN_FEATURE (psubwin)->mon_z_label,FALSE);
00545       }
00546       /*else no changes : the axes visible properties are driven by the previous plot */
00547     }
00548     else if(iflag[2] == 3)
00549     {
00550       pSUBWIN_FEATURE (psubwin)->axes.rect = BT_ON ; /* for 2d use only (when switching to 2d mode) */
00551       
00552       pSUBWIN_FEATURE (psubwin)->axes.axes_visible[0] = FALSE;
00553       pSUBWIN_FEATURE (psubwin)->axes.axes_visible[1] = FALSE;
00554       pSUBWIN_FEATURE (psubwin)->axes.axes_visible[2] = FALSE;
00555       
00556       sciSetVisibility(pSUBWIN_FEATURE (psubwin)->mon_x_label,TRUE);
00557       sciSetVisibility(pSUBWIN_FEATURE (psubwin)->mon_y_label,TRUE);
00558       sciSetVisibility(pSUBWIN_FEATURE (psubwin)->mon_z_label,TRUE);
00559     }
00560     else if(iflag[2] == 4)
00561     {
00562       pSUBWIN_FEATURE (psubwin)->axes.rect = BT_ON ;
00563       
00564       pSUBWIN_FEATURE (psubwin)->axes.axes_visible[0] = TRUE;
00565       pSUBWIN_FEATURE (psubwin)->axes.axes_visible[1] = TRUE;
00566       pSUBWIN_FEATURE (psubwin)->axes.axes_visible[2] = TRUE;
00567       
00568       sciSetVisibility(pSUBWIN_FEATURE (psubwin)->mon_x_label,TRUE);
00569       sciSetVisibility(pSUBWIN_FEATURE (psubwin)->mon_y_label,TRUE);
00570       sciSetVisibility(pSUBWIN_FEATURE (psubwin)->mon_z_label,TRUE);
00571     }
00572   }
00573 
00574   pSUBWIN_FEATURE (psubwin)->alpha  = *alpha;
00575   pSUBWIN_FEATURE (psubwin)->theta  = *theta; 
00576 
00577   if ( ChildrenCounter(psubwin) > 0 )
00578   { 
00579     needMerge = TRUE ;
00580   }
00581   
00582   if ((sciGetGraphicMode (psubwin)->autoscaling)) {
00583     /* compute and merge new specified bounds with psubwin->Srect */
00584     switch (iflag[1])  {
00585     case 0:  /* do not change psubwin->Srect */
00586       break;
00587     case 1 : case 3 : case 5 : case 7 : /* Force psubwin->Srect=ebox */
00588       drect[0] = ebox[0]; /*xmin*/
00589       drect[2] = ebox[2]; /*ymin*/
00590       drect[1] = ebox[1]; /*xmax*/
00591       drect[3] = ebox[3]; /*ymax*/
00592       drect[4] = ebox[4]; /*zmin*/
00593       drect[5] = ebox[5]; /*zmax*/
00594       break;
00595     case 2 : case 4 : case 6 : case 8:/* Force psubwin->Srect to the x and y bounds */
00596       mn=(*m1) * (*n1); 
00597       drect[0] = (double) Mini(x, mn); /*xmin*/
00598       drect[1] = (double) Maxi(x, mn); /*xmax*/
00599       mn=(*m2) * (*n2); 
00600       drect[2] = (double) Mini(y, mn); /*ymin*/
00601       drect[3] = (double) Maxi(y, mn); /*ymax*/
00602       mn=(*m3) * (*n3); 
00603       drect[4] = (double) Mini(z, mn); /*zmin*/
00604       drect[5] = (double) Maxi(z, mn); /*zmax*/
00605       break;
00606     }
00607     if (!pSUBWIN_FEATURE(psubwin)->FirstPlot ) { /* merge psubwin->Srect and drect */
00608       drect[0] = Min(pSUBWIN_FEATURE(psubwin)->SRect[0],drect[0]); /*xmin*/
00609       drect[1] = Max(pSUBWIN_FEATURE(psubwin)->SRect[1],drect[1]); /*xmax*/
00610       drect[2] = Min(pSUBWIN_FEATURE(psubwin)->SRect[2],drect[2]); /*ymin*/
00611       drect[3] = Max(pSUBWIN_FEATURE(psubwin)->SRect[3],drect[3]); /*ymax*/
00612       drect[4] = Min(pSUBWIN_FEATURE(psubwin)->SRect[4],drect[4]); /*zmin*/
00613       drect[5] = Max(pSUBWIN_FEATURE(psubwin)->SRect[5],drect[5]); /*zmax*/
00614     }
00615     if (iflag[1] != 0) 
00616       bounds_changed = update_specification_bounds(psubwin, drect,3);
00617   } 
00618   
00619   if(iflag[1] != 0)
00620     pSUBWIN_FEATURE(psubwin)->isoview = (BOOL)( iflag[1] == 3 || iflag[1] == 4 ||
00621                                                 iflag[1] == 5 || iflag[1] == 6);
00622   
00623   /* =================================================
00624    * Analyze arguments to find entity type 
00625    * ================================================= */
00626 
00627   if (*isfac== 1) { 
00628     if (*izcol == 0) { 
00629       if (strcmp(fname,"plot3d1")==0) {typeof3d = SCI_FAC3D;   flagcolor=1;}
00630       else                               {typeof3d = SCI_FAC3D;   flagcolor=0;}
00631     }
00632     else if (*izcol == 2)                {typeof3d = SCI_FAC3D;   flagcolor=3;}
00633     else                                 {typeof3d = SCI_FAC3D;   flagcolor=2;}
00634   } 
00635   else  if  (*isfac== 0) {
00636     if (strcmp(fname,"plot3d1")==0)   {typeof3d = SCI_PLOT3D;  flagcolor=1;}
00637     else                                 {typeof3d = SCI_PLOT3D;  flagcolor=0;}
00638   }
00639   else                                   {typeof3d = SCI_PARAM3D1;flagcolor=1;}
00640 
00641 
00642   /* =================================================
00643    * Construct the Entities
00644    * ================================================= */
00645 
00646   if ( typeof3d != SCI_PARAM3D1 ) {/*Distinction here between SCI_PARAM3D1 and others*/
00647 
00648 
00649     if ( *isfac == 1 )
00650     {
00651       /* x is considered as a matrix */
00652       dimvectx = -1 ;
00653     }
00654     else if ( *m1 == 1 ) /* x is a row vector */
00655     {
00656       dimvectx = *n1;
00657     }
00658     else if ( *n1 == 1 ) /* x is a column vector */
00659     {
00660       dimvectx = *m1;
00661     }
00662     else /* x is a matrix */
00663     {
00664       dimvectx = -1;
00665     }
00666 
00667     if ( dimvectx > 1 )
00668     {
00669       int monotony = checkMonotony( x, dimvectx ) ;
00670       if ( monotony == 0 )
00671       {
00672         sciprint("Objplot3d: x vector is not monotonous \t\n.");
00673         return;
00674       }
00675 
00676       flag_x = monotony ;
00677     }
00678     
00679     if ( *isfac == 1 )
00680     {
00681       /* y is considered as a matrix */
00682       dimvecty = -1 ;
00683     }
00684     else if ( *m2 == 1 ) /* y is a row vector */
00685     {
00686       dimvecty = *n2 ;
00687     }
00688     else if ( *n2 == 1 ) /* y is a column vector */
00689     {
00690       dimvecty = *m2 ;
00691     }
00692     else /* y is a matrix */
00693     {
00694       dimvecty = -1 ;
00695     }
00696    
00697     if( dimvecty > 1 )
00698     {
00699       /* test the monotony on y*/
00700       int monotony = checkMonotony( y, dimvecty ) ;
00701       if ( monotony == 0 )
00702       {
00703         sciprint("Objplot3d: x vector is not monotonous \t\n.");
00704         return ;
00705       }
00706 
00707       flag_y = monotony ;
00708     }
00709     
00710     pNewSurface = ConstructSurface( psubwin, typeof3d,
00711                                     x, y, z, zcol, *izcol, *m, *n, iflag,ebox,flagcolor,
00712                                     isfac,m1,n1,m2,n2,m3,n3,m3n,n3n) ;
00713     
00714     if ( pNewSurface == NULL ) { return ; }
00715 
00716     sciSetCurrentObj( pNewSurface ) ;
00717     
00718     pSURFACE_FEATURE (sciGetCurrentObj())->flag_x = flag_x;
00719     pSURFACE_FEATURE (sciGetCurrentObj())->flag_y = flag_y;
00720     
00721     
00722   }
00723   else
00724     {
00725       if ((hdltab = MALLOC (*n * sizeof (long))) == NULL) {
00726         Scierror(999,"%s: No more memory available\r\n",fname);
00727         return; 
00728       }
00729       for (i = 0; i < *n; ++i) { 
00730         /* F.Leray Pb here: In fact we do not create a Surface but one or several 3D Polylines
00731            Pb comes when wanting to access the fields "surface_color" or "flag" for example
00732            in function sciSet (cf. matdes.c). 
00733            Question 1: Are these properties accessible from a SCI_PARAM3D1 ?
00734            Question 2: Is "flag" obsolete and replaced by "color_mode"?*/
00735 
00736         if ((*n > 0) && (zcol != (double *)NULL)) {
00737           if ((int) zcol[i] > 0){
00738             int intzcol = (int) zcol[i];
00739             sciSetCurrentObj (ConstructPolyline
00740                               (sciGetCurrentSubWin(),
00741                                &(x[*m * i]),&(y[*m * i]),&(z[*m * i]),0,*m,*n,1,
00742                                &intzcol,NULL,NULL,NULL,NULL,TRUE,FALSE,FALSE,FALSE));  
00743           }
00744           else {
00745             int intzcol = (int) -zcol[i];
00746             sciSetCurrentObj (ConstructPolyline
00747                               (sciGetCurrentSubWin(),
00748                                &(x[*m * i]),&(y[*m * i]),&(z[*m * i]),0,*m,*n,1,
00749                                NULL,NULL,&intzcol,NULL,NULL,FALSE,FALSE,TRUE,FALSE));  
00750           }
00751         }
00752         else { /* default case, nothing is given */
00753           int curcolor = sciGetForeground(sciGetCurrentSubWin()); /* current color equivalent for new graphics mode */
00754           sciSetCurrentObj (ConstructPolyline
00755                             (sciGetCurrentSubWin(),
00756                              &(x[*m * i]),&(y[*m * i]),&(z[*m * i]),0,*m,*n,1,
00757                              &curcolor,NULL,NULL,NULL,NULL,TRUE,FALSE,FALSE,FALSE));  
00758         }
00759 
00760         pobj = sciGetCurrentObj();
00761         
00762         hdltab[i]=sciGetHandle(pobj); 
00763       }
00764 
00765 
00767       if ( *n>1 ) sciSetCurrentObj (ConstructCompound (hdltab, *n));  
00768       FREE(hdltab);
00769     }
00770 
00771   /* =================================================
00772    * Merge with previous 3D plots (build a set of facets)
00773    * ================================================= */
00774 
00775   if ( needMerge )
00776   {
00777     Merge3d( psubwin ) ;
00778   }
00779 
00780   /* =================================================
00781    * Redraw Figure
00782    * ================================================= */
00783 
00784   sciDrawObj(sciGetCurrentFigure ());
00785   pSUBWIN_FEATURE(psubwin)->FirstPlot=FALSE;
00786    
00787   FREE(loc); loc = NULL;
00788 
00789 }
00790 /*-----------------------------------------------------------
00791  * Objaxis:
00792  *-----------------------------------------------------------*/
00793 
00794 void Objdrawaxis ( char     dir    ,
00795                    char     tics   ,
00796                    double * x      ,
00797                    int    * nx     ,
00798                    double * y      ,
00799                    int    * ny     ,
00800                    char   * val[]  ,
00801                    int      subint ,
00802                    char   * format ,
00803                    int      font   ,
00804                    int      textcol,
00805                    int      ticscol,
00806                    char     flag   ,
00807                    int      seg    ,
00808                    int      nb_tics_labels )
00809 {
00810   BOOL redraw = FALSE ;
00811   redraw = checkRedrawing() ;
00812   sciSetCurrentObj (ConstructAxes 
00813                     ((sciPointObj *)
00814                      sciGetCurrentSubWin(),
00815                      dir,tics,x,*nx,y,*ny,val,subint,format,font,textcol,ticscol,flag,seg,nb_tics_labels));  
00816   sciDrawObjIfRequired(sciGetCurrentObj ());
00817   
00818   if ( redraw )
00819   {
00820     sciDrawObjIfRequired( sciGetCurrentFigure() ) ;
00821   }
00822 
00823   /* F.Leray 10.03.04: In fact we use ConstructAxes AND NOT ConstructAxis to draw
00824      one axis. ConstructAxis is apparently unused!!*/
00825      
00826 }
00827 
00828 /*-----------------------------------------------------------
00829  * Objnumb:
00830  *-----------------------------------------------------------*/
00831 
00832 void Objnumb( char          * fname    ,
00833               unsigned long   fname_len,
00834               integer         n        ,
00835               integer         flag     ,
00836               double          x        ,
00837               double          y        ,
00838               double        * angle    ,
00839               double        * box       )
00840 { 
00841   /*** faire une macro scilab sur xstring ****/
00842 
00843    
00844 }
00845 
00846 /*------------------------------------------------
00847  * fec
00848  *-----------------------------------------------*/   
00849 void Objfec ( double    x[]        ,
00850               double    y[]        ,
00851               double    noeud[]    ,
00852               double  * fun        ,
00853               integer * n          ,
00854               integer * m          ,
00855               char      strflag[]  ,
00856               char      legend[]   ,
00857               double    brect[]    ,
00858               integer   aaint[]    ,
00859               double    Zminmax[]  ,
00860               integer   Colminmax[],
00861               integer   ColOut[]   ,
00862               BOOL      WithMesh   ,
00863               BOOL      flagNax     )
00864 {
00865   C2F(fec)(x,y,noeud,fun,n,m,strflag,legend,brect,aaint,
00866            Zminmax,Colminmax,ColOut,WithMesh,flagNax,4L,bsiz);
00867 }

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