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 AddFrame(fAutoButton,new TGLayoutHints(kLHintsExpandX,0,0,topBorder,0));
81 fAutoButton->Connect("Clicked()","AliMUONPainterColorSlider",this,"DataRangeAutoRequested()");
83 AddFrame(fLockButton,new TGLayoutHints(kLHintsExpandX,0,0,topBorder,0));
85 fLockButton->Connect("Clicked()","AliMUONPainterColorSlider",this,"LockButtonWasClicked()");
87 fEntryMax->Connect("ValueSet(Long_t)","AliMUONPainterColorSlider",this,"DataRangeWasChanged(Double_t*)");
88 fEntryMin->Connect("ValueSet(Long_t)","AliMUONPainterColorSlider",this,"DataRangeWasChanged(Double_t*)");
91 //_____________________________________________________________________________
92 AliMUONPainterColorSlider::~AliMUONPainterColorSlider()
97 //_____________________________________________________________________________
99 AliMUONPainterColorSlider::DataRangeAutoRequested()
101 /// Signal that the "Auto" button was clicked
103 Emit("DataRangeAutoRequested()");
106 //_____________________________________________________________________________
108 AliMUONPainterColorSlider::DataRangeWasChanged(Double_t*)
110 /// Data range was changed
112 Double_t values[] = { fEntryMin->GetNumber(), fEntryMax->GetNumber() };
114 Long_t param[] = { (Long_t)values };
116 AliDebug(1,Form("double min %e max %e",values[0],values[1]));
118 Emit("DataRangeWasChanged(Double_t*)",param);
121 //_____________________________________________________________________________
123 AliMUONPainterColorSlider::IsLocked() const
125 /// Whether our range is locked or not
127 return (fLockButton->GetString() == "Unlock"); // if we can unlock it means we are locked...
130 //_____________________________________________________________________________
132 AliMUONPainterColorSlider::LockButtonWasClicked()
134 /// Lock (toggle button) was clicked
139 fLockButton->SetText("Lock");
140 fEntryMin->SetState(kTRUE);
141 fEntryMax->SetState(kTRUE);
142 fAutoButton->SetEnabled(kTRUE);
147 fLockButton->SetText("Unlock");
148 fEntryMin->SetState(kFALSE);
149 fEntryMax->SetState(kFALSE);
150 fAutoButton->SetEnabled(kFALSE);
154 //_____________________________________________________________________________
156 AliMUONPainterColorSlider::SetRange(Double_t min, Double_t max, Bool_t emit)
158 /// Set the data range
160 AliDebug(1,Form("min %e max %e emit %d",min,max,emit));
167 fEntryMin->SetNumber(fMin);
168 fEntryMax->SetNumber(fMax);
173 DataRangeWasChanged(0x0);