Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSpectrum2Painter.cxx
Go to the documentation of this file.
1// @(#)root/spectrumpainter:$Id: TSpectrum2Painter.cxx,v 1.00
2// Author: Miroslav Morhac 29/09/06
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12
13/** \class TSpectrum2Painter
14 \ingroup Spectrumpainter
15
16Two-dimensional graphics function
17
18TSpectrum2Painter is a set of graphical functions developed by Miroslav
19Morhac to paint 2D-histograms in three dimensions. This package is accessed
20via THistPainter in a transparent way. For the ROOT user it is enough to use
21the "SPEC" option to draw a 2D-Histogram. This option offers many
22functionalities detailed in the header of the PaintSpectrum function.
23
24Reference:
25
26Morhac M., Kliman J., Matousek V., Turzo I.: Sophisticated visualization
27algorithms for analysis of multidimensional experimental nuclear data. Acta
28Pysica Slovaca Vol. 54/ 4 (2004), pp. 385-400.
29*/
30
31#include <climits>
32
33#include "TROOT.h"
34#include "TColor.h"
35#include "TMath.h"
36#include "TLine.h"
37#include "TEllipse.h"
38#include "TVirtualPad.h"
39#include "TBox.h"
40#include "TF1.h"
41#include "TH2.h"
42#include "TGaxis.h"
43#include "THLimitsFinder.h"
44#include "TSpectrum2Painter.h"
45#include "strlcpy.h"
46
48
49
50////////////////////////////////////////////////////////////////////////////////
51/// TSpectrum2Painter normal constructor
52
54 : TNamed ("Spectrum Painter2","Miroslav Morhac Painter")
55{
56 int i, j;
57 double val;
58 gPad->Range(0, 0, 1 ,1);
59 fXmin = 0;
60 fXmax = h2->GetNbinsX() - 1;
61 fYmin = 0;
62 fYmax = h2->GetNbinsY() - 1;
63 fZmin = 0, fZmax = 0;
64 fMaximumXScreenResolution = bs;
65
66 for (i = 0;i <= fXmax; i++) {
67 for (j = 0;j <= fYmax; j++) {
68 val = h2->GetBinContent(i + 1,j + 1);
69 if (val > fZmax) fZmax = val;
70 }
71 }
72
73 fBx1 = gPad->XtoPixel(0.1); //axis positions
74 fBx2 = gPad->XtoPixel(0.99);
75 fBy1 = gPad->YtoPixel(0.99);
76 fBy2 = gPad->YtoPixel(0.05);
77
78 fModeGroup = kModeGroupLightHeight;
79
80 fDisplayMode = kDisplayModeSurface;
81
82 fZscale = kZScaleLinear; // Scale linear, log.
83
84 fNodesx = fXmax-fXmin+1; // Number of nodes in x dimension of grid
85 fNodesy = fYmax-fYmin+1; // Number of nodes in y dimension of grid
86
87 fContWidth = 50; // Width between contours,
88 // applies only for contours display mode.
89 fAlpha = 20; // Angles of display,alfa+beta must be less or equal to 90,
90 // alpha- angle between base line of Canvas and left lower
91 // edge of picture picture base plane
92 fBeta = 60; // Angle between base line of Canvas and right lower edge
93 // of picture base plane
94 fViewAngle = 0; // Rotation angle of the view,
95 // it can be 0, 90, 180, 270 degrees.
96
97 fLevels = 256; // Number of color levels for rainbowed display modes,
98 // It does not apply for simple display modes
99 // algorithm group
100 fRainbow1Step = 1; // Determines the first component step for
101 // neighbouring color levels, applies only for
102 // rainbowed display modes, it does not apply for
103 // simple display modes algorithm group.
104 fRainbow2Step = 1; // Determines the second component step for
105 // neighbouring color levels, applies only for
106 // rainbowed display modes, it does not apply for
107 // simple display modes algorithm group.
108 fRainbow3Step = 1; // Determines the third component step for
109 // neighbouring color levels, applies only for
110 // rainbowed display modes, it does not apply for
111 // simple display modes algorithm group.
112
113 fColorAlg = kColorAlgRgbSmooth; // Applies only for rainbowed display modes
114 // (rgb smooth algorithm, rgb modulo color
115 // component, cmy smooth algorithm, cmy
116 // modulo color component, cie smooth
117 // algorithm, cie modulo color component,
118 // yiq smooth algorithm, yiq modulo color
119 // component, hsv smooth algorithm, hsv
120 // modulo color component, it does not
121 // apply for simple display modes
122 // algorithm group.
123
124 fLHweight = 0.5; // Weight between shading according to fictive light
125 // source and according to channels counts, applies only
126 // for kModeGroupLightHeight modes group.
127
128 fXlight = 1000; // X position of fictive light source, applies only for
129 // rainbowed display modes with shading according to light.
130 fYlight = 1000; // Y position of fictive light source, applies only for
131 // rainbowed display modes with shading according to light.
132 fZlight = 1000; // Z position of fictive light source, applies only for
133 // rainbowed display modes with shading according to light.
134
135 fShadow = kShadowsNotPainted; // Determines whether shadow will be drawn
136 // (no shadow, shadow), for rainbowed
137 // display modes with shading according to
138 // light.
139
140 fShading = kShaded; // Determines whether the picture will shaded,
141 // smoothed (no shading, shading), for rainbowed
142 // display modes only.
143
144 fBezier = kNoBezierInterpol; // Determines Bezier interpolation (applies
145 // only for simple display modes group for
146 // grid, x_lines, y_lines display modes).
147
148 fPenColor = kBlack; // Color of spectrum.
149 fPenWidth = 1; // Width of line.
150 fPenDash = kPenStyleSolid; // Style of pen.
151
152 fChanmarkEnDis = kChannelMarksNotDrawn; // Decides whether the channel
153 // marks are shown.
154 fChanmarkColor = kBlue; // Color of channel marks.
155 fChanmarkWidth = 8; // Width of channel marks.
156 fChanmarkHeight = 8; // Height of channel marks.
157 fChanmarkStyle = kChannelMarksStyleDot; // Style of channel marks.
158
159 fChanlineEnDis = kChannelGridNotDrawn; // Decides whether the channel lines
160 // (grid) are shown.
161 fChanlineColor = kRed; // Color of channel marks.
162 fNewColor = 0;
163 fEnvelope = new Short_t [fMaximumXScreenResolution];
164 fEnvelopeContour = new Short_t [fMaximumXScreenResolution];
165 for (i=0;i<fMaximumXScreenResolution;i++) {
166 fEnvelope[i] = fBy2;
167 fEnvelopeContour[i] = fBy2;
168 }
169 fH2 = h2;
170}
171
172
173////////////////////////////////////////////////////////////////////////////////
174/// TSpectrum2Painter destructor
175
177{
178 TColor* col;
179 for (int i=0; i<256; i++) {
180 col = gROOT->GetColor(250+i);
181 if (col) delete col;
182 }
183 if (fEnvelope) delete [] fEnvelope;
184 if (fEnvelopeContour) delete [] fEnvelopeContour;
185}
186
187
188////////////////////////////////////////////////////////////////////////////////
189/// Reads out the value from histogram and calculates screen coordinates
190///
191/// Parameters:
192/// - it - node in x- direction
193/// - jt - node in y- direction
194/// - zmt - control variable
195
197{
198 Int_t lxt,lyt,ix,iy;
199 Double_t zf = 0;
200 Double_t p1,p2;
201 p1 = fXmin+fKx*(Double_t)it;
202 p2 = fYmin+fKy*(Double_t)jt;
203 ix = (Int_t)p1;
204 iy = (Int_t)p2;
205 fDxspline = p1;
206 fDyspline = p2;
207 if ((zmt==0)||(zmt==-3)||(zmt==-4)) {
208 zf = fH2->GetBinContent(ix+1,iy+1);
209 } else if (zmt==-2) zf = fZPresetValue;
210 if (zf<fZmin) zf = fZmin;
211 fZeq = zf;
212 switch (fZscale) {
213 case kZScaleLog:
214 if (zf>=1.0) zf = log(zf);
215 else zf = 0;
216 break;
217 case kZScaleSqrt:
218 if (zf>0) zf = sqrt(zf);
219 else zf = 0;
220 break;
221 }
222 lxt = (Int_t)(fTxx*(Double_t)it+fTxy*(Double_t)jt+fVx);
223 lyt = (Int_t)(fTyx*(Double_t)it+fTyy*(Double_t)jt+fTyz*zf+fVy);
224 if (lxt<fBx1) lxt = fBx1;
225 if (lxt>fBx2) lxt = fBx2;
226 if (lyt<fBy1) lyt = fBy1;
227 if (lyt>fBy2) lyt = fBy2;
228 fXt = lxt;
229 fYt = lyt;
230 fZ = zf;
231 return;
232}
233
234
235////////////////////////////////////////////////////////////////////////////////
236/// Calculates and returns color value for the surface triangle
237/// given by function parameters:
238/// -dx1,dy1,z1 coordinates of the first point in 3d space
239/// -dx2,dy2,z2 coordinates of the second point in 3d space
240/// -dx3,dy3,z3 coordinates of the third point in 3d space
241
243 Double_t dx1, Double_t dy1, Double_t z1,
244 Double_t dx2, Double_t dy2, Double_t z2,
245 Double_t dx3, Double_t dy3, Double_t z3)
246{
247 Double_t da,db,dc=0,dd,dl,dm,dn,xtaz,ytaz,ztaz,v=0,v1;
248 Double_t pi=3.1415927;
249 Int_t i;
250 switch (fZscale) {
251 case kZScaleLog:
252 if (z1>900) z1 = 900;
253 z1 = exp(z1);
254 if (z2>900) z2 = 900;
255 z2 = exp(z2);
256 if (z3>900) z3 = 900;
257 z3 = exp(z3);
258 break;
259 case kZScaleSqrt:
260 z1 = z1*z1;
261 z2 = z2*z2;
262 z3 = z3*z3;
263 break;
264 }
265 i = fViewAngle;
266 i = i/90;
267 if ((i==1)||(i==3)) {
268 da = dx1;
269 dx1 = dx2;
270 dx2 = da;
271 da = dy1;
272 dy1 = dy2;
273 dy2 = da;
274 da = z1;
275 z1 = z2;
276 z2 = da;
277 }
278 xtaz = (dx1+dx2+dx3)/3;
279 ytaz = (dy1+dy2+dy3)/3;
280 ztaz = (z1+z2+z3)/3;
282 dn = (Double_t)fZlight-ztaz;
283 dm = (Double_t)fYlight-ytaz;
284 dl = (Double_t)fXlight-xtaz;
285 da = (dy2-dy1)*(z3-z1)-(dy3-dy1)*(z2-z1);
286 db = (z2-z1)*(dx3-dx1)-(z3-z1)*(dx2-dx1);
287 dc = (dx2-dx1)*(dy3-dy1)-(dx3-dx1)*(dy2-dy1);
288 dd = (da*da+db*db+dc*dc)*(dl*dl+dm*dm+dn*dn);
289 dd = sqrt(dd);
290 if (dd!=0) v = (da*dl+db*dm+dc*dn)/dd;
291 else v = 0;
292 if (v<-1) v=-1;
293 if (v>1) v=1;
294 v = asin(v);
295 v = v+pi/2;
296 v = v/pi;
297 } else if (fModeGroup==kModeGroupHeight) {
298 da = fZmax-fZmin;
299 if (ztaz<fZmin) ztaz=fZmin;
300 if (ztaz>=fZmax) ztaz=fZmax-1;
301 db = ztaz-fZmin;
302 if (da!=0) {
303 switch (fZscale) {
304 case kZScaleLinear:
305 dc = db/da;
306 break;
307 case kZScaleLog:
308 if (da>=1) da=log(da);
309 if (db>=1) db=log(db);
310 if (da!=0) dc=db/da;
311 else dc=0;
312 break;
313 case kZScaleSqrt:
314 da = sqrt(da);
315 db = sqrt(db);
316 dc = db/da;
317 break;
318 }
319 } else {
320 dc=0;
321 }
322 i = (Int_t)dc;
323 v = dc-i;
324 } else if (fModeGroup==kModeGroupLightHeight) {
325 dn = (Double_t)fZlight-ztaz;
326 dm = (Double_t)fYlight-ytaz;
327 dl = (Double_t)fXlight-xtaz;
328 da = (dy2-dy1)*(z3-z1)-(dy3-dy1)*(z2-z1);
329 db = (z2-z1)*(dx3-dx1)-(z3-z1)*(dx2-dx1);
330 dc = (dx2-dx1)*(dy3-dy1)-(dx3-dx1)*(dy2-dy1);
331 dd = (da*da+db*db+dc*dc)*(dl*dl+dm*dm+dn*dn);
332 dd = sqrt(dd);
333 if (dd!=0) v = (da*dl+db*dm+dc*dn)/dd;
334 else v = 0;
335 if (v<-1) v=-1;
336 if (v>1) v=1;
337 v = asin(v);
338 v = v+pi/2;
339 v = v/pi;
340 da = fZmax-fZmin;
341 if (ztaz<fZmin) ztaz = fZmin;
342 if (ztaz>=fZmax) ztaz = fZmax-1;
343 db = ztaz-fZmin;
344 if (da!=0) {
345 switch (fZscale) {
346 case kZScaleLinear:
347 dc = db/da;
348 break;
349 case kZScaleLog:
350 if (da>=1) da = log(da);
351 if (db>=1) db = log(db);
352 if (da!=0) dc = db/da;
353 else dc = 0;
354 break;
355 case kZScaleSqrt:
356 da = sqrt(da);
357 db = sqrt(db);
358 dc = db/da;
359 break;
360 }
361 } else {
362 dc = 0;
363 }
364 i = (Int_t)dc;
365 v1 = dc-i;
366 v = fLHweight*v+(1-fLHweight)*v1;
367 }
369 da = 1.0/(Double_t)fLevels;
370 if (v<da) v = da;
371 } else {
372 da = 2.0/(Double_t)fLevels;
373 if (v<da) v = da;
374 }
375 return(v);
376}
377
378
379////////////////////////////////////////////////////////////////////////////////
380/// Determines whether the center of the triangle in 3-d space
381/// given by function parameters:
382/// - xtaz,ytaz,ztaz
383/// is in shadow or not. If yes it return 1 otherwise it returns 0.
384
386 Double_t ztaz,
387 Double_t shad_noise)
388{
389 Int_t sx2,sy2,sz1,sz2,skrokx,skroky,xmax,ymax;
390 Double_t sx1,sy1;
391 Double_t pom1,pom2,sdx1=0,sdx2=0,sdy1,sdy2,spriz;
392 switch (fZscale) {
393 case kZScaleLog:
394 if (ztaz>900) ztaz = 900;
395 ztaz = exp(ztaz);
396 if (ztaz>32767) ztaz = 32767;
397 break;
398 case kZScaleSqrt:
399 ztaz = ztaz*ztaz;
400 break;
401 }
402 spriz = 0;
403 sx1 = xtaz;
404 sy1 = ytaz;
405 sz1 = (Int_t)ztaz;
406 sx2 = fXlight;
407 sy2 = fYlight;
408 sz2 = fZlight;
409 xmax = fXmax;
410 ymax = fYmax;
411 if (sx1!=sx2) {
412 if (sx1<sx2) skrokx = 1;
413 else skrokx = -1;
414 if (sy1<sy2) skroky = 1;
415 else skroky = -1;
416 pom1 = sx2-sx1;
417 pom2 = sy2-sy1;
418 if (TMath::Abs(pom1)>0.0000001) sdx1 = pom2/pom1;
419 pom1 = sx1;
420 pom2 = sy1;
421 sdy1 = pom2-sdx1*pom1;
422 pom1 = sx2-sx1;
423 pom2 = sz2-sz1;
424 if (TMath::Abs(pom1)>0.0000001) sdx2 = pom2/pom1;
425 pom1 = sx1;
426 pom2 = sz1;
427 sdy2 = pom2-sdx2*pom1;
428 spriz = 0;
429 pom1 = sx1;
430 pom2 = pom1*sdx1+sdy1;
431 sy1 = pom2;
432 for (;(sx1>(fXmin-skrokx)) && (sx1<(xmax-skrokx)) &&
433 (sy1>(fYmin-skroky)) && (sy1<(ymax-skroky)) &&
434 (spriz==0);sx1+=skrokx) {
435 pom1 = sx1;
436 pom2 = pom1*sdx1+sdy1;
437 sy1 = pom2+skroky;
438 if ((sy1>=fYmin)&&(sy1<=fYmax)) {
439 sz1 = (Int_t)(fH2->GetBinContent((Int_t)sx1+1,(Int_t)sy1+1));
440 pom2 = pom1*sdx2+sdy2;
441 sz2 = (Int_t)(pom2+shad_noise);
442 if (sz1>sz2) spriz = 1;
443 }
444 }
445 } else if (sy1!=sy2) {
446 if (sy1<sy2) skroky = 1;
447 else skroky = -1;
448 pom1 = sy2-sy1;
449 pom2 = sz2-sz1;
450 if (TMath::Abs(pom1)>0.0000001) sdx2 = pom2/pom1;
451 pom1 = sy1;
452 pom2 = sz1;
453 sdy2 = pom2-sdx2*pom1;
454 spriz = 0;
455 for (;(sy1>(fYmin-skroky)) && (sy1<(ymax-skroky)) &&
456 (spriz==0);sy1+=skroky) {
457 sz1 = (Int_t)(fH2->GetBinContent((Int_t)sx1+1,(Int_t)sy1+1));
458 pom1 = sy1;
459 pom2 = pom1*sdx2+sdy2;
460 sz2 = (Int_t)(pom2+shad_noise);
461 if (sz1>sz2) spriz=1;
462 }
463 }
464 return(spriz);
465}
466
467
468////////////////////////////////////////////////////////////////////////////////
469/// This function calculates color for one palette entry
470/// given by function parameter ui. Other parameters
471/// -ui1,ui2,ui3
472/// represent r, g, b color components of the basic pen color.
473
474void TSpectrum2Painter::ColorModel(unsigned ui, unsigned ui1, unsigned ui2,
475 unsigned ui3)
476{
477 unsigned long uinc1=0,uinc2=0,uinc3=0,upom,i;
478 Double_t a,b,c,d,h,v,s,f;
479 Int_t j,iv=ui;
480 Double_t red=0,green=0,blue=0;
481 if (iv<0) iv = 0;
482 else if (iv>255) iv = 255;
483 if (gROOT->GetColor(250+iv)) {
484 fNewColorIndex = 250+iv;
485 return;
486 }
487 if (fColorAlg%2==0) {
489 a = ui*a;
490 a = ui1+a;
491 if (a >= UINT_MAX) uinc1 = UINT_MAX;
492 else uinc1 = (unsigned)a;
493 upom = uinc1%256;
494 i = (uinc1-upom)/256;
495 if ((i%2)==0) uinc1 = upom;
496 else uinc1 = 255-upom;
498 b = ui*b;
499 b = ui2+b;
500 uinc2 = (Int_t)b;
501 upom = uinc2%256;
502 i = (uinc2-upom)/256;
503 if ((i%2)==0) uinc2 = upom;
504 else uinc2 = 255-upom;
506 c = ui*c;
507 c = ui3+c;
508 uinc3 = (Int_t)c;
509 upom = uinc3%256;
510 i = (uinc3-upom)/256;
511 if ((i%2)==0) uinc3 = upom;
512 else uinc3 = 255-upom;
514 uinc1 = 255-uinc1;
515 uinc2 = 255-uinc2;
516 uinc3 = 255-uinc3;
517 } else if (fColorAlg==kColorAlgCieSmooth) {
518 a = uinc1;
519 b = uinc2;
520 c = uinc3;
521 d = a+b+c;
522 if (d!=0) {
523 a = a/d;
524 b = b/d;
525 c = c/d;
526 }
527 red = a*255;
528 green = b*255;
529 blue = c*255;
530 uinc1 = (Int_t)red;
531 uinc2 = (Int_t)green;
532 uinc3 = (Int_t)blue;
533 } else if (fColorAlg==kColorAlgYiqSmooth) {
534 a = uinc1;
535 b = uinc2;
536 c = uinc3;
537 a = a/256;
538 b = b/256;
539 c = c/256;
540 red = a+0.956*b+0.62*c;
541 green = a-0.272*b-0.647*c;
542 blue = a-1.108*b+1.705*c;
543 if (red>=2) red = red-2;
544 else if (red>=1) red = 2-red;
545 if (green<0) green = -green;
546 if (blue>=2) blue = blue-2;
547 else if (blue>=1) blue = 2-blue;
548 else if (blue<-1) blue = 2+blue;
549 else if (blue<0) blue = -blue;
550 red = red*255;
551 green = green*255;
552 blue = blue*255;
553 uinc1 = (Int_t)red;
554 uinc2 = (Int_t)green;
555 uinc3 = (Int_t)blue;
556 } else if (fColorAlg==kColorAlgHvsSmooth) {
557 h = uinc1;
558 v = uinc2;
559 s = uinc3;
560 h = h/256;
561 v = v/256;
562 s = s/256;
563 if (s==0) {
564 red = v;
565 green = v;
566 blue = v;
567 } else {
568 if (h==1.0) h=0;
569 h = 6.0*h;
570 j = (Int_t)h;
571 f = h-j;
572 a = v*(1-s);
573 b = v*(1-s*f);
574 c = v*(1-s*(1-f));
575 switch (j) {
576 case 0:
577 red = v;
578 green = c;
579 blue = a;
580 break;
581 case 1:
582 red = b;
583 green = v;
584 blue = a;
585 break;
586 case 2:
587 red = a;
588 green = v;
589 blue = c;
590 break;
591 case 3:
592 red = a;
593 green = b;
594 blue = v;
595 break;
596 case 4:
597 red = c;
598 green = a;
599 blue = v;
600 break;
601 case 5:
602 red = v;
603 green = a;
604 blue = b;
605 break;
606 }
607 }
608 red = red*255;
609 green = green*255;
610 blue = blue*255;
611 uinc1 = (Int_t)red;
612 uinc2 = (Int_t)green;
613 uinc3 = (Int_t)blue;
614 }
615 ui = uinc1+uinc2*256+uinc3*65536;
616 } else if (fColorAlg%2==1) {
618 a = ui*a;
619 a = ui1/2+a;
620 uinc1 = (Int_t)a;
621 uinc1 = uinc1%256;
623 b = ui*b;
624 b = ui2/2+b;
625 uinc2 = (Int_t)b;
626 uinc2 = uinc2%256;
628 c = ui*c;
629 c = ui3/2+c;
630 uinc3 = (Int_t)c;
631 uinc3 = uinc3%256;
633 uinc1 = 255-uinc1;
634 uinc2 = 255-uinc2;
635 uinc3 = 255-uinc3;
636 } else if (fColorAlg==kColorAlgCieModulo) {
637 a = uinc1;
638 b = uinc2;
639 c = uinc3;
640 d = a+b+c;
641 if (d!=0) {
642 a = a/d;
643 b = b/d;
644 c = c/d;
645 }
646 red = a*255;
647 green = b*255;
648 blue = c*255;
649 uinc1 = (Int_t)red;
650 uinc2 = (Int_t)green;
651 uinc3 = (Int_t)blue;
652 } else if (fColorAlg==kColorAlgYiqModulo) {
653 a = uinc1;
654 b = uinc2;
655 c = uinc3;
656 a = a/256;
657 b = b/256;
658 c = c/256;
659 red = a+0.956*b+0.62*c;
660 green = a-0.272*b-0.647*c;
661 blue = a-1.108*b+1.705*c;
662 if (red>=2) red = red-2;
663 else if (red>=1) red = red-1;
664 if (green<0) green = 1+green;
665 if (blue>=2) blue = blue-2;
666 else if (blue>=1) blue = blue-1;
667 else if (blue<-1) blue = 2+blue;
668 else if (blue<0) blue = 1+blue;
669 red = red*255;
670 green = green*255;
671 blue = blue*255;
672 uinc1 = (Int_t)red;
673 uinc2 = (Int_t)green;
674 uinc3 = (Int_t)blue;
675 } else if (fColorAlg==kColorAlgHvsModulo) {
676 h = uinc1;
677 v = uinc2;
678 s = uinc3;
679 h = h/256;
680 v = v/256;
681 s = s/256;
682 if (s==0) {
683 red = v;
684 green = v;
685 blue = v;
686 } else {
687 if (h==1.0) h = 0;
688 h = 6.0*h;
689 j = (Int_t)h;
690 f = h-j;
691 a = v*(1-s);
692 b = v*(1-s*f);
693 c = v*(1-s*(1-f));
694 switch (j) {
695 case 0:
696 red = v;
697 green = c;
698 blue = a;
699 break;
700 case 1:
701 red = b;
702 green = v;
703 blue = a;
704 break;
705 case 2:
706 red = a;
707 green = v;
708 blue = c;
709 break;
710 case 3:
711 red = a;
712 green = b;
713 blue = v;
714 break;
715 case 4:
716 red = c;
717 green = a;
718 blue = v;
719 break;
720 case 5:
721 red = v;
722 green = a;
723 blue = b;
724 break;
725 }
726 }
727 red = red*255;
728 green = green*255;
729 blue = blue*255;
730 uinc1 = (Int_t)red;
731 uinc2 = (Int_t)green;
732 uinc3 = (Int_t)blue;
733 }
734 ui = uinc1+uinc2*256+uinc3*65536;
735 }
736 red = uinc1;
737 green = uinc2;
738 blue = uinc3;
739 red = red/255.0;
740 green = green/255.0;
741 blue = blue/255.0;
742 fNewColor = new TColor(250+iv,red,green,blue);
743 fNewColorIndex = 250+iv;
744 return;
745}
746
747
748////////////////////////////////////////////////////////////////////////////////
749/// This function is called from BezierBlend function.
750
752{
753 Int_t j,a;
754 a = 1;
755 for (j=i+1;j<=3;j++) a = a*j;
756 for (j=1;j<=3-i;j++) a = a/j;
757 return a;
758}
759
760
761////////////////////////////////////////////////////////////////////////////////
762/// This function calculates Bezier approximation.
763
765{
766 Int_t j;
767 Double_t v;
768 v = BezC(i);
769 for (j=1;j<=i;j++) v = v*bezf;
770 for (j=1;j<=3-i;j++) v = v*(1-bezf);
771 return v;
772}
773
774
775////////////////////////////////////////////////////////////////////////////////
776/// Calculates screen coordinates of the smoothed point.
777/// Parameter bezf changes within the interval 0 to 1 in 0.1 steps.
778
780{
781 Int_t i;
782 Double_t b;
783 fGbezx = 0;
784 fGbezy = 0;
785 for (i=0;i<4;i++) {
786 b = BezierBlend(i,bezf);
787 fGbezx += fBzX[i]*b;
788 fGbezy += fBzY[i]*b;
789 }
790 return;
791}
792
793
794////////////////////////////////////////////////////////////////////////////////
795/// Ensures hidden surface removal.
796
798{
799 Int_t x,y,krok,xold=0,yold=0,prvy,yprv=0;
800 Double_t fx,fy,fx1,fy1;
801 if (y1<fBy1) y1 = fBy1;
802 if (y2<fBy1) y2 = fBy1;
803 if (x1==x2) {
804 if ((y1>=fEnvelope[x1]) && (y2>=fEnvelope[x1])) {
805 if (x1>0) {
806 if (y1<=fEnvelope[x1-1]||y2<=fEnvelope[x1-1]) {
807 if (y1>fEnvelope[x1-1]) y1 = fEnvelope[x1-1];
808 if (y2>fEnvelope[x1-1]) y2 = fEnvelope[x1-1];
809 fLine = 2;
810 fXs = x1;
811 fYs = y1;
812 fXe = x2;
813 fYe = y2;
814 return;
815 }
816 }
817 if (x1<fBx2) {
818 if (y1<=fEnvelope[x1+1]||y2<=fEnvelope[x1+1]) {
819 if (y1>fEnvelope[x1+1]) y1 = fEnvelope[x1+1];
820 if (y2>fEnvelope[x1+1]) y2 = fEnvelope[x1+1];
821 fLine = 2;
822 fXs = x1;
823 fYs = y1;
824 fXe = x2;
825 fYe = y2;
826 return;
827 }
828 }
829 fLine=0;
830 return;
831 }
832 if ((y1<fEnvelope[x1]) && (y2<fEnvelope[x1])) {
833 fLine = 2;
834 fXs = x1;
835 fYs = y1;
836 fXe = x2;
837 fYe = y2;
838 if (y1<y2) fEnvelope[x1] = y1;
839 else fEnvelope[x1] = y2;
840 return;
841 }
842 if (y1<y2) {
843 fLine = 2;
844 fXs = x1;
845 fYs = y1;
846 fXe = x1;
847 fYe = fEnvelope[x1];
848 fEnvelope[x1] = y1;
849 return;
850 } else {
851 fLine = 2;
852 fXs = x1;
853 fYs = y2;
854 fXe = x1;
855 fYe = fEnvelope[x1];
856 fEnvelope[x1] = y2;
857 return;
858 }
859 }
860 krok = (x1<x2)? 1:-1;
861 fLine = 0;
862 prvy = 0;
863 x = x1;
864 y = y1;
865l1:
866 if (y<=fEnvelope[x]) {
867 xold = x;
868 yold = y;
869 if (fLine==0) {
870 fLine = 1;
871 if (prvy==1) {
872 if (yprv<=fEnvelope[x]) fYs = yprv;
873 else fYs = fEnvelope[x];
874 fXs = x;
875 } else {
876 fXs = x;
877 fYs = y;
878 }
879 }
880 if (x!=x2) fEnvelope[x] = y;
881 } else {
882 prvy = 1;
883 yprv = y;
884 if (fLine==1) {
885 fLine = 2;
886 fXe = xold;
887 fYe = yold;
888 }
889 }
890 if (x1==x2) {
891 if (y1!=y2) y += (y1<y2)? +1:-1;
892 if (y!=y2) goto l1;
893 } else {
894 x += krok;
895 fy1 = y2-y1;
896 fx1 = x2-x1;
897 fx = x-x1;
898 fy = fy1*fx/fx1;
899 y = (Int_t)(y1+fy);
900 if (((x<=x2)&&(x1<x2)) || ((x>=x2)&&(x1>x2))) goto l1;
901 }
902 return;
903}
904
905
906////////////////////////////////////////////////////////////////////////////////
907/// Ensures hidden surface removal for Bars, BarsX and BarsY
908/// display modes.
909
911{
912 Int_t x,y,krok,xold=0,yold=0,prvy,xprv,yprv=0;
913 Double_t fx,fy,fx1,fy1;
914 if (x1==x2) {
915 if ((y1>=fEnvelope[x1]) && (y2>=fEnvelope[x1])) {
916 fLine = 0;
917 return;
918 }
919 if ((y1<fEnvelope[x1]) && (y2<fEnvelope[x1])) {
920 fLine = 2;
921 fXs = x1;
922 fYs = y1;
923 fXe = x2;
924 fYe = y2;
925 if (y1<y2) fEnvelope[x1] = y1;
926 else fEnvelope[x1] = y2;
927 return;
928 }
929 if (y1<y2) {
930 fLine = 2;
931 fXs = x1;
932 fYs = y1;
933 fXe = x1;
934 fYe = fEnvelope[x1];
935 fEnvelope[x1] = y1;
936 return;
937 } else {
938 fLine = 2;
939 fXs = x1;
940 fYs = y2;
941 fXe = x1;
942 fYe = fEnvelope[x1];
943 fEnvelope[x1] = y2;
944 return;
945 }
946 }
947 krok = (x1<x2)? 1:-1;
948 fLine = 0;
949 prvy = 0;
950 x = x1;
951 y = y1;
952l1:
953 if (y<=fEnvelope[x]) {
954 xold = x;
955 yold = y;
956 if (fLine==0) {
957 fLine = 1;
958 if (prvy==1) {
959 xprv = x;
960 fXs = xprv;
961 fYs = yprv;
962 } else {
963 fXs = x;
964 fYs = y;
965 }
966 }
967 if (x!=x2) fEnvelope[x] = y;
968 } else {
969 prvy = 1;
970 xprv = x;
971 yprv = y;
972 if (fLine==1) {
973 fLine = 2;
974 fXe = xold;
975 fYe = yold;
976 }
977 }
978 if (x1==x2) {
979 if (y1!=y2) y+=(y1<y2)? +1:-1;
980 if (y!=y2) goto l1;
981 } else {
982 x += krok;
983 fy1 = y2-y1;
984 fx1 = x2-x1;
985 fx = x-x1;
986 fy = fy1*fx/fx1;
987 y = (Int_t)(y1+fy);
988 if (((x<=x2)&&(x1<x2)) || ((x>=x2)&&(x1>x2))) goto l1;
989 }
990 return;
991}
992
993
994////////////////////////////////////////////////////////////////////////////////
995/// Draws channel mark at the screen coordinates x, y. Width of
996/// the mark is w, height is h and the type of the mark is determined by the
997/// parameter type.
998
1000{
1001 TLine *line=new TLine();
1002 TEllipse *ellipse=new TEllipse();
1004 line->SetLineWidth(1);
1006 ellipse->SetLineColor(fChanmarkColor);
1007 ellipse->SetLineWidth(1);
1008 ellipse->SetLineStyle(kPenStyleSolid);
1009 switch (type) {
1011 ellipse->SetX1(gPad->PixeltoX(x));
1012 ellipse->SetY1(gPad->PixeltoY(y)+1);
1013 ellipse->SetR1(gPad->PixeltoX(w/2));
1014 ellipse->SetR2(gPad->PixeltoY(h/2));
1015 ellipse->SetPhimin(0);
1016 ellipse->SetPhimax(360);
1017 ellipse->SetTheta(0);
1018 ellipse->Paint("");
1019 break;
1021 line->PaintLine(gPad->PixeltoX(x-w/2),gPad->PixeltoY(y)+1,
1022 gPad->PixeltoX(x+w/2),gPad->PixeltoY(y)+1);
1023 line->PaintLine(gPad->PixeltoX(x) ,gPad->PixeltoY(y-h/2)+1,
1024 gPad->PixeltoX(x) ,gPad->PixeltoY(y+h/2+1)+1);
1025 break;
1027 line->PaintLine(gPad->PixeltoX(x-w/2) ,gPad->PixeltoY(y)+1,
1028 gPad->PixeltoX(x+w/2+1),gPad->PixeltoY(y)+1);
1029 line->PaintLine(gPad->PixeltoX(x) ,gPad->PixeltoY(y-h/2)+1,
1030 gPad->PixeltoX(x) ,gPad->PixeltoY(y+h/2+1)+1);
1031 line->PaintLine(gPad->PixeltoX(x-w/2) ,gPad->PixeltoY(y-h/2)+1,
1032 gPad->PixeltoX(x+w/2+1),gPad->PixeltoY(y+h/2+1)+1);
1033 line->PaintLine(gPad->PixeltoX(x-w/2) ,gPad->PixeltoY(y+h/2)+1,
1034 gPad->PixeltoX(x+w/2+1),gPad->PixeltoY(y-h/2-1)+1);
1035 break;
1037 line->PaintLine(gPad->PixeltoX(x-w/2),gPad->PixeltoY(y-h/2)+1,
1038 gPad->PixeltoX(x-w/2),gPad->PixeltoY(y+h/2)+1);
1039 line->PaintLine(gPad->PixeltoX(x-w/2),gPad->PixeltoY(y+h/2)+1,
1040 gPad->PixeltoX(x+w/2),gPad->PixeltoY(y+h/2)+1);
1041 line->PaintLine(gPad->PixeltoX(x+w/2),gPad->PixeltoY(y+h/2)+1,
1042 gPad->PixeltoX(x+w/2),gPad->PixeltoY(y-h/2)+1);
1043 line->PaintLine(gPad->PixeltoX(x+w/2),gPad->PixeltoY(y-h/2)+1,
1044 gPad->PixeltoX(x-w/2),gPad->PixeltoY(y-h/2)+1);
1045 break;
1047 line->PaintLine(gPad->PixeltoX(x-w/2) ,gPad->PixeltoY(y-h/2)+1,
1048 gPad->PixeltoX(x+w/2+1),gPad->PixeltoY(y+h/2+1)+1);
1049 line->PaintLine(gPad->PixeltoX(x-w/2) ,gPad->PixeltoY(y+h/2)+1,
1050 gPad->PixeltoX(x+w/2+1),gPad->PixeltoY(y-h/2-1)+1);
1051 break;
1053 line->PaintLine(gPad->PixeltoX(x) ,gPad->PixeltoY(y-h/2)+1,
1054 gPad->PixeltoX(x-w/2),gPad->PixeltoY(y)+1);
1055 line->PaintLine(gPad->PixeltoX(x-w/2),gPad->PixeltoY(y)+1,
1056 gPad->PixeltoX(x) ,gPad->PixeltoY(y+h/2)+1);
1057 line->PaintLine(gPad->PixeltoX(x) ,gPad->PixeltoY(y+h/2)+1,
1058 gPad->PixeltoX(x+w/2),gPad->PixeltoY(y)+1);
1059 line->PaintLine(gPad->PixeltoX(x+w/2),gPad->PixeltoY(y)+1,
1060 gPad->PixeltoX(x) ,gPad->PixeltoY(y-h/2)+1);
1061 break;
1063 line->PaintLine(gPad->PixeltoX(x) ,gPad->PixeltoY(y-h/2)+1,
1064 gPad->PixeltoX(x-w/2),gPad->PixeltoY(y+h/2)+1);
1065 line->PaintLine(gPad->PixeltoX(x-w/2),gPad->PixeltoY(y+h/2)+1,
1066 gPad->PixeltoX(x+w/2),gPad->PixeltoY(y+h/2)+1);
1067 line->PaintLine(gPad->PixeltoX(x+w/2),gPad->PixeltoY(y+h/2)+1,
1068 gPad->PixeltoX(x) ,gPad->PixeltoY(y-h/2)+1);
1069 break;
1070 }
1071 delete line;
1072 delete ellipse;
1073 return;
1074}
1075
1076
1077////////////////////////////////////////////////////////////////////////////////
1078/// Calculates screen coordinates of the line given by two
1079/// nodes for contours display mode. The line is given by two points
1080/// xr, yr, xs, ys. Finally it draws the line.
1081
1083 Double_t ys, TLine *line)
1084{
1085 Int_t krok,xi,yi,xj,yj,a,b,as,bs,pr,ae,be;
1086 Double_t fx,fy,fx1,fy1;
1087 xi = (Int_t)(fTxx*(xr-fXmin)/fKx+fTxy*(yr-fYmin)/fKy+fVx);
1088 xj = (Int_t)(fTxx*(xs-fXmin)/fKx+fTxy*(ys-fYmin)/fKy+fVx);
1089 yi = (Int_t)(fTyx*(xr-fXmin)/fKx+fTyy*(yr-fYmin)/fKy+fTyz*fZ+fVy);
1090 yj = (Int_t)(fTyx*(xs-fXmin)/fKx+fTyy*(ys-fYmin)/fKy+fTyz*fZ+fVy);
1091 as = xi;
1092 bs = yi;
1093 ae = xj;
1094 be = yj;
1095 a = xi;
1096 b = yi;
1097 pr = 0;
1098 krok = (xi<xj)? 1:-1;
1099l1:
1100 if (b<=fEnvelope[a]) {
1101 fEnvelopeContour[a] = b;
1102 if (pr==0) {
1103 pr = 1;
1104 as = a;
1105 bs = b;
1106 }
1107 } else {
1108 if (pr==1) {
1109 pr = 2;
1110 ae = a;
1111 be = b;
1112 }
1113 }
1114 if (xi==xj) {
1115 if (yi!=yj) b += (yi<yj)? +1:-1;
1116 if (b!=yj) goto l1;
1117 } else {
1118 a += krok;
1119 fy1 = yj-yi;
1120 fx1 = xj-xi;
1121 fx = a-xi;
1122 fy = fy1*fx/fx1;
1123 b = (Int_t)(yi+fy);
1124 if (a!=xj) goto l1;
1125 }
1126 if (pr!=0) {
1127 if (pr==1) {
1128 ae = xj;
1129 be = yj;
1130 }
1131 line->PaintLine(gPad->PixeltoX(as),gPad->PixeltoY(bs)+1,
1132 gPad->PixeltoX(ae),gPad->PixeltoY(be)+1);
1133 }
1134 return;
1135}
1136
1137
1138////////////////////////////////////////////////////////////////////////////////
1139/// Copies envelope vector, which ensures hidden surface removal for the
1140/// contours display mode.
1141
1143 Double_t ys)
1144{
1145 Int_t xi,xj,a;
1146 xi = (Int_t)(fTxx*(xr-fXmin)/fKx+fTxy*(yr-fYmin)/fKy+fVx);
1147 xj = (Int_t)(fTxx*(xs-fXmin)/fKx+fTxy*(ys-fYmin)/fKy+fVx);
1148 if (xi<xj) {
1149 for (a=xi;a<=xj;a++) {
1153 }
1154 } else if (xj<xi) {
1155 for (a=xj;a<=xi;a++) {
1159 }
1160 }
1161 return;
1162}
1163
1164
1165////////////////////////////////////////////////////////////////////////////////
1166/// Paints histogram according to preset parameters.
1167/// ### Visualization
1168/// #### Goal: to present 2-dimensional spectra in suitable visual form
1169/// This package has several display mode groups and display modes, which can be
1170/// employed for the presentation of 2-dimensional histograms
1171/// #### Display modes groups:
1172///
1173/// - `kModeGroupSimple` - it covers simple display modes using one
1174/// color only
1175/// - `kModeGroupLight` - in this group the shading is carried out
1176/// according to the position of the fictive
1177/// light source
1178/// - `kModeGroupHeight` - in this group the shading is carried out
1179/// according to the channel contents
1180/// - `kModeGroupLightHeight` - combination of two previous shading
1181/// algorithms. One can control the weight
1182/// between both algorithms.
1183///
1184/// #### Display modes:
1185///
1186/// - `kDisplayModePoints, `
1187/// - `kDisplayModeGrid, `
1188/// - `kDisplayModeContours,`
1189/// - `kDisplayModeBars,`
1190/// - `kDisplayModeLinesX,`
1191/// - `kDisplayModeLinesY,`
1192/// - `kDisplayModeBarsX,`
1193/// - `kDisplayModeBarsY,`
1194/// - `kDisplayModeNeedles,`
1195/// - `kDisplayModeSurface,`
1196/// - `kDisplayModeTriangles.`
1197///
1198/// one can combine the above given modes groups and display modes. The meaningful
1199/// combinations (denoted by x) are given in the next table.
1200///
1201/// | | Simple | Light | Height | Light-Height |
1202/// |-----------|--------|-------|--------|--------------|
1203/// | Points | X | X | X | X |
1204/// | Grid | X | X | X | X |
1205/// | Contours | X | - | X | - |
1206/// | Bars | X | - | X | - |
1207/// | LinesX | X | X | X | X |
1208/// | LinesY | X | X | X | X |
1209/// | BarsX | X | - | X | - |
1210/// | BarsY | X | - | X | - |
1211/// | Needles | X | - | - | - |
1212/// | Surface | - | X | X | X |
1213/// | Triangles | X | X | X | X |
1214///
1215/// #### Function: void TSpectrum2Painter::SetDisplayMode (Int_t modeGroup, Int_t displayMode)
1216///
1217/// This function controls the display mode group and display mode of the
1218/// histogram drawing. To illustrate the possible effects of the various display
1219/// modes we introduce a set of examples. Default values:
1220///
1221/// - `modeGroup = kModeGroupLightHeight `
1222/// - `displayMode = kDisplayModeSurface `
1223///
1224/// \image html spectrumpainter001.jpg
1225///
1226/// Simple modes group, display mode = points, 256 x 256 channels.
1227/// \image html spectrumpainter002.jpg
1228///
1229/// Simple modes group, display mode = grid, 64 x 64 channels.
1230/// \image html spectrumpainter003.jpg
1231///
1232/// Simple modes group, display mode = contours, 64 x 64 channels.
1233/// \image html spectrumpainter004.jpg
1234///
1235/// Simple modes group, display mode = bars, 64 x 64 channels.
1236/// \image html spectrumpainter005.jpg
1237///
1238/// Simple modes group, display mode = linesX, 64 x 64 channels.
1239/// \image html spectrumpainter006.jpg
1240///
1241/// Simple modes group, display mode = linesY, 64 x 64 channels.
1242/// \image html spectrumpainter007.jpg
1243///
1244/// Simple modes group, display mode = barsX, 64 x 64 channels.
1245/// \image html spectrumpainter008.jpg
1246///
1247/// Simple modes group, display mode = barsY, 64 x 64 channels.
1248/// \image html spectrumpainter009.jpg
1249///
1250/// Simple modes group, display mode = needles, 64 x 64 channels.
1251/// \image html spectrumpainter010.jpg
1252///
1253/// Simple modes group, display mode = triangles, 64 x 64 channels.
1254/// \image html spectrumpainter011.jpg
1255///
1256/// Light modes group, display mode = points, 256 x 256 channels.
1257/// \image html spectrumpainter012.jpg
1258///
1259/// Light modes group, display mode = grid, 256 x 256 channels.
1260/// \image html spectrumpainter013.jpg
1261///
1262/// Light modes group, display mode = surface, 64 x 64 channels.
1263/// \image html spectrumpainter014.jpg
1264///
1265/// Light modes group, display mode = triangles, 64 x 64 channels.
1266/// \image html spectrumpainter015.jpg
1267///
1268/// Height modes group, display mode = points, 256 x 256 channels.
1269/// \image html spectrumpainter016.jpg
1270///
1271/// Height modes group, display mode = grid, 256 x 256 channels.
1272/// \image html spectrumpainter017.jpg
1273///
1274/// Height modes group, display mode = contours, 64 x 64 channels.
1275/// \image html spectrumpainter018.jpg
1276///
1277/// Height modes group, display mode = bars, 64 x 64 channels.
1278/// \image html spectrumpainter019.jpg
1279///
1280/// Height modes group, display mode = surface, 64 x 64 channels.
1281/// \image html spectrumpainter020.jpg
1282///
1283/// Height modes group, display mode = triangles, 64 x 64 channels.
1284/// \image html spectrumpainter021.jpg
1285///
1286/// Light - height modes group, display mode = surface, 64 x 64 channels. The weight
1287/// between both shading algorithms is set to 0.5. One can observe the influence of
1288/// both shadings.
1289///
1290/// #### Function: TSpectrum2Painter::SetPenAttr(Int_t color,Int_t style,Int_t width)
1291///
1292/// Using this function one can change pen color, pen style and pen width.
1293/// Possible pen styles are:
1294///
1295/// - ` kPenStyleSolid,`
1296/// - ` kPenStyleDash,`
1297/// - ` kPenStyleDot,`
1298/// - ` kPenStyleDashDot.`
1299///
1300/// Default values:
1301///
1302/// - ` color = kBlack`
1303/// - ` style = kPenStyleSolid`
1304/// - ` width = 1`
1305///
1306/// \image html spectrumpainter022.jpg
1307///
1308/// Simple modes group, display mode = linesX, 64 x 64 channels. Pen width = 3.
1309///
1310/// #### Function: TSpectrum2Painter::SetNodes(Int_t nodesx,Int_t nodesy)
1311///
1312/// Sometimes the displayed region is rather large. When displaying all channels
1313/// pictures become very dense and complicated. It is very difficult to understand
1314/// overall shape of the data. Therefore in the package we have implemented the
1315/// possibility to change the density of displayed channels. Only channels
1316/// coinciding with given nodes are displayed. In the next figure we introduce the
1317/// example of the above presented spectrum with number of nodes set to 64x64.
1318///
1319/// Default values:
1320///
1321/// - ` nodesx = Xmax-Xmin+1`
1322/// - ` nodesy = Ymax-Ymin+1`
1323///
1324/// \image html spectrumpainter023.jpg
1325///
1326/// Simple modes group, display mode = grid, 256 x 256 channels.
1327/// Number of nodes is 64x64.
1328///
1329/// #### Function: void TSpectrum2Painter::SetAngles (Int_t alpha,Int_t beta, Int_t view)
1330///
1331/// One can change the angles of the position of 3-d space and to rotate the
1332/// space. Alpha parameter defines the angle between bottom horizontal screen line
1333/// and the displayed space on the right side of the picture and beta on the left
1334/// side, respectively. One can rotate the 3-d space around vertical axis going
1335/// through the center of it employing the view parameter.
1336/// Allowed values are 0, 90, 180 and 270 degrees respectively.
1337///
1338/// Default values:
1339///
1340/// - ` alpha = 20`
1341/// - ` beta = 60`
1342/// - ` view = 0`
1343///
1344/// \image html spectrumpainter024.jpg
1345///
1346/// Light modes group, display mode = surface, 256 x 256 channels. Angles are
1347/// set as follows: alpha=40, beta=30, view=0.
1348/// \image html spectrumpainter025.jpg
1349///
1350/// Light modes group, display mode = surface, 256 x 256 channels. Angles are
1351/// set as follows: alpha=30, beta=30, view=90.
1352///
1353/// #### Function: TSpectrum2Painter::SetZScale(Int_t scale)
1354///
1355/// One can change the scale of z-axis. Possible values are:
1356///
1357/// - ` kZScaleLinear`
1358/// - ` kZScaleLog`
1359/// - ` kZScaleSqrt`
1360///
1361/// Default value is:
1362///
1363/// - ` scale = kZScaleLinear`
1364///
1365/// \image html spectrumpainter026.jpg
1366///
1367/// Height modes group, display mode = surface, 64 x 64 channels, log scale.
1368///
1369/// #### Function: TSpectrum2Painter::SetColorIncrements(Double_t r,Double_t g,Double_t b);
1370///
1371/// For sophisticated shading (in kModeGroupLight, kModeGroupHeight
1372/// and kModeGroupLightHeight display modes groups) the color palette starts
1373/// from the basic pen color (see SetPenAttr function). There is a predefined number
1374/// of color levels (256). Color in every level is calculated by adding the
1375/// increments of the r, g, b components to the previous level. Using this function
1376/// one can change the color increments between two neighbouring color levels. The
1377/// function does not apply for kModeGroupSimple display modes group.
1378/// Default values: r=1, g=1, b=1;
1379/// \image html spectrumpainter027.jpg
1380///
1381/// Light modes group, display mode = surface, 64 x 64 channels, color increments
1382/// r=1, g=2, b=3.
1383/// \image html spectrumpainter028.jpg
1384///
1385/// Light modes group, display mode = surface, 64 x 64 channels, color
1386/// increments r=4, g=2, b=1.
1387///
1388/// #### Function: TSpectrum2Painter::SetColorAlgorithm(Int_t colorAlgorithm)
1389///
1390/// To define the colors one can employ one of the following color algorithms
1391/// (rgb, cmy, cie, yiq, hvs models [1], [2]). When the level of a component
1392/// achieves the limit value one can choose either smooth transition (by decreasing
1393/// the limit value) or sharp - modulo transition (continuing with 0 value). This
1394/// makes possible to realize various visual effects. One can choose from the
1395/// following set of the algorithms:
1396///
1397/// - ` kColorAlgRgbSmooth `
1398/// - ` kColorAlgRgbModulo `
1399/// - ` kColorAlgCmySmooth `
1400/// - ` kColorAlgCmyModulo `
1401/// - ` kColorAlgCieSmooth `
1402/// - ` kColorAlgCieModulo `
1403/// - ` kColorAlgYiqSmooth `
1404/// - ` kColorAlgYiqModulo `
1405/// - ` kColorAlgHvsSmooth `
1406/// - ` kColorAlgHvsModulo `
1407///
1408/// The function does not apply for kModeGroupSimple display modes group.
1409/// Default value is:
1410///
1411/// - ` colorAlgorithm = kColorAlgRgbSmooth`
1412///
1413/// \image html spectrumpainter029.jpg
1414///
1415/// Light modes group, display mode = surface, 64 x 64 channels, color algorithm
1416/// is cmy smooth.
1417/// \image html spectrumpainter030.jpg
1418///
1419/// Light modes group, display mode = surface, 64 x 64 channels, color algorithm
1420/// is hvs smooth.
1421/// \image html spectrumpainter031.jpg
1422///
1423/// Light modes group, display mode = surface, 64 x 64 channels, color algorithm
1424/// is yiq smooth.
1425/// \image html spectrumpainter032.jpg
1426///
1427/// Light modes group, display mode = surface, 64 x 64 channels, color algorithm
1428/// is rgb modulo.
1429/// \image html spectrumpainter033.jpg
1430///
1431/// Height modes group, display mode = surface, 256 x 256 channels, color
1432/// algorithm is rgb modulo, increments r=5, g=5, b=5, angles alpha=0, beta=90,
1433/// view=0.
1434///
1435/// #### Function: TSpectrum2Painter::SetLightPosition(Int_t x, Int_t y, Int_t z)
1436///
1437/// In kModeGroupLight and kModeGroupLightHeight display modes
1438/// groups the color palette is calculated according to the fictive light source
1439/// position in 3-d space. Using this function one can change the position of the
1440/// source and thus to achieve various graphical effects. The function does not
1441/// apply for kModeGroupSimple and kModeGroupHeight display modes
1442/// groups. Default values are: x=1000, y=1000, z=1000.
1443/// \image html spectrumpainter034.jpg
1444///
1445/// Light modes group, display mode = surface, 64 x 64 channels. Position of the
1446/// light source was set to x=0, y=1000, z=1000.
1447///
1448/// #### Function: TSpectrum2Painter::SetShading(Int_t shading,Int_t shadow)
1449///
1450/// Surface of the picture is composed of triangles. If desired the edges of the
1451/// neighbouring triangles can be smoothed (shaded). If desired the display of the
1452/// shadow can be painted as well. The function does not apply for
1453/// kModeGroupSimple display modes group.
1454///
1455/// Possible values for shading are:
1456///
1457/// - ` kNotShaded`
1458/// - ` kShaded.`
1459///
1460/// Possible values for shadow are:
1461///
1462/// - ` kShadowsNotPainted`
1463/// - ` kShadowsPainted`
1464///
1465/// Default values:
1466///
1467/// - ` shading = kShaded`
1468/// - ` shadow = kShadowsNotPainted`
1469///
1470/// \image html spectrumpainter035.jpg
1471///
1472/// Light modes group, display mode = surface, 64 x 64 channels, not shaded.
1473/// \image html spectrumpainter036.jpg
1474///
1475/// Light modes group, display mode = surface, 64 x 64 channels, shaded, with
1476/// shadow.
1477///
1478/// #### Function: TSpectrum2Painter::SetBezier(Int_t bezier)
1479///
1480/// For kModeGroupSimple display modes group and for kDisplayModeGrid,
1481/// kDisplayModeLinesX >and kDisplayModeLinesY display modes one
1482/// can smooth data using Bezier smoothing algorithm. The function does not apply
1483/// for other display modes groups and display modes. Possible values are:
1484///
1485/// - ` kNoBezierInterpol`
1486/// - ` kBezierInterpol`
1487///
1488/// Default value is:
1489///
1490/// - ` bezier = kNoBezierInterpol.`
1491///
1492/// \image html spectrumpainter005.jpg
1493///
1494/// Simple modes group, display mode = linesX, 64 x 64 channels with Bezier
1495/// smoothing.
1496///
1497/// #### Function: TSpectrum2Painter::SetContourWidth(Int_t width)
1498///
1499/// This function applies only for kDisplayModeContours display mode.
1500/// One can change the width between horizontal slices and thus their density.
1501/// Default value: width=50.
1502/// \image html spectrumpainter037.jpg
1503///
1504/// Simple modes group, display mode = contours, 64 x 64 channels. Width between
1505/// slices was set to 30.
1506///
1507/// #### Function: TSpectrum2Painter::SetLightHeightWeight(Double_t weight)
1508///
1509/// For kModeGroupLightHeight display modes group one can change the
1510/// weight between both shading algorithm. The function does not apply for other
1511/// display modes groups. Default value is: weight=0.5.
1512/// \image html spectrumpainter038.jpg
1513///
1514/// Light - height modes group, display mode = surface, 64 x 64 channels.
1515/// The weight between both shading algorithms is set to 0.7.
1516///
1517/// #### Function: TSpectrum2Painter::SetChanMarks(Int_t enable,Int_t color,Int_t width,Int_t height,Int_t style)
1518/// In addition to the surface drawn using any above given algorithm one can display
1519/// channel marks. One can control the color as well as the width, height
1520/// (in pixels) and the style of the marks. The parameter enable can be set to:
1521///
1522/// - `kChannelMarksNotDrawn`
1523/// - `kChannelMarksDrawn.`
1524///
1525/// The possible styles can be chosen from the set:
1526///
1527/// - ` kChannelMarksStyleDot`
1528/// - ` kChannelMarksStyleCross`
1529/// - ` kChannelMarksStyleStar`
1530/// - ` kChannelMarksStyleRectangle`
1531/// - ` kChannelMarksStyleX`
1532/// - ` kChannelMarksStyleDiamond`
1533/// - ` kChannelMarksStyleTriangle.`
1534///
1535/// \image html spectrumpainter039.jpg
1536///
1537/// Light modes group, display mode = surface, 64 x 64 channels,
1538/// with marks (red circles).</p>
1539///
1540/// #### Function: TSpectrum2Painter::SetChanGrid(Int_t enable,Int_t color)
1541///
1542/// In addition to the surface drawn using any above given algorithm one can
1543/// display grid using the color parameter. The parameter enable can be set to:
1544///
1545/// - ` kChannelGridNotDrawn`
1546/// - ` kChannelGridDrawn.`
1547///
1548/// \image html spectrumpainter040.jpg
1549///
1550/// Height modes group, display mode = surface, 64 x 64 channels, with blue grid.
1551/// \image html spectrumpainter041.jpg
1552///
1553/// Height modes group, display mode = surface, 64 x 64 channels, with marks
1554/// (red circles) and blue grid.
1555/// #### References:
1556///
1557/// [1] Morhac M., Kliman J., Matouoek V., Turzo I.,
1558/// Sophisticated visualization algorithms for analysis of multidimensional
1559/// experimental nuclear data, Acta Physica Slovaca 54 (2004) 385.
1560///
1561/// [2] D. Hearn, M. P. Baker: Computer Graphics, Prentice Hall International,
1562/// Inc. 1994.
1563/// #### Script:
1564///
1565/// Example to draw source spectrum (class TSpectrum2Painter).
1566/// To execute this example, do:
1567/// ~~~
1568/// root > .x VisA.C
1569/// ~~~
1570/// ~~~ {.cpp}
1571/// #include "TSpectrum2Painter.h"
1572///
1573/// void VisA() {
1574/// TFile *f = new TFile("TSpectrum2.root");
1575/// TH2F *graph=(TH2F*) f->Get("graph2;1");
1576/// TCanvas *Graph2 = new TCanvas("Graph2","Illustration of 2D graphics",10,10,1000,700);
1577/// graph->Draw("SPEC");
1578/// }
1579/// ~~~
1580
1582{
1583
1584
1585 Int_t turni,turnj,w1,w2,x,y;
1586 Int_t q1=0,q2=0,qv=0,smer=0,flag=0,i=0,j=0,x1=0,y1=0,x2=0,y2=0,x3=0,y3=0,x4=0,y4=0,uhl=0,xp1=0,yp1=0,xp2=0,yp2=0;
1587 Int_t ix5,iy5,x6,y6,x7,y7,y8,x1d,y1d,x2d=0,y2d=0;
1588 Int_t i1=0,i2=0,i3=0,i4=0,j1=0,j2=0,j3=0,j4=0;
1589 Int_t s1=0,s2=0,s3=0,s4=0,t1=0,t2=0,t3=0,t4=0;
1590 Double_t dx1,dx2,dx3,dx4,dy1,dy2,dy3,dy4,z1,z2,z3,z4,zl,zh;
1591 Double_t xa,xb=0,ya,yb=0,x5=0,y5=0;
1592 Double_t da=0,db=0,dc=0,dd=0,xtaz,ytaz,ztaz,v,shad_noise;
1593 Int_t iv=0,ekv,stvor,sx1,sx2,sx3,sx4,sx5,sy1,sy2,sy3,sy4,sy5;
1594 Double_t pom1,pom2,sdx1,sdy1,sdx2=0,sdy2,sdx3,sdy3,sdy4,spriz;
1595 Int_t sr1=0,sr2=0,sr3=0,sr4=0,sr5=0,sr6=0,sr7=0,sr8=0;
1596 Int_t tr1=0,tr2=0,tr3=0,tr4=0,tr5=0,tr6=0,tr7=0,tr8=0;
1597 Int_t il,iv1=0,iv2=0,iv3=0,iv4=0;
1598 Double_t v1=0,v2=0,v3=0,v4=0,dxr1,dxr2,dyr1,dyr2,zr1,zr2,bezf;
1599 Double_t dcount_reg,z1l,z2l,z3l,z4l,sdx2p,sdy2p,dap,dbp,dcp,ddp;
1600 Int_t sx1p,sy1p,sx3p,uip=0;
1601 Double_t bezx1,bezy1,bezx2,bezy2;
1602 Double_t p000x,p000y,p100x,p100y,p010x,p010y,p110x,p110y;
1603 Double_t p001x,p001y,p101x,p101y,p011x,p011y,p111x,p111y;
1604 Int_t ibezx1=0,ibezy1=0,ibezx2,ibezy2;
1605 unsigned ui1,ui2,ui3;
1606 Double_t fi,alfa,beta,x3max,y3max,mul,movx,movy;
1607 Double_t xmin,xmax,ymin,ymax,zmin,zmax,mx,my,mz;
1608 Double_t mxx,mxy,myx,myy,myz,px,py,kx,ky;
1609 Double_t bxl,bxh,byl,byh,xd,yd,a,b,rotx,roty;
1610 TLine *line = new TLine();
1611 TBox *box = new TBox();
1612 TColor *pen_col;
1613 pen_col = (TColor*)(gROOT->GetListOfColors()->At(fPenColor));
1614 ui1 = (Int_t)(256*pen_col->GetRed());
1615 ui2 = (Int_t)(256*pen_col->GetGreen());
1616 ui3 = (Int_t)(256*pen_col->GetBlue());
1617
1619 printf("The canvas size exceed the maximum X screen resolution.\n");
1620 printf("Use the option bf() to increase the buffer size (it should be greater than %d).\n",fBx2);
1621 return;
1622 }
1623
1624 for (i=fBx1;i<fBx2;i++) {
1625 fEnvelope[i] = fBy2;
1627 }
1628
1629// gPad->Range(0, 0, 1 ,1);
1630
1631 // Set the histogram's parameters.
1632 fBx1 = gPad->XtoPixel(0.1);
1633 fBx2 = gPad->XtoPixel(0.99);
1634 fBy1 = gPad->YtoPixel(0.99);
1635 fBy2 = gPad->YtoPixel(0.05);
1636 fXmin = fH2->GetXaxis()->GetFirst();
1637 fXmax = fH2->GetXaxis()->GetLast();
1638 fYmin = fH2->GetYaxis()->GetFirst();
1639 fYmax = fH2->GetYaxis()->GetLast();
1640 fZmax = fH2->GetMaximum();
1641 fZmin = fH2->GetMinimum();
1642
1643 // Calculation of display parameters.
1644 xmin = fXmin;
1645 xmax = fXmax;
1646 ymin = fYmin;
1647 ymax = fYmax;
1648 zmin = fZmin;
1649 zmax = fZmax;
1650 xd = (xmax-xmin)/2;
1651 yd = (ymax-ymin)/2;
1652 a = (xmax+xmin)/2;
1653 b = (ymax+ymin)/2;
1654 fi = (fViewAngle*3.1415927)/180;
1655 alfa = (fAlpha*3.1415927)/180;
1656 beta = (fBeta*3.1415927)/180;
1657 rotx = (-1)*a*cos(fi)+b*sin(fi)+xd*TMath::Abs(cos(fi))+yd*TMath::Abs(sin(fi));
1658 roty = (-1)*a*sin(fi)-b*cos(fi)+xd*TMath::Abs(sin(fi))+yd*TMath::Abs(cos(fi));
1659 x3max = (xmax-xmin)*TMath::Abs(cos(fi))+(ymax-ymin)*TMath::Abs(sin(fi));
1660 y3max = (xmax-xmin)*TMath::Abs(sin(fi))+(ymax-ymin)*TMath::Abs(cos(fi));
1661 bxl = fBx1;
1662 bxh = fBx2;
1663 byl = fBy1;
1664 byh = fBy2;
1665 mx = (bxh-bxl)/(x3max*(cos(alfa)+cos(beta)));
1666 my = (bxh-bxl)/(y3max*(cos(alfa)+cos(beta)));
1667 mul = (byh-byl)/(bxh-bxl);
1668 movx = bxl+my*cos(alfa)*y3max;
1669 mxx = mx*cos(beta)*cos(fi)-my*cos(alfa)*sin(fi);
1670 mxy = (-1)*mx*cos(beta)*sin(fi)-my*cos(alfa)*cos(fi);
1671 myx = mul*(mx*sin(beta)*cos(fi)+my*sin(alfa)*sin(fi));
1672 myy = mul*((-1)*mx*sin(beta)*sin(fi)+my*sin(alfa)*cos(fi));
1673 px = rotx*mx*cos(beta)-roty*my*cos(alfa)+movx;
1674 kx = (xmax-xmin)/(fNodesx-1);
1675 ky = (ymax-ymin)/(fNodesy-1);
1676 fKx = kx;
1677 fKy = ky;
1678 fMxx = mxx;
1679 fMxy = mxy;
1680 fMyx = myx;
1681 fMyy = myy;
1682 fTxx = mxx*kx;
1683 fTxy = mxy*ky;
1684 fTyx = myx*kx;
1685 fTyy = myy*ky;
1686 fVx = mxx*xmin+mxy*ymin+px;
1687 if (fZscale==kZScaleLinear) {
1688 mz = (bxh-bxl)*(cos(alfa)+cos(beta)-sin(alfa)-sin(beta));
1689 mz = mz/((zmax-zmin)*(cos(alfa)+cos(beta)));
1690 movy = byl+mul*mz*zmax;
1691 myz = (-1)*mz*mul;
1692 py = mul*(rotx*mx*sin(beta)+roty*my*sin(alfa))+movy;
1693 fTyz = myz;
1694 fVy = myx*xmin+myy*ymin+py;
1695 fNuSli = (zmax-zmin)/(Double_t)fContWidth;
1696 } else if (fZscale==kZScaleLog) {
1697 if (zmin>=1) zmin = log(zmin);
1698 else zmin = 0;
1699 if (zmax>=1) zmax = log(zmax);
1700 else zmax = 0;
1701 if ((zmax-zmin)<0.000001) zmax = zmin+0.000001;
1702 mz = (bxh-bxl)*(cos(alfa)+cos(beta)-sin(alfa)-sin(beta));
1703 mz = mz/((zmax-zmin)*(cos(alfa)+cos(beta)));
1704 movy = byl+mul*mz*zmax;
1705 myz = (-1)*mz*mul;
1706 py = mul*(rotx*mx*sin(beta)+roty*my*sin(alfa))+movy;
1707 fTyz = myz;
1708 fVy = myx*xmin+myy*ymin+py;
1709 fNuSli = (zmax-zmin)/(Double_t)fContWidth;
1710 } else if (fZscale==kZScaleSqrt) {
1711 if (zmin>=1) zmin = sqrt(zmin);
1712 else zmin = 0;
1713 if (zmax>=1) zmax = sqrt(zmax);
1714 else zmax = 0;
1715 if ((zmax-zmin)<0.000001) zmax = zmin+0.000001;
1716 mz = (bxh-bxl)*(cos(alfa)+cos(beta)-sin(alfa)-sin(beta));
1717 mz = mz/((zmax-zmin)*(cos(alfa)+cos(beta)));
1718 movy = byl+mul*mz*zmax;
1719 myz = (-1)*mz*mul;
1720 py = mul*(rotx*mx*sin(beta)+roty*my*sin(alfa))+movy;
1721 fTyz = myz;
1722 fVy = myx*xmin+myy*ymin+py;
1723 fNuSli = (zmax-zmin)/(Double_t)fContWidth;
1724 }
1725
1726 // End of calculations of display parameters.
1727 dcount_reg=fContWidth;
1728 switch (fZscale) {
1729 case kZScaleLog:
1730 dcount_reg=log(dcount_reg);
1731 break;
1732 case kZScaleSqrt:
1733 dcount_reg=sqrt(dcount_reg);
1734 break;
1735 }
1736 shad_noise = fZmax;
1737 shad_noise /= 100.;
1738 w1 = fNodesx-1;
1739 w2 = fNodesy-1;
1740
1741 // Drawing axis in backplanes.
1742 Transform(0,0,-1);
1743 p000x = gPad->PixeltoX(fXt);
1744 p000y = gPad->PixeltoY(fYt)+1;
1745 Transform(w1,0,-1);
1746 p100x = gPad->PixeltoX(fXt);
1747 p100y = gPad->PixeltoY(fYt)+1;
1748 Transform(0,w2,-1);
1749 p010x = gPad->PixeltoX(fXt);
1750 p010y = gPad->PixeltoY(fYt)+1;
1751 Transform(w1,w2,-1);
1752 p110x = gPad->PixeltoX(fXt);
1753 p110y = gPad->PixeltoY(fYt)+1;
1755 Transform(0,0,-2);
1756 p001x = gPad->PixeltoX(fXt);
1757 p001y = gPad->PixeltoY(fYt)+1;
1758 Transform(w1,0,-2);
1759 p101x = gPad->PixeltoX(fXt);
1760 p101y = gPad->PixeltoY(fYt)+1;
1761 Transform(0,w2,-2);
1762 p011x = gPad->PixeltoX(fXt);
1763 p011y = gPad->PixeltoY(fYt)+1;
1764 Transform(w1,w2,-2);
1765 p111x = gPad->PixeltoX(fXt);
1766 p111y = gPad->PixeltoY(fYt)+1;
1767 Double_t bmin, bmax, binLow, binHigh, binWidth;
1768 Double_t axisLevel, gridDist, gridY1, gridY2;
1769 Int_t ndivx = 0, ndivy, ndivz, nbins;
1770 TGaxis *axis = new TGaxis();
1771 TGaxis *xaxis = new TGaxis();
1772 TGaxis *yaxis = new TGaxis();
1773 TGaxis *zaxis = new TGaxis();
1775 if (fViewAngle==0) {
1776 axis->PaintAxis(p000x, p000y, p100x, p100y, bmin, bmax, ndivx, "");
1777 axis->PaintAxis(p000x, p000y, p010x, p010y, bmin, bmax, ndivx, "");
1778 if(fAlpha+fBeta<90)
1779 axis->PaintAxis(p000x, p000y, p001x, p001y, bmin, bmax, ndivx, "");
1780 if(fAlpha+fBeta<90)
1781 axis->PaintAxis(p100x, p100y, p101x, p101y, bmin, bmax, ndivx, "");
1782 axis->PaintAxis(p101x, p101y, p001x, p001y, bmin, bmax, ndivx, "");
1783 axis->PaintAxis(p001x, p001y, p011x, p011y, bmin, bmax, ndivx, "");
1784 if (fZscale==kZScaleLinear) {
1785 bmin = fZmin;
1786 bmax = fZmax;
1787 ndivz = 10;
1788 THLimitsFinder::Optimize(bmin, bmax, ndivz, binLow, binHigh,
1789 nbins, binWidth, " ");
1790 for (i = 0; i < nbins + 1; i++) {
1791 axisLevel = binLow+i*binWidth;
1792 gridDist = (axisLevel-bmin)*(p001y-p000y)/(bmax-bmin);
1793 gridY1 = p000y + gridDist, gridY2 = p100y + gridDist;
1794 line->PaintLine(p000x,gridY1,p100x,gridY2);
1795 gridY2 = p010y + gridDist;
1796 line->PaintLine(p000x,gridY1,p010x,gridY2);
1797 }
1798 }
1799 } else if (fViewAngle==90) {
1800 axis->PaintAxis(p010x, p010y, p000x, p000y, bmin, bmax, ndivx, "");
1801 axis->PaintAxis(p010x, p010y, p110x, p110y, bmin, bmax, ndivx, "");
1802 if(fAlpha+fBeta<90)
1803 axis->PaintAxis(p010x, p010y, p011x, p011y, bmin, bmax, ndivx, "");
1804 if(fAlpha+fBeta<90)
1805 axis->PaintAxis(p000x, p000y, p001x, p001y, bmin, bmax, ndivx, "");
1806 axis->PaintAxis(p001x, p001y, p011x, p011y, bmin, bmax, ndivx, "");
1807 axis->PaintAxis(p011x, p011y, p111x, p111y, bmin, bmax, ndivx, "");
1808 if (fZscale==kZScaleLinear) {
1809 bmin = fZmin;
1810 bmax = fZmax;
1811 ndivz = 10;
1812 THLimitsFinder::Optimize(bmin, bmax, ndivz, binLow, binHigh,
1813 nbins, binWidth, " ");
1814 for (i = 0; i < nbins + 1; i++) {
1815 axisLevel = binLow+i*binWidth;
1816 gridDist = (axisLevel-bmin)*(p011y-p010y)/(bmax-bmin);
1817 gridY1 = p010y + gridDist, gridY2 = p000y + gridDist;
1818 line->PaintLine(p010x,gridY1,p000x,gridY2);
1819 gridY2 = p110y + gridDist;
1820 line->PaintLine(p010x,gridY1,p110x,gridY2);
1821 }
1822 }
1823 } else if (fViewAngle==180) {
1824 axis->PaintAxis(p110x, p110y, p010x, p010y, bmin, bmax, ndivx, "");
1825 axis->PaintAxis(p110x, p110y, p100x, p100y, bmin, bmax, ndivx, "");
1826 if(fAlpha+fBeta<90)
1827 axis->PaintAxis(p110x, p110y, p111x, p111y, bmin, bmax, ndivx, "");
1828 if(fAlpha+fBeta<90)
1829 axis->PaintAxis(p010x, p010y, p011x, p011y, bmin, bmax, ndivx, "");
1830 axis->PaintAxis(p011x, p011y, p111x, p111y, bmin, bmax, ndivx, "");
1831 axis->PaintAxis(p111x, p111y, p101x, p101y, bmin, bmax, ndivx, "");
1832 if (fZscale==kZScaleLinear) {
1833 bmin = fZmin;
1834 bmax = fZmax;
1835 ndivz = 10;
1836 THLimitsFinder::Optimize(bmin, bmax, ndivz, binLow, binHigh,
1837 nbins, binWidth, " ");
1838 for (i = 0; i < nbins + 1; i++) {
1839 axisLevel = binLow+i*binWidth;
1840 gridDist = (axisLevel-bmin)*(p111y-p110y)/(bmax-bmin);
1841 gridY1 = p110y + gridDist, gridY2 = p010y + gridDist;
1842 line->PaintLine(p110x,gridY1,p010x,gridY2);
1843 gridY2 = p100y + gridDist;
1844 line->PaintLine(p110x,gridY1,p100x,gridY2);
1845 }
1846 }
1847 } else if (fViewAngle==270) {
1848 axis->PaintAxis(p100x, p100y, p110x, p110y, bmin, bmax, ndivx, "");
1849 axis->PaintAxis(p100x, p100y, p000x, p000y, bmin, bmax, ndivx, "");
1850 if(fAlpha+fBeta<90)
1851 axis->PaintAxis(p100x, p100y, p101x, p101y, bmin, bmax, ndivx, "");
1852 if(fAlpha+fBeta<90)
1853 axis->PaintAxis(p110x, p110y, p111x, p111y, bmin, bmax, ndivx, "");
1854 axis->PaintAxis(p111x, p111y, p101x, p101y, bmin, bmax, ndivx, "");
1855 axis->PaintAxis(p101x, p101y, p001x, p001y, bmin, bmax, ndivx, "");
1856 if (fZscale==kZScaleLinear) {
1857 bmin = fZmin;
1858 bmax = fZmax;
1859 ndivz = 10;
1860 THLimitsFinder::Optimize(bmin, bmax, ndivz, binLow, binHigh,
1861 nbins, binWidth, " ");
1862 for (i = 0; i < nbins + 1; i++) {
1863 axisLevel = binLow+i*binWidth;
1864 gridDist = (axisLevel-bmin)*(p101y-p100y)/(bmax-bmin);
1865 gridY1 = p100y + gridDist, gridY2 = p110y + gridDist;
1866 line->PaintLine(p100x,gridY1,p110x,gridY2);
1867 gridY2 = p000y + gridDist;
1868 line->PaintLine(p100x,gridY1,p000x,gridY2);
1869 }
1870 }
1871 }
1872
1873 // End.
1874 line->ResetAttLine("");
1878 turni = 0;
1879 turnj = 0;
1880 Transform(w1,0,0);
1881 x1 = fXt;
1882 Transform(0,0,0);
1883 x2 = fXt;
1884 Transform(0,w2,0);
1885 x3 = fXt;
1886 if (x2>=x1) turnj = 1;
1887 if (x3>=x2) turni = 1;
1888 q1 = 1;
1889 q2 = 0;
1890 qv = 1;
1891 do {
1892 uhl = 0;
1893 smer = 0;
1894 flag = 0;
1895l2:
1896 if (turni==1) {
1897 i = q1;
1898 } else {
1899 i = w1-q1;
1900 }
1901 if (turnj==1) {
1902 j = q2;
1903 } else {
1904 j = w2-q2;
1905 }
1906 Transform(i,j,0);
1907 x1 = fXt;
1908 y1 = fYt;
1909 Transform(i,j,-1);
1910 x1d = fXt;
1911 y1d = fYt;
1912 do {
1913 if (flag==0) {
1914 flag = 1;
1915 if (smer==0) q1 -= 1;
1916 else q2 -= 1;
1917 } else {
1918 flag = 0;
1919 if (smer==0) q2 += 1;
1920 else q1 += 1;
1921 }
1922 if (turni==1) {
1923 i = q1;
1924 } else {
1925 i = w1-q1;
1926 }
1927 if (turnj==1) {
1928 j = q2;
1929 } else {
1930 j = w2-q2;
1931 }
1932 Transform(i,j,0);
1933 x2 = fXt;
1934 y2 = fYt;
1935 if (flag==1) {
1936 x = x1;
1937 y = y1;
1938 x1 = x2;
1939 y1 = y2;
1940 x2 = x;
1941 y2 = y;
1942 }
1943 switch (fDisplayMode) {
1944 case kDisplayModePoints:
1946 Envelope(x1,y1,x2,y2);
1947 if (y1<=fEnvelope[x1]) {
1948 line->PaintLine(gPad->PixeltoX(x1) ,gPad->PixeltoY(y1)+1,
1949 gPad->PixeltoX(x1+1),gPad->PixeltoY(y1)+1);
1950 }
1951 if (y2<=fEnvelope[x2]) {
1952 line->PaintLine(gPad->PixeltoX(x2) ,gPad->PixeltoY(y2)+1,
1953 gPad->PixeltoX(x2+1),gPad->PixeltoY(y2)+1);
1954 }
1955 } else {
1956 if ((q1!=q2||smer!=0) && flag==1) {
1957 s1 = q1+1;
1958 t1 = q2;
1959 s2 = q1;
1960 t2 = q2;
1961 s3 = q1;
1962 t3 = q2+1;
1963 s4 = q1+1;
1964 t4 = q2+1;
1965 if (fShading==kShaded) {
1966 sr1 = s1;
1967 tr1 = (Int_t)TMath::Max(t1-1,0);
1968 sr2 = s2;
1969 tr2 = (Int_t)TMath::Max(t2-1,0);
1970 sr3 = (Int_t)TMath::Max(s2-1,0);
1971 tr3 = t2;
1972 sr4 = (Int_t)TMath::Max(s3-1,0);
1973 tr4 = t3;
1974 sr5 = s3;
1975 tr5 = t3+1;
1976 sr6 = s4;
1977 tr6 = t4+1;
1978 sr7 = s4+1;
1979 tr7 = t4;
1980 sr8 = s1+1;
1981 tr8 = t1;
1982 }
1983 if (turni==1) {
1984 i1 = s1;
1985 i2 = s2;
1986 i3 = s3;
1987 i4 = s4;
1988 } else {
1989 i1 = (Int_t)TMath::Max(w1-s1,0);
1990 i2 = (Int_t)TMath::Max(w1-s2,0);
1991 i3 = (Int_t)TMath::Max(w1-s3,0);
1992 i4 = (Int_t)TMath::Max(w1-s4,0);
1993 if (fShading==kShaded) {
1994 sr1 = (Int_t)TMath::Max(w1-sr1,0);
1995 sr2 = (Int_t)TMath::Max(w1-sr2,0);
1996 sr3 = (Int_t)TMath::Max(w1-sr3,0);
1997 sr4 = (Int_t)TMath::Max(w1-sr4,0);
1998 sr5 = (Int_t)TMath::Max(w1-sr5,0);
1999 sr6 = (Int_t)TMath::Max(w1-sr6,0);
2000 sr7 = (Int_t)TMath::Max(w1-sr7,0);
2001 sr8 = (Int_t)TMath::Max(w1-sr8,0);
2002 }
2003 }
2004 if (turnj==1) {
2005 j1 = t1;
2006 j2 = t2;
2007 j3 = t3;
2008 j4 = t4;
2009 } else {
2010 j1 = (Int_t)TMath::Max(w2-t1,0);
2011 j2 = (Int_t)TMath::Max(w2-t2,0);
2012 j3 = (Int_t)TMath::Max(w2-t3,0);
2013 j4 = (Int_t)TMath::Max(w2-t4,0);
2014 if (fShading==kShaded) {
2015 tr1 = (Int_t)TMath::Max(w2-tr1,0);
2016 tr2 = (Int_t)TMath::Max(w2-tr2,0);
2017 tr3 = (Int_t)TMath::Max(w2-tr3,0);
2018 tr4 = (Int_t)TMath::Max(w2-tr4,0);
2019 tr5 = (Int_t)TMath::Max(w2-tr5,0);
2020 tr6 = (Int_t)TMath::Max(w2-tr6,0);
2021 tr7 = (Int_t)TMath::Max(w2-tr7,0);
2022 tr8 = (Int_t)TMath::Max(w2-tr8,0);
2023 }
2024 }
2025 Transform(i1,j1,0);
2026 x1 = fXt;
2027 y1 = fYt;
2028 dx1 = fDxspline;
2029 dy1 = fDyspline;
2030 z1 = fZ;
2031 Transform(i2,j2,0);
2032 x2 = fXt;
2033 y2 = fYt;
2034 dx2 = fDxspline;
2035 dy2 = fDyspline;
2036 z2 = fZ;
2037 Transform(i3,j3,0);
2038 x3 = fXt;
2039 y3 = fYt;
2040 dx3 = fDxspline;
2041 dy3 = fDyspline;
2042 z3 = fZ;
2043 Transform(i4,j4,0);
2044 x4 = fXt;
2045 y4 = fYt;
2046 dx4 = fDxspline;
2047 dy4 = fDyspline;
2048 z4 = fZ;
2049 Envelope(x1,y1,x2,y2);
2050 Envelope(x2,y2,x3,y3);
2051 xtaz = (dx1+dx2+dx4)/3;
2052 ytaz = (dy1+dy2+dy4)/3;
2053 ztaz = (z1+z2+z4)/3;
2054 v = ColorCalculation(dx1,dy1,z1,dx2,dy2,z2,dx4,dy4,z4);
2055 if (fShading==kShaded) {
2057 if (sr1<0||sr1>w1||tr1<0||tr1>w2) Transform(sr1,tr1,-1);
2058 else Transform(sr1,tr1,0);
2059 dxr1 = fDxspline;
2060 dyr1 = fDyspline;
2061 zr1 = fZ;
2062 if (sr8<0||sr8>w1||tr8<0||tr8>w2) Transform(sr8,tr8,-1);
2063 else Transform(sr8,tr8,0);
2064 dxr2 = fDxspline;
2065 dyr2 = fDyspline;
2066 zr2 = fZ;
2067 v = v+ColorCalculation(dxr1,dyr1,zr1,dx2,dy2,z2,dx1,dy1,z1);
2068 v = v+ColorCalculation(dxr1,dyr1,zr1,dx1,dy1,z1,dxr2,dyr2,zr2);
2069 v = v+ColorCalculation(dxr2,dyr2,zr2,dx1,dy1,z1,dx4,dy4,z4);
2070 v1 = v/4;
2071 if (sr3<0||sr3>w1||tr3<0||tr3>w2) Transform(sr3,tr3,-1);
2072 else Transform(sr3,tr3,0);
2073 dxr1 = fDxspline;
2074 dyr1 = fDyspline;
2075 zr1 = fZ;
2076 if (sr2<0||sr2>w1||tr2<0||tr2>w2) Transform(sr2,tr2,-1);
2077 else Transform(sr2,tr2,0);
2078 dxr2 = fDxspline;
2079 dyr2 = fDyspline;
2080 zr2 = fZ;
2081 v = ColorCalculation(dx1,dy1,z1,dx2,dy2,z2,dx3,dy3,z3);
2082 v = v+ColorCalculation(dx2,dy2,z2,dxr1,dyr1,zr1,dx3,dy3,z3);
2083 v = v+ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dxr1,dyr1,zr1);
2084 v = v+ColorCalculation(dxr2,dyr2,zr2,dx2,dy2,z2,dx1,dy1,z1);
2085 v2 = v/4;
2086 if (sr5<0||sr5>w1||tr5<0||tr5>w2) Transform(sr5,tr5,-1);
2087 else Transform(sr5,tr5,0);
2088 dxr1 = fDxspline;
2089 dyr1 = fDyspline;
2090 zr1 = fZ;
2091 if (sr4<0||sr4>w1||tr4<0||tr4>w2) Transform(sr4,tr4,-1);
2092 else Transform(sr4,tr4,0);
2093 dxr2 = fDxspline;
2094 dyr2 = fDyspline;
2095 zr2 = fZ;
2096 v = ColorCalculation(dx2,dy2,z2,dx3,dy3,z3,dx4,dy4,z4);
2097 v = v+ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr1,dyr1,zr1);
2098 v = v+ColorCalculation(dx3,dy3,z3,dxr2,dyr2,zr2,dxr1,dyr1,zr1);
2099 v = v+ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dx3,dy3,z3);
2100 v3 = v/4;
2101 if (sr7<0||sr7>w1||tr7<0||tr7>w2) Transform(sr7,tr7,-1);
2102 else Transform(sr7,tr7,0);
2103 dxr1 = fDxspline;
2104 dyr1 = fDyspline;
2105 zr1 = fZ;
2106 if (sr6<0||sr6>w1||tr6<0||tr6>w2) Transform(sr6,tr6,-1);
2107 else Transform(sr6,tr6,0);
2108 dxr2 = fDxspline;
2109 dyr2 = fDyspline;
2110 zr2 = fZ;
2111 v = ColorCalculation(dx1,dy1,z1,dx3,dy3,z3,dx4,dy4,z4);
2112 v = v+ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr2,dyr2,zr2);
2113 v = v+ColorCalculation(dx4,dy4,z4,dxr2,dyr2,zr2,dxr1,dyr1,zr1);
2114 v = v+ColorCalculation(dx1,dy1,z1,dx4,dy4,z4,dxr1,dyr1,zr1);
2115 v4 = v/4;
2116 } else {
2117 spriz = ShadowColorCalculation(xtaz,ytaz,ztaz,shad_noise);
2118 v = v+spriz;
2119 v = v/2;
2120 if (sr1<0||sr1>w1||tr1<0||tr1>w2) Transform(sr1,tr1,-1);
2121 else Transform(sr1,tr1,0);
2122 dxr1 = fDxspline;
2123 dyr1 = fDyspline;
2124 zr1 = fZ;
2125 if (sr8<0||sr8>w1||tr8<0||tr8>w2) Transform(sr8,tr8,-1);
2126 else Transform(sr8,tr8,0);
2127 dxr2 = fDxspline;
2128 dyr2 = fDyspline;
2129 zr2 = fZ;
2130 da = (dxr1+dx2+dx1)/3;
2131 db = (dyr1+dy2+dy1)/3;
2132 dc = (zr1+z2+z1)/3;
2133 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2134 v = v+(ColorCalculation(dxr1,dyr1,zr1,dx2,dy2,z2,dx1,dy1,z1)+spriz)/2;
2135 da = (dxr1+dxr2+dx1)/3;
2136 db = (dyr1+dyr2+dy1)/3;
2137 dc = (zr1+zr2+z1)/3;
2138 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2139 v = v+(ColorCalculation(dxr1,dyr1,zr1,dx1,dy1,z1,dxr2,dyr2,zr2)+spriz)/2;
2140 da = (dxr2+dx1+dx4)/3;
2141 db = (dyr2+dy1+dy4)/3;
2142 dc = (zr2+z1+z4)/3;
2143 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2144 v = v+(ColorCalculation(dxr2,dyr2,zr2,dx1,dy1,z1,dx4,dy4,z4)+spriz)/2;
2145 v1 = v/4;
2146 if (sr3<0||sr3>w1||tr3<0||tr3>w2) Transform(sr3,tr3,-1);
2147 else Transform(sr3,tr3,0);
2148 dxr1 = fDxspline;
2149 dyr1 = fDyspline;
2150 zr1 = fZ;
2151 if (sr2<0||sr2>w1||tr2<0||tr2>w2) Transform(sr2,tr2,-1);
2152 else Transform(sr2,tr2,0);
2153 dxr2 = fDxspline;
2154 dyr2 = fDyspline;
2155 zr2 = fZ;
2156 da = (dx1+dx2+dx3)/3;
2157 db = (dy1+dy2+dy3)/3;
2158 dc = (z1+z2+z3)/3;
2159 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2160 v = (ColorCalculation(dx1,dy1,z1,dx2,dy2,z2,dx3,dy3,z3)+spriz)/2;
2161 da = (dx2+dxr1+dx3)/3;
2162 db = (dy2+dyr1+dy3)/3;
2163 dc = (z2+zr1+z3)/3;
2164 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2165 v = v+(ColorCalculation(dx2,dy2,z2,dxr1,dyr1,zr1,dx3,dy3,z3)+spriz)/2;
2166 da = (dx2+dxr2+dxr1)/3;
2167 db = (dy2+dyr2+dyr1)/3;
2168 dc = (z2+zr2+zr1)/3;
2169 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2170 v = v+(ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dxr1,dyr1,zr1)+spriz)/2;
2171 da = (dxr2+dx2+dx1)/3;
2172 db = (dyr2+dy2+dy1)/3;
2173 dc = (zr2+z2+z1)/3;
2174 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2175 v = v+(ColorCalculation(dxr2,dyr2,zr2,dx2,dy2,z2,dx1,dy1,z1)+spriz)/2;
2176 v2 = v/4;
2177 if (sr5<0||sr5>w1||tr5<0||tr5>w2) Transform(sr5,tr5,-1);
2178 else Transform(sr5,tr5,0);
2179 dxr1 = fDxspline;
2180 dyr1 = fDyspline;
2181 zr1 = fZ;
2182 if (sr4<0||sr4>w1||tr4<0||tr4>w2) Transform(sr4,tr4,-1);
2183 else Transform(sr4,tr4,0);
2184 dxr2 = fDxspline;
2185 dyr2 = fDyspline;
2186 zr2 = fZ;
2187 da = (dx2+dx3+dx4)/3;
2188 db = (dy2+dy3+dy4)/3;
2189 dc = (z2+z3+z4)/3;
2190 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2191 v = (ColorCalculation(dx2,dy2,z2,dx3,dy3,z3,dx4,dy4,z4)+spriz)/2;
2192 da = (dx4+dx3+dxr1)/3;
2193 db = (dy4+dy3+dyr1)/3;
2194 dc = (z4+z3+zr1)/3;
2195 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2196 v = v+(ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr1,dyr1,zr1)+spriz)/2;
2197 da = (dx3+dxr2+dxr1)/3;
2198 db = (dy3+dyr2+dyr1)/3;
2199 dc = (z3+zr2+zr1)/3;
2200 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2201 v = v+(ColorCalculation(dx3,dy3,z3,dxr2,dyr2,zr2,dxr1,dyr1,zr1)+spriz)/2;
2202 da = (dx2+dxr2+dx3)/3;
2203 db = (dy2+dyr2+dy3)/3;
2204 dc = (z2+zr2+z3)/3;
2205 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2206 v = v+(ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dx3,dy3,z3)+spriz)/2;
2207 v3 = v/4;
2208 if (sr7<0||sr7>w1||tr7<0||tr7>w2) Transform(sr7,tr7,-1);
2209 else Transform(sr7,tr7,0);
2210 dxr1 = fDxspline;
2211 dyr1 = fDyspline;
2212 zr1 = fZ;
2213 if (sr6<0||sr6>w1||tr6<0||tr6>w2) Transform(sr6,tr6,-1);
2214 else Transform(sr6,tr6,0);
2215 dxr2 = fDxspline;
2216 dyr2 = fDyspline;
2217 zr2 = fZ;
2218 da = (dx1+dx3+dx4)/3;
2219 db = (dy1+dy3+dy4)/3;
2220 dc = (z1+z3+z4)/3;
2221 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2222 v = (ColorCalculation(dx1,dy1,z1,dx3,dy3,z3,dx4,dy4,z4)+spriz)/2;
2223 da = (dx4+dx3+dxr2)/3;
2224 db = (dy4+dy3+dyr2)/3;
2225 dc = (z4+z3+zr2)/3;
2226 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2227 v = v+(ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr2,dyr2,zr2)+spriz)/2;
2228 da = (dx4+dxr2+dxr1)/3;
2229 db = (dy4+dyr2+dyr1)/3;
2230 dc = (z4+zr2+zr1)/3;
2231 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2232 v = v+(ColorCalculation(dx4,dy4,z4,dxr2,dyr2,zr2,dxr1,dyr1,zr1)+spriz)/2;
2233 da = (dx1+dx4+dxr1)/3;
2234 db = (dy1+dy4+dyr1)/3;
2235 dc = (z1+z4+zr1)/3;
2236 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2237 v = v+(ColorCalculation(dx1,dy1,z1,dx4,dy4,z4,dxr1,dyr1,zr1)+spriz)/2;
2238 v4 = v/4;
2239 }
2240 }
2241 spriz = 0;
2243 if (fShading==kNotShaded) {
2244 v = v*fLevels+0.5;
2245 iv = fLevels-(Int_t)v;
2246 } else {
2247 v1 = v1*fLevels;
2248 iv1 = fLevels-(Int_t)v1;
2249 v2 = v2*fLevels;
2250 iv2 = fLevels-(Int_t)v2;
2251 v4 = v4*fLevels;
2252 iv4 = fLevels-(Int_t)v4;
2253 }
2254 } else {
2255 spriz = ShadowColorCalculation(xtaz,ytaz,ztaz,shad_noise);
2256 if (fShading==kNotShaded) {
2257 v = v*fLevels/2.0;
2258 iv = fLevels-(Int_t)(v+0.5);
2259 } else {
2260 v1 = v1*fLevels;
2261 iv1 = fLevels-(Int_t)v1;
2262 v2 = v2*fLevels;
2263 iv2 = fLevels-(Int_t)v2;
2264 v4 = v4*fLevels;
2265 iv4 = fLevels-(Int_t)v4;
2266 }
2267 }
2268 if (fShading==kNotShaded) {
2269 ColorModel(iv,ui1,ui2,ui3);
2271 if (fEnvelope[x1]>=y1) {
2272 line->PaintLine(gPad->PixeltoX(x1),gPad->PixeltoY(y1)+1,gPad->PixeltoX(x1+1),gPad->PixeltoY(y1)+1);
2273 fEnvelope[x1] = y1;
2274 }
2275 if (fEnvelope[x2]>=y2) {
2276 line->PaintLine(gPad->PixeltoX(x2),gPad->PixeltoY(y2)+1,gPad->PixeltoX(x2+1),gPad->PixeltoY(y2)+1);
2277 fEnvelope[x2] = y2;
2278 }
2279 if (fEnvelope[x4]>=y4) {
2280 line->PaintLine(gPad->PixeltoX(x4),gPad->PixeltoY(y4)+1,gPad->PixeltoX(x4+1),gPad->PixeltoY(y4)+1);
2281 fEnvelope[x4] = y4;
2282 }
2283 } else {
2284 if (fEnvelope[x1]>=y1) {
2285 iv = iv1;
2286 ColorModel(iv,ui1,ui2,ui3);
2288 line->PaintLine(gPad->PixeltoX(x1),gPad->PixeltoY(y1)+1,gPad->PixeltoX(x1+1),gPad->PixeltoY(y1)+1);
2289 fEnvelope[x1] = y1;
2290 }
2291 if (fEnvelope[x2]>=y2) {
2292 iv = iv2;
2293 ColorModel(iv,ui1,ui2,ui3);
2295 line->PaintLine(gPad->PixeltoX(x2),gPad->PixeltoY(y2)+1,gPad->PixeltoX(x2+1),gPad->PixeltoY(y2)+1);
2296 fEnvelope[x2]=y2;
2297 }
2298 if (fEnvelope[x4]>=y4) {
2299 iv = iv4;
2300 ColorModel(iv,ui1,ui2,ui3);
2302 line->PaintLine(gPad->PixeltoX(x4),gPad->PixeltoY(y4)+1,gPad->PixeltoX(x4+1),gPad->PixeltoY(y4)+1);
2303 fEnvelope[x4] = y4;
2304 }
2305 }
2306 xtaz = (dx3+dx2+dx4)/3;
2307 ytaz = (dy3+dy2+dy4)/3;
2308 ztaz = (z3+z2+z4)/3;
2309 if (fShading==kNotShaded) v=ColorCalculation(dx2,dy2,z2,dx3,dy3,z3,dx4,dy4,z4);
2310 spriz = 0;
2312 if (fShading==kNotShaded) {
2313 v = v*fLevels;
2314 iv = fLevels-(Int_t)v;
2315 } else {
2316 v3 = v3*fLevels;
2317 iv3 = fLevels-(Int_t)v3;
2318 }
2319 } else {
2320 spriz = ShadowColorCalculation(xtaz,ytaz,ztaz,shad_noise);
2321 if (fShading==kNotShaded) {
2322 v = v*fLevels/2;
2323 iv = fLevels-(Int_t)v;
2324 iv = (Int_t)(iv-fLevels*spriz/2);
2325 } else {
2326 v3 = v3*fLevels;
2327 iv3 = fLevels-(Int_t)v3;
2328 }
2329 }
2330 if (fShading==kNotShaded) {
2331 ColorModel(iv,ui1,ui2,ui3);
2332 line->ResetAttLine("");
2334 if (fEnvelope[x3]>=y3) {
2335 line->PaintLine(gPad->PixeltoX(x3),gPad->PixeltoY(y3)+1,gPad->PixeltoX(x3+1),gPad->PixeltoY(y3)+1);
2336 fEnvelope[x3] = y3;
2337 }
2338 } else {
2339 if (fEnvelope[x3]>=y3) {
2340 iv = iv3;
2341 ColorModel(iv,ui1,ui2,ui3);
2342 line->ResetAttLine("");
2344 line->PaintLine(gPad->PixeltoX(x3),gPad->PixeltoY(y3)+1,gPad->PixeltoX(x3+1),gPad->PixeltoY(y3)+1);
2345 fEnvelope[x3]=y3;
2346 }
2347 }
2348 }
2349 }
2350 break;
2351 case kDisplayModeGrid:
2354 Envelope(x1,y1,x2,y2);
2355 if (fLine!=0) {
2356 if (fLine==1) {
2357 fXe = x2;
2358 fYe = y2;
2359 }
2360 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
2361 }
2362 } else {
2363 if ((q1!=q2||smer!=0)&&flag==1) {
2364 s1 = q1+1;
2365 t1 = q2;
2366 s2 = q1;
2367 t2 = q2;
2368 s3 = q1;
2369 t3 = q2+1;
2370 s4 = q1+1;
2371 t4 = q2+1;
2372 if (fShading==kShaded) {
2373 sr1 = s1;
2374 tr1 = (Int_t)TMath::Max(t1-1,0);
2375 sr2 = s2;
2376 tr2 = (Int_t)TMath::Max(t2-1,0);
2377 sr3 = (Int_t)TMath::Max(s2-1,0);
2378 tr3 = t2;
2379 sr4 = (Int_t)TMath::Max(s3-1,0);
2380 tr4 = t3;
2381 sr5 = s3;
2382 tr5 = t3+1;
2383 sr6 = s4;
2384 tr6 = t4+1;
2385 sr7 = s4+1;
2386 tr7 = t4;
2387 sr8 = s1+1;
2388 tr8 = t1;
2389 }
2390 if (turni==1) {
2391 i1 = s1;
2392 i2 = s2;
2393 i3 = s3;
2394 i4 = s4;
2395 } else {
2396 i1 = (Int_t)TMath::Max(w1-s1,0);
2397 i2 = (Int_t)TMath::Max(w1-s2,0);
2398 i3 = (Int_t)TMath::Max(w1-s3,0);
2399 i4 = (Int_t)TMath::Max(w1-s4,0);
2400 if (fShading==kShaded) {
2401 sr1 = (Int_t)TMath::Max(w1-sr1,0);
2402 sr2 = (Int_t)TMath::Max(w1-sr2,0);
2403 sr3 = (Int_t)TMath::Max(w1-sr3,0);
2404 sr4 = (Int_t)TMath::Max(w1-sr4,0);
2405 sr5 = (Int_t)TMath::Max(w1-sr5,0);
2406 sr6 = (Int_t)TMath::Max(w1-sr6,0);
2407 sr7 = (Int_t)TMath::Max(w1-sr7,0);
2408 sr8 = (Int_t)TMath::Max(w1-sr8,0);
2409 }
2410 }
2411 if (turnj==1) {
2412 j1 = t1;
2413 j2 = t2;
2414 j3 = t3;
2415 j4 = t4;
2416 } else {
2417 j1 = (Int_t)TMath::Max(w2-t1,0);
2418 j2 = (Int_t)TMath::Max(w2-t2,0);
2419 j3 = (Int_t)TMath::Max(w2-t3,0);
2420 j4 = (Int_t)TMath::Max(w2-t4,0);
2421 if (fShading==kShaded) {
2422 tr1 = (Int_t)TMath::Max(w2-tr1,0);
2423 tr2 = (Int_t)TMath::Max(w2-tr2,0);
2424 tr3 = (Int_t)TMath::Max(w2-tr3,0);
2425 tr4 = (Int_t)TMath::Max(w2-tr4,0);
2426 tr5 = (Int_t)TMath::Max(w2-tr5,0);
2427 tr6 = (Int_t)TMath::Max(w2-tr6,0);
2428 tr7 = (Int_t)TMath::Max(w2-tr7,0);
2429 tr8 = (Int_t)TMath::Max(w2-tr8,0);
2430 }
2431 }
2432 Transform(i1,j1,0);
2433 x1 = fXt;
2434 y1 = fYt;
2435 dx1 = fDxspline;
2436 dy1 = fDyspline;
2437 z1 = fZ;
2438 Transform(i2,j2,0);
2439 x2 = fXt;
2440 y2 = fYt;
2441 dx2 = fDxspline;
2442 dy2 = fDyspline;
2443 z2 = fZ;
2444 Transform(i3,j3,0);
2445 x3 = fXt;
2446 y3 = fYt;
2447 dx3 = fDxspline;
2448 dy3 = fDyspline;
2449 z3 = fZ;
2450 Transform(i4,j4,0);
2451 x4 = fXt;
2452 y4 = fYt;
2453 dx4 = fDxspline;
2454 dy4 = fDyspline;
2455 z4 = fZ;
2456 Envelope(x1,y1,x2,y2);
2457 Envelope(x2,y2,x3,y3);
2458 xtaz = (dx1+dx2+dx4)/3;
2459 ytaz = (dy1+dy2+dy4)/3;
2460 ztaz = (z1+z2+z4)/3;
2461 v = ColorCalculation(dx1,dy1,z1,dx2,dy2,z2,dx4,dy4,z4);
2462 if (fShading==kShaded) {
2464 if (sr1<0||sr1>w1||tr1<0||tr1>w2) Transform(sr1,tr1,-1);
2465 else Transform(sr1,tr1,0);
2466 dxr1 = fDxspline;
2467 dyr1 = fDyspline;
2468 zr1 = fZ;
2469 if (sr8<0||sr8>w1||tr8<0||tr8>w2) Transform(sr8,tr8,-1);
2470 else Transform(sr8,tr8,0);
2471 dxr2 = fDxspline;
2472 dyr2 = fDyspline;
2473 zr2 = fZ;
2474 v = v+ColorCalculation(dxr1,dyr1,zr1,dx2,dy2,z2,dx1,dy1,z1);
2475 v = v+ColorCalculation(dxr1,dyr1,zr1,dx1,dy1,z1,dxr2,dyr2,zr2);
2476 v = v+ColorCalculation(dxr2,dyr2,zr2,dx1,dy1,z1,dx4,dy4,z4);
2477 v1 = v/4;
2478 if (sr3<0||sr3>w1||tr3<0||tr3>w2) Transform(sr3,tr3,-1);
2479 else Transform(sr3,tr3,0);
2480 dxr1 = fDxspline;
2481 dyr1 = fDyspline;
2482 zr1 = fZ;
2483 if (sr2<0||sr2>w1||tr2<0||tr2>w2) Transform(sr2,tr2,-1);
2484 else Transform(sr2,tr2,0);
2485 dxr2 = fDxspline;
2486 dyr2 = fDyspline;
2487 zr2 = fZ;
2488 v = ColorCalculation(dx1,dy1,z1,dx2,dy2,z2,dx3,dy3,z3);
2489 v = v+ColorCalculation(dx2,dy2,z2,dxr1,dyr1,zr1,dx3,dy3,z3);
2490 v = v+ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dxr1,dyr1,zr1);
2491 v = v+ColorCalculation(dxr2,dyr2,zr2,dx2,dy2,z2,dx1,dy1,z1);
2492 v2 = v/4;
2493 if (sr5<0||sr5>w1||tr5<0||tr5>w2) Transform(sr5,tr5,-1);
2494 else Transform(sr5,tr5,0);
2495 dxr1 = fDxspline;
2496 dyr1 = fDyspline;
2497 zr1 = fZ;
2498 if (sr4<0||sr4>w1||tr4<0||tr4>w2) Transform(sr4,tr4,-1);
2499 else Transform(sr4,tr4,0);
2500 dxr2 = fDxspline;
2501 dyr2 = fDyspline;
2502 zr2 = fZ;
2503 v = ColorCalculation(dx2,dy2,z2,dx3,dy3,z3,dx4,dy4,z4);
2504 v = v+ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr1,dyr1,zr1);
2505 v = v+ColorCalculation(dx3,dy3,z3,dxr2,dyr2,zr2,dxr1,dyr1,zr1);
2506 v = v+ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dx3,dy3,z3);
2507 v3 = v/4;
2508 if (sr7<0||sr7>w1||tr7<0||tr7>w2) Transform(sr7,tr7,-1);
2509 else Transform(sr7,tr7,0);
2510 dxr1 = fDxspline;
2511 dyr1 = fDyspline;
2512 zr1 = fZ;
2513 if (sr6<0||sr6>w1||tr6<0||tr6>w2) Transform(sr6,tr6,-1);
2514 else Transform(sr6,tr6,0);
2515 dxr2 = fDxspline;
2516 dyr2 = fDyspline;
2517 zr2 = fZ;
2518 v = ColorCalculation(dx1,dy1,z1,dx3,dy3,z3,dx4,dy4,z4);
2519 v = v+ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr2,dyr2,zr2);
2520 v = v+ColorCalculation(dx4,dy4,z4,dxr2,dyr2,zr2,dxr1,dyr1,zr1);
2521 v = v+ColorCalculation(dx1,dy1,z1,dx4,dy4,z4,dxr1,dyr1,zr1);
2522 v4 = v/4;
2523 } else {
2524 spriz = ShadowColorCalculation(xtaz,ytaz,ztaz,shad_noise);
2525 v = v+spriz;
2526 v = v/2;
2527 if (sr1<0||sr1>w1||tr1<0||tr1>w2) Transform(sr1,tr1,-1);
2528 else Transform(sr1,tr1,0);
2529 dxr1 = fDxspline;
2530 dyr1 = fDyspline;
2531 zr1 = fZ;
2532 if (sr8<0||sr8>w1||tr8<0||tr8>w2) Transform(sr8,tr8,-1);
2533 else Transform(sr8,tr8,0);
2534 dxr2 = fDxspline;
2535 dyr2 = fDyspline;
2536 zr2 = fZ;
2537 da = (dxr1+dx2+dx1)/3;
2538 db = (dyr1+dy2+dy1)/3;
2539 dc = (zr1+z2+z1)/3;
2540 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2541 v = v+(ColorCalculation(dxr1,dyr1,zr1,dx2,dy2,z2,dx1,dy1,z1)+spriz)/2;
2542 da = (dxr1+dxr2+dx1)/3;
2543 db = (dyr1+dyr2+dy1)/3;
2544 dc = (zr1+zr2+z1)/3;
2545 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2546 v = v+(ColorCalculation(dxr1,dyr1,zr1,dx1,dy1,z1,dxr2,dyr2,zr2)+spriz)/2;
2547 da = (dxr2+dx1+dx4)/3;
2548 db = (dyr2+dy1+dy4)/3;
2549 dc = (zr2+z1+z4)/3;
2550 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2551 v = v+(ColorCalculation(dxr2,dyr2,zr2,dx1,dy1,z1,dx4,dy4,z4)+spriz)/2;
2552 v1 = v/4;
2553 if (sr3<0||sr3>w1||tr3<0||tr3>w2) Transform(sr3,tr3,-1);
2554 else Transform(sr3,tr3,0);
2555 dxr1 = fDxspline;
2556 dyr1 = fDyspline;
2557 zr1 = fZ;
2558 if (sr2<0||sr2>w1||tr2<0||tr2>w2) Transform(sr2,tr2,-1);
2559 else Transform(sr2,tr2,0);
2560 dxr2 = fDxspline;
2561 dyr2 = fDyspline;
2562 zr2 = fZ;
2563 da = (dx1+dx2+dx3)/3;
2564 db = (dy1+dy2+dy3)/3;
2565 dc = (z1+z2+z3)/3;
2566 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2567 v = (ColorCalculation(dx1,dy1,z1,dx2,dy2,z2,dx3,dy3,z3)+spriz)/2;
2568 da = (dx2+dxr1+dx3)/3;
2569 db = (dy2+dyr1+dy3)/3;
2570 dc = (z2+zr1+z3)/3;
2571 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2572 v = v+(ColorCalculation(dx2,dy2,z2,dxr1,dyr1,zr1,dx3,dy3,z3)+spriz)/2;
2573 da = (dx2+dxr2+dxr1)/3;
2574 db = (dy2+dyr2+dyr1)/3;
2575 dc = (z2+zr2+zr1)/3;
2576 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2577 v = v+(ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dxr1,dyr1,zr1)+spriz)/2;
2578 da = (dxr2+dx2+dx1)/3;
2579 db = (dyr2+dy2+dy1)/3;
2580 dc = (zr2+z2+z1)/3;
2581 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2582 v = v+(ColorCalculation(dxr2,dyr2,zr2,dx2,dy2,z2,dx1,dy1,z1)+spriz)/2;
2583 v2 = v/4;
2584 if (sr5<0||sr5>w1||tr5<0||tr5>w2) Transform(sr5,tr5,-1);
2585 else Transform(sr5,tr5,0);
2586 dxr1 = fDxspline;
2587 dyr1 = fDyspline;
2588 zr1 = fZ;
2589 if (sr4<0||sr4>w1||tr4<0||tr4>w2) Transform(sr4,tr4,-1);
2590 else Transform(sr4,tr4,0);
2591 dxr2 = fDxspline;
2592 dyr2 = fDyspline;
2593 zr2 = fZ;
2594 da = (dx2+dx3+dx4)/3;
2595 db = (dy2+dy3+dy4)/3;
2596 dc = (z2+z3+z4)/3;
2597 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2598 v = (ColorCalculation(dx2,dy2,z2,dx3,dy3,z3,dx4,dy4,z4)+spriz)/2;
2599 da = (dx4+dx3+dxr1)/3;
2600 db = (dy4+dy3+dyr1)/3;
2601 dc = (z4+z3+zr1)/3;
2602 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2603 v = v+(ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr1,dyr1,zr1)+spriz)/2;
2604 da = (dx3+dxr2+dxr1)/3;
2605 db = (dy3+dyr2+dyr1)/3;
2606 dc = (z3+zr2+zr1)/3;
2607 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2608 v = v+(ColorCalculation(dx3,dy3,z3,dxr2,dyr2,zr2,dxr1,dyr1,zr1)+spriz)/2;
2609 da = (dx2+dxr2+dx3)/3;
2610 db = (dy2+dyr2+dy3)/3;
2611 dc = (z2+zr2+z3)/3;
2612 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2613 v = v+(ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dx3,dy3,z3)+spriz)/2;
2614 v3 = v/4;
2615 if (sr7<0||sr7>w1||tr7<0||tr7>w2) Transform(sr7,tr7,-1);
2616 else Transform(sr7,tr7,0);
2617 dxr1 = fDxspline;
2618 dyr1 = fDyspline;
2619 zr1 = fZ;
2620 if (sr6<0||sr6>w1||tr6<0||tr6>w2) Transform(sr6,tr6,-1);
2621 else Transform(sr6,tr6,0);
2622 dxr2 = fDxspline;
2623 dyr2 = fDyspline;
2624 zr2 = fZ;
2625 da = (dx1+dx3+dx4)/3;
2626 db = (dy1+dy3+dy4)/3;
2627 dc = (z1+z3+z4)/3;
2628 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2629 v = (ColorCalculation(dx1,dy1,z1,dx3,dy3,z3,dx4,dy4,z4)+spriz)/2;
2630 da = (dx4+dx3+dxr2)/3;
2631 db = (dy4+dy3+dyr2)/3;
2632 dc = (z4+z3+zr2)/3;
2633 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2634 v = v+(ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr2,dyr2,zr2)+spriz)/2;
2635 da = (dx4+dxr2+dxr1)/3;
2636 db = (dy4+dyr2+dyr1)/3;
2637 dc = (z4+zr2+zr1)/3;
2638 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2639 v = v+(ColorCalculation(dx4,dy4,z4,dxr2,dyr2,zr2,dxr1,dyr1,zr1)+spriz)/2;
2640 da = (dx1+dx4+dxr1)/3;
2641 db = (dy1+dy4+dyr1)/3;
2642 dc = (z1+z4+zr1)/3;
2643 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
2644 v = v+(ColorCalculation(dx1,dy1,z1,dx4,dy4,z4,dxr1,dyr1,zr1)+spriz)/2;
2645 v4 = v/4;
2646 }
2647 }
2648 spriz = 0;
2650 if (fShading==kNotShaded) {
2651 v = v*fLevels+0.5;
2652 iv = fLevels-(Int_t)v;
2653 } else {
2654 v1 = v1*fLevels;
2655 iv1 = fLevels-(Int_t)v1;
2656 v2 = v2*fLevels;
2657 iv2 = fLevels-(Int_t)v2;
2658 v4 = v4*fLevels;
2659 iv4 = fLevels-(Int_t)v4;
2660 }
2661 } else {
2662 spriz = ShadowColorCalculation(xtaz,ytaz,ztaz,shad_noise);
2663 if (fShading==kNotShaded) {
2664 v = v*fLevels/2.0;
2665 iv = fLevels-(Int_t)(v+0.5);
2666 } else {
2667 v1 = v1*fLevels;
2668 iv1 = fLevels-(Int_t)v1;
2669 v2 = v2*fLevels;
2670 iv2 = fLevels-(Int_t)v2;
2671 v4 = v4*fLevels;
2672 iv4 = fLevels-(Int_t)v4;
2673 }
2674 }
2675 if (fShading==kNotShaded) {
2676 ColorModel(iv,ui1,ui2,ui3);
2678 } else {
2679 dx1 = x1;
2680 dy1 = y1;
2681 dx2 = x2;
2682 dy2 = y2;
2683 dx3 = x4;
2684 dy3 = y4;
2685 z1 = iv1;
2686 z2 = iv2;
2687 z3 = iv4;
2688 da = (dy2-dy1)*(z3-z1)-(dy3-dy1)*(z2-z1);
2689 db = (z2-z1)*(dx3-dx1)-(z3-z1)*(dx2-dx1);
2690 dc = (dx2-dx1)*(dy3-dy1)-(dx3-dx1)*(dy2-dy1);
2691 dd = -da*dx1-db*dy1-dc*z1;
2692 }
2693 sx1 = x1;
2694 sy1 = y1;
2695 sx2 = x2;
2696 sy2 = y2;
2697 if (sx2<sx1) {
2698 sx4 = sx1;
2699 sy4 = sy1;
2700 sx1 = sx2;
2701 sy1 = sy2;
2702 sx2 = sx4;
2703 sy2 = sy4;
2704 }
2705 sdx1 = 0;
2706 pom1 = sy2-sy1;
2707 pom2 = sx2-sx1;
2708 if (pom2!=0) sdx1 = pom1/pom2;
2709 pom1 = sy1;
2710 pom2 = sx1;
2711 sdy1 = pom1-sdx1*pom2;
2712 for (sx4=sx1,sx5=sx1,sy5=sy1;sx4<=sx2;sx4++) {
2713 pom1 = sx4;
2714 sdy4 = sdx1*pom1+sdy1;
2715 sy4 = (Int_t)(sdy4);
2716 if (sy4<=fEnvelope[sx4]) {
2717 fEnvelope[sx4] = sy4;
2718 if (fShading==kNotShaded) {
2719 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2720 } else {
2721 dx1 = sx4;
2722 dy1 = sy4;
2723 if (dc!=0) v = (-dd-da*dx1-db*dy1)/dc;
2724 else v = (iv1+iv2+iv4)/3;
2725 iv = (Int_t)v;
2726 ColorModel(iv,ui1,ui2,ui3);
2728 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2729 }
2730 sy5 = sy4;
2731 } else {
2732 sy4 = fEnvelope[sx4];
2733 if (fShading==kNotShaded&&sy5<=fEnvelope[sx5]) {
2734 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2735 } else if (sy5<=fEnvelope[sx5]) {
2736 dx1 = sx4;
2737 dy1 = sy4;
2738 if (dc!=0) v = (-dd-da*dx1-db*dy1)/dc;
2739 else v = (iv1+iv2+iv4)/3;
2740 iv = (Int_t)v;
2741 ColorModel(iv,ui1,ui2,ui3);
2743 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2744 }
2745 sy5 = fEnvelope[sx4];
2746 }
2747 sx5 = sx4;
2748 }
2749 sx1 = x1;
2750 sy1 = y1;
2751 sx3 = x4;
2752 sy3 = y4;
2753 if (sx3<sx1) {
2754 sx4 = sx1;
2755 sy4 = sy1;
2756 sx1 = sx3;
2757 sy1 = sy3;
2758 sx3 = sx4;
2759 sy3 = sy4;
2760 }
2761 pom1 = sy3-sy1;
2762 pom2 = sx3-sx1;
2763 if (pom2!=0) sdx2 = pom1/pom2;
2764 pom1 = sy1;
2765 pom2 = sx1;
2766 sdy2 = pom1-sdx2*pom2;
2767 sx1p = sx1;
2768 sy1p = sy1;
2769 sx3p = sx3;
2770 sdx2p = sdx2;
2771 sdy2p = sdy2;
2772 dap = da;
2773 dbp = db;
2774 dcp = dc;
2775 ddp = dd;
2776 uip = fNewColorIndex;
2777 xtaz = (dx3+dx2+dx4)/3;
2778 ytaz = (dy3+dy2+dy4)/3;
2779 ztaz = (z3+z2+z4)/3;
2780 if (fShading==kNotShaded) v = ColorCalculation(dx2,dy2,z2,dx3,dy3,z3,dx4,dy4,z4);
2781 spriz = 0;
2783 if (fShading==kNotShaded) {
2784 v = v*fLevels;
2785 iv = fLevels-(Int_t)v;
2786 } else {
2787 v3 = v3*fLevels;
2788 iv3 = fLevels-(Int_t)v3;
2789 }
2790 } else {
2791 spriz = ShadowColorCalculation(xtaz,ytaz,ztaz,shad_noise);
2792 if (fShading==kNotShaded) {
2793 v = v*fLevels/2;
2794 iv = fLevels-(Int_t)v;
2795 iv = (Int_t)(iv-fLevels*spriz/2);
2796 } else {
2797 v3 = v3*fLevels;
2798 iv3 = fLevels-(Int_t)v3;
2799 }
2800 }
2801 if (fShading==kNotShaded) {
2802 ColorModel(iv,ui1,ui2,ui3);
2804 } else {
2805 dx1 = x2;
2806 dy1 = y2;
2807 dx2 = x3;
2808 dy2 = y3;
2809 dx3 = x4;
2810 dy3 = y4;
2811 z1 = iv2;
2812 z2 = iv3;
2813 z3 = iv4;
2814 da = (dy2-dy1)*(z3-z1)-(dy3-dy1)*(z2-z1);
2815 db = (z2-z1)*(dx3-dx1)-(z3-z1)*(dx2-dx1);
2816 dc = (dx2-dx1)*(dy3-dy1)-(dx3-dx1)*(dy2-dy1);
2817 dd = -da*dx1-db*dy1-dc*z1;
2818 }
2819 sx1 = x2;
2820 sy1 = y2;
2821 sx2 = x3;
2822 sy2 = y3;
2823 if (sx2<sx1) {
2824 sx4 = sx1;
2825 sy4 = sy1;
2826 sx1 = sx2;
2827 sy1 = sy2;
2828 sx2 = sx4;
2829 sy2 = sy4;
2830 }
2831 pom1 = sy2-sy1;
2832 pom2 = sx2-sx1;
2833 sdx1 = 0;
2834 if (pom2!=0) sdx1 = pom1/pom2;
2835 pom1 = sy1;
2836 pom2 = sx1;
2837 sdy1 = pom1-sdx1*pom2;
2838 for (sx4=sx1,sx5=sx1,sy5=sy1;sx4<=sx2;sx4++) {
2839 pom1 = sx4;
2840 sdy4 = sdx1*pom1+sdy1;
2841 sy4 = (Int_t)sdy4;
2842 if (sy4<=fEnvelope[sx4]) {
2843 fEnvelope[sx4] = sy4;
2844 if (fShading==kNotShaded) {
2845 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2846 } else {
2847 dx1 = sx4;
2848 dy1 = sy4;
2849 if (dc!=0) v = (-dd-da*dx1-db*dy1)/dc;
2850 else v = (iv1+iv2+iv4)/3;
2851 iv = (Int_t)v;
2852 ColorModel(iv,ui1,ui2,ui3);
2854 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2855 }
2856 sy5 = sy4;
2857 } else {
2858 sy4 = fEnvelope[sx4];
2859 if (fShading==kNotShaded&&sy5<=fEnvelope[sx5]) {
2860 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2861 } else if (sy5<=fEnvelope[sx5]) {
2862 dx1 = sx4;
2863 dy1 = sy4;
2864 if (dc!=0) v = (-dd-da*dx1-db*dy1)/dc;
2865 else v = (iv1+iv2+iv4)/3;
2866 iv = (Int_t)v;
2867 ColorModel(iv,ui1,ui2,ui3);
2869 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2870 }
2871 sy5 = fEnvelope[sx4];
2872 }
2873 sx5 = sx4;
2874 }
2875 for (sx4=sx1p,sx5=sx1p,sy5=sy1p;sx4<=sx3p;sx4++) {
2876 pom1 = sx4;
2877 sdy4 = sdx2p*pom1+sdy2p;
2878 sy4 = (Int_t)sdy4;
2879 if (sy4<=fEnvelope[sx4]) {
2880 fEnvelope[sx4]=sy4;
2881 if (fShading==kNotShaded) {
2882 line->SetLineColor(uip);
2883 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2884 } else {
2885 dx1 = sx4;
2886 dy1 = sy4;
2887 if (dcp!=0) v = (-ddp-dap*dx1-dbp*dy1)/dcp;
2888 else v = (iv1+iv2+iv4)/3;
2889 iv = (Int_t)v;
2890 ColorModel(iv,ui1,ui2,ui3);
2892 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2893 }
2894 sy5 = sy4;
2895 } else {
2896 sy4 = fEnvelope[sx4];
2897 if (fShading==kNotShaded&&sy5<=fEnvelope[sx5]) {
2898 line->SetLineColor(uip);
2899 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2900 } else if (sy5<=fEnvelope[sx5]) {
2901 dx1 = sx4;
2902 dy1 = sy4;
2903 if (dcp!=0) v = (-ddp-dap*dx1-dbp*dy1)/dcp;
2904 else v = (iv1+iv2+iv4)/3;
2905 iv = (Int_t)v;
2906 ColorModel(iv,ui1,ui2,ui3);
2908 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2909 }
2910 sy5 = fEnvelope[sx4];
2911 }
2912 sx5 = sx4;
2913 }
2914 sx2 = x3;
2915 sy2 = y3;
2916 sx3 = x4;
2917 sy3 = y4;
2918 if (sx3<sx2) {
2919 sx4 = sx2;
2920 sy4 = sy2;
2921 sx2 = sx3;
2922 sy2 = sy3;
2923 sx3 = sx4;
2924 sy3 = sy4;
2925 }
2926 sdx2 = 0;
2927 pom1 = sy3-sy2;
2928 pom2 = sx3-sx2;
2929 if (pom2!=0) sdx2 = pom1/pom2;
2930 pom1 = sy2;
2931 pom2 = sx2;
2932 sdy2 = pom1-sdx2*pom2;
2933 for (sx4=sx2,sx5=sx2,sy5=sy2;sx4<=sx3;sx4++) {
2934 pom1 = sx4;
2935 sdy4 = sdx2*pom1+sdy2;
2936 sy4 = (Int_t)sdy4;
2937 if (sy4<=fEnvelope[sx4]) {
2938 fEnvelope[sx4] = sy4;
2939 if (fShading==kNotShaded) {
2940 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2941 } else {
2942 dx1 = sx4;
2943 dy1 = sy4;
2944 if (dc!=0) v = (-dd-da*dx1-db*dy1)/dc;
2945 else v =(iv1+iv2+iv4)/3;
2946 iv = (Int_t)v;
2947 ColorModel(iv,ui1,ui2,ui3);
2949 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2950 }
2951 sy5 = sy4;
2952 } else {
2953 sy4 = fEnvelope[sx4];
2954 if (fShading==kNotShaded&&sy5<=fEnvelope[sx5]) {
2955 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2956 } else if (sy5<=fEnvelope[sx5]) {
2957 dx1 = sx4;
2958 dy1 = sy4;
2959 if (dc!=0) v = (-dd-da*dx1-db*dy1)/dc;
2960 else v =(iv1+iv2+iv4)/3;
2961 iv = (Int_t)v;
2962 ColorModel(iv,ui1,ui2,ui3);
2964 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx5),gPad->PixeltoY(sy5)+1);
2965 }
2966 sy5 = fEnvelope[sx4];
2967 }
2968 sx5 = sx4;
2969 }
2970 }
2971 }
2972 } else {
2973 if (((flag==0)&&(smer==0))||((flag!=0)&&(smer!=0))) {
2974 s1 = q1;
2975 t1 = (Int_t)TMath::Max(q2-1,0);
2976 s2 = q1;
2977 t2 = (Int_t)TMath::Min(q2+2,w2);
2978 } else if (((flag!=0)&&(smer==0))||((flag==0)&&(smer!=0))) {
2979 s1 = (Int_t)TMath::Max(q1-1,0);
2980 t1 = q2;
2981 s2 = (Int_t)TMath::Min(q1+2,w1);
2982 t2 = q2;
2983 }
2984 if (turni==1) {
2985 i1 = s1;
2986 i2 = s2;
2987 } else {
2988 i1 = w1-s1;
2989 i2 = w1-s2;
2990 }
2991 if (turnj==1) {
2992 j1 = t1;
2993 j2 = t2;
2994 } else {
2995 j1 = w2-t1;
2996 j2 = w2-t2;
2997 }
2998 Transform(i1,j1,0);
2999 x3 = fXt;
3000 y3 = fYt;
3001 Transform(i2,j2,0);
3002 x4 = fXt;
3003 y4 = fYt;
3004 bezx1 = x1+(x2-x1)/3;
3005 bezx2 = x1+2*(x2-x1)/3;
3006 bezy1 = y1+(y2-y3)/6;
3007 bezy2 = y2-(y4-y1)/6;
3008 if (x1<=x2) {
3009 if (bezx1<=x1) {
3010 bezx1 = x1;
3011 bezy1 = y1;
3012 }
3013 if (bezx1>=x2) {
3014 bezx1 = x2;
3015 bezy1 = y2;
3016 }
3017 if (bezx2<=x1) {
3018 bezx2 = x1;
3019 bezy2 = y1;
3020 }
3021 if (bezx2>=x2) {
3022 bezx2 = x2;
3023 bezy2 = y2;
3024 }
3025 fBzX[0] = x1;
3026 fBzY[0] = y1;
3027 fBzX[1] = (Int_t)bezx1;
3028 fBzY[1] = (Int_t)bezy1;
3029 fBzX[2] = (Int_t)bezx2;
3030 fBzY[2] = (Int_t)bezy2;
3031 fBzX[3] = x2;
3032 fBzY[3] = y2;
3033 for (bezf=0;bezf<1.01;bezf+=0.1) {
3034 BezierSmoothing(bezf);
3035 if (bezf==0) {
3036 ibezx1 = (Int_t)(fGbezx+0.5);
3037 ibezy1 = (Int_t)(fGbezy+0.5);
3038 } else {
3039 ibezx2 = ibezx1;
3040 ibezy2 = ibezy1;
3041 ibezx1 = (Int_t)(fGbezx+0.5);
3042 ibezy1 = (Int_t)(fGbezy+0.5);
3043 Envelope(ibezx2,ibezy2,ibezx1,ibezy1);
3044 if (fLine!=0) {
3045 if (fLine==1) {
3046 fXe = ibezx1;
3047 fYe = ibezy1;
3048 }
3049 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3050 }
3051 }
3052 }
3053 } else if (x1>x2) {
3054 if (bezx1>=x1) {
3055 bezx1 = x1;
3056 bezy1 = y1;
3057 }
3058 if (bezx1<=x2) {
3059 bezx1 = x2;
3060 bezy1 = y2;
3061 }
3062 if (bezx2>=x1) {
3063 bezx2 = x1;
3064 bezy2 = y1;
3065 }
3066 if (bezx2<=x2) {
3067 bezx2 = x2;
3068 bezy2 = y2;
3069 }
3070 fBzX[0] = x1;
3071 fBzY[0] = y1;
3072 fBzX[1] = (Int_t)bezx1;
3073 fBzY[1] = (Int_t)bezy1;
3074 fBzX[2] = (Int_t)bezx2;
3075 fBzY[2] = (Int_t)bezy2;
3076 fBzX[3] = x2;
3077 fBzY[3] = y2;
3078 for (bezf=0;bezf<1.01;bezf+=0.1) {
3079 BezierSmoothing(bezf);
3080 if (bezf==0) {
3081 ibezx1 = (Int_t)(fGbezx+0.5);
3082 ibezy1 = (Int_t)(fGbezy+0.5);
3083 } else {
3084 ibezx2 = ibezx1;
3085 ibezy2 = ibezy1;
3086 ibezx1 = (Int_t)(fGbezx+0.5);
3087 ibezy1 = (Int_t)(fGbezy+0.5);
3088 Envelope(ibezx1,ibezy1,ibezx2,ibezy2);
3089 if (fLine!=0) {
3090 if (fLine==1) {
3091 fXe = ibezx2;
3092 fYe = ibezy2;
3093 }
3094 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3095 }
3096 }
3097 }
3098 }
3099 }
3100 break;
3102 if ((q1!=q2||smer!=0)&&flag==1) {
3103 s1 = q1+1;
3104 t1 = q2;
3105 s2 = q1;
3106 t2 = q2;
3107 s3 = q1;
3108 t3 = q2+1;
3109 s4 = q1+1;
3110 t4 = q2+1;
3111 if (turni==1) {
3112 i1 = (Int_t)TMath::Min(w1,s1);
3113 i2 = (Int_t)TMath::Min(w1,s2);
3114 i3 = (Int_t)TMath::Min(w1,s3);
3115 i4 = (Int_t)TMath::Min(w1,s4);
3116 } else {
3117 i1 = (Int_t)TMath::Max(w1-s1,0);
3118 i2 = (Int_t)TMath::Max(w1-s2,0);
3119 i3 = (Int_t)TMath::Max(w1-s3,0);
3120 i4 = (Int_t)TMath::Max(w1-s4,0);
3121 }
3122 if (turnj==1) {
3123 j1 = (Int_t)TMath::Min(w2,t1);
3124 j2 = (Int_t)TMath::Min(w2,t2);
3125 j3 = (Int_t)TMath::Min(w2,t3);
3126 j4 = (Int_t)TMath::Min(w2,t4);
3127 } else {
3128 j1 = (Int_t)TMath::Max(w2-t1,0);
3129 j2 = (Int_t)TMath::Max(w2-t2,0);
3130 j3 = (Int_t)TMath::Max(w2-t3,0);
3131 j4 = (Int_t)TMath::Max(w2-t4,0);
3132 }
3133 Transform(i1,j1,0);
3134 dx1 = fDxspline;
3135 dy1 = fDyspline;
3136 z1 = fZ;
3137 z1l = fZeq;
3138 Transform(i2,j2,0);
3139 dx2 = fDxspline;
3140 dy2 = fDyspline;
3141 z2 = fZ;
3142 z2l = fZeq;
3143 Transform(i3,j3,0);
3144 dx3 = fDxspline;
3145 dy3 = fDyspline;
3146 z3 = fZ;
3147 z3l = fZeq;
3148 Transform(i4,j4,0);
3149 dx4 = fDxspline;
3150 dy4 = fDyspline;
3151 z4 = fZ;
3152 z4l = fZeq;
3153 zh = (Double_t)TMath::Max(z1,z2);
3154 zh = (Double_t)TMath::Max(zh,z3);
3155 zh = (Double_t)TMath::Max(zh,z4);
3156 zl = (Double_t)TMath::Min(z1l,z2l);
3157 zl = (Double_t)TMath::Min(zl,z3l);
3158 zl = (Double_t)TMath::Min(zl,z4l);
3159 i1 = (Int_t)(zl/dcount_reg+1);
3160 if (z1!=z2||z2!=z3||z3!=z4) {
3161 do {
3162 fZ = i1*dcount_reg;
3163 switch (fZscale) {
3164 case kZScaleLog:
3165 if (fZ>=1.0) fZ = log(fZ);
3166 else fZ = 0;
3167 break;
3168 case kZScaleSqrt:
3169 if (fZ>0) fZ = sqrt(fZ);
3170 else fZ = 0;
3171 break;
3172 }
3174 v = ColorCalculation(dx1,dy1,fZ,dx2,dy2,fZ,dx4,dy4,fZ);
3175 v = v*fLevels+0.5;
3176 iv = fLevels-(Int_t)v;
3177 ColorModel(iv,ui1,ui2,ui3);
3179 }
3180 if (fZ>zh) goto eqend;
3181 i1 += 1;
3182 ekv = 0;
3183 stvor = 0;
3184 if ((z2<=fZ&&fZ<z1)||(z2<fZ&&fZ<=z1)) {
3185 xb = (fZ-z2)*(dx1-dx2)/(z1-z2)+dx2;
3186 goto ekvi1;
3187 }
3188 if ((z1<=fZ&&fZ<z2)||(z1<fZ&&fZ<=z2)) {
3189 xb = (fZ-z1)*(dx2-dx1)/(z2-z1)+dx1;
3190 goto ekvi1;
3191 }
3192 if (z2==fZ&&fZ==z1) {
3193 xb = dx2;
3194ekvi1:
3195 yb = dy2;
3196 ekv = 1;
3197 x5 = xb;
3198 y5 = yb;
3199 stvor += 1;
3200 }
3201 if ((z1<=fZ&&fZ<z4)||(z1<fZ&&fZ<=z4)) {
3202 ya = (fZ-z1)*(dy4-dy1)/(z4-z1)+dy1;
3203 goto ekvi2;
3204 }
3205 if ((z4<=fZ&&fZ<z1)||(z4<fZ&&fZ<=z1)) {
3206 ya = (fZ-z4)*(dy1-dy4)/(z1-z4)+dy4;
3207 goto ekvi2;
3208 }
3209 if (z4==fZ&&fZ==z1) {
3210 ya = dy1;
3211ekvi2:
3212 xa = dx1;
3213 if (ekv==1) {
3214 Slice(xa,ya,xb,yb,line);
3215 stvor += 1;
3216 }
3217 xb = xa;
3218 yb = ya;
3219 ekv = 1;
3220 }
3221 if ((z3<=fZ&&fZ<z4)||(z3<fZ&&fZ<=z4)) {
3222 xa = (fZ-z3)*(dx4-dx3)/(z4-z3)+dx3;
3223 goto ekvi3;
3224 }
3225 if ((z4<=fZ&&fZ<z3)||(z4<fZ&&fZ<=z3)) {
3226 xa = (fZ-z4)*(dx3-dx4)/(z3-z4)+dx4;
3227 goto ekvi3;
3228 }
3229 if (z4==fZ&&fZ==z3) {
3230 xa = dx4;
3231ekvi3:
3232 ya = dy4;
3233 if (ekv==1) {
3234 Slice(xa,ya,xb,yb,line);
3235 stvor += 1;
3236 }
3237 xb = xa;
3238 yb = ya;
3239 ekv = 1;
3240 }
3241 if ((z2<=fZ&&fZ<z3)||(z2<fZ&&fZ<=z3)) {
3242 ya = (fZ-z2)*(dy3-dy2)/(z3-z2)+dy2;
3243 goto ekvi4;
3244 }
3245 if ((z3<=fZ&&fZ<z2)||(z3<fZ&&fZ<=z2)) {
3246 ya = (fZ-z3)*(dy2-dy3)/(z2-z3)+dy3;
3247 goto ekvi4;
3248 }
3249 if (z3==fZ&&fZ==z2) {
3250 ya = dy3;
3251ekvi4:
3252 xa = dx3;
3253 if (ekv==1) {
3254 Slice(xa,ya,xb,yb,line);
3255 stvor += 1;
3256 }
3257 if (stvor==4) Slice(xa,ya,x5,y5,line);
3258 }
3259 } while (fZ<=zh);
3260eqend:
3261 CopyEnvelope(dx1,dx3,dy1,dy3);
3262 }
3263 }
3264 break;
3265 case kDisplayModeBars:
3266 case kDisplayModeBarsX:
3267 case kDisplayModeBarsY:
3268 if ((q1!=q2||smer!=0)&&flag==1) {
3269 s1 = q1+1;
3270 t1 = q2;
3271 s2 = q1;
3272 t2 = q2;
3273 s3 = q1;
3274 t3 = q2+1;
3275 s4 = q1+1;
3276 t4 = q2+1;
3277 }
3278 if (turni==1) {
3280 if (s1<=w1&&s2<=w1&&s3<=w1&&s4<=w1) {
3281 i1 = s1;
3282 i2 = s2;
3283 i3 = s3;
3284 i4 = s4;
3285 }
3286 } else {
3287 i1 = (Int_t)TMath::Min(w1,s1);
3288 i2 = (Int_t)TMath::Min(w1,s2);
3289 i3 = (Int_t)TMath::Min(w1,s3);
3290 i4 = (Int_t)TMath::Min(w1,s4);
3291 }
3292 } else {
3294 if (s1<=w1&&s2<=w1&&s3<=w1&&s4<=w1) {
3295 i1 = w1-s1;
3296 i2 = w1-s2;
3297 i3 = w1-s3;
3298 i4 = w1-s4;
3299 }
3300 } else {
3301 i1 = (Int_t)TMath::Max(w1-s1,0);
3302 i2 = (Int_t)TMath::Max(w1-s2,0);
3303 i3 = (Int_t)TMath::Max(w1-s3,0);
3304 i4 = (Int_t)TMath::Max(w1-s4,0);
3305 }
3306 }
3307 if (turnj==1) {
3309 if (t1<=w2&&t2<=w2&&t3<=w2&&t4<=w2) {
3310 j1 = t1;
3311 j2 = t2;
3312 j3 = t3;
3313 j4 = t4;
3314 }
3315 } else {
3316 j1 = (Int_t)TMath::Min(w2,t1);
3317 j2 = (Int_t)TMath::Min(w2,t2);
3318 j3 = (Int_t)TMath::Min(w2,t3);
3319 j4 = (Int_t)TMath::Min(w2,t4);
3320 }
3321 } else {
3323 if (t1<=w2&&t2<=w2&&t3<=w2&&t4<=w2) {
3324 j1 = w2-t1;
3325 j2 = w2-t2;
3326 j3 = w2-t3;
3327 j4 = w2-t4;
3328 }
3329 } else {
3330 j1 = (Int_t)TMath::Max(w2-t1,0);
3331 j2 = (Int_t)TMath::Max(w2-t2,0);
3332 j3 = (Int_t)TMath::Max(w2-t3,0);
3333 j4 = (Int_t)TMath::Max(w2-t4,0);
3334 }
3335 }
3336 Transform(i1,j1,0);
3337 x1 = fXt;
3338 dx1 = fDxspline;
3339 dy1 = fDyspline;
3340 z1 = fZ;
3341 Transform(i2,j2,0);
3342 x2 = fXt;
3343 dx2 = fDxspline;
3344 dy2 = fDyspline;
3345 z2 = fZ;
3346 Transform(i3,j3,0);
3347 x3 = fXt;
3348 dx3 = fDxspline;
3349 dy3 = fDyspline;
3350 z3 = fZ;
3351 Transform(i4,j4,0);
3352 x4 = fXt;
3353 y4 = fYt;
3354 dx4 = fDxspline;
3355 dy4 = fDyspline;
3356 z4 = fZ;
3357 Transform(i1,j1,-1);
3358 ix5 = fXt;
3359 iy5 = fYt;
3360 Transform(i2,j2,-1);
3361 x6 = fXt;
3362 y6 = fYt;
3363 Transform(i3,j3,-1);
3364 x7 = fXt;
3365 y7 = fYt;
3366 Transform(i4,j4,-1);
3367 y8 = fYt;
3368 y1 = iy5+(y4-y8);
3369 y2 = y6+(y4-y8);
3370 y3 = y7+(y4-y8);
3371 if ((fDisplayMode==kDisplayModeBars)&&(q1!=q2||smer!=0)&&(flag==1)) {
3372 EnvelopeBars(ix5,iy5,x6,y6);
3373 if (fLine!=0) {
3374 if (fLine==1) {
3375 fXe = x6;
3376 fYe = y6;
3377 }
3378 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3379 }
3380 EnvelopeBars(x6,y6,x7,y7);
3381 if (fLine!=0) {
3382 if (fLine==1) {
3383 fXe = x7;
3384 fYe = y7;
3385 }
3386 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3387 }
3388 EnvelopeBars(ix5,iy5,x1,y1);
3389 if (fLine!=0) {
3390 if (fLine==1) {
3391 fXe = x1;
3392 fYe = y1;
3393 }
3394 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3395 }
3396 EnvelopeBars(x6,y6,x2,y2);
3397 if (fLine!=0) {
3398 if (fLine==1) {
3399 fXe = x2;
3400 fYe = y2;
3401 }
3402 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3403 }
3404 EnvelopeBars(x7,y7,x3,y3);
3405 if (fLine!=0) {
3406 if (fLine==1) {
3407 fXe = x3;
3408 fYe = y3;
3409 }
3410 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3411 }
3413 v = ColorCalculation(dx1,dy1,z4,dx2,dy2,z4,dx4,dy4,z4);
3414 v = v*fLevels+0.5;
3415 iv = fLevels-(Int_t)v;
3416 uip = fNewColorIndex;
3417 ColorModel(iv,ui1,ui2,ui3);
3419 sx1 = x1;
3420 sy1 = y1;
3421 sx2 = x2;
3422 sy2 = y2;
3423 sx3 = x4;
3424 sy3 = y4;
3425 if (sx2<sx1) {
3426 sx4 = sx1;
3427 sy4 = sy1;
3428 sx1 = sx2;
3429 sy1 = sy2;
3430 sx2 = sx4;
3431 sy2 = sy4;
3432 }
3433 if (sx3<sx1) {
3434 sx4 = sx1;
3435 sy4 = sy1;
3436 sx1 = sx3;
3437 sy1 = sy3;
3438 sx3 = sx4;
3439 sy3 = sy4;
3440 }
3441 if (sy2<sy3) {
3442 sx4 = sx2;
3443 sy4 = sy2;
3444 sx2 = sx3;
3445 sy2 = sy3;
3446 sx3 = sx4;
3447 sy3 = sy4;
3448 }
3449 sdx1 = 0;
3450 sdx2 = 0;
3451 sdx3 = 0;
3452 pom1 = sy2-sy1;
3453 pom2 = sx2-sx1;
3454 if (pom2!=0) sdx1 = pom1/pom2;
3455 pom1 = sy1;
3456 pom2 = sx1;
3457 sdy1 = pom1-sdx1*pom2;
3458 pom1 = sy3-sy1;
3459 pom2 = sx3-sx1;
3460 if (pom2!=0) sdx2 = pom1/pom2;
3461 pom1 = sy1;
3462 pom2 = sx1;
3463 sdy2 = pom1-sdx2*pom2;
3464 pom1 = sy3-sy2;
3465 pom2 = sx3-sx2;
3466 if (pom2!=0) sdx3 = pom1/pom2;
3467 pom1 = sy2;
3468 pom2 = sx2;
3469 sdy3 = pom1-sdx3*pom2;
3470 if (sx2<sx3) {
3471 if (sx1!=sx2) {
3472 for (sx4=sx1;sx4<=sx2;sx4++) {
3473 pom1 = sx4;
3474 sdy4 = sdx1*pom1+sdy1;
3475 sy4 = (Int_t)sdy4;
3476 if (sx3!=sx1) {
3477 sdy4 = sdx2*pom1+sdy2;
3478 sy5 = (Int_t)sdy4;
3479 y5 = fEnvelope[sx4];
3480 if (sy4<sy5) {
3481 pom1 = sy4;
3482 sy4 = sy5;
3483 sy5 = (Int_t)pom1;
3484 }
3485 if ((sy4<=y5)||(sy5<y5)) {
3486 sy4 = (Int_t)TMath::Min(sy4,(Int_t)y5);
3487 sy5 = (Int_t)TMath::Min(sy5,(Int_t)y5);
3488 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx4),gPad->PixeltoY(sy5)+1);
3489 }
3490 }
3491 }
3492 }
3493 if (sx2!=sx3) {
3494 for (sx4=sx2;sx4<=sx3;sx4++) {
3495 pom1 = sx4;
3496 sdy4 = sdx3*pom1+sdy3;
3497 sy4 = (Int_t)sdy4;
3498 if (sx3!=sx1) {
3499 sdy4 = sdx2*pom1+sdy2;
3500 sy5 = (Int_t)sdy4;
3501 y5 = fEnvelope[sx4];
3502 if (sy4<sy5) {
3503 pom1 = sy4;
3504 sy4 = sy5;
3505 sy5 = (Int_t)pom1;
3506 }
3507 if ((sy4<=y5)||(sy5<y5)) {
3508 sy4 = (Int_t)TMath::Min(sy4,(Int_t)y5);
3509 sy5 = (Int_t)TMath::Min(sy5,(Int_t)y5);
3510 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx4),gPad->PixeltoY(sy5)+1);
3511 }
3512 }
3513 }
3514 }
3515 } else {
3516 if (sx3!=sx1) {
3517 for (sx4=sx1;sx4<=sx3;sx4++) {
3518 pom1 = sx4;
3519 sdy4 = sdx2*pom1+sdy2;
3520 sy4 = (Int_t)sdy4;
3521 if (sx2!=sx1) {
3522 sdy4 = sdx1*pom1+sdy1;
3523 sy5 = (Int_t)sdy4;
3524 y5 = fEnvelope[sx4];
3525 if (sy4<sy5) {
3526 pom1 = sy4;
3527 sy4 = sy5;
3528 sy5 = (Int_t)pom1;
3529 }
3530 if ((sy4<=y5)||(sy5<y5)) {
3531 sy4 = (Int_t)TMath::Min(sy4,(Int_t)y5);
3532 sy5 = (Int_t)TMath::Min(sy5,(Int_t)y5);
3533 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx4),gPad->PixeltoY(sy5)+1);
3534 }
3535 }
3536 }
3537 }
3538 if (sx2!=sx3) {
3539 for (sx4=sx3;sx4<=sx2;sx4++) {
3540 pom1 = sx4;
3541 sdy4 = sdx3*pom1+sdy3;
3542 sy4 = (Int_t)sdy4;
3543 if (sx2!=sx1) {
3544 sdy4 = sdx1*pom1+sdy1;
3545 sy5 = (Int_t)sdy4;
3546 y5 = fEnvelope[sx4];
3547 if (sy4<sy5) {
3548 pom1 = sy4;
3549 sy4 = sy5;
3550 sy5 = (Int_t)pom1;
3551 }
3552 if ((sy4<=y5)||(sy5<y5)) {
3553 sy4 = (Int_t)TMath::Min(sy4,(Int_t)y5);
3554 sy5 = (Int_t)TMath::Min(sy5,(Int_t)y5);
3555 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx4),gPad->PixeltoY(sy5)+1);
3556 }
3557 }
3558 }
3559 }
3560 }
3561 sx1 = x2;
3562 sy1 = y2;
3563 sx2 = x3;
3564 sy2 = y3;
3565 sx3 = x4;
3566 sy3 = y4;
3567 if (sx2<sx1) {
3568 sx4 = sx1;
3569 sy4 = sy1;
3570 sx1 = sx2;
3571 sy1 = sy2;
3572 sx2 = sx4;
3573 sy2 = sy4;
3574 }
3575 if (sx3<sx1) {
3576 sx4 = sx1;
3577 sy4 = sy1;
3578 sx1 = sx3;
3579 sy1 = sy3;
3580 sx3 = sx4;
3581 sy3 = sy4;
3582 }
3583 if (sy2<sy3) {
3584 sx4 = sx2;
3585 sy4 = sy2;
3586 sx2 = sx3;
3587 sy2 = sy3;
3588 sx3 = sx4;
3589 sy3 = sy4;
3590 }
3591 sdx1 = 0;
3592 sdx2 = 0;
3593 sdx3 = 0;
3594 pom1 = sy2-sy1;
3595 pom2 = sx2-sx1;
3596 if (pom2!=0) sdx1 = pom1/pom2;
3597 pom1 = sy1;
3598 pom2 = sx1;
3599 sdy1 = pom1-sdx1*pom2;
3600 pom1 = sy3-sy1;
3601 pom2 = sx3-sx1;
3602 if (pom2!=0) sdx2 = pom1/pom2;
3603 pom1 = sy1;
3604 pom2 = sx1;
3605 sdy2 = pom1-sdx2*pom2;
3606 pom1 = sy3-sy2;
3607 pom2 = sx3-sx2;
3608 if (pom2!=0) sdx3 = pom1/pom2;
3609 pom1 = sy2;
3610 pom2 = sx2;
3611 sdy3 = pom1-sdx3*pom2;
3612 if (sx2<sx3) {
3613 if (sx1!=sx2) {
3614 for (sx4=sx1;sx4<=sx2;sx4++) {
3615 pom1 = sx4;
3616 sdy4 = sdx1*pom1+sdy1;
3617 sy4 = (Int_t)sdy4;
3618 if (sx3!=sx1) {
3619 sdy4 = sdx2*pom1+sdy2;
3620 sy5 = (Int_t)sdy4;
3621 y5 = fEnvelope[sx4];
3622 if (sy4<sy5) {
3623 pom1 = sy4;
3624 sy4 = sy5;
3625 sy5 = (Int_t)pom1;
3626 }
3627 if ((sy4<=y5)||(sy5<y5)) {
3628 sy4 = (Int_t)TMath::Min(sy4,(Int_t)y5);
3629 sy5 = (Int_t)TMath::Min(sy5,(Int_t)y5);
3630 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx4),gPad->PixeltoY(sy5)+1);
3631 }
3632 }
3633 }
3634 }
3635 if (sx2!=sx3) {
3636 for (sx4=sx2;sx4<=sx3;sx4++) {
3637 pom1 = sx4;
3638 sdy4 = sdx3*pom1+sdy3;
3639 sy4 = (Int_t)sdy4;
3640 if (sx3!=sx1) {
3641 sdy4 = sdx2*pom1+sdy2;
3642 sy5 = (Int_t)sdy4;
3643 y5 = fEnvelope[sx4];
3644 if (sy4<sy5) {
3645 pom1 = sy4;
3646 sy4 = sy5;
3647 sy5 = (Int_t)pom1;
3648 }
3649 if ((sy4<=y5)||(sy5<y5)) {
3650 sy4 = (Int_t)TMath::Min(sy4,(Int_t)y5);
3651 sy5 = (Int_t)TMath::Min(sy5,(Int_t)y5);
3652 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx4),gPad->PixeltoY(sy5)+1);
3653 }
3654 }
3655 }
3656 }
3657 } else {
3658 if (sx3!=sx1) {
3659 for (sx4=sx1;sx4<=sx3;sx4++) {
3660 pom1 = sx4;
3661 sdy4 = sdx2*pom1+sdy2;
3662 sy4 = (Int_t)sdy4;
3663 if (sx2!=sx1) {
3664 sdy4 = sdx1*pom1+sdy1;
3665 sy5 = (Int_t)sdy4;
3666 y5 = fEnvelope[sx4];
3667 if (sy4<sy5) {
3668 pom1 = sy4;
3669 sy4 = sy5;
3670 sy5 = (Int_t)pom1;
3671 }
3672 if ((sy4<=y5)||(sy5<y5)) {
3673 sy4 = (Int_t)TMath::Min(sy4,(Int_t)y5);
3674 sy5 = (Int_t)TMath::Min(sy5,(Int_t)y5);
3675 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx4),gPad->PixeltoY(sy5)+1);
3676 }
3677 }
3678 }
3679 }
3680 if (sx2!=sx3) {
3681 for (sx4=sx3;sx4<=sx2;sx4++) {
3682 pom1 = sx4;
3683 sdy4 = sdx3*pom1+sdy3;
3684 sy4 = (Int_t)sdy4;
3685 if (sx2!=sx1) {
3686 sdy4 = sdx1*pom1+sdy1;
3687 sy5 = (Int_t)sdy4;
3688 y5 = fEnvelope[sx4];
3689 if (sy4<sy5) {
3690 pom1 = sy4;
3691 sy4 = sy5;
3692 sy5 = (Int_t)pom1;
3693 }
3694 if ((sy4<=y5)||(sy5<y5)) {
3695 sy4 = (Int_t)TMath::Min(sy4,(Int_t)y5);
3696 sy5 = (Int_t)TMath::Min(sy5,(Int_t)y5);
3697 line->PaintLine(gPad->PixeltoX(sx4),gPad->PixeltoY(sy4)+1,gPad->PixeltoX(sx4),gPad->PixeltoY(sy5)+1);
3698 }
3699 }
3700 }
3701 }
3702 }
3703 line->SetLineColor(uip);
3704 }
3705 EnvelopeBars(x1,y1,x2,y2);
3706 if (fLine!=0) {
3707 if (fLine==1) {
3708 fXe = x2;
3709 fYe = y2;
3710 }
3711 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3712 }
3713 EnvelopeBars(x2,y2,x3,y3);
3714 if (fLine!=0) {
3715 if (fLine==1) {
3716 fXe = x3;
3717 fYe = y3;
3718 }
3719 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3720 }
3721 EnvelopeBars(x1,y1,x4,y4);
3722 if (fLine!=0) {
3723 if (fLine==1) {
3724 fXe = x4;
3725 fYe = y4;
3726 }
3727 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3728 }
3729 EnvelopeBars(x4,y4,x3,y3);
3730 if (fLine!=0) {
3731 if (fLine==1) {
3732 fXe = x3;
3733 fYe = y3;
3734 }
3735 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3736 }
3737 } else if ((fDisplayMode==kDisplayModeBarsY)&&(((flag!=0)&&(smer==0))||((flag==0)&&(smer!=0)))) {
3738 EnvelopeBars(ix5,iy5,x6,y6);
3739 if (fLine!=0) {
3740 if (fLine==1) {
3741 fXe = x6;
3742 fYe = y6;
3743 }
3744 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3745 }
3746 EnvelopeBars(x1,y1,ix5,iy5);
3747 if (fLine!=0) {
3748 if (fLine==1) {
3749 fXe = ix5;
3750 fYe = iy5;
3751 }
3752 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3753 }
3754 EnvelopeBars(x2,y2,x6,y6);
3755 if (fLine!=0) {
3756 if (fLine==1) {
3757 fXe = x6;
3758 fYe = y6;
3759 }
3760 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3761 }
3763 v = ColorCalculation(dx1,dy1,z4,dx2,dy2,z4,dx4,dy4,z4);
3764 v = v*fLevels+0.5;
3765 iv = fLevels-(Int_t)v;
3766 uip = fNewColorIndex;
3767 ColorModel(iv,ui1,ui2,ui3);
3769 }
3770 EnvelopeBars(x1,y1,x2,y2);
3771 if (fLine!=0) {
3772 if (fLine==1) {
3773 fXe = x2;
3774 fYe = y2;
3775 }
3776 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3777 }
3779 line->SetLineColor(uip);
3780 }
3781 } else if ((fDisplayMode==kDisplayModeBarsX)&&(((flag==0)&&(smer==0))||((flag!=0)&&(smer!=0)))) {
3782 EnvelopeBars(x7,y7,x6,y6);
3783 if (fLine!=0) {
3784 if (fLine==1) {
3785 fXe = x6;
3786 fYe = y6;
3787 }
3788 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3789 }
3790 EnvelopeBars(x2,y2,x6,y6);
3791 if (fLine!=0) {
3792 if (fLine==1) {
3793 fXe = x6;
3794 fYe = y6;
3795 }
3796 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3797 }
3798 EnvelopeBars(x3,y3,x7,y7);
3799 if (fLine!=0) {
3800 if (fLine==1) {
3801 fXe = x7;
3802 fYe = y7;
3803 }
3804 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3805 }
3807 v = ColorCalculation(dx1,dy1,z4,dx2,dy2,z4,dx4,dy4,z4);
3808 v = v*fLevels+0.5;
3809 iv = fLevels-(Int_t)v;
3810 uip = fNewColorIndex;
3811 ColorModel(iv,ui1,ui2,ui3);
3813 }
3814 EnvelopeBars(x3,y3,x2,y2);
3815 if (fLine!=0) {
3816 if (fLine==1) {
3817 fXe = x2;
3818 fYe = y2;
3819 }
3820 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3821 }
3823 line->SetLineColor(uip);
3824 }
3825 }
3826 break;
3827 case kDisplayModeLinesX:
3829 if (((flag==0)&&(smer==0))||((flag!=0)&&(smer!=0))) {
3831 Envelope(x1,y1,x2,y2);
3832 if (fLine!=0) {
3833 if (fLine==1) {
3834 fXe = x2;
3835 fYe = y2;
3836 }
3837 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3838 }
3839 } else {
3840 s1 = q1;
3841 t1 = (Int_t)TMath::Max(q2-1,0);
3842 s2 = q1;
3843 t2 = (Int_t)TMath::Min(q2+2,w2);
3844 if (turni==1) {
3845 i1 = s1;
3846 i2 = s2;
3847 } else {
3848 i1 = (Int_t)TMath::Max(w1-s1,0);
3849 i2 = (Int_t)TMath::Max(w1-s2,0);
3850 }
3851 if (turnj==1) {
3852 j1 = t1;
3853 j2 = t2;
3854 } else {
3855 j1 = (Int_t)TMath::Max(w2-t1,0);
3856 j2 = (Int_t)TMath::Max(w2-t2,0);
3857 }
3858 Transform(i1,j1,0);
3859 x3 = fXt;
3860 y3 = fYt;
3861 Transform(i2,j2,0);
3862 x4 = fXt;
3863 y4 = fYt;
3864 bezx1 = x1+(x2-x1)/3;
3865 bezx2 = x1+2*(x2-x1)/3;
3866 bezy1 = y1+(y2-y3)/6;
3867 bezy2 = y2-(y4-y1)/6;
3868 if (x1<=x2) {
3869 if (bezx1<=x1) {
3870 bezx1 = x1;
3871 bezy1 = y1;
3872 }
3873 if (bezx1>=x2) {
3874 bezx1 = x2;
3875 bezy1 = y2;
3876 }
3877 if (bezx2<=x1) {
3878 bezx2 = x1;
3879 bezy2 = y1;
3880 }
3881 if (bezx2>=x2) {
3882 bezx2 = x2;
3883 bezy2 = y2;
3884 }
3885 fBzX[0] = x1;
3886 fBzY[0] = y1;
3887 fBzX[1] = (Int_t)bezx1;
3888 fBzY[1] = (Int_t)bezy1;
3889 fBzX[2] = (Int_t)bezx2;
3890 fBzY[2] = (Int_t)bezy2;
3891 fBzX[3] = x2;
3892 fBzY[3] = y2;
3893 for (bezf=0;bezf<1.01;bezf+=0.1) {
3894 BezierSmoothing(bezf);
3895 if (bezf==0) {
3896 ibezx1 = (Int_t)(fGbezx+0.5);
3897 ibezy1 = (Int_t)(fGbezy+0.5);
3898 } else {
3899 ibezx2 = ibezx1;
3900 ibezy2 = ibezy1;
3901 ibezx1 = (Int_t)(fGbezx+0.5);
3902 ibezy1 = (Int_t)(fGbezy+0.5);
3903 Envelope(ibezx2,ibezy2,ibezx1,ibezy1);
3904 if (fLine!=0) {
3905 if (fLine==1) {
3906 fXe = ibezx1;
3907 fYe = ibezy1;
3908 }
3909 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3910 }
3911 }
3912 }
3913 } else if (x1>x2) {
3914 if (bezx1>=x1) {
3915 bezx1 = x1;
3916 bezy1 = y1;
3917 }
3918 if (bezx1<=x2) {
3919 bezx1 = x2;
3920 bezy1 = y2;
3921 }
3922 if (bezx2>=x1) {
3923 bezx2 = x1;
3924 bezy2 = y1;
3925 }
3926 if (bezx2<=x2) {
3927 bezx2 = x2;
3928 bezy2 = y2;
3929 }
3930 fBzX[0] = x1;
3931 fBzY[0] = y1;
3932 fBzX[1] = (Int_t)bezx1;
3933 fBzY[1] = (Int_t)bezy1;
3934 fBzX[2] = (Int_t)bezx2;
3935 fBzY[2] = (Int_t)bezy2;
3936 fBzX[3] = x2;
3937 fBzY[3] = y2;
3938 for (bezf=0;bezf<1.01;bezf+=0.1) {
3939 BezierSmoothing(bezf);
3940 if (bezf==0) {
3941 ibezx1 = (Int_t)(fGbezx+0.5);
3942 ibezy1 = (Int_t)(fGbezy+0.5);
3943 } else {
3944 ibezx2 = ibezx1;
3945 ibezy2 = ibezy1;
3946 ibezx1 = (Int_t)(fGbezx+0.5);
3947 ibezy1 = (Int_t)(fGbezy+0.5);
3948 Envelope(ibezx1,ibezy1,ibezx2,ibezy2);
3949 if (fLine!=0) {
3950 if (fLine==1) {
3951 fXe = ibezx2;
3952 fYe = ibezy2;
3953 }
3954 line->PaintLine(gPad->PixeltoX(fXs),gPad->PixeltoY(fYs)+1,gPad->PixeltoX(fXe),gPad->PixeltoY(fYe)+1);
3955 }
3956 }
3957 }
3958 }
3959 }
3960 }
3961 } else {
3962 if ((q1!=q2||smer!=0)&&flag==1) {
3963 s1 = q1+1;
3964 t1 = q2;
3965 s2 = q1;
3966 t2 = q2;
3967 s3 = q1;
3968 t3 = q2+1;
3969 s4 = q1+1;
3970 t4 = q2+1;
3971 if (fShading==kShaded) {
3972 sr1 = s1;
3973 tr1 = (Int_t)TMath::Max(t1-1,0);
3974 sr2 = s2;
3975 tr2 = (Int_t)TMath::Max(t2-1,0);
3976 sr3 = (Int_t)TMath::Max(s2-1,0);
3977 tr3 = t2;
3978 sr4 = (Int_t)TMath::Max(s3-1,0);
3979 tr4 = t3;
3980 sr5 = s3;
3981 tr5 = t3+1;
3982 sr6 = s4;
3983 tr6 = t4+1;
3984 sr7 = s4+1;
3985 tr7 = t4;
3986 sr8 = s1+1;
3987 tr8 = t1;
3988 }
3989 if (turni==1) {
3990 i1 = s1;
3991 i2 = s2;
3992 i3 = s3;
3993 i4 = s4;
3994 } else {
3995 i1 = (Int_t)TMath::Max(w1-s1,0);
3996 i2 = (Int_t)TMath::Max(w1-s2,0);
3997 i3 = (Int_t)TMath::Max(w1-s3,0);
3998 i4 = (Int_t)TMath::Max(w1-s4,0);
3999 if (fShading==kShaded) {
4000 sr1 = (Int_t)TMath::Max(w1-sr1,0);
4001 sr2 = (Int_t)TMath::Max(w1-sr2,0);
4002 sr3 = (Int_t)TMath::Max(w1-sr3,0);
4003 sr4 = (Int_t)TMath::Max(w1-sr4,0);
4004 sr5 = (Int_t)TMath::Max(w1-sr5,0);
4005 sr6 = (Int_t)TMath::Max(w1-sr6,0);
4006 sr7 = (Int_t)TMath::Max(w1-sr7,0);
4007 sr8 = (Int_t)TMath::Max(w1-sr8,0);
4008 }
4009 }
4010 if (turnj==1) {
4011 j1 = t1;
4012 j2 = t2;
4013 j3 = t3;
4014 j4 = t4;
4015 } else {
4016 j1 = (Int_t)TMath::Max(w2-t1,0);
4017 j2 = (Int_t)TMath::Max(w2-t2,0);
4018 j3 = (Int_t)TMath::Max(w2-t3,0);
4019 j4 = (Int_t)TMath::Max(w2-t4,0);
4020 if (fShading==kShaded) {
4021 tr1 = (Int_t)TMath::Max(w2-tr1,0);
4022 tr2 = (Int_t)TMath::Max(w2-tr2,0);
4023 tr3 = (Int_t)TMath::Max(w2-tr3,0);
4024 tr4 = (Int_t)TMath::Max(w2-tr4,0);
4025 tr5 = (Int_t)TMath::Max(w2-tr5,0);
4026 tr6 = (Int_t)TMath::Max(w2-tr6,0);
4027 tr7 = (Int_t)TMath::Max(w2-tr7,0);
4028 tr8 = (Int_t)TMath::Max(w2-tr8,0);
4029 }
4030 }
4031 Transform(i1,j1,0);
4032 x1 = fXt;
4033 y1 = fYt;
4034 dx1 = fDxspline;
4035 dy1 = fDyspline;
4036 z1 = fZ;
4037 Transform(i2,j2,0);
4038 x2 = fXt;
4039 y2 = fYt;
4040 dx2 = fDxspline;
4041 dy2 = fDyspline;
4042 z2 = fZ;
4043 Transform(i3,j3,0);
4044 x3 = fXt;
4045 y3 = fYt;
4046 dx3 = fDxspline;
4047 dy3 = fDyspline;
4048 z3 = fZ;
4049 Transform(i4,j4,0);
4050 x4 = fXt;
4051 y4 = fYt;
4052 dx4 = fDxspline;
4053 dy4 = fDyspline;
4054 z4 = fZ;
4055 Envelope(x1,y1,x2,y2);
4056 Envelope(x2,y2,x3,y3);
4057 xtaz = (dx1+dx2+dx4)/3;
4058 ytaz = (dy1+dy2+dy4)/3;
4059 ztaz = (z1+z2+z4)/3;
4060 v = ColorCalculation(dx1,dy1,z1,dx2,dy2,z2,dx4,dy4,z4);
4061 if (fShading==kShaded) {
4063 if (sr1<0||sr1>w1||tr1<0||tr1>w2) Transform(sr1,tr1,-1);
4064 else Transform(sr1,tr1,0);
4065 dxr1 = fDxspline;
4066 dyr1 = fDyspline;
4067 zr1 = fZ;
4068 if (sr8<0||sr8>w1||tr8<0||tr8>w2) Transform(sr8,tr8,-1);
4069 else Transform(sr8,tr8,0);
4070 dxr2 = fDxspline;
4071 dyr2 = fDyspline;
4072 zr2 = fZ;
4073 v = v+ColorCalculation(dxr1,dyr1,zr1,dx2,dy2,z2,dx1,dy1,z1);
4074 v = v+ColorCalculation(dxr1,dyr1,zr1,dx1,dy1,z1,dxr2,dyr2,zr2);
4075 v = v+ColorCalculation(dxr2,dyr2,zr2,dx1,dy1,z1,dx4,dy4,z4);
4076 v1 = v/4;
4077 if (sr3<0||sr3>w1||tr3<0||tr3>w2) Transform(sr3,tr3,-1);
4078 else Transform(sr3,tr3,0);
4079 dxr1 = fDxspline;
4080 dyr1 = fDyspline;
4081 zr1 = fZ;
4082 if (sr2<0||sr2>w1||tr2<0||tr2>w2) Transform(sr2,tr2,-1);
4083 else Transform(sr2,tr2,0);
4084 dxr2 = fDxspline;
4085 dyr2 = fDyspline;
4086 zr2 = fZ;
4087 v = ColorCalculation(dx1,dy1,z1,dx2,dy2,z2,dx3,dy3,z3);
4088 v = v+ColorCalculation(dx2,dy2,z2,dxr1,dyr1,zr1,dx3,dy3,z3);
4089 v = v+ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dxr1,dyr1,zr1);
4090 v = v+ColorCalculation(dxr2,dyr2,zr2,dx2,dy2,z2,dx1,dy1,z1);
4091 v2 = v/4;
4092 if (sr5<0||sr5>w1||tr5<0||tr5>w2) Transform(sr5,tr5,-1);
4093 else Transform(sr5,tr5,0);
4094 dxr1 = fDxspline;
4095 dyr1 = fDyspline;
4096 zr1 = fZ;
4097 if (sr4<0||sr4>w1||tr4<0||tr4>w2) Transform(sr4,tr4,-1);
4098 else Transform(sr4,tr4,0);
4099 dxr2 = fDxspline;
4100 dyr2 = fDyspline;
4101 zr2 = fZ;
4102 v = ColorCalculation(dx2,dy2,z2,dx3,dy3,z3,dx4,dy4,z4);
4103 v = v+ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr1,dyr1,zr1);
4104 v = v+ColorCalculation(dx3,dy3,z3,dxr2,dyr2,zr2,dxr1,dyr1,zr1);
4105 v = v+ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dx3,dy3,z3);
4106 v3 = v/4;
4107 if (sr7<0||sr7>w1||tr7<0||tr7>w2) Transform(sr7,tr7,-1);
4108 else Transform(sr7,tr7,0);
4109 dxr1 = fDxspline;
4110 dyr1 = fDyspline;
4111 zr1 = fZ;
4112 if (sr6<0||sr6>w1||tr6<0||tr6>w2) Transform(sr6,tr6,-1);
4113 else Transform(sr6,tr6,0);
4114 dxr2 = fDxspline;
4115 dyr2 = fDyspline;
4116 zr2 = fZ;
4117 v = ColorCalculation(dx1,dy1,z1,dx3,dy3,z3,dx4,dy4,z4);
4118 v = v+ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr2,dyr2,zr2);
4119 v = v+ColorCalculation(dx4,dy4,z4,dxr2,dyr2,zr2,dxr1,dyr1,zr1);
4120 v = v+ColorCalculation(dx1,dy1,z1,dx4,dy4,z4,dxr1,dyr1,zr1);
4121 v4 = v/4;
4122 } else {
4123 spriz = ShadowColorCalculation(xtaz,ytaz,ztaz,shad_noise);
4124 v = v+spriz;
4125 v = v/2;
4126 if (sr1<0||sr1>w1||tr1<0||tr1>w2) Transform(sr1,tr1,-1);
4127 else Transform(sr1,tr1,0);
4128 dxr1 = fDxspline;
4129 dyr1 = fDyspline;
4130 zr1 = fZ;
4131 if (sr8<0||sr8>w1||tr8<0||tr8>w2) Transform(sr8,tr8,-1);
4132 else Transform(sr8,tr8,0);
4133 dxr2 = fDxspline;
4134 dyr2 = fDyspline;
4135 zr2 = fZ;
4136 da = (dxr1+dx2+dx1)/3;
4137 db = (dyr1+dy2+dy1)/3;
4138 dc = (zr1+z2+z1)/3;
4139 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4140 v = v+(ColorCalculation(dxr1,dyr1,zr1,dx2,dy2,z2,dx1,dy1,z1)+spriz)/2;
4141 da = (dxr1+dxr2+dx1)/3;
4142 db = (dyr1+dyr2+dy1)/3;
4143 dc = (zr1+zr2+z1)/3;
4144 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4145 v = v+(ColorCalculation(dxr1,dyr1,zr1,dx1,dy1,z1,dxr2,dyr2,zr2)+spriz)/2;
4146 da = (dxr2+dx1+dx4)/3;
4147 db = (dyr2+dy1+dy4)/3;
4148 dc = (zr2+z1+z4)/3;
4149 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4150 v = v+(ColorCalculation(dxr2,dyr2,zr2,dx1,dy1,z1,dx4,dy4,z4)+spriz)/2;
4151 v1 = v/4;
4152 if (sr3<0||sr3>w1||tr3<0||tr3>w2) Transform(sr3,tr3,-1);
4153 else Transform(sr3,tr3,0);
4154 dxr1 = fDxspline;
4155 dyr1 = fDyspline;
4156 zr1 = fZ;
4157 if (sr2<0||sr2>w1||tr2<0||tr2>w2) Transform(sr2,tr2,-1);
4158 else Transform(sr2,tr2,0);
4159 dxr2 = fDxspline;
4160 dyr2 = fDyspline;
4161 zr2 = fZ;
4162 da = (dx1+dx2+dx3)/3;
4163 db = (dy1+dy2+dy3)/3;
4164 dc = (z1+z2+z3)/3;
4165 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4166 v = (ColorCalculation(dx1,dy1,z1,dx2,dy2,z2,dx3,dy3,z3)+spriz)/2;
4167 da = (dx2+dxr1+dx3)/3;
4168 db = (dy2+dyr1+dy3)/3;
4169 dc = (z2+zr1+z3)/3;
4170 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4171 v = v+(ColorCalculation(dx2,dy2,z2,dxr1,dyr1,zr1,dx3,dy3,z3)+spriz)/2;
4172 da = (dx2+dxr2+dxr1)/3;
4173 db = (dy2+dyr2+dyr1)/3;
4174 dc = (z2+zr2+zr1)/3;
4175 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4176 v = v+(ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dxr1,dyr1,zr1)+spriz)/2;
4177 da = (dxr2+dx2+dx1)/3;
4178 db = (dyr2+dy2+dy1)/3;
4179 dc = (zr2+z2+z1)/3;
4180 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4181 v = v+(ColorCalculation(dxr2,dyr2,zr2,dx2,dy2,z2,dx1,dy1,z1)+spriz)/2;
4182 v2 = v/4;
4183 if (sr5<0||sr5>w1||tr5<0||tr5>w2) Transform(sr5,tr5,-1);
4184 else Transform(sr5,tr5,0);
4185 dxr1 = fDxspline;
4186 dyr1 = fDyspline;
4187 zr1 = fZ;
4188 if (sr4<0||sr4>w1||tr4<0||tr4>w2) Transform(sr4,tr4,-1);
4189 else Transform(sr4,tr4,0);
4190 dxr2 = fDxspline;
4191 dyr2 = fDyspline;
4192 zr2 = fZ;
4193 da = (dx2+dx3+dx4)/3;
4194 db = (dy2+dy3+dy4)/3;
4195 dc = (z2+z3+z4)/3;
4196 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4197 v = (ColorCalculation(dx2,dy2,z2,dx3,dy3,z3,dx4,dy4,z4)+spriz)/2;
4198 da = (dx4+dx3+dxr1)/3;
4199 db = (dy4+dy3+dyr1)/3;
4200 dc = (z4+z3+zr1)/3;
4201 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4202 v = v+(ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr1,dyr1,zr1)+spriz)/2;
4203 da = (dx3+dxr2+dxr1)/3;
4204 db = (dy3+dyr2+dyr1)/3;
4205 dc = (z3+zr2+zr1)/3;
4206 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4207 v = v+(ColorCalculation(dx3,dy3,z3,dxr2,dyr2,zr2,dxr1,dyr1,zr1)+spriz)/2;
4208 da = (dx2+dxr2+dx3)/3;
4209 db = (dy2+dyr2+dy3)/3;
4210 dc = (z2+zr2+z3)/3;
4211 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4212 v = v+(ColorCalculation(dx2,dy2,z2,dxr2,dyr2,zr2,dx3,dy3,z3)+spriz)/2;
4213 v3 = v/4;
4214 if (sr7<0||sr7>w1||tr7<0||tr7>w2) Transform(sr7,tr7,-1);
4215 else Transform(sr7,tr7,0);
4216 dxr1 = fDxspline;
4217 dyr1 = fDyspline;
4218 zr1 = fZ;
4219 if (sr6<0||sr6>w1||tr6<0||tr6>w2) Transform(sr6,tr6,-1);
4220 else Transform(sr6,tr6,0);
4221 dxr2 = fDxspline;
4222 dyr2 = fDyspline;
4223 zr2 = fZ;
4224 da = (dx1+dx3+dx4)/3;
4225 db = (dy1+dy3+dy4)/3;
4226 dc = (z1+z3+z4)/3;
4227 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4228 v = (ColorCalculation(dx1,dy1,z1,dx3,dy3,z3,dx4,dy4,z4)+spriz)/2;
4229 da = (dx4+dx3+dxr2)/3;
4230 db = (dy4+dy3+dyr2)/3;
4231 dc = (z4+z3+zr2)/3;
4232 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4233 v = v+(ColorCalculation(dx4,dy4,z4,dx3,dy3,z3,dxr2,dyr2,zr2)+spriz)/2;
4234 da = (dx4+dxr2+dxr1)/3;
4235 db = (dy4+dyr2+dyr1)/3;
4236 dc = (z4+zr2+zr1)/3;
4237 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4238 v = v+(ColorCalculation(dx4,dy4,z4,dxr2,dyr2,zr2,dxr1,dyr1,zr1)+spriz)/2;
4239 da = (dx1+dx4+dxr1)/3;
4240 db = (dy1+dy4+dyr1)/3;
4241 dc = (z1+z4+zr1)/3;
4242 spriz = ShadowColorCalculation(da,db,dc,shad_noise);
4243 v = v+(ColorCalculation(dx1,dy1,z1,dx4,dy4,z4,dxr1,dyr1,zr1)+spriz)/2;
4244 v4 = v/4;
4245 }
4246 }
4247 spriz = 0;
4249 if (fShading==kNotShaded) {
4250 v = v*fLevels+0.5;
4251 iv = fLevels-(Int_t)v;
4252 } else {
4253 v1 = v1*fLevels;
4254 iv1 = fLevels-(Int_t)v1;
4255 v2 = v2*fLevels;
4256 iv2 = fLevels-(Int_t)v2;
4257 v4 = v4*fLevels;
4258 iv4 = fLevels-(Int_t)v4;
4259 }
4260 } else {
4261 spriz = ShadowColorCalculation(xtaz,ytaz,ztaz,shad_noise);
4262 if (fShading==kNotShaded) {
4263