Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:28

0001 // @(#)root/eve:$Id$
0002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_REveDigitSet
0013 #define ROOT_REveDigitSet
0014 
0015 #include "TNamed.h"
0016 #include "TAtt3D.h"
0017 #include "TAttBBox.h"
0018 
0019 #include "ROOT/REveUtil.hxx"
0020 #include "ROOT/REveElement.hxx"
0021 #include "ROOT/REveFrameBox.hxx"
0022 #include "ROOT/REveRGBAPalette.hxx"
0023 #include "ROOT/REveChunkManager.hxx"
0024 #include "ROOT/REveSecondarySelectable.hxx"
0025 
0026 class TRefArray;
0027 
0028 namespace ROOT {
0029 namespace Experimental {
0030 
0031 class REveDigitSet : public REveElement,
0032                      public TAtt3D,
0033                      public TAttBBox,
0034                      public REveSecondarySelectable
0035 {
0036    friend class REveDigitSetEditor;
0037    friend class REveDigitSetGL;
0038 
0039    REveDigitSet(const REveDigitSet&);            // Not implemented
0040    REveDigitSet& operator=(const REveDigitSet&); // Not implemented
0041 
0042 public:
0043    enum ERenderMode_e { kRM_AsIs, kRM_Line, kRM_Fill };
0044 
0045    typedef void (*Callback_foo)(const REveDigitSet*, Int_t, TObject*);
0046    typedef std::string (*TooltipCB_foo)(const REveDigitSet*, Int_t);
0047 
0048    struct DigitBase_t
0049    {
0050       // Base-class for digit representation classes.
0051 
0052       Int_t  fValue;    // signal value of a digit (can be direct RGBA color)
0053       void  *fUserData{nullptr}; // user-data for given digit
0054 
0055       DigitBase_t(Int_t v=0) : fValue(v), fUserData(nullptr) {}
0056    };
0057 
0058 protected:
0059    TRefArray        *fDigitIds{nullptr};  //  Array holding references to external objects.
0060 
0061    Int_t             fDefaultValue;   //  Default signal value.
0062    Bool_t            fValueIsColor{false};   //  Interpret signal value as RGBA color.
0063    Bool_t            fSingleColor;    //  Use the same color for all digits.
0064    Bool_t            fAntiFlick;      // Make extra render pass to avoid flickering when quads are too small.
0065 
0066    Bool_t            fOwnIds{false};  //  Flag specifying if id-objects are owned by the TEveDigitSet.
0067    Bool_t            fDetIdsAsSecondaryIndices;         //  Flag specifying if id-objects are owned by the REveDigitSet.
0068    REveChunkManager  fPlex;           //  Container of digit data.
0069    DigitBase_t*      fLastDigit;      //! The last / current digit added to collection.
0070    Int_t             fLastIdx;        //! The last / current idx added to collection.
0071 
0072    Color_t           fColor;          //  Color used for frame (or all digis with single-color).
0073    REveFrameBox*     fFrame;          //  Pointer to frame structure.
0074    REveRGBAPalette*  fPalette;        //  Pointer to signal-color palette.
0075    ERenderMode_e     fRenderMode;     //  Render mode: as-is / line / filled.
0076    Bool_t            fSelectViaFrame; //  Allow selection via frame.
0077    Bool_t            fHighlightFrame; //  Highlight frame when object is selected.
0078    Bool_t            fDisableLighting;//  Disable lighting for rendering.
0079    Bool_t            fHistoButtons;   //  Show histogram buttons in object editor.
0080 
0081    Bool_t            fEmitSignals;    //  Emit signals on secondary-select.
0082    Callback_foo      fCallbackFoo;    //! Additional function to call on secondary-select.
0083    TooltipCB_foo     fTooltipCBFoo;   //! Function providing highlight tooltips when always-sec-select is active.
0084 
0085    DigitBase_t* NewDigit();
0086    void         ReleaseIds();
0087 
0088 public:
0089    REveDigitSet(const char* n="REveDigitSet", const char* t="");
0090    ~REveDigitSet() override;
0091 
0092    void   UseSingleColor();
0093 
0094    Bool_t GetAntiFlick() const   { return fAntiFlick; }
0095    void   SetAntiFlick(Bool_t f) { fAntiFlick = f; }
0096 
0097    void SetMainColor(Color_t color) override;
0098 
0099    /*
0100    virtual void UnSelected();
0101    virtual void UnHighlighted();
0102 */
0103    using REveElement::GetHighlightTooltip;
0104    std::string GetHighlightTooltip(const std::set<int>& secondary_idcs) const override;
0105 
0106    // Implemented in sub-classes:
0107    // virtual void Reset(EQuadType_e quadType, Bool_t valIsCol, Int_t chunkSize);
0108 
0109    void RefitPlex();
0110    void ScanMinMaxValues(Int_t& min, Int_t& max);
0111 
0112    // --------------------------------
0113 
0114    void SetCurrentDigit(Int_t idx);
0115 
0116    void DigitValue(Int_t value);
0117    void DigitColor(Color_t ci);
0118    void DigitColor(Color_t ci, Char_t transparency);
0119    void DigitColor(UChar_t r, UChar_t g, UChar_t b, UChar_t a=255);
0120    void DigitColor(UChar_t* rgba);
0121 
0122    void   DigitId(TObject* id);
0123    void   DigitId(Int_t n, TObject* id);
0124 
0125    Bool_t GetDetIdsAsSecondaryIndices() const     { return fDetIdsAsSecondaryIndices; }
0126    void   SetDetIdsAsSecondaryIndices(Bool_t o)   { fDetIdsAsSecondaryIndices = o; }
0127 
0128    DigitBase_t* GetDigit(Int_t n) const { return (DigitBase_t*) fPlex.Atom(n); }
0129    TObject*  GetId(Int_t n) const;
0130 
0131    // --------------------------------
0132 
0133    // Implemented in subclasses:
0134    // virtual void ComputeBBox();
0135    /*
0136    virtual void Paint(Option_t* option="");
0137 
0138    virtual void DigitSelected(Int_t idx);
0139    virtual void SecSelected(REveDigitSet* qs, Int_t idx); // *SIGNAL*
0140    */
0141    // --------------------------------
0142 
0143    REveChunkManager* GetPlex() { return &fPlex; }
0144 
0145    REveFrameBox* GetFrame() const { return fFrame; }
0146    void          SetFrame(REveFrameBox* b);
0147 
0148    Bool_t GetSelectViaFrame() const    { return fSelectViaFrame; }
0149    void   SetSelectViaFrame(Bool_t sf) { fSelectViaFrame = sf; }
0150 
0151    Bool_t GetHighlightFrame() const    { return fHighlightFrame; }
0152    void   SetHighlightFrame(Bool_t hf) { fHighlightFrame = hf; }
0153 
0154    Bool_t GetValueIsColor()  const { return fValueIsColor; }
0155 
0156    REveRGBAPalette* GetPalette() const { return fPalette; }
0157    void             SetPalette(REveRGBAPalette* p);
0158    REveRGBAPalette* AssertPalette();
0159 
0160    ERenderMode_e  GetRenderMode()           const { return fRenderMode; }
0161    void           SetRenderMode(ERenderMode_e rm) { fRenderMode = rm; }
0162 
0163    Bool_t GetDisableLighting() const   { return fDisableLighting; }
0164    void   SetDisableLighting(Bool_t l) { fDisableLighting = l; }
0165 
0166    Bool_t GetHistoButtons() const   { return fHistoButtons; }
0167    void   SetHistoButtons(Bool_t f) { fHistoButtons = f; }
0168 
0169    Bool_t GetEmitSignals() const   { return fEmitSignals; }
0170    void   SetEmitSignals(Bool_t f) { fEmitSignals = f; }
0171 
0172    Callback_foo GetCallbackFoo()         const { return fCallbackFoo; }
0173    void         SetCallbackFoo(Callback_foo f) { fCallbackFoo = f; }
0174 
0175    TooltipCB_foo GetTooltipCBFoo()          const { return fTooltipCBFoo; }
0176    void          SetTooltipCBFoo(TooltipCB_foo f) { fTooltipCBFoo = f; }
0177 
0178    bool    IsDigitVisible(const DigitBase_t*) const;
0179    int     GetAtomIdxFromShapeIdx(int) const;
0180    int     GetShapeIdxFromAtomIdx(int) const;
0181 
0182    void    NewShapePicked(int shapeId, Int_t selectionId, bool multi);
0183 
0184 
0185    bool    RequiresExtraSelectionData() const override { return GetAlwaysSecSelect(); };
0186    void    FillExtraSelectionData(nlohmann::json& j, const std::set<int>& secondary_idcs) const override;
0187 
0188    Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
0189 };
0190 
0191 } // namespace Experimental
0192 } // namespace ROOT
0193 #endif