Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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/** \class TAttFillEditor
14 \ingroup ged
15
16Implements GUI for editing fill attributes.
17 color and fill style
18
19*/
20
21#include "TAttFillEditor.h"
22#include "TGedPatternSelect.h"
23#include "TGColorSelect.h"
24#include "TColor.h"
25#include "TGLabel.h"
26#include "TGSlider.h"
27#include "TGNumberEntry.h"
28#include "TCanvas.h"
29#include "TROOT.h"
30
32
38};
39
40
41////////////////////////////////////////////////////////////////////////////////
42/// Constructor of fill attributes GUI.
43
45 Int_t height, UInt_t options, Pixel_t back)
46 : TGedFrame(p, width, height, options | kVerticalFrame, back)
47{
48 fPriority = 2;
49
50 fAttFill = 0;
51
52 MakeTitle("Fill");
53
54 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
55 fColorSelect = new TGColorSelect(f2, 0, kCOLOR);
56 f2->AddFrame(fColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
59 f2->AddFrame(fPatternSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
61 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
62
63 TGLabel *AlphaLabel = new TGLabel(this,"Opacity");
64 AddFrame(AlphaLabel,
66 TGHorizontalFrame *f2a = new TGHorizontalFrame(this);
68 fAlpha->SetRange(0,1000);
73 fAlphaField->Resize(40,20);
74 if (!TCanvas::SupportAlpha()) {
76 AlphaLabel->Disable(kTRUE);
78 }
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Destructor of fill editor.
85
87{
88}
89
90////////////////////////////////////////////////////////////////////////////////
91/// Connect signals to slots.
92
94{
95 fColorSelect->Connect("ColorSelected(Pixel_t)", "TAttFillEditor", this, "DoFillColor(Pixel_t)");
96 fColorSelect->Connect("AlphaColorSelected(ULong_t)", "TAttFillEditor", this, "DoFillAlphaColor(ULong_t)");
97 fPatternSelect->Connect("PatternSelected(Style_t)", "TAttFillEditor", this, "DoFillPattern(Style_t)");
98 fAlpha->Connect("Released()","TAttFillEditor", this, "DoAlpha()");
99 fAlpha->Connect("PositionChanged(Int_t)","TAttFillEditor", this, "DoLiveAlpha(Int_t)");
100 fAlphaField->Connect("ReturnPressed()","TAttFillEditor", this, "DoAlphaField()");
101 fAlpha->Connect("Pressed()","TAttFillEditor", this, "GetCurAlpha()");
102 fInit = kFALSE;
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// Pick up the used fill attributes.
107
109{
110 TAttFill *attfill = dynamic_cast<TAttFill *>(obj);
111 if (!attfill) return;
112
113 fAttFill = attfill;
115
119
122
125
126 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
127 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
128 fAlphaField->SetNumber(color->GetAlpha());
129 }
130}
131
132////////////////////////////////////////////////////////////////////////////////
133/// Slot connected to the fill area color with alpha.
134
136{
137 TColor *color = (TColor *)p;
138
139 if (fAvoidSignal) return;
141 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
142 fAlphaField->SetNumber(color->GetAlpha());
143
144 Update();
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Slot connected to the fill area color.
149
151{
152 if (fAvoidSignal) return;
154
155 if (TColor *tcolor = gROOT->GetColor(TColor::GetColor(color))) {
156 fAlpha->SetPosition((Int_t)(tcolor->GetAlpha()*1000));
157 fAlphaField->SetNumber(tcolor->GetAlpha());
158 }
159
160 Update();
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Slot connected to the fill area pattern.
165
167{
168 if (fAvoidSignal) return;
169 fAttFill->SetFillStyle(pattern);
170 Update();
171}
172
173////////////////////////////////////////////////////////////////////////////////
174/// Slot to set the alpha value from the entry field.
175
177{
178 if (fAvoidSignal) return;
179
180 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
181 color->SetAlpha((Float_t)fAlphaField->GetNumber());
183 }
184 Update();
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Slot to set the alpha value
189
191{
192 if (fAvoidSignal) return;
193
194 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
195 color->SetAlpha((Float_t)fAlpha->GetPosition()/1000);
197 }
198 Update();
199}
200
201////////////////////////////////////////////////////////////////////////////////
202/// Slot to set alpha value online.
203
205{
206 if (fAvoidSignal) return;
208
209 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
210 // In case the color is not transparent a new color is created.
211 if (color->GetAlpha() == 1.) {
212 fAttFill->SetFillColor(TColor::GetColorTransparent(color->GetNumber(),0.99));
213 } else {
214 color->SetAlpha((Float_t)a/1000);
215 }
216 }
217 Update();
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Slot to update alpha value on click on Slider
222
224{
225 if (fAvoidSignal) return;
226
227 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
228 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
229 fAlphaField->SetNumber(color->GetAlpha());
230 }
231 Update();
232}
@ kVerticalFrame
Definition GuiTypes.h:381
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
short Style_t
Definition RtypesCore.h:89
short Color_t
Definition RtypesCore.h:92
unsigned long ULongptr_t
Definition RtypesCore.h:83
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
@ kALPHAFIELD
@ kPATTERN
@ kCOLOR
@ kALPHA
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsTop
Definition TGLayout.h:27
@ kScaleNo
Definition TGSlider.h:34
@ kSlider2
Definition TGSlider.h:31
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
#define gROOT
Definition TROOT.h:406
Implements GUI for editing fill attributes.
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.
TAttFillEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of fill attributes GUI.
void SetModel(TObject *obj) override
Pick up the used fill attributes.
virtual void DoFillPattern(Style_t color)
Slot connected to the fill area pattern.
TGColorSelect * fColorSelect
fill color widget
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.
~TAttFillEditor() override
Destructor of fill editor.
TAttFill * fAttFill
fill attribute object
TGHSlider * fAlpha
fill opacity
virtual void DoAlpha()
Slot to set the alpha value.
TGedPatternSelect * fPatternSelect
fill pattern widget
virtual void DoFillAlphaColor(ULongptr_t p)
Slot connected to the fill area color with alpha.
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:2470
The color creation and management class.
Definition TColor.h:21
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition TColor.cxx:2256
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:1839
Float_t GetAlpha() const
Definition TColor.h:66
Int_t GetNumber() const
Definition TColor.h:58
static Int_t GetColorTransparent(Int_t color, Float_t a)
Static function: Returns the transparent color number corresponding to n.
Definition TColor.cxx:2056
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
Concrete class for horizontal slider.
Definition TGSlider.h:119
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
This class handles GUI labels.
Definition TGLabel.h:24
virtual void Disable(Bool_t on=kTRUE)
Definition TGLabel.h:89
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
Set the numeric value (floating point representation).
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
@ kNEANonNegative
Non-negative number.
@ kNESReal
Real number.
virtual Int_t GetPosition() const
Definition TGSlider.h:77
virtual void SetPosition(Int_t pos)
Set slider position.
Definition TGSlider.cxx:110
virtual void SetRange(Int_t min, Int_t max)
Set slider range.
Definition TGSlider.cxx:99
virtual void SetEnabled(Bool_t flag=kTRUE)
Definition TGSlider.h:72
void SetEnabled(Bool_t flag=kTRUE)
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
ROOT GUI Window base class.
Definition TGWindow.h:23
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:95
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:72
Int_t fPriority
location in GedEditor
Definition TGedFrame.h:53
Bool_t fAvoidSignal
flag for executing slots
Definition TGedFrame.h:50
is a button with pattern area with a little down arrow.
void SetPattern(Style_t pattern, Bool_t emit=kTRUE)
Set pattern.
Mother of all ROOT objects.
Definition TObject.h:41
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:869