00001
00002
00003
00004
00005
00006
00007
00008 #include "drawPolylineEntity.h"
00009 #include "GetProperty.h"
00010 #include "MALLOC.h"
00011 #include "math_graphics.h"
00012 #include "sciprint.h"
00013 #include "clipping.h"
00014 #include "axesScale.h"
00015 #include "drawMarks.h"
00016 #include "Xcall1.h"
00017 #include "Plo3d.h"
00018 #include "periScreen.h"
00019 #include "BasicAlgos.h"
00020 #include "PloEch.h"
00021
00022
00023 int drawPolylineEntity( sciPointObj * pObj )
00024 {
00025
00026 sciPolyline * ppPoly = pPOLYLINE_FEATURE(pObj) ;
00027 sciPointObj * parentSubWin = sciGetParentSubwin( pObj ) ;
00028 int foreground = sciGetForeground( pObj ) ;
00029 int background = sciGetBackground( pObj ) ;
00030 int lineWidth = sciGetLineWidth(pObj) ;
00031 int lineStyle = sciGetLineStyle(pObj) ;
00032 int markStyle = sciGetMarkStyle(pObj) ;
00033 int markSize = sciGetMarkSize( pObj) ;
00034 int markForeground = sciGetMarkForeground(pObj) ;
00035 int v = 0 ;
00036 double dv = 0.0 ;
00037 char logFlags[4] ;
00038 int nb_curves = 0 ;
00039 int * curves_size = NULL ;
00040 double ** xMat = NULL ;
00041 double ** yMat = NULL ;
00042 double ** zMat = NULL ;
00043 int closeFlag = ppPoly->closed ;
00044 int i ;
00045 int DPI[2] ;
00046
00047 if ( !sciGetVisibility(pObj) ) { return 0 ; }
00048
00049 GetDPIFromDriver( DPI ) ;
00050
00051 logFlags[0] = 'g';
00052 logFlags[1] = pSUBWIN_FEATURE(parentSubWin)->logflags[0];
00053 logFlags[2] = pSUBWIN_FEATURE(parentSubWin)->logflags[1];
00054 logFlags[3] = '\0' ;
00055
00056
00057
00058
00059 if ( BuildXYZvectForClipping_IfNanOrLogON(pObj,parentSubWin,&nb_curves, &xMat, &yMat, &zMat, &curves_size) < 0 )
00060 {
00061 return -1 ;
00062 }
00063
00064
00065 #ifdef _MSC_VER
00066 flag_DO = MaybeSetWinhdc();
00067 #endif
00068
00069 C2F (dr) ("xset", "dashes", &foreground, &foreground, &v, &v, &v, &v, &dv,
00070 &dv, &dv, &dv, 5L, 4096);
00071 C2F (dr) ("xset", "foreground", &foreground, &foreground, &v, &v, &v, &v,
00072 &dv, &dv, &dv, &dv, 5L, 4096);
00073 C2F (dr) ("xset", "thickness", &lineWidth, PI0, PI0, PI0, PI0, PI0, PD0,
00074 PD0, PD0, PD0, 0L, 0L);
00075 C2F (dr) ("xset", "line style", &lineStyle, PI0, PI0, PI0, PI0, PI0, PD0,
00076 PD0, PD0, PD0, 0L, 0L);
00077
00078 #ifdef _MSC_VER
00079 if ( flag_DO == 1) { ReleaseWinHdc() ; }
00080 #endif
00081
00082 sciClip(pObj);
00083
00084
00085 #ifdef _MSC_VER
00086 flag_DO = MaybeSetWinhdc ();
00087 #endif
00088
00089
00090 for( i = 0 ; i < nb_curves ; i++ )
00091 {
00092 int n1 = curves_size[i];
00093 int * xCoords = NULL ;
00094 int * yCoords = NULL ;
00095 double * xVect = NULL ;
00096 double * yVect = NULL ;
00097 double * zVect = NULL ;
00098 BOOL drawLine = FALSE ;
00099 int resultTrans3d = 1 ;
00100 int one = 1 ;
00101
00102 if( n1 == 0 ) { continue ; }
00103
00104 xCoords = MALLOC( 2 * n1 * sizeof(int ) ) ;
00105 yCoords = MALLOC( 2 * n1 * sizeof(int ) ) ;
00106 xVect = MALLOC( 2 * n1 * sizeof(double) ) ;
00107 yVect = MALLOC( 2 * n1 * sizeof(double) ) ;
00108 zVect = MALLOC( 2 * n1 * sizeof(double) ) ;
00109
00110 if ( xCoords == NULL || yCoords == NULL
00111 || xVect == NULL || yVect == NULL || zVect == NULL )
00112 {
00113 FREE( xCoords ) ;
00114 FREE( yCoords ) ;
00115 FREE( xVect ) ;
00116 FREE( yVect ) ;
00117 FREE( zVect ) ;
00118 sciprint( "Unable to allocate temporary vector, memory full.\n" ) ;
00119 return -1 ;
00120 }
00121
00123 switch ( ppPoly->plot )
00124 {
00125 case 1:
00126 drawLine = TRUE;
00127 if ( sciGetIs3d(parentSubWin) )
00128 {
00129
00130 ReverseDataFor3D(parentSubWin,xMat[i],yMat[i],zMat[i],n1);
00131
00132 resultTrans3d = trans3d(parentSubWin,n1,xCoords,yCoords,xMat[i],yMat[i],zMat[i]);
00133 }
00134 else
00135 {
00136
00137 C2F (echelle2d) (xMat[i],yMat[i], xCoords, yCoords, &n1, &one, "f2i",3L);
00138 }
00139 break ;
00140 case 2:
00141 drawLine = TRUE ;
00142 if ( sciGetIs3d(parentSubWin) )
00143 {
00144 if( zMat[i] == NULL )
00145 {
00146 FREE( zVect ) ;
00147 zVect = NULL ;
00148 }
00149
00150 ReverseDataFor3D(parentSubWin,xMat[i],yMat[i],zMat[i],n1);
00151
00152 Plo2dTo3d(2,&one,&n1,xMat[i],yMat[i],zMat[i],xVect,yVect,zVect);
00153 resultTrans3d = trans3d(parentSubWin,2*n1,xCoords,yCoords,xVect,yVect,zVect);
00154 }
00155 else
00156 {
00157 Plo2d2RealToPixel(&one,&n1,xMat[i],yMat[i],xCoords,yCoords,logFlags);
00158 }
00159 n1 = 2 * n1 ;
00160 break;
00161 case 3:
00162 {
00163 int nn1 = 0 ;
00164 drawLine = FALSE;
00165 if ( sciGetIs3d(parentSubWin) )
00166 {
00167 if( zMat[i] == NULL )
00168 {
00169 FREE(zVect) ;
00170 zVect = NULL ;
00171 }
00172
00173 ReverseDataFor3D(parentSubWin,xMat[i],yMat[i],zMat[i],n1);
00174
00175 Plo2dTo3d(3,&one,&n1,xMat[i],yMat[i],zMat[i],xVect,yVect,zVect);
00176 resultTrans3d = trans3d(parentSubWin, 2 * n1,xCoords,yCoords,xVect,yVect,zVect);
00177 }
00178 else
00179 {
00180 Plo2d3RealToPixel(&one,&n1,xMat[i],yMat[i],xCoords,yCoords,logFlags);
00181 }
00182
00183 if( resultTrans3d == 1 )
00184 {
00185 nn1 = n1 * 2 ;
00186 }
00187
00188
00189 if ( sciGetIsMark(pObj) )
00190 {
00191
00192 C2F (dr) ("xset", "dashes", &markForeground, &markForeground, &v, &v, &v, &v, &dv,
00193 &dv, &dv, &dv, 5L, 4096);
00194 C2F (dr) ("xset", "foreground", &markForeground, &markForeground, &v, &v, &v, &v,
00195 &dv, &dv, &dv, &dv, 5L, 4096);
00196
00197 C2F (dr) ("xset", "mark", &markStyle, &markSize, PI0, PI0, PI0, PI0, PD0, PD0,
00198 PD0, PD0, 0L, 0L);
00199
00200 DrawNewMarks(pObj,nn1,xCoords,yCoords,DPI);
00201 }
00202
00203 if ( sciGetIsLine(pObj) )
00204 {
00205 int iflag = 0;
00206 C2F(dr)("xsegs","v",xCoords,yCoords,&nn1,&foreground,&iflag,PI0,PD0,PD0,PD0,PD0,0L,0L);
00207 }
00209 n1 = one ;
00210 }
00211 break;
00212 case 4:
00213 {
00214 int nn2 = 0 ;
00215 double arsize1 = 0.0 ;
00216 double arsize2 = 0.0 ;
00217 int arrowSize = 0 ;
00218
00219 drawLine = FALSE;
00220
00221 if ( sciGetIs3d(parentSubWin) )
00222 {
00223 if( zMat[i] == NULL )
00224 {
00225 FREE(zVect) ;
00226 zVect = NULL ;
00227 }
00228
00229 ReverseDataFor3D( parentSubWin, xMat[i], yMat[i], zMat[i], n1 ) ;
00230
00231 Plo2dTo3d( 4, &one, &n1, xMat[i], yMat[i],zMat[i],xVect,yVect,zVect);
00232
00233 resultTrans3d = trans3d(parentSubWin,2 * n1,xCoords,yCoords,xVect,yVect,zVect);
00234 }
00235 else
00236 {
00237 Plo2d4RealToPixel(&one,&n1,xMat[i],yMat[i],xCoords,yCoords,logFlags);
00238 }
00239
00240 nn2 = 2 * (n1) - 1 ;
00241 arsize1 = Cscale.WIRect1[2] / 70.0 ;
00242 arsize2 = Cscale.WIRect1[3] / 70.0 ;
00243 arrowSize = ( (arsize1 < arsize2) ? inint(10.0*arsize1) : inint(10.0*arsize2) ) ;
00244
00245 if(resultTrans3d == 1)
00246 {
00247
00248 int iflag = 0 ;
00249
00250
00251 if ( sciGetIsMark(pObj) )
00252 {
00253
00254 C2F (dr) ("xset", "dashes", &markForeground, &markForeground, &v, &v, &v, &v, &dv,
00255 &dv, &dv, &dv, 5L, 4096);
00256 C2F (dr) ("xset", "foreground", &markForeground, &markForeground, &v, &v, &v, &v,
00257 &dv, &dv, &dv, &dv, 5L, 4096);
00258
00259 C2F (dr) ("xset", "mark", &markStyle, &markSize, PI0, PI0, PI0, PI0, PD0, PD0,
00260 PD0, PD0, 0L, 0L);
00261
00262 DrawNewMarks(pObj,nn2,xCoords,yCoords,DPI);
00263 }
00264
00265 if ( sciGetIsLine(pObj) )
00266 {
00267
00268 C2F (dr) ("xset", "dashes", &foreground, &foreground, &v, &v, &v, &v, &dv,
00269 &dv, &dv, &dv, 5L, 4096);
00270 C2F (dr) ("xset", "foreground", &foreground, &foreground, &v, &v, &v, &v,
00271 &dv, &dv, &dv, &dv, 5L, 4096);
00272 C2F (dr) ("xset", "thickness", &lineWidth, PI0, PI0, PI0, PI0, PI0, PD0,
00273 PD0, PD0, PD0, 0L, 0L);
00274 C2F (dr) ("xset", "line style", &lineStyle, PI0, PI0, PI0, PI0, PI0, PD0,
00275 PD0, PD0, PD0, 0L, 0L);
00276
00277 arrowSize = round( ppPoly->arsize_factor * arrowSize ) ;
00278
00279 C2F(dr)("xarrow","v",xCoords,yCoords,&nn2,&arrowSize,&foreground,&iflag,PD0,PD0,PD0,PD0,0L,0L);
00280 }
00281 }
00282 }
00283 break;
00284 case 5:
00285 drawLine = TRUE;
00286 if ( sciGetIs3d(parentSubWin) )
00287 {
00288 ReverseDataFor3D(parentSubWin,xMat[i],yMat[i],zMat[i],n1);
00289 resultTrans3d = trans3d(parentSubWin,n1,xCoords,yCoords,xMat[i],yMat[i],zMat[i]);
00290 }
00291 else
00292 {
00293 C2F(echelle2d)( xMat[i],yMat[i], xCoords, yCoords, &n1, &one, "f2i",3L);
00294 }
00295
00296 sciClip(pObj);
00297
00298 if(resultTrans3d == 1)
00299 {
00300 C2F (dr)("xarea", "xv", &n1, xCoords, yCoords, &closeFlag, PI0, PI0, PD0, PD0, PD0, PD0, 5L, 2L ) ;
00301 }
00302 break;
00303 case 6:
00304 {
00305
00306 double * y_shift = ppPoly->y_shift ;
00307 double barWidth = ppPoly->bar_width;
00308 double barX[4] ;
00309 double barY[4] ;
00310 double barZ[4];
00311 int pixX[4] ;
00312 int pixY[4];
00313 int four = 4;
00314
00315 drawLine = TRUE;
00316
00317 if ( sciGetIs3d(parentSubWin) )
00318 {
00319 int j ;
00320
00321 for( j = 0 ; j < n1 ; j++ )
00322 {
00323 barX[0] = xMat[i][j] - barWidth / 2 ;
00324 barX[1] = barX[0] ;
00325 barX[2] = xMat[i][j] + barWidth / 2 ;
00326 barX[3] = barX[2] ;
00327
00328 if( y_shift == NULL )
00329 {
00330 barY[0] = 0. ;
00331 barY[3] = 0. ;
00332 }
00333 else
00334 {
00335 barY[0] = y_shift[i] ;
00336 barY[3] = y_shift[i] ;
00337 }
00338 barY[1] = yMat[i][j] ;
00339 barY[2] = barY[1] ;
00340
00341 if( zMat[i] == NULL )
00342 {
00343 barZ[0] = 0.0 ;
00344 barZ[1] = 0.0 ;
00345 barZ[2] = 0.0 ;
00346 barZ[3] = 0.0 ;
00347 }
00348 else
00349 {
00350 barZ[0] = zMat[i][j] ;
00351 barZ[1] = zMat[i][j] ;
00352 barZ[2] = zMat[i][j] ;
00353 barZ[3] = zMat[i][j] ;
00354 }
00355
00356 ReverseDataFor3D( parentSubWin, barX, barY, barZ, four ) ;
00357 resultTrans3d = trans3d(parentSubWin,four,pixX,pixY,barX,barY,barZ);
00358
00359 C2F (dr) ("xset", "dashes", &background, &background, &v, &v, &v, &v, &dv,
00360 &dv, &dv, &dv, 5L, 4096);
00361 C2F (dr) ("xset", "foreground", &background, &background, &v, &v, &v, &v,
00362 &dv, &dv, &dv, &dv, 5L, 4096);
00363
00364 C2F (dr) ("xarea", "xv", &four, pixX, pixY, &closeFlag, PI0, PI0, PD0, PD0, PD0, PD0, 5L,2L);
00365
00366 C2F (dr) ("xset", "dashes", &foreground, &foreground, &v, &v, &v, &v, &dv,
00367 &dv, &dv, &dv, 5L, 4096);
00368 C2F (dr) ("xset", "foreground", &foreground, &foreground, &v, &v, &v, &v,
00369 &dv, &dv, &dv, &dv, 5L, 4096);
00370
00371
00372 C2F (dr) ("xlines", "xv", &four, pixX, pixY, &one, PI0, PI0, PD0, PD0, PD0, PD0,6L,2L);
00373 }
00374
00375 ReverseDataFor3D(parentSubWin,xMat[i],yMat[i],zMat[i],n1);
00376 resultTrans3d = trans3d(parentSubWin,n1,xCoords,yCoords,xMat[i],yMat[i],zMat[i]);
00377 }
00378 else
00379 {
00380 int j ;
00381
00382 for( j = 0 ; j < n1 ; j++ )
00383 {
00384 barX[0] = xMat[i][j] - barWidth/2;
00385 barX[1] = barX[0] ;
00386 barX[2] = xMat[i][j] + barWidth/2;
00387 barX[3] = barX[2] ;
00388
00389 if ( y_shift == NULL )
00390 {
00391 barY[0] = 0.0 ;
00392 barY[3] = 0.0 ;
00393 }
00394 else
00395 {
00396 barY[0] = y_shift[j] ;
00397 barY[3] = y_shift[j] ;
00398 }
00399 barY[1] = yMat[i][j];
00400 barY[2] = barY[1] ;
00401
00402 C2F(echelle2d)(barX,barY, pixX, pixY, &four, &one, "f2i",3L);
00403
00404 C2F (dr) ("xset", "dashes", &background, &background, &v, &v, &v, &v, &dv,
00405 &dv, &dv, &dv, 5L, 4096);
00406 C2F (dr) ("xset", "foreground", &background, &background, &v, &v, &v, &v,
00407 &dv, &dv, &dv, &dv, 5L, 4096);
00408
00409 C2F (dr) ("xarea", "xv", &four, pixX, pixY, &closeFlag, PI0, PI0, PD0, PD0, PD0, PD0, 5L,2L);
00410
00411 C2F (dr) ("xset", "dashes", &foreground, &foreground, &v, &v, &v, &v, &dv,
00412 &dv, &dv, &dv, 5L, 4096);
00413 C2F (dr) ("xset", "foreground", &foreground, &foreground, &v, &v, &v, &v,
00414 &dv, &dv, &dv, &dv, 5L, 4096);
00415
00416 C2F (dr) ("xlines", "xv", &four, pixX, pixY, &one, PI0, PI0, PD0, PD0, PD0, PD0,6L,2L);
00417 }
00418 C2F (echelle2d) (xMat[i],yMat[i], xCoords, yCoords, &n1, &one, "f2i",3L);
00419 }
00420 }
00421 break;
00422 case 7:
00423 {
00424 double * y_shift = ppPoly->y_shift ;
00425 double barX[4] ;
00426 double barY[4] ;
00427 double barZ[4];
00428 int pixX[4] ;
00429 int pixY[4];
00430 double barWidth = ppPoly->bar_width ;
00431 int four = 4 ;
00432
00433 int j ;
00434
00435 drawLine = TRUE ;
00436
00437 for( j = 0 ; j < n1 ; j++ )
00438 {
00439 double temp = xMat[i][j];
00440 xMat[i][j] = yMat[i][j];
00441 yMat[i][j] = temp ;
00442 }
00443
00444 if ( sciGetIs3d(parentSubWin) )
00445 {
00446
00447 for( j = 0 ; j < n1 ; j++ )
00448 {
00449 barY[0] = yMat[i][j] + barWidth / 2 ;
00450 barY[1] = barY[0] ;
00451 barY[2] = yMat[i][j] - barWidth / 2 ;
00452 barY[3] = barY[2] ;
00453
00454 if( y_shift == NULL)
00455 {
00456 barX[0] = 0.0 ;
00457 barX[3] = 0.0 ;
00458 }
00459 else
00460 {
00461 barX[0] = y_shift[i] ;
00462 barX[3] = y_shift[i] ;
00463 }
00464 barX[1] = xMat[i][j] ;
00465 barX[2] = barX[1] ;
00466
00467 if( zMat[i] == NULL )
00468 {
00469 barZ[0] = 0.0 ;
00470 barZ[1] = 0.0 ;
00471 barZ[2] = 0.0 ;
00472 barZ[3] = 0.0 ;
00473 }
00474 else
00475 {
00476 barZ[0] = zMat[i][j] ;
00477 barZ[1] = barZ[0] ;
00478 barZ[2] = barZ[0] ;
00479 barZ[3] = barZ[0] ;
00480 }
00481
00482 ReverseDataFor3D(parentSubWin,barX,barY,barZ,four);
00483 resultTrans3d = trans3d(parentSubWin,four,pixX,pixY,barX,barY,barZ);
00484
00485 C2F (dr) ("xset", "dashes", &background, &background, &v, &v, &v, &v, &dv,
00486 &dv, &dv, &dv, 5L, 4096);
00487 C2F (dr) ("xset", "foreground", &background, &background, &v, &v, &v, &v,
00488 &dv, &dv, &dv, &dv, 5L, 4096);
00489
00490 C2F (dr) ("xarea", "xv", &four, pixX, pixY, &closeFlag, PI0, PI0, PD0, PD0, PD0, PD0, 5L,2L);
00491
00492 C2F (dr) ("xset", "dashes", &foreground, &foreground, &v, &v, &v, &v, &dv,
00493 &dv, &dv, &dv, 5L, 4096);
00494 C2F (dr) ("xset", "foreground", &foreground, &foreground, &v, &v, &v, &v,
00495 &dv, &dv, &dv, &dv, 5L, 4096);
00496
00497 C2F (dr) ("xlines", "xv", &four, pixX, pixY, &one, PI0, PI0, PD0, PD0, PD0, PD0,6L,2L);
00498 }
00499
00500 ReverseDataFor3D(parentSubWin,xMat[i],yMat[i],zMat[i],n1);
00501 resultTrans3d = trans3d(parentSubWin,n1,xCoords,yCoords,xMat[i],yMat[i],zMat[i]);
00502 }
00503 else
00504 {
00505
00506 for( j = 0 ; j < n1 ; j++ )
00507 {
00508 barY[0] = yMat[i][j] + barWidth/2;
00509 barY[1] = barY[0] ;
00510 barY[2] = yMat[i][j] - barWidth/2;
00511 barY[3] = barY[2] ;
00512
00513 if( y_shift == NULL )
00514 {
00515 barX[0] = 0.0 ;
00516 barX[3] = 0.0 ;
00517 }
00518 else
00519 {
00520 barX[0] = y_shift[j] ;
00521 barX[3] = y_shift[j] ;
00522 }
00523 barX[1] = xMat[i][j] ;
00524 barX[2] = barX[1] ;
00525
00526 C2F (echelle2d) (barX,barY, pixX, pixY, &four, &one, "f2i",3L);
00527
00528 C2F (dr) ("xset", "dashes", &background, &background, &v, &v, &v, &v, &dv,
00529 &dv, &dv, &dv, 5L, 4096);
00530 C2F (dr) ("xset", "foreground", &background, &background, &v, &v, &v, &v,
00531 &dv, &dv, &dv, &dv, 5L, 4096);
00532
00533 C2F (dr) ("xarea", "xv", &four, pixX, pixY, &closeFlag, PI0, PI0, PD0, PD0, PD0, PD0, 5L, 2L ) ;
00534
00535 C2F (dr) ("xset", "dashes", &foreground, &foreground, &v, &v, &v, &v, &dv,
00536 &dv, &dv, &dv, 5L, 4096);
00537 C2F (dr) ("xset", "foreground", &foreground, &foreground, &v, &v, &v, &v,
00538 &dv, &dv, &dv, &dv, 5L, 4096);
00539
00540 C2F (dr) ("xlines", "xv", &four, pixX, pixY, &one, PI0, PI0, PD0, PD0, PD0, PD0,6L,2L);
00541 }
00542 C2F (echelle2d) (xMat[i],yMat[i], xCoords, yCoords, &n1, &one, "f2i",3L);
00543 }
00544 }
00545 break;
00546 default:
00547 sciprint ("This Polyline cannot be drawn !\n");
00548 break ;
00549 }
00550
00551 if(resultTrans3d == 1 && drawLine)
00552 {
00553 if(sciGetIsFilled(pObj) && ppPoly->plot != 5)
00554 {
00555 if( !ppPoly->isinterpshaded )
00556 {
00557
00558
00559 C2F (dr) ("xset", "dashes", &background, &background, &v, &v, &v, &v, &dv,
00560 &dv, &dv, &dv, 5L, 4096);
00561 C2F (dr) ("xset", "foreground", &background, &background, &v, &v, &v, &v,
00562 &dv, &dv, &dv, &dv, 5L, 4096);
00563
00564 C2F (dr) ("xarea", "xv", &n1, xCoords, yCoords, &closeFlag, PI0, PI0, PD0, PD0, PD0, PD0, 5L,2L);
00565 }
00566 else
00567 {
00568
00569 scilab_shade ( xCoords, yCoords, ppPoly->scvector, ppPoly->n1, 0);
00570 }
00571 }
00572
00573 if ( sciGetIsMark(pObj) )
00574 {
00575
00576 C2F (dr) ("xset", "dashes", &markForeground, &markForeground, &v, &v, &v, &v, &dv,
00577 &dv, &dv, &dv, 5L, 4096);
00578 C2F (dr) ("xset", "foreground", &markForeground, &markForeground, &v, &v, &v, &v,
00579 &dv, &dv, &dv, &dv, 5L, 4096);
00580
00581 C2F (dr) ("xset", "mark", &markStyle, &markSize, PI0, PI0, PI0, PI0, PD0, PD0,
00582 PD0, PD0, 0L, 0L);
00583
00584 DrawNewMarks(pObj,n1,xCoords,yCoords,DPI);
00585 }
00586
00587 if ( sciGetIsLine(pObj) )
00588 {
00589
00590 C2F (dr) ("xset", "dashes", &foreground, &foreground, &v, &v, &v, &v, &dv,
00591 &dv, &dv, &dv, 5L, 4096);
00592 C2F (dr) ("xset", "foreground", &foreground, &foreground, &v, &v, &v, &v,
00593 &dv, &dv, &dv, &dv, 5L, 4096);
00594 C2F (dr) ("xset", "thickness", &lineWidth, PI0, PI0, PI0, PI0, PI0, PD0,
00595 PD0, PD0, PD0, 0L, 0L);
00596 C2F (dr) ("xset", "line style", &lineStyle, PI0, PI0, PI0, PI0, PI0, PD0,
00597 PD0, PD0, PD0, 0L, 0L);
00598
00599 C2F (dr) ("xlines", "xv", &n1, xCoords, yCoords, &closeFlag, PI0, PI0, PD0, PD0, PD0, PD0,6L,2L);
00600
00601 }
00602 }
00603
00604 #ifdef _MSC_VER
00605 if ( flag_DO == 1) { ReleaseWinHdc () ; }
00606 #endif
00607
00608 FREE(xVect);
00609 FREE(yVect);
00610 FREE(zVect);
00611
00612 FREE (xCoords);
00613 FREE (yCoords);
00614
00615 }
00616
00617
00618 for( i = 0 ; i < nb_curves ; i++ )
00619 {
00620 int nbCurves;
00621 nbCurves = curves_size[i];
00622
00623 if( nbCurves == 0 ) { continue ; }
00624
00625 FREE(xMat[i]); xMat[i] = NULL;
00626 FREE(yMat[i]); yMat[i] = NULL;
00627 FREE(zMat[i]); zMat[i] = NULL;
00628 }
00629 FREE(xMat);
00630 FREE(yMat);
00631 FREE(zMat);
00632 FREE(curves_size); curves_size = NULL;
00633
00634 #ifdef _MSC_VER
00635 if ( flag_DO == 1) { ReleaseWinHdc (); }
00636 #endif
00637
00638 sciUnClip(pObj);
00639
00640 return 0 ;
00641
00642 }
00643
00644 int BuildXYZvectForClipping_IfNanOrLogON( sciPointObj * ppolyline,
00645 sciPointObj * psubwin ,
00646 int * nb_curves,
00647 double *** xvect ,
00648 double *** yvect ,
00649 double *** zvect ,
00650 int ** curves_size )
00651 {
00652 int i ;
00653 sciSubWindow * ppsubwin = pSUBWIN_FEATURE(psubwin) ;
00654 sciPolyline * pppolyline = pPOLYLINE_FEATURE(ppolyline);
00655 int * indexGoodPoints = NULL;
00656
00657 int value = 0;
00658 int nb = 0;
00659
00660 int nbPoints = pppolyline->n1 ;
00661
00662 int * store_data[3] = { NULL, NULL, NULL } ;
00663 double * pvx_plus_x_shift = NULL;
00664 double * pvy_plus_y_shift = NULL;
00665 double * pvz_plus_z_shift = NULL;
00666
00667 double * x_shift = pppolyline->x_shift;
00668 double * y_shift = pppolyline->y_shift;
00669 double * z_shift = pppolyline->z_shift;
00670
00671 if ( pppolyline->n1 == 0 )
00672 {
00673 *nb_curves = 0 ;
00674 *xvect = NULL ;
00675 *yvect = NULL ;
00676 *zvect = NULL ;
00677 *curves_size = 0 ;
00678 return 0 ;
00679 }
00680
00681 pvx_plus_x_shift = MALLOC( nbPoints * sizeof(double) ) ;
00682 if ( pvx_plus_x_shift == NULL )
00683 {
00684 sciprint( "Unable to allocate temporary vector, memory full.\n" ) ;
00685 return -1 ;
00686 }
00687
00688 if( x_shift != NULL )
00689 {
00690 for( i = 0 ; i < nbPoints ; i++ )
00691 {
00692 pvx_plus_x_shift[i] = pppolyline->pvx[i] + x_shift[i] ;
00693 }
00694 }
00695 else
00696 {
00697 for( i = 0 ; i < nbPoints ; i++ )
00698 {
00699 pvx_plus_x_shift[i] = pppolyline->pvx[i];
00700 }
00701 }
00702
00703 pvy_plus_y_shift = MALLOC( nbPoints * sizeof(double) ) ;
00704 if ( pvy_plus_y_shift == NULL )
00705 {
00706 FREE( pvx_plus_x_shift ) ;
00707 sciprint( "Unable to allocate temporary vector, memory full.\n" ) ;
00708 return -1 ;
00709 }
00710
00711 if( y_shift != NULL )
00712 {
00713 for( i = 0 ; i < nbPoints ; i++ )
00714 {
00715 pvy_plus_y_shift[i] = pppolyline->pvy[i] + y_shift[i] ;
00716 }
00717 }
00718 else
00719 {
00720 for ( i = 0 ; i < nbPoints ; i++ )
00721 {
00722 pvy_plus_y_shift[i] = pppolyline->pvy[i] ;
00723 }
00724 }
00725
00726
00727 if( pppolyline->pvz != NULL || z_shift != NULL )
00728 {
00729 pvz_plus_z_shift = MALLOC( nbPoints * sizeof(double) ) ;
00730 if ( pvz_plus_z_shift == NULL )
00731 {
00732 FREE( pvx_plus_x_shift ) ;
00733 FREE( pvy_plus_y_shift ) ;
00734 sciprint( "Unable to allocate temporary vector, memory full.\n" ) ;
00735 return -1 ;
00736 }
00737
00738 if ( z_shift != NULL && pppolyline->pvz != NULL)
00739 {
00740 for( i = 0 ; i < nbPoints ; i++ )
00741 {
00742 pvz_plus_z_shift[i] = pppolyline->pvz[i] + z_shift[i] ;
00743 }
00744 }
00745 else if ( z_shift != NULL && pppolyline->pvz == NULL )
00746 {
00747 for ( i = 0 ; i < nbPoints ; i++ )
00748 {
00749 pvz_plus_z_shift[i] = z_shift[i] ;
00750 }
00751 }
00752 else if ( z_shift == NULL && pppolyline->pvz != NULL )
00753 {
00754 for( i = 0 ; i < nbPoints ; i++ )
00755 {
00756 pvz_plus_z_shift[i] = pppolyline->pvz[i] ;
00757 }
00758 }
00759 }
00760
00761 for( i = 0 ; i < 3 ; i++ )
00762 {
00763 store_data[i] = MALLOC ( nbPoints * sizeof(int) ) ;
00764 if ( store_data[i] == NULL )
00765 {
00766 int j ;
00767 for ( j = 0 ; j < i ; j++ )
00768 {
00769 FREE( store_data[i] ) ;
00770 }
00771 FREE( pvx_plus_x_shift ) ;
00772 FREE( pvy_plus_y_shift ) ;
00773 FREE( pvz_plus_z_shift ) ;
00774 sciprint( "Unable to allocate temporary vector, memory full.\n" ) ;
00775 return -1 ;
00776 }
00777 }
00778
00779 indexGoodPoints = MALLOC( nbPoints * sizeof(integer) ) ;
00780 if ( indexGoodPoints == NULL )
00781 {
00782 FREE( store_data[0] ) ;
00783 FREE( store_data[1] ) ;
00784 FREE( store_data[2] ) ;
00785 FREE( pvx_plus_x_shift ) ;
00786 FREE( pvy_plus_y_shift ) ;
00787 FREE( pvz_plus_z_shift ) ;
00788 sciprint( "Unable to allocate temporary vector, memory full.\n" ) ;
00789 return -1 ;
00790 }
00791
00792 for( i = 0 ; i < nbPoints ; i++ )
00793 {
00794 indexGoodPoints[i] = nbPoints + 1000;
00795 }
00796
00797
00798
00799
00800 for( i = 0 ; i < nbPoints ; i++ )
00801 {
00802 if ( pvz_plus_z_shift == NULL )
00803 {
00804 if( (finite(pvx_plus_x_shift[i]) == 1) &&
00805 (finite(pvy_plus_y_shift[i]) == 1) )
00806 {
00807 indexGoodPoints[i] = 1 ;
00808 }
00809 else
00810 {
00811 indexGoodPoints[i] = -1 ;
00812 }
00813 }
00814 else
00815 {
00816 if( (finite(pvx_plus_x_shift[i]) == 1) &&
00817 (finite(pvy_plus_y_shift[i]) == 1) &&
00818 (finite(pvz_plus_z_shift[i]) == 1))
00819 {
00820 indexGoodPoints[i] = 1 ;
00821 }
00822 else
00823 {
00824 indexGoodPoints[i] = -1;
00825 }
00826
00827 }
00828 }
00829
00830
00831
00832 for( i = 0 ; i < nbPoints ; i++ )
00833 {
00834 if( ppsubwin->logflags[0] == 'l' )
00835 {
00836 if((indexGoodPoints[i] == 1) && (pvx_plus_x_shift[i] <= 0))
00837 {
00838 indexGoodPoints[i] = -1;
00839 }
00840 }
00841
00842 if(ppsubwin->logflags[1] == 'l')
00843 {
00844 if((indexGoodPoints[i] == 1) && (pvy_plus_y_shift[i] <= 0))
00845 {
00846 indexGoodPoints[i] = -1;
00847 }
00848 }
00849
00850 if(pppolyline->pvz != NULL && ppsubwin->logflags[2] == 'l')
00851 {
00852 if((indexGoodPoints[i] == 1) && (pvz_plus_z_shift[i] <= 0))
00853 {
00854 indexGoodPoints[i] = -1;
00855 }
00856 }
00857
00858 }
00859
00860 value = indexGoodPoints[0];
00861
00862
00863 *nb_curves = 0;
00864 if( value == 1 )
00865 {
00866
00867
00868 int j = 0 ;
00869 int k = 0 ;
00870
00871 *nb_curves = 0 ;
00872
00873 while( j < nbPoints )
00874 {
00875
00876 for( i = j ; i < nbPoints ; i++ )
00877 {
00878 if(indexGoodPoints[i] == 1)
00879 {
00880 continue ;
00881 }
00882 else
00883 {
00884 break ;
00885 }
00886 }
00887
00888 store_data[0][(*nb_curves)] = j ;
00889 store_data[1][(*nb_curves)] = i ;
00890 store_data[2][(*nb_curves)] = i - j ;
00891
00892 *nb_curves = *nb_curves + 1;
00893
00894
00895 for( k = i ; k < nbPoints ; k++ )
00896 {
00897 if(indexGoodPoints[k] == -1)
00898 {
00899 continue ;
00900 }
00901 else
00902 {
00903 break ;
00904 }
00905 }
00906 j = k ;
00907 }
00908 }
00909 else if( value == -1 )
00910 {
00911
00912
00913 int j = 0 ;
00914 int k = 0 ;
00915
00916 *nb_curves = 0 ;
00917
00918 while( j < nbPoints )
00919 {
00920
00921 for( i = j ; i < nbPoints ; i++ )
00922 {
00923 if(indexGoodPoints[i] == -1)
00924 {
00925 continue ;
00926 }
00927 else
00928 {
00929 break ;
00930 }
00931 }
00932
00933 for ( k = i ; k < nbPoints ; k++ )
00934 {
00935 if(indexGoodPoints[k] == 1)
00936 {
00937 continue ;
00938 }
00939 else
00940 {
00941 break ;
00942 }
00943 }
00944
00945 store_data[0][(*nb_curves)] = i;
00946 store_data[1][(*nb_curves)] = k;
00947 store_data[2][(*nb_curves)] = k-i;
00948
00949
00950 *nb_curves = *nb_curves + 1;
00951 j = k ;
00952
00953 }
00954 }
00955 else
00956 {
00957 sciprint("Impossible case in CheckClippingNanLogON\n");
00958 }
00959
00960
00961 nb = *nb_curves;
00962
00963
00964 *xvect = MALLOC( nb * sizeof(double *) ) ;
00965 *yvect = MALLOC( nb * sizeof(double *) ) ;
00966 *zvect = MALLOC( nb * sizeof(double *) ) ;
00967 if ( *xvect == NULL || *yvect == NULL || *zvect == NULL )
00968 {
00969 FREE( store_data[0] ) ;
00970 FREE( store_data[1] ) ;
00971 FREE( store_data[2] ) ;
00972 FREE( pvx_plus_x_shift ) ;
00973 FREE( pvy_plus_y_shift ) ;
00974 FREE( pvz_plus_z_shift ) ;
00975 FREE( indexGoodPoints ) ;
00976 FREE( *xvect ) ;
00977 FREE( *yvect ) ;
00978 FREE( *zvect ) ;
00979 sciprint( "Unable to allocate temporary vector, memory full.\n" ) ;
00980 return -1 ;
00981 }
00982
00983 for( i = 0 ; i < nb ; i++ )
00984 {
00985 int j ;
00986 int cmpteur = 0;
00987
00988 if( store_data[2][i] > 0 )
00989 {
00990
00991 (*xvect)[i] = MALLOC( store_data[2][i] * sizeof(double) ) ;
00992 (*yvect)[i] = MALLOC( store_data[2][i] * sizeof(double) ) ;
00993 if(pvz_plus_z_shift == NULL)
00994 {
00995 (*zvect)[i] = NULL ;
00996 }
00997 else
00998 {
00999 (*zvect)[i] = MALLOC( store_data[2][i] * sizeof(double) ) ;
01000 }
01001
01002 if ( ( *xvect)[i] == NULL || (*yvect)[i] == NULL
01003 || ( pvz_plus_z_shift != NULL && (*zvect)[i] == NULL ) )
01004 {
01005 int k ;
01006 for ( k = 0 ; k <= i ; k++ )
01007 {
01008 FREE( (*xvect)[k] ) ;
01009 FREE( (*yvect)[k] ) ;
01010 if ( pvz_plus_z_shift != NULL ) { FREE( (*zvect)[k] ) ; }
01011 }
01012 FREE( store_data[0] ) ;
01013 FREE( store_data[1] ) ;
01014 FREE( store_data[2] ) ;
01015 FREE( pvx_plus_x_shift ) ;
01016 FREE( pvy_plus_y_shift ) ;
01017 FREE( pvz_plus_z_shift ) ;
01018 FREE( indexGoodPoints ) ;
01019 FREE( *xvect ) ;
01020 FREE( *yvect ) ;
01021 FREE( *zvect ) ;
01022 sciprint( "Unable to allocate temporary vector, memory full.\n" ) ;
01023 return -1 ;
01024 }
01025 }
01026 for(j=store_data[0][i];j<store_data[1][i];j++)
01027 {
01028 (*xvect)[i][cmpteur] = pvx_plus_x_shift[j];
01029 (*yvect)[i][cmpteur] = pvy_plus_y_shift[j];
01030 if(pvz_plus_z_shift != NULL)
01031 {
01032 (*zvect)[i][cmpteur] = pvz_plus_z_shift[j];
01033 }
01034
01035 cmpteur++;
01036
01037 }
01038 }
01039
01040 *curves_size = createIntArrayCopy( store_data[2], nb ) ;
01041 if ( *curves_size == NULL )
01042 {
01043 int k ;
01044 for ( k = 0 ; k < nb ; k++ )
01045 {
01046 FREE( (*xvect)[k] ) ;
01047 FREE( (*yvect)[k] ) ;
01048 FREE( (*zvect)[k] ) ;
01049 }
01050 FREE( store_data[0] ) ;
01051 FREE( store_data[1] ) ;
01052 FREE( store_data[2] ) ;
01053 FREE( pvx_plus_x_shift ) ;
01054 FREE( pvy_plus_y_shift ) ;
01055 FREE( pvz_plus_z_shift ) ;
01056 FREE( indexGoodPoints ) ;
01057 FREE( *xvect ) ;
01058 FREE( *yvect ) ;
01059 FREE( *zvect ) ;
01060 sciprint( "Unable to allocate temporary vector, memory full.\n" ) ;
01061 return -1 ;
01062 }
01063
01064
01065 FREE( store_data[0] ) ;
01066 FREE( store_data[1] ) ;
01067 FREE( store_data[2] ) ;
01068 FREE(indexGoodPoints); indexGoodPoints = NULL;
01069 FREE(pvx_plus_x_shift); pvx_plus_x_shift = NULL;
01070 FREE(pvy_plus_y_shift); pvy_plus_y_shift = NULL;
01071 FREE(pvz_plus_z_shift); pvz_plus_z_shift = NULL;
01072 return 0;
01073 }
01074
01075 void Plo2dTo3d(integer type, integer *n1, integer *n2, double x[], double y[], double z[], double xOut[], double yOut[], double zOut[])
01076 {
01077
01078 integer i,j;
01079 switch (type)
01080 {
01081 case 2:
01083 for ( i=0 ; i < (*n2) ; i++)
01084 for (j=0 ; j< (*n1) ; j++)
01085 {
01086 yOut[2*i+1+2*(*n2)*j]= yOut[2*i+2*(*n2)*j]= y[i+(*n2)*j];
01087 if (z == NULL)
01088 zOut = (double *) NULL;
01089 else
01090 zOut[2*i+1+2*(*n2)*j]= zOut[2*i+2*(*n2)*j]= z[i+(*n2)*j];
01091 }
01092
01093
01095 for (j=0 ; j< (*n1) ; j++)
01096 {
01097 for ( i=1 ; i < (*n2) ; i++)
01098 {
01099 xOut[2*i+2*(*n2)*j]= x[i+(*n2)*j];
01100 xOut[2*i-1+2*(*n2)*j]=xOut[2*i+2*(*n2)*j];
01101 }
01102 xOut[2*(*n2)*j]= x[(*n2)*j];
01103 xOut[2*(*n2)-1+ 2*(*n2)*j]= xOut[2*(*n2-1)+ 2*(*n2)*j];
01104 }
01105 break;
01106 case 3:
01108 for ( i=0 ; i < (*n2) ; i++)
01109 for (j=0 ; j< (*n1) ; j++)
01110 {
01111 yOut[2*i+1+2*(*n2)*j]= 0.0;
01112 yOut[2*i+2*(*n2)*j]= y[i+(*n2)*j];
01113 }
01115 for (j=0 ; j< (*n1) ; j++)
01116 {
01117 for ( i=0 ; i < (*n2) ; i++)
01118 {
01119 xOut[2*i+2*(*n2)*j]= x[i+(*n2)*j];
01120 xOut[2*i+1+2*(*n2)*j]=xOut[2*i+2*(*n2)*j];
01121 if (z == NULL)
01122 zOut = (double *) NULL;
01123 else
01124 {
01125 zOut[2*i+2*(*n2)*j]= z[i+(*n2)*j];
01126 zOut[2*i+1+2*(*n2)*j]=zOut[2*i+2*(*n2)*j];
01127 }
01128 }
01129 }
01130 break;
01131 case 4:
01133 for ( i=0 ; i < (*n2) ; i++)
01134 for (j=0 ; j< (*n1) ; j++)
01135 yOut[2*i+2*(*n2)*j]= y[i+(*n2)*j];
01136 for ( i=0 ; i < (*n2)-1 ; i++)
01137 for (j=0 ; j< (*n1) ; j++)
01138 yOut[2*i+1+2*(*n2)*j]=yOut[2*i+2+2*(*n2)*j];
01140 for (j=0 ; j< (*n1) ; j++)
01141 for ( i=0 ; i < (*n2) ; i++)
01142 xOut[2*i+2*(*n2)*j]= x[i+(*n2)*j];
01143 for (j=0 ; j< (*n1) ; j++)
01144 for ( i=0 ; i < (*n2)-1 ; i++)
01145 xOut[2*i+1+2*(*n2)*j]=xOut[2*i+2+2*(*n2)*j];
01147 if (z == NULL)
01148 zOut = (double *) NULL;
01149 else
01150 {
01151 for (j=0 ; j< (*n1) ; j++)
01152 for ( i=0 ; i < (*n2) ; i++)
01153 zOut[2*i+2*(*n2)*j]= z[i+(*n2)*j];
01154 for (j=0 ; j< (*n1) ; j++)
01155 for ( i=0 ; i < (*n2)-1 ; i++)
01156 zOut[2*i+1+2*(*n2)*j]=zOut[2*i+2+2*(*n2)*j];
01157 }
01158 break;
01159 default:
01160 break;
01161 }
01162 }
01163