00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TEveLine.h"
00013 #include "TEveProjectionManager.h"
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 ClassImp(TEveLine);
00025
00026 Bool_t TEveLine::fgDefaultSmooth = kFALSE;
00027
00028
00029 TEveLine::TEveLine(Int_t n_points, ETreeVarType_e tv_type) :
00030 TEvePointSet("Line", n_points, tv_type),
00031 fRnrLine (kTRUE),
00032 fRnrPoints (kFALSE),
00033 fSmooth (fgDefaultSmooth)
00034 {
00035
00036
00037 fMainColorPtr = &fLineColor;
00038 fMarkerColor = kGreen;
00039 }
00040
00041
00042 TEveLine::TEveLine(const char* name, Int_t n_points, ETreeVarType_e tv_type) :
00043 TEvePointSet(name, n_points, tv_type),
00044 fRnrLine (kTRUE),
00045 fRnrPoints (kFALSE),
00046 fSmooth (fgDefaultSmooth)
00047 {
00048
00049
00050 fMainColorPtr = &fLineColor;
00051 fMarkerColor = kGreen;
00052 }
00053
00054
00055 const TGPicture* TEveLine::GetListTreeIcon(Bool_t)
00056 {
00057
00058
00059 return fgListTreeIcons[8];
00060 }
00061
00062
00063 void TEveLine::SetMarkerColor(Color_t col)
00064 {
00065
00066
00067 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
00068 while (pi != fProjectedList.end())
00069 {
00070 TEveLine* l = dynamic_cast<TEveLine*>(*pi);
00071 if (l && fMarkerColor == l->GetMarkerColor())
00072 {
00073 l->SetMarkerColor(col);
00074 l->StampObjProps();
00075 }
00076 ++pi;
00077 }
00078 TAttMarker::SetMarkerColor(col);
00079 }
00080
00081
00082 void TEveLine::SetLineStyle(Style_t lstyle)
00083 {
00084
00085
00086
00087 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
00088 while (pi != fProjectedList.end())
00089 {
00090 TEveLine* pt = dynamic_cast<TEveLine*>(*pi);
00091 if (pt)
00092 {
00093 pt->SetLineStyle(lstyle);
00094 pt->StampObjProps();
00095 }
00096 ++pi;
00097 }
00098 TAttLine::SetLineStyle(lstyle);
00099 }
00100
00101
00102 void TEveLine::SetLineWidth(Width_t lwidth)
00103 {
00104
00105
00106
00107 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
00108 while (pi != fProjectedList.end())
00109 {
00110 TEveLine* pt = dynamic_cast<TEveLine*>(*pi);
00111 if (pt)
00112 {
00113 pt->SetLineWidth(lwidth);
00114 pt->StampObjProps();
00115 }
00116 ++pi;
00117 }
00118 TAttLine::SetLineWidth(lwidth);
00119 }
00120
00121
00122 void TEveLine::SetRnrLine(Bool_t r)
00123 {
00124
00125
00126 fRnrLine = r;
00127 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
00128 while (pi != fProjectedList.end())
00129 {
00130 TEveLine* l = dynamic_cast<TEveLine*>(*pi);
00131 if (l)
00132 {
00133 l->SetRnrLine(r);
00134 l->ElementChanged();
00135 }
00136 ++pi;
00137 }
00138 }
00139
00140
00141 void TEveLine::SetRnrPoints(Bool_t r)
00142 {
00143
00144
00145 fRnrPoints = r;
00146 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
00147 while (pi != fProjectedList.end())
00148 {
00149 TEveLine* l = dynamic_cast<TEveLine*>(*pi);
00150 if (l)
00151 {
00152 l->SetRnrPoints(r);
00153 l->ElementChanged();
00154 }
00155 ++pi;
00156 }
00157 }
00158
00159
00160 void TEveLine::SetSmooth(Bool_t r)
00161 {
00162
00163
00164 fSmooth = r;
00165 std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
00166 while (pi != fProjectedList.end())
00167 {
00168 TEveLine* l = dynamic_cast<TEveLine*>(*pi);
00169 if (l)
00170 {
00171 l->SetSmooth(r);
00172 l->ElementChanged();
00173 }
00174 ++pi;
00175 }
00176 }
00177
00178
00179
00180
00181 void TEveLine::ReduceSegmentLengths(Float_t max)
00182 {
00183
00184
00185
00186 const Float_t max2 = max*max;
00187
00188 Float_t *p = GetP();
00189 Int_t s = Size();
00190 TEveVector a, b, d;
00191
00192 std::vector<TEveVector> q;
00193
00194 b.Set(p);
00195 q.push_back(b);
00196 for (Int_t i = 1; i < s; ++i)
00197 {
00198 a = b; b.Set(&p[3*i]); d = b - a;
00199 Float_t m2 = d.Mag2();
00200 if (m2 > max2)
00201 {
00202 Float_t f = TMath::Sqrt(m2) / max;
00203 Int_t n = TMath::FloorNint(f);
00204 d *= 1.0f / (n + 1);
00205 for (Int_t j = 0; j < n; ++j)
00206 {
00207 a += d;
00208 q.push_back(a);
00209 }
00210 }
00211 q.push_back(b);
00212 }
00213
00214 s = q.size();
00215 Reset(s);
00216 for (std::vector<TEveVector>::iterator i = q.begin(); i != q.end(); ++i)
00217 SetNextPoint(i->fX, i->fY, i->fZ);
00218 }
00219
00220
00221 TEveVector TEveLine::GetLineStart() const
00222 {
00223
00224
00225
00226 TEveVector v;
00227 GetPoint(0, v.fX, v.fY, v.fZ);
00228 return v;
00229 }
00230
00231
00232 TEveVector TEveLine::GetLineEnd() const
00233 {
00234
00235
00236
00237 TEveVector v;
00238 GetPoint(fLastPoint, v.fX, v.fY, v.fZ);
00239 return v;
00240 }
00241
00242
00243
00244
00245 void TEveLine::CopyVizParams(const TEveElement* el)
00246 {
00247
00248
00249 const TEveLine* m = dynamic_cast<const TEveLine*>(el);
00250 if (m)
00251 {
00252 TAttLine::operator=(*m);
00253 fRnrLine = m->fRnrLine;
00254 fRnrPoints = m->fRnrPoints;
00255 fSmooth = m->fSmooth;
00256 }
00257
00258 TEvePointSet::CopyVizParams(el);
00259 }
00260
00261
00262 void TEveLine::WriteVizParams(ostream& out, const TString& var)
00263 {
00264
00265
00266 TEvePointSet::WriteVizParams(out, var);
00267
00268 TString t = " " + var + "->";
00269 TAttLine::SaveLineAttributes(out, var);
00270 out << t << "SetRnrLine(" << ToString(fRnrLine) << ");\n";
00271 out << t << "SetRnrPoints(" << ToString(fRnrPoints) << ");\n";
00272 out << t << "SetSmooth(" << ToString(fSmooth) << ");\n";
00273 }
00274
00275
00276 TClass* TEveLine::ProjectedClass(const TEveProjection*) const
00277 {
00278
00279
00280 return TEveLineProjected::Class();
00281 }
00282
00283
00284
00285
00286 Bool_t TEveLine::GetDefaultSmooth()
00287 {
00288
00289
00290
00291 return fgDefaultSmooth;
00292 }
00293
00294
00295 void TEveLine::SetDefaultSmooth(Bool_t r)
00296 {
00297
00298
00299
00300 fgDefaultSmooth = r;
00301 }
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314 ClassImp(TEveLineProjected);
00315
00316
00317 TEveLineProjected::TEveLineProjected() :
00318 TEveLine (),
00319 TEveProjected ()
00320 {
00321
00322 }
00323
00324
00325 void TEveLineProjected::SetProjection(TEveProjectionManager* mng,
00326 TEveProjectable* model)
00327 {
00328
00329
00330
00331 TEveProjected::SetProjection(mng, model);
00332 CopyVizParams(dynamic_cast<TEveElement*>(model));
00333 }
00334
00335
00336 void TEveLineProjected::SetDepthLocal(Float_t d)
00337 {
00338
00339
00340 SetDepthCommon(d, this, fBBox);
00341
00342 Int_t n = Size();
00343 Float_t *p = GetP() + 2;
00344 for (Int_t i = 0; i < n; ++i, p+=3)
00345 *p = fDepth;
00346 }
00347
00348
00349 void TEveLineProjected::UpdateProjection()
00350 {
00351
00352
00353
00354 TEveProjection& proj = * fManager->GetProjection();
00355 TEveLine & als = * dynamic_cast<TEveLine*>(fProjectable);
00356 TEveTrans *tr = als.PtrMainTrans(kFALSE);
00357
00358 Int_t n = als.Size();
00359 Reset(n);
00360 fLastPoint = n - 1;
00361 Float_t *o = als.GetP(), *p = GetP();
00362 for (Int_t i = 0; i < n; ++i, o+=3, p+=3)
00363 {
00364 proj.ProjectPointfv(tr, o, p, fDepth);
00365 }
00366 }