ALIROOT-5420 Changes for CDH v3
[u/mrichter/AliRoot.git] / MUON / AliMUONAttPainterSelectorFrame.cxx
CommitLineData
0145e89a 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
16// $Id$
17
18///\class AliMUONAttPainterSelectorFrame
19///
20/// Widget to select painter view type
21///
22///\author Laurent Aphecetche, Subatech
23
24#include "AliMUONAttPainterSelectorFrame.h"
25
26#include "AliMUONAttPainter.h"
27#include "AliMUONPainterInterfaceHelper.h"
28#include "AliLog.h"
29#include <TGButton.h>
30#include <TGButtonGroup.h>
31
32///\cond CLASSIMP
33ClassImp(AliMUONAttPainterSelectorFrame)
34///\endcond
35
36//_____________________________________________________________________________
37AliMUONAttPainterSelectorFrame::AliMUONAttPainterSelectorFrame(TGWindow* p, UInt_t w, UInt_t h)
38: TGHorizontalFrame(p,w,h),
39fCathode(0x0),
40fPlane(0x0),
41fViewPoint(0x0),
42fAttributes()
43{
44 /// ctor
45
46 fCathode = new TGButtonGroup(this,"Cathode",kHorizontalFrame);
47
48 fAttributes.SetCathode(kTRUE,kFALSE);
49 AliMUONPainterInterfaceHelper::AddRadioButton(*fCathode,fAttributes.CathodeName(),(void*)(10));
50 fAttributes.SetCathode(kFALSE,kTRUE);
51 AliMUONPainterInterfaceHelper::AddRadioButton(*fCathode,fAttributes.CathodeName(),(void*)(1));
52
53 fPlane = new TGButtonGroup(this,"Plane",kHorizontalFrame);
54
55 fAttributes.SetPlane(kTRUE,kFALSE);
56 AliMUONPainterInterfaceHelper::AddRadioButton(*fPlane,fAttributes.PlaneName(),(void*)(10));
57 fAttributes.SetPlane(kFALSE,kTRUE);
58 AliMUONPainterInterfaceHelper::AddRadioButton(*fPlane,fAttributes.PlaneName(),(void*)(1));
59
60 fViewPoint = new TGButtonGroup(this,"ViewPoint",kHorizontalFrame);
61
62 fAttributes.SetViewPoint(kTRUE,kFALSE);
63 AliMUONPainterInterfaceHelper::AddRadioButton(*fViewPoint,fAttributes.ViewPointName(),(void*)(10));
64 fAttributes.SetViewPoint(kFALSE,kTRUE);
65 AliMUONPainterInterfaceHelper::AddRadioButton(*fViewPoint,fAttributes.ViewPointName(),(void*)(1));
66
67 fViewPoint->SetState(kFALSE); //FIXME: until we're sure back views are handled correctly
68
69 AddFrame(fCathode);
70 AddFrame(fPlane);
71 AddFrame(fViewPoint);
72
73 fCathode->Connect("Clicked(Int_t)","AliMUONAttPainterSelectorFrame",this,"CathodeClicked(Int_t)");
74 fPlane->Connect("Clicked(Int_t)","AliMUONAttPainterSelectorFrame",this,"PlaneClicked(Int_t)");
75 fViewPoint->Connect("Clicked(Int_t)","AliMUONAttPainterSelectorFrame",this,"ViewClicked(Int_t)");
76}
77
78//_____________________________________________________________________________
79AliMUONAttPainterSelectorFrame::~AliMUONAttPainterSelectorFrame()
80{
81 /// dtor
82}
83
84//_____________________________________________________________________________
85void
86AliMUONAttPainterSelectorFrame::CathodeClicked(Int_t buttonId)
87{
88 /// Cathode button clicked
89
90 fAttributes.SetPlane(kFALSE,kFALSE);
91
92 TGButton* button = fCathode->GetButton(buttonId);
93
c9756e69 94 Long_t i = reinterpret_cast<Long_t>(button->GetUserData());
0145e89a 95
96 if ( i == 10 )
97 {
98 fAttributes.SetCathode(kTRUE,kFALSE);
99 }
100 else if ( i == 1 )
101 {
102 fAttributes.SetCathode(kFALSE,kTRUE);
103 }
104 else
105 {
106 AliFatal("");
107 }
108
109 Clicked(&fAttributes);
110}
111
112//_____________________________________________________________________________
113void
114AliMUONAttPainterSelectorFrame::PlaneClicked(Int_t buttonId)
115{
116 /// Plane button clicked
117
118 fAttributes.SetCathode(kFALSE,kFALSE);
119
120 TGButton* button = fPlane->GetButton(buttonId);
121
c9756e69 122 Long_t i = reinterpret_cast<Long_t> (button->GetUserData());
0145e89a 123
124 if ( i == 10 )
125 {
126 fAttributes.SetPlane(kTRUE,kFALSE);
127 }
128 else if ( i == 1 )
129 {
130 fAttributes.SetPlane(kFALSE,kTRUE);
131 }
132 else
133 {
134 AliFatal("");
135 }
136
137 Clicked(&fAttributes);
138
139}
140
141//_____________________________________________________________________________
142void
143AliMUONAttPainterSelectorFrame::ViewClicked(Int_t buttonId)
144{
145 /// View button clicked
146
147 TGButton* button = fViewPoint->GetButton(buttonId);
148
c9756e69 149 Long_t i = reinterpret_cast<Long_t> (button->GetUserData());
0145e89a 150
151 if ( i == 10 )
152 {
153 fAttributes.SetViewPoint(kTRUE,kFALSE);
154 }
155 else if ( i == 1 )
156 {
157 fAttributes.SetViewPoint(kFALSE,kTRUE);
158 }
159 else
160 {
161 AliFatal("");
162 }
163
164 Clicked(&fAttributes);
165
166}
167
168//_____________________________________________________________________________
169void
57e2ad1a 170AliMUONAttPainterSelectorFrame::Clicked(const AliMUONAttPainter* newValues)
0145e89a 171{
172 /// Emit a signal
173
174 Long_t params[] = { (Long_t)newValues };
175
176 Emit("Clicked(AliMUONAttPainter*)",params);
177}
178
179//_____________________________________________________________________________
180void
181AliMUONAttPainterSelectorFrame::Update(const AliMUONAttPainter& att)
182{
183 /// Update button state from the painter attributes
184
185 AliMUONPainterInterfaceHelper::Unselect(*fCathode,"*");
186 AliMUONPainterInterfaceHelper::Unselect(*fPlane,"*");
187 AliMUONPainterInterfaceHelper::Unselect(*fViewPoint,"*");
188
189 fAttributes = att;
190
191 fCathode->SetState(!fAttributes.IsCathodeAndPlaneDisabled());
192 fPlane->SetState(!fAttributes.IsCathodeAndPlaneDisabled());
193
194 if ( fAttributes.IsCathodeDefined() )
195 {
196 AliMUONPainterInterfaceHelper::Select(*fCathode,fAttributes.CathodeName());
197 }
198
199 if ( fAttributes.IsPlaneDefined() )
200 {
201 AliMUONPainterInterfaceHelper::Select(*fPlane,fAttributes.PlaneName());
202 }
203
204 AliMUONPainterInterfaceHelper::Select(*fViewPoint,fAttributes.ViewPointName());
205
206}