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
31
38
39
40////////////////////////////////////////////////////////////////////////////////
41/// Constructor of fill attributes GUI.
42
44 Int_t height, UInt_t options, Pixel_t back)
45 : TGedFrame(p, width, height, options | kVerticalFrame, back)
46{
47 fPriority = 2;
48
49 fAttFill = 0;
50
51 MakeTitle("Fill");
52
53 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
54 fColorSelect = new TGColorSelect(f2, 0, kCOLOR);
55 f2->AddFrame(fColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
58 f2->AddFrame(fPatternSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
60 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
61
62 TGLabel *AlphaLabel = new TGLabel(this,"Opacity");
67 fAlpha->SetRange(0,1000);
72 fAlphaField->Resize(40,20);
73 if (!TCanvas::SupportAlpha()) {
75 AlphaLabel->Disable(kTRUE);
77 }
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Destructor of fill editor.
84
88
89////////////////////////////////////////////////////////////////////////////////
90/// Connect signals to slots.
91
93{
94 fColorSelect->Connect("ColorSelected(Pixel_t)", "TAttFillEditor", this, "DoFillColor(Pixel_t)");
95 fColorSelect->Connect("AlphaColorSelected(ULong_t)", "TAttFillEditor", this, "DoFillAlphaColor(ULong_t)");
96 fPatternSelect->Connect("PatternSelected(Style_t)", "TAttFillEditor", this, "DoFillPattern(Style_t)");
97 fAlpha->Connect("Released()","TAttFillEditor", this, "DoAlpha()");
98 fAlpha->Connect("PositionChanged(Int_t)","TAttFillEditor", this, "DoLiveAlpha(Int_t)");
99 fAlphaField->Connect("ReturnPressed()","TAttFillEditor", this, "DoAlphaField()");
100 fAlpha->Connect("Pressed()","TAttFillEditor", this, "GetCurAlpha()");
101 fInit = kFALSE;
102}
103
104////////////////////////////////////////////////////////////////////////////////
105/// Pick up the used fill attributes.
106
108{
109 TAttFill *attfill = dynamic_cast<TAttFill *>(obj);
110 if (!attfill) return;
111
114
118
121
124
125 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
126 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
127 fAlphaField->SetNumber(color->GetAlpha());
128 }
129}
130
131////////////////////////////////////////////////////////////////////////////////
132/// Slot connected to the fill area color with alpha.
133
135{
136 TColor *color = (TColor *)p;
137
138 if (fAvoidSignal) return;
140 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
141 fAlphaField->SetNumber(color->GetAlpha());
142
143 Update();
144}
145
146////////////////////////////////////////////////////////////////////////////////
147/// Slot connected to the fill area color.
148
150{
151 if (fAvoidSignal) return;
153
154 if (TColor *tcolor = gROOT->GetColor(TColor::GetColor(color))) {
155 fAlpha->SetPosition((Int_t)(tcolor->GetAlpha()*1000));
156 fAlphaField->SetNumber(tcolor->GetAlpha());
157 }
158
159 Update();
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// Slot connected to the fill area pattern.
164
166{
167 if (fAvoidSignal) return;
168 fAttFill->SetFillStyle(pattern);
169 Update();
170}
171
172////////////////////////////////////////////////////////////////////////////////
173/// Slot to set the alpha value from the entry field.
174
176{
177 if (fAvoidSignal) return;
178
179 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
180 color->SetAlpha((Float_t)fAlphaField->GetNumber());
182 }
183 Update();
184}
185
186////////////////////////////////////////////////////////////////////////////////
187/// Slot to set the alpha value
188
190{
191 if (fAvoidSignal) return;
192
193 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
194 color->SetAlpha((Float_t)fAlpha->GetPosition()/1000);
196 }
197 Update();
198}
199
200////////////////////////////////////////////////////////////////////////////////
201/// Slot to set alpha value online.
202
204{
205 if (fAvoidSignal) return;
207
208 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
209 // In case the color is not transparent a new color is created.
210 if (color->GetAlpha() == 1.) {
211 fAttFill->SetFillColor(TColor::GetColorTransparent(color->GetNumber(),0.99));
212 } else {
213 color->SetAlpha((Float_t)a/1000);
214 }
215 }
216 Update();
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Slot to update alpha value on click on Slider
221
223{
224 if (fAvoidSignal) return;
225
226 if (TColor *color = gROOT->GetColor(fAttFill->GetFillColor())) {
227 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
228 fAlphaField->SetNumber(color->GetAlpha());
229 }
230 Update();
231}
@ 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
Style number (short)
Definition RtypesCore.h:96
short Color_t
Color number (short)
Definition RtypesCore.h:99
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kALPHAFIELD
@ kPATTERN
@ kCOLOR
@ kALPHA
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ 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:411
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:20
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:31
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:32
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:38
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:40
static Bool_t SupportAlpha()
Static function returning "true" if transparency is supported.
Definition TCanvas.cxx:2473
The color creation and management class.
Definition TColor.h:22
static ULong_t Number2Pixel(Int_t ci)
Static method that given a color index number, returns the corresponding pixel value.
Definition TColor.cxx:2445
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:1926
Float_t GetAlpha() const
Definition TColor.h:67
Int_t GetNumber() const
Definition TColor.h:59
static Int_t GetColorTransparent(Int_t color, Float_t a)
Static function: Returns the transparent color number corresponding to n.
Definition TColor.cxx:2182
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:289
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
TGCompositeFrame(const TGCompositeFrame &)=delete
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
Concrete class for horizontal slider.
Definition TGSlider.h:119
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
This class handles GUI labels.
Definition TGLabel.h:24
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:107
virtual void SetRange(Int_t min, Int_t max)
Set slider range.
Definition TGSlider.cxx:96
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:94
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:71
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:865