AntarcticaBackground.h
1 /* -*- C++ -*-.*********************************************************************************************
2  Author: Ben Strutt
3  Email: strutt@physics.ucla.edu
4 
5  Description:
6  TProfile2D to contain the map of antarctica for pretty, interactive plotting.
7  Honed to "perfection" (well, a functional state) on a flight from London to Los Angeles.
8 ***********************************************************************************************************/
9 
10 #ifndef ANTARCTICA_BACKGROUND_H
11 #define ANTARCTICA_BACKGROUND_H
12 
13 #include "TProfile2D.h"
14 #include "RampdemReader.h"
15 #include "RVersion.h"
16 #include "TColor.h"
17 
18 class TExec;
19 class TGToolTip;
20 class TGraphAntarctica;
21 class TPad;
22 
24  const int defaultCoarseness = 10;
25  const double zAxisTextSize = 0.02;
26  const double zAxisWidth = 0.03;
27  const double zAxisHeight = 0.4;
28  const double zAxisRightMargin = 0.02;
29  const double zAxisTopBottomMargin = 0.02;
30  const TString drawOpt = "";
31 }
32 
33 
34 class AntarcticaBackground : public TProfile2D {
35 
36 
37 public:
38 
39  AntarcticaBackground(RampdemReader::dataSet dataSet = RampdemReader::thickness,
40  Int_t coarseness = AntarcticaBackgroundDefaults::defaultCoarseness);
41  virtual ~AntarcticaBackground();
42 
43  virtual void Draw(Option_t* opt = "");
44 
45  // Interactive plotting fun
46  // Enable for extra info on mouse over...
47  void UnZoom(){fXaxis.UnZoom();fYaxis.UnZoom();} // *MENU
48 
49  void SetGrayScale(bool greyScale); //*TOGGLE* *GETTER=GetGrayScale
50  Bool_t GetGrayScale() const;
51 
52  void SetToolTip(Bool_t toolTip); // *TOGGLE* *GETTER=GetToolTip
53  Bool_t GetToolTip() const;
54 
55  void SetShowBases(Bool_t showBases); // *TOGGLE* *GETTER=GetShowBases
56  Bool_t GetShowBases() const;
57 
58  // Click on the map to choose which RAMPDEM/BEDMAP2 data and set resolution.
59  Int_t GetCoarseness() const;
60  void SetCoarseness(Int_t coarseness); // *MENU* *ARGS={coarseness=>fCoarseness}
61 
62  void SetRampdem(bool useRampdem); //*TOGGLE* *GETTER=GetRampdem
63  Bool_t GetRampdem() const;
64 
65  void SetBed(bool useBed); //*TOGGLE* *GETTER=GetBed
66  Bool_t GetBed() const;
67 
68  void SetIcemask(bool useIcemask); //*TOGGLE* *GETTER=GetIcemask
69  Bool_t GetIcemask() const;
70 
71  void SetSurface(bool useSurface); //*TOGGLE* *GETTER=GetSurface
72  Bool_t GetSurface() const;
73 
74  void SetThickness(bool useThickness); //*TOGGLE* *GETTER=GetThickness
75  Bool_t GetThickness() const;
76 
77  void SetGrid(Bool_t grid); //*TOGGLE* *GETTER=GetGrid
78  Bool_t GetGrid() const;
79 
80  void SetGridDivisions(Int_t deltaLon, Int_t deltaLat); // *MENU* *ARGS={deltaLat=>fDeltaLon, deltaLon=>fDeltaLat}
81 
82  void SetShowColorAxis(Bool_t showZaxis); // *TOGGLE* *GETTER=GetShowColorAxis
83  Bool_t GetShowColorAxis() const {return fShowColorAxis;}
84 
85  void ResetColorAxis(bool trigger_redraw = false); // *MENU
86 
87  const char* getToolTipUnits(){return fToolTipUnits.Data();}
88 
89  RampdemReader::dataSet GetDataSet() const;
90  void SetDataSet(RampdemReader::dataSet dataSet);
91  void ExecuteEvent(Int_t event, Int_t x, Int_t y);
92  void updateToolTip(Int_t event, Int_t x, Int_t y, const char* extraInfo = NULL);
93 
94  // needs to be public and accessible for other classes that want to find one of these on their canvases
95  static const char* getDefaultName(){return "fAntarctica";}
96 
97  void setPalette();
98  void unsetPalette();
99 
100  // at some point, supporting ROOT versions < 6 is gonna be impossible...
101 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
102  std::map<RampdemReader::dataSet, EColorPalette> palettes;
103  float opacity;
104 #endif
105 
106  void scale(double newMin, double newMax);
107 private:
108 
109  Double_t fMinVal;
110  Double_t fMaxVal;
111 
112  Int_t fCoarseness; // map coarseness factor
113  RampdemReader::dataSet fDataSet; // rampdem data set
114  Bool_t needRemakeHist; // if changed coarseness or data set
115  Bool_t fGrayScale;
116 
117  Bool_t fGrid;
118  Int_t fDeltaLon;
119  Int_t fDeltaLat;
120  void updateGrid();
121  void deleteGrid();
122  std::vector<TGraphAntarctica*> grGrids;
123 
124  Int_t fGridPoints;
125  Bool_t needRemakeGrid; // if changed grid settings
126  void updateHist();
127  void init(RampdemReader::dataSet dataSet, Int_t coarseness); // in case I ever want another constructor
128 
129  void setPadMargins();
130 
131  Bool_t fUseToolTip;
132  TGToolTip* fToolTip;
133  TString fToolTipUnits;
134  void setToolTipUnits();
135 
136  Bool_t fBases;
137  Bool_t fDrawBasesOnTop;
138  std::vector<TGraphAntarctica*> grBases;
139  void updateBases();
140 
141  Bool_t fDrawnSelf; // Set by Draw(), help the updateHist() function to do sensible things
142  void updateGPadPrims(std::vector<TGraphAntarctica*>& grs, Bool_t drawThem, Option_t* opt, bool drawOnTop=false);
143 
144  std::vector<Int_t> fOldPalette;
145  Bool_t fOldGrayScale;
146  TExec* fPalSetter;
147  TExec* fPalUnsetter;
148  std::vector<TPad*> fPads;
149  double fScaleMin;
150  double fScaleMax;
151  Bool_t fShowColorAxis;
152  TH2D hDummy;
153  ClassDef(AntarcticaBackground, 0)
154 
155 };
156 
157 
158 
159 #endif
void ExecuteEvent(Int_t event, Int_t x, Int_t y)
virtual void Draw(Option_t *opt="")
float opacity
Does not persist in ROOT!
void scale(double newMin, double newMax)
Does not persist in ROOT!
void ResetColorAxis(bool trigger_redraw=false)