Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPadEditor.cxx
Go to the documentation of this file.
1// @(#)root/ged:$Id$
2// Author: Ilka Antcheva 24/06/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 TPadEditor
14 \ingroup ged
15
16Editor of pad/canvas objects.
17 color and fill style,
18 'Edit' check box sets pad/canvad editable,
19 'Crosshair' sets a cross hair on the pad,
20 'Fixed aspect ratio' can be set when resizing the pad
21 'TickX' and 'TickY' set ticks along the X and Y axis
22 'GridX' and 'GridY' set a grid along the X and Y axis
23 pad/canvas border size can be set if a sinken or a raised
24 border mode is selected; no border mode can be set to
25
26*/
27
28
29#include "TPadEditor.h"
30#include "TGedEditor.h"
31#include "TGComboBox.h"
32#include "TGButtonGroup.h"
33#include "TGLabel.h"
34#include "TCanvas.h"
35
37
38enum EPadWid {
52};
53
54
55////////////////////////////////////////////////////////////////////////////////
56/// Constructor of TPad editor GUI.
57
59 Int_t height, UInt_t options, Pixel_t back)
60 : TGedFrame(p, width, height, options | kVerticalFrame, back)
61{
62 fPadPointer = 0;
63
64 MakeTitle("Pad/Canvas");
65
66 fFixedAR = new TGCheckButton(this, "Fixed aspect ratio", kPAD_FAR);
67 fFixedAR->SetToolTipText("Set fixed aspect ratio");
68 AddFrame(fFixedAR, new TGLayoutHints(kLHintsTop, 4, 1, 2, 1));
69
70 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
72 fCrosshair = new TGCheckButton(f3, "Crosshair", kPAD_CROSS);
73 fCrosshair->SetToolTipText("Set crosshair");
74 f3->AddFrame(fCrosshair, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
75 fGridX = new TGCheckButton(f3, "GridX", kPAD_GRIDX);
76 fGridX->SetToolTipText("Set grid along X");
77 f3->AddFrame(fGridX, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
78 fTickX = new TGCheckButton(f3, "TickX", kPAD_TICKX);
79 fTickX->SetToolTipText("Set tick marks along X");
80 f3->AddFrame(fTickX, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
81 f2->AddFrame(f3, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
82
84 fEditable = new TGCheckButton(f4, "Edit", kPAD_EDIT);
85 fEditable->SetToolTipText("Set editable mode");
86 f4->AddFrame(fEditable, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
87 fGridY = new TGCheckButton(f4, "GridY", kPAD_GRIDY);
88 fGridY->SetToolTipText("Set grid along Y");
89 f4->AddFrame(fGridY, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
90 fTickY = new TGCheckButton(f4, "TickY", kPAD_TICKY);
91 fTickY->SetToolTipText("Set tick marks along Y");
92 f4->AddFrame(fTickY, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
93 f2->AddFrame(f4, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
94
95 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
96
97 MakeTitle("Log Scale");
98
99 TGCompositeFrame *f5 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
100 fLogX = new TGCheckButton(f5, ":X", kPAD_LOGX);
101 fLogX->SetToolTipText("Set logarithmic scale along X");
102 f5->AddFrame(fLogX, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
103 fLogY = new TGCheckButton(f5, ":Y", kPAD_LOGY);
104 fLogY->SetToolTipText("Set logarithmic scale along Y");
105 f5->AddFrame(fLogY, new TGLayoutHints(kLHintsTop, 15, 1, 1, 1));
106 fLogZ = new TGCheckButton(f5, ":Z", kPAD_LOGZ);
107 fLogZ->SetToolTipText("Set logarithmic scale along Z");
108 f5->AddFrame(fLogZ, new TGLayoutHints(kLHintsTop, 15, 1, 1, 1));
109 AddFrame(f5, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
110
111 TGCompositeFrame *f6 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
112 fBgroup = new TGButtonGroup(f6,3,1,3,0, "Border Mode");
114 fBmode = new TGRadioButton(fBgroup, " Sunken border", 77);
115 fBmode->SetToolTipText("Set a sinken border of the pad/canvas");
116 fBmode0 = new TGRadioButton(fBgroup, " No border", 78);
117 fBmode0->SetToolTipText("Set no border of the pad/canvas");
118 fBmode1 = new TGRadioButton(fBgroup, " Raised border", 79);
119 fBmode1->SetToolTipText("Set a raised border of the pad/canvas");
120 fBmodelh = new TGLayoutHints(kLHintsLeft, 0,0,3,0);
124 AddFrame(f6, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
125
126 TGCompositeFrame *f7 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
127 TGLabel *fSizeLbl = new TGLabel(f7, "Size:");
128 f7->AddFrame(fSizeLbl, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 6, 1, 0, 0));
130 fBsize->Resize(92, 20);
131 f7->AddFrame(fBsize, new TGLayoutHints(kLHintsLeft, 13, 1, 0, 0));
132 fBsize->Associate(this);
133 AddFrame(f7, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
134
135 fInit = kTRUE;
136}
137
138////////////////////////////////////////////////////////////////////////////////
139/// Destructor of fill editor.
140
142{
143 // children of TGButonGroup are not deleted
144 delete fBmode;
145 delete fBmode0;
146 delete fBmode1;
147 delete fBmodelh;
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Connect signals to slots.
152
154{
155 fFixedAR->Connect("Toggled(Bool_t)","TPadEditor",this,"DoFixedAspectRatio(Bool_t)");
156 fCrosshair->Connect("Toggled(Bool_t)","TPadEditor",this,"DoCrosshair(Bool_t)");
157 fEditable->Connect("Toggled(Bool_t)","TPadEditor",this,"DoEditable(Bool_t)");
158 fGridX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoGridX(Bool_t)");
159 fGridY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoGridY(Bool_t)");
160 fTickX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoTickX(Bool_t)");
161 fTickY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoTickY(Bool_t)");
162 fLogX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogX(Bool_t)");
163 fLogY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogY(Bool_t)");
164 fLogZ->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogZ(Bool_t)");
165 fBgroup->Connect("Clicked(Int_t)","TPadEditor",this,"DoBorderMode()");
166 fBsize->Connect("Selected(Int_t)", "TPadEditor", this, "DoBorderSize(Int_t)");
167 fInit = kFALSE;
168}
169
170////////////////////////////////////////////////////////////////////////////////
171/// Pick up the used fill attributes.
172
174{
175 if (!obj || !obj->InheritsFrom("TPad"))
176 return;
177 fPadPointer = (TPad *)obj;
179 Bool_t on;
180
184
188
192
196
200
201 Int_t par;
202 par = fPadPointer->GetLogx();
203 if (par) fLogX->SetState(kButtonDown);
204 else fLogX->SetState(kButtonUp);
205
206 par = fPadPointer->GetLogy();
207 if (par) fLogY->SetState(kButtonDown);
208 else fLogY->SetState(kButtonUp);
209
210 par = fPadPointer->GetLogz();
211 if (par) fLogZ->SetState(kButtonDown);
212 else fLogZ->SetState(kButtonUp);
213
214 par = fPadPointer->GetTickx();
215 if (par) fTickX->SetState(kButtonDown);
217
218 par = fPadPointer->GetTicky();
219 if (par) fTickY->SetState(kButtonDown);
221
222 par = fPadPointer->GetBorderMode();
223 if (par == -1) {
224 fBgroup->SetButton(77, kTRUE);
226 } else if (par == 1) {
227 fBgroup->SetButton(79, kTRUE);
229 } else {
230 fBgroup->SetButton(78, kTRUE);
232 }
233 par = fPadPointer->GetBorderSize();
234 if (par < 1) par = 1;
235 if (par > 16) par = 16;
236 fBsize->Select(par);
237
239
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Exclude TAttLineEditor from this interface.
245
247{
250}
251
252////////////////////////////////////////////////////////////////////////////////
253/// Slot connected to the check box 'Editable'.
254
256{
257 if (fAvoidSignal) return;
259 Update();
260}
261
262////////////////////////////////////////////////////////////////////////////////
263/// Slot connected to the check box 'Crosshair'.
264
266{
267 if (fAvoidSignal) return;
269 Update();
270}
271
272////////////////////////////////////////////////////////////////////////////////
273/// Slot connected to the check box 'Fixed aspect ratio'.
274
276{
277 if (fAvoidSignal) return;
279 Update();
280}
281
282////////////////////////////////////////////////////////////////////////////////
283/// Slot connected to the check box 'GridX'.
284
286{
287 if (fAvoidSignal) return;
289 Update();
290}
291
292////////////////////////////////////////////////////////////////////////////////
293/// Slot connected to the check box 'GridY'.
294
296{
297 if (fAvoidSignal) return;
299 Update();
300}
301
302////////////////////////////////////////////////////////////////////////////////
303/// Slot connected to the check box 'LogX'.
304
306{
307 if (fAvoidSignal) return;
309 Update();
310}
311
312////////////////////////////////////////////////////////////////////////////////
313/// Slot connected to the check box 'LogY'.
314
316{
317 if (fAvoidSignal) return;
319 Update();
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// Slot connected to the check box 'LogZ'.
324
326{
327 if (fAvoidSignal) return;
329 Update();
330}
331
332////////////////////////////////////////////////////////////////////////////////
333/// Slot connected to the check box 'TickX'.
334
336{
337 if (fAvoidSignal) return;
339 Update();
340}
341
342////////////////////////////////////////////////////////////////////////////////
343/// Slot connected to the check box 'TickY'.
344
346{
347 if (fAvoidSignal) return;
349 Update();
350}
351
352////////////////////////////////////////////////////////////////////////////////
353/// Slot connected to the border mode settings.
354
356{
357 if (fAvoidSignal) return;
358 Int_t mode = 0;
359 if (fBmode->GetState() == kButtonDown) mode = -1;
360 else if (fBmode0->GetState() == kButtonDown) mode = 0;
361 else mode = 1;
362
363 if (!mode) {
365 } else {
367 }
369 Update();
370}
371
372////////////////////////////////////////////////////////////////////////////////
373/// Slot connected to the border size settings.
374
376{
377 if (fAvoidSignal) return;
379 Update();
380}
@ kChildFrame
Definition GuiTypes.h:379
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFitWidth
Definition GuiTypes.h:386
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsTop
Definition TGLayout.h:27
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char mode
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
EPadWid
@ kPAD_TICKX
@ kPAD_BSIZE
@ kPAD_FAR
@ kPAD_TICKY
@ kPAD_LOGX
@ kPAD_CROSS
@ kPAD_GRIDX
@ kPAD_LOGY
@ kPAD_EDIT
@ kPAD_LOGZ
@ kCOLOR
@ kPAD_BMODE
@ kPAD_GRIDY
static TClass * Class()
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
Organizes TGButton widgets in a group.
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=nullptr)
Set layout hints for the specified button or if button=0 for all buttons.
virtual void SetRadioButtonExclusive(Bool_t flag=kTRUE)
If enable is kTRUE, this button group will treat radio buttons as mutually exclusive,...
virtual void SetButton(Int_t id, Bool_t down=kTRUE)
Sets the button with id to be on/down, and if this is an exclusive group, all other button in the gro...
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:445
virtual EButtonState GetState() const
Definition TGButton.h:112
Selects different options.
Definition TGButton.h:264
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
virtual void SetEnabled(Bool_t on=kTRUE)
Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
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 ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1043
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
The TGLineWidthComboBox user callable and it creates a combobox for selecting the line width.
Definition TGComboBox.h:158
Selects different options.
Definition TGButton.h:321
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
ROOT GUI Window base class.
Definition TGWindow.h:23
void ExcludeClassEditor(TClass *cl, Bool_t recurse=kFALSE)
Exclude editor for class cl from current construction.
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
virtual void ActivateBaseClassEditors(TClass *cl)
Provide list of editors for base-classes.
TGedEditor * fGedEditor
manager of this frame
Definition TGedFrame.h:48
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
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:525
Editor of pad/canvas objects.
Definition TPadEditor.h:25
~TPadEditor() override
Destructor of fill editor.
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGRadioButton * fBmode0
set no pad border
Definition TPadEditor.h:40
virtual void DoGridX(Bool_t on)
Slot connected to the check box 'GridX'.
TGButtonGroup * fBgroup
button group of border mode
Definition TPadEditor.h:44
virtual void DoLogY(Bool_t on)
Slot connected to the check box 'LogY'.
virtual void DoEditable(Bool_t on)
Slot connected to the check box 'Editable'.
TGCheckButton * fLogX
set log scale on X
Definition TPadEditor.h:34
void SetModel(TObject *obj) override
Pick up the used fill attributes.
void ActivateBaseClassEditors(TClass *cl) override
Exclude TAttLineEditor from this interface.
TGCheckButton * fFixedAR
set fixed aspect ratio
Definition TPadEditor.h:31
TGCheckButton * fLogZ
set log scale on Z
Definition TPadEditor.h:36
virtual void DoBorderSize(Int_t size)
Slot connected to the border size settings.
virtual void DoCrosshair(Bool_t on)
Slot connected to the check box 'Crosshair'.
virtual void DoTickY(Bool_t on)
Slot connected to the check box 'TickY'.
TGCheckButton * fLogY
set log scale on Y
Definition TPadEditor.h:35
TGLineWidthComboBox * fBsize
set pad border size
Definition TPadEditor.h:43
virtual void DoBorderMode()
Slot connected to the border mode settings.
TGCheckButton * fTickX
set ticks on X
Definition TPadEditor.h:37
TGRadioButton * fBmode1
set raised pad border mode
Definition TPadEditor.h:41
TGCheckButton * fGridY
set grid on Y
Definition TPadEditor.h:33
TGCheckButton * fCrosshair
set crosshair
Definition TPadEditor.h:30
virtual void DoFixedAspectRatio(Bool_t on)
Slot connected to the check box 'Fixed aspect ratio'.
TPad * fPadPointer
TPad object.
Definition TPadEditor.h:28
virtual void DoLogX(Bool_t on)
Slot connected to the check box 'LogX'.
TGCheckButton * fGridX
set grid on X
Definition TPadEditor.h:32
virtual void DoGridY(Bool_t on)
Slot connected to the check box 'GridY'.
TGRadioButton * fBmode
set sinken pad border mode
Definition TPadEditor.h:39
virtual void DoTickX(Bool_t on)
Slot connected to the check box 'TickX'.
TGCheckButton * fEditable
set pad editable
Definition TPadEditor.h:29
TGCheckButton * fTickY
set ticks on Y
Definition TPadEditor.h:38
TPadEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of TPad editor GUI.
virtual void DoLogZ(Bool_t on)
Slot connected to the check box 'LogZ'.
TGLayoutHints * fBmodelh
layout hints for border mode buttons
Definition TPadEditor.h:42
The most important graphics class in the ROOT system.
Definition TPad.h:28
void SetGridx(Int_t value=1) override
Definition TPad.h:333
Short_t GetBorderMode() const override
Definition TPad.h:197
void SetBorderSize(Short_t bordersize) override
Definition TPad.h:323
Int_t GetTicky() const override
Definition TPad.h:237
Bool_t IsEditable() const override
Definition TPad.h:270
void SetTickx(Int_t value=1) override
Definition TPad.h:353
Bool_t GetGridx() const override
Definition TPad.h:233
void SetLogz(Int_t value=1) override
Set Lin/Log scale for Z.
Definition TPad.cxx:5998
void SetEditable(Bool_t mode=kTRUE) override
Set pad editable yes/no If a pad is not editable:
Definition TPad.cxx:5942
Int_t GetTickx() const override
Definition TPad.h:236
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition TPad.cxx:5987
Bool_t HasCrosshair() const override
Return kTRUE if the crosshair has been activated (via SetCrosshair).
Definition TPad.cxx:6529
Bool_t HasFixedAspectRatio() const override
Definition TPad.h:268
Bool_t GetGridy() const override
Definition TPad.h:234
Int_t GetLogz() const override
Definition TPad.h:256
void SetFixedAspectRatio(Bool_t fixed=kTRUE) override
Fix pad aspect ratio to current value if fixed is true.
Definition TPad.cxx:5918
Short_t GetBorderSize() const override
Definition TPad.h:198
void SetGridy(Int_t value=1) override
Definition TPad.h:334
Int_t GetLogy() const override
Definition TPad.h:255
void SetBorderMode(Short_t bordermode) override
Definition TPad.h:322
void SetTicky(Int_t value=1) override
Definition TPad.h:354
void SetLogx(Int_t value=1) override
Set Lin/Log scale for X.
Definition TPad.cxx:5973
void SetCrosshair(Int_t crhair=1) override
Set crosshair active/inactive.
Definition TPad.cxx:6551
Int_t GetLogx() const override
Definition TPad.h:254
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