Logo ROOT   6.18/05
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//////////////////////////////////////////////////////////////////////////
13// //
14// TAttMarkerEditor //
15// //
16// Implements GUI for editing marker attributes. //
17// color, style and size //
18// //
19//////////////////////////////////////////////////////////////////////////
20//Begin_Html
21/*
22<img src="gif/TAttMarkerEditor.gif">
23*/
24//End_Html
25
26
27#include "TAttMarkerEditor.h"
28#include "TGedMarkerSelect.h"
29#include "TGColorSelect.h"
30#include "TGNumberEntry.h"
31#include "TColor.h"
32#include "TGLabel.h"
33#include "TGNumberEntry.h"
34#include "TPad.h"
35#include "TCanvas.h"
36#include "TROOT.h"
37
39
46};
47
48////////////////////////////////////////////////////////////////////////////////
49/// Constructor of marker attributes GUI.
50
52 Int_t height,UInt_t options, Pixel_t back)
53 : TGedFrame(p, width, height, options | kVerticalFrame, back)
54{
55 fAttMarker = 0;
57
58 MakeTitle("Marker");
59
60 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
61 fColorSelect = new TGColorSelect(f2, 0, kCOLOR);
62 f2->AddFrame(fColorSelect, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
64
66 f2->AddFrame(fMarkerType, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
68
69 fMarkerSize = new TGNumberEntry(f2, 0., 4, kMARKER_SIZE,
73 fMarkerSize->GetNumberEntry()->SetToolTipText("Set marker size");
74 f2->AddFrame(fMarkerSize, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
76 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
77
78 TGLabel *AlphaLabel = new TGLabel(this,"Opacity");
79 AddFrame(AlphaLabel,
81 TGHorizontalFrame *f2a = new TGHorizontalFrame(this);
83 fAlpha->SetRange(0,1000);
88 fAlphaField->Resize(40,20);
89 if (!TCanvas::SupportAlpha()) {
91 AlphaLabel->Disable(kTRUE);
93 }
96}
97
98////////////////////////////////////////////////////////////////////////////////
99/// Destructor of marker editor.
100
102{
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// Connect signals to slots.
107
109{
110 fColorSelect->Connect("ColorSelected(Pixel_t)", "TAttMarkerEditor", this, "DoMarkerColor(Pixel_t)");
111 fColorSelect->Connect("AlphaColorSelected(ULong_t)", "TAttMarkerEditor", this, "DoMarkerAlphaColor(ULong_t)");
112 fMarkerType->Connect("MarkerSelected(Style_t)", "TAttMarkerEditor", this, "DoMarkerStyle(Style_t)");
113 fMarkerSize->Connect("ValueSet(Long_t)", "TAttMarkerEditor", this, "DoMarkerSize()");
114 (fMarkerSize->GetNumberEntry())->Connect("ReturnPressed()", "TAttMarkerEditor", this, "DoMarkerSize()");
115 fAlpha->Connect("Released()","TAttMarkerEditor", this, "DoAlpha()");
116 fAlpha->Connect("PositionChanged(Int_t)","TAttMarkerEditor", this, "DoLiveAlpha(Int_t)");
117 fAlphaField->Connect("ReturnPressed()","TAttMarkerEditor", this, "DoAlphaField()");
118 fAlpha->Connect("Pressed()","TAttMarkerEditor", this, "GetCurAlpha()");
119 fInit = kFALSE;
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// Pick up the values of used marker attributes.
124
126{
128
129 fAttMarker = dynamic_cast<TAttMarker *>(obj);
130 if (!fAttMarker) return;
131
132 TString str = GetDrawOption();
133 str.ToUpper();
134 if (obj->InheritsFrom("TH2") && str.Contains("TEXT")) {
136 } else {
138 }
140 if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
143 } else {
147 }
149
153
156
157 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
158 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
159 fAlphaField->SetNumber(color->GetAlpha());
160 }
161}
162
163
164////////////////////////////////////////////////////////////////////////////////
165/// Slot connected to the marker color.
166
168{
169 if (fAvoidSignal) return;
171
172 if (TColor *tcolor = gROOT->GetColor(TColor::GetColor(color))) {
173 fAlpha->SetPosition((Int_t)(tcolor->GetAlpha()*1000));
174 fAlphaField->SetNumber(tcolor->GetAlpha());
175 }
176
177 Update();
178}
179
180////////////////////////////////////////////////////////////////////////////////
181/// Slot connected to the color with alpha.
182
184{
185 TColor *color = (TColor *)p;
186
187 if (fAvoidSignal) return;
189 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
190 fAlphaField->SetNumber(color->GetAlpha());
191
192 Update();
193}
194
195////////////////////////////////////////////////////////////////////////////////
196/// Slot connected to the marker type.
197
199{
200 if (fAvoidSignal) return;
201 if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
204 } else
206
207 fAttMarker->SetMarkerStyle(marker);
208 Update();
209}
210
211////////////////////////////////////////////////////////////////////////////////
212/// Slot connected to the marker size.
213
215{
216 if (fAvoidSignal) return;
218 if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
221 } else
223 Float_t size = fMarkerSize->GetNumber();
225 Update();
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Slot to set the alpha value from the entry field.
230
232{
233 if (fAvoidSignal) return;
234
235 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
236 color->SetAlpha((Float_t)fAlphaField->GetNumber());
238 }
239 Update();
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Slot to set the alpha value
244
246{
247 if (fAvoidSignal) return;
248
249 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
250 color->SetAlpha((Float_t)fAlpha->GetPosition()/1000);
252 }
253 Update();
254}
255
256////////////////////////////////////////////////////////////////////////////////
257/// Slot to set alpha value online.
258
260{
261 if (fAvoidSignal) return;
263
264 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
265 // In case the color is not transparent a new color is created.
266 if (color->GetAlpha() == 1.) {
267 fAttMarker->SetMarkerColor(TColor::GetColorTransparent(color->GetNumber(),0.99));
268 } else {
269 color->SetAlpha((Float_t)a/1000);
270 }
271 }
272 Update();
273}
274
275////////////////////////////////////////////////////////////////////////////////
276/// Slot to update alpha value on click on Slider
277
279{
280 if (fAvoidSignal) return;
281
282 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
283 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
284 fAlphaField->SetNumber(color->GetAlpha());
285 }
286 Update();
287}
ULong_t Pixel_t
Definition: GuiTypes.h:39
#define c(i)
Definition: RSha256.hxx:101
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
unsigned long ULong_t
Definition: RtypesCore.h:51
short Color_t
Definition: RtypesCore.h:79
short Style_t
Definition: RtypesCore.h:76
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
EMarkerWid
@ kALPHAFIELD
@ kCOLOR
@ kALPHA
@ kMARKER_SIZE
@ kMARKER
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kVerticalFrame
Definition: TGFrame.h:59
@ kHorizontalFrame
Definition: TGFrame.h:60
@ 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:414
virtual void DoAlpha()
Slot to set the alpha value.
virtual void GetCurAlpha()
Slot to update alpha value on click on Slider.
virtual void SetModel(TObject *obj)
Pick up the values of used marker attributes.
TAttMarker * fAttMarker
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
virtual void DoMarkerSize()
Slot connected to the marker size.
TGHSlider * fAlpha
virtual void DoMarkerColor(Pixel_t color)
Slot connected to the marker color.
TGColorSelect * fColorSelect
virtual void DoAlphaField()
Slot to set the alpha value from the entry field.
virtual ~TAttMarkerEditor()
Destructor of marker editor.
virtual void DoMarkerAlphaColor(ULong_t p)
Slot connected to the color with alpha.
TGNumberEntry * fMarkerSize
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:2273
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:2003
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:1764
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:1966
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:1099
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
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 void SetNumber(Double_t val)
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 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 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:84
virtual Option_t * GetDrawOption() const
Get draw options of the selected object.
Definition: TGedFrame.cxx:81
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
Bool_t fAvoidSignal
Definition: TGedFrame.h:56
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:443
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:867
Basic string class.
Definition: TString.h:131
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1138
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
static constexpr double s
auto * a
Definition: textangle.C:12