LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
View3D.cxx
Go to the documentation of this file.
1 #include <algorithm>
4 
5 namespace evdb{
6 
7  //......................................................................
8 
9  std::list<TMarker3DBox*> View3D::fgMarker3DBoxL;
10  std::list<TPolyMarker3D*> View3D::fgPolyMarker3DL;
11  std::list<TPolyLine3D*> View3D::fgPolyLine3DL;
12  std::list<TText*> View3D::fgText3DL;
13 
14  //......................................................................
15 
17  {
18  }
19 
20  //......................................................................
21 
23  {
24  // Make sure to return all our objects to where they came from
25  Clear();
26  }
27 
28  //......................................................................
29 
30  void View3D::Draw()
31  {
32  for_each(fMarker3DBoxL.begin(), fMarker3DBoxL.end(), draw_tobject());
33  for_each(fPolyMarker3DL.begin(),fPolyMarker3DL.end(),draw_tobject());
34  for_each(fPolyLine3DL.begin(), fPolyLine3DL.end(), draw_tobject());
35  for_each(fText3DL.begin(), fText3DL.end(), draw_tobject());
36  }
37 
38  //......................................................................
39 
40  void View3D::Clear()
41  {
42  // Empty each of our lists, appending them back onto the static ones
46  fgText3DL.splice(fgText3DL.end(), fText3DL);
47  }
48 
49  //......................................................................
50 
51  TMarker3DBox& View3D::AddMarker3DBox(double x, double y, double z,
52  double dx, double dy, double dz,
53  double th, double ph)
54  {
55  // See comment in View2D::AddMarker()
56  TMarker3DBox* m = 0;
57  if(fgMarker3DBoxL.empty()){
58  m = new TMarker3DBox(x,y,z,dx,dy,dz,th,ph);
59  m->SetBit(kCanDelete,kFALSE);
60  }
61  else {
62  m = fgMarker3DBoxL.back();
63  fgMarker3DBoxL.pop_back();
64 
65  m->SetPosition(x,y,z);
66  m->SetSize(dx,dy,dz);
67  }
68 
69  fMarker3DBoxL.push_back(m);
70  return *m;
71  }
72 
73  //......................................................................
74 
75  TPolyMarker3D& View3D::AddPolyMarker3D(int n, int c, int st, double sz)
76  {
77  TPolyMarker3D* pm = 0;
78  if(fgPolyMarker3DL.empty()){
79  pm = new TPolyMarker3D(n);
80  pm->SetBit(kCanDelete,kFALSE);
81  pm->SetMarkerColor(c);
82  pm->SetMarkerStyle(st);
83  pm->SetMarkerSize(sz);
84  }
85  else {
86  pm = fgPolyMarker3DL.back();
87  fgPolyMarker3DL.pop_back();
88 
89  // The first call to SetPolyMarker3D with the 0
90  // deletes the current set of points before trying
91  // to make a new set
92  pm->SetPolyMarker(0,(double*)0,1,"");
93  pm->SetPolyMarker(n,(double*)0,1,"");
94  pm->SetMarkerColor(c);
95  pm->SetMarkerStyle(st);
96  pm->SetMarkerSize(sz);
97  }
98 
99  fPolyMarker3DL.push_back(pm);
100  return *pm;
101  }
102 
103  //......................................................................
104 
105  TPolyLine3D& View3D::AddPolyLine3D(int n, int c, int w, int s)
106  {
107  TPolyLine3D* pl = 0;
108  if(fgPolyLine3DL.empty()){
109  pl = new TPolyLine3D(n);
110  pl->SetBit(kCanDelete,kFALSE);
111  pl->SetLineColor(c);
112  pl->SetLineWidth(w);
113  pl->SetLineStyle(s);
114  }
115  else {
116  pl = fgPolyLine3DL.back();
117  fgPolyLine3DL.pop_back();
118 
119  // The first call to SetPolyMarker3D with the 0
120  // deletes the current set of points before trying
121  // to make a new set
122  pl->SetPolyLine(0,(double*)0,"");
123  pl->SetPolyLine(n,(double*)0,"");
124  pl->SetLineColor(c);
125  pl->SetLineWidth(w);
126  pl->SetLineStyle(s);
127  }
128 
129  fPolyLine3DL.push_back(pl);
130  return *pl;
131  }
132 
133  //......................................................................
134 
135  TText& View3D::AddText(double x, double y, const char* text)
136  {
137  TText* itxt = 0;
138  if(fgText3DL.empty()){
139  itxt = new TText(x,y,text);
140  itxt->SetBit(kCanDelete,kFALSE);
141  }
142  else {
143  itxt = fgText3DL.back();
144  fgText3DL.pop_back();
145 
146  itxt->SetText(x,y,text);
147  }
148 
149  fText3DL.push_back(itxt);
150  return *itxt;
151  }
152 
153 } // namespace
Float_t x
Definition: compare.C:6
Float_t s
Definition: plot.C:23
TMarker3DBox & AddMarker3DBox(double x, double y, double z, double dx, double dy, double dz, double th=0.0, double ph=0.0)
Definition: View3D.cxx:51
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
Manage all things related to colors for the event display.
static std::list< TPolyMarker3D * > fgPolyMarker3DL
Definition: View3D.h:38
TText & AddText(double x, double y, const char *text)
Definition: View3D.cxx:135
std::list< TText * > fText3DL
List of texts.
Definition: View3D.h:45
static std::list< TPolyLine3D * > fgPolyLine3DL
Definition: View3D.h:39
TPolyLine3D & AddPolyLine3D(int n, int c, int w, int s)
Definition: View3D.cxx:105
static std::list< TText * > fgText3DL
Definition: View3D.h:40
std::list< TMarker3DBox * > fMarker3DBoxL
List of 3D marker boxes.
Definition: View3D.h:42
static std::list< TMarker3DBox * > fgMarker3DBoxL
Definition: View3D.h:37
void Draw()
Definition: View3D.cxx:30
std::list< TPolyLine3D * > fPolyLine3DL
List of poly lines.
Definition: View3D.h:44
void Clear()
Definition: View3D.cxx:40
std::list< TPolyMarker3D * > fPolyMarker3DL
List of poly markers.
Definition: View3D.h:43
Char_t n[5]
A collection of 3D drawable objects.
Float_t w
Definition: plot.C:23
TPolyMarker3D & AddPolyMarker3D(int n, int c, int st, double sz)
Definition: View3D.cxx:75