00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <typeinfo>
00013
00014 #include "TVirtualGL.h"
00015 #include "KeySymbols.h"
00016 #include "TVirtualX.h"
00017 #include "Buttons.h"
00018 #include "TString.h"
00019 #include "TROOT.h"
00020 #include "TColor.h"
00021 #include "TMath.h"
00022 #include "TH3.h"
00023 #include "TF3.h"
00024
00025 #include "TGLMarchingCubes.h"
00026 #include "TGLPlotCamera.h"
00027 #include "TGLTF3Painter.h"
00028 #include "TGLIncludes.h"
00029
00030
00031
00032
00033
00034 ClassImp(TGLTF3Painter)
00035
00036
00037 TGLTF3Painter::TGLTF3Painter(TF3 *fun, TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord)
00038 : TGLPlotPainter(hist, camera, coord, kFALSE, kFALSE, kFALSE),
00039 fStyle(kDefault),
00040 fF3(fun),
00041 fXOZSlice("XOZ", (TH3 *)hist, fun, coord, &fBackBox, TGLTH3Slice::kXOZ),
00042 fYOZSlice("YOZ", (TH3 *)hist, fun, coord, &fBackBox, TGLTH3Slice::kYOZ),
00043 fXOYSlice("XOY", (TH3 *)hist, fun, coord, &fBackBox, TGLTH3Slice::kXOY)
00044 {
00045
00046 }
00047
00048
00049 char *TGLTF3Painter::GetPlotInfo(Int_t , Int_t )
00050 {
00051
00052 static char mess[] = { "fun3" };
00053 return mess;
00054 }
00055
00056
00057 Bool_t TGLTF3Painter::InitGeometry()
00058 {
00059
00060 fCoord->SetCoordType(kGLCartesian);
00061
00062 if (!fCoord->SetRanges(fHist, kFALSE, kTRUE))
00063 return kFALSE;
00064
00065 fBackBox.SetPlotBox(fCoord->GetXRangeScaled(), fCoord->GetYRangeScaled(), fCoord->GetZRangeScaled());
00066 if (fCamera) fCamera->SetViewVolume(fBackBox.Get3DBox());
00067
00068
00069 fMesh.ClearMesh();
00070
00071 Rgl::Mc::TMeshBuilder<TF3, Double_t> builder(kFALSE);
00072
00073 Rgl::Mc::TGridGeometry<Double_t> geom(fXAxis, fYAxis, fZAxis, fCoord->GetXScale(),
00074 fCoord->GetYScale(), fCoord->GetZScale(),
00075 Rgl::Mc::TGridGeometry<Double_t>::kBinEdge);
00076
00077 builder.BuildMesh(fF3, geom, &fMesh, 0.2);
00078
00079 if (fCoord->Modified()) {
00080 fUpdateSelection = kTRUE;
00081 const TGLVertex3 &vertex = fBackBox.Get3DBox()[0];
00082 fXOZSectionPos = vertex.Y();
00083 fYOZSectionPos = vertex.X();
00084 fXOYSectionPos = vertex.Z();
00085 fCoord->ResetModified();
00086 }
00087
00088 return kTRUE;
00089 }
00090
00091
00092 void TGLTF3Painter::StartPan(Int_t px, Int_t py)
00093 {
00094
00095 fMousePosition.fX = px;
00096 fMousePosition.fY = fCamera->GetHeight() - py;
00097 fCamera->StartPan(px, py);
00098 fBoxCut.StartMovement(px, fCamera->GetHeight() - py);
00099 }
00100
00101
00102 void TGLTF3Painter::Pan(Int_t px, Int_t py)
00103 {
00104
00105
00106
00107 if (fSelectedPart >= fSelectionBase) {
00108 SaveModelviewMatrix();
00109 SaveProjectionMatrix();
00110
00111 fCamera->SetCamera();
00112 fCamera->Apply(fPadPhi, fPadTheta);
00113 fCamera->Pan(px, py);
00114
00115 RestoreProjectionMatrix();
00116 RestoreModelviewMatrix();
00117 } else if (fSelectedPart > 0) {
00118
00119
00120 py = fCamera->GetHeight() - py;
00121
00122 SaveModelviewMatrix();
00123 SaveProjectionMatrix();
00124
00125 fCamera->SetCamera();
00126 fCamera->Apply(fPadPhi, fPadTheta);
00127
00128 if (!fHighColor) {
00129 if (fBoxCut.IsActive() && (fSelectedPart >= kXAxis && fSelectedPart <= kZAxis)) {
00130 fBoxCut.MoveBox(px, py, fSelectedPart);
00131 } else {
00132
00133 }
00134 } else {
00135
00136 }
00137
00138 RestoreProjectionMatrix();
00139 RestoreModelviewMatrix();
00140 }
00141
00142 fMousePosition.fX = px, fMousePosition.fY = py;
00143 fUpdateSelection = kTRUE;
00144 }
00145
00146
00147 void TGLTF3Painter::AddOption(const TString &)
00148 {
00149
00150 }
00151
00152
00153 void TGLTF3Painter::ProcessEvent(Int_t event, Int_t , Int_t py)
00154 {
00155
00156 if (event == kKeyPress) {
00157 if (py == kKey_s || py == kKey_S) {
00158 fStyle < kMaple2 ? fStyle = ETF3Style(fStyle + 1) : fStyle = kDefault;
00159 } else if (py == kKey_c || py == kKey_C) {
00160 if (fHighColor)
00161 Info("ProcessEvent", "Cut box does not work in high color, please, switch to true color");
00162 else {
00163 fBoxCut.TurnOnOff();
00164 fUpdateSelection = kTRUE;
00165 }
00166 }
00167 } else if (event == kButton1Double && (fBoxCut.IsActive() || HasSections())) {
00168 if (fBoxCut.IsActive())
00169 fBoxCut.TurnOnOff();
00170 const TGLVertex3 *frame = fBackBox.Get3DBox();
00171 fXOZSectionPos = frame[0].Y();
00172 fYOZSectionPos = frame[0].X();
00173 fXOYSectionPos = frame[0].Z();
00174
00175 if (!gVirtualX->IsCmdThread())
00176 gROOT->ProcessLineFast(Form("((TGLPlotPainter *)0x%lx)->Paint()", (ULong_t)this));
00177 else
00178 Paint();
00179 }
00180 }
00181
00182
00183 void TGLTF3Painter::InitGL() const
00184 {
00185
00186 glEnable(GL_LIGHTING);
00187 glEnable(GL_LIGHT0);
00188 glEnable(GL_DEPTH_TEST);
00189 glDisable(GL_CULL_FACE);
00190 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
00191 }
00192
00193
00194 void TGLTF3Painter::DeInitGL() const
00195 {
00196
00197 glDisable(GL_LIGHTING);
00198 glDisable(GL_LIGHT0);
00199 glDisable(GL_DEPTH_TEST);
00200 glDisable(GL_CULL_FACE);
00201 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
00202 }
00203
00204
00205 void TGLTF3Painter::DrawToSelectionBuffer() const
00206 {
00207
00208 Rgl::ObjectIDToColor(fSelectionBase, fHighColor);
00209
00210 if (!fBoxCut.IsActive())
00211 Rgl::DrawMesh(fMesh.fVerts, fMesh.fTris);
00212 else
00213 Rgl::DrawMesh(fMesh.fVerts, fMesh.fTris, fBoxCut);
00214 }
00215
00216
00217 void TGLTF3Painter::DrawDefaultPlot() const
00218 {
00219
00220 if (HasSections()) {
00221 glEnable(GL_BLEND);
00222 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00223 glDepthMask(GL_FALSE);
00224 }
00225
00226 SetSurfaceColor();
00227
00228 if (!fBoxCut.IsActive()) {
00229 Rgl::DrawMesh(fMesh.fVerts, fMesh.fNorms, fMesh.fTris);
00230 } else {
00231 Rgl::DrawMesh(fMesh.fVerts, fMesh.fNorms, fMesh.fTris, fBoxCut);
00232 }
00233
00234 if (HasSections()) {
00235 glDisable(GL_BLEND);
00236 glDepthMask(GL_TRUE);
00237 }
00238 }
00239
00240
00241 void TGLTF3Painter::DrawMaplePlot() const
00242 {
00243
00244
00245 const TGLDisableGuard lightGuard(GL_LIGHTING);
00246
00247 if (HasSections() && fStyle < kMaple2) {
00248 glEnable(GL_BLEND);
00249 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00250 glDepthMask(GL_FALSE);
00251 }
00252
00253 if (fStyle == kMaple1) {
00254 glEnable(GL_POLYGON_OFFSET_FILL);
00255 glPolygonOffset(1.f, 1.f);
00256 } else if (fStyle == kMaple2)
00257 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
00258
00259 if(!fBoxCut.IsActive())
00260 Rgl::DrawMapleMesh(fMesh.fVerts, fMesh.fNorms, fMesh.fTris);
00261 else
00262 Rgl::DrawMapleMesh(fMesh.fVerts, fMesh.fNorms, fMesh.fTris, fBoxCut);
00263
00264 if (fStyle == kMaple1) {
00265
00266 glDisable(GL_POLYGON_OFFSET_FILL);
00267 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
00268 glColor4d(0., 0., 0., 0.25);
00269
00270 if(!fBoxCut.IsActive())
00271 Rgl::DrawMesh(fMesh.fVerts, fMesh.fTris);
00272 else
00273 Rgl::DrawMesh(fMesh.fVerts, fMesh.fTris, fBoxCut);
00274
00275 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00276 } else if (fStyle == kMaple2)
00277 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00278
00279 if (HasSections() && fStyle < kMaple2) {
00280 glDisable(GL_BLEND);
00281 glDepthMask(GL_TRUE);
00282 }
00283 }
00284
00285
00286 void TGLTF3Painter::DrawPlot() const
00287 {
00288
00289
00290
00291 const Rgl::PlotTranslation trGuard(this);
00292
00293 fBackBox.DrawBox(fSelectedPart, fSelectionPass, fZLevels, fHighColor);
00294 DrawSections();
00295
00296 if (fSelectionPass) {
00297 DrawToSelectionBuffer();
00298 } else if (fStyle == kDefault) {
00299 DrawDefaultPlot();
00300 } else {
00301 DrawMaplePlot();
00302 }
00303
00304 if (fBoxCut.IsActive())
00305 fBoxCut.DrawBox(fSelectionPass, fSelectedPart);
00306 }
00307
00308
00309 void TGLTF3Painter::SetSurfaceColor() const
00310 {
00311
00312 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.15f};
00313
00314 if (fF3->GetFillColor() != kWhite)
00315 if (const TColor *c = gROOT->GetColor(fF3->GetFillColor()))
00316 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
00317
00318 glMaterialfv(GL_BACK, GL_DIFFUSE, diffColor);
00319 diffColor[0] /= 2, diffColor[1] /= 2, diffColor[2] /= 2;
00320 glMaterialfv(GL_FRONT, GL_DIFFUSE, diffColor);
00321 const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
00322 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
00323 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
00324 }
00325
00326
00327 Bool_t TGLTF3Painter::HasSections() const
00328 {
00329
00330 return fXOZSectionPos > fBackBox.Get3DBox()[0].Y() ||
00331 fYOZSectionPos > fBackBox.Get3DBox()[0].X() ||
00332 fXOYSectionPos > fBackBox.Get3DBox()[0].Z();
00333 }
00334
00335
00336 void TGLTF3Painter::DrawSectionXOZ() const
00337 {
00338
00339 if (fSelectionPass)
00340 return;
00341 fXOZSlice.DrawSlice(fXOZSectionPos / fCoord->GetYScale());
00342 }
00343
00344
00345 void TGLTF3Painter::DrawSectionYOZ() const
00346 {
00347
00348 if (fSelectionPass)
00349 return;
00350 fYOZSlice.DrawSlice(fYOZSectionPos / fCoord->GetXScale());
00351 }
00352
00353
00354 void TGLTF3Painter::DrawSectionXOY() const
00355 {
00356
00357 if (fSelectionPass)
00358 return;
00359 fXOYSlice.DrawSlice(fXOYSectionPos / fCoord->GetZScale());
00360 }
00361
00362
00363
00364
00365
00366
00367 ClassImp(TGLIsoPainter)
00368
00369
00370 TGLIsoPainter::TGLIsoPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord)
00371 : TGLPlotPainter(hist, camera, coord, kFALSE, kFALSE, kFALSE),
00372 fXOZSlice("XOZ", (TH3 *)hist, coord, &fBackBox, TGLTH3Slice::kXOZ),
00373 fYOZSlice("YOZ", (TH3 *)hist, coord, &fBackBox, TGLTH3Slice::kYOZ),
00374 fXOYSlice("XOY", (TH3 *)hist, coord, &fBackBox, TGLTH3Slice::kXOY),
00375 fInit(kFALSE)
00376 {
00377
00378 if (hist->GetDimension() < 3)
00379 Error("TGLIsoPainter::TGLIsoPainter", "Wrong type of histogramm, must have 3 dimensions");
00380 }
00381
00382
00383 char *TGLIsoPainter::GetPlotInfo(Int_t , Int_t )
00384 {
00385
00386
00387 static char mess[] = { "iso" };
00388 return mess;
00389 }
00390
00391
00392 Bool_t TGLIsoPainter::InitGeometry()
00393 {
00394
00395 if (fHist->GetDimension() < 3) {
00396 Error("TGLIsoPainter::TGLIsoPainter", "Wrong type of histogramm, must have 3 dimensions");
00397 return kFALSE;
00398 }
00399
00400
00401 if (fInit)
00402 return kTRUE;
00403
00404
00405 fCoord->SetCoordType(kGLCartesian);
00406 if (!fCoord->SetRanges(fHist, kFALSE, kTRUE))
00407 return kFALSE;
00408
00409 fBackBox.SetPlotBox(fCoord->GetXRangeScaled(), fCoord->GetYRangeScaled(), fCoord->GetZRangeScaled());
00410 if (fCamera) fCamera->SetViewVolume(fBackBox.Get3DBox());
00411
00412
00413 if (!fIsos.empty())
00414 fCache.splice(fCache.begin(), fIsos);
00415
00416 UInt_t nContours = fHist->GetContour();
00417
00418 if (nContours > 1) {
00419 fColorLevels.resize(nContours);
00420 FindMinMax();
00421
00422 if (fHist->TestBit(TH1::kUserContour)) {
00423
00424 for (UInt_t i = 0; i < nContours; ++i)
00425 fColorLevels[i] = fHist->GetContourLevelPad(i);
00426 } else {
00427
00428 const Double_t isoStep = (fMinMax.second - fMinMax.first) / nContours;
00429 for (UInt_t i = 0; i < nContours; ++i)
00430 fColorLevels[i] = fMinMax.first + i * isoStep;
00431 }
00432
00433 fPalette.GeneratePalette(nContours, fMinMax, kFALSE);
00434 } else {
00435
00436 fColorLevels.resize(nContours = 1);
00437 fColorLevels[0] = fHist->GetSumOfWeights() / (fHist->GetNbinsX() * fHist->GetNbinsY() * fHist->GetNbinsZ());
00438 }
00439
00440 MeshIter_t firstMesh = fCache.begin();
00441
00442
00443 for (UInt_t i = 0; i < nContours; ++i) {
00444 if (firstMesh != fCache.end()) {
00445
00446 SetMesh(*firstMesh, fColorLevels[i]);
00447 MeshIter_t next = firstMesh;
00448 ++next;
00449 fIsos.splice(fIsos.begin(), fCache, firstMesh);
00450 firstMesh = next;
00451 } else {
00452
00453
00454
00455
00456 Mesh_t newMesh;
00457 SetMesh(newMesh, fColorLevels[i]);
00458 fIsos.push_back(fDummyMesh);
00459 fIsos.back().Swap(newMesh);
00460 }
00461 }
00462
00463 if (fCoord->Modified()) {
00464 fUpdateSelection = kTRUE;
00465 fXOZSectionPos = fBackBox.Get3DBox()[0].Y();
00466 fYOZSectionPos = fBackBox.Get3DBox()[0].X();
00467 fXOYSectionPos = fBackBox.Get3DBox()[0].Z();
00468 fCoord->ResetModified();
00469 }
00470
00471
00472 fInit = kTRUE;
00473
00474 return kTRUE;
00475
00476 }
00477
00478
00479 void TGLIsoPainter::StartPan(Int_t px, Int_t py)
00480 {
00481
00482 fMousePosition.fX = px;
00483 fMousePosition.fY = fCamera->GetHeight() - py;
00484 fCamera->StartPan(px, py);
00485 fBoxCut.StartMovement(px, fCamera->GetHeight() - py);
00486 }
00487
00488
00489 void TGLIsoPainter::Pan(Int_t px, Int_t py)
00490 {
00491
00492
00493
00494
00495 if (fSelectedPart >= fSelectionBase) {
00496 SaveModelviewMatrix();
00497 SaveProjectionMatrix();
00498
00499 fCamera->SetCamera();
00500 fCamera->Apply(fPadPhi, fPadTheta);
00501 fCamera->Pan(px, py);
00502
00503 RestoreProjectionMatrix();
00504 RestoreModelviewMatrix();
00505 } else if (fSelectedPart > 0) {
00506
00507
00508 py = fCamera->GetHeight() - py;
00509
00510 SaveModelviewMatrix();
00511 SaveProjectionMatrix();
00512
00513 fCamera->SetCamera();
00514 fCamera->Apply(fPadPhi, fPadTheta);
00515
00516 if (!fHighColor) {
00517 if (fBoxCut.IsActive() && (fSelectedPart >= kXAxis && fSelectedPart <= kZAxis)) {
00518 fBoxCut.MoveBox(px, py, fSelectedPart);
00519 } else {
00520
00521 }
00522 } else {
00523
00524 }
00525
00526 RestoreProjectionMatrix();
00527 RestoreModelviewMatrix();
00528
00529 }
00530
00531 fMousePosition.fX = px, fMousePosition.fY = py;
00532 fUpdateSelection = kTRUE;
00533 }
00534
00535
00536 void TGLIsoPainter::AddOption(const TString &)
00537 {
00538
00539 }
00540
00541
00542 void TGLIsoPainter::ProcessEvent(Int_t event, Int_t , Int_t py)
00543 {
00544
00545 if (event == kKeyPress) {
00546 if (py == kKey_c || py == kKey_C) {
00547 if (fHighColor)
00548 Info("ProcessEvent", "Cut box does not work in high color, please, switch to true color");
00549 else {
00550 fBoxCut.TurnOnOff();
00551 fUpdateSelection = kTRUE;
00552 }
00553 }
00554 } else if (event == kButton1Double && (fBoxCut.IsActive() || HasSections())) {
00555 if (fBoxCut.IsActive())
00556 fBoxCut.TurnOnOff();
00557 const TGLVertex3 *frame = fBackBox.Get3DBox();
00558 fXOZSectionPos = frame[0].Y();
00559 fYOZSectionPos = frame[0].X();
00560 fXOYSectionPos = frame[0].Z();
00561
00562 if (!gVirtualX->IsCmdThread())
00563 gROOT->ProcessLineFast(Form("((TGLPlotPainter *)0x%lx)->Paint()", (ULong_t)this));
00564 else
00565 Paint();
00566 }
00567 }
00568
00569
00570 void TGLIsoPainter::InitGL() const
00571 {
00572
00573 glEnable(GL_LIGHTING);
00574 glEnable(GL_LIGHT0);
00575 glEnable(GL_DEPTH_TEST);
00576 glDisable(GL_CULL_FACE);
00577 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
00578 }
00579
00580
00581 void TGLIsoPainter::DeInitGL() const
00582 {
00583
00584 glDisable(GL_LIGHTING);
00585 glDisable(GL_LIGHT0);
00586 glDisable(GL_DEPTH_TEST);
00587 glDisable(GL_CULL_FACE);
00588 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
00589 }
00590
00591
00592 void TGLIsoPainter::DrawPlot() const
00593 {
00594
00595
00596
00597 const Rgl::PlotTranslation trGuard(this);
00598
00599
00600 fBackBox.DrawBox(fSelectedPart, fSelectionPass, fZLevels, fHighColor);
00601 DrawSections();
00602
00603 if (fIsos.size() != fColorLevels.size()) {
00604 Error("TGLIsoPainter::DrawPlot", "Non-equal number of levels and isos");
00605 return;
00606 }
00607
00608 if (!fSelectionPass && HasSections()) {
00609
00610
00611
00612
00613 glEnable(GL_BLEND);
00614 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00615 glDepthMask(GL_FALSE);
00616 }
00617
00618 UInt_t colorInd = 0;
00619 ConstMeshIter_t iso = fIsos.begin();
00620
00621 for (; iso != fIsos.end(); ++iso, ++colorInd)
00622 DrawMesh(*iso, colorInd);
00623
00624 if (!fSelectionPass && HasSections()) {
00625 glDisable(GL_BLEND);
00626 glDepthMask(GL_TRUE);
00627 }
00628
00629 if (fBoxCut.IsActive())
00630 fBoxCut.DrawBox(fSelectionPass, fSelectedPart);
00631 }
00632
00633
00634 void TGLIsoPainter::DrawSectionXOZ() const
00635 {
00636
00637 if (fSelectionPass)
00638 return;
00639 fXOZSlice.DrawSlice(fXOZSectionPos / fCoord->GetYScale());
00640 }
00641
00642
00643 void TGLIsoPainter::DrawSectionYOZ() const
00644 {
00645
00646 if (fSelectionPass)
00647 return;
00648 fYOZSlice.DrawSlice(fYOZSectionPos / fCoord->GetXScale());
00649 }
00650
00651
00652 void TGLIsoPainter::DrawSectionXOY() const
00653 {
00654
00655 if (fSelectionPass)
00656 return;
00657 fXOYSlice.DrawSlice(fXOYSectionPos / fCoord->GetZScale());
00658 }
00659
00660
00661 Bool_t TGLIsoPainter::HasSections() const
00662 {
00663
00664 return fXOZSectionPos > fBackBox.Get3DBox()[0].Y() || fYOZSectionPos > fBackBox.Get3DBox()[0].X() ||
00665 fXOYSectionPos > fBackBox.Get3DBox()[0].Z();
00666 }
00667
00668
00669 void TGLIsoPainter::SetSurfaceColor(Int_t ind) const
00670 {
00671
00672 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.25f};
00673
00674 if (fColorLevels.size() == 1) {
00675 if (fHist->GetFillColor() != kWhite)
00676 if (const TColor *c = gROOT->GetColor(fHist->GetFillColor()))
00677 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
00678 } else {
00679 const UChar_t *color = fPalette.GetColour(ind);
00680 diffColor[0] = color[0] / 255.;
00681 diffColor[1] = color[1] / 255.;
00682 diffColor[2] = color[2] / 255.;
00683 }
00684
00685 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
00686 const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
00687 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
00688 diffColor[0] /= 3.5, diffColor[1] /= 3.5, diffColor[2] /= 3.5;
00689 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, diffColor);
00690 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 30.f);
00691 }
00692
00693
00694 void TGLIsoPainter::SetMesh(Mesh_t &m, Double_t isoValue)
00695 {
00696
00697 Rgl::Mc::TGridGeometry<Float_t> geom(fXAxis, fYAxis, fZAxis, fCoord->GetXScale(),
00698 fCoord->GetYScale(), fCoord->GetZScale());
00699
00700 m.ClearMesh();
00701
00702 if (typeid(*fHist) == typeid(TH3C)) {
00703 Rgl::Mc::TMeshBuilder<TH3C, Float_t> builder(kTRUE);
00704 builder.BuildMesh(static_cast<TH3C *>(fHist), geom, &m, isoValue);
00705 } else if (typeid(*fHist) == typeid(TH3S)) {
00706 Rgl::Mc::TMeshBuilder<TH3S, Float_t> builder(kTRUE);
00707 builder.BuildMesh(static_cast<TH3S *>(fHist), geom, &m, isoValue);
00708 } else if (typeid(*fHist) == typeid(TH3I)) {
00709 Rgl::Mc::TMeshBuilder<TH3I, Float_t> builder(kTRUE);
00710 builder.BuildMesh(static_cast<TH3I *>(fHist), geom, &m, isoValue);
00711 } else if (typeid(*fHist) == typeid(TH3F)) {
00712 Rgl::Mc::TMeshBuilder<TH3F, Float_t> builder(kTRUE);
00713 builder.BuildMesh(static_cast<TH3F *>(fHist), geom, &m, isoValue);
00714 } else if (typeid(*fHist) == typeid(TH3D)) {
00715 Rgl::Mc::TMeshBuilder<TH3D, Float_t> builder(kTRUE);
00716 builder.BuildMesh(static_cast<TH3D *>(fHist), geom, &m, isoValue);
00717 }
00718 }
00719
00720
00721 void TGLIsoPainter::DrawMesh(const Mesh_t &m, Int_t level) const
00722 {
00723
00724 if (!fSelectionPass)
00725 SetSurfaceColor(level);
00726
00727 if (!fBoxCut.IsActive()) {
00728 if (!fSelectionPass)
00729 Rgl::DrawMesh(m.fVerts, m.fNorms, m.fTris);
00730 else {
00731 Rgl::ObjectIDToColor(fSelectionBase, fHighColor);
00732 Rgl::DrawMesh(m.fVerts, m.fTris);
00733 }
00734 } else {
00735 if (!fSelectionPass)
00736 Rgl::DrawMesh(m.fVerts, m.fNorms, m.fTris, fBoxCut);
00737 else {
00738 Rgl::ObjectIDToColor(fSelectionBase, fHighColor);
00739 Rgl::DrawMesh(m.fVerts, m.fTris, fBoxCut);
00740 }
00741 }
00742 }
00743
00744
00745 void TGLIsoPainter::FindMinMax()
00746 {
00747
00748 fMinMax.first = fHist->GetBinContent(fXAxis->GetFirst(), fYAxis->GetFirst(), fZAxis->GetFirst());
00749 fMinMax.second = fMinMax.first;
00750
00751 for (Int_t i = fXAxis->GetFirst(), ei = fXAxis->GetLast(); i <= ei; ++i) {
00752 for (Int_t j = fYAxis->GetFirst(), ej = fYAxis->GetLast(); j <= ej; ++j) {
00753 for (Int_t k = fZAxis->GetFirst(), ek = fZAxis->GetLast(); k <= ek; ++k) {
00754 const Double_t binContent = fHist->GetBinContent(i, j, k);
00755 fMinMax.first = TMath::Min(binContent, fMinMax.first);
00756 fMinMax.second = TMath::Max(binContent, fMinMax.second);
00757 }
00758 }
00759 }
00760 }