1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONPainterColorSlider.h"
19 #include "AliMUONPainterHelper.h"
21 #include <TGNumberEntry.h>
25 ///\class AliMUONPainterColorSlider
27 /// A painter color palette
29 ///\author Laurent Aphecetche, Subatech
32 ClassImp(AliMUONPainterColorSlider)
35 //_____________________________________________________________________________
36 AliMUONPainterColorSlider::AliMUONPainterColorSlider(const TGWindow* p,
38 : TGCompositeFrame(p,w,h,kVerticalFrame),
43 fAutoButton(new TGTextButton(this,"Auto")),
44 fLockButton(new TGTextButton(this,"Lock"))
49 Int_t hsize = (h-100)/(ndivisions+2);
55 Double_t step = (max-min)/ndivisions;
57 for ( Int_t i = -1; i <= ndivisions+1; ++i )
59 Double_t value = max - (min + step*i);
61 Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,
63 Pixel_t pixel = gVirtualX->GetPixel(color);
64 TGVerticalFrame* frame = new TGVerticalFrame(this,w,hsize,kFixedSize,pixel);
66 AddFrame(frame,new TGLayoutHints(kLHintsExpandX,0,0,topBorder,0));
71 fEntryMax = new TGNumberEntry(this);
73 AddFrame(fEntryMax,new TGLayoutHints(kLHintsExpandX,0,0,topBorder,0));
75 fEntryMin = new TGNumberEntry(this);
77 AddFrame(fEntryMin,new TGLayoutHints(kLHintsExpandX,0,0,topBorder,0));
79 // fEntryMin->SetFormat(TGNumberFormat::kNESRealOne);
80 // fEntryMax->SetFormat(TGNumberFormat::kNESRealOne);
82 AddFrame(fAutoButton,new TGLayoutHints(kLHintsExpandX,0,0,topBorder,0));
84 fAutoButton->Connect("Clicked()","AliMUONPainterColorSlider",this,"DataRangeAutoRequested()");
86 AddFrame(fLockButton,new TGLayoutHints(kLHintsExpandX,0,0,topBorder,0));
88 fLockButton->Connect("Clicked()","AliMUONPainterColorSlider",this,"LockButtonWasClicked()");
90 fEntryMax->Connect("ValueSet(Long_t)","AliMUONPainterColorSlider",this,"DataRangeWasChanged(Double_t*)");
91 fEntryMin->Connect("ValueSet(Long_t)","AliMUONPainterColorSlider",this,"DataRangeWasChanged(Double_t*)");
94 //_____________________________________________________________________________
95 AliMUONPainterColorSlider::~AliMUONPainterColorSlider()
100 //_____________________________________________________________________________
102 AliMUONPainterColorSlider::DataRangeAutoRequested()
104 /// Signal that the "Auto" button was clicked
106 Emit("DataRangeAutoRequested()");
109 //_____________________________________________________________________________
111 AliMUONPainterColorSlider::DataRangeWasChanged(Double_t*)
113 /// Data range was changed
115 Double_t values[] = { fEntryMin->GetNumber(), fEntryMax->GetNumber() };
117 Long_t param[] = { (Long_t)values };
119 AliDebug(1,Form("double min %e max %e",values[0],values[1]));
121 Emit("DataRangeWasChanged(Double_t*)",param);
124 //_____________________________________________________________________________
126 AliMUONPainterColorSlider::IsLocked() const
128 /// Whether our range is locked or not
130 return (fLockButton->GetString() == "Unlock"); // if we can unlock it means we are locked...
133 //_____________________________________________________________________________
135 AliMUONPainterColorSlider::LockButtonWasClicked()
137 /// Lock (toggle button) was clicked
142 fLockButton->SetText("Lock");
143 fEntryMin->SetState(kTRUE);
144 fEntryMax->SetState(kTRUE);
145 fAutoButton->SetEnabled(kTRUE);
150 fLockButton->SetText("Unlock");
151 fEntryMin->SetState(kFALSE);
152 fEntryMax->SetState(kFALSE);
153 fAutoButton->SetEnabled(kFALSE);
157 //_____________________________________________________________________________
159 AliMUONPainterColorSlider::SetRange(Double_t min, Double_t max, Bool_t emit)
161 /// Set the data range
163 AliDebug(1,Form("min %e max %e emit %d",min,max,emit));
170 fEntryMin->SetNumber(fMin);
171 fEntryMax->SetNumber(fMax);
176 DataRangeWasChanged(0x0);