Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:29:48

0001 // Author: Andrei Gheata   05/03/02
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 #ifndef ROOT_TGeoPainter
0011 #define ROOT_TGeoPainter
0012 
0013 //////////////////////////////////////////////////////////////////////////
0014 //                                                                      //
0015 // TGeoPainter                                                          //
0016 //                                                                      //
0017 // Painter class utility TGeo geometries. Interfaces visualization      //
0018 // queries with the viewers.                                            //
0019 //                                                                      //
0020 //////////////////////////////////////////////////////////////////////////
0021 
0022 #include "TVirtualGeoPainter.h"
0023 
0024 #include "TGeoManager.h"
0025 
0026 class TString;
0027 class TGeoHMatrix;
0028 class TGeoNode;
0029 class TGeoVolume;
0030 class TGeoShape;
0031 class TVirtualGeoTrack;
0032 class TGeoPhysicalNode;
0033 class TGeoOverlap;
0034 class TGeoBatemanSol;
0035 class TGeoPolygon;
0036 
0037 class TGeoPainter : public TVirtualGeoPainter {
0038 private:
0039    Double_t fBombX;             // bomb factor on X
0040    Double_t fBombY;             // bomb factor on Y
0041    Double_t fBombZ;             // bomb factor on Z
0042    Double_t fBombR;             // bomb factor on radius (cyl or sph)
0043    Double_t fCheckedBox[6];     // bounding box of checked node
0044    Double_t fMat[9];            // view rotation matrix
0045    Int_t fNsegments;            // number of segments approximating circles
0046    Int_t fNVisNodes;            // number of visible nodes
0047    Int_t fVisLevel;             // depth for drawing
0048    Int_t fVisOption;            // global visualization option
0049    Int_t fExplodedView;         // type of exploding current view
0050    Bool_t fVisLock;             // lock for adding visible volumes
0051    Bool_t fTopVisible;          // set top volume visible
0052    Bool_t fPaintingOverlaps;    // lock overlaps painting
0053    Bool_t fIsRaytracing;        // raytracing flag
0054    Bool_t fIsPaintingShape;     // flag for shape painting
0055    TString fVisBranch;          // drawn branch
0056    TString fVolInfo;            // volume info
0057    TGeoNode *fCheckedNode;      // checked node
0058    TGeoOverlap *fOverlap;       // current overlap
0059    TGeoHMatrix *fGlobal;        // current global matrix
0060    TBuffer3D *fBuffer;          // buffer used for painting
0061    TGeoManager *fGeoManager;    // geometry to which applies
0062    TGeoShape *fClippingShape;   // clipping shape
0063    TGeoVolume *fTopVolume;      // top drawn volume
0064    TGeoVolume *fLastVolume;     // last drawn volume
0065    TGeoIteratorPlugin *fPlugin; // User iterator plugin for changing pain volume properties
0066    TObjArray *fVisVolumes;      // list of visible volumes
0067    Bool_t fIsEditable;          // flag that geometry is editable
0068 
0069    void DefineColors() const;
0070    void LocalToMasterVect(const Double_t *local, Double_t *master) const;
0071 
0072 protected:
0073    void ClearVisibleVolumes();
0074 
0075 public:
0076    TGeoPainter(TGeoManager *manager);
0077    ~TGeoPainter() override;
0078 
0079    void AddSize3D(Int_t numpoints, Int_t numsegs, Int_t numpolys) override;
0080    TVirtualGeoTrack *AddTrack(Int_t id, Int_t pdgcode, TObject *part) override;
0081    void AddTrackPoint(Double_t *point, Double_t *box, Bool_t reset = kFALSE) override;
0082    void BombTranslation(const Double_t *tr, Double_t *bombtr) override;
0083    void CheckEdit();
0084    Int_t CountNodes(TGeoVolume *vol, Int_t level) const;
0085    Int_t CountVisibleNodes() override;
0086    void DefaultAngles() override;
0087    void DefaultColors() override;
0088    Int_t DistanceToPrimitiveVol(TGeoVolume *vol, Int_t px, Int_t py) override;
0089    void Draw(Option_t *option = "") override;
0090    void DrawBatemanSol(TGeoBatemanSol *sol, Option_t *option = "") override;
0091    void DrawOverlap(void *ovlp, Option_t *option = "") override;
0092    void DrawCurrentPoint(Int_t color) override;
0093    void DrawOnly(Option_t *option = "") override;
0094    void DrawPanel() override;
0095    void DrawPath(const char *path, Option_t *option = "") override;
0096    void DrawPolygon(const TGeoPolygon *poly) override;
0097    void DrawShape(TGeoShape *shape, Option_t *option = "") override;
0098    void DrawVolume(TGeoVolume *vol, Option_t *option = "") override;
0099    void EditGeometry(Option_t *option = "") override;
0100    void EstimateCameraMove(Double_t tmin, Double_t tmax, Double_t *start, Double_t *end) override;
0101    void ExecuteManagerEvent(TGeoManager *geom, Int_t event, Int_t px, Int_t py) override;
0102    void ExecuteShapeEvent(TGeoShape *shape, Int_t event, Int_t px, Int_t py) override;
0103    void ExecuteVolumeEvent(TGeoVolume *volume, Int_t event, Int_t px, Int_t py) override;
0104    const char *GetVolumeInfo(const TGeoVolume *volume, Int_t px, Int_t py) const override;
0105    void GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const override
0106    {
0107       bombx = fBombX;
0108       bomby = fBombY;
0109       bombz = fBombZ;
0110       bombr = fBombR;
0111    }
0112    Int_t GetBombMode() const override { return fExplodedView; }
0113    TGeoNode *GetCheckedNode() { return fCheckedNode; }
0114    Int_t GetColor(Int_t base, Float_t light) const override;
0115    const char *GetDrawPath() const override { return fVisBranch.Data(); }
0116    TGeoVolume *GetDrawnVolume() const override;
0117    TGeoVolume *GetTopVolume() const override { return fTopVolume; }
0118    Int_t GetVisLevel() const override { return fVisLevel; }
0119    Int_t GetVisOption() const override { return fVisOption; }
0120    Int_t GetNsegments() const override { return fNsegments; }
0121    void GrabFocus(Int_t nfr = 0, Double_t dlong = 0, Double_t dlat = 0, Double_t dpsi = 0) override;
0122    Double_t *GetViewBox() override { return &fCheckedBox[0]; }
0123    void GetViewAngles(Double_t &longitude, Double_t &latitude, Double_t &psi) override;
0124    Bool_t IsExplodedView() const override { return (fExplodedView == kGeoVisDefault) ? kFALSE : kTRUE; }
0125    Bool_t IsRaytracing() const override { return fIsRaytracing; }
0126    Bool_t IsPaintingShape() const override { return fIsPaintingShape; }
0127    void Lock(Bool_t flag = kTRUE) { fVisLock = flag; }
0128    void ModifiedPad(Bool_t update = kFALSE) const override;
0129    void Paint(Option_t *option = "") override;
0130    void PaintNode(TGeoNode *node, Option_t *option = "", TGeoMatrix *global = nullptr) override;
0131    Bool_t PaintShape(const TGeoShape &shape, Option_t *option) const;
0132    void PaintShape(TGeoShape *shape, Option_t *option = "") override;
0133    void PaintOverlap(void *ovlp, Option_t *option = "") override;
0134    void PaintVolume(TGeoVolume *vol, Option_t *option = "", TGeoMatrix *global = nullptr) override;
0135    void PaintPhysicalNode(TGeoPhysicalNode *node, Option_t *option = "");
0136    void Raytrace(Option_t *option = "") override;
0137    void SetBombFactors(Double_t bombx = 1.3, Double_t bomby = 1.3, Double_t bombz = 1.3, Double_t bombr = 1.3) override;
0138    void SetClippingShape(TGeoShape *shape) override { fClippingShape = shape; }
0139    void SetExplodedView(Int_t iopt = 0) override;
0140    void SetNsegments(Int_t nseg = 20) override;
0141    void SetGeoManager(TGeoManager *geom) override { fGeoManager = geom; }
0142    void SetIteratorPlugin(TGeoIteratorPlugin *plugin) override
0143    {
0144       fPlugin = plugin;
0145       ModifiedPad();
0146    }
0147    void SetRaytracing(Bool_t flag = kTRUE) override { fIsRaytracing = flag; }
0148    void SetTopVisible(Bool_t vis = kTRUE) override;
0149    void SetTopVolume(TGeoVolume *vol) override { fTopVolume = vol; }
0150    void SetVisLevel(Int_t level = 3) override;
0151    void SetVisOption(Int_t option = 0) override;
0152    Int_t ShapeDistancetoPrimitive(const TGeoShape *shape, Int_t numpoints, Int_t px, Int_t py) const override;
0153    void UnbombTranslation(const Double_t *tr, Double_t *bombtr) override;
0154 
0155    ClassDefOverride(TGeoPainter, 0) // geometry painter
0156 };
0157 
0158 #endif