]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
With Jochen: new class for arbitrarily shaped jet-cone. Will go to ROOT for the next...
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Dec 2008 11:52:00 +0000 (11:52 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 17 Dec 2008 11:52:00 +0000 (11:52 +0000)
EVE/EveBase/EveBaseLinkDef.h
EVE/EveBase/TEveJetCone.cxx [new file with mode: 0644]
EVE/EveBase/TEveJetCone.h [new file with mode: 0644]
EVE/EveBase/TEveJetConeEditor.cxx [new file with mode: 0644]
EVE/EveBase/TEveJetConeEditor.h [new file with mode: 0644]
EVE/EveBase/TEveJetConeGL.cxx [new file with mode: 0644]
EVE/EveBase/TEveJetConeGL.h [new file with mode: 0644]

index 150279012bf6bc9b0aaf0bcdd96f15ff577c27dd..f0277755a4ae845681c8b5aa2bf65aa1c9227fcc 100644 (file)
 #pragma link C++ class AliEveCascadeEditor+;
 #pragma link C++ class AliEveCascadeList+;
 #pragma link C++ class AliEveCascadeListEditor+;
-//
+
 // AliEveV0
 #pragma link C++ class AliEveV0+;
 #pragma link C++ class AliEveV0List+;
 #pragma link C++ class AliEveV0Editor+;
 #pragma link C++ class AliEveV0ListEditor+;
+
+// TEveJetCone
+#pragma link C++ class TEveJetCone+;
+#pragma link C++ class TEveJetConeEditor+;
+#pragma link C++ class TEveJetConeGL+;
diff --git a/EVE/EveBase/TEveJetCone.cxx b/EVE/EveBase/TEveJetCone.cxx
new file mode 100644 (file)
index 0000000..657866e
--- /dev/null
@@ -0,0 +1,78 @@
+// @(#)root/eve:$Id$
+// Author: Matevz Tadel 2007
+
+/*************************************************************************
+ * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
+ * All rights reserved.                                                  *
+ *                                                                       *
+ * For the licensing terms see $ROOTSYS/LICENSE.                         *
+ * For the list of contributors see $ROOTSYS/README/CREDITS.             *
+ *************************************************************************/
+
+#include "TEveJetCone.h"
+#include "TEveTrans.h"
+
+#include "TBuffer3D.h"
+#include "TBuffer3DTypes.h"
+#include "TVirtualPad.h"
+#include "TVirtualViewer3D.h"
+
+//______________________________________________________________________________
+// Description of TEveJetCone
+//
+// The base must have at least three points.
+
+ClassImp(TEveJetCone)
+
+//______________________________________________________________________________
+TEveJetCone::TEveJetCone(const Text_t* n, const Text_t* t) :
+   TEveElementList(n, t, kTRUE),
+   TAttBBox(),
+   fApex(),
+   fBasePoints()
+{
+   // Constructor.
+
+   fColor = kYellow;
+}
+
+
+/******************************************************************************/
+
+//______________________________________________________________________________
+void TEveJetCone::ComputeBBox()
+{
+   // Compute bounding-box of the data.
+
+   BBoxInit();
+   BBoxCheckPoint(fApex);
+   for (vTEveVector_ci i = fBasePoints.begin(); i != fBasePoints.end(); ++i)
+   {
+      BBoxCheckPoint(*i);
+   }
+}
+
+//______________________________________________________________________________
+void TEveJetCone::Paint(Option_t*)
+{
+   // Paint object.
+   // This is for direct rendering (using TEveJetConeGL class).
+
+   static const TEveException eh("TEveJetCone::Paint ");
+
+   if (fRnrSelf == kFALSE) return;
+
+   TBuffer3D buff(TBuffer3DTypes::kGeneric);
+
+   // Section kCore
+   buff.fID           = this;
+   buff.fColor        = GetMainColor();
+   buff.fTransparency = GetMainTransparency();
+   if (HasMainTrans())
+      RefMainTrans().SetBuffer3D(buff);
+   buff.SetSectionsValid(TBuffer3D::kCore);
+
+   Int_t reqSections = gPad->GetViewer3D()->AddObject(buff);
+   if (reqSections != TBuffer3D::kNone)
+      Error(eh, "only direct GL rendering supported.");
+}
diff --git a/EVE/EveBase/TEveJetCone.h b/EVE/EveBase/TEveJetCone.h
new file mode 100644 (file)
index 0000000..d312653
--- /dev/null
@@ -0,0 +1,55 @@
+// @(#)root/eve:$Id$
+// Author: Matevz Tadel 2007
+
+/*************************************************************************
+ * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
+ * All rights reserved.                                                  *
+ *                                                                       *
+ * For the licensing terms see $ROOTSYS/LICENSE.                         *
+ * For the list of contributors see $ROOTSYS/README/CREDITS.             *
+ *************************************************************************/
+
+#ifndef ROOT_TEveJetCone
+#define ROOT_TEveJetCone
+
+#include "TEveElement.h"
+#include "TEveVSDStructs.h"
+#include "TAttBBox.h"
+
+class TEveJetCone : public TEveElementList,
+                    public TAttBBox
+{
+   friend class TEveJetConeGL;
+
+private:
+   TEveJetCone(const TEveJetCone&);            // Not implemented
+   TEveJetCone& operator=(const TEveJetCone&); // Not implemented
+
+protected:
+   typedef std::vector<TEveVector>        vTEveVector_t;
+   typedef vTEveVector_t::iterator        vTEveVector_i;
+   typedef vTEveVector_t::const_iterator  vTEveVector_ci;
+
+   TEveVector      fApex;
+   vTEveVector_t   fBasePoints;
+
+public:
+   TEveJetCone(const Text_t* n="TEveJetCone", const Text_t* t="");
+   virtual ~TEveJetCone() {}
+
+   void SetApex(const TEveVector& a)      { fApex = a; }
+   void AddBasePoint(const TEveVector& p) { fBasePoints.push_back(p); }
+
+   // void SetBaseFromEtaPhi(radius, eta, phi, deta, dphi);
+
+   virtual Bool_t  CanEditMainTransparency() const { return kTRUE; }
+
+   // For TAttBBox:
+   virtual void ComputeBBox();
+   // If painting is needed:
+   virtual void Paint(Option_t* option="");
+
+   ClassDef(TEveJetCone, 0); // Short description.
+};
+
+#endif
diff --git a/EVE/EveBase/TEveJetConeEditor.cxx b/EVE/EveBase/TEveJetConeEditor.cxx
new file mode 100644 (file)
index 0000000..26e68dc
--- /dev/null
@@ -0,0 +1,73 @@
+// @(#)root/eve:$Id$
+// Author: Matevz Tadel 2007
+
+/*************************************************************************
+ * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
+ * All rights reserved.                                                  *
+ *                                                                       *
+ * For the licensing terms see $ROOTSYS/LICENSE.                         *
+ * For the list of contributors see $ROOTSYS/README/CREDITS.             *
+ *************************************************************************/
+
+#include "TEveJetConeEditor.h"
+#include "TEveJetCone.h"
+
+#include "TVirtualPad.h"
+#include "TColor.h"
+
+// Cleanup these includes:
+#include "TGLabel.h"
+#include "TGButton.h"
+#include "TGNumberEntry.h"
+#include "TGColorSelect.h"
+#include "TGDoubleSlider.h"
+
+
+//______________________________________________________________________________
+// GUI editor for TEveJetCone.
+//
+
+ClassImp(TEveJetConeEditor)
+
+//______________________________________________________________________________
+TEveJetConeEditor::TEveJetConeEditor(const TGWindow *p, Int_t width, Int_t height,
+             UInt_t options, Pixel_t back) :
+   TGedFrame(p, width, height, options | kVerticalFrame, back),
+   fM(0)
+   // Initialize widget pointers to 0
+{
+   // Constructor.
+
+   MakeTitle("TEveJetCone");
+
+   // Create widgets
+   // fXYZZ = new TGSomeWidget(this, ...);
+   // AddFrame(fXYZZ, new TGLayoutHints(...));
+   // fXYZZ->Connect("SignalName()", "Reve::TEveJetConeEditor", this, "DoXYZZ()");
+}
+
+/******************************************************************************/
+
+//______________________________________________________________________________
+void TEveJetConeEditor::SetModel(TObject* obj)
+{
+   // Set model object.
+
+   fM = dynamic_cast<TEveJetCone*>(obj);
+
+   // Set values of widgets
+   // fXYZZ->SetValue(fM->GetXYZZ());
+}
+
+/******************************************************************************/
+
+// Implements callback/slot methods
+
+//______________________________________________________________________________
+// void TEveJetConeEditor::DoXYZZ()
+// {
+//    // Slot for XYZZ.
+//
+//    fM->SetXYZZ(fXYZZ->GetValue());
+//    Update();
+// }
diff --git a/EVE/EveBase/TEveJetConeEditor.h b/EVE/EveBase/TEveJetConeEditor.h
new file mode 100644 (file)
index 0000000..a1965b5
--- /dev/null
@@ -0,0 +1,49 @@
+// @(#)root/eve:$Id$
+// Author: Matevz Tadel 2007
+
+/*************************************************************************
+ * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
+ * All rights reserved.                                                  *
+ *                                                                       *
+ * For the licensing terms see $ROOTSYS/LICENSE.                         *
+ * For the list of contributors see $ROOTSYS/README/CREDITS.             *
+ *************************************************************************/
+
+#ifndef ROOT_TEveJetConeEditor
+#define ROOT_TEveJetConeEditor
+
+#include "TGedFrame.h"
+
+class TGButton;
+class TGCheckButton;
+class TGNumberEntry;
+class TGColorSelect;
+
+class TEveJetCone;
+
+class TEveJetConeEditor : public TGedFrame
+{
+private:
+   TEveJetConeEditor(const TEveJetConeEditor&);            // Not implemented
+   TEveJetConeEditor& operator=(const TEveJetConeEditor&); // Not implemented
+
+protected:
+   TEveJetCone            *fM; // Model object.
+
+   // Declare widgets
+   // TGSomeWidget*   fXYZZ;
+
+public:
+   TEveJetConeEditor(const TGWindow* p=0, Int_t width=170, Int_t height=30,
+         UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground());
+   virtual ~TEveJetConeEditor() {}
+
+   virtual void SetModel(TObject* obj);
+
+   // Declare callback/slot methods
+   // void DoXYZZ();
+
+   ClassDef(TEveJetConeEditor, 0); // GUI editor for TEveJetCone.
+};
+
+#endif
diff --git a/EVE/EveBase/TEveJetConeGL.cxx b/EVE/EveBase/TEveJetConeGL.cxx
new file mode 100644 (file)
index 0000000..af75216
--- /dev/null
@@ -0,0 +1,104 @@
+// @(#)root/eve:$Id$
+// Author: Matevz Tadel 2007
+
+/*************************************************************************
+ * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
+ * All rights reserved.                                                  *
+ *                                                                       *
+ * For the licensing terms see $ROOTSYS/LICENSE.                         *
+ * For the list of contributors see $ROOTSYS/README/CREDITS.             *
+ *************************************************************************/
+
+#include "TEveJetConeGL.h"
+#include "TEveJetCone.h"
+
+#include "TMath.h"
+
+#include "TGLRnrCtx.h"
+#include "TGLIncludes.h"
+
+//______________________________________________________________________________
+// OpenGL renderer class for TEveJetCone.
+//
+
+ClassImp(TEveJetConeGL)
+
+//______________________________________________________________________________
+TEveJetConeGL::TEveJetConeGL() :
+   TGLObject(), fM(0)
+{
+   // Constructor.
+
+   // fDLCache = kFALSE; // Disable display list.
+}
+
+/******************************************************************************/
+
+//______________________________________________________________________________
+Bool_t TEveJetConeGL::SetModel(TObject* obj, const Option_t* /*opt*/)
+{
+   // Set model object.
+
+   if (SetModelCheckClass(obj, TEveJetCone::Class())) {
+      fM = dynamic_cast<TEveJetCone*>(obj);
+      return kTRUE;
+   }
+   return kFALSE;
+}
+
+//______________________________________________________________________________
+void TEveJetConeGL::SetBBox()
+{
+   // Set bounding box.
+
+   // !! This ok if master sub-classed from TAttBBox
+   SetAxisAlignedBBox(((TEveJetCone*)fExternalObj)->AssertBBox());
+}
+
+/******************************************************************************/
+
+//______________________________________________________________________________
+void TEveJetConeGL::DirectDraw(TGLRnrCtx & rnrCtx) const
+{
+   // Render with OpenGL.
+
+   printf("TEveJetConeGL::DirectDraw LOD %d\n", rnrCtx.CombiLOD());
+
+   glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
+
+   glDisable(GL_CULL_FACE);
+   glEnable(GL_NORMALIZE);
+
+   glBegin(GL_TRIANGLE_FAN);
+   glVertex3fv(fM->fApex);
+   if ( fM->fBasePoints.size() > 2)
+   {
+      TEveJetCone::vTEveVector_ci prev = fM->fBasePoints.end(); --prev;
+      TEveJetCone::vTEveVector_ci i    = fM->fBasePoints.begin();
+      TEveJetCone::vTEveVector_ci next = i; ++next;
+
+      TEveVector norm_buf;
+      TEveVector beg_normal = TMath::Cross((*i - fM->fApex).Arr(), (*next - *prev).Arr(), norm_buf.Arr());
+
+      glNormal3fv(beg_normal);
+      glVertex3fv(fM->fBasePoints.front());
+
+      prev = i;  i = next;  ++next;
+
+      while (i != fM->fBasePoints.begin())
+      {
+         glNormal3fv(TMath::Cross((*i - fM->fApex).Arr(), (*next - *prev).Arr(), norm_buf.Arr()));
+         glVertex3fv(*i);
+
+         prev = i;
+         i    = next;
+         ++next; if (next == fM->fBasePoints.end()) next = fM->fBasePoints.begin();
+      }
+         
+      glNormal3fv(beg_normal);
+      glVertex3fv(fM->fBasePoints.front());
+   }
+   glEnd();
+
+   glPopAttrib();
+}
diff --git a/EVE/EveBase/TEveJetConeGL.h b/EVE/EveBase/TEveJetConeGL.h
new file mode 100644 (file)
index 0000000..ef53f10
--- /dev/null
@@ -0,0 +1,47 @@
+// @(#)root/eve:$Id$
+// Author: Matevz Tadel 2007
+
+/*************************************************************************
+ * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
+ * All rights reserved.                                                  *
+ *                                                                       *
+ * For the licensing terms see $ROOTSYS/LICENSE.                         *
+ * For the list of contributors see $ROOTSYS/README/CREDITS.             *
+ *************************************************************************/
+
+#ifndef ROOT_TEveJetConeGL
+#define ROOT_TEveJetConeGL
+
+#include "TGLObject.h"
+
+class TGLViewer;
+class TGLScene;
+
+class TEveJetCone;
+
+class TEveJetConeGL : public TGLObject
+{
+private:
+   TEveJetConeGL(const TEveJetConeGL&);            // Not implemented
+   TEveJetConeGL& operator=(const TEveJetConeGL&); // Not implemented
+
+protected:
+   TEveJetCone             *fM;  // Model object.
+
+public:
+   TEveJetConeGL();
+   virtual ~TEveJetConeGL() {}
+
+   virtual Bool_t SetModel(TObject* obj, const Option_t* opt=0);
+   virtual void   SetBBox();
+
+   virtual void DirectDraw(TGLRnrCtx & rnrCtx) const;
+
+   // To support two-level selection
+   // virtual Bool_t SupportsSecondarySelect() const { return kTRUE; }
+   // virtual void ProcessSelection(TGLRnrCtx & rnrCtx, TGLSelectRecord & rec);
+
+   ClassDef(TEveJetConeGL, 0); // GL renderer class for TEveJetCone.
+};
+
+#endif