1 /*------------------------------------------------------------------------
4 * newGraph Library header
5 * Matthieu PHILIPPE, INRIA 2001-2002
6 * Djalel ABDEMOUCHE, INRIA 2002-2004
7 * Fabrice Leray, INRIA 2004-2006
8 * Jean-Baptiste Silvy, INRIA 2006-xxxxdrawmerge
10 * This file contains all functions used to Draw the content of a window.
11 * The main functions is sciDrawObj that draws the objects recursively.
12 ------------------------------------------------------------------------/-*/
22 #include "DrawObjects.h"
23 #include "GetProperty.h"
25 #include "SetProperty.h"
26 #include "BuildObjects.h"
27 #include "DestroyObjects.h"
28 #include "ObjectStructure.h"
32 #include "StringBox.h"
33 #include "handleDrawing/drawTextEntity.h"
34 #include "handleDrawing/drawFigureEntity.h"
35 #include "handleDrawing/drawSubWinEntity.h"
36 #include "handleDrawing/drawCompoundEntity.h"
37 #include "handleDrawing/drawLegendEntity.h"
38 #include "handleDrawing/drawFecEntity.h"
39 #include "handleDrawing/drawSegsEntity.h"
40 #include "handleDrawing/drawGrayplotEntity.h"
41 #include "handleDrawing/drawPolylineEntity.h"
42 #include "handleDrawing/drawArcEntity.h"
43 #include "handleDrawing/drawRectangleEntity.h"
44 #include "handleDrawing/drawAxesEntity.h"
45 #include "handleDrawing/drawMergeEntity.h"
46 #include "handleDrawing/drawSurfaceEntity.h"
47 #include "periScreen.h" /* to be removed */
49 #include "axesScale.h"
51 #include "math_graphics.h"
52 #include "graphicSession.h"
54 #include "axesScale.h"
55 #include "drawMarks.h"
56 #include "BasicAlgos.h"
58 #include "MALLOC.h" /* MALLOC */
61 #include "../../../tclsci/includes/GedManagement.h"
65 extern HDC TryToGetDC(HWND hWnd);
68 #define round(a) (int)(((a)<0.0)?(a)-.5:(a)+.5)
70 extern double C2F(dsort)();/*DJ.A merge*/
71 extern int scilab_shade(integer *polyx, integer *polyy, integer *fill, integer polysize, integer flag);
72 extern void xstringb_angle (char *string, integer x, integer y, integer w, integer h, double angle);
73 extern void xstringb_bbox (char *string, integer x, integer y, integer w, integer h, double angle, int *bbox);
75 extern void Scistring (char *str);
78 void GradFixedlog( double minVal, double maxVal, double * ticks, int nbGrads );
79 int sciGetLogExponent( double minBound, double maxBound, double * expMin, double * expMax );
81 unsigned short defcolors[] = {
82 0, 0, 0, /* Black: DEFAULTBLACK */
84 0, 255, 0, /* Green */
85 0, 255, 255, /* Cyan */
87 255, 0, 255, /* Magenta */
88 255, 255, 0, /* Yellow */
89 255, 255, 255, /* White: DEFAULTWHITE */
90 0, 0, 144, /* Blue4 */
91 0, 0, 176, /* Blue3 */
92 0, 0, 208, /* Blue2 */
93 135, 206, 255, /* LtBlue */
94 0, 144, 0, /* Green4 */
95 0, 176, 0, /* Green3 */
96 0, 208, 0, /* Green2 */
97 0, 144, 144, /* Cyan4 */
98 0, 176, 176, /* Cyan3 */
99 0, 208, 208, /* Cyan2 */
100 144, 0, 0, /* Red4 */
101 176, 0, 0, /* Red3 */
102 208, 0, 0, /* Red2 */
103 144, 0, 144, /* Magenta4 */
104 176, 0, 176, /* Magenta3 */
105 208, 0, 208, /* Magenta2 */
106 128, 48, 0, /* Brown4 */
107 160, 64, 0, /* Brown3 */
108 192, 96, 0, /* Brown2 */
109 255, 128, 128, /* Pink4 */
110 255, 160, 160, /* Pink3 */
111 255, 192, 192, /* Pink2 */
112 255, 224, 224, /* Pink */
113 255, 215, 0 /* Gold */
118 int get_cf_type(void)
123 void set_cf_type(int val)
131 * Returns the HDC of the figure window (not the parent)
134 HDC /* BCG Type priWin !! decommente par SS ???? */
135 sciGetDC (sciPointObj * pobj)
137 switch (sciGetEntityType (pobj))
141 return (HDC)TryToGetDC (sciGetScilabXgc (pobj)->CWindow);
144 return sciGetDC (sciGetParent (pobj));
147 return (HDC ) NULL; /* Type HDC ! "periWin-bgc"*/
152 void sciRedrawFigure()
155 sciDrawObj (sciGetCurrentFigure ());
156 sciSetReplay (FALSE);
160 void sciRedrawF(value)
164 integer cur,na,verb=0;
165 figure= (sciPointObj *) sciIsExistingFigure(value);
166 /* F.Leray 13.04.04 : Test if returned sciPointObj* is NULL (means Figure has been destroyed) */
168 if(figure == (sciPointObj *) NULL)
174 C2F (dr) ("xget", "window",&verb,&cur,&na,PI0,PI0,PI0,PD0,PD0,PD0,PD0,4L,6L);
175 C2F (dr) ("xset", "window",value,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,4L,6L);
176 /* sciSetCurrentObj(figure); */ /*F.Leray 25.03.04*/
179 sciSetReplay (FALSE);
180 C2F (dr) ("xset", "window",&cur,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,4L,6L);
186 static sciPointObj *mafigure;
187 static sciPointObj *masousfen;
189 mafigure= (sciPointObj *) sciGetCurrentFigure();
190 DestroyAllGraphicsSons((sciPointObj *)mafigure);
193 if ((masousfen = ConstructSubWin (mafigure, 'o')) != NULL){
194 sciSetCurrentObj(masousfen);
195 sciSetOriginalSubWin (mafigure, masousfen);}
196 sciDrawObj(sciGetCurrentFigure ());
199 /* Completely destroy the handle hierearchy */
200 /* when switching from new to old figure_style */
202 void sciXClearFigure()
204 static sciPointObj *mafigure;
205 struct BCG * XGC = (struct BCG*) NULL;
209 mafigure= (sciPointObj *) sciGetCurrentFigure();
213 /* close ged to prevent errors when using it */
214 sciDestroyGed( sciGetNum( mafigure ) ) ;
217 DestroyAllGraphicsSons((sciPointObj *)mafigure);
218 DestroyFigure (mafigure);
219 C2F(dr)("xget","gc",&verb,&v,&v,&v,&v,&v,(double *)&XGC,&dv,&dv,&dv,5L,10L);
220 XGC->mafigure = (sciPointObj *) NULL;
225 static sciPointObj *masousfen, *tmpsousfen;
228 tmpsousfen= (sciPointObj *) sciGetSelectedSubWin (sciGetCurrentFigure());
229 psonstmp = sciGetSons (sciGetCurrentFigure());
231 while (psonstmp != (sciSons *) NULL)
233 if(sciGetEntityType (psonstmp->pointobj) == SCI_SUBWIN)
235 masousfen= (sciPointObj *)psonstmp->pointobj;
236 sciSetSelectedSubWin (masousfen);
237 sciSetdrawmode (FALSE);
239 psonstmp = psonstmp->pnext;
241 sciSetSelectedSubWin (tmpsousfen);
242 sciDrawObj(sciGetCurrentFigure ());
247 static sciPointObj *masousfen, *tmpsousfen;
250 tmpsousfen= (sciPointObj *) sciGetSelectedSubWin (sciGetCurrentFigure ());
251 psonstmp = sciGetSons (sciGetCurrentFigure ());
254 while (psonstmp != (sciSons *) NULL)
256 if(sciGetEntityType (psonstmp->pointobj) == SCI_SUBWIN)
258 masousfen= (sciPointObj *)psonstmp->pointobj;
259 sciSetSelectedSubWin (masousfen);
260 sciSetdrawmode (TRUE);
262 psonstmp = psonstmp->pnext;
264 sciSetSelectedSubWin (tmpsousfen);
265 sciDrawObj(sciGetCurrentFigure ());
270 /* update the scale and retrieve the bounding box of the axis */
271 void updateScale3d( sciPointObj * pobj ,
285 integer aaint[] = {2,10,2,10} ;
286 sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
288 sci_update_frame_bounds_3d( pobj ) ;
290 dbox[0] = ppsubwin->FRect[0] ; /*xmin*/
291 dbox[1] = ppsubwin->FRect[2] ; /*xmax*/
292 dbox[2] = ppsubwin->FRect[1] ; /*ymin*/
293 dbox[3] = ppsubwin->FRect[3] ; /*ymax*/
294 dbox[4] = ppsubwin->FRect[4] ; /*zmin*/
295 dbox[5] = ppsubwin->FRect[5] ; /*zmax*/
297 if( ppsubwin->cube_scaling )
308 /** changement de coordonnees 3d */
309 flag = ( ppsubwin->axes.flag[1] + 1 ) / 2 ; /* F.Leray Adding HERE 19.04.04 */
311 Cscale.alpha = ppsubwin->alpha ;
312 Cscale.theta = ppsubwin->theta ;
314 /* update Cscale.m from the new viewing angles */
315 sciUpdateScaleAngles( ppsubwin->theta, ppsubwin->alpha ) ;
317 for ( i = 0 ; i < 6 ; i++ )
321 dbox[i] = Cscale.bbox1[i];
325 Cscale.bbox1[i] = dbox[i];
329 /* get the vertices of the axes box */
330 sciGetAxisBox( dbox, xbox, ybox, zbox ) ;
332 /** Calcul des echelles en fonction de la taille du dessin **/
333 if ( flag == 1 || flag == 3 ) /* ALL the expanded cases : flag[1] = 1 or 2 or 5 or 6 */
335 xmmin = Mini(xbox,8L) ;
336 xmmax = Maxi(xbox,8L) ; /* search for x Min/Max on all the edges (there are 8 edges that compose the box) F.Leray 13.10.04 */
337 ymmax = -Mini(ybox,8L) ; /* same thing on ybox vector ( 1) why - (minus) ? see 2) )*/
338 ymmin = -Maxi(ybox,8L);
341 if ( flag == 2 || flag == 3 ) /* ALL the isometric cases : flag[1] = 3 or 4 or 5 or 6 */
350 /* get current window size */
351 C2F(dr)("xget","wdim",&verbose,wdim,&narg, PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
352 getscale2d(WRect,FRect,logf_,ARect);
353 wmax=linint((double)wdim[0] * WRect[2]);
354 hmax=linint((double)wdim[1] * WRect[3]);
357 if ( flag == 2 ) /* the "NON expanded isometric" cases : flag[1] = 3 or 4 */
367 /* radius and center of the sphere circumscribing the box */
368 dx = dbox[1] - dbox[0] ;
369 dy = dbox[3] - dbox[2] ;
370 dz = dbox[5] - dbox[4] ;
372 R = sqrt( dx*dx + dy*dy + dz*dz)/2;
373 xo = ( xbox[0] + xbox[6] ) / 2.0 ;
374 yo = ( ybox[0] + ybox[6] ) / 2.0 ;
375 zo = ( zbox[0] + zbox[6] ) / 2.0 ;
383 if (flag==2 || flag==3)
389 if ( hx/(double)wmax < hy/(double)hmax )
392 hx1 = wmax * hy / hmax ;
393 xmmin = xmmin - ( hx1 - hx ) / 2.0 ;
394 xmmax = xmmax + ( hx1 - hx ) / 2.0 ;
399 hy1 = hmax * hx / wmax ;
400 ymmin = ymmin - ( hy1 - hy ) / 2.0 ;
401 ymmax = ymmax + ( hy1 - hy ) / 2.0 ;
405 if (flag != 0 ) /* != using current 3D scale */
408 /* FRect = [Xmin,Ymin,Xmax,Ymax] */
412 FRect[3] = -ymmin ; /* 2) ... (why - (minus) ? )*/
413 set_scale("tftttf",NULL,FRect,aaint,"nn",NULL);
414 Cscale.metric3d = flag;
420 * @author Djalel Abdemouche 10/2003
421 * Should be in Action.c file
423 void Nextind(integer ind1, integer *ind2, integer *ind3)
429 if (*ind2 == 8) *ind2 = 4;
430 if (*ind3 == 3) *ind3 = 7;
434 if (*ind2 == 4) *ind2 = 0;
435 if (*ind3 == -1) *ind3 = 3;
441 * @author F.Leray 18.10.04
442 * Should be in Axes.c file
444 int Axes3dStrings2(integer *ixbox, integer *iybox, integer *xind)
446 integer verbose=0,narg,xz[2],fontid[2],fontsize_kp,color_kp,size;
447 integer iof,barlengthx = 0,barlengthy = 0, posi[2];
448 integer rect[4],flag=0,x=0,y=0;
449 double ang=0.0, bbox[6];
450 int fontsize=-1,textcolor=-1,ticscolor=-1;
451 int fontstyle=0; /* F.Leray 08.04.04 */
452 sciPointObj *psubwin = NULL;
453 sciSubWindow * ppsubwin = NULL;
454 int ns=2,iflag=0,gstyle,gridStyle=2,dash[6];
455 double xx[4],yy[4],zz[4],vxx1,vyy1,vzz1;
456 integer i,xm,ym,vx[2],vy[2],xg[2],yg[2],j;
457 integer fontid_old[2], textcolor_old;
459 int lastzindex = 0, lastxindex = 0, lastyindex = 0;
460 double xminval, yminval, zminval, xmaxval, ymaxval, zmaxval;
464 int logrect[4], XX = 0, YY = 0; /* see below */ /* ah ouais ou ca ? */
467 int constOffset[2] ; /* displacment of labels from the axes segments. */
468 int maxTicksLabelSize[2] ; /* for each axis the maximum size of ticks label */
471 psubwin= (sciPointObj *)sciGetSelectedSubWin (sciGetCurrentFigure ());
472 ppsubwin = pSUBWIN_FEATURE (psubwin);
474 /** le cot\'e gauche ( c'est tjrs un axe des Z **/
475 xz[0] = Cscale.WIRect1[2] ;
476 xz[1] = Cscale.WIRect1[2] ;
477 iof = (xz[0]+xz[1])/50;
479 ticscolor = sciGetForeground(psubwin);
480 textcolor=sciGetFontForeground(psubwin);
482 fontsize=sciGetFontDeciWidth(psubwin)/100;
483 fontstyle=sciGetFontStyle(psubwin);
485 if(sciGetEntityType (psubwin) != SCI_SUBWIN) {
486 sciprint("Impossible case\n");
491 bbox[0] = xminval = pSUBWIN_FEATURE (psubwin)->FRect[0]; /*xmin*/
492 bbox[1] = xmaxval = pSUBWIN_FEATURE (psubwin)->FRect[2]; /*xmax*/
493 bbox[2] = yminval = pSUBWIN_FEATURE (psubwin)->FRect[1]; /*ymin*/
494 bbox[3] = ymaxval = pSUBWIN_FEATURE (psubwin)->FRect[3]; /*ymax*/
495 bbox[4] = zminval = pSUBWIN_FEATURE (psubwin)->FRect[4]; /*zmin*/
496 bbox[5] = zmaxval = pSUBWIN_FEATURE (psubwin)->FRect[5]; /*zmax*/
498 C2F(dr)("xget","font",&verbose,fontid,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
500 fontid[0]= fontstyle;
501 fontsize_kp = fontid[1] ;
502 if( fontsize == -1 ){
504 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
507 fontid[1] = fontsize ;
508 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
510 if ( textcolor != -1 || ticscolor != -1 )
511 C2F(dr)("xget","pattern",&verbose,&color_kp,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
513 for (i=0; i<3 ; i++) {
514 xx[i]=pSUBWIN_FEATURE (psubwin)->axes.xlim[i];
515 yy[i]=pSUBWIN_FEATURE (psubwin)->axes.ylim[i];
516 zz[i]=pSUBWIN_FEATURE (psubwin)->axes.zlim[i];
519 /* main title */ /* We fix the title always at the top */
520 rect[0]= Cscale.WIRect1[0] ;
521 rect[1]= Cscale.WIRect1[1] ;
522 rect[2]= Cscale.WIRect1[2] ;
523 rect[3]= Cscale.WIRect1[3]/6 ;
524 textcolor_old = textcolor;
525 fontid_old[0] = fontid[0];
526 fontid_old[1] = fontid[1];
528 constOffset[0] = Cscale.WIRect1[2] / 50 + 1 ;
529 constOffset[1] = Cscale.WIRect1[3] / 25 + 1 ;
531 if( sciGetVisibility(ppsubwin->mon_title) )
533 /* get the pointer on the title */
534 sciLabel * ppLabel = pLABEL_FEATURE( ppsubwin->mon_title ) ;
536 /* get position and orientation of the title */
537 if ( ppLabel->auto_rotation )
539 sciSetFontOrientation( ppsubwin->mon_title, 0 ) ;
542 if ( ppLabel->auto_position )
545 int segmentStart[2] = { rect[0] + rect[2], rect[1] } ;
546 int segmentEnd[2] = { rect[0] , rect[1] } ;
547 computeLabelAutoPos( ppsubwin->mon_title, segmentStart, segmentEnd, constOffset ) ;
550 drawTextEntity( ppLabel->text ) ;
553 textcolor = textcolor_old;
554 fontid[0] = fontid_old[0];
555 fontid[1] = fontid_old[1];
557 size = xz[0]>=xz[1] ? (integer) (xz[1]/50.0) : (integer) (xz[0]/50.0);
559 /* compute bounding of "10" string used for log scale ON and auto_ticks ON */
560 C2F(dr)("xstringl","10",&XX,&YY,logrect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
562 /********************************************/
563 /* draw the axis line if axes_visible is on */
564 /********************************************/
573 x2[0] = sciGetForeground (psubwin);
574 x2[2] = sciGetLineWidth (psubwin) ;
575 x2[3] = sciGetLineStyle (psubwin);
577 C2F(dr)("xget","line style",&verbose2,dash2,&narg2,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
578 C2F(dr)("xget","pattern",&verbose2,&pat,&narg2,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
579 C2F (dr) ("xset", "dashes", x2, x2, x2+4, x2+4, x2+4,PI0,PD0,PD0,PD0,PD0, 5L, 6L);
580 C2F (dr) ("xset","foreground",x2,x2,x2+4,x2+4,x2+4,PI0,PD0,PD0,PD0,PD0,5L,4096); /* F.Leray 05.03.04 Useless too*/
581 C2F (dr) ("xset","thickness",x2+2,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
582 C2F (dr) ("xset", "line style", x2+3,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
583 if ( ppsubwin->axes.axes_visible[2] )
585 /* draw the line of the axis like in 2d */
586 /* the two bounds are (ixbox[2],iybox[2]) and (ixbox[2],iybox[2]) */
587 C2F(dr)("xpolys","v",&(ixbox[2]),&(iybox[2]),x2,&one,&two, PI0,PD0,PD0,PD0,PD0,0L,0L);
589 if ( ( xind[4]+xind[5] == 3) || ( xind[4]+xind[5] == 11 ) )
591 /* i copy this test but I don't know what it mean... jb Silvy 03/2006 */
592 if ( ppsubwin->axes.axes_visible[1] )
594 /* draw the line of the axis like in 2d */
595 /* the two bounds are (ixbox[3],iybox[3]) and (ixbox[3],iybox[3]) */
596 C2F(dr)("xpolys","v",&(ixbox[3]),&(iybox[3]),x2,&one,&two, PI0,PD0,PD0,PD0,PD0,0L,0L);
598 if ( ppsubwin->axes.axes_visible[0] )
600 /* draw the line of the axis like in 2d */
601 /* the two bounds are (ixbox[4],iybox[4]) and (ixbox[4],iybox[4]) */
602 C2F(dr)("xpolys","v",&(ixbox[4]),&(iybox[4]),x2,&one,&two, PI0,PD0,PD0,PD0,PD0,0L,0L);
607 if ( ppsubwin->axes.axes_visible[1] )
609 /* draw the line of the axis like in 2d */
610 /* the two bounds are (ixbox[3],iybox[3]) and (ixbox[3],iybox[3]) */
611 C2F(dr)("xpolys","v",&(ixbox[4]),&(iybox[4]),x2,&one,&two, PI0,PD0,PD0,PD0,PD0,0L,0L);
613 if ( ppsubwin->axes.axes_visible[0] )
615 /* draw the line of the axis like in 2d */
616 /* the two bounds are (ixbox[4],iybox[4]) and (ixbox[4],iybox[4]) */
617 C2F(dr)("xpolys","v",&(ixbox[3]),&(iybox[3]),x2,&one,&two, PI0,PD0,PD0,PD0,PD0,0L,0L);
620 C2F(dr)("xset","pattern",&pat,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
621 C2F(dr)("xset","line style",dash2,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
624 /********************/
625 /*** le z scaling ***/ /* DISPLAY Z graduations */
626 /********************/
629 if (pSUBWIN_FEATURE (psubwin)->project[2]==1)
635 Ticsdir[0]=ixbox[3]-ixbox[4]; /* <=> en pixel direction/vecteur non norme(e)s des tics en x */
636 Ticsdir[1]=iybox[3]-iybox[4]; /* <=> idem pour y */
637 /* NB: for a default plot3d (simply calling plot3d in siclab console) */
638 /* Ticsdir[0] & Ticsdir[1] are negative : we do min - max here... */
640 BBoxToval(&fx,&fy,&fz,xind[3],bbox); /* xind[3] <=> en bas a gauche <=> zmin */
641 x=ixbox[2]-(xz[0]+xz[1])/20;
642 y=(iybox[3]+iybox[2])/2;
644 /* NumberFormat(str,((integer) zz[0]),((integer) zz[2])); */
647 if( !ppsubwin->axes.auto_ticks[2] )
649 /* we display the z tics specified by the user*/
650 nbtics = ppsubwin->axes.u_nzgrads;
651 nbsubtics = ppsubwin->axes.nbsubtics[2];
653 maxTicksLabelSize[0] = 0 ;
654 maxTicksLabelSize[1] = 0 ;
656 for(i=0;i<nbtics;i++)
658 char *foo = ppsubwin->axes.u_zlabels[i];
659 double ztmp = ppsubwin->axes.u_zgrads[i];
661 if(ztmp<zminval || ztmp>zmaxval)
663 /* sciprint("je rejete la valeur: %lf\n\n",xtmp); */
664 continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
665 /* donc autant ne pas aller plus loin dans l'algo... */
669 /***************************************************************/
670 /************************* COMMON PART *************************/
671 /***************************************************************/
673 if( ppsubwin->axes.reverse[2] )
675 ztmp = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],ztmp);
678 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&ztmp);
683 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
684 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
685 vx[1]=vx[0]+barlengthx;
686 vy[1]=vy[0]+barlengthy;
688 /* foo is set above with sprintf(foo,c_format,xtmp); */
690 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
692 /* get the size of ticks label */
693 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
694 maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
695 maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
698 posi[0] = inint( xm+2*barlengthx - rect[2]);
699 posi[1]=inint( ym + 2*barlengthy + rect[3]/2);
702 if(ppsubwin->axes.axes_visible[2] == TRUE){
703 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
704 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
705 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
706 C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
707 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
709 /* grid to put here */
710 if ( ppsubwin->grid[2] > -1 && ppsubwin->axes.axes_visible[2] )
712 gstyle = pSUBWIN_FEATURE (psubwin)->grid[2];
714 if((ppsubwin->logflags[2] =='l') && (i != nbtics-1))
718 double * tmp_log_grads = (double *) NULL;
721 double * grads = ppsubwin->axes.u_zgrads;
723 tmp[0] = exp10(grads[i]);
724 tmp[1] = exp10(grads[i+1]);
725 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
727 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
728 sciprint("Error allocating tmp_log_grads\n");
732 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
734 for(j=0;j<nbsubtics;j++)
736 vzz1 = tmp_log_grads[j];
738 if(vzz1<=zminval || vzz1>=zmaxval) continue;
740 if(ppsubwin->axes.reverse[2] == TRUE)
741 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
743 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
745 /* if ((ym != iybox[3]) && (ym != iybox[2])) */
747 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
748 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
749 xg[0]= ixbox[3];yg[0]= ym;
750 if (Ishidden(psubwin))
751 { xg[1]=ixbox[4]; yg[1]= iybox[4]- iybox[3]+ym;}
753 {xg[1]=ixbox[1]; yg[1]= iybox[1]- iybox[2]+ym;}
754 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
755 xg[0]=xg[1]; ; xg[1] =ixbox[0];
756 yg[0]=yg[1]; yg[1]= ym- iybox[3]+ iybox[5];
757 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
758 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
761 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
765 if(ztmp>zminval && ztmp<zmaxval)
767 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
768 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
769 xg[0]= ixbox[3];yg[0]= ym;
770 if (Ishidden(psubwin))
771 { xg[1]=ixbox[4]; yg[1]= iybox[4]- iybox[3]+ym;}
773 {xg[1]=ixbox[1]; yg[1]= iybox[1]- iybox[2]+ym;}
774 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
775 xg[0]=xg[1]; ; xg[1] =ixbox[0];
776 yg[0]=yg[1]; yg[1]= ym- iybox[3]+ iybox[5];
777 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
778 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
786 if(ppsubwin->logflags[2] =='l')
790 double * tmp_log_grads = (double *) NULL;
793 double * grads = ppsubwin->axes.u_zgrads;
795 tmp[0] = exp10(grads[i]);
796 tmp[1] = exp10(grads[i+1]);
797 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
799 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
800 sciprint("Error allocating tmp_log_grads\n");
804 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
806 for(j=0;j<nbsubtics;j++)
808 vzz1 = tmp_log_grads[j];
810 if(vzz1<zminval || vzz1>zmaxval) continue;
812 if(ppsubwin->axes.reverse[2] == TRUE)
813 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
815 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
818 vx[1]= (integer) (vx[0]+barlengthx/2.0);
819 vy[1]= (integer) (vy[0]+barlengthy/2.0);
821 if(ppsubwin->axes.axes_visible[2] == TRUE)
822 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
824 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
828 double xtmp = ppsubwin->axes.u_zgrads[i];
829 double dx = (ppsubwin->axes.u_zgrads[i+1] - ppsubwin->axes.u_zgrads[i]) / nbsubtics;
830 for(j=0;j<nbsubtics;j++)
834 if(vzz1<zminval || vzz1>zmaxval) continue;
836 if(ppsubwin->axes.reverse[2] == TRUE)
837 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
839 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
840 /* trans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1); */
844 vx[1]= (integer) (vx[0]+barlengthx/2.0);
845 vy[1]= (integer) (vy[0]+barlengthy/2.0);
847 if(ppsubwin->axes.axes_visible[2] == TRUE)
848 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
853 /***************************************************************/
854 /************************* END OF COMMON PART ******************/
855 /***************************************************************/
858 else /* we display the computed tics */
860 AdaptGraduationsOnZ(x,y,size,Ticsdir,fontid,psubwin,zminval,zmaxval,fx,fy,0.);
862 lastzindex = ppsubwin->axes.nzgrads - 1;
865 ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.zgrads[0]));
867 ChoixFormatE(c_format,
868 ppsubwin->axes.zgrads[0],
869 ppsubwin->axes.zgrads[lastzindex],
870 ((ppsubwin->axes.zgrads[lastzindex])-(ppsubwin->axes.zgrads[0]))/(lastzindex));
872 nbtics = ppsubwin->axes.nzgrads;
873 nbsubtics = ppsubwin->axes.nbsubtics[2];
875 maxTicksLabelSize[0] = 0 ;
876 maxTicksLabelSize[1] = 0 ;
878 for(i=0;i<nbtics;i++)
881 double ztmp = ppsubwin->axes.zgrads[i];
883 if(ztmp<zminval || ztmp>zmaxval)
885 /* sciprint("je rejete la valeur: %lf\n\n",xtmp); */
886 continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
887 /* donc autant ne pas aller plus loin dans l'algo... */
890 sprintf(foo,c_format,ztmp);
892 /***************************************************************/
893 /************************* COMMON PART *************************/
894 /***************************************************************/
895 if(ppsubwin->axes.reverse[2] == TRUE)
896 ztmp = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],ztmp);
898 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&ztmp);
900 /* trans3d(psubwin,1,&xm,&ym,&fx,&fy,&ztmp); */
905 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
906 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
907 vx[1]=vx[0]+barlengthx;
908 vy[1]=vy[0]+barlengthy;
910 /* foo is set above with sprintf(foo,c_format,xtmp); */
912 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
914 /* get the size of ticks label */
915 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
916 maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
917 maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
919 posi[0] = inint( xm+2*barlengthx - rect[2]);
920 posi[1]=inint( ym + 2*barlengthy + rect[3]/2);
922 if(ppsubwin->axes.axes_visible[2] == TRUE){
923 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
924 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
925 if ( ppsubwin->logflags[2] == 'l' )
927 int smallersize = fontid[1]-2;
929 /* char str[2] = "xv"; */
932 posi10[0] = posi[0] - logrect[2];
933 posi10[1] = posi[1] + logrect[3];
935 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
936 C2F(dr)("xstring","10",(&posi10[0]),(&posi10[1]),PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
938 C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
940 posi[0] = old_rect10[0] + old_rect10[2];
941 posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
943 C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
944 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
946 /* put back the current fontid */
947 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
950 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
953 C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
954 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
956 /* grid to put here */
957 if ( ppsubwin->grid[2] > -1 && ppsubwin->axes.axes_visible[2] )
959 gstyle = pSUBWIN_FEATURE (psubwin)->grid[2];
961 if((ppsubwin->logflags[2] =='l') && (i != nbtics-1))
965 double * tmp_log_grads = (double *) NULL;
968 double * grads = ppsubwin->axes.zgrads;
970 tmp[0] = exp10(grads[i]);
971 tmp[1] = exp10(grads[i+1]);
972 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
974 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
975 sciprint("Error allocating tmp_log_grads\n");
979 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
981 for(j=0;j<nbsubtics;j++)
983 vzz1 = tmp_log_grads[j];
985 if(vzz1<=zminval || vzz1>=zmaxval) continue;
987 if(ppsubwin->axes.reverse[2] == TRUE)
988 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
990 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
992 /* if ((ym != iybox[3]) && (ym != iybox[2])) */
994 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
995 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
996 xg[0]= ixbox[3];yg[0]= ym;
997 if (Ishidden(psubwin))
998 { xg[1]=ixbox[4]; yg[1]= iybox[4]- iybox[3]+ym;}
1000 {xg[1]=ixbox[1]; yg[1]= iybox[1]- iybox[2]+ym;}
1001 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1002 xg[0]=xg[1]; ; xg[1] =ixbox[0];
1003 yg[0]=yg[1]; yg[1]= ym- iybox[3]+ iybox[5];
1004 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1005 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1008 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
1012 if(ztmp>zminval && ztmp<zmaxval)
1014 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1015 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1016 xg[0]= ixbox[3];yg[0]= ym;
1017 if (Ishidden(psubwin))
1018 { xg[1]=ixbox[4]; yg[1]= iybox[4]- iybox[3]+ym;}
1020 {xg[1]=ixbox[1]; yg[1]= iybox[1]- iybox[2]+ym;}
1021 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1022 xg[0]=xg[1]; ; xg[1] =ixbox[0];
1023 yg[0]=yg[1]; yg[1]= ym- iybox[3]+ iybox[5];
1024 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1025 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1033 if(ppsubwin->logflags[2] =='l')
1037 double * tmp_log_grads = (double *) NULL;
1040 double * grads = ppsubwin->axes.zgrads;
1042 tmp[0] = exp10(grads[i]);
1043 tmp[1] = exp10(grads[i+1]);
1044 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
1046 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
1047 sciprint("Error allocating tmp_log_grads\n");
1051 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
1053 for(j=0;j<nbsubtics;j++)
1055 vzz1 = tmp_log_grads[j];
1057 if(vzz1<zminval || vzz1>zmaxval) continue;
1059 if(ppsubwin->axes.reverse[2] == TRUE)
1060 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
1062 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
1065 vx[1]= (integer) (vx[0]+barlengthx/2.0);
1066 vy[1]= (integer) (vy[0]+barlengthy/2.0);
1068 if(ppsubwin->axes.axes_visible[2] == TRUE)
1069 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1071 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
1075 double ztmp2 = ppsubwin->axes.zgrads[i];
1076 double dz = (ppsubwin->axes.zgrads[i+1] - ppsubwin->axes.zgrads[i]) / nbsubtics;
1077 for(j=0;j<nbsubtics;j++)
1081 if(vzz1<zminval || vzz1>zmaxval) continue;
1083 if(ppsubwin->axes.reverse[2] == TRUE)
1084 vzz1 = InvAxis(ppsubwin->FRect[4],ppsubwin->FRect[5],vzz1);
1086 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1);
1087 /* trans3d(psubwin,1,&xm,&ym,&fx,&fy,&vzz1); */
1091 vx[1]= (integer) (vx[0]+barlengthx/2.0);
1092 vy[1]= (integer) (vy[0]+barlengthy/2.0);
1094 if(ppsubwin->axes.axes_visible[2] == TRUE)
1095 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1099 /***************************************************************/
1100 /************************* END OF COMMON PART ******************/
1101 /***************************************************************/
1107 if ( sciGetVisibility(ppsubwin->mon_z_label) )
1110 sciLabel * ppLabel = pLABEL_FEATURE(ppsubwin->mon_z_label) ;
1112 if ( ppLabel->auto_rotation )
1114 /* mult by 10 because */
1115 sciSetFontOrientation(ppsubwin->mon_z_label, 270 * 10 ) ;
1118 if( ppLabel->auto_position )
1121 int segmentStart[2] = { ixbox[2], iybox[2] } ;
1122 int segmentEnd[2] = { ixbox[3], iybox[3] } ;
1124 /* add the bar size and ticks label size to the offset */
1125 int offset[2] = { constOffset[0] + maxTicksLabelSize[0] + abs( barlengthx ),
1126 constOffset[1] + maxTicksLabelSize[1] + abs( barlengthy ) } ;
1127 computeLabelAutoPos( ppsubwin->mon_z_label, segmentStart, segmentEnd, offset ) ;
1129 /* a trick to force the display with 2d scale */
1130 drawTextEntity( ppLabel->text ) ;
1135 /***********************/ /** bottom right side ***/
1136 /*** le x-y scaling ***/ /* DISPLAY x or y graduations */
1137 /***********************/
1140 if (( xind[4]+xind[5] == 3) || ( xind[4]+xind[5] == 11))
1142 if (pSUBWIN_FEATURE (psubwin)->project[0]==1) /* x HERE */
1148 Ticsdir[0]=ixbox[4]-ixbox[3];
1149 Ticsdir[1]=iybox[4]-iybox[3];
1150 BBoxToval(&fx,&fy,&fz,xind[4],bbox);
1151 x=inint((ixbox[4]+ixbox[5])/2+1.5*rect[2] +iof);
1152 y=inint(((2/3.0)*iybox[4]+(1/3.0)*iybox[5])+1.5*rect[3]+iof);
1154 if( !ppsubwin->axes.auto_ticks[0] )
1156 /* we display the x tics specified by the user*/
1157 nbtics = ppsubwin->axes.u_nxgrads;
1158 nbsubtics = ppsubwin->axes.nbsubtics[0];
1160 maxTicksLabelSize[0] = 0 ;
1161 maxTicksLabelSize[1] = 0 ;
1163 for(i=0;i<nbtics;i++)
1165 char *foo = ppsubwin->axes.u_xlabels[i];
1166 double xtmp = ppsubwin->axes.u_xgrads[i];
1168 if(xtmp<xminval || xtmp>xmaxval)
1170 /* sciprint("je rejete la valeur: %lf\n\n",xtmp); */
1171 continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
1172 /* donc autant ne pas aller plus loin dans l'algo... */
1175 /***************************************************************/
1176 /************************* COMMON PART *************************/
1177 /***************************************************************/
1179 if(ppsubwin->axes.reverse[0] == TRUE)
1180 xtmp = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],xtmp);
1182 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz);
1183 /* trans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz); */
1188 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
1189 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
1191 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
1193 /* get the size of the icks label */
1194 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1195 maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
1196 maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
1199 if (IsDownAxes(psubwin)){
1202 posi[0] = inint(xm-rect[2]/2);
1203 posi[1]=inint( vy[0] + iof + rect[3]);}
1205 vx[1]=vx[0]+barlengthx;
1206 vy[1]=vy[0]+barlengthy;
1207 posi[0] = inint( xm+2*barlengthx);
1208 posi[1]=inint( ym + 2*barlengthy + rect[3]);}
1210 if( ppsubwin->axes.axes_visible[0] )
1212 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1213 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1214 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
1215 C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1216 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1218 /* grid to put here */
1219 if ( ppsubwin->grid[0] > -1 && ppsubwin->axes.axes_visible[0] )
1221 gstyle = pSUBWIN_FEATURE (psubwin)->grid[0];
1223 if((ppsubwin->logflags[0] =='l') && (i != nbtics-1))
1227 double * tmp_log_grads = (double *) NULL;
1230 double * grads = ppsubwin->axes.u_xgrads;
1232 tmp[0] = exp10(grads[i]);
1233 tmp[1] = exp10(grads[i+1]);
1234 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
1236 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
1237 sciprint("Error allocating tmp_log_grads\n");
1241 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
1243 for(j=0;j<nbsubtics;j++)
1245 vxx1 = tmp_log_grads[j];
1247 if(vxx1<=xminval || vxx1>=xmaxval) continue;
1249 if(ppsubwin->axes.reverse[0] == TRUE)
1250 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
1252 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
1254 /* if ((xm != ixbox[5]) && (xm != ixbox[4])) */
1256 xg[0]= xm; yg[0]= ym;
1257 if (Ishidden(psubwin))
1258 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
1260 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; }
1262 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1263 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1264 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1265 xg[0]= xg[1]; yg[0]= yg[1];
1266 xg[1] = ixbox[3] - ixbox[4] +xm;
1267 yg[1]= iybox[2] - iybox[4] +ym;
1268 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1269 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1272 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
1276 if(xtmp>xminval && xtmp<xmaxval)
1278 xg[0]= xm; yg[0]= ym;
1279 if (Ishidden(psubwin))
1280 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
1282 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; }
1283 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1284 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1285 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1286 xg[0]= xg[1]; yg[0]= yg[1];
1287 xg[1] = ixbox[3] - ixbox[4] +xm;
1288 yg[1]= iybox[2] - iybox[4] +ym;
1289 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1290 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1298 if(ppsubwin->logflags[0] =='l')
1302 double * tmp_log_grads = (double *) NULL;
1305 double * grads = ppsubwin->axes.u_xgrads;
1307 tmp[0] = exp10(grads[i]);
1308 tmp[1] = exp10(grads[i+1]);
1309 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
1311 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
1312 sciprint("Error allocating tmp_log_grads\n");
1316 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
1318 for(j=0;j<nbsubtics;j++)
1320 vxx1 = tmp_log_grads[j];
1322 if(vxx1<xminval || vxx1>xmaxval) continue;
1324 if(ppsubwin->axes.reverse[0] == TRUE)
1325 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
1327 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
1329 if (IsDownAxes(psubwin))
1338 vx[1]= (integer) (vx[0]+barlengthx/2.0);
1339 vy[1]= (integer) (vy[0]+barlengthy/2.0);
1342 if(ppsubwin->axes.axes_visible[0] == TRUE)
1343 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1346 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
1350 double xtmp2 = ppsubwin->axes.u_xgrads[i];
1351 double dx = (ppsubwin->axes.u_xgrads[i+1] - ppsubwin->axes.u_xgrads[i]) / nbsubtics;
1353 for (j=1;j<nbsubtics;j++)
1357 if(vxx1<xminval || vxx1>xmaxval) continue;
1359 if(ppsubwin->axes.reverse[0] == TRUE)
1360 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
1362 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
1363 /* trans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz); */
1366 if (IsDownAxes(psubwin))
1375 vx[1]= (integer) (vx[0]+barlengthx/2.0);
1376 vy[1]= (integer) (vy[0]+barlengthy/2.0);
1379 if(ppsubwin->axes.axes_visible[0] == TRUE)
1380 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1384 /***************************************************************/
1385 /************************* END OF COMMON PART ******************/
1386 /***************************************************************/
1390 else /* we display the computed tics */
1392 AdaptGraduationsOnXBottomRight(iof,x,y,size,Ticsdir,fontid,psubwin,xminval,xmaxval,0.,fy,fz);
1394 lastxindex = ppsubwin->axes.nxgrads - 1;
1398 ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.xgrads[0]));
1402 ChoixFormatE(c_format,
1403 ppsubwin->axes.xgrads[0],
1404 ppsubwin->axes.xgrads[lastxindex],
1405 ((ppsubwin->axes.xgrads[lastxindex])-(ppsubwin->axes.xgrads[0]))/(lastxindex));
1408 nbtics = ppsubwin->axes.nxgrads;
1409 nbsubtics = ppsubwin->axes.nbsubtics[0];
1411 maxTicksLabelSize[0] = 0 ;
1412 maxTicksLabelSize[1] = 0 ;
1414 for(i=0;i<nbtics;i++)
1417 double xtmp = ppsubwin->axes.xgrads[i];
1419 if(xtmp<xminval || xtmp>xmaxval)
1421 /* sciprint("je rejete la valeur: %lf\n\n",xtmp); */
1422 continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
1423 /* donc autant ne pas aller plus loin dans l'algo... */
1426 sprintf(foo,c_format,xtmp);
1428 /***************************************************************/
1429 /************************* COMMON PART *************************/
1430 /***************************************************************/
1433 /* F.Leray 03.11.04 Test if log scale to perform a : exp10(x) because trans3d will */
1434 /* re-do a log10() (that is needed for data computations) */
1436 if( ppsubwin->axes.reverse[0] )
1438 xtmp = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],xtmp);
1441 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz);
1445 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
1446 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
1448 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
1450 /* get the size of ticks label */
1451 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1452 maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
1453 maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
1455 if (IsDownAxes(psubwin)){
1458 posi[0] = inint(xm-rect[2]/2);
1459 posi[1]=inint( vy[0] + iof + rect[3]);}
1461 vx[1]=vx[0]+barlengthx;
1462 vy[1]=vy[0]+barlengthy;
1463 posi[0] = inint( xm+2*barlengthx);
1464 posi[1]=inint( ym + 2*barlengthy + rect[3]);}
1466 if( ppsubwin->axes.axes_visible[0] )
1468 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1469 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1470 if ( ppsubwin->logflags[0] == 'l' )
1472 int smallersize = fontid[1]-2;
1476 posi10[0] = posi[0] - logrect[2];
1477 posi10[1] = posi[1] + logrect[3];
1479 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1480 C2F(dr)("xstring","10",(&posi10[0]),(&posi10[1]),PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
1482 C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1484 posi[0] = old_rect10[0] + old_rect10[2];
1485 posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
1487 C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1488 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
1490 /* put back the current fontid */
1491 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1495 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
1497 C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1498 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1500 /* grid to put here */
1501 if ( ppsubwin->grid[0] > -1 && ppsubwin->axes.axes_visible[0] )
1503 gstyle = pSUBWIN_FEATURE (psubwin)->grid[0];
1505 if((ppsubwin->logflags[0] =='l') && (i != nbtics-1))
1509 double * tmp_log_grads = (double *) NULL;
1512 double * grads = ppsubwin->axes.xgrads;
1514 tmp[0] = exp10(grads[i]);
1515 tmp[1] = exp10(grads[i+1]);
1516 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
1518 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
1519 sciprint("Error allocating tmp_log_grads\n");
1523 for(j=0;j<nbsubtics;j++)
1525 tmp_log_grads[j] = log10( tmp[0] + (j) * pas ) ;
1528 for(j=0;j<nbsubtics;j++)
1530 vxx1 = tmp_log_grads[j];
1532 if(vxx1<=xminval || vxx1>=xmaxval) continue;
1534 if(ppsubwin->axes.reverse[0] == TRUE)
1535 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
1537 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
1539 /* if ((xm != ixbox[5]) && (xm != ixbox[4])) */
1541 xg[0]= xm; yg[0]= ym;
1542 if (Ishidden(psubwin))
1543 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
1545 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; }
1547 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1548 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1549 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1550 xg[0]= xg[1]; yg[0]= yg[1];
1551 xg[1] = ixbox[3] - ixbox[4] +xm;
1552 yg[1]= iybox[2] - iybox[4] +ym;
1553 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1554 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1557 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
1561 if(xtmp>xminval && xtmp<xmaxval)
1563 xg[0]= xm; yg[0]= ym;
1564 if (Ishidden(psubwin))
1565 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
1567 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; }
1568 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1569 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1570 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1571 xg[0]= xg[1]; yg[0]= yg[1];
1572 xg[1] = ixbox[3] - ixbox[4] +xm;
1573 yg[1]= iybox[2] - iybox[4] +ym;
1574 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1575 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1581 if(i != nbtics-1) /* F.Leray NEW 03.11.04 */
1584 if(ppsubwin->logflags[0] =='l')
1588 double * tmp_log_grads = (double *) NULL;
1591 double * grads = ppsubwin->axes.xgrads;
1593 tmp[0] = exp10(grads[i]);
1594 tmp[1] = exp10(grads[i+1]);
1595 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
1597 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
1598 sciprint("Error allocating tmp_log_grads\n");
1602 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
1604 for(j=0;j<nbsubtics;j++)
1606 vxx1 = tmp_log_grads[j];
1608 if(vxx1<xminval || vxx1>xmaxval) continue;
1610 if(ppsubwin->axes.reverse[0] == TRUE)
1611 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
1613 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
1615 if (IsDownAxes(psubwin))
1624 vx[1]= (integer) (vx[0]+barlengthx/2.0);
1625 vy[1]= (integer) (vy[0]+barlengthy/2.0);
1628 if( ppsubwin->axes.axes_visible[0] )
1629 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1632 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
1636 double xtmp2 = ppsubwin->axes.xgrads[i];
1637 double dx = (ppsubwin->axes.xgrads[i+1] - ppsubwin->axes.xgrads[i]) / nbsubtics;
1639 for (j=1;j<nbsubtics;j++)
1643 if(vxx1<xminval || vxx1>xmaxval) continue;
1645 if(ppsubwin->axes.reverse[0] == TRUE)
1646 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
1648 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
1650 if (IsDownAxes(psubwin))
1659 vx[1]= (integer) (vx[0]+barlengthx/2.0);
1660 vy[1]= (integer) (vy[0]+barlengthy/2.0);
1663 if(ppsubwin->axes.axes_visible[0] == TRUE)
1664 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1669 /***************************************************************/
1670 /************************* END OF COMMON PART ******************/
1671 /***************************************************************/
1676 if ( sciGetVisibility(ppsubwin->mon_x_label) )
1678 sciLabel * ppLabel = pLABEL_FEATURE( ppsubwin->mon_x_label ) ;
1679 if( ppLabel->auto_rotation )
1681 sciSetFontOrientation(ppsubwin->mon_x_label, 0) ;
1685 if( ppLabel->auto_position )
1688 int segmentStart[2] = { ixbox[4], iybox[4] } ;
1689 int segmentEnd[2] = { ixbox[5], iybox[5] } ;
1691 /* add the bar size and ticks label size to the offset */
1692 int offset[2] = { constOffset[0] + maxTicksLabelSize[0] + abs( barlengthx ),
1693 constOffset[1] + maxTicksLabelSize[1] + abs( barlengthy ) } ;
1694 computeLabelAutoPos( ppsubwin->mon_x_label, segmentStart, segmentEnd, offset ) ;
1696 /* a trick to force the display with 2d scale */
1697 drawTextEntity( ppLabel->text ) ;
1704 if ( pSUBWIN_FEATURE (psubwin)->project[1]==1) /* y is HERE */
1710 Ticsdir[0]=ixbox[4]-ixbox[3];
1711 Ticsdir[1]=iybox[4]-iybox[3];
1712 BBoxToval(&fx,&fy,&fz,xind[4],bbox);
1714 x=inint((ixbox[4]+ixbox[5])/2+1.5*rect[2] +iof);
1715 y=inint(((2/3.0)*iybox[4]+(1/3.0)*iybox[5])+1.5*rect[3]+iof);
1717 if(ppsubwin->axes.auto_ticks[1] == FALSE)
1719 /* we display the y tics specified by the user*/
1720 nbtics = ppsubwin->axes.u_nygrads;
1721 nbsubtics = ppsubwin->axes.nbsubtics[1];
1723 maxTicksLabelSize[0] = 0 ;
1724 maxTicksLabelSize[1] = 0 ;
1726 for(i=0;i<nbtics;i++)
1728 char *foo = ppsubwin->axes.u_ylabels[i];
1729 double ytmp = ppsubwin->axes.u_ygrads[i];
1731 if(ytmp<yminval || ytmp>ymaxval)
1733 /* sciprint("je rejete la valeur: %lf\n\n",xtmp); */
1734 continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
1735 /* donc autant ne pas aller plus loin dans l'algo... */
1739 /***************************************************************/
1740 /************************* COMMON PART *************************/
1741 /***************************************************************/
1743 if(ppsubwin->axes.reverse[1] == TRUE)
1744 ytmp = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ytmp);
1746 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz);
1747 /* trans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz); */
1753 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
1754 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
1755 /* NumberFormat(foo,((integer) (yy[0] + i*ceil((yy[1]-yy[0])/yy[3]))), */
1756 /* ((integer) yy[2])); */
1757 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
1759 /* get the size of the ticks */
1760 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1761 maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
1762 maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
1765 if (IsDownAxes(psubwin)){
1768 posi[0] = inint(xm-rect[2]/2);
1769 posi[1]=inint( vy[0] + iof + rect[3]);}
1771 vx[1]=vx[0]+barlengthx;
1772 vy[1]=vy[0]+barlengthy;
1773 /* posi[0] = inint( xm+2*barlengthx - rect[2]/2); */
1774 /* posi[0] = inint( xm+2*barlengthx - rect[2]); */
1775 posi[0] = inint( xm+2*barlengthx);
1776 posi[1]=inint( ym + 2*barlengthy + rect[3]);}
1778 if(ppsubwin->axes.axes_visible[1] == TRUE){
1779 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1780 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1781 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
1782 C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1783 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1785 /* grid to put here */
1786 if ( ppsubwin->grid[1] > -1 && ppsubwin->axes.axes_visible[1] )
1788 gstyle = pSUBWIN_FEATURE (psubwin)->grid[1];
1790 if((ppsubwin->logflags[1] =='l') && (i != nbtics-1))
1794 double * tmp_log_grads = (double *) NULL;
1797 double * grads = ppsubwin->axes.u_ygrads;
1799 tmp[0] = exp10(grads[i]);
1800 tmp[1] = exp10(grads[i+1]);
1801 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
1803 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
1804 sciprint("Error allocating tmp_log_grads\n");
1808 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
1810 for(j=0;j<nbsubtics;j++)
1812 vyy1 = tmp_log_grads[j];
1814 if(vyy1<=yminval || vyy1>=ymaxval) continue;
1816 if(ppsubwin->axes.reverse[1] == TRUE)
1817 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
1819 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
1821 /* if ((xm != ixbox[5]) && (xm != ixbox[4])) */
1823 xg[0]= xm; yg[0]= ym;
1824 if (Ishidden(psubwin))
1825 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
1827 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; }
1828 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1829 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1830 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1831 xg[0]= xg[1]; yg[0]= yg[1];
1832 xg[1] = ixbox[3] - ixbox[4] +xm;
1833 yg[1]= iybox[2] - iybox[4] +ym;
1834 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1835 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1838 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
1842 if(ytmp>yminval && ytmp<ymaxval)
1844 xg[0]= xm; yg[0]= ym;
1845 if (Ishidden(psubwin))
1846 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
1848 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; }
1849 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1850 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1851 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1852 xg[0]= xg[1]; yg[0]= yg[1];
1853 xg[1] = ixbox[3] - ixbox[4] +xm;
1854 yg[1]= iybox[2] - iybox[4] +ym;
1855 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1856 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
1864 if(ppsubwin->logflags[1] =='l')
1868 double * tmp_log_grads = (double *) NULL;
1871 double * grads = ppsubwin->axes.u_ygrads;
1873 tmp[0] = exp10(grads[i]);
1874 tmp[1] = exp10(grads[i+1]);
1875 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
1877 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
1878 sciprint("Error allocating tmp_log_grads\n");
1882 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
1884 for(j=0;j<nbsubtics;j++)
1886 vyy1 = tmp_log_grads[j];
1888 if(vyy1<yminval || vyy1>ymaxval) continue;
1890 if(ppsubwin->axes.reverse[1] == TRUE)
1891 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
1893 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
1895 if (IsDownAxes(psubwin))
1904 vx[1]= (integer) (vx[0]+barlengthx/2.0);
1905 vy[1]= (integer) (vy[0]+barlengthy/2.0);
1908 if(ppsubwin->axes.axes_visible[1] == TRUE)
1909 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1911 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
1916 double ytmp2 = ppsubwin->axes.u_ygrads[i];
1917 double dy = (ppsubwin->axes.u_ygrads[i+1] - ppsubwin->axes.u_ygrads[i]) / nbsubtics;
1918 for(j=0;j<nbsubtics;j++)
1922 if(vyy1<yminval || vyy1>ymaxval) continue;
1924 if(ppsubwin->axes.reverse[1] == TRUE)
1925 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
1927 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
1929 if (IsDownAxes(psubwin))
1938 vx[1]= (integer) (vx[0]+barlengthx/2.0);
1939 vy[1]= (integer) (vy[0]+barlengthy/2.0);
1942 if(ppsubwin->axes.axes_visible[1] == TRUE)
1943 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
1948 /***************************************************************/
1949 /************************* END OF COMMON PART ******************/
1950 /***************************************************************/
1953 else /* we display the computed tics */
1955 AdaptGraduationsOnYBottomRight(iof,x,y,size,Ticsdir,fontid,psubwin,yminval,ymaxval,fx,0.,fz);
1957 lastyindex = ppsubwin->axes.nygrads - 1;
1960 ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.ygrads[0]));
1962 ChoixFormatE(c_format,
1963 ppsubwin->axes.ygrads[0],
1964 ppsubwin->axes.ygrads[lastyindex],
1965 ((ppsubwin->axes.ygrads[lastyindex])-(ppsubwin->axes.ygrads[0]))/(lastyindex));
1967 nbtics = ppsubwin->axes.nygrads;
1968 nbsubtics = ppsubwin->axes.nbsubtics[1];
1970 maxTicksLabelSize[0] = 0 ;
1971 maxTicksLabelSize[1] = 0 ;
1973 for(i=0;i<nbtics;i++)
1976 double ytmp2 = ppsubwin->axes.ygrads[i];
1978 if(ytmp2<yminval || ytmp2>ymaxval)
1980 /* sciprint("je rejete la valeur: %lf\n\n",xtmp); */
1981 continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
1982 /* donc autant ne pas aller plus loin dans l'algo... */
1985 sprintf(foo,c_format,ytmp2);
1987 /***************************************************************/
1988 /************************* COMMON PART *************************/
1989 /***************************************************************/
1991 /* F.Leray 03.11.04 Test if log scale to perform a : exp10(x) because trans3d will */
1992 /* re-do a log10() (that is needed for data computations) */
1995 if(ppsubwin->axes.reverse[1] == TRUE)
1996 ytmp2 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ytmp2);
1998 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&ytmp2,&fz);
2003 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
2004 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
2006 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
2009 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2010 maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
2011 maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
2013 if (IsDownAxes(psubwin)){
2016 posi[0] = inint(xm-rect[2]/2);
2017 posi[1]=inint( vy[0] + iof + rect[3]);}
2019 vx[1]=vx[0]+barlengthx;
2020 vy[1]=vy[0]+barlengthy;
2021 /* posi[0] = inint( xm+2*barlengthx - rect[2]/2); */
2022 /* posi[0] = inint( xm+2*barlengthx - rect[2]); */
2023 posi[0] = inint( xm+2*barlengthx);
2024 posi[1]=inint( ym + 2*barlengthy + rect[3]);}
2026 if(ppsubwin->axes.axes_visible[1] == TRUE){
2027 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2028 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2029 if ( ppsubwin->logflags[1] == 'l' )
2031 int smallersize = fontid[1]-2;
2033 /* char str[2] = "xv"; */
2036 posi10[0] = posi[0] - logrect[2];
2037 posi10[1] = posi[1] + logrect[3];
2039 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2040 C2F(dr)("xstring","10",(&posi10[0]),(&posi10[1]),PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
2042 C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2044 posi[0] = old_rect10[0] + old_rect10[2];
2045 posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
2047 C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2048 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
2050 /* put back the current fontid */
2051 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2054 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
2056 C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2057 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2060 /* grid to put here */
2062 if ( ppsubwin->grid[1] > -1 && ppsubwin->axes.axes_visible[1] )
2064 gstyle = pSUBWIN_FEATURE (psubwin)->grid[1];
2066 if((ppsubwin->logflags[1] =='l') && (i != nbtics-1))
2070 double * tmp_log_grads = (double *) NULL;
2073 double * grads = ppsubwin->axes.ygrads;
2075 tmp[0] = exp10(grads[i]);
2076 tmp[1] = exp10(grads[i+1]);
2077 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
2079 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
2080 sciprint("Error allocating tmp_log_grads\n");
2084 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
2086 for(j=0;j<nbsubtics;j++)
2088 vyy1 = tmp_log_grads[j];
2090 if(vyy1<=yminval || vyy1>=ymaxval) continue;
2092 if(ppsubwin->axes.reverse[1] == TRUE)
2093 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
2095 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
2097 /* if ((xm != ixbox[5]) && (xm != ixbox[4])) */
2099 xg[0]= xm; yg[0]= ym;
2100 if (Ishidden(psubwin))
2101 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
2103 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; }
2104 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2105 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2106 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2107 xg[0]= xg[1]; yg[0]= yg[1];
2108 xg[1] = ixbox[3] - ixbox[4] +xm;
2109 yg[1]= iybox[2] - iybox[4] +ym;
2110 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2111 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2114 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
2118 if(ytmp2>yminval && ytmp2<ymaxval)
2120 xg[0]= xm; yg[0]= ym;
2121 if (Ishidden(psubwin))
2122 { xg[1]= xm; yg[1]= iybox[2] -iybox[3]+ym; }
2124 {xg[1]= ixbox[3] - ixbox[4] +xm; yg[1]= iybox[3] - iybox[4] +ym; }
2125 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2126 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2127 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2128 xg[0]= xg[1]; yg[0]= yg[1];
2129 xg[1] = ixbox[3] - ixbox[4] +xm;
2130 yg[1]= iybox[2] - iybox[4] +ym;
2131 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2132 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2140 if(ppsubwin->logflags[1] =='l')
2144 double * tmp_log_grads = (double *) NULL;
2147 double * grads = ppsubwin->axes.ygrads;
2149 tmp[0] = exp10(grads[i]);
2150 tmp[1] = exp10(grads[i+1]);
2151 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
2153 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
2154 sciprint("Error allocating tmp_log_grads\n");
2158 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
2160 for(j=0;j<nbsubtics;j++)
2162 vyy1 = tmp_log_grads[j];
2164 if(vyy1<yminval || vyy1>ymaxval) continue;
2166 if(ppsubwin->axes.reverse[1] == TRUE)
2167 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
2169 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
2171 if (IsDownAxes(psubwin))
2180 vx[1]= (integer) (vx[0]+barlengthx/2.0);
2181 vy[1]= (integer) (vy[0]+barlengthy/2.0);
2184 if(ppsubwin->axes.axes_visible[1] == TRUE)
2185 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2187 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
2192 double ytmp3 = ppsubwin->axes.ygrads[i];
2193 double dy = (ppsubwin->axes.ygrads[i+1] - ppsubwin->axes.ygrads[i]) / nbsubtics;
2194 for(j=0;j<nbsubtics;j++)
2198 if(vyy1<yminval || vyy1>ymaxval) continue;
2200 if(ppsubwin->axes.reverse[1] == TRUE)
2201 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
2203 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
2204 /* trans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz); */
2206 if (IsDownAxes(psubwin))
2215 vx[1]= (integer) (vx[0]+barlengthx/2.0);
2216 vy[1]= (integer) (vy[0]+barlengthy/2.0);
2219 if(ppsubwin->axes.axes_visible[1] == TRUE)
2220 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2224 /***************************************************************/
2225 /************************* END OF COMMON PART ******************/
2226 /***************************************************************/
2231 if ( sciGetVisibility(ppsubwin->mon_y_label) )
2233 sciLabel * ppLabel = pLABEL_FEATURE( ppsubwin->mon_y_label ) ;
2234 if( ppLabel->auto_rotation )
2236 sciSetFontOrientation( ppsubwin->mon_y_label, 0 ) ;
2239 if( ppLabel->auto_position )
2242 int segmentStart[2] = { ixbox[4], iybox[4] } ;
2243 int segmentEnd[2] = { ixbox[5], iybox[5] } ;
2245 /* add the bar size and ticks label size to the offset */
2246 int offset[2] = { constOffset[0] + maxTicksLabelSize[0] + abs( barlengthx ),
2247 constOffset[1] + maxTicksLabelSize[1] + abs( barlengthy ) } ;
2248 computeLabelAutoPos( ppsubwin->mon_y_label, segmentStart, segmentEnd, offset ) ;
2250 /* a trick to force the display with 2d scale */
2251 drawTextEntity( ppLabel->text ) ;
2258 /***********************/ /** bottom left side ***/
2259 /*** le x-y scaling ***/ /* DISPLAY x or y graduations */
2260 /***********************/
2262 if (( xind[3]+xind[4] == 3) || ( xind[3]+xind[4] == 11))
2264 if (pSUBWIN_FEATURE (psubwin)->project[0]==1) /* x HERE */
2271 Ticsdir[0]=ixbox[4]-ixbox[5];
2272 Ticsdir[1]=iybox[4]-iybox[5];
2273 BBoxToval(&fx,&fy,&fz,xind[3],bbox);
2275 x=inint((ixbox[3]+ixbox[4])/2.0 -rect[2] -iof);
2276 y=inint((1/3.0)*iybox[3]+(2/3.0)*iybox[4]+ iof+ 1.5*rect[3]);
2278 if(ppsubwin->axes.auto_ticks[0] == FALSE)
2280 /* we display the x tics specified by the user*/
2281 nbtics = ppsubwin->axes.u_nxgrads;
2282 nbsubtics = ppsubwin->axes.nbsubtics[0];
2284 maxTicksLabelSize[0] = 0 ;
2285 maxTicksLabelSize[1] = 0 ;
2287 for(i=0;i<nbtics;i++)
2289 char *foo = ppsubwin->axes.u_xlabels[i];
2290 double xtmp = ppsubwin->axes.u_xgrads[i];
2292 if(xtmp<xminval || xtmp>xmaxval)
2294 /* sciprint("je rejete la valeur: %lf\n\n",xtmp); */
2295 continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
2296 /* donc autant ne pas aller plus loin dans l'algo... */
2299 /***************************************************************/
2300 /************************* COMMON PART *************************/
2301 /***************************************************************/
2303 if(ppsubwin->axes.reverse[0] == TRUE)
2304 xtmp = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],xtmp);
2306 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz);
2307 /* trans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz); */
2312 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
2313 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
2315 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
2317 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2318 maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
2319 maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
2322 if (IsDownAxes(psubwin)){
2325 posi[0] = inint(xm-rect[2]/2);
2326 posi[1]=inint( vy[0] + iof + rect[3]);}
2328 vx[1]=vx[0]+barlengthx;
2329 vy[1]=vy[0]+barlengthy;
2330 posi[0] = inint( xm+2*barlengthx-rect[2]);
2331 posi[1]=inint( ym + 2*barlengthy + rect[3]);}
2333 if(ppsubwin->axes.axes_visible[0] == TRUE){
2334 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2335 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2336 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
2337 C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2338 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2340 /* grid to put here */
2341 if ( ppsubwin->grid[0] > -1 && ppsubwin->axes.axes_visible[0] )
2343 gstyle = pSUBWIN_FEATURE (psubwin)->grid[0];
2345 if((ppsubwin->logflags[0] =='l') && (i != nbtics-1))
2349 double * tmp_log_grads = (double *) NULL;
2352 double * grads = ppsubwin->axes.u_xgrads;
2354 tmp[0] = exp10(grads[i]);
2355 tmp[1] = exp10(grads[i+1]);
2356 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
2358 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
2359 sciprint("Error allocating tmp_log_grads\n");
2363 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
2365 for(j=0;j<nbsubtics;j++)
2367 vxx1 = tmp_log_grads[j];
2369 if(vxx1<=xminval || vxx1>=xmaxval) continue;
2371 if(ppsubwin->axes.reverse[0] == TRUE)
2372 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
2374 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
2376 /* if ((xm != ixbox[3]) && (xm != ixbox[4])) */
2378 xg[0]= xm; yg[0]= ym;
2379 if (Ishidden(psubwin))
2380 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
2382 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; }
2383 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2384 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2385 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2386 xg[0]= xg[1]; yg[0]= yg[1];
2387 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]= iybox[0] - iybox[4] +ym;
2388 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2389 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2392 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
2396 if(xtmp>xminval && xtmp<xmaxval)
2398 xg[0]= xm; yg[0]= ym;
2399 if (Ishidden(psubwin))
2400 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
2402 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; }
2403 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2404 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2405 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2406 xg[0]= xg[1]; yg[0]= yg[1];
2407 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]= iybox[0] - iybox[4] +ym;
2408 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2409 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2417 if(ppsubwin->logflags[0] =='l')
2421 double * tmp_log_grads = (double *) NULL;
2424 double * grads = ppsubwin->axes.u_xgrads;
2426 tmp[0] = exp10(grads[i]);
2427 tmp[1] = exp10(grads[i+1]);
2428 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
2430 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
2431 sciprint("Error allocating tmp_log_grads\n");
2435 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
2437 for(j=0;j<nbsubtics;j++)
2439 vxx1 = tmp_log_grads[j];
2441 if(vxx1<xminval || vxx1>xmaxval) continue;
2443 if(ppsubwin->axes.reverse[0] == TRUE)
2444 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
2446 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
2448 if (IsDownAxes(psubwin))
2457 vx[1]= (integer) (vx[0]+barlengthx/2.0);
2458 vy[1]= (integer) (vy[0]+barlengthy/2.0);
2461 if(ppsubwin->axes.axes_visible[0] == TRUE)
2462 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2465 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
2469 double xtmp2 = ppsubwin->axes.u_xgrads[i];
2470 double dx = (ppsubwin->axes.u_xgrads[i+1] - ppsubwin->axes.u_xgrads[i]) / nbsubtics;
2472 for (j=1;j<nbsubtics;j++)
2476 if(vxx1<xminval || vxx1>xmaxval) continue;
2478 if(ppsubwin->axes.reverse[0] == TRUE)
2479 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
2481 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
2482 /* trans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz); */
2485 if (IsDownAxes(psubwin))
2494 vx[1]= (integer) (vx[0]+barlengthx/2.0);
2495 vy[1]= (integer) (vy[0]+barlengthy/2.0);
2498 if(ppsubwin->axes.axes_visible[0] == TRUE)
2499 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2503 /***************************************************************/
2504 /************************* COMMON PART *************************/
2505 /***************************************************************/
2511 else /* we display the computed tics */
2513 AdaptGraduationsOnXBottomLeft(iof,x,y,size,Ticsdir,fontid,psubwin,xminval,xmaxval,0.,fy,fz);
2515 lastxindex = ppsubwin->axes.nxgrads - 1;
2518 ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.xgrads[0]));
2520 ChoixFormatE(c_format,
2521 ppsubwin->axes.xgrads[0],
2522 ppsubwin->axes.xgrads[lastxindex],
2523 ((ppsubwin->axes.xgrads[lastxindex])-(ppsubwin->axes.xgrads[0]))/(lastxindex));
2525 nbtics = ppsubwin->axes.nxgrads;
2526 nbsubtics = ppsubwin->axes.nbsubtics[0];
2528 maxTicksLabelSize[0] = 0 ;
2529 maxTicksLabelSize[1] = 0 ;
2531 for(i=0;i<nbtics;i++)
2534 double xtmp = ppsubwin->axes.xgrads[i];
2536 if(xtmp<xminval || xtmp>xmaxval)
2538 /* sciprint("je rejete la valeur: %lf\n\n",xtmp); */
2539 continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
2540 /* donc autant ne pas aller plus loin dans l'algo... */
2543 sprintf(foo,c_format,xtmp);
2545 /***************************************************************/
2546 /************************* COMMON PART *************************/
2547 /***************************************************************/
2549 if(ppsubwin->axes.reverse[0] == TRUE)
2550 xtmp = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],xtmp);
2552 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz);
2556 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
2557 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
2559 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
2561 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2562 maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
2563 maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
2565 if (IsDownAxes(psubwin)){
2568 posi[0] = inint(xm-rect[2]/2);
2569 posi[1]=inint( vy[0] + iof + rect[3]);}
2571 vx[1]=vx[0]+barlengthx;
2572 vy[1]=vy[0]+barlengthy;
2573 posi[0] = inint( xm+2*barlengthx-rect[2]);
2574 posi[1]=inint( ym + 2*barlengthy + rect[3]);}
2576 if(ppsubwin->axes.axes_visible[0] == TRUE){
2577 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2578 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2579 if ( ppsubwin->logflags[0] == 'l' )
2581 int smallersize = fontid[1]-2;
2585 posi10[0] = posi[0] - logrect[2];
2586 posi10[1] = posi[1] + logrect[3];
2588 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2589 C2F(dr)("xstring","10",(&posi10[0]),(&posi10[1]),PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
2591 C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2593 posi[0] = old_rect10[0] + old_rect10[2];
2594 posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
2596 C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2597 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
2599 /* put back the current fontid */
2600 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2603 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
2605 C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2606 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2608 /* grid to put here */
2609 if ( ppsubwin->grid[0] > -1 && ppsubwin->axes.axes_visible[0] )
2611 gstyle = pSUBWIN_FEATURE (psubwin)->grid[0];
2613 if((ppsubwin->logflags[0] =='l') && (i != nbtics-1))
2617 double * tmp_log_grads = (double *) NULL;
2620 double * grads = ppsubwin->axes.xgrads;
2622 tmp[0] = exp10(grads[i]);
2623 tmp[1] = exp10(grads[i+1]);
2624 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
2626 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
2627 sciprint("Error allocating tmp_log_grads\n");
2631 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
2633 for(j=0;j<nbsubtics;j++)
2635 vxx1 = tmp_log_grads[j];
2637 if(vxx1<=xminval || vxx1>=xmaxval) continue;
2639 if(ppsubwin->axes.reverse[0] == TRUE)
2640 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
2642 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
2645 xg[0]= xm; yg[0]= ym;
2646 if (Ishidden(psubwin))
2647 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
2649 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; }
2650 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2651 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2652 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2653 xg[0]= xg[1]; yg[0]= yg[1];
2654 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]= iybox[0] - iybox[4] +ym;
2655 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2656 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2659 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
2663 if(xtmp>xminval && xtmp<xmaxval)
2665 xg[0]= xm; yg[0]= ym;
2666 if (Ishidden(psubwin))
2667 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
2669 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; }
2670 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2671 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2672 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2673 xg[0]= xg[1]; yg[0]= yg[1];
2674 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]= iybox[0] - iybox[4] +ym;
2675 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2676 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2684 if(ppsubwin->logflags[0] =='l')
2688 double * tmp_log_grads = (double *) NULL;
2691 double * grads = ppsubwin->axes.xgrads;
2693 tmp[0] = exp10(grads[i]);
2694 tmp[1] = exp10(grads[i+1]);
2695 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
2697 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
2698 sciprint("Error allocating tmp_log_grads\n");
2702 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
2704 for(j=0;j<nbsubtics;j++)
2706 vxx1 = tmp_log_grads[j];
2708 if(vxx1<xminval || vxx1>xmaxval) continue;
2710 if(ppsubwin->axes.reverse[0] == TRUE)
2711 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
2713 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
2715 if (IsDownAxes(psubwin))
2724 vx[1]= (integer) (vx[0]+barlengthx/2.0);
2725 vy[1]= (integer) (vy[0]+barlengthy/2.0);
2728 if(ppsubwin->axes.axes_visible[0] == TRUE)
2729 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2731 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
2735 double xtmp2 = ppsubwin->axes.xgrads[i];
2736 double dx = (ppsubwin->axes.xgrads[i+1] - ppsubwin->axes.xgrads[i]) / nbsubtics;
2738 for (j=1;j<nbsubtics;j++)
2742 if(vxx1<xminval || vxx1>xmaxval) continue;
2744 if(ppsubwin->axes.reverse[0] == TRUE)
2745 vxx1 = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],vxx1);
2747 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz);
2748 /* trans3d(psubwin,1,&xm,&ym,&vxx1,&fy,&fz); */
2751 if (IsDownAxes(psubwin))
2760 vx[1]= (integer) (vx[0]+barlengthx/2.0);
2761 vy[1]= (integer) (vy[0]+barlengthy/2.0);
2764 if(ppsubwin->axes.axes_visible[0] == TRUE)
2765 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2769 /***************************************************************/
2770 /************************* COMMON PART *************************/
2771 /***************************************************************/
2777 if ( sciGetVisibility(ppsubwin->mon_x_label) )
2780 sciLabel * ppLabel = pLABEL_FEATURE(ppsubwin->mon_x_label) ;
2781 if( ppLabel->auto_rotation )
2783 sciSetFontOrientation(ppsubwin->mon_x_label, 0 ) ;
2787 if( ppLabel->auto_position )
2790 int segmentStart[2] = { ixbox[3], iybox[3] } ;
2791 int segmentEnd[2] = { ixbox[4], iybox[4] } ;
2793 /* add the bar size and ticks label size to the offset */
2794 int offset[2] = { constOffset[0] + maxTicksLabelSize[0] + abs( barlengthx ),
2795 constOffset[1] + maxTicksLabelSize[1] + abs( barlengthy ) } ;
2796 computeLabelAutoPos( ppsubwin->mon_x_label, segmentStart, segmentEnd, offset ) ;
2798 /* a trick to force the display with 2d scale */
2799 drawTextEntity( ppLabel->text ) ;
2805 if (pSUBWIN_FEATURE (psubwin)->project[1]==1) /* y is HERE */
2811 Ticsdir[0]=ixbox[4]-ixbox[5];
2812 Ticsdir[1]=iybox[4]-iybox[5];
2813 BBoxToval(&fx,&fy,&fz,xind[3],bbox);
2815 x=inint((ixbox[3]+ixbox[4])/2.0 -rect[2] -iof);
2816 y=inint((1/3.0)*iybox[3]+(2/3.0)*iybox[4]+ iof + 1.5*rect[3]);
2818 if(ppsubwin->axes.auto_ticks[1] == FALSE)
2820 /* we display the y tics specified by the user*/
2821 nbtics = ppsubwin->axes.u_nygrads;
2822 nbsubtics = ppsubwin->axes.nbsubtics[1];
2824 maxTicksLabelSize[0] = 0 ;
2825 maxTicksLabelSize[1] = 0 ;
2827 for(i=0;i<nbtics;i++)
2829 char *foo = ppsubwin->axes.u_ylabels[i];
2830 double ytmp = ppsubwin->axes.u_ygrads[i];
2832 if(ytmp<yminval || ytmp>ymaxval)
2834 /* sciprint("je rejete la valeur: %lf\n\n",xtmp); */
2835 continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
2836 /* donc autant ne pas aller plus loin dans l'algo... */
2839 /***************************************************************/
2840 /************************* COMMON PART *************************/
2841 /***************************************************************/
2843 if(ppsubwin->axes.reverse[1] == TRUE)
2844 ytmp = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ytmp);
2846 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz);
2847 /* trans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz); */
2852 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
2853 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
2855 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
2857 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2858 maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
2859 maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
2861 if (IsDownAxes(psubwin)){
2864 posi[0] = inint(xm-rect[2]/2);
2865 posi[1]=inint( vy[0] + iof + rect[3]);}
2867 vx[1]=vx[0]+barlengthx;
2868 vy[1]=vy[0]+barlengthy;
2869 /* posi[0] = inint( xm+2*barlengthx-rect[2]/2); */
2870 posi[0] = inint( xm+2*barlengthx-rect[2]);
2871 posi[1]=inint( ym + 2*barlengthy + rect[3]);}
2874 if(ppsubwin->axes.axes_visible[1] == TRUE){
2875 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2876 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2877 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
2878 C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2879 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2881 /* grid to put here */
2882 if ( ppsubwin->grid[1] > -1 && ppsubwin->axes.axes_visible[1] )
2884 gstyle = pSUBWIN_FEATURE (psubwin)->grid[1];
2886 if((ppsubwin->logflags[1] =='l') && (i != nbtics-1))
2890 double * tmp_log_grads = (double *) NULL;
2893 double * grads = ppsubwin->axes.u_ygrads;
2895 tmp[0] = exp10(grads[i]);
2896 tmp[1] = exp10(grads[i+1]);
2897 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
2899 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
2900 sciprint("Error allocating tmp_log_grads\n");
2904 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
2906 for(j=0;j<nbsubtics;j++)
2908 vyy1 = tmp_log_grads[j];
2910 if(vyy1<=yminval || vyy1>=ymaxval) continue;
2912 if(ppsubwin->axes.reverse[1] == TRUE)
2913 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
2915 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
2917 /* if ((xm != ixbox[3]) && (xm != ixbox[4])) */
2919 xg[0]= xm; yg[0]= ym;
2920 if (Ishidden(psubwin))
2921 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
2923 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; }
2924 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2925 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2926 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2927 xg[0]= xg[1]; yg[0]= yg[1];
2928 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]= iybox[0] - iybox[4] +ym;
2929 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2930 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2933 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
2937 if(ytmp>yminval && ytmp<ymaxval)
2939 xg[0]= xm; yg[0]= ym;
2940 if (Ishidden(psubwin))
2941 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
2943 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; }
2944 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2945 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2946 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2947 xg[0]= xg[1]; yg[0]= yg[1];
2948 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]= iybox[0] - iybox[4] +ym;
2949 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
2950 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
2958 if(ppsubwin->logflags[1] =='l')
2962 double * tmp_log_grads = (double *) NULL;
2965 double * grads = ppsubwin->axes.u_ygrads;
2967 tmp[0] = exp10(grads[i]);
2968 tmp[1] = exp10(grads[i+1]);
2969 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
2971 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
2972 sciprint("Error allocating tmp_log_grads\n");
2976 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
2978 for(j=0;j<nbsubtics;j++)
2980 vyy1 = tmp_log_grads[j];
2982 if(vyy1<yminval || vyy1>ymaxval) continue;
2984 if(ppsubwin->axes.reverse[1] == TRUE)
2985 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
2987 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
2989 if (IsDownAxes(psubwin))
2998 vx[1]= (integer) (vx[0]+barlengthx/2.0);
2999 vy[1]= (integer) (vy[0]+barlengthy/2.0);
3002 if(ppsubwin->axes.axes_visible[1] == TRUE)
3003 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
3005 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
3011 double ytmp2 = ppsubwin->axes.u_ygrads[i];
3012 double dy = (ppsubwin->axes.u_ygrads[i+1] - ppsubwin->axes.u_ygrads[i]) / nbsubtics;
3013 for(j=0;j<nbsubtics;j++)
3017 if(vyy1<yminval || vyy1>ymaxval) continue;
3019 if(ppsubwin->axes.reverse[1] == TRUE)
3020 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
3022 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
3023 /* trans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz); */
3026 if (IsDownAxes(psubwin))
3035 vx[1]= (integer) (vx[0]+barlengthx/2.0);
3036 vy[1]= (integer) (vy[0]+barlengthy/2.0);
3039 if(ppsubwin->axes.axes_visible[1] == TRUE)
3040 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
3044 /***************************************************************/
3045 /************************* COMMON PART *************************/
3046 /***************************************************************/
3050 else /* we display the computed tics */
3052 AdaptGraduationsOnYBottomLeft(iof,x,y,size,Ticsdir,fontid,psubwin,yminval,ymaxval,fx,0.,fz);
3054 lastyindex = ppsubwin->axes.nygrads - 1;
3057 ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.ygrads[0]));
3059 ChoixFormatE(c_format,
3060 ppsubwin->axes.ygrads[0],
3061 ppsubwin->axes.ygrads[lastyindex],
3062 ((ppsubwin->axes.ygrads[lastyindex])-(ppsubwin->axes.ygrads[0]))/(lastyindex));
3064 nbtics = ppsubwin->axes.nygrads;
3065 nbsubtics = ppsubwin->axes.nbsubtics[1];
3067 maxTicksLabelSize[0] = 0 ;
3068 maxTicksLabelSize[1] = 0 ;
3070 for(i=0;i<nbtics;i++)
3073 double ytmp = ppsubwin->axes.ygrads[i];
3075 if(ytmp<yminval || ytmp>ymaxval)
3077 /* sciprint("je rejete la valeur: %lf\n\n",xtmp); */
3078 continue; /* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon */
3079 /* donc autant ne pas aller plus loin dans l'algo... */
3082 sprintf(foo,c_format,ytmp);
3084 /***************************************************************/
3085 /************************* COMMON PART *************************/
3086 /***************************************************************/
3088 if(ppsubwin->axes.reverse[1] == TRUE)
3089 ytmp = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ytmp);
3091 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz);
3092 /* trans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz); */
3097 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
3098 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
3100 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
3102 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3103 maxTicksLabelSize[0] = Max( maxTicksLabelSize[0], rect[2] ) ;
3104 maxTicksLabelSize[1] = Max( maxTicksLabelSize[1], rect[3] ) ;
3106 if (IsDownAxes(psubwin)){
3109 posi[0] = inint(xm-rect[2]/2);
3110 posi[1]=inint( vy[0] + iof + rect[3]);}
3112 vx[1]=vx[0]+barlengthx;
3113 vy[1]=vy[0]+barlengthy;
3114 /* posi[0] = inint( xm+2*barlengthx-rect[2]/2); */
3115 posi[0] = inint( xm+2*barlengthx-rect[2]);
3116 posi[1]=inint( ym + 2*barlengthy + rect[3]);}
3118 if(ppsubwin->axes.axes_visible[1] == TRUE){
3119 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3120 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3121 if ( ppsubwin->logflags[1] == 'l' )
3123 int smallersize = fontid[1]-2;
3125 /* char str[2] = "xv"; */
3128 posi10[0] = posi[0] - logrect[2];
3129 posi10[1] = posi[1] + logrect[3];
3131 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3132 C2F(dr)("xstring","10",(&posi10[0]),(&posi10[1]),PI0,&flag,PI0,PI0,&angle,PD0,PD0,PD0,0L,0L);
3134 C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3136 posi[0] = old_rect10[0] + old_rect10[2];
3137 posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
3139 C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3140 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
3142 /* put back the current fontid */
3143 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3146 C2F(dr)("xstring",foo,&(posi[0]),&(posi[1]),PI0,&flag,PI0,PI0,&ang, PD0,PD0,PD0,0L,0L);
3148 C2F(dr)("xset","pattern",&ticscolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3149 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
3151 /* grid to put here */
3152 if ( ppsubwin->grid[1] > -1 && ppsubwin->axes.axes_visible[1] )
3154 gstyle = pSUBWIN_FEATURE (psubwin)->grid[1];
3156 if((ppsubwin->logflags[1] =='l') && (i != nbtics-1))
3160 double * tmp_log_grads = (double *) NULL;
3163 double * grads = ppsubwin->axes.ygrads;
3165 tmp[0] = exp10(grads[i]);
3166 tmp[1] = exp10(grads[i+1]);
3167 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
3169 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
3170 sciprint("Error allocating tmp_log_grads\n");
3174 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
3176 for(j=0;j<nbsubtics;j++)
3178 vyy1 = tmp_log_grads[j];
3180 if(vyy1<=yminval || vyy1>=ymaxval) continue;
3182 if(ppsubwin->axes.reverse[1] == TRUE)
3183 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
3185 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
3187 /* if ((xm != ixbox[3]) && (xm != ixbox[4])) */
3189 xg[0]= xm; yg[0]= ym;
3190 if (Ishidden(psubwin))
3191 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
3193 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; }
3194 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3195 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3196 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
3197 xg[0]= xg[1]; yg[0]= yg[1];
3198 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]= iybox[0] - iybox[4] +ym;
3199 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
3200 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3203 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
3207 if(ytmp>yminval && ytmp<ymaxval)
3209 xg[0]= xm; yg[0]= ym;
3210 if (Ishidden(psubwin))
3211 { xg[1]= xm; yg[1]= iybox[0] -iybox[5]+ym; }
3213 {xg[1]= ixbox[1] - ixbox[3] +xm; yg[1]= iybox[5] - iybox[4] +ym; }
3214 C2F(dr)("xget","line style",&verbose,dash,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3215 C2F (dr) ("xset", "line style",&gridStyle,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3216 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
3217 xg[0]= xg[1]; yg[0]= yg[1];
3218 xg[1] = ixbox[1] - ixbox[3] +xm; yg[1]= iybox[0] - iybox[4] +ym;
3219 C2F(dr)("xsegs","v", xg, yg, &ns,&gstyle,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
3220 C2F(dr)("xset","line style",dash,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3228 if(ppsubwin->logflags[1] =='l')
3232 double * tmp_log_grads = (double *) NULL;
3235 double * grads = ppsubwin->axes.ygrads;
3237 tmp[0] = exp10(grads[i]);
3238 tmp[1] = exp10(grads[i+1]);
3239 pas = (exp10(grads[i+1]) - exp10(grads[i])) / (nbsubtics );
3241 if((tmp_log_grads = (double *)MALLOC(nbsubtics*sizeof(double)))==NULL){
3242 sciprint("Error allocating tmp_log_grads\n");
3246 for(j=0;j<nbsubtics;j++) tmp_log_grads[j] = log10(tmp[0]+(j)*pas);
3248 for(j=0;j<nbsubtics;j++)
3250 vyy1 = tmp_log_grads[j];
3252 if(vyy1<yminval || vyy1>ymaxval) continue;
3254 if(ppsubwin->axes.reverse[1] == TRUE)
3255 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
3257 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
3259 if (IsDownAxes(psubwin))
3268 vx[1]= (integer) (vx[0]+barlengthx/2.0);
3269 vy[1]= (integer) (vy[0]+barlengthy/2.0);
3272 if(ppsubwin->axes.axes_visible[1] == TRUE)
3273 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
3275 FREE(tmp_log_grads); tmp_log_grads = (double *) NULL;
3281 double ytmp2 = ppsubwin->axes.ygrads[i];
3282 double dy = (ppsubwin->axes.ygrads[i+1] - ppsubwin->axes.ygrads[i]) / nbsubtics;
3283 for(j=0;j<nbsubtics;j++)
3287 if(vyy1<yminval || vyy1>ymaxval) continue;
3289 if(ppsubwin->axes.reverse[1] == TRUE)
3290 vyy1 = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],vyy1);
3292 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&vyy1,&fz);
3294 if (IsDownAxes(psubwin))
3303 vx[1]= (integer) (vx[0]+barlengthx/2.0);
3304 vy[1]= (integer) (vy[0]+barlengthy/2.0);
3307 if(ppsubwin->axes.axes_visible[1] == TRUE)
3308 C2F(dr)("xsegs","v", vx, vy, &ns,&ticscolor,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
3313 /***************************************************************/
3314 /************************* COMMON PART *************************/
3315 /***************************************************************/
3320 if ( sciGetVisibility(ppsubwin->mon_y_label) )
3322 sciLabel * ppLabel = pLABEL_FEATURE(ppsubwin->mon_y_label) ;
3323 if( ppLabel->auto_rotation )
3325 sciSetFontOrientation(ppsubwin->mon_y_label, 0 ) ;
3328 if( ppLabel->auto_position )
3331 int segmentStart[2] = { ixbox[3], iybox[3] } ;
3332 int segmentEnd[2] = { ixbox[4], iybox[4] } ;
3334 /* add the bar size and ticks label size to the offset */
3335 int offset[2] = { constOffset[0] + maxTicksLabelSize[0] + abs( barlengthx ),
3336 constOffset[1] + maxTicksLabelSize[1] + abs( barlengthy ) } ;
3337 computeLabelAutoPos( ppsubwin->mon_y_label, segmentStart, segmentEnd, offset ) ;
3339 /* a trick to force the display with 2d scale */
3340 drawTextEntity( ppLabel->text ) ;
3344 /* reset font to its current size & to current color*/
3345 if ( fontsize != -1 ){
3346 fontid[1] = fontsize_kp;
3347 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3349 if ( textcolor != -1 || ticscolor != -1 )
3350 C2F(dr)("xset","pattern",&color_kp,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3368 BOOL Ishidden(sciPointObj *pobj)
3371 if (sciGetEntityType(pobj) == SCI_SUBWIN){
3372 alpha = pSUBWIN_FEATURE (pobj)->alpha;
3373 if ((alpha <0.0 ) && (alpha > -90.0))
3375 if ((alpha <360.0 ) && (alpha > 270.0)) /* missing case added to fix bug 839 F.Leray */
3377 if ((alpha <-180.0 ) && (alpha > -270.0))
3379 if ((alpha <180.0 ) && (alpha > 90.0))
3385 /* When alpha is close to a singularity (90,-90,270...), use to determine how to draw the x and y graduations */
3386 /* depending on cof */
3387 BOOL IsDownAxes(sciPointObj *pobj)
3391 if (sciGetEntityType(pobj) == SCI_SUBWIN){
3392 alpha = pSUBWIN_FEATURE (pobj)->alpha;
3393 if (!(pSUBWIN_FEATURE (pobj)->isoview))
3396 cof = 5.0; /* F.Leray : hard fixed here */
3397 /* Correction Warnings Attention Precision*/
3398 /* cof= (double) (Min(5.0,ceil(Max( */
3399 /* abs((int)ppsubwin->axes.xlim[1]-(int)ppsubwin->axes.xlim[0])/ */
3400 /* abs((int)ppsubwin->axes.ylim[1]-(int)ppsubwin->axes.ylim[0]), */
3401 /* abs((int)ppsubwin->axes.ylim[1]-(int)ppsubwin->axes.ylim[0])/ */
3402 /* abs((int)ppsubwin->axes.xlim[1]-(int)ppsubwin->axes.xlim[0]))))); */
3403 if (cof == 0 ) cof =5;
3404 if ((alpha <=(-90.0+cof) ) && (alpha >= (-90.0-cof)))
3406 if ((alpha <=(-270.0+cof) ) && (alpha >= (-270.0-cof)))
3408 if ((alpha <=(90.0+cof) ) && (alpha >= (90.0-cof)))
3410 if ((alpha <=(270.0+cof) ) && (alpha >= (270.0-cof)))
3416 /* compute the graduation of the segment [minVal,maxVal] knowing the number of ticks */
3417 void GradFixedlog( double minVal, double maxVal, double * ticks, int nbGrads )
3422 /* intialize the array as usual */
3423 GradLog( minVal, maxVal, ticks, &initSize, FALSE ) ;
3425 if ( initSize > nbGrads )
3427 /* we create a smaller vector from a bigger one */
3428 int nbRemove = initSize - nbGrads ;
3430 BOOL * removedTicks ;
3431 if( ( removedTicks = MALLOC( initSize * sizeof(BOOL) ) ) == NULL )
3436 for ( i = 0 ; i < initSize ; i++ )
3438 removedTicks[i] = FALSE ;
3441 /* we now remove the nbremove indexes : round( ( 0.5 + i ) * size / nbRemove ) */
3442 /* i=0..nbReg-1 should do the thing */
3443 for ( i = 0 ; i < nbRemove ; i++ )
3445 int remIndex = 1 + (int) round( i * ((double) initSize - 2 ) / ( (double) nbRemove ) ) ;
3446 removedTicks[remIndex] = TRUE ;
3449 removeBadTicks( ticks, removedTicks, &initSize ) ;
3451 FREE( removedTicks ) ;
3458 /* compute the automatic graduation of the segment [_min,_max] and store it in _grads */
3459 /* the number of graduation may be fixed if compNgrads is TRUE or automaticaly computed */
3461 int GradLog( double _min ,
3468 int log_min, log_max;
3473 GradFixedlog( _min, _max, _grads, *n_grads ) ;
3477 log_max = (int) ceil(_max);
3478 log_min = (int) floor(_min);
3481 size = log_max - log_min +1;
3482 /* tab=(int *)MALLOC(size*sizeof(int)); */
3484 /* for(i=0;i<size;i++) tab[i]=log_min+i; */
3491 /* _grads[i] = exp10(tab[i]); */
3492 _grads[i] = log_min+i;
3493 *n_grads = (*n_grads) + 1;
3494 /* sciprint("Juste en sortie, _grads[%d] = %lf\n",i, _grads[i]); */
3499 int pas = 0, old_pas= 0,j;
3500 int val = size, passed = 0;
3502 for(j=val-1;j>1;j--)
3509 if(old_pas != 0) {pas = old_pas; }
3514 if(passed != 1 || (size/pas)>15 ) pas = size;
3518 _grads[0] = log_min;
3519 _grads[1] = log_max;
3524 for(i=0;i<=(int )(size/pas);i++)
3526 _grads[i] = log_min+(i*pas);
3528 *n_grads = (*n_grads) + 1;
3529 /* sciprint("Juste en sortie, _grads[%d] = %lf\n",i, _grads[i]); */
3538 * get the exponent used for log axis from given data bounds
3539 * @return 0 if OK, -1 if negative bounds.
3541 int sciGetLogExponent( double minBound, double maxBound, double * expMin, double * expMax )
3545 *expMin = floor( log10( minBound ) ) ;
3546 *expMax = ceil( log10( maxBound ) ) ;
3554 /* get the displayed bounds of an axis */
3555 void sciGetDisplayedBounds( sciPointObj * pSubWin,
3563 sciSubWindow * ppsubwin = pSUBWIN_FEATURE ( pSubWin ) ;
3564 /*****************************************************************
3565 * get initial bounds
3566 *****************************************************************/
3567 if( sciGetZooming( pSubWin ) )
3569 *xmin = ppsubwin->ZRect[0] ;
3570 *ymin = ppsubwin->ZRect[1] ;
3571 *xmax = ppsubwin->ZRect[2] ;
3572 *ymax = ppsubwin->ZRect[3] ;
3573 *zmin = ppsubwin->ZRect[4] ;
3574 *zmax = ppsubwin->ZRect[5] ;
3578 *xmin = ppsubwin->SRect[0] ;
3579 *ymin = ppsubwin->SRect[2] ;
3580 *xmax = ppsubwin->SRect[1] ;
3581 *ymax = ppsubwin->SRect[3] ;
3582 *zmin = ppsubwin->SRect[4] ;
3583 *zmax = ppsubwin->SRect[5] ;
3588 /*****************************************************************
3589 * modify bounds and aaint if using log scaling X axis
3590 *****************************************************************/
3591 if ( ppsubwin->logflags[0] == 'l' )
3593 if ( sciGetLogExponent( *xmin, *xmax, xmin, xmax ) != 0 )
3595 sciprint("Warning: Can't use Log on X-axis xmin is negative. \n");
3599 /*****************************************************************
3600 * modify bounds and aaint if using log scaling Y axis
3601 *****************************************************************/
3602 if ( ppsubwin->logflags[1] == 'l' )
3604 if ( sciGetLogExponent( *ymin, *ymax, ymin, ymax ) != 0 )
3606 sciprint("Warning: Can't use Log on Y-axis ymin is negative. \n");
3610 /*****************************************************************
3611 * modify bounds and aaint if using log scaling Z axis
3612 *****************************************************************/
3613 if ( ppsubwin->logflags[2] == 'l' )
3615 if ( sciGetLogExponent( *zmin, *zmax, zmin, zmax ) != 0 )
3617 sciprint("Warning: Can't use Log on Z-axis zmin is negative. \n");
3623 /* F.Leray au 13.10.04 completly review for new axes graduations */
3624 /*** F.Leray 02.04.04 */
3625 /* FUNCTION FOR 2D UPDATE ONLY !!!!! <=> beginning of axis_3ddraw (in 2d HERE of course! ) */
3626 /* Copy on update_frame_bounds */
3627 BOOL sci_update_frame_bounds_2d(sciPointObj *pobj)
3629 double xmax, xmin, ymin, ymax, zmin, zmax ;
3630 double hx,hy,hx1,hy1;
3633 sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
3634 double FRect[4],WRect[4],ARect[4];
3637 /* Temp variables only used when called from update_specification_bounds */
3638 /* to know if we have to redraw all the figure */
3639 double ExistingFRect[4]; /* the Existing FRect at start to be compared at the end of this routine */
3640 /* in order to determine wheter or not the bounds have changed... */
3643 /* End of Temp variables */
3645 for(i=0;i<4;i++) ExistingFRect[i] = ppsubwin->FRect[i]; /* store old initial bounds*/
3647 for(i=0;i<2;i++) nbsubtics[i] = ppsubwin->axes.nbsubtics[i];
3648 nbgrads[0] = ppsubwin->axes.nxgrads;
3649 nbgrads[1] = ppsubwin->axes.nygrads;
3651 /* nbtics on z put to 0 */
3652 /* ppsubwin->axes.nzgrads = 0; */
3655 sciGetDisplayedBounds( pobj, &xmin, &xmax, &ymin, &ymax, &zmin, &zmax ) ;
3658 /* _grad Init. to 0. */
3661 ppsubwin->axes.xgrads[i] = 0.;
3662 ppsubwin->axes.ygrads[i] = 0.;
3666 if ( ppsubwin->logflags[0]=='n') { /* x-axis */
3667 TheTicks(&xmin, &xmax, &(ppsubwin->axes.xgrads[0]), &ppsubwin->axes.nxgrads, FALSE);
3668 ppsubwin->axes.nbsubtics[0] = ComputeNbSubTics(pobj,ppsubwin->axes.nxgrads,'n',NULL,ppsubwin->axes.nbsubtics[0]); /* Nb of subtics computation and storage */ /* F.Leray 07.10.04 */
3670 else{ /* log. case */
3671 GradLog(xmin,xmax,ppsubwin->axes.xgrads,&ppsubwin->axes.nxgrads, FALSE );
3672 ppsubwin->axes.nbsubtics[0] = ComputeNbSubTics(pobj,ppsubwin->axes.nxgrads,'l',ppsubwin->axes.xgrads,0);
3675 if ( ppsubwin->logflags[1]=='n') { /* y-axis */
3676 TheTicks(&ymin, &ymax, &(ppsubwin->axes.ygrads[0]), &ppsubwin->axes.nygrads, FALSE);
3677 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTics(pobj,ppsubwin->axes.nygrads,'n',NULL, ppsubwin->axes.nbsubtics[1]); /* Nb of subtics computation and storage */ /* F.Leray 07.10.04 */
3679 else{ /* log. case */
3680 GradLog(ymin,ymax,ppsubwin->axes.ygrads,&ppsubwin->axes.nygrads, FALSE );
3681 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTics(pobj,ppsubwin->axes.nygrads,'l',ppsubwin->axes.ygrads,0);
3684 if(ppsubwin->tight_limits == FALSE )
3686 xmin = ppsubwin->axes.xgrads[0];
3687 xmax = ppsubwin->axes.xgrads[ ppsubwin->axes.nxgrads - 1];
3688 ymin = ppsubwin->axes.ygrads[0];
3689 ymax = ppsubwin->axes.ygrads[ ppsubwin->axes.nygrads - 1];
3692 /*****************************************************************
3693 * modify bounds if isoview requested
3694 *****************************************************************/
3695 if ( ppsubwin->isoview == TRUE) {
3696 int verbose=0,wdim[2],narg;
3698 C2F(dr)("xget","wdim",&verbose,wdim,&narg, PI0, PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
3701 getscale2d(WRect,FRect,logscale,ARect);
3703 wdim[0]=linint((double)wdim[0] *WRect[2]);
3704 wdim[1]=linint((double)wdim[1] *WRect[3]);
3706 if ( hx/(double)wdim[0] <hy/(double) wdim[1] ) {
3707 hx1=wdim[0]*hy/wdim[1];
3708 xmin=xmin-(hx1-hx)/2.0;
3709 xmax=xmax+(hx1-hx)/2.0;
3712 hy1=wdim[1]*hx/wdim[0];
3713 ymin=ymin-(hy1-hy)/2.0;
3714 ymax=ymax+(hy1-hy)/2.0;
3717 /* F.Leray 28.09.04 */
3718 /* I need to recompute the correct xgrads and ygrads vector to have a good display */
3720 if ( ppsubwin->logflags[0]=='n') { /* x-axis */
3721 TheTicks(&xmin, &xmax, &(ppsubwin->axes.xgrads[0]), &ppsubwin->axes.nxgrads, FALSE);
3722 ppsubwin->axes.nbsubtics[0] = ComputeNbSubTics(pobj,ppsubwin->axes.nxgrads,'n',NULL, ppsubwin->axes.nbsubtics[0]); /* Nb of subtics computation and storage */ /* F.Leray 07.10.04 */
3724 else{ /* log. case */
3725 GradLog(xmin,xmax,ppsubwin->axes.xgrads,&ppsubwin->axes.nxgrads, FALSE);
3726 ppsubwin->axes.nbsubtics[0] = ComputeNbSubTics(pobj,ppsubwin->axes.nxgrads,'l',ppsubwin->axes.xgrads,0);
3731 if ( ppsubwin->logflags[1]=='n') { /* y-axis */
3732 TheTicks(&ymin, &ymax, &(ppsubwin->axes.ygrads[0]), &ppsubwin->axes.nygrads, FALSE);
3733 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTics(pobj,ppsubwin->axes.nygrads,'n',NULL, ppsubwin->axes.nbsubtics[1]); /* Nb of subtics computation and storage */ /* F.Leray 07.10.04 */
3735 else{ /* log. case */
3736 GradLog(ymin,ymax,ppsubwin->axes.ygrads,&ppsubwin->axes.nygrads, FALSE );
3737 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTics(pobj,ppsubwin->axes.nygrads,'l',ppsubwin->axes.ygrads,0);
3744 /* Changement ci-dessous F.Leray 21.09.04 */
3745 ppsubwin->axes.xlim[0]=xmin;
3746 ppsubwin->axes.xlim[1]=xmax;
3747 ppsubwin->axes.xlim[2]=0;
3748 ppsubwin->axes.ylim[0]=ymin;
3749 ppsubwin->axes.ylim[1]=ymax;
3750 ppsubwin->axes.ylim[2]=0;
3754 /*****************************************************************
3755 * set the actual bounds in subwindow data structure
3756 *****************************************************************/
3759 ppsubwin->FRect[0]=xmin;
3760 ppsubwin->FRect[2]=xmax;
3761 ppsubwin->FRect[1]=ymin;
3762 ppsubwin->FRect[3]=ymax;
3764 ppsubwin->axes.xlim[3] = ppsubwin->axes.nxgrads;
3765 ppsubwin->axes.ylim[3] = ppsubwin->axes.nygrads;
3767 /* ppsubwin->axes.reverse[0] = FALSE; /\*TRUE;*\/ /\* TEST en DUR F.Leray ICIIIIIIIIIIIII 12.10.04 *\/ */
3768 /* ppsubwin->axes.reverse[1] = FALSE; /\*TRUE;*\/ */
3771 set_scale("tftftf",NULL,ppsubwin->FRect,NULL,ppsubwin->logflags,NULL);
3775 if(ppsubwin->FRect[i] != ExistingFRect[i]){
3781 if(nbsubtics[i] != ppsubwin->axes.nbsubtics[i]){
3786 if(nbgrads[0] != ppsubwin->axes.nxgrads) return TRUE;
3787 if(nbgrads[1] != ppsubwin->axes.nygrads) return TRUE;
3792 /**update_3dbounds -> renammed sci_update_frame_bounds_3d
3793 * @author Djalel Abdemouche 10/2003
3794 * Should be in Plo2dEch.c file
3796 BOOL sci_update_frame_bounds_3d(sciPointObj *pobj)
3798 double xmin,xmax,ymin,ymax,zmin,zmax;
3800 sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
3802 /* Temp variables only used when called from update_specification_bounds */
3803 /* to know if we have to redraw all the figure */
3804 double ExistingFRect[6]; /* the Existing FRect at start to be compared at the end of this routine */
3805 /* in order to determine wheter or not the bounds have changed... */
3808 /* End of Temp variables */
3810 for(i=0;i<6;i++) ExistingFRect[i] = ppsubwin->FRect[i]; /* store old initial bounds*/
3812 for(i=0;i<3;i++) nbsubtics[i] = ppsubwin->axes.nbsubtics[i];
3813 nbgrads[0] = ppsubwin->axes.nxgrads;
3814 nbgrads[1] = ppsubwin->axes.nygrads;
3815 nbgrads[2] = ppsubwin->axes.nzgrads;
3817 sciGetDisplayedBounds( pobj, &xmin, &xmax, &ymin, &ymax, &zmin, &zmax ) ;
3820 /* _grad Init. to 0. */
3823 ppsubwin->axes.xgrads[i] = 0.;
3824 ppsubwin->axes.ygrads[i] = 0.;
3825 ppsubwin->axes.zgrads[i] = 0.;
3829 if ( ppsubwin->logflags[0]=='n') { /* x-axis */
3830 TheTicks(&xmin, &xmax, &(ppsubwin->axes.xgrads[0]), &ppsubwin->axes.nxgrads, FALSE);
3831 ppsubwin->axes.nbsubtics[0] = ComputeNbSubTics(pobj,ppsubwin->axes.nxgrads,'n',NULL,ppsubwin->axes.nbsubtics[0]); /* Nb of subtics computation and storage */
3833 else{ /* log. case */
3834 GradLog(xmin,xmax,ppsubwin->axes.xgrads,&ppsubwin->axes.nxgrads, FALSE );
3835 ppsubwin->axes.nbsubtics[0] = ComputeNbSubTics(pobj,ppsubwin->axes.nxgrads,'l',ppsubwin->axes.xgrads,0);
3838 if ( ppsubwin->logflags[1]=='n') { /* y-axis */
3839 TheTicks(&ymin, &ymax, &(ppsubwin->axes.ygrads[0]), &ppsubwin->axes.nygrads, FALSE);
3840 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTics(pobj,ppsubwin->axes.nygrads,'n',NULL, ppsubwin->axes.nbsubtics[1]); /* Nb of subtics computation and storage */
3842 else{ /* log. case */
3843 GradLog(ymin,ymax,ppsubwin->axes.ygrads,&ppsubwin->axes.nygrads, FALSE );
3844 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTics(pobj,ppsubwin->axes.nygrads,'l',ppsubwin->axes.ygrads,0);
3847 if ( ppsubwin->logflags[2]=='n') { /* z-axis */
3848 TheTicks(&zmin, &zmax, &(ppsubwin->axes.zgrads[0]), &ppsubwin->axes.nzgrads, FALSE);
3849 ppsubwin->axes.nbsubtics[2] = ComputeNbSubTics(pobj,ppsubwin->axes.nzgrads,'n',NULL, ppsubwin->axes.nbsubtics[2]); /* Nb of subtics computation and storage */
3851 else{ /* log. case */
3852 GradLog(zmin,zmax,ppsubwin->axes.zgrads,&ppsubwin->axes.nzgrads, FALSE );
3853 ppsubwin->axes.nbsubtics[2] = ComputeNbSubTics(pobj,ppsubwin->axes.nzgrads,'l',ppsubwin->axes.zgrads,0);
3856 if(ppsubwin->tight_limits == FALSE )
3858 xmin = ppsubwin->axes.xgrads[0];
3859 xmax = ppsubwin->axes.xgrads[ ppsubwin->axes.nxgrads - 1];
3860 ymin = ppsubwin->axes.ygrads[0];
3861 ymax = ppsubwin->axes.ygrads[ ppsubwin->axes.nygrads - 1];
3862 zmin = ppsubwin->axes.zgrads[0];
3863 zmax = ppsubwin->axes.zgrads[ ppsubwin->axes.nzgrads - 1];
3866 ppsubwin->axes.xlim[0]=xmin;
3867 ppsubwin->axes.xlim[1]=xmax;
3868 ppsubwin->axes.xlim[2]=0;
3869 ppsubwin->axes.ylim[0]=ymin;
3870 ppsubwin->axes.ylim[1]=ymax;
3871 ppsubwin->axes.ylim[2]=0;
3872 ppsubwin->axes.zlim[0]=zmin; /* rajout pour z */
3873 ppsubwin->axes.zlim[1]=zmax;
3874 ppsubwin->axes.zlim[2]=0;
3876 ppsubwin->FRect[0]=xmin;
3877 ppsubwin->FRect[2]=xmax;
3878 ppsubwin->FRect[1]=ymin;
3879 ppsubwin->FRect[3]=ymax;
3880 ppsubwin->FRect[4]=zmin;
3881 ppsubwin->FRect[5]=zmax;
3883 ppsubwin->axes.xlim[3] = ppsubwin->axes.nxgrads;
3884 ppsubwin->axes.ylim[3] = ppsubwin->axes.nygrads;
3885 ppsubwin->axes.zlim[3] = ppsubwin->axes.nzgrads;
3887 set_scale("tftftf",NULL,ppsubwin->FRect,NULL,ppsubwin->logflags,NULL);
3889 wininfo("alpha=%.1f,theta=%.1f",ppsubwin->alpha,ppsubwin->theta);
3892 if(ppsubwin->FRect[i] != ExistingFRect[i]){
3898 if(nbsubtics[i] != ppsubwin->axes.nbsubtics[i]){
3903 if(nbgrads[0] != ppsubwin->axes.nxgrads) return TRUE;
3904 if(nbgrads[1] != ppsubwin->axes.nygrads) return TRUE;
3905 if(nbgrads[2] != ppsubwin->axes.nzgrads) return TRUE;
3916 int ComputeNbSubTics(sciPointObj * pobj, int nbtics, char logflag, double * grads, int nbsubtics_input)
3918 int ticsval[] = {2 ,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
3919 int subticsval[] = {10,7,5,5,4,4,3,2,2 ,2 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 };
3921 sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
3925 if((grads[1]-grads[0])==1) /* intervalle de type ...10^n 10^(n+1)...*/
3927 return 9; /* 9 subtics to have a pretty tics/grid in log.*/
3931 return 1; /* no subtics at all (1 but draw on a tics place) */
3935 if(ppsubwin->flagNax == FALSE) /* if auto subtics mode == ON */
3938 if(nbtics == ticsval[i])
3940 return subticsval[i];
3943 else /* if auto subtics mode == OFF already computed in Plo2dn.c, Champ.c routines... */
3944 { /* or given via a.subtics=[nbsubtics_on_x, nbsubtics_on_y, nbsubtics_on_z] command */
3945 return nbsubtics_input;
3952 /* test on x and y axes only : used in 2D routines only */
3953 BOOL GetIsAxes2D(sciPointObj *psubwin)
3955 sciSubWindow * ppsubwin = pSUBWIN_FEATURE (psubwin);
3957 if((ppsubwin->axes.axes_visible[0] == FALSE)
3958 && (ppsubwin->axes.axes_visible[1] == FALSE))
3964 int ComputeCorrectXindAndInsideUD(double Teta,double Alpha, double *dbox, integer *xind, integer *InsideU, integer *InsideD)
3966 double xbox[8], ybox[8], zbox[8];
3968 Teta = 0.1; /* Little offset to compute correct values for xind, InsideU and InsideD */
3970 /* update Cscale.m from the new viewing angles */
3971 sciUpdateScaleAngles( Teta, Alpha ) ;
3973 sciGetAxisBox( dbox, xbox, ybox, zbox ) ;
3975 sciAxesVerticesIndices( InsideU, InsideD, xbox, ybox, xind ) ;
3980 /* don't waste time on %NaN */
3981 int CheckIfiisNan(int j, int dim, int * tab)
3996 int ComputeGoodTrans3d( sciPointObj * psubwin, int n, int *xm, int *ym, double * fx, double *fy, double *fz)
3998 sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
4001 double tmp_fx = *fx;
4002 double tmp_fy = *fy;
4003 double tmp_fz = *fz;
4005 if(ppsubwin->logflags[0] == 'l')
4006 tmp_fx = exp10(tmp_fx);
4008 if(ppsubwin->logflags[1] == 'l')
4009 tmp_fy = exp10(tmp_fy);
4011 if(ppsubwin->logflags[2] == 'l')
4012 tmp_fz = exp10(tmp_fz);
4014 trans3d(psubwin, n, xm, ym, &tmp_fx, &tmp_fy, &tmp_fz);
4020 /**DrawAxesIfRequired
4021 * Draws Axes (only the basic graphicobject under subwindows) in its SubWindow or figure
4022 * if and only if pFIGURE_FEATURE(pobj)->auto_redraw == TRUE !!
4023 * Only used inside High Level functions calls (sucha as plot2d, plot3d...)
4024 * @param sciPointObj * pobj: the pointer to the entity
4025 * @return int 0 if OK, -1 if not
4027 void DrawAxesIfRequired(sciPointObj * pobj)
4029 sciPointObj * pfigure = sciGetParentFigure(pobj);
4031 if( pFIGURE_FEATURE(pfigure)->auto_redraw && pFIGURE_FEATURE(pfigure)->visible )
4038 /* Routine used inside Plo2dn.c, Champ.c, Gray.c... */
4039 /* to force the drawing of the axes after a new object is created */
4040 void DrawAxes(sciPointObj * pobj)
4042 sciPointObj * psubwin = sciGetParentSubwin(pobj);
4043 /* sciPointObj * pfigure = sciGetParentFigure(pobj); */
4045 integer x[6], v, markidsizenew[2];
4048 if (!sciGetVisibility(pobj)) return;
4050 x[0] = sciGetForeground (psubwin);
4051 x[2] = sciGetLineWidth (psubwin);
4052 x[3] = sciGetLineStyle (psubwin);
4053 markidsizenew[0] = sciGetMarkStyle(psubwin);
4054 markidsizenew[1] = sciGetLineWidth (psubwin);
4060 sciSetSelectedSubWin(psubwin);
4062 set_scale ("tttftt", pSUBWIN_FEATURE (psubwin)->WRect, pSUBWIN_FEATURE (psubwin)->FRect,
4063 NULL, pSUBWIN_FEATURE (psubwin)->logflags,
4064 pSUBWIN_FEATURE (psubwin)->ARect);
4066 if (!pSUBWIN_FEATURE (psubwin)->is3d) /* we are in 2D mode...*/
4068 /* F.Leray 07.12.04 */
4069 /* TO CORRECT the bug 1115 : Big object (grayplots) could cover axes*/
4070 C2F (dr) ("xset","dashes",x,x,x+4,x+4,x+4,&v,&dv,&dv,&dv,&dv,5L,4096);
4071 C2F (dr) ("xset","foreground",x,x,x+4,x+4,x+4,&v,&dv,&dv,&dv,&dv,5L,4096);
4072 C2F (dr) ("xset","thickness",x+2,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4073 C2F (dr) ("xset","mark",&markidsizenew[0],&markidsizenew[1],PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4075 rebuild_strflag(psubwin,STRFLAG);
4076 axis_draw2 (STRFLAG); /* Axes is rebuilt here to avoid being covered by the new created object */
4081 /* Used only when switching from a plot3d to a plot2d or
4082 * when typing: a=gca();
4083 * a.view='2d' and we were in 3d
4084 * to have a good update of 3d graphics scale in 2D
4085 * whenever we are in auto_redraw OFF */
4086 void UpdateSubwinScale(sciPointObj * pobj)
4088 sciSubWindow * ppsubwin = pSUBWIN_FEATURE (pobj);
4089 sciPointObj * currentsubwin = NULL;
4090 BOOL vis_save = FALSE;
4091 double xbox[8],ybox[8],zbox[8];
4092 static integer InsideU[4],InsideD[4];
4094 currentsubwin = (sciPointObj *)sciGetSelectedSubWin (sciGetCurrentFigure ());
4096 sciSetSelectedSubWin(pobj);
4098 /* set_scale ("tttftt", pSUBWIN_FEATURE (pobj)->WRect, pSUBWIN_FEATURE (pobj)->FRect, */
4099 /* NULL, pSUBWIN_FEATURE (pobj)->logflags, */
4100 /* pSUBWIN_FEATURE (pobj)->ARect); */
4103 { /* 3D Coordinates */ /* verifier si c'est encore utile SS */
4104 /*To have directly all the possible ISOVIEW Modes*/
4105 long isoflag = (long)(ppsubwin->axes.flag[1]+1)/2;
4107 if(ppsubwin->isoview == TRUE) {
4108 if(isoflag ==2 || isoflag == 3){ }
4110 if((ppsubwin->axes.flag[1] == 0)
4111 || (ppsubwin->axes.flag[1] == 2))
4112 /* The default isoview mode is type=4 3d isometric bounds
4113 derived from the data, to similarily type=2 */
4114 ppsubwin->axes.flag[1] = 4;
4115 else if(ppsubwin->axes.flag[1] == 1)
4116 ppsubwin->axes.flag[1] = 3;
4120 if((ppsubwin->axes.flag[1] == 3)
4121 || (ppsubwin->axes.flag[1] == 5))
4122 ppsubwin->axes.flag[1] = 1; /* computed from ebox*/
4123 else if((ppsubwin->axes.flag[1] == 4)
4124 || (ppsubwin->axes.flag[1] == 6))
4125 /* The default NON-isoview mode is 2 computed from data*/
4126 ppsubwin->axes.flag[1] = 2;
4130 vis_save = sciGetVisibility(pobj);
4132 sciSetVisibility(pobj,FALSE);
4133 axis_3ddraw(pobj,xbox,ybox,zbox,InsideU,InsideD); /* TEST on sciGetVisibility inside */
4134 /* because axis_3ddraw displays 3d axes BUT ALSO compute + reset the 3d scale BEFORE !! */
4135 sciSetVisibility(pobj,vis_save);
4137 else /* we are in 2D mode...*/
4139 sci_update_frame_bounds_2d(pobj);
4142 sciSetSelectedSubWin(currentsubwin);
4146 int Gen3DPoints(integer type,integer *polyx, integer *polyy, integer *fill, integer whiteid, double zmin, double zmax, double *x, double *y, double *z, integer i, integer j, integer jj1, integer *p, integer dc, integer fg, sciPointObj * psurface)
4151 sciPointObj *psubwin = sciGetSelectedSubWin (sciGetCurrentFigure ());
4152 sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
4153 sciSurface * ppsurface = pSURFACE_FEATURE (psurface);
4155 pobj = sciGetSelectedSubWin (sciGetCurrentFigure ());
4156 if (trans3d(pobj ,1, &(polyx[ 5*jj1]),&(polyy[ 5*jj1]),&(x[i]),&(y[j]),&(z[i+(*p)*j]))==0) return 0;
4157 if (trans3d(pobj ,1, &(polyx[1+ 5*jj1]),&(polyy[1+ 5*jj1]),&(x[i]),&(y[j+1]),&(z[i+(*p)*(j+1)]))==0) return 0;
4158 if (trans3d(pobj ,1, &(polyx[2+ 5*jj1]),&(polyy[2+ 5*jj1]),&(x[i+1]),&(y[j+1]),&(z[(i+1)+(*p)*(j+1)]))==0) return 0;
4159 if (trans3d(pobj ,1, &(polyx[3+ 5*jj1]),&(polyy[3+ 5*jj1]),&(x[i+1]),&(y[j]),&(z[(i+1)+(*p)*j]))==0) return 0;
4160 if (trans3d(pobj ,1, &(polyx[4+ 5*jj1]),&(polyy[4+ 5*jj1]),&(x[i]),&(y[j]),&(z[i+(*p)*j]))==0) return 0;
4163 if(ppsubwin->axes.reverse[0] == TRUE) facteur = -facteur;
4164 if(ppsubwin->axes.reverse[1] == TRUE) facteur = -facteur;
4165 if(ppsubwin->axes.reverse[2] == TRUE) facteur = -facteur;
4168 facteur = ppsurface->flag_x * ppsurface->flag_y * facteur;
4170 /* type == flagcolor and dc == color_mode */
4171 /* fg = hidden color */
4173 if ((((polyx[1+5*jj1]-polyx[0+5*jj1])*(polyy[2+5*jj1]-polyy[0+5*jj1])-
4174 (polyy[1+5*jj1]-polyy[0+5*jj1])*(polyx[2+5*jj1]-polyx[0+5*jj1]))*facteur < 0) && (fg >=0 ))
4177 /* ------------------- */
4178 /* Beneath the surface */
4179 /* ------------------- */
4181 if (type != 0) /* flagcolor = 1 case : special treatment compared to flagcolor = 0 */
4182 /* don't know why... F.Leray */
4183 fill[jj1]= (dc < 0 ) ? -fg : fg ;
4184 else /* flagcolor = 0 : No shading at all, fixed facecolor. */
4185 fill[jj1]= (dc != 0 ) ? fg : dc ;
4190 /* ------------------- */
4191 /* Above the surface */
4192 /* ------------------- */
4195 { /* flagcolor = 1 : Z-level flat shading. */
4196 fill[jj1]=inint((whiteid-1)*((1/4.0*( z[i+(*p)*j]+ z[i+1+(*p)*j]+
4197 z[i+(*p)*(j+1)]+ z[i+1+(*p)*(j+1)])-zmin)
4199 if ( dc < 0 ) fill[jj1]= -fill[jj1];
4211 int Merge3dDimension(sciPointObj *pparent)
4216 /* ========================================================================
4217 * Compute the number of facets, segments,... included in all the subwin
4219 * Each entities to merge; is decomposed in a set of basic elements
4220 * (facet, segment, point,...)
4221 * Each basic element is represented in the Merge structure by the handle of its entity and an
4222 * index within this entity
4223 * ========================================================================*/
4226 psonstmp = sciGetSons (pparent);
4227 while (psonstmp != (sciSons *) NULL) {
4228 switch (sciGetEntityType (psonstmp->pointobj)) {
4230 if (pSURFACE_FEATURE (psonstmp->pointobj)->typeof3d == SCI_PLOT3D)
4231 N=(pSURFACE_FEATURE (psonstmp->pointobj)->dimzx-1)*(pSURFACE_FEATURE (psonstmp->pointobj)->dimzy-1);
4233 N = pSURFACE_FEATURE (psonstmp->pointobj)->dimzy;
4238 if ( pPOLYLINE_FEATURE(psonstmp->pointobj)->n1 == 0 )
4242 else if (pPOLYLINE_FEATURE (psonstmp->pointobj)->plot != 5)
4244 N = pPOLYLINE_FEATURE (psonstmp->pointobj)->n1-1;
4245 if ((pPOLYLINE_FEATURE (psonstmp->pointobj)->plot != 2) &&
4246 (sciGetIsMark((sciPointObj *)psonstmp->pointobj) == 1))
4258 N=pSEGS_FEATURE (psonstmp->pointobj)->Nbr1 / 2 ;
4264 N = Merge3dDimension(psonstmp->pointobj);
4270 psonstmp = psonstmp->pnext;
4276 int ChildrenCounter(sciPointObj *pparent)
4279 sciSons * psonstmp = sciGetSons (pparent);
4281 while (psonstmp != (sciSons *) NULL) {
4282 switch (sciGetEntityType (psonstmp->pointobj)) {
4296 N = ChildrenCounter(psonstmp->pointobj);
4302 psonstmp = psonstmp->pnext;
4309 void Merge3dBuildTable(sciPointObj *pparent, int *index_in_entity, long *from_entity, int *pos)
4314 psonstmp = sciGetSons (pparent);
4316 while (psonstmp != (sciSons *) NULL) {
4317 switch (sciGetEntityType (psonstmp->pointobj)) {
4319 if (pSURFACE_FEATURE (psonstmp->pointobj)->typeof3d == SCI_PLOT3D)
4320 N=(pSURFACE_FEATURE (psonstmp->pointobj)->dimzx-1)*(pSURFACE_FEATURE (psonstmp->pointobj)->dimzy-1);
4322 N = pSURFACE_FEATURE (psonstmp->pointobj)->dimzy;
4325 if ( pPOLYLINE_FEATURE(psonstmp->pointobj)->n1 == 0 )
4329 else if (pPOLYLINE_FEATURE (psonstmp->pointobj)->plot != 5)
4331 N = pPOLYLINE_FEATURE (psonstmp->pointobj)->n1-1;
4332 if ((pPOLYLINE_FEATURE (psonstmp->pointobj)->plot != 2) &&
4333 (sciGetIsMark((sciPointObj *)psonstmp->pointobj) == 1))
4344 N=pSEGS_FEATURE (psonstmp->pointobj)->Nbr1/2;
4350 Merge3dBuildTable(psonstmp->pointobj, index_in_entity, from_entity, pos);
4355 if (sciGetEntityType (psonstmp->pointobj) != SCI_AGREG)
4356 for (i=0 ; i<N; i++) {
4357 index_in_entity[*pos]=i;
4358 from_entity[*pos]=(long) sciGetHandle (psonstmp->pointobj);
4361 psonstmp = psonstmp->pnext;
4366 void Merge3d(sciPointObj *psubwin)
4369 sciPointObj *pmerge;
4370 int *index_in_entity;
4373 if(sciGetEntityType (psubwin) != SCI_SUBWIN) return;
4374 if ((pmerge= sciGetMerge(psubwin)) != (sciPointObj *) NULL)
4375 DestroyMerge(pmerge);
4377 /* ========================================================================
4378 * Compute the number of facets, segments,... included in all the subwin
4380 * ========================================================================*/
4383 q = Merge3dDimension(psubwin);
4386 /* ========================================================================
4387 * allocate tables for index and handles
4388 * ========================================================================*/
4390 /* q now contains the total number of elements */
4391 if ((index_in_entity = (int *) MALLOC (q * sizeof (int))) == (int *)NULL) {
4392 sciprint("Merge3d : not enough memory to allocate \n");
4395 if ((from_entity = (long *) MALLOC (q * sizeof (long))) == (long *) NULL) {
4396 sciprint("Merge3d : not enough memory to allocate \n");
4397 FREE(index_in_entity);
4400 /* ========================================================================
4401 * fill the index and handles tables
4402 * ========================================================================*/
4404 Merge3dBuildTable(psubwin, index_in_entity, from_entity, &k);
4406 /* ========================================================================
4407 * create the Merge data structure
4408 * ========================================================================*/
4410 if ((pmerge=ConstructMerge ((sciPointObj *) psubwin,q,index_in_entity,from_entity)) == (sciPointObj *) NULL) {
4411 FREE(index_in_entity);
4413 sciprint ("\r\n No merge supported");}
4414 else /* inform the subwindow to display Merge instead of individual children */
4415 pSUBWIN_FEATURE (psubwin)->facetmerge = TRUE;
4419 /*------------------------------------------------------------------------------------------*/
4421 * draw the figure number numFigure.
4423 void sciDrawFigure( int numFigure )
4425 int curFigure = sciGetNumFigure( sciGetCurrentFigure() ) ;
4426 sciSetUsedWindow( numFigure ) ;
4427 sciDrawObj( sciGetCurrentFigure() ) ;
4428 sciSetUsedWindow( curFigure ) ;
4430 /*------------------------------------------------------------------------------------------*/
4432 /*-------------------------------------------------------------------------------------------*/
4434 /* draw an object but before select the rigth figure for display */
4435 /*-------------------------------------------------------------------------------------------*/
4436 int sciRefreshObj( sciPointObj * pobj )
4439 int parentId = sciGetNum( sciGetParentFigure( pobj ) ) ;
4442 int verboseGet = 0 ;
4443 int iDontKnowWhatItIs ;
4444 /* get current Id in ScilabXgc */
4445 C2F (dr) ("xget", "window",&verboseGet,¤tId,&iDontKnowWhatItIs,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4447 /* set the parent figure of the object as the current figure */
4448 if ( parentId != currentId )
4450 C2F (dr) ("xset", "window",&parentId,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4453 /* draw the object */
4454 status = sciDrawObjIfRequired( pobj ) ;
4456 /* set back the values */
4457 if ( parentId != currentId )
4459 C2F (dr) ("xset", "window",¤tId,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4469 /**sciDrawObjIfRequired
4470 * Draws Object (only the basic graphicobject under subwindows) in its SubWindow or figure
4471 * if and only if pFIGURE_FEATURE(pobj)->auto_redraw == TRUE !!
4472 * Only used inside High Level functions calls (sucha as plot2d, plot3d...)
4473 * @param sciPointObj * pobj: the pointer to the entity
4474 * @return int 0 if OK, -1 if not
4477 sciDrawObjIfRequired (sciPointObj * pobj)
4479 sciPointObj * pfigure = sciGetParentFigure(pobj);
4481 if( pFIGURE_FEATURE(pfigure)->auto_redraw && pFIGURE_FEATURE(pfigure)->visible )
4490 * Draws Object (only the basic graphicobject under subwindows) in its SubWindow or figure
4491 * @param sciPointObj * pobj: the pointer to the entity
4492 * @return int 0 if OK, -1 if not
4495 sciDrawObj (sciPointObj * pobj)
4498 /*sciPointObj * curSubWin = sciGetSelectedSubWin( sciGetCurrentFigure() ) ;*/
4501 if((GetDriverId() != 0) && ( isGraphicSessionOpened() )){
4505 switch (sciGetEntityType (pobj))
4508 return drawFigureEntity( pobj ) ;
4511 return drawSubWinEntity( pobj ) ;
4514 return drawCompoundEntity( pobj ) ;
4517 return drawLegendEntity( pobj ) ;
4520 return drawFecEntity( pobj ) ;
4523 return drawSegsEntity( pobj ) ;
4526 return drawGrayplotEntity( pobj ) ;
4529 return drawPolylineEntity( pobj ) ;
4532 return drawArcEntity( pobj ) ;
4535 return drawRectangleEntity( pobj ) ;
4538 return drawTextEntity( pobj ) ;
4541 return drawAxesEntity(pobj) ;
4544 return drawMergeEntity(pobj) ;
4547 return drawSurfaceEntity(pobj) ;
4554 case SCI_MENUCONTEXT:
4560 /*sciSetSelectedSubWin (curSubWin);*/
4567 /* F.Leray 25.02.05 */
4568 /* This function is used to determine how the pixel data*/
4569 /* is given to Xt method (like XDrawLines) */
4570 /* 0 : pixel itself */
4571 /* 1 : pixel's interval */
4573 /* i.e.in X11 (same thing using Win32 driver), with x2=x1+1 and y1=y2, we have : */
4574 /* XDrawLine(x1,y1,x1,y1) does nothing (no pixel lit) */
4575 /* XDrawLine(x1,y1,x2,y2) ONE pixel lit */
4576 /* BUT the corresponding function with driver Gif (and others?) give us: */
4577 /* for now (and only for marks), I make a trick using a pixel_offset set to 0 or 1 */
4578 /* depending on the driver. */
4580 /* slight modif from Bruno : if fact GetDriverId return also 0 */
4581 /* if gtk is enable so I have added a call to withgtk to get the */
4582 /* the good pixel_offset */
4586 int AdaptGraduationsOnYBottomLeft(int iof, int x, int y, int size, integer *Ticsdir, int *fontid, sciPointObj * psubwin, double yminval, double ymaxval, double fx, double fy, double fz)
4589 int nbtics, nbsubtics;
4592 int nb_grads_max = 0;
4595 double grads_tmp[20];
4597 integer barlengthx = 0,barlengthy = 0;
4598 integer rect[4],posi[2];
4599 integer textcolor = -1;
4604 double fact_h = 1.5, fact_w = 1.5;
4607 int possible_pas, possible_compteur;
4609 sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
4611 for(i=0;i<4;i++) { old_rect[i] = 0 ; } /* Init. old_rect to force first grad. to be displayed */
4613 lastyindex = ppsubwin->axes.nygrads - 1;
4616 ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.ygrads[0]));
4618 ChoixFormatE(c_format,
4619 ppsubwin->axes.ygrads[0],
4620 ppsubwin->axes.ygrads[lastyindex],
4621 ((ppsubwin->axes.ygrads[lastyindex])-(ppsubwin->axes.ygrads[0]))/(lastyindex));
4623 nbtics = ppsubwin->axes.nygrads;
4624 nbsubtics = ppsubwin->axes.nbsubtics[1];
4627 for(i=0;i<nbtics;i++) grads_tmp[i] = ppsubwin->axes.ygrads[i];
4629 for(i=0;i<nbtics;i++)
4632 double ytmp = ppsubwin->axes.ygrads[i];
4635 sprintf(foo,c_format,ytmp);
4637 /***************************************************************/
4638 /************************* COMMON PART *************************/
4639 /***************************************************************/
4640 if(ppsubwin->axes.reverse[1] == TRUE)
4641 ytmp = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ytmp);
4643 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz);
4647 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
4648 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
4650 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
4651 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4654 if (IsDownAxes(psubwin)){
4657 posi[0] = inint(xm-rect[2]/2);
4658 posi[1]=inint( vy[0] + iof + rect[3]);}
4660 vx[1]=vx[0]+barlengthx;
4661 vy[1]=vy[0]+barlengthy;
4662 /* posi[0] = inint( xm+2*barlengthx-rect[2]/2); */
4663 posi[0] = inint( xm+2*barlengthx-rect[2]);
4664 posi[1]=inint( ym + 2*barlengthy + rect[3]);}
4666 /* compute bounding of "10" string used for log scale ON and auto_ticks ON */
4667 C2F(dr)("xstringl","10",&XX,&YY,logrect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4670 if(CheckDisplay(fact_h, fact_w, ppsubwin->logflags[1],foo,posi,fontid,old_rect) == 0)
4671 continue; /* graduation too close, DO NOT display the graduation ! */
4674 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4675 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4676 if ( ppsubwin->logflags[1] == 'l' )
4678 int smallersize = fontid[1]-2;
4682 posi10[0] = posi[0] - logrect[2];
4683 posi10[1] = posi[1] + logrect[3];
4685 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4687 C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4689 posi[0] = old_rect10[0] + old_rect10[2];
4690 posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
4692 C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4693 C2F(dr)("xstringl",foo,(&posi[0]),(&posi[1]),old_rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4695 /* update old_rect */
4696 old_rect[2] = (int)(fact_w*(old_rect[2] + (double)old_rect10[2]));
4697 old_rect[3] = (int)(fact_h*(old_rect[3] + old_rect10[3] + (int) (old_rect10[3]*.1)));
4698 old_rect[0] = old_rect10[0];
4699 old_rect[1] = old_rect[1];
4703 /* put back the current fontid */
4704 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4707 /* update old_rect */
4708 C2F(dr)("xstringl",foo,(&posi[0]),(&posi[1]),old_rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4709 old_rect[3] = (int)(fact_h* old_rect[3]);
4710 old_rect[2] = (int)(fact_w* old_rect[2]);
4715 if(ppsubwin->logflags[1] != 'l')
4716 if(nb_grads_max == 1) /* only one grad. can be displayed : we choose to display the average value (max+min)/2 */
4718 ppsubwin->axes.ygrads[0] = (grads_tmp[0]+grads_tmp[lastyindex])/2.;
4719 ppsubwin->axes.nygrads = 1;
4721 if ( !ppsubwin->flagNax )
4723 /* don't change the number if it aldready has been specified */
4724 ppsubwin->axes.nbsubtics[1] = 1 ;
4730 pas = nbtics - 2; /* pas == grads number - 2 */
4733 possible_compteur = -99;
4744 if((tmp == (nbtics - 1)) && (compteur < nb_grads_max)){
4746 possible_compteur = ++compteur;
4750 if(tmp > (nbtics - 1))
4758 if(possible_compteur != -99){
4759 compteur = possible_compteur;
4762 for(i=0;i<compteur;i++)
4763 ppsubwin->axes.ygrads[i] = grads_tmp[i*pas];
4765 ppsubwin->axes.nygrads = compteur;
4767 /* Nb of subtics computation and storage */
4768 /* jb Silvy 01/2006 : default value was Max((int) abs((13-compteur)/2),2) */
4769 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTicsFor3dUse(psubwin,
4770 ppsubwin->axes.nygrads,
4771 ppsubwin->logflags[1],
4772 ppsubwin->axes.ygrads,
4773 ppsubwin->axes.nbsubtics[1]);
4776 ppsubwin->axes.ygrads[0] = grads_tmp[0];
4777 ppsubwin->axes.ygrads[1] = grads_tmp[lastyindex];
4778 ppsubwin->axes.nygrads = 2;
4779 /* Nb of subtics computation and storage */
4780 /* jb Silvy 01/2006 : default value was Max((int) abs((13-compteur)/2),2) */
4781 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTicsFor3dUse(psubwin,
4782 ppsubwin->axes.nygrads,
4783 ppsubwin->logflags[1],
4784 ppsubwin->axes.ygrads,
4785 ppsubwin->axes.nbsubtics[1]);
4787 if(ppsubwin->logflags[1] == 'n'){
4788 if(nb_grads_max > 4) {
4789 /* we could display at least 4 graduations but we did not find a proper interval... */
4790 /* To avoid to display only the min and max (see above), we add 2 newly created grads by interpolating between min and max */
4791 double pas_ = (grads_tmp[lastyindex]-grads_tmp[0])/3;
4793 ppsubwin->axes.ygrads[i] = grads_tmp[0] + i*pas_;
4796 ppsubwin->axes.ygrads[3] = grads_tmp[lastyindex]; /* exact max */
4797 ppsubwin->axes.nygrads = 4;
4798 /* Nb of subtics computation and storage */
4799 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTicsFor3dUse(psubwin,
4800 ppsubwin->axes.nygrads,
4802 ppsubwin->axes.ygrads,
4803 ppsubwin->axes.nbsubtics[1]);
4812 int AdaptGraduationsOnXBottomLeft(int iof, int x, int y, int size, integer *Ticsdir, int *fontid, sciPointObj * psubwin, double xminval, double xmaxval, double fx, double fy, double fz)
4815 int nbtics, nbsubtics;
4818 int nb_grads_max = 0;
4821 double grads_tmp[20];
4823 integer barlengthx = 0,barlengthy = 0;
4824 integer rect[4],posi[2];
4825 integer textcolor = -1;
4826 int logrect[4],XX,YY;
4828 double fact_h = 1.5, fact_w = 1.5;
4831 int possible_pas, possible_compteur;
4833 sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
4835 for(i=0;i<4;i++) old_rect[i] = 0; /* Init. old_rect to force first grad. to be displayed */
4837 lastxindex = ppsubwin->axes.nxgrads - 1;
4840 ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.xgrads[0]));
4842 ChoixFormatE(c_format,
4843 ppsubwin->axes.xgrads[0],
4844 ppsubwin->axes.xgrads[lastxindex],
4845 ((ppsubwin->axes.xgrads[lastxindex])-(ppsubwin->axes.xgrads[0]))/(lastxindex));
4847 nbtics = ppsubwin->axes.nxgrads;
4848 nbsubtics = ppsubwin->axes.nbsubtics[0];
4851 for(i=0;i<nbtics;i++) grads_tmp[i] = ppsubwin->axes.xgrads[i];
4853 for(i=0;i<nbtics;i++)
4856 double xtmp = ppsubwin->axes.xgrads[i];
4858 /* if(xtmp<xminval || xtmp>xmaxval) */
4860 /* /\* sciprint("je rejete la valeur: %lf\n\n",xtmp); *\/ */
4861 /* continue; /\* cas ou TL est ON et on a des graduations qui ne seront pas affichees de tte facon *\/ */
4862 /* /\* donc autant ne pas aller plus loin dans l'algo... *\/ */
4865 sprintf(foo,c_format,xtmp);
4867 /***************************************************************/
4868 /************************* COMMON PART *************************/
4869 /***************************************************************/
4870 if(ppsubwin->axes.reverse[0] == TRUE)
4871 xtmp = InvAxis(ppsubwin->FRect[0],ppsubwin->FRect[2],xtmp);
4873 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&xtmp,&fy,&fz);
4877 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
4878 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
4880 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
4881 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4884 /* if (IsDownAxes(psubwin)){ */
4886 /* vy[1]=vy[0]+iof/2; */
4887 /* posi[0] = inint(xm-rect[2]/2); */
4888 /* posi[1]=inint( vy[0] + iof + rect[3]);} */
4890 /* vx[1]=vx[0]+barlengthx; */
4891 /* vy[1]=vy[0]+barlengthy; */
4892 /* posi[0] = inint( xm+2*barlengthx); */
4893 /* posi[1]=inint( ym + 2*barlengthy + rect[3]);} */
4895 if (IsDownAxes(psubwin)){
4898 posi[0] = inint(xm-rect[2]/2);
4899 posi[1]=inint( vy[0] + iof + rect[3]);}
4901 vx[1]=vx[0]+barlengthx;
4902 vy[1]=vy[0]+barlengthy;
4903 posi[0] = inint( xm+2*barlengthx-rect[2]);
4904 posi[1]=inint( ym + 2*barlengthy + rect[3]);}
4906 /* compute bounding of "10" string used for log scale ON and auto_ticks ON */
4907 C2F(dr)("xstringl","10",&XX,&YY,logrect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4910 if(CheckDisplay(fact_h, fact_w, ppsubwin->logflags[0],foo,posi,fontid,old_rect) == 0)
4911 continue; /* graduation too close, DO NOT display the graduation ! */
4914 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4915 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4916 if ( ppsubwin->logflags[0] == 'l' )
4918 int smallersize = fontid[1]-2;
4922 posi10[0] = posi[0] - logrect[2];
4923 posi10[1] = posi[1] + logrect[3];
4925 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4927 C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4929 posi[0] = old_rect10[0] + old_rect10[2];
4930 posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
4932 C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4933 C2F(dr)("xstringl",foo,(&posi[0]),(&posi[1]),old_rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4935 /* update old_rect */
4936 old_rect[2] = (int)(fact_w*(old_rect[2] + old_rect10[2]));
4937 old_rect[3] = (int)(fact_h*(old_rect[3] + old_rect10[3] + (int) (old_rect10[3]*.1)));
4938 old_rect[0] = old_rect10[0];
4939 old_rect[1] = old_rect[1];
4943 /* put back the current fontid */
4944 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4947 /* update old_rect */
4948 C2F(dr)("xstringl",foo,(&posi[0]),(&posi[1]),old_rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
4949 old_rect[3] = (int)(fact_h* old_rect[3]);
4950 old_rect[2] = (int)(fact_w* old_rect[2]);
4955 if(ppsubwin->logflags[0] != 'l')
4956 if(nb_grads_max == 1) /* only one grad. can be displayed : we choose to display the average value (max+min)/2 */
4958 ppsubwin->axes.xgrads[0] = (grads_tmp[0]+grads_tmp[lastxindex])/2.;
4959 ppsubwin->axes.nxgrads = 1;
4960 if ( !ppsubwin->flagNax )
4962 ppsubwin->axes.nbsubtics[0] = 1;
4968 pas = nbtics - 2; /* pas == grads number - 2 */
4971 possible_compteur = -99;
4982 if((tmp == (nbtics - 1)) && (compteur < nb_grads_max)){
4984 possible_compteur = ++compteur;
4988 if(tmp > (nbtics - 1))
4996 if(possible_compteur != -99){
4997 compteur = possible_compteur;
5000 for(i=0;i<compteur;i++)
5001 ppsubwin->axes.xgrads[i] = grads_tmp[i*pas];
5003 ppsubwin->axes.nxgrads = compteur;
5005 /* Nb of subtics computation and storage */
5006 /* jb Silvy 01/2006 : default value was Max((int) abs((13-compteur)/2),2) */
5007 ppsubwin->axes.nbsubtics[0] = ComputeNbSubTicsFor3dUse(psubwin,
5008 ppsubwin->axes.nxgrads,
5009 ppsubwin->logflags[0],
5010 ppsubwin->axes.xgrads,
5011 ppsubwin->axes.nbsubtics[0]);
5014 ppsubwin->axes.xgrads[0] = grads_tmp[0];
5015 ppsubwin->axes.xgrads[1] = grads_tmp[lastxindex];
5016 ppsubwin->axes.nxgrads = 2;
5017 /* Nb of subtics computation and storage */
5018 /* jb Silvy 01/2006 : default value was Max((int) abs((13-compteur)/2),2) */
5019 ppsubwin->axes.nbsubtics[0] = ComputeNbSubTicsFor3dUse(psubwin,
5020 ppsubwin->axes.nxgrads,
5021 ppsubwin->logflags[0],
5022 ppsubwin->axes.xgrads,
5023 ppsubwin->axes.nbsubtics[0]);
5025 if(ppsubwin->logflags[0] == 'n'){
5026 if(nb_grads_max > 4) {
5027 /* we could display at least 4 graduations but we did not find a proper interval... */
5028 /* To avoid to display only the min and max (see above), we add 2 newly created grads by interpolating between min and max */
5029 double pas_ = (grads_tmp[lastxindex]-grads_tmp[0])/3;
5031 ppsubwin->axes.xgrads[i] = grads_tmp[0] + i*pas_;
5034 ppsubwin->axes.xgrads[3] = grads_tmp[lastxindex]; /* exact max */
5035 ppsubwin->axes.nxgrads = 4;
5037 /* Nb of subtics computation and storage */
5038 /* jb Silvy 01/2006 : default value was Max((int) abs((13-compteur)/2),2) */
5039 ppsubwin->axes.nbsubtics[0] = ComputeNbSubTicsFor3dUse(psubwin,
5040 ppsubwin->axes.nxgrads,
5042 ppsubwin->axes.xgrads,
5043 ppsubwin->axes.nbsubtics[0]);
5053 int AdaptGraduationsOnYBottomRight(int iof, int x, int y, int size, integer *Ticsdir, int *fontid, sciPointObj * psubwin, double yminval, double ymaxval, double fx, double fy, double fz)
5056 int nbtics, nbsubtics;
5059 int nb_grads_max = 0;
5062 double grads_tmp[20];
5064 integer barlengthx = 0,barlengthy = 0;
5065 integer rect[4],posi[2];
5066 integer textcolor = -1;
5071 double fact_h = 1.5, fact_w = 1.5;
5074 int possible_pas, possible_compteur;
5076 sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin);
5078 for(i=0;i<4;i++) old_rect[i] = 0; /* Init. old_rect to force first grad. to be displayed */
5080 lastyindex = ppsubwin->axes.nygrads - 1;
5083 ChooseFormatForOneGrad(c_format,&(ppsubwin->axes.ygrads[0]));
5085 ChoixFormatE(c_format,
5086 ppsubwin->axes.ygrads[0],
5087 ppsubwin->axes.ygrads[lastyindex],
5088 ((ppsubwin->axes.ygrads[lastyindex])-(ppsubwin->axes.ygrads[0]))/(lastyindex));
5090 nbtics = ppsubwin->axes.nygrads;
5091 nbsubtics = ppsubwin->axes.nbsubtics[1];
5094 for(i=0;i<nbtics;i++) grads_tmp[i] = ppsubwin->axes.ygrads[i];
5096 for(i=0;i<nbtics;i++)
5099 double ytmp = ppsubwin->axes.ygrads[i];
5101 sprintf(foo,c_format,ytmp);
5103 /***************************************************************/
5104 /************************* COMMON PART *************************/
5105 /***************************************************************/
5106 if(ppsubwin->axes.reverse[1] == TRUE)
5107 ytmp = InvAxis(ppsubwin->FRect[1],ppsubwin->FRect[3],ytmp);
5109 ComputeGoodTrans3d(psubwin,1,&xm,&ym,&fx,&ytmp,&fz);
5113 barlengthx= (integer) (( Ticsdir[0])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
5114 barlengthy= (integer) (( Ticsdir[1])/sqrt((double) Ticsdir[0]*Ticsdir[0]+Ticsdir[1]*Ticsdir[1])*size);
5116 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); /* fix bug noticed by R.N. */
5117 C2F(dr)("xstringl",foo,&x,&y,rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
5120 if (IsDownAxes(psubwin)){
5123 posi[0] = inint(xm-rect[2]/2);
5124 posi[1]=inint( vy[0] + iof + rect[3]);}
5126 vx[1]=vx[0]+barlengthx;
5127 vy[1]=vy[0]+barlengthy;
5128 posi[0] = inint( xm+2*barlengthx);
5129 posi[1]=inint( ym + 2*barlengthy + rect[3]);}
5132 /* compute bounding of "10" string used for log scale ON and auto_ticks ON */
5133 C2F(dr)("xstringl","10",&XX,&YY,logrect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
5136 if(CheckDisplay(fact_h, fact_w, ppsubwin->logflags[1],foo,posi,fontid,old_rect) == 0)
5137 continue; /* graduation too close, DO NOT display the graduation ! */
5140 C2F(dr)("xset","pattern",&textcolor,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
5141 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
5142 if ( ppsubwin->logflags[1] == 'l' )
5144 int smallersize = fontid[1]-2;
5148 posi10[0] = posi[0] - logrect[2];
5149 posi10[1] = posi[1] + logrect[3];
5151 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
5153 C2F(dr)("xstringl","10",(&posi10[0]),(&posi10[1]),old_rect10,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
5155 posi[0] = old_rect10[0] + old_rect10[2];
5156 posi[1] = (int) (old_rect10[1] - old_rect10[3]*.1);
5158 C2F(dr)("xset","font",fontid,&smallersize,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
5159 C2F(dr)("xstringl",foo,(&posi[0]),(&posi[1]),old_rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
5161 /* update old_rect */
5162 old_rect[2] = (int)(fact_w*(old_rect[2] + old_rect10[2]));
5163 old_rect[3] = (int)(fact_h*(old_rect[3] + old_rect10[3] + (int) (old_rect10[3]*.1)));
5164 old_rect[0] = old_rect10[0];
5165 old_rect[1] = old_rect[1];
5169 /* put back the current fontid */
5170 C2F(dr)("xset","font",fontid,fontid+1,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
5173 /* update old_rect */
5174 C2F(dr)("xstringl",foo,(&posi[0]),(&posi[1]),old_rect,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
5175 old_rect[3] = (int)(fact_h* old_rect[3]);
5176 old_rect[2] = (int)(fact_w* old_rect[2]);
5181 if(ppsubwin->logflags[1] != 'l')
5182 if(nb_grads_max == 1) /* only one grad. can be displayed : we choose to display the average value (max+min)/2 */
5184 ppsubwin->axes.ygrads[0] = (grads_tmp[0]+grads_tmp[lastyindex])/2.;
5185 ppsubwin->axes.nygrads = 1;
5186 if ( !ppsubwin->flagNax )
5188 ppsubwin->axes.nbsubtics[1] = 1;
5194 pas = nbtics - 2; /* pas == grads number - 2 */
5197 possible_compteur = -99;
5208 if((tmp == (nbtics - 1)) && (compteur < nb_grads_max)){
5210 possible_compteur = ++compteur;
5214 if(tmp > (nbtics - 1))
5222 if(possible_compteur != -99){
5223 compteur = possible_compteur;
5226 for(i=0;i<compteur;i++)
5227 ppsubwin->axes.ygrads[i] = grads_tmp[i*pas];
5229 ppsubwin->axes.nygrads = compteur;
5231 /* Nb of subtics computation and storage */
5232 /* jb Silvy 01/2006 : default value was Max((int) abs((13-compteur)/2),2) */
5233 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTicsFor3dUse(psubwin,
5234 ppsubwin->axes.nygrads,
5235 ppsubwin->logflags[1],
5236 ppsubwin->axes.ygrads,
5237 ppsubwin->axes.nbsubtics[1]);
5240 ppsubwin->axes.ygrads[0] = grads_tmp[0];
5241 ppsubwin->axes.ygrads[1] = grads_tmp[lastyindex];
5242 ppsubwin->axes.nygrads = 2;
5244 /* Nb of subtics computation and storage */
5245 /* jb Silvy 01/2006 : default value was Max((int) abs((13-compteur)/2),2) */
5246 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTicsFor3dUse(psubwin,
5247 ppsubwin->axes.nygrads,
5248 ppsubwin->logflags[1],
5249 ppsubwin->axes.ygrads,
5250 ppsubwin->axes.nbsubtics[1]);
5252 if(ppsubwin->logflags[1] == 'n'){
5253 if(nb_grads_max > 4) {
5254 /* we could display at least 4 graduations but we did not find a proper interval... */
5255 /* To avoid to display only the min and max (see above), we add 2 newly created grads by interpolating between min and max */
5256 double pas_ = (grads_tmp[lastyindex]-grads_tmp[0])/3;
5258 ppsubwin->axes.ygrads[i] = grads_tmp[0] + i*pas_;
5261 ppsubwin->axes.ygrads[3] = grads_tmp[lastyindex]; /* exact max */
5262 ppsubwin->axes.nygrads = 4;
5263 /* Nb of subtics computation and storage */
5264 /* jb Silvy 01/2006 : default value was Max((int) abs((13-compteur)/2),2) */
5265 ppsubwin->axes.nbsubtics[1] = ComputeNbSubTicsFor3dUse(psubwin,
5266 ppsubwin->axes.nygrads,