5 #include <Reve/RGTopFrame.h>
15 //______________________________________________________________________
21 PointSet::PointSet(Int_t n_points) :
22 TPointSet3D(n_points),
23 RenderElement(fMarkerColor)
28 PointSet::PointSet(const Text_t* name, Int_t n_points) :
29 TPointSet3D(n_points),
30 RenderElement(fMarkerColor)
36 PointSet::PointSet(const Text_t* name, TTree* tree,
37 TreeVarType_e tv_type) :
38 TPointSet3D(tree->GetSelectedRows()),
39 RenderElement(fMarkerColor)
41 static const Exc_t eH("PointSet::PointSet ");
45 Double_t *vx = tree->GetV1(), *vy = tree->GetV2(), *vz = tree->GetV3();
46 Long64_t nr = tree->GetSelectedRows();
51 SetNextPoint(*vx, *vy, *vz);
57 SetNextPoint(*vx * TMath::Cos(*vy), *vx * TMath::Sin(*vy), *vz);
62 throw(eH + "unknown tree variable type.");
66 /**************************************************************************/
68 void PointSet::Reset(Int_t n_points)
72 if(fN) fP = new Float_t [3*fN];
73 memset(fP, 0, 3*fN*sizeof(Float_t));
78 /**************************************************************************/
80 void PointSet::Paint(Option_t* option)
82 if(fRnrElement == false) return;
84 TPointSet3D::Paint(option);
87 /**************************************************************************/
88 /**************************************************************************/
90 //______________________________________________________________________
94 ClassImp(PointSetArray)
96 PointSetArray::PointSetArray(const Text_t* name,
97 const Text_t* title) :
98 TNamed(name, title), RenderElementListBase(fColor)
104 PointSetArray::~PointSetArray()
109 /**************************************************************************/
110 /**************************************************************************/
112 void PointSetArray::InitBins(TGListTreeItem* tree_item, const Text_t* quant_name,
113 Int_t nbins, Double_t min, Double_t max)
115 fQuantName = quant_name;
117 fMin = fCurMin = min;
118 fMax = fCurMax = max;
119 fBinWidth = (fMax - fMin)/fNBins;
121 fBins = new Reve::PointSet*[fNBins];
122 for(Int_t i=0; i<fNBins; ++i) {
123 fBins[i] = new Reve::PointSet
124 (Form("Slice %d [%4.3lf, %4.3lf]", i, fMin + i*fBinWidth, fMin + (i+1)*fBinWidth));
125 AddElement(fBins[i]);
127 gReve->AddRenderElement(tree_item, fBins[i]);
131 void PointSetArray::Fill(Double_t quant, Double_t x, Double_t y, Double_t z)
133 Int_t bin = Int_t( (quant - fMin)/fBinWidth );
134 if(bin >= 0 && bin < fNBins)
135 fBins[bin]->SetNextPoint(x, y, z);
138 void PointSetArray::Fill(TF3* , TTree* , TreeVarType_e )
143 void PointSetArray::CloseBins(Int_t mark_stlye, Float_t mark_size)
145 for(Int_t i=0; i<fNBins; ++i) {
146 fBins[i]->SetMarkerColor(fColor);
147 fBins[i]->SetMarkerColor(fColor);
148 fBins[i]->SetMarkerStyle(mark_stlye);
149 fBins[i]->SetMarkerSize(mark_size);
150 fBins[i]->fN = fBins[i]->fLastPoint; // HACK! PolyMarker3D does half-management of array size.
151 fBins[i]->ComputeBBox();
155 /**************************************************************************/
157 void PointSetArray::SetRange(Double_t min, Double_t max)
159 using namespace TMath;
161 fCurMin = min; fCurMax = max;
162 Int_t low_b = (Int_t) Max(Double_t(0), Floor((min-fMin)/fBinWidth));
163 Int_t high_b = (Int_t) Min(Double_t(fNBins-1), Ceil((max-fMin)/fBinWidth));
164 for(Int_t i=0; i<fNBins; ++i) {
165 fBins[i]->SetRnrElement(i>=low_b && i<=high_b);
169 /**************************************************************************/
172 #include <TGDoubleSlider.h>
173 #include <TGXYLayout.h>
175 void PointSetArray::MakeScrollbar()
177 TGMainFrame* mf = new TGMainFrame(gClient->GetRoot(), 320, 60);
179 TGDoubleHSlider* hs = new TGDoubleHSlider(mf);
180 hs->SetRange(fMin, fMax);
181 hs->SetPosition(fMin, fMax);
183 mf->AddFrame(hs, new TGLayoutHints(kLHintsCenterX, 10, 10, 10, 10));
185 hs->Connect("PositionChanged()", "Reve::PointSetArray",
186 this, "HandleScrollEvent()");
188 mf->SetWindowName(fQuantName + " Selector");
190 mf->Resize(mf->GetDefaultSize()); // this is used here to init layout algorithm
194 void PointSetArray::HandleScrollEvent()
196 TGDoubleHSlider* hs = (TGDoubleHSlider*)gTQSender;
198 Float_t min = hs->GetMinPosition(), max = hs->GetMaxPosition();
199 printf("hslidor min=%f max=%f\n", min, max);