Skip to content
Snippets Groups Projects
Commit 6b8ac8d0 authored by Timur Pocheptsov's avatar Timur Pocheptsov
Browse files

Draw axes for parametric surface.

git-svn-id: http://root.cern.ch/svn/root/trunk@42449 27541ba8-7e3a-0410-8455-c3a389f83636
parent 44a35fe2
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
#ifndef ROOT_TGLUtil #ifndef ROOT_TGLUtil
#include "TGLUtil.h" #include "TGLUtil.h"
#endif #endif
#ifndef ROOT_TAxis
#include "TAxis.h"
#endif
#ifndef ROOT_TF2 #ifndef ROOT_TF2
#include "TF2.h" #include "TF2.h"
#endif #endif
...@@ -107,6 +110,12 @@ private: ...@@ -107,6 +110,12 @@ private:
Int_t fColorScheme; Int_t fColorScheme;
TGLParametricEquation *fEquation; TGLParametricEquation *fEquation;
TAxis fCartesianXAxis;
TAxis fCartesianYAxis;
TAxis fCartesianZAxis;
TGLPlotCoordinates fCartesianCoord;
public: public:
TGLParametricPlot(TGLParametricEquation *equation, TGLPlotCamera *camera); TGLParametricPlot(TGLParametricEquation *equation, TGLPlotCamera *camera);
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
* For the licensing terms see $ROOTSYS/LICENSE. * * For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. * * For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/ *************************************************************************/
#include "Riostream.h"
#include <cctype> #include <cctype>
#ifdef WIN32 #ifdef WIN32
...@@ -19,6 +17,7 @@ ...@@ -19,6 +17,7 @@
#include "TVirtualX.h" #include "TVirtualX.h"
#include "TString.h" #include "TString.h"
#include "TROOT.h" #include "TROOT.h"
#include "TH3.h"
#include "TGLPlotCamera.h" #include "TGLPlotCamera.h"
#include "TGLParametric.h" #include "TGLParametric.h"
...@@ -276,6 +275,12 @@ TGLParametricPlot::TGLParametricPlot(TGLParametricEquation *eq, ...@@ -276,6 +275,12 @@ TGLParametricPlot::TGLParametricPlot(TGLParametricEquation *eq,
fEquation(eq) fEquation(eq)
{ {
//Constructor. //Constructor.
fXAxis = &fCartesianXAxis;
fYAxis = &fCartesianYAxis;
fZAxis = &fCartesianZAxis;
fCoord = &fCartesianCoord;
InitGeometry(); InitGeometry();
InitColors(); InitColors();
} }
...@@ -329,22 +334,30 @@ Bool_t TGLParametricPlot::InitGeometry() ...@@ -329,22 +334,30 @@ Bool_t TGLParametricPlot::InitGeometry()
} }
u += dU; u += dU;
} }
const Double_t xRange = max.X() - min.X(), yRange = max.Y() - min.Y(), zRange = max.Z() - min.Z(); TH3F hist("tmp", "tmp", 2, -1., 1., 2, -1., 1., 2, -1., 1.);
const Double_t xS = 1. / xRange, yS = 1. / yRange, zS = 1. / zRange; hist.SetDirectory(0);
//TAxis has a lot of attributes, defaults, set by ctor,
//are not enough to be correctly painted by TGaxis object.
//To simplify their initialization - I use temporary histogram.
hist.GetXaxis()->Copy(fCartesianXAxis);
hist.GetYaxis()->Copy(fCartesianYAxis);
hist.GetZaxis()->Copy(fCartesianZAxis);
fCartesianXAxis.Set(fMeshSize, min.X(), max.X());
fCartesianYAxis.Set(fMeshSize, min.Y(), max.Y());
fCartesianZAxis.Set(fMeshSize, min.Z(), max.Z());
if (!fCoord->SetRanges(&fCartesianXAxis, &fCartesianYAxis, &fCartesianZAxis))
return kFALSE;
for (Int_t i = 0; i < fMeshSize; ++i) { for (Int_t i = 0; i < fMeshSize; ++i) {
for (Int_t j = 0; j < fMeshSize; ++j) { for (Int_t j = 0; j < fMeshSize; ++j) {
TGLVertex3 &ver = fMesh[i][j].fPos; TGLVertex3 &ver = fMesh[i][j].fPos;
ver.X() *= xS, ver.Y() *= yS, ver.Z() *= zS; ver.X() *= fCoord->GetXScale(), ver.Y() *= fCoord->GetYScale(), ver.Z() *= fCoord->GetZScale();
} }
} }
if (!xRange || !yRange || !zRange) {
Error("InitGeometry", "Zero axis range");
return kFALSE;
}
u = uRange.first; u = uRange.first;
for (Int_t i = 0; i < fMeshSize; ++i) { for (Int_t i = 0; i < fMeshSize; ++i) {
Double_t v = vRange.first; Double_t v = vRange.first;
...@@ -352,18 +365,17 @@ Bool_t TGLParametricPlot::InitGeometry() ...@@ -352,18 +365,17 @@ Bool_t TGLParametricPlot::InitGeometry()
TGLVertex3 &ver = fMesh[i][j].fPos; TGLVertex3 &ver = fMesh[i][j].fPos;
fEquation->EvalVertex(v1, u + dd, v); fEquation->EvalVertex(v1, u + dd, v);
fEquation->EvalVertex(v2, u, v + dd); fEquation->EvalVertex(v2, u, v + dd);
v1.X() *= xS, v1.Y() *= yS, v1.Z() *= zS; v1.X() *= fCoord->GetXScale(), v1.Y() *= fCoord->GetYScale(), v1.Z() *= fCoord->GetZScale();
v2.X() *= xS, v2.Y() *= yS, v2.Z() *= zS; v2.X() *= fCoord->GetXScale(), v2.Y() *= fCoord->GetYScale(), v2.Z() *= fCoord->GetZScale();
Normal2Plane(ver.CArr(), v1.CArr(), v2.CArr(), fMesh[i][j].fNormal.Arr()); Normal2Plane(ver.CArr(), v1.CArr(), v2.CArr(), fMesh[i][j].fNormal.Arr());
v += dV; v += dV;
} }
u += dU; u += dU;
} }
using Rgl::Range_t; fBackBox.SetPlotBox(fCoord->GetXRangeScaled(),
fBackBox.SetPlotBox(Range_t(min.X() * xS, max.X() * xS), fCoord->GetYRangeScaled(),
Range_t(min.Y() * yS, max.Y() * yS), fCoord->GetZRangeScaled());
Range_t(min.Z() * zS, max.Z() * zS));
if (fCamera) fCamera->SetViewVolume(fBackBox.Get3DBox()); if (fCamera) fCamera->SetViewVolume(fBackBox.Get3DBox());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment