]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New files: line representation with per-point selection.
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 21 Nov 2006 18:42:33 +0000 (18:42 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 21 Nov 2006 18:42:33 +0000 (18:42 +0000)
EVE/Reve/Line.cxx [new file with mode: 0644]
EVE/Reve/Line.h [new file with mode: 0644]
EVE/Reve/LineEditor.cxx [new file with mode: 0644]
EVE/Reve/LineEditor.h [new file with mode: 0644]
EVE/Reve/LineGL.cxx [new file with mode: 0644]
EVE/Reve/LineGL.h [new file with mode: 0644]

diff --git a/EVE/Reve/Line.cxx b/EVE/Reve/Line.cxx
new file mode 100644 (file)
index 0000000..29446d7
--- /dev/null
@@ -0,0 +1,39 @@
+// $Header$
+
+#include "Line.h"
+
+using namespace Reve;
+
+//______________________________________________________________________
+// Line
+//
+
+ClassImp(Line)
+
+
+Line::Line(Int_t n_points, TreeVarType_e tv_type) :
+  PointSet(n_points, tv_type),
+  fRnrLine   (kTRUE),
+  fRnrPoints (kFALSE)
+{
+  fMainColorPtr = &fLineColor;
+}
+
+Line::Line(const Text_t* name, Int_t n_points, TreeVarType_e tv_type) :
+  PointSet(name, n_points, tv_type),
+  fRnrLine   (kTRUE),
+  fRnrPoints (kFALSE)
+{
+  fMainColorPtr = &fLineColor;
+}
+
+Line::Line(const Text_t* name, TTree* tree, TreeVarType_e tv_type) :
+  PointSet(name, tree, tv_type),
+  fRnrLine   (kTRUE),
+  fRnrPoints (kFALSE)
+{
+  fMainColorPtr = &fLineColor;
+}
+
+Line::~Line()
+{}
diff --git a/EVE/Reve/Line.h b/EVE/Reve/Line.h
new file mode 100644 (file)
index 0000000..db281d9
--- /dev/null
@@ -0,0 +1,48 @@
+// $Header$
+
+#ifndef REVE_Line_H
+#define REVE_Line_H
+
+#include <Reve/Reve.h>
+#include <Reve/PointSet.h>
+
+#include <TAttLine.h>
+
+namespace Reve {
+
+class Line : public PointSet,
+            public TAttLine
+{
+  friend class LineEditor;
+  friend class LineGL;
+
+private:
+  Line(const Line&);            // Not implemented
+  Line& operator=(const Line&); // Not implemented
+
+protected:
+  Bool_t  fRnrLine;
+  Bool_t  fRnrPoints;
+
+public:
+  Line(Int_t n_points=0, TreeVarType_e tv_type=TVT_XYZ);
+  Line(const Text_t* name, Int_t n_points=0, TreeVarType_e tv_type=TVT_XYZ);
+  Line(const Text_t* name, TTree* tree, TreeVarType_e tv_type=TVT_XYZ);
+  virtual ~Line();
+
+  virtual void SetMarkerColor(Color_t col)
+  { TAttMarker::SetMarkerColor(col); }
+  virtual void SetLineColor(Color_t col)
+  { SetMainColor(col); }
+
+  Bool_t GetRnrLine() const   { return fRnrLine;   }
+  void SetRnrLine(Bool_t r)   { fRnrLine = r;      }
+  Bool_t GetRnrPoints() const { return fRnrPoints; }
+  void SetRnrPoints(Bool_t r) { fRnrPoints = r;    }
+
+  ClassDef(Line, 1);
+}; // endclass Line
+
+}
+
+#endif
diff --git a/EVE/Reve/LineEditor.cxx b/EVE/Reve/LineEditor.cxx
new file mode 100644 (file)
index 0000000..12222d6
--- /dev/null
@@ -0,0 +1,71 @@
+// $Header$
+
+#include "LineEditor.h"
+#include <Reve/Line.h>
+
+#include <TVirtualPad.h>
+#include <TColor.h>
+
+#include <TGLabel.h>
+#include <TGButton.h>
+#include <TGNumberEntry.h>
+#include <TGColorSelect.h>
+#include <TGDoubleSlider.h>
+
+using namespace Reve;
+
+//______________________________________________________________________
+// LineEditor
+//
+
+ClassImp(LineEditor)
+
+  LineEditor::LineEditor(const TGWindow *p, Int_t width, Int_t height,
+                        UInt_t options, Pixel_t back) :
+    TGedFrame(p, width, height, options | kVerticalFrame, back),
+    fM(0),
+    fRnrLine   (0),
+    fRnrPoints (0)
+{
+  // MakeTitle("Line");
+
+  {
+    TGHorizontalFrame* f = new TGHorizontalFrame(this);
+
+    fRnrLine  = new TGCheckButton(f, "Draw Line");
+    f->AddFrame(fRnrLine, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
+    fRnrLine->Connect("Toggled(Bool_t)", "Reve::LineEditor", this, "DoRnrLine()");
+    fRnrPoints = new TGCheckButton(f, "Draw Marker");
+    f->AddFrame(fRnrPoints, new TGLayoutHints(kLHintsLeft, 2,1,0,0));  
+    fRnrPoints->Connect("Toggled(Bool_t)"," Reve::LineEditor", this, "DoRnrPoints()");
+
+    AddFrame(f, new TGLayoutHints(kLHintsTop, 0,0,2,1));
+  }
+}
+
+LineEditor::~LineEditor()
+{}
+
+/**************************************************************************/
+
+void LineEditor::SetModel(TObject* obj)
+{
+  fM = dynamic_cast<Line*>(obj);
+
+  fRnrLine  ->SetState(fM->fRnrLine  ? kButtonDown : kButtonUp);
+  fRnrPoints->SetState(fM->fRnrPoints ? kButtonDown : kButtonUp);
+}
+
+/**************************************************************************/
+
+void LineEditor::DoRnrLine()
+{
+  fM->SetRnrLine(fRnrLine->IsOn());
+  Update();
+}
+
+void LineEditor::DoRnrPoints()
+{
+  fM->SetRnrPoints(fRnrPoints->IsOn());
+  Update();
+}
diff --git a/EVE/Reve/LineEditor.h b/EVE/Reve/LineEditor.h
new file mode 100644 (file)
index 0000000..b1f461e
--- /dev/null
@@ -0,0 +1,42 @@
+// $Header$
+
+#ifndef REVE_LineEditor_H
+#define REVE_LineEditor_H
+
+#include <TGedFrame.h>
+
+class TGCheckButton;
+class TGNumberEntry;
+class TGColorSelect;
+
+namespace Reve {
+
+class Line;
+
+class LineEditor : public TGedFrame
+{
+private:
+  LineEditor(const LineEditor&);            // Not implemented
+  LineEditor& operator=(const LineEditor&); // Not implemented
+
+protected:
+  Line* fM; // fModel dynamic-casted to LineEditor
+
+  TGCheckButton     *fRnrLine;
+  TGCheckButton     *fRnrPoints;
+
+public:
+  LineEditor(const TGWindow* p=0, Int_t width=170, Int_t height=30, UInt_t options = kChildFrame, Pixel_t back=GetDefaultFrameBackground());
+  virtual ~LineEditor();
+
+  virtual void SetModel(TObject* obj);
+
+  void DoRnrLine();
+  void DoRnrPoints();
+
+  ClassDef(LineEditor, 1); // Editor for Line
+}; // endclass LineEditor
+
+}
+
+#endif
diff --git a/EVE/Reve/LineGL.cxx b/EVE/Reve/LineGL.cxx
new file mode 100644 (file)
index 0000000..c1bb264
--- /dev/null
@@ -0,0 +1,102 @@
+// $Header$
+
+#include "LineGL.h"
+#include <Reve/Line.h>
+
+#include <TGLDrawFlags.h>
+
+#ifdef WIN32
+#include "Windows4root.h"
+#endif
+#include <GL/gl.h>
+#include <GL/glu.h>
+
+using namespace Reve;
+
+//______________________________________________________________________
+// LineGL
+//
+
+ClassImp(LineGL)
+
+LineGL::LineGL() : TPointSet3DGL(), fM(0)
+{
+  // fCached = false; // Disable display list.
+}
+
+LineGL::~LineGL()
+{}
+
+/**************************************************************************/
+
+Bool_t LineGL::SetModel(TObject* obj)
+{
+  // TPointSet3DGL::SetModel(obj);
+  if(SetModelCheckClass(obj, Line::Class())) {
+    fM = dynamic_cast<Line*>(obj);
+    return kTRUE;
+  }
+  return kFALSE;
+}
+
+/**************************************************************************/
+
+void LineGL::DirectDraw(const TGLDrawFlags & flags) const
+{
+  // printf("LineGL::DirectDraw Style %d, LOD %d\n", flags.Style(), flags.LOD());
+
+  Line& q = *fM;
+  if (q.Size() <= 0) return;
+
+  glPushAttrib(GL_POINT_BIT | GL_LINE_BIT | GL_ENABLE_BIT);
+  glDisable(GL_LIGHTING);
+
+  UChar_t color[4];
+
+  if (q.fRnrLine)
+  {
+    glPushAttrib(GL_LINE_BIT);
+    ColorFromIdx(q.GetLineColor(), color);
+    glColor4ubv(color);
+    glLineWidth(q.GetLineWidth());
+    if (q.GetLineStyle() > 1) {
+      Int_t    fac = 1;
+      UShort_t pat = 0xffff;
+      switch (q.GetLineStyle()) {
+      case 2:  pat = 0x3333; break;
+      case 3:  pat = 0x5555; break;
+      case 4:  pat = 0xf040; break;
+      case 5:  pat = 0xf4f4; break;
+      case 6:  pat = 0xf111; break;
+      case 7:  pat = 0xf0f0; break;
+      case 8:  pat = 0xff11; break;
+      case 9:  pat = 0x3fff; break;
+      case 10: pat = 0x08ff; fac = 2; break;
+      }
+
+      glLineStipple(1, pat);
+      glEnable(GL_LINE_STIPPLE);
+    }
+
+    const Float_t* p = q.GetP();
+    const Int_t    n = q.Size();
+    glBegin(GL_LINE_STRIP);
+    for (Int_t i=0; i<n; ++i, p+=3)
+      glVertex3fv(p);
+    glEnd();
+    glPopAttrib();
+  }
+
+  if (q.fRnrPoints)
+  {
+    ColorFromIdx(q.GetMarkerColor(), color);
+    glColor4ubv(color);
+    Int_t ms = q.GetMarkerStyle();
+    if (ms != 2 && ms != 3 && ms != 5 && ms != 28)
+      RenderPoints(flags);
+    else
+      RenderCrosses(flags);
+  }
+
+  glPopAttrib();
+}
diff --git a/EVE/Reve/LineGL.h b/EVE/Reve/LineGL.h
new file mode 100644 (file)
index 0000000..2c71e13
--- /dev/null
@@ -0,0 +1,42 @@
+// $Header$
+
+#ifndef REVE_LineGL_H
+#define REVE_LineGL_H
+
+#include <TGLObject.h>
+#include <TPointSet3DGL.h>
+
+class TGLViewer;
+class TGLScene;
+
+namespace Reve {
+
+class Line;
+
+class LineGL : public TPointSet3DGL
+{
+private:
+  LineGL(const LineGL&);            // Not implemented
+  LineGL& operator=(const LineGL&); // Not implemented
+
+protected:
+  Line* fM; // fModel dynamic-casted to LineGL
+
+  virtual void DirectDraw(const TGLDrawFlags & flags) const;
+
+public:
+  LineGL();
+  virtual ~LineGL();
+
+  virtual Bool_t SetModel(TObject* obj);
+
+  // To support two-level selection
+  // virtual Bool_t SupportsSecondarySelect() const { return kTRUE; }
+  // virtual void ProcessSelection(UInt_t* ptr, TGLViewer*, TGLScene*);
+
+  ClassDef(LineGL, 0);
+}; // endclass LineGL
+
+}
+
+#endif