Logo ROOT  
Reference Guide
TAttMarkerEditor.cxx
Go to the documentation of this file.
1// @(#)root/ged:$Id$
2// Author: Ilka Antcheva 11/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/** \class TAttMarkerEditor
13 \ingroup ged
14
15Implements GUI for editing marker attributes.
16 color, style and size
17
18*/
19
20
21#include "TAttMarkerEditor.h"
22#include "TAttMarker.h"
23#include "TGedMarkerSelect.h"
24#include "TGColorSelect.h"
25#include "TGNumberEntry.h"
26#include "TColor.h"
27#include "TGLabel.h"
28#include "TGSlider.h"
29#include "TCanvas.h"
30#include "TROOT.h"
31
33
40};
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor of marker attributes GUI.
44
46 Int_t height,UInt_t options, Pixel_t back)
47 : TGedFrame(p, width, height, options | kVerticalFrame, back)
48{
49 fAttMarker = 0;
51
52 MakeTitle("Marker");
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));
58
60 f2->AddFrame(fMarkerType, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
62
63 fMarkerSize = new TGNumberEntry(f2, 0., 4, kMARKER_SIZE,
67 fMarkerSize->GetNumberEntry()->SetToolTipText("Set marker size");
68 f2->AddFrame(fMarkerSize, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
70 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
71
72 TGLabel *AlphaLabel = new TGLabel(this,"Opacity");
73 AddFrame(AlphaLabel,
75 TGHorizontalFrame *f2a = new TGHorizontalFrame(this);
77 fAlpha->SetRange(0,1000);
82 fAlphaField->Resize(40,20);
83 if (!TCanvas::SupportAlpha()) {
85 AlphaLabel->Disable(kTRUE);
87 }
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Destructor of marker editor.
94
96{
97}
98
99////////////////////////////////////////////////////////////////////////////////
100/// Connect signals to slots.
101
103{
104 fColorSelect->Connect("ColorSelected(Pixel_t)", "TAttMarkerEditor", this, "DoMarkerColor(Pixel_t)");
105 fColorSelect->Connect("AlphaColorSelected(ULong_t)", "TAttMarkerEditor", this, "DoMarkerAlphaColor(ULong_t)");
106 fMarkerType->Connect("MarkerSelected(Style_t)", "TAttMarkerEditor", this, "DoMarkerStyle(Style_t)");
107 fMarkerSize->Connect("ValueSet(Long_t)", "TAttMarkerEditor", this, "DoMarkerSize()");
108 (fMarkerSize->GetNumberEntry())->Connect("ReturnPressed()", "TAttMarkerEditor", this, "DoMarkerSize()");
109 fAlpha->Connect("Released()","TAttMarkerEditor", this, "DoAlpha()");
110 fAlpha->Connect("PositionChanged(Int_t)","TAttMarkerEditor", this, "DoLiveAlpha(Int_t)");
111 fAlphaField->Connect("ReturnPressed()","TAttMarkerEditor", this, "DoAlphaField()");
112 fAlpha->Connect("Pressed()","TAttMarkerEditor", this, "GetCurAlpha()");
113 fInit = kFALSE;
114}
115
116////////////////////////////////////////////////////////////////////////////////
117/// Pick up the values of used marker attributes.
118
120{
122
123 fAttMarker = dynamic_cast<TAttMarker *>(obj);
124 if (!fAttMarker) return;
125
126 TString str = GetDrawOption();
127 str.ToUpper();
128 if (obj->InheritsFrom("TH2") && str.Contains("TEXT")) {
130 } else {
132 }
134 if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
137 } else {
141 }
143
147
150
151 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
152 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
153 fAlphaField->SetNumber(color->GetAlpha());
154 }
155}
156
157
158////////////////////////////////////////////////////////////////////////////////
159/// Slot connected to the marker color.
160
162{
163 if (fAvoidSignal) return;
165
166 if (TColor *tcolor = gROOT->GetColor(TColor::GetColor(color))) {
167 fAlpha->SetPosition((Int_t)(tcolor->GetAlpha()*1000));
168 fAlphaField->SetNumber(tcolor->GetAlpha());
169 }
170
171 Update();
172}
173
174////////////////////////////////////////////////////////////////////////////////
175/// Slot connected to the color with alpha.
176
178{
179 TColor *color = (TColor *)p;
180
181 if (fAvoidSignal) return;
183 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
184 fAlphaField->SetNumber(color->GetAlpha());
185
186 Update();
187}
188
189////////////////////////////////////////////////////////////////////////////////
190/// Slot connected to the marker type.
191
193{
194 if (fAvoidSignal) return;
195 if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
198 } else
200
201 fAttMarker->SetMarkerStyle(marker);
202 Update();
203}
204
205////////////////////////////////////////////////////////////////////////////////
206/// Slot connected to the marker size.
207
209{
210 if (fAvoidSignal) return;
212 if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
215 } else
219 Update();
220}
221
222////////////////////////////////////////////////////////////////////////////////
223/// Slot to set the alpha value from the entry field.
224
226{
227 if (fAvoidSignal) return;
228
229 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
230 color->SetAlpha((Float_t)fAlphaField->GetNumber());
232 }
233 Update();
234}
235
236////////////////////////////////////////////////////////////////////////////////
237/// Slot to set the alpha value
238
240{
241 if (fAvoidSignal) return;
242
243 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
244 color->SetAlpha((Float_t)fAlpha->GetPosition()/1000);
246 }
247 Update();
248}
249
250////////////////////////////////////////////////////////////////////////////////
251/// Slot to set alpha value online.
252
254{
255 if (fAvoidSignal) return;
257
258 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
259 // In case the color is not transparent a new color is created.
260 if (color->GetAlpha() == 1.) {
261 fAttMarker->SetMarkerColor(TColor::GetColorTransparent(color->GetNumber(),0.99));
262 } else {
263 color->SetAlpha((Float_t)a/1000);
264 }
265 }
266 Update();
267}
268
269////////////////////////////////////////////////////////////////////////////////
270/// Slot to update alpha value on click on Slider
271
273{
274 if (fAvoidSignal) return;
275
276 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
277 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
278 fAlphaField->SetNumber(color->GetAlpha());
279 }
280 Update();
281}
@ 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
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition: RtypesCore.h:45
unsigned long ULongptr_t
Definition: RtypesCore.h:83
unsigned int UInt_t
Definition: RtypesCore.h:46
const Bool_t kFALSE
Definition: RtypesCore.h:101
short Color_t
Definition: RtypesCore.h:92
short Style_t
Definition: RtypesCore.h:89
float Float_t
Definition: RtypesCore.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassImp(name)
Definition: Rtypes.h:364
EMarkerWid
@ kALPHAFIELD
@ kCOLOR
@ kALPHA
@ kMARKER_SIZE
@ kMARKER
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ 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
#define gROOT
Definition: TROOT.h:404
Implements GUI for editing marker attributes.
virtual void DoAlpha()
Slot to set the alpha value.
virtual void GetCurAlpha()
Slot to update alpha value on click on Slider.
Bool_t fSizeForText
true if "text" draw option uses marker size
virtual void SetModel(TObject *obj)
Pick up the values of used marker attributes.
TAttMarker * fAttMarker
marker attribute object
virtual void ConnectSignals2Slots()
Connect signals to slots.
virtual void DoLiveAlpha(Int_t a)
Slot to set alpha value online.
TGNumberEntryField * fAlphaField
virtual void DoMarkerStyle(Style_t style)
Slot connected to the marker type.
TGedMarkerSelect * fMarkerType
marker type
virtual void DoMarkerSize()
Slot connected to the marker size.
TGHSlider * fAlpha
fill opacity
virtual void DoMarkerColor(Pixel_t color)
Slot connected to the marker color.
TGColorSelect * fColorSelect
marker color
virtual void DoAlphaField()
Slot to set the alpha value from the entry field.
virtual ~TAttMarkerEditor()
Destructor of marker editor.
virtual void DoMarkerAlphaColor(ULongptr_t p)
Slot connected to the color with alpha.
TGNumberEntry * fMarkerSize
marker size combo box
TAttMarkerEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of marker attributes GUI.
Marker Attributes class.
Definition: TAttMarker.h:19
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition: TAttMarker.h:32
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition: TAttMarker.h:31
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition: TAttMarker.h:33
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:40
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:41
static Bool_t SupportAlpha()
Static function returning "true" if transparency is supported.
Definition: TCanvas.cxx:2489
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:2069
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:1822
Float_t GetAlpha() const
Definition: TColor.h:64
Int_t GetNumber() const
Definition: TColor.h:56
static Int_t GetColorTransparent(Int_t color, Float_t a)
Static function: Returns the transparent color number corresponding to n.
Definition: TColor.cxx:2032
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=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1117
TGCompositeFrame(const TGCompositeFrame &)=delete
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:605
Concrete class for horizontal slider.
Definition: TGSlider.h:128
A composite frame that layout their children in horizontal way.
Definition: TGFrame.h:386
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).
TGNumberEntry is a number entry input widget with up/down buttons.
TGNumberEntryField * GetNumberEntry() const
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
@ kNEANonNegative
Non-negative number.
Definition: TGNumberEntry.h:42
@ kNESRealOne
Fixed fraction real, one digit.
Definition: TGNumberEntry.h:26
@ kNESReal
Real number.
Definition: TGNumberEntry.h:30
@ kNELLimitMinMax
Both lower and upper limits.
Definition: TGNumberEntry.h:50
virtual Int_t GetPosition() const
Definition: TGSlider.h:83
virtual void SetPosition(Int_t pos)
Definition: TGSlider.h:79
virtual void SetRange(Int_t min, Int_t max)
Definition: TGSlider.h:75
virtual void SetEnabled(Bool_t flag=kTRUE)
Definition: TGSlider.h:72
void SetEnabled(Bool_t flag=kTRUE)
Definition: TGTextEntry.h:149
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
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
virtual Option_t * GetDrawOption() const
Get draw options of the selected object.
Definition: TGedFrame.cxx:80
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
Bool_t fAvoidSignal
flag for executing slots
Definition: TGedFrame.h:50
The TGedMarkerSelect widget is a button showing selected marker and a little down arrow.
void SetMarkerStyle(Style_t pattern)
Set marker.
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
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
Basic string class.
Definition: TString.h:136
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1163
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:624
static constexpr double s
auto * a
Definition: textangle.C:12