Merge from EVE-dev to HEAD.
[u/mrichter/AliRoot.git] / EVE / Alieve / TPCSector2DEditor.cxx
1 // $Header$
2
3 #include "TPCSector2DEditor.h"
4 #include <Alieve/TPCSector2D.h>
5
6 #include <TVirtualPad.h>
7 #include <TColor.h>
8
9 #include <TGLabel.h>
10 #include <TGButton.h>
11 #include <TGNumberEntry.h>
12 #include <TGColorSelect.h>
13 #include <TGSlider.h>
14 #include <TGDoubleSlider.h>
15
16 using namespace Reve;
17 using namespace Alieve;
18
19 //______________________________________________________________________
20 // TPCSector2DEditor
21 //
22
23 ClassImp(TPCSector2DEditor)
24
25   TPCSector2DEditor::TPCSector2DEditor(const TGWindow *p, Int_t id, Int_t width, Int_t height,
26                                        UInt_t options, Pixel_t back) :
27     TGedFrame(p, id, width, height, options | kVerticalFrame, back)
28 {
29   fM = 0;
30   MakeTitle("TPCSector2D");
31
32   //!!! create the widgets here ...
33
34   // Register the editor.
35   // TClass *cl = TPCSector2D::Class();
36   //  TGedElement *ge = new TGedElement;
37   // ge->fGedFrame = this;
38   //  ge->fCanvas = 0;
39   //  cl->GetEditorList()->Add(ge);
40
41   fUseTexture = new TGCheckButton(this, "UseTexture");
42   AddFrame(fUseTexture, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
43   fUseTexture->Connect
44     ("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoUseTexture()");
45
46   {
47     TGHorizontalFrame* f = new TGHorizontalFrame(this);
48     fShowMax = new TGCheckButton(f, "ShowMax");
49     f->AddFrame(fShowMax, new TGLayoutHints(kLHintsLeft, 3, 16, 1, 0));
50     fShowMax->Connect("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoShowMax()");
51     fAverage = new TGCheckButton(f, "Average");
52     f->AddFrame(fAverage, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0));
53     fAverage->Connect("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoAverage()");
54     AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
55   }
56
57   // Register the editor.
58   TClass *cl = TPCSector2DEditor::Class();
59   TGedElement *ge = new TGedElement;
60   ge->fGedFrame = this;
61   ge->fCanvas = 0;
62   cl->GetEditorList()->Add(ge);
63 }
64
65 TPCSector2DEditor::~TPCSector2DEditor()
66 {}
67
68 /**************************************************************************/
69
70 void TPCSector2DEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t )
71 {
72   fModel = 0;
73   fPad   = 0;
74
75   if (!obj || !obj->InheritsFrom(TPCSector2D::Class()) || obj->InheritsFrom(TVirtualPad::Class())) {
76     SetActive(kFALSE);
77     return;
78   }
79
80   fModel = obj;
81   fPad   = pad;
82
83   fM = dynamic_cast<TPCSector2D*>(fModel);
84
85   fShowMax->SetState(fM->fShowMax ? kButtonDown : kButtonUp);
86   SetupAverage();
87
88   fUseTexture->SetState(fM->fUseTexture ? kButtonDown : kButtonUp);
89
90   SetActive();
91 }
92
93 /**************************************************************************/
94
95 void TPCSector2DEditor::DoShowMax()
96 {
97   fM->SetShowMax(fShowMax->IsOn());
98   SetupAverage();
99   Update();
100 }
101
102 void TPCSector2DEditor::DoAverage()
103 {
104   fM->SetAverage(fAverage->IsOn());
105   Update();
106 }
107
108 void TPCSector2DEditor::SetupAverage()
109 {
110   if(fM->fShowMax) {
111     fAverage->SetEnabled(kFALSE);
112   } else {
113     fAverage->SetEnabled(kTRUE);
114     fAverage->SetState(fM->fAverage ? kButtonDown : kButtonUp);
115   }
116 }
117
118 /**************************************************************************/
119
120 void TPCSector2DEditor::DoUseTexture()
121 {
122   fM->fUseTexture = fUseTexture->IsOn();
123   Update();
124 }