Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
32
40
41////////////////////////////////////////////////////////////////////////////////
42/// Constructor of marker attributes GUI.
43
45 Int_t height,UInt_t options, Pixel_t back)
46 : TGedFrame(p, width, height, options | kVerticalFrame, back)
47{
48 fAttMarker = 0;
50
51 MakeTitle("Marker");
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));
57
59 f2->AddFrame(fMarkerType, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
61
62 fMarkerSize = new TGNumberEntry(f2, 0., 4, kMARKER_SIZE,
66 fMarkerSize->GetNumberEntry()->SetToolTipText("Set marker size");
67 f2->AddFrame(fMarkerSize, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
69 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
70
71 TGLabel *AlphaLabel = new TGLabel(this,"Opacity");
76 fAlpha->SetRange(0,1000);
81 fAlphaField->Resize(40,20);
82 if (!TCanvas::SupportAlpha()) {
84 AlphaLabel->Disable(kTRUE);
86 }
89}
90
91////////////////////////////////////////////////////////////////////////////////
92/// Destructor of marker editor.
93
97
98////////////////////////////////////////////////////////////////////////////////
99/// Connect signals to slots.
100
102{
103 fColorSelect->Connect("ColorSelected(Pixel_t)", "TAttMarkerEditor", this, "DoMarkerColor(Pixel_t)");
104 fColorSelect->Connect("AlphaColorSelected(ULong_t)", "TAttMarkerEditor", this, "DoMarkerAlphaColor(ULong_t)");
105 fMarkerType->Connect("MarkerSelected(Style_t)", "TAttMarkerEditor", this, "DoMarkerStyle(Style_t)");
106 fMarkerSize->Connect("ValueSet(Long_t)", "TAttMarkerEditor", this, "DoMarkerSize()");
107 (fMarkerSize->GetNumberEntry())->Connect("ReturnPressed()", "TAttMarkerEditor", this, "DoMarkerSize()");
108 fAlpha->Connect("Released()","TAttMarkerEditor", this, "DoAlpha()");
109 fAlpha->Connect("PositionChanged(Int_t)","TAttMarkerEditor", this, "DoLiveAlpha(Int_t)");
110 fAlphaField->Connect("ReturnPressed()","TAttMarkerEditor", this, "DoAlphaField()");
111 fAlpha->Connect("Pressed()","TAttMarkerEditor", this, "GetCurAlpha()");
112 fInit = kFALSE;
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// Pick up the values of used marker attributes.
117
119{
121
122 fAttMarker = dynamic_cast<TAttMarker *>(obj);
123 if (!fAttMarker) return;
124
125 TString str = GetDrawOption();
126 str.ToUpper();
127 if (obj->InheritsFrom("TH2") && str.Contains("TEXT")) {
129 } else {
131 }
133 if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
136 } else {
140 }
142
146
149
150 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
151 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
152 fAlphaField->SetNumber(color->GetAlpha());
153 }
154}
155
156
157////////////////////////////////////////////////////////////////////////////////
158/// Slot connected to the marker color.
159
161{
162 if (fAvoidSignal) return;
164
165 if (TColor *tcolor = gROOT->GetColor(TColor::GetColor(color))) {
166 fAlpha->SetPosition((Int_t)(tcolor->GetAlpha()*1000));
167 fAlphaField->SetNumber(tcolor->GetAlpha());
168 }
169
170 Update();
171}
172
173////////////////////////////////////////////////////////////////////////////////
174/// Slot connected to the color with alpha.
175
177{
178 TColor *color = (TColor *)p;
179
180 if (fAvoidSignal) return;
182 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
183 fAlphaField->SetNumber(color->GetAlpha());
184
185 Update();
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// Slot connected to the marker type.
190
192{
193 if (fAvoidSignal) return;
194 if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
197 } else
199
200 fAttMarker->SetMarkerStyle(marker);
201 Update();
202}
203
204////////////////////////////////////////////////////////////////////////////////
205/// Slot connected to the marker size.
206
208{
209 if (fAvoidSignal) return;
211 if ((marker==1 || marker==6 || marker==7) && !fSizeForText) {
214 } else
218 Update();
219}
220
221////////////////////////////////////////////////////////////////////////////////
222/// Slot to set the alpha value from the entry field.
223
225{
226 if (fAvoidSignal) return;
227
228 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
229 color->SetAlpha((Float_t)fAlphaField->GetNumber());
231 }
232 Update();
233}
234
235////////////////////////////////////////////////////////////////////////////////
236/// Slot to set the alpha value
237
239{
240 if (fAvoidSignal) return;
241
242 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
243 color->SetAlpha((Float_t)fAlpha->GetPosition()/1000);
245 }
246 Update();
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// Slot to set alpha value online.
251
253{
254 if (fAvoidSignal) return;
256
257 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
258 // In case the color is not transparent a new color is created.
259 if (color->GetAlpha() == 1.) {
260 fAttMarker->SetMarkerColor(TColor::GetColorTransparent(color->GetNumber(),0.99));
261 } else {
262 color->SetAlpha((Float_t)a/1000);
263 }
264 }
265 Update();
266}
267
268////////////////////////////////////////////////////////////////////////////////
269/// Slot to update alpha value on click on Slider
270
272{
273 if (fAvoidSignal) return;
274
275 if (TColor *color = gROOT->GetColor(fAttMarker->GetMarkerColor())) {
276 fAlpha->SetPosition((Int_t)(color->GetAlpha()*1000));
277 fAlphaField->SetNumber(color->GetAlpha());
278 }
279 Update();
280}
@ 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
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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
@ kCOLOR
@ kALPHA
@ kALPHAFIELD
@ kMARKER_SIZE
@ kMARKER
@ 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 DoAlpha()
Slot to set the alpha value.
virtual void GetCurAlpha()
Slot to update alpha value on click on Slider.
void SetModel(TObject *obj) override
Pick up the values of used marker attributes.
Bool_t fSizeForText
true if "text" draw option uses marker size
TAttMarker * fAttMarker
marker attribute object
virtual void ConnectSignals2Slots()
Connect signals to slots.
~TAttMarkerEditor() override
Destructor of marker editor.
virtual void DoLiveAlpha(Int_t a)
Slot to set alpha value online.
TAttMarkerEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of marker attributes GUI.
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 void DoMarkerAlphaColor(ULongptr_t p)
Slot connected to the color with alpha.
TGNumberEntry * fMarkerSize
marker size combo box
Marker Attributes class.
Definition TAttMarker.h:20
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition TAttMarker.h:33
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:39
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition TAttMarker.h:32
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:34
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition TAttMarker.h:41
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition TAttMarker.h:46
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).
TGNumberEntry is a number entry input widget with up/down buttons.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
void Associate(const TGWindow *w) override
Make w the window that will receive the generated messages.
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
@ kNEANonNegative
Non-negative number.
@ kNESRealOne
Fixed fraction real, one digit.
@ kNESReal
Real number.
@ kNELLimitMinMax
Both lower and upper limits.
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 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
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
Option_t * GetDrawOption() const override
Get draw options of the selected object.
Definition TGedFrame.cxx:79
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:41
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
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
Basic string class.
Definition TString.h:138