]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New files: provide a surrounding box/rectangle with a given size/color; can be shared...
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 14 Nov 2006 16:27:43 +0000 (16:27 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 14 Nov 2006 16:27:43 +0000 (16:27 +0000)
EVE/Reve/FrameBox.cxx [new file with mode: 0644]
EVE/Reve/FrameBox.h [new file with mode: 0644]
EVE/Reve/FrameBoxGL.cxx [new file with mode: 0644]
EVE/Reve/FrameBoxGL.h [new file with mode: 0644]

diff --git a/EVE/Reve/FrameBox.cxx b/EVE/Reve/FrameBox.cxx
new file mode 100644 (file)
index 0000000..297d176
--- /dev/null
@@ -0,0 +1,101 @@
+// $Header$
+
+#include <Reve/FrameBox.h>
+
+#include <TColor.h>
+
+using namespace Reve;
+
+//______________________________________________________________________
+// FrameBox
+//
+
+ClassImp(FrameBox)
+
+FrameBox::FrameBox() :
+  fFrameType   (FT_None),
+  fFrameSize   (0),
+  fFramePoints (0),
+
+  fFrameColor  (0)
+{
+  fFrameRGBA[0] = fFrameRGBA[1] = fFrameRGBA[2] = fFrameRGBA[3] = 255;
+}
+
+FrameBox::~FrameBox()
+{
+  delete [] fFramePoints;
+}
+
+/**************************************************************************/
+
+void FrameBox::SetAAQuadXY(Float_t x,  Float_t y, Float_t z,
+                          Float_t dx, Float_t dy)
+{
+  fFrameType = FT_Quad;
+  fFrameSize = 12;
+  delete [] fFramePoints;
+  fFramePoints = new Float_t [fFrameSize];
+  Float_t* p = fFramePoints;
+  p[0] = x;    p[1] = y;    p[2] = z; p += 3;
+  p[0] = x+dx; p[1] = y;    p[2] = z; p += 3;
+  p[0] = x+dx; p[1] = y+dy; p[2] = z; p += 3;
+  p[0] = x ;   p[1] = y+dy; p[2] = z; p += 3;
+}
+
+void FrameBox::SetAAQuadXZ(Float_t x,  Float_t y, Float_t z,
+                          Float_t dx, Float_t dz)
+{
+  fFrameType = FT_Quad;
+  fFrameSize = 12;
+  delete [] fFramePoints;
+  fFramePoints = new Float_t [fFrameSize];
+  Float_t* p = fFramePoints;
+  p[0] = x;    p[1] = y; p[2] = z;    p += 3;
+  p[0] = x+dx; p[1] = y; p[2] = z;    p += 3;
+  p[0] = x+dx; p[1] = y; p[2] = z+dz; p += 3;
+  p[0] = x ;   p[1] = y; p[2] = z+dz; p += 3;
+}
+
+void FrameBox::SetAABox(Float_t x,  Float_t y,  Float_t z,
+                       Float_t dx, Float_t dy, Float_t dz)
+{
+  fFrameType = FT_Box;
+  fFrameSize = 24;
+  delete [] fFramePoints;
+  fFramePoints = new Float_t [fFrameSize];
+
+  Float_t* p = fFramePoints;
+  //bottom
+  p[0] = x;       p[1] = y + dy;  p[2] = z;       p += 3;
+  p[0] = x + dx;  p[1] = y + dy;  p[2] = z;       p += 3;
+  p[0] = x + dx;  p[1] = y;       p[2] = z;       p += 3;
+  p[0] = x;       p[1] = y;       p[2] = z;       p += 3;
+  //top
+  p[0] = x;       p[1] = y + dy;  p[2] = z + dz;  p += 3;
+  p[0] = x + dx;  p[1] = y + dy;  p[2] = z + dz;  p += 3;
+  p[0] = x + dx;  p[1] = y;       p[2] = z + dz;  p += 3;
+  p[0] = x;       p[1] = y;       p[2] = z + dz;
+}
+
+/**************************************************************************/
+
+void FrameBox::SetFrameColor(Color_t ci)
+{
+  fFrameColor = ci;
+  ColorFromIdx(ci, fFrameRGBA, kTRUE);
+}
+
+void FrameBox::SetFrameColor(Pixel_t pix)
+{
+  SetFrameColor(Color_t(TColor::GetColor(pix)));
+}
+
+void FrameBox::SetFrameColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a)
+{
+  fFrameColor = Color_t(TColor::GetColor(r, g, b));
+  fFrameRGBA[0] = r;
+  fFrameRGBA[1] = g;
+  fFrameRGBA[2] = b;
+  fFrameRGBA[3] = a;
+}
diff --git a/EVE/Reve/FrameBox.h b/EVE/Reve/FrameBox.h
new file mode 100644 (file)
index 0000000..c126a8b
--- /dev/null
@@ -0,0 +1,58 @@
+// $Header$
+
+#ifndef REVE_FrameBox_H
+#define REVE_FrameBox_H
+
+#include <Reve/Reve.h>
+
+#include <TObject.h>
+
+namespace Reve {
+
+class FrameBox : public TObject, public ReferenceCount
+{
+  friend class FrameBoxGL;
+
+public:
+  enum FrameType_e  { FT_None, FT_Quad, FT_Box };
+
+private:
+  FrameBox(const FrameBox&);            // Not implemented
+  FrameBox& operator=(const FrameBox&); // Not implemented
+
+protected:
+  FrameType_e  fFrameType;
+  Int_t        fFrameSize;
+  Float_t     *fFramePoints;  //[fFrameSize]
+
+  Color_t      fFrameColor;
+  UChar_t      fFrameRGBA[4];
+
+  // !!!! Back-refs to RenderElement consumers (as for palette)
+
+public:
+  FrameBox();
+  virtual ~FrameBox();
+
+  void SetAAQuadXY(Float_t x, Float_t y, Float_t z, Float_t dx, Float_t dy);
+  void SetAAQuadXZ(Float_t x, Float_t y, Float_t z, Float_t dx, Float_t dz);
+
+  void SetAABox(Float_t x,  Float_t y,  Float_t z,
+               Float_t dx, Float_t dy, Float_t dz);
+
+  // ----------------------------------------------------------------
+
+  Color_t  GetFrameColor() const { return fFrameColor; }
+  Color_t* PtrFrameColor() { return &fFrameColor; }
+  UChar_t* GetFrameRGBA()  { return fFrameRGBA;  }
+
+  void SetFrameColor(Color_t ci);
+  void SetFrameColor(Pixel_t pix);
+  void SetFrameColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255);
+
+  ClassDef(FrameBox, 1);
+}; // endclass FrameBox
+
+}
+
+#endif
diff --git a/EVE/Reve/FrameBoxGL.cxx b/EVE/Reve/FrameBoxGL.cxx
new file mode 100644 (file)
index 0000000..f04c62e
--- /dev/null
@@ -0,0 +1,58 @@
+// $Header$
+
+#include "FrameBoxGL.h"
+#include <Reve/FrameBox.h>
+
+#include <TGLDrawFlags.h>
+
+#ifdef WIN32
+#include "Windows4root.h"
+#endif
+#include <GL/gl.h>
+#include <GL/glu.h>
+
+using namespace Reve;
+
+//______________________________________________________________________
+// FrameBoxGL
+//
+// A class encapsulating GL rendering of Reve::FrameBox via a static
+// meber function.
+
+ClassImp(FrameBoxGL)
+
+void FrameBoxGL::Render(const FrameBox* box)
+{
+  GLboolean lightp;
+  glGetBooleanv(GL_LIGHTING, &lightp);
+  if (lightp) glDisable(GL_LIGHTING);
+
+  const FrameBox& b = *box;
+  const Float_t*  p =  b.fFramePoints;
+  glColor4ubv(b.fFrameRGBA);
+  if (b.fFrameType == FrameBox::FT_Quad)
+  {
+    glBegin(GL_LINE_LOOP);
+    glVertex3fv(p);       glVertex3fv(p + 3);
+    glVertex3fv(p + 6);   glVertex3fv(p + 9);
+    glEnd();
+  }
+  else if (b.fFrameType == FrameBox::FT_Box)
+  {
+    glBegin(GL_LINE_STRIP);
+    glVertex3fv(p);       glVertex3fv(p + 3);
+    glVertex3fv(p + 6);   glVertex3fv(p + 9);
+    glVertex3fv(p);
+    glVertex3fv(p + 12);  glVertex3fv(p + 15);
+    glVertex3fv(p + 18);  glVertex3fv(p + 21);
+    glVertex3fv(p + 12);
+    glEnd();
+    glBegin(GL_LINES);
+    glVertex3fv(p + 3);   glVertex3fv(p + 15);
+    glVertex3fv(p + 6);   glVertex3fv(p + 18);
+    glVertex3fv(p + 9);   glVertex3fv(p + 21);
+    glEnd();
+  }
+
+  if (lightp) glEnable(GL_LIGHTING);
+}
diff --git a/EVE/Reve/FrameBoxGL.h b/EVE/Reve/FrameBoxGL.h
new file mode 100644 (file)
index 0000000..cb89953
--- /dev/null
@@ -0,0 +1,27 @@
+// $Header$
+
+#ifndef REVE_FrameBoxGL_H
+#define REVE_FrameBoxGL_H
+
+#include <Reve/Reve.h>
+
+namespace Reve {
+
+class FrameBox;
+
+class FrameBoxGL
+{
+private:
+  FrameBoxGL();                             // Not implemented
+  FrameBoxGL(const FrameBoxGL&);            // Not implemented
+  FrameBoxGL& operator=(const FrameBoxGL&); // Not implemented
+
+public:
+  static void Render(const FrameBox* box);
+
+  ClassDef(FrameBoxGL, 0);
+}; // endclass FrameBoxGL
+
+}
+
+#endif