]>
Commit | Line | Data |
---|---|---|
1383fb4a | 1 | // $Header$ |
2 | ||
3 | #include "StraightLineSet.h" | |
4 | ||
5 | #include <TBuffer3D.h> | |
6 | #include <TBuffer3DTypes.h> | |
7 | #include <TVirtualPad.h> | |
8 | #include <TVirtualViewer3D.h> | |
9 | ||
10 | #include <TRandom.h> | |
32e219c2 | 11 | #include <Reve/NLTProjector.h> |
1383fb4a | 12 | |
13 | using namespace Reve; | |
14 | ||
15 | //______________________________________________________________________ | |
16 | // StraightLineSet | |
17 | // | |
18 | ||
19 | ClassImp(StraightLineSet) | |
20 | ||
21 | StraightLineSet::StraightLineSet(const Text_t* n, const Text_t* t): | |
32e219c2 | 22 | RenderElement (), |
23 | TNamed (n, t), | |
24 | ||
25 | fLinePlex (sizeof(Line), 4), | |
26 | fMarkerPlex (sizeof(Marker), 8), | |
27 | fOwnLinesIds (kFALSE), | |
28 | fOwnMarkersIds (kFALSE), | |
29 | fRnrMarkers (kTRUE), | |
30 | fRnrLines (kTRUE), | |
31 | fLastLine (0), | |
32 | fTrans (kFALSE), | |
33 | fHMTrans () | |
1383fb4a | 34 | { |
32e219c2 | 35 | fMainColorPtr = &fLineColor; |
36 | fLineColor = 4; | |
37 | fMarkerColor = 2; | |
38 | fMarkerStyle = 20; | |
1383fb4a | 39 | } |
40 | ||
41 | /**************************************************************************/ | |
42 | ||
43 | void StraightLineSet::AddLine(Float_t x1, Float_t y1, Float_t z1, | |
1a19ee66 | 44 | Float_t x2, Float_t y2, Float_t z2) |
1383fb4a | 45 | { |
46 | fLastLine = new (fLinePlex.NewAtom()) Line(x1, y1, z1, x2, y2, z2); | |
47 | } | |
48 | ||
49 | /**************************************************************************/ | |
50 | ||
51 | void StraightLineSet::AddMarker(Int_t line, Float_t pos) | |
52 | { | |
53 | /*Marker* marker = */new (fMarkerPlex.NewAtom()) Marker(line, pos); | |
54 | } | |
55 | ||
56 | /**************************************************************************/ | |
57 | ||
58 | void StraightLineSet::ComputeBBox() | |
59 | { | |
60 | static const Exc_t eH("StraightLineSet::ComputeBBox "); | |
61 | if(fLinePlex.Size() == 0) { | |
62 | BBoxZero(); | |
63 | return; | |
64 | } | |
65 | ||
66 | BBoxInit(); | |
67 | ||
68 | VoidCPlex::iterator li(fLinePlex); | |
69 | while (li.next()) { | |
70 | BBoxCheckPoint(((Line*)li())->fV1); | |
71 | BBoxCheckPoint(((Line*)li())->fV2); | |
72 | } | |
73 | } | |
74 | ||
75 | /**************************************************************************/ | |
76 | ||
77 | void StraightLineSet::Paint(Option_t* /*option*/) | |
78 | { | |
79 | static const Exc_t eH("StraightLineSet::Paint "); | |
80 | ||
81 | TBuffer3D buff(TBuffer3DTypes::kGeneric); | |
82 | ||
83 | // Section kCore | |
84 | buff.fID = this; | |
32e219c2 | 85 | buff.fColor = fLineColor; |
1383fb4a | 86 | buff.fTransparency = 0; |
87 | buff.fLocalFrame = kFALSE; | |
32e219c2 | 88 | fHMTrans.SetBuffer3D(buff); |
1383fb4a | 89 | buff.SetSectionsValid(TBuffer3D::kCore); |
90 | ||
91 | Int_t reqSections = gPad->GetViewer3D()->AddObject(buff); | |
92 | if (reqSections != TBuffer3D::kNone) | |
93 | Error(eH, "only direct GL rendering supported."); | |
94 | } | |
32e219c2 | 95 | |
96 | /**************************************************************************/ | |
97 | ||
98 | TClass* StraightLineSet::ProjectedClass() const | |
99 | { | |
100 | return NLTSLineSet::Class(); | |
101 | } | |
102 | ||
103 | //______________________________________________________________________ | |
104 | // NLTSLineSet | |
105 | // | |
106 | ||
107 | ClassImp(NLTSLineSet) | |
108 | ||
109 | NLTSLineSet::NLTSLineSet() : StraightLineSet(), NLTProjected () | |
110 | {} | |
111 | ||
112 | /**************************************************************************/ | |
113 | ||
114 | void NLTSLineSet::SetProjection(NLTProjector* proj, NLTProjectable* model) | |
115 | { | |
116 | NLTProjected::SetProjection(proj, model); | |
117 | ||
118 | // copy line and marker attributes | |
119 | * (TAttMarker*)this = * dynamic_cast<TAttMarker*>(fProjectable); | |
120 | * (TAttLine*)this = * dynamic_cast<TAttLine*>(fProjectable); | |
121 | } | |
122 | /**************************************************************************/ | |
123 | ||
124 | void NLTSLineSet::UpdateProjection() | |
125 | { | |
1dfd2e42 | 126 | NLTProjection& proj = * fProjector->GetProjection(); |
32e219c2 | 127 | StraightLineSet& orig = * dynamic_cast<StraightLineSet*>(fProjectable); |
128 | ||
129 | // lines | |
130 | Int_t NL = orig.GetLinePlex().Size(); | |
131 | fLinePlex.Reset(sizeof(Line), NL); | |
132 | Line* l; | |
133 | Float_t p1[3]; | |
134 | Float_t p2[3]; | |
135 | VoidCPlex::iterator li(orig.GetLinePlex()); | |
136 | ||
137 | Double_t s1, s2, s3; | |
138 | orig.RefHMTrans().GetScale(s1, s2, s3); | |
1dfd2e42 | 139 | ZTrans mx; mx.Scale(s1, s2, s3); |
140 | Double_t x, y, z; | |
141 | orig.RefHMTrans().GetPos(x, y,z); | |
32e219c2 | 142 | while (li.next()) |
143 | { | |
144 | l = (Line*) li(); | |
145 | p1[0] = l->fV1[0]; p1[1] = l->fV1[1]; p1[2] = l->fV1[2]; | |
146 | p2[0] = l->fV2[0]; p2[1] = l->fV2[1]; p2[2] = l->fV2[2]; | |
147 | mx.MultiplyIP(p1); | |
148 | mx.MultiplyIP(p2); | |
1dfd2e42 | 149 | p1[0] += x; p1[1] += y; p1[2] += z; |
150 | p2[0] += x; p2[1] += y; p2[2] += z; | |
32e219c2 | 151 | proj.ProjectPointFv(p1); |
152 | proj.ProjectPointFv(p2); | |
153 | AddLine(p1[0], p1[1], p1[2], p2[0], p2[1], p2[2]); | |
154 | } | |
155 | ||
156 | // markers | |
157 | Int_t NM = orig.GetMarkerPlex().Size(); | |
158 | fMarkerPlex.Reset(sizeof(Marker), NM); | |
159 | Marker* m; | |
160 | VoidCPlex::iterator mi(orig.GetMarkerPlex()); | |
161 | while (mi.next()) | |
162 | { | |
163 | m = (Marker*) mi(); | |
164 | AddMarker(m->fLineID, m->fPos); | |
165 | } | |
32e219c2 | 166 | } |