#include <string.h>#include <stdio.h>#include <math.h>#include "math_graphics.h"#include "PloEch.h"#include "../../sparse/includes/spConfig.h"#include "SetProperty.h"#include "GetProperty.h"#include "InitObjects.h"#include "DrawObjects.h"#include "BuildObjects.h"#include "Axes.h"#include "BasicAlgos.h"#include "clipping.h"#include "sciprint.h"#include "CurrentObjectsManagement.h"#include "MALLOC.h"Include dependency graph for Plo2dn.c:

Go to the source code of this file.
Defines | |
| #define | spINSIDE_SPARSE |
Functions | |
| void | initsubwin () |
| void | compute_data_bounds (int cflag, char dataflag, double *x, double *y, integer n1, integer n2, double *drect) |
| void | compute_data_bounds2 (int cflag, char dataflag, char *logflags, double *x, double *y, integer n1, integer n2, double *drect) |
| BOOL | update_specification_bounds (sciPointObj *psubwin, double *rect, int flag) |
| int | re_index_brect (double *brect, double *drect) |
| BOOL | strflag2axes_properties (sciPointObj *psubwin, char *strflag) |
| char ** | FreeUserLabels (char **u_xlabels, int *u_nxgrads) |
| double * | FreeUserGrads (double *u_xgrads) |
| double * | AllocUserGrads (double *u_xgrads, int nb) |
| int | CopyUserGrads (double *u_xgrad_SRC, double *u_xgrad_DEST, int dim) |
| char ** | AllocAndSetUserLabels (char **u_xlabels, double *u_xgrads, int u_nxgrads, char logflag) |
| char ** | AllocAndSetUserLabelsFromMdl (char **u_xlabels, char **u_xlabels_MDL, int u_nxgrads) |
| int | CreatePrettyGradsFromNax (sciPointObj *psubwin, int *Nax) |
| int | GraduateWithNax (sciSubWindow *ppsubwin, double *min, double *max, int nbtics, double *grads) |
| int | ChooseGoodFormat (char *c_format, char logflag, double *_grads, int n_grads) |
| int | plot2dn (integer ptype, char *logflags, double *x, double *y, integer *n1, integer *n2, integer *style, char *strflag, char *legend, double *brect, integer *aaint, BOOL flagNax, integer lstr1, integer lstr2) |
| BOOL | update_specification_bounds (sciPointObj *psubwin, rect, int flag) |
| char ** AllocAndSetUserLabels | ( | char ** | u_xlabels, | |
| double * | u_xgrads, | |||
| int | u_nxgrads, | |||
| char | logflag | |||
| ) |
Definition at line 732 of file Plo2dn.c.
References ChooseGoodFormat(), foo(), i, MALLOC, NULL, and sciprint().
Referenced by CreatePrettyGradsFromNax().
00733 { 00734 int i; 00735 char c_format[5]; 00736 int nbtics = u_nxgrads; 00737 00738 if(u_xgrads == NULL) 00739 return (char **) NULL; 00740 00741 if(u_xlabels != NULL) 00742 { 00743 sciprint("Impossible: u_xlabels must be freed before re-allocating"); 00744 return (char **) NULL; 00745 } 00746 00747 00748 if((u_xlabels=(char **)MALLOC(u_nxgrads*sizeof(char *)))==NULL){ 00749 sciprint("No more place for allocating user labels using Nax"); 00750 return (char **) NULL; 00751 } 00752 00753 ChooseGoodFormat(c_format,logflag,u_xgrads,u_nxgrads); 00754 00755 for(i=0;i<nbtics;i++) 00756 { 00757 char foo[100]; 00758 00759 sprintf(foo,c_format, u_xgrads[i]); 00760 00761 if((u_xlabels[i]=(char *)MALLOC((strlen(foo)+1)*sizeof(char )))==NULL){ 00762 sciprint("No more place for allocating u_xlabels"); 00763 return (char **) NULL; 00764 } 00765 00766 strcpy(u_xlabels[i],foo); 00767 } 00768 00769 return u_xlabels; 00770 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char** AllocAndSetUserLabelsFromMdl | ( | char ** | u_xlabels, | |
| char ** | u_xlabels_MDL, | |||
| int | u_nxgrads | |||
| ) |
| double* AllocUserGrads | ( | double * | u_xgrads, | |
| int | nb | |||
| ) |
Definition at line 1199 of file Format.c.
References ChoixFormatE().
01200 { 01201 int last_index = n_grads - 1; 01202 01203 if(logflag == 'l') 01204 { 01205 ChoixFormatE(c_format, 01206 exp10(_grads[0]), 01207 exp10(_grads[last_index]), 01208 (( exp10(_grads[last_index]))-( exp10(_grads[0])))/(last_index)); 01209 } 01210 else 01211 { 01212 ChoixFormatE(c_format, 01213 _grads[0], 01214 _grads[last_index], 01215 ((_grads[last_index])-(_grads[0]))/(last_index)); /* Adding F.Leray 06.05.04 */ 01216 } 01217 01218 return 0; 01219 01220 }
Here is the call graph for this function:

| void compute_data_bounds | ( | int | cflag, | |
| char | dataflag, | |||
| double * | x, | |||
| double * | y, | |||
| integer | n1, | |||
| integer | n2, | |||
| double * | drect | |||
| ) |
Definition at line 369 of file Plo2dn.c.
References Maxi(), Mini(), and xd.
00370 { 00371 int size_x,size_y; 00372 double xd[2]; 00373 double *x1; 00374 switch ( dataflag ) { 00375 case 'e' : 00376 xd[0] = 1.0; xd[1] = (double)n2; 00377 x1 = xd;size_x = (n2 != 0) ? 2 : 0 ; 00378 break; 00379 case 'o' : 00380 x1 = x;size_x = n2; 00381 break; 00382 case 'g' : 00383 default : 00384 x1 = x;size_x = (cflag == 1) ? n1 : (n1*n2) ; 00385 break; 00386 } 00387 00388 if (size_x != 0) { 00389 drect[0] = Mini(x1, size_x); 00390 drect[1] = Maxi(x1,size_x); 00391 } 00392 else { 00393 drect[0] = 0.0; 00394 drect[1] = 10.0; 00395 } 00396 00397 size_y = (cflag == 1) ? n2 : (n1*n2) ; 00398 if (size_y != 0) { 00399 drect[2] = Mini(y, size_y); 00400 drect[3] = Maxi(y,size_y); 00401 } 00402 else { 00403 drect[2] = 0.0; 00404 drect[3] = 10.0; 00405 } 00406 /* back to default values for x=[] and y = [] */ 00407 if ( drect[2] == LARGEST_REAL ) { drect[2] = 0.0; drect[3] = 10.0 ;} 00408 if ( drect[0] == LARGEST_REAL ) { drect[0] = 0.0; drect[1] = 10.0 ;} 00409 00410 }
Here is the call graph for this function:

| void compute_data_bounds2 | ( | int | cflag, | |
| char | dataflag, | |||
| char * | logflags, | |||
| double * | x, | |||
| double * | y, | |||
| integer | n1, | |||
| integer | n2, | |||
| double * | drect | |||
| ) |
Definition at line 294 of file Plo2dn.c.
References Maxi(), Mini(), sciFindStPosMin(), and xd.
00295 { 00296 int size_x,size_y; 00297 double xd[2]; 00298 double *x1; 00299 switch ( dataflag ) { 00300 case 'e' : 00301 xd[0] = 1.0; xd[1] = (double)n2; 00302 x1 = xd;size_x = (n2 != 0) ? 2 : 0 ; 00303 break; 00304 case 'o' : 00305 x1 = x;size_x = n2; 00306 break; 00307 case 'g' : 00308 default : 00309 x1 = x;size_x = (cflag == 1) ? n1 : (n1*n2) ; 00310 break; 00311 } 00312 00313 if (size_x != 0) { 00314 if(logflags[0] != 'l'){ 00315 drect[0] = Mini(x1, size_x); 00316 drect[1] = Maxi(x1,size_x); 00317 } 00318 else { /* log. case */ 00319 drect[0] = sciFindStPosMin(x1,size_x); 00320 drect[1] = Maxi(x1,size_x); 00321 } 00322 00323 } 00324 else { 00325 if(logflags[0] != 'l'){ 00326 drect[0] = 0.0; 00327 drect[1] = 10.0; 00328 } 00329 else{/* log. case */ 00330 drect[0] = 1.0; 00331 drect[1] = 10.0; 00332 } 00333 } 00334 00335 size_y = (cflag == 1) ? n2 : (n1*n2) ; 00336 if (size_y != 0) { 00337 if(logflags[1] != 'l'){ 00338 drect[2] = Mini(y, size_y); 00339 drect[3] = Maxi(y,size_y); 00340 } 00341 else{/* log. case */ 00342 drect[2] = sciFindStPosMin(y,size_y); 00343 drect[3] = Maxi(y,size_y); 00344 } 00345 00346 } 00347 else { 00348 if(logflags[1] != 'l'){ 00349 drect[2] = 0.0; 00350 drect[3] = 10.0; 00351 } 00352 else{/* log. case */ 00353 drect[2] = 1.0; 00354 drect[3] = 10.0; 00355 } 00356 } 00357 /* back to default values for x=[] and y = [] */ 00358 if ( drect[2] == LARGEST_REAL ) { drect[2] = 0.0; drect[3] = 10.0 ;} 00359 if ( drect[0] == LARGEST_REAL ) { drect[0] = 0.0; drect[1] = 10.0 ;} 00360 00361 }
Here is the call graph for this function:

| int CreatePrettyGradsFromNax | ( | sciPointObj * | psubwin, | |
| int * | Nax | |||
| ) |
| double * FreeUserGrads | ( | double * | u_xgrads | ) |
| char** FreeUserLabels | ( | char ** | u_xlabels, | |
| int * | u_nxgrads | |||
| ) |
| int GraduateWithNax | ( | sciSubWindow * | ppsubwin, | |
| double * | min, | |||
| double * | max, | |||
| int | nbtics, | |||
| double * | grads | |||
| ) |
Definition at line 654 of file Plo2dn.c.
Referenced by CreatePrettyGradsFromNax().
00655 { 00656 int i; 00657 double pas; 00658 00659 if(nbtics == 1){ 00660 pas = 0.; 00661 grads[0] = (*min); 00662 } 00663 else{ 00664 pas = (*max - *min) / (nbtics -1); 00665 00666 for(i=0;i<nbtics;i++) 00667 grads[i] = (*min) + pas*i; 00668 } 00669 00670 return 0; 00671 }
Here is the caller graph for this function:

| void initsubwin | ( | ) |
Definition at line 431 of file InitObjects.c.
References sciSubWindow::axes, BT_OFF, clearUserData(), Cscale2default(), FALSE, initSubWinSize(), AXES::limits, pSUBWIN_FEATURE, AXES::rect, reinitSubWin(), sciGetCurrentSubWin(), AXES::subint, and AXES::ticscolor.
00432 { 00433 sciPointObj * psubwin ; 00434 sciSubWindow * ppSubWin ; 00435 00436 00437 Cscale2default(); 00438 psubwin = sciGetCurrentSubWin(); 00439 ppSubWin = pSUBWIN_FEATURE (psubwin) ; 00440 00441 00442 initSubWinSize( psubwin ) ; 00443 00444 clearUserData( psubwin ) ; 00445 00446 reinitSubWin( psubwin ) ; 00447 00448 (ppSubWin->axes).axes_visible[0] = FALSE; 00449 (ppSubWin->axes).axes_visible[1] = FALSE; 00450 (ppSubWin->axes).axes_visible[2] = FALSE; 00451 00452 (ppSubWin->axes).reverse[0] = FALSE; 00453 (ppSubWin->axes).reverse[1] = FALSE; 00454 (ppSubWin->axes).reverse[2] = FALSE; 00455 00456 ppSubWin->axes.rect = BT_OFF; 00457 ppSubWin->axes.ticscolor = -1; 00458 ppSubWin->axes.subint[0] = 1; 00459 ppSubWin->axes.subint[1] = 1; 00460 ppSubWin->axes.subint[2] = 1; 00461 ppSubWin->axes.limits[0] = 0; 00462 00463 }
Here is the call graph for this function:

| int plot2dn | ( | integer | ptype, | |
| char * | logflags, | |||
| double * | x, | |||
| double * | y, | |||
| integer * | n1, | |||
| integer * | n2, | |||
| integer * | style, | |||
| char * | strflag, | |||
| char * | legend, | |||
| double * | brect, | |||
| integer * | aaint, | |||
| BOOL | flagNax, | |||
| integer | lstr1, | |||
| integer | lstr2 | |||
| ) |
Definition at line 90 of file Plo2dn.c.
References sciSubWindow::alpha, sciSubWindow::alpha_kp, AXES::auto_ticks, sciSubWindow::axes, checkRedrawing(), compute_data_bounds2(), ConstructCompound(), ConstructLegend(), ConstructPolyline(), CreatePrettyGradsFromNax(), DrawAxesIfRequired(), FALSE, sciSubWindow::FirstPlot, sciSubWindow::flagNax, frame_clip_off(), frame_clip_on(), FREE, sciSubWindow::is3d, sciSubWindow::logflags, MALLOC, Max, Merge3d(), Min, NULL, PD0, sciSubWindow::project, pSUBWIN_FEATURE, re_index_brect(), sciDrawObj(), sciDrawObjIfRequired(), sciGetCurrentFigure(), sciGetCurrentObj(), sciGetCurrentScilabXgc(), sciGetCurrentSubWin(), sciGetGraphicMode(), sciGetHandle(), sciGetSurface(), sciprint(), sciSetCurrentObj(), sciSetIsClipping(), sciSubWindow::SRect, strflag2axes_properties(), sciSubWindow::theta, sciSubWindow::theta_kp, TRUE, update_specification_bounds(), UpdateSubwinScale(), and sciSubWindow::with_leg.
Referenced by Objplot2d().
00091 { 00092 int closeflag = 0; 00093 int jj = 0; 00094 sciPointObj **pptabofpointobj; 00095 sciPointObj *psubwin; 00096 long hdl; 00097 long *hdltab; 00098 int cmpt=0/*,i*/; 00099 BOOL containsSurface = FALSE ; 00100 int with_leg; 00101 double drect[6]; 00102 char dataflag/*,frameflag*/; 00103 sciSubWindow * ppsubwin = NULL; 00104 BOOL bounds_changed = FALSE; 00105 BOOL axes_properties_changed = FALSE; 00106 00107 psubwin = sciGetCurrentSubWin(); 00108 ppsubwin = pSUBWIN_FEATURE(psubwin); 00109 00110 /* check if the auto_clear property is on and then erase everything */ 00111 checkRedrawing() ; 00112 00113 if ( sciGetSurface(psubwin) != NULL ) 00114 { 00115 containsSurface = TRUE ; 00116 } 00117 00118 if (sciGetSurface(psubwin) == (sciPointObj *) NULL) /* F.Leray 18.05.04 */ 00119 { 00120 ppsubwin->is3d = FALSE; 00121 ppsubwin->project[2]= 0; 00122 } 00123 else 00124 { 00125 ppsubwin->theta_kp=ppsubwin->theta; 00126 ppsubwin->alpha_kp=ppsubwin->alpha; 00127 } 00128 00129 ppsubwin->alpha = 0.0; 00130 ppsubwin->theta = 270.0; 00131 00132 if (sciGetSurface(psubwin) != (sciPointObj *) NULL){ 00133 if(sciGetCurrentScilabXgc () != (struct BCG *) NULL) 00134 UpdateSubwinScale(psubwin); 00135 ppsubwin->is3d = FALSE; 00136 } 00137 00138 00139 /* Force psubwin->axes.aaint to those given by argument aaint*/ 00140 /* F.Leray 07.10.04 REMOVE AAINT*/ 00141 /* for (i=0;i<4;i++) pSUBWIN_FEATURE(psubwin)->axes.aaint[i] = aaint[i]; */ 00142 00143 00144 00145 /* Force psubwin->logflags to those given by argument*/ 00146 if ( ppsubwin->FirstPlot ) 00147 { 00148 ppsubwin->logflags[0]=logflags[1]; 00149 ppsubwin->logflags[1]=logflags[2]; 00150 } 00151 00152 /* Force "cligrf" clipping */ 00153 sciSetIsClipping (psubwin,0); 00154 00155 /* Force axes_visible property */ 00156 /*pSUBWIN_FEATURE (psubwin)->isaxes = TRUE;*/ /* WHY ??? */ 00157 00158 if (sciGetGraphicMode (psubwin)->autoscaling) { 00159 /* compute and merge new specified bounds with psubwin->Srect */ 00160 switch (strflag[1]) { 00161 case '0': 00162 /* do not change psubwin->Srect */ 00163 break; 00164 case '1' : case '3' : case '5' : case '7': 00165 /* Force psubwin->Srect=brect */ 00166 re_index_brect(brect, drect); 00167 break; 00168 case '2' : case '4' : case '6' : case '8': case '9': 00169 /* Force psubwin->Srect to the x and y bounds */ 00170 if ( (int)strlen(logflags) < 1) dataflag='g' ; else dataflag=logflags[0]; 00171 compute_data_bounds2(0,dataflag,ppsubwin->logflags,x,y,*n1,*n2,drect); 00172 break; 00173 } 00174 if (!pSUBWIN_FEATURE(psubwin)->FirstPlot && 00175 (strflag[1] == '5' || strflag[1] == '7' || strflag[1] == '8' || strflag[1] == '9')) { /* merge psubwin->Srect and drect */ 00176 00177 drect[0] = Min(ppsubwin->SRect[0],drect[0]); /*xmin*/ 00178 drect[2] = Min(ppsubwin->SRect[2],drect[2]); /*ymin*/ 00179 drect[1] = Max(ppsubwin->SRect[1],drect[1]); /*xmax*/ 00180 drect[3] = Max(ppsubwin->SRect[3],drect[3]); /*ymax*/ 00181 00182 } 00183 if (strflag[1] != '0') 00184 bounds_changed = update_specification_bounds(psubwin, drect,2); 00185 } 00186 00187 if(ppsubwin->FirstPlot == TRUE) bounds_changed = TRUE; 00188 00189 axes_properties_changed = strflag2axes_properties(psubwin, strflag); 00190 00191 ppsubwin->FirstPlot = FALSE; /* just after strflag2axes_properties */ 00192 00193 with_leg= (strflag[0] == '1'); 00194 ppsubwin->with_leg = with_leg; 00195 00196 /* F.Leray 07.10.04 : trigger algo to init. manual graduation u_xgrads and 00197 u_ygrads if nax (in matdes.c which is == aaint HERE) was specified */ 00198 00199 ppsubwin->flagNax = flagNax; /* store new value for flagNax */ 00200 00201 if(ppsubwin->flagNax == TRUE){ 00202 if(ppsubwin->logflags[0] == 'n' && ppsubwin->logflags[1] == 'n') 00203 { 00204 ppsubwin->axes.auto_ticks[0] = FALSE; /* x and y graduations are imposed by Nax */ 00205 ppsubwin->axes.auto_ticks[1] = FALSE; 00206 00207 CreatePrettyGradsFromNax(psubwin,aaint); 00208 } 00209 else{ 00210 sciprint("Warning : Nax does not work with logarithmic scaling\n");} 00211 } 00212 00213 if(bounds_changed == TRUE || axes_properties_changed == TRUE) 00214 sciDrawObj(sciGetCurrentFigure()); 00215 /* EraseAndOrRedraw(psubwin); /\* inhibit EraseAndOrRedraw for now F.Leray 20.12.04 *\/ */ 00216 00217 /*---- Drawing the curves and the legends ----*/ 00218 if ( *n1 != 0 ) { 00219 frame_clip_on (); 00220 if ((hdltab = MALLOC ((*n1+2) * sizeof (long))) == NULL) { 00221 sciprint ("Running out of memory for plot2d\n"); 00222 return 0; 00223 } 00224 if (with_leg) { 00225 /* pptabofpointobj allocated for legends */ 00226 if ((pptabofpointobj = MALLOC((*n1)*sizeof(sciPointObj*))) == NULL) { 00227 sciprint ("Running out of memory for plot2d\n"); 00228 FREE(hdltab); 00229 return 0; 00230 } 00231 } 00232 for (jj = 0;jj < *n1; jj++) {/*A.Djalel 3D axes*/ 00233 sciPointObj * pobj = NULL; 00234 if (style[jj] > 0) { 00235 sciSetCurrentObj (ConstructPolyline 00236 (sciGetCurrentSubWin(),&(x[jj*(*n2)]), 00237 &(y[jj*(*n2)]),PD0,closeflag,*n2,*n1,ptype, 00238 &style[jj],NULL,NULL,NULL,NULL,TRUE,FALSE,FALSE,FALSE)); 00239 } 00240 else { 00241 int minusstyle = -style[jj]; 00242 sciSetCurrentObj (ConstructPolyline 00243 (sciGetCurrentSubWin(),&(x[jj*(*n2)]), 00244 &(y[jj*(*n2)]),PD0,closeflag,*n2,*n1,ptype, 00245 NULL,NULL,&minusstyle,NULL,NULL,FALSE,FALSE,TRUE,FALSE)); 00246 } 00247 pobj = sciGetCurrentObj(); 00248 00249 if (with_leg) pptabofpointobj[jj] = pobj; 00250 sciDrawObjIfRequired(pobj); 00251 00252 hdl=sciGetHandle(pobj); 00253 hdltab[cmpt]=hdl; 00254 cmpt++; 00255 } 00256 00257 DrawAxesIfRequired(sciGetCurrentObj ()); /* force axes redrawing once is sufficient (F.Leray 10.01.05) */ 00258 00259 frame_clip_off (); 00260 00261 /*---- Drawing the Legends ----*/ 00262 if (with_leg) { 00263 sciSetCurrentObj (ConstructLegend 00264 (sciGetCurrentSubWin(), 00265 legend, strlen(legend), *n1, style, pptabofpointobj)); 00266 hdl=sciGetHandle(sciGetCurrentObj ()); 00267 hdltab[cmpt]=hdl; 00268 cmpt++; 00269 FREE(pptabofpointobj); 00270 } 00271 00272 /*---- construct Compound ----*/ 00273 sciSetCurrentObj(ConstructCompound (hdltab, cmpt)); 00274 FREE(hdltab); 00275 if ( containsSurface ) { 00276 Merge3d(psubwin); 00277 sciDrawObj(sciGetCurrentFigure ()); 00278 } 00279 return(0); 00280 } 00281 00282 00283 /* sciDrawObj(sciGetCurrentFigure ());*/ 00284 return(0); 00285 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int re_index_brect | ( | double * | brect, | |
| double * | drect | |||
| ) |
| BOOL strflag2axes_properties | ( | sciPointObj * | psubwin, | |
| char * | strflag | |||
| ) |
| BOOL update_specification_bounds | ( | sciPointObj * | psubwin, | |
| rect | , | |||
| int | flag | |||
| ) |
Definition at line 411 of file Plo2dn.c.
References FALSE, pSUBWIN_FEATURE, sci_update_frame_bounds_2d(), sci_update_frame_bounds_3d(), and sciSubWindow::SRect.
00415 { 00416 sciSubWindow * ppsubwin = pSUBWIN_FEATURE (psubwin); 00417 BOOL haschanged = FALSE; 00418 00419 ppsubwin->SRect[0] = rect[0]; 00420 ppsubwin->SRect[1] = rect[1]; 00421 ppsubwin->SRect[2] = rect[2]; 00422 ppsubwin->SRect[3] = rect[3]; 00423 if (flag==3) { 00424 ppsubwin->SRect[4] = rect[4]; 00425 ppsubwin->SRect[5] = rect[5]; 00426 } 00427 00428 if(flag != 3) 00429 haschanged = sci_update_frame_bounds_2d(psubwin); 00430 else 00431 haschanged = sci_update_frame_bounds_3d(psubwin); 00432 00433 00434 return haschanged; 00435 }
Here is the call graph for this function:

| BOOL update_specification_bounds | ( | sciPointObj * | psubwin, | |
| double * | rect, | |||
| int | flag | |||
| ) |
1.5.1