Index: graf3d/gl/src/TGLParametric.cxx =================================================================== --- graf3d/gl/src/TGLParametric.cxx (revision 42013) +++ graf3d/gl/src/TGLParametric.cxx (working copy) @@ -114,7 +114,8 @@ fURange(uMin, uMax), fVRange(vMin, vMax), fConstrained(kFALSE), - fModified(kFALSE) + fModified(kFALSE), + GetColor(0) { //Surface is defined by three strings. //ROOT does not use exceptions in ctors, @@ -163,7 +164,7 @@ fURange(uMin, uMax), fVRange(vMin, vMax), fConstrained(kFALSE), - fModified(kFALSE) + fModified(kFALSE), GetColor(0) { //Surface defined by user's function (see ParametricEquation_t declaration in TGLParametricEquation.h) if (!fEquation) { @@ -172,6 +173,23 @@ } } +TGLParametricEquation::TGLParametricEquation(const TString &name, ParametricEquation_t equation, + void(*ColorFunc)(Double_t &color,Double_t u, Double_t v), + Double_t uMin, Double_t uMax, Double_t vMin, Double_t vMax) + : TNamed(name, name), + fEquation(equation), + fURange(uMin, uMax), + fVRange(vMin, vMax), + fConstrained(kFALSE), + fModified(kFALSE), GetColor(ColorFunc) +{ + //Surface defined by user's function (see ParametricEquation_t declaration in TGLParametricEquation.h) + if (!fEquation) { + Error("TGLParametricEquation", "Function ptr is null"); + MakeZombie(); + } +} + //______________________________________________________________________________ Rgl::Range_t TGLParametricEquation::GetURange()const { @@ -273,13 +291,14 @@ fMeshSize(90), fShowMesh(kFALSE), fColorScheme(4), - fEquation(eq) + fEquation(eq) { //Constructor. InitGeometry(); InitColors(); } + //______________________________________________________________________________ Bool_t TGLParametricPlot::InitGeometry() { @@ -593,15 +612,48 @@ if (fColorScheme == -1) return; - const Rgl::Range_t uRange(fEquation->GetURange()); + if(!fEquation->GetColor){ + const Rgl::Range_t uRange(fEquation->GetURange()); - const Float_t dU = Float_t((uRange.second - uRange.first) / (fMeshSize - 1)); - Float_t u = Float_t(uRange.first); - - for (Int_t i = 0; i < fMeshSize; ++i) { - for (Int_t j = 0; j < fMeshSize; ++j) + const Float_t dU = Float_t((uRange.second - uRange.first) / (fMeshSize - 1)); + Float_t u = Float_t(uRange.first); + + for (Int_t i = 0; i < fMeshSize; ++i) { + for (Int_t j = 0; j < fMeshSize; ++j) Rgl::GetColor(u, uRange.first, uRange.second, fColorScheme, fMesh[i][j].fRGBA); - u += dU; + u += dU; + } + } else { + const Rgl::Range_t uRange(fEquation->GetURange()); + const Rgl::Range_t vRange(fEquation->GetVRange()); + + const Double_t dU = (uRange.second - uRange.first) / (fMeshSize - 1); + const Double_t dV = (vRange.second - vRange.first) / (fMeshSize - 1); + Double_t u = uRange.first; + Double_t min,max,col; + fEquation->GetColor(min, uRange.first, vRange.first); + max=min; + using namespace TMath; + for (Int_t i = 0; i < fMeshSize; ++i) { + Double_t v = vRange.first; + for (Int_t j = 0; j < fMeshSize; ++j) { + fEquation->GetColor(col,u,v); + if(col>max) max=col; + if(colGetColor(col,u,v); + Rgl::GetColor(col, min,max, fColorScheme, fMesh[i][j].fRGBA); + v += dV; + } + u += dU; + } } }