5a5a1232 |
1 | // $Header$ |
2 | |
915dabe1 |
3 | #include "TPCSector2DEditor.h" |
4 | #include <Alieve/TPCSector2D.h> |
5a5a1232 |
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 | //______________________________________________________________________ |
915dabe1 |
20 | // TPCSector2DEditor |
5a5a1232 |
21 | // |
22 | |
915dabe1 |
23 | ClassImp(TPCSector2DEditor) |
5a5a1232 |
24 | |
684070b7 |
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) |
5a5a1232 |
28 | { |
29 | fM = 0; |
915dabe1 |
30 | MakeTitle("TPCSector2D"); |
5a5a1232 |
31 | |
5a5a1232 |
32 | fUseTexture = new TGCheckButton(this, "UseTexture"); |
33 | AddFrame(fUseTexture, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0)); |
34 | fUseTexture->Connect |
915dabe1 |
35 | ("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoUseTexture()"); |
5a5a1232 |
36 | |
5a5a1232 |
37 | { |
38 | TGHorizontalFrame* f = new TGHorizontalFrame(this); |
b56d8877 |
39 | fShowMax = new TGCheckButton(f, "ShowMax"); |
40 | f->AddFrame(fShowMax, new TGLayoutHints(kLHintsLeft, 3, 16, 1, 0)); |
41 | fShowMax->Connect("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoShowMax()"); |
42 | fAverage = new TGCheckButton(f, "Average"); |
43 | f->AddFrame(fAverage, new TGLayoutHints(kLHintsLeft, 3, 1, 1, 0)); |
44 | fAverage->Connect("Toggled(Bool_t)","Alieve::TPCSector2DEditor", this, "DoAverage()"); |
45 | AddFrame(f, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1)); |
46 | } |
47 | |
092578a7 |
48 | // Register the editor. |
915dabe1 |
49 | TClass *cl = TPCSector2DEditor::Class(); |
5a5a1232 |
50 | TGedElement *ge = new TGedElement; |
51 | ge->fGedFrame = this; |
52 | ge->fCanvas = 0; |
53 | cl->GetEditorList()->Add(ge); |
54 | } |
55 | |
915dabe1 |
56 | TPCSector2DEditor::~TPCSector2DEditor() |
5a5a1232 |
57 | {} |
58 | |
59 | /**************************************************************************/ |
60 | |
915dabe1 |
61 | void TPCSector2DEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t ) |
5a5a1232 |
62 | { |
63 | fModel = 0; |
64 | fPad = 0; |
65 | |
915dabe1 |
66 | if (!obj || !obj->InheritsFrom(TPCSector2D::Class()) || obj->InheritsFrom(TVirtualPad::Class())) { |
5a5a1232 |
67 | SetActive(kFALSE); |
68 | return; |
69 | } |
70 | |
71 | fModel = obj; |
72 | fPad = pad; |
73 | |
915dabe1 |
74 | fM = dynamic_cast<TPCSector2D*>(fModel); |
5a5a1232 |
75 | |
5a5a1232 |
76 | fShowMax->SetState(fM->fShowMax ? kButtonDown : kButtonUp); |
b56d8877 |
77 | SetupAverage(); |
915dabe1 |
78 | |
092578a7 |
79 | fUseTexture->SetState(fM->fUseTexture ? kButtonDown : kButtonUp); |
80 | |
5a5a1232 |
81 | SetActive(); |
82 | } |
83 | |
84 | /**************************************************************************/ |
85 | |
915dabe1 |
86 | void TPCSector2DEditor::DoShowMax() |
5a5a1232 |
87 | { |
88 | fM->SetShowMax(fShowMax->IsOn()); |
b56d8877 |
89 | SetupAverage(); |
90 | Update(); |
91 | } |
92 | |
93 | void TPCSector2DEditor::DoAverage() |
94 | { |
95 | fM->SetAverage(fAverage->IsOn()); |
96 | Update(); |
97 | } |
98 | |
99 | void TPCSector2DEditor::SetupAverage() |
100 | { |
101 | if(fM->fShowMax) { |
102 | fAverage->SetEnabled(kFALSE); |
103 | } else { |
104 | fAverage->SetEnabled(kTRUE); |
105 | fAverage->SetState(fM->fAverage ? kButtonDown : kButtonUp); |
106 | } |
107 | } |
108 | |
092578a7 |
109 | /**************************************************************************/ |
b56d8877 |
110 | |
092578a7 |
111 | void TPCSector2DEditor::DoUseTexture() |
b56d8877 |
112 | { |
092578a7 |
113 | fM->fUseTexture = fUseTexture->IsOn(); |
5a5a1232 |
114 | Update(); |
115 | } |