Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGLScenePad.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Matevz Tadel, Jun 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGLScenePad
13 #define ROOT_TGLScenePad
14 
15 #include "TGLScene.h"
16 #include "TVirtualViewer3D.h"
17 #include "CsgOps.h"
18 
19 
20 class TGLViewer;
21 class TGLFaceSet;
22 class TList;
23 
24 
25 class TGLScenePad : public TVirtualViewer3D, public TGLScene {
26 
27 private:
28  TGLScenePad(const TGLScenePad&); // Not implemented
29  TGLScenePad& operator=(const TGLScenePad&); // Not implemented
30 
31 protected:
32  TVirtualPad* fPad;
33 
34  // For building via VV3D
35  Bool_t fInternalPIDs; //! using internal physical IDs
36  UInt_t fNextInternalPID; //! next internal physical ID (from 1 - 0 reserved)
37  UInt_t fLastPID; //! last physical ID that was processed in AddObject()
38  Int_t fAcceptedPhysicals;
39 
40  Int_t ValidateObjectBuffer(const TBuffer3D& buffer, Bool_t includeRaw) const;
41  TGLLogicalShape* CreateNewLogical(const TBuffer3D & buffer) const;
42  TGLPhysicalShape* CreateNewPhysical(UInt_t physicalID, const TBuffer3D& buffer,
43  const TGLLogicalShape& logical) const;
44 
45  void ComposePolymarker(const TList *padPrimitives);
46  // Composite shape specific
47  typedef std::pair<UInt_t, RootCsg::TBaseMesh*> CSPart_t;
48  mutable TGLFaceSet *fComposite; //! Paritally created composite
49  UInt_t fCSLevel;
50  std::vector<CSPart_t> fCSTokens;
51  RootCsg::TBaseMesh* BuildComposite();
52 
53  TGLLogicalShape* AttemptDirectRenderer(TObject* id);
54 
55  Bool_t fSmartRefresh; //! cache logicals during scene rebuilds
56 
57 public:
58  TGLScenePad(TVirtualPad* pad);
59  virtual ~TGLScenePad() {}
60 
61  TVirtualPad* GetPad() const { return fPad; }
62  void SetPad(TVirtualPad* p) { fPad = p; }
63 
64  // Histo import and Sub-pad traversal
65  void AddHistoPhysical(TGLLogicalShape* log, const Float_t *histColor = 0);
66  void SubPadPaint(TVirtualPad* pad);
67 
68  // PadPaint wrapper for calls from TGLViewer:
69  virtual void PadPaintFromViewer(TGLViewer* viewer);
70 
71  Bool_t GetSmartRefresh() const { return fSmartRefresh; }
72  void SetSmartRefresh(Bool_t smart_ref) { fSmartRefresh = smart_ref; }
73 
74 
75  // TVirtualViewer3D interface
76 
77  virtual Bool_t CanLoopOnPrimitives() const { return kTRUE; }
78  virtual void PadPaint(TVirtualPad* pad);
79  virtual void ObjectPaint(TObject* obj, Option_t* opt="");
80 
81  // For now handled by viewer
82  virtual Int_t DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/) { return 9999; }
83  virtual void ExecuteEvent(Int_t /*event*/, Int_t /*px*/, Int_t /*py*/) {}
84 
85  virtual Bool_t PreferLocalFrame() const { return kTRUE; }
86 
87  virtual void BeginScene();
88  virtual Bool_t BuildingScene() const { return CurrentLock() == kModifyLock; }
89  virtual void EndScene();
90 
91  virtual Int_t AddObject(const TBuffer3D& buffer, Bool_t* addChildren = 0);
92  virtual Int_t AddObject(UInt_t physicalID, const TBuffer3D& buffer, Bool_t* addChildren = 0);
93  virtual Bool_t OpenComposite(const TBuffer3D& buffer, Bool_t* addChildren = 0);
94  virtual void CloseComposite();
95  virtual void AddCompositeOp(UInt_t operation);
96 
97  ClassDef(TGLScenePad, 0); // GL-scene filled via TPad-TVirtualViewer interface.
98 };
99 
100 #endif