Logo ROOT  
Reference Guide
TAttFillEditor.cxx
Go to the documentation of this file.
1// @(#)root/ged:$Id$
2// Author: Ilka Antcheva 10/05/04
3
4/*************************************************************************
5 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12//////////////////////////////////////////////////////////////////////////
13// //
14// TAttFillEditor //
15// //
16// Implements GUI for editing fill attributes. // //
17// color and fill style //
18// //
19//////////////////////////////////////////////////////////////////////////
20//Begin_Html
21/*
22<img src="gif/TAttFillEditor.gif">
23*/
24//End_Html
25
26#include "TAttFillEditor.h"
27#include "TGedPatternSelect.h"
28#include "TGColorSelect.h"
29#include "TColor.h"
30#include "TGLabel.h"
31#include "TGNumberEntry.h"
32#include "TCanvas.h"
33#include "TROOT.h"
34
36
42};
43
44
45////////////////////////////////////////////////////////////////////////////////
46/// Constructor of fill attributes GUI.
47
49 Int_t height, UInt_t options, Pixel_t back)
50 : TGedFrame(p, width, height, options | kVerticalFrame, back)
51{
52 fPriority = 2;
53
54 fAttFill = 0;
55
56 MakeTitle("Fill");
57
58 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
59 fColorSelect = new TGColorSelect(f2, 0, kCOLOR);
60 f2->AddFrame(fColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
63 f2->AddFrame(fPatternSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
65 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
66
67 TGLabel *AlphaLabel = new TGLabel(this,"Opacity");
68 AddFrame(AlphaLabel,
70 TGHorizontalFrame *f2a = new TGHorizontalFrame(this);
72 fAlpha->SetRange(0,1000);
77 fAlphaField->Resize(40,20);
78 if (!TCanvas::SupportAlpha()) {
80 AlphaLabel->Disable(kTRUE);
82 }
85}
86
87////////////////////////////////////////////////////////////////////////////////
88/// Destructor of fill editor.
89
91{
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Connect signals to slots.
96
98{
99 fColorSelect->Connect("ColorSelected(Pixel_t)", "TAttFillEditor", this, "DoFillColor(Pixel_t)");
100 fColorSelect->Connect("AlphaColorSelected(ULong_t)", "TAttFillEditor", this, "DoFillAlphaColor(ULong_t)");
101 fPatternSelect->Connect("PatternSelected(Style_t)", "TAttFillEditor", this, "DoFillPattern(Style_t)");
102 fAlpha->Connect("Released()","TAttFillEditor", this, "DoAlpha()");
103 fAlpha->Connect("PositionChanged(Int_t)","TAttFillEditor", this, "DoLiveAlpha(Int_t)");
104 fAlphaField->Connect("ReturnPressed()","TAttFillEditor", this, "DoAlphaField()");
105 fAlpha->Connect("Pressed()","TAttFillEditor", this, "GetCurAlpha()");
106 fInit = kFALSE;
107}
108
109////////////////////////////////////////////////////////////////////////////////
110/// Pick up the used fill attributes.
111
113{
114 TAttFill *attfill = dynamic_cast<TAttFill *>(obj);
115 if (!attfill) return;
116
117 fAttFill = attfill;
119
123
126
129
130 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
131 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
132 fAlphaField->SetNumber(color->GetAlpha());
133 }
134}
135
136////////////////////////////////////////////////////////////////////////////////
137/// Slot connected to the fill area color with alpha.
138
140{
141 TColor *color = (TColor *)p;
142
143 if (fAvoidSignal) return;
145 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
146 fAlphaField->SetNumber(color->GetAlpha());
147
148 Update();
149}
150
151////////////////////////////////////////////////////////////////////////////////
152/// Slot connected to the fill area color.
153
155{
156 if (fAvoidSignal) return;
158
159 if (TColor *tcolor = gROOT->GetColor(TColor::GetColor(color))) {
160 fAlpha->SetPosition((Int_t)(tcolor->GetAlpha()*1000));
161 fAlphaField->SetNumber(tcolor->GetAlpha());
162 }
163
164 Update();
165}
166
167////////////////////////////////////////////////////////////////////////////////
168/// Slot connected to the fill area pattern.
169
171{
172 if (fAvoidSignal) return;
174 Update();
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// Slot to set the alpha value from the entry field.
179
181{
182 if (fAvoidSignal) return;
183
184 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
185 color->SetAlpha((Float_t)fAlphaField->GetNumber());
187 }
188 Update();
189}
190
191////////////////////////////////////////////////////////////////////////////////
192/// Slot to set the alpha value
193
195{
196 if (fAvoidSignal) return;
197
198 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
199 color->SetAlpha((Float_t)fAlpha->GetPosition()/1000);
201 }
202 Update();
203}
204
205////////////////////////////////////////////////////////////////////////////////
206/// Slot to set alpha value online.
207
209{
210 if (fAvoidSignal) return;
212
213 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
214 // In case the color is not transparent a new color is created.
215 if (color->GetAlpha() == 1.) {
216 fAttFill->SetFillColor(TColor::GetColorTransparent(color->GetNumber(),0.99));
217 } else {
218 color->SetAlpha((Float_t)a/1000);
219 }
220 }
221 Update();
222}
223
224////////////////////////////////////////////////////////////////////////////////
225/// Slot to update alpha value on click on Slider
226
228{
229 if (fAvoidSignal) return;
230
231 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
232 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
233 fAlphaField->SetNumber(color->GetAlpha());
234 }
235 Update();
236}
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kHorizontalFrame
Definition: GuiTypes.h:382
ULong_t Pixel_t
Definition: GuiTypes.h:39
#define c(i)
Definition: RSha256.hxx:101
const Bool_t kFALSE
Definition: RtypesCore.h:90
unsigned long ULong_t
Definition: RtypesCore.h:53
short Color_t
Definition: RtypesCore.h:81
short Style_t
Definition: RtypesCore.h:78
float Float_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
EFillWid
@ kALPHAFIELD
@ kPATTERN
@ kCOLOR
@ kALPHA
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsCenterY
Definition: TGLayout.h:35
@ kLHintsTop
Definition: TGLayout.h:34
@ kScaleNo
Definition: TGSlider.h:60
@ kSlider2
Definition: TGSlider.h:57
#define gROOT
Definition: TROOT.h:406
virtual void ConnectSignals2Slots()
Connect signals to slots.
virtual void GetCurAlpha()
Slot to update alpha value on click on Slider.
TGNumberEntryField * fAlphaField
virtual void DoFillColor(Pixel_t color)
Slot connected to the fill area color.
virtual void DoFillPattern(Style_t color)
Slot connected to the fill area pattern.
TAttFillEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of fill attributes GUI.
TGColorSelect * fColorSelect
virtual void DoFillAlphaColor(ULong_t p)
Slot connected to the fill area color with alpha.
virtual void DoLiveAlpha(Int_t a)
Slot to set alpha value online.
virtual void DoAlphaField()
Slot to set the alpha value from the entry field.
TAttFill * fAttFill
TGHSlider * fAlpha
virtual void DoAlpha()
Slot to set the alpha value.
virtual void SetModel(TObject *obj)
Pick up the used fill attributes.
TGedPatternSelect * fPatternSelect
virtual ~TAttFillEditor()
Destructor of fill editor.
Fill Area Attributes class.
Definition: TAttFill.h:19
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition: TAttFill.h:31
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
static Bool_t SupportAlpha()
Static function returning "true" if transparency is supported.
Definition: TCanvas.cxx:2420
The color creation and management class.
Definition: TColor.h:19
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition: TColor.cxx:2016
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition: TColor.cxx:1769
Float_t GetAlpha() const
Definition: TColor.h:63
Int_t GetNumber() const
Definition: TColor.h:55
static Int_t GetColorTransparent(Int_t color, Float_t a)
Static function: Returns the transparent color number corresponding to n.
Definition: TColor.cxx:1979
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1101
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:589
virtual void Disable(Bool_t on=kTRUE)
Definition: TGLabel.h:97
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
virtual void SetNumber(Double_t val)
Set the numeric value (floating point representation).
virtual Int_t GetPosition() const
Definition: TGSlider.h:109
virtual void SetPosition(Int_t pos)
Definition: TGSlider.h:105
virtual void SetRange(Int_t min, Int_t max)
Definition: TGSlider.h:101
virtual void SetEnabled(Bool_t flag=kTRUE)
Definition: TGSlider.h:98
void SetEnabled(Bool_t flag=kTRUE)
Definition: TGTextEntry.h:164
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
Int_t fPriority
Definition: TGedFrame.h:59
Bool_t fAvoidSignal
Definition: TGedFrame.h:56
void SetPattern(Style_t pattern, Bool_t emit=kTRUE)
Set pattern.
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:866
static const std::string pattern("pattern")
static constexpr double s
auto * a
Definition: textangle.C:12