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
36
52
53
54////////////////////////////////////////////////////////////////////////////////
55/// Constructor of TPad editor GUI.
56
58 Int_t height, UInt_t options, Pixel_t back)
59 : TGedFrame(p, width, height, options | kVerticalFrame, back)
60{
61 fPadPointer = 0;
62
63 MakeTitle("Pad/Canvas");
64
65 fFixedAR = new TGCheckButton(this, "Fixed aspect ratio", kPAD_FAR);
66 fFixedAR->SetToolTipText("Set fixed aspect ratio");
67 AddFrame(fFixedAR, new TGLayoutHints(kLHintsTop, 4, 1, 2, 1));
68
69 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
71 fCrosshair = new TGCheckButton(f3, "Crosshair", kPAD_CROSS);
72 fCrosshair->SetToolTipText("Set crosshair");
73 f3->AddFrame(fCrosshair, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
74 fGridX = new TGCheckButton(f3, "GridX", kPAD_GRIDX);
75 fGridX->SetToolTipText("Set grid along X");
76 f3->AddFrame(fGridX, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
77 fTickX = new TGCheckButton(f3, "TickX", kPAD_TICKX);
78 fTickX->SetToolTipText("Set tick marks along X");
79 f3->AddFrame(fTickX, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
80 f2->AddFrame(f3, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
81
83 fEditable = new TGCheckButton(f4, "Edit", kPAD_EDIT);
84 fEditable->SetToolTipText("Set editable mode");
85 f4->AddFrame(fEditable, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
86 fGridY = new TGCheckButton(f4, "GridY", kPAD_GRIDY);
87 fGridY->SetToolTipText("Set grid along Y");
88 f4->AddFrame(fGridY, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
89 fTickY = new TGCheckButton(f4, "TickY", kPAD_TICKY);
90 fTickY->SetToolTipText("Set tick marks along Y");
91 f4->AddFrame(fTickY, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
92 f2->AddFrame(f4, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
93
94 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
95
96 MakeTitle("Log Scale");
97
98 TGCompositeFrame *f5 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
99 fLogX = new TGCheckButton(f5, ":X", kPAD_LOGX);
100 fLogX->SetToolTipText("Set logarithmic scale along X");
101 f5->AddFrame(fLogX, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
102 fLogY = new TGCheckButton(f5, ":Y", kPAD_LOGY);
103 fLogY->SetToolTipText("Set logarithmic scale along Y");
104 f5->AddFrame(fLogY, new TGLayoutHints(kLHintsTop, 15, 1, 1, 1));
105 fLogZ = new TGCheckButton(f5, ":Z", kPAD_LOGZ);
106 fLogZ->SetToolTipText("Set logarithmic scale along Z");
107 f5->AddFrame(fLogZ, new TGLayoutHints(kLHintsTop, 15, 1, 1, 1));
108 AddFrame(f5, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
109
110 TGCompositeFrame *f6 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
111 fBgroup = new TGButtonGroup(f6,3,1,3,0, "Border Mode");
113 fBmode = new TGRadioButton(fBgroup, " Sunken border", 77);
114 fBmode->SetToolTipText("Set a sinken border of the pad/canvas");
115 fBmode0 = new TGRadioButton(fBgroup, " No border", 78);
116 fBmode0->SetToolTipText("Set no border of the pad/canvas");
117 fBmode1 = new TGRadioButton(fBgroup, " Raised border", 79);
118 fBmode1->SetToolTipText("Set a raised border of the pad/canvas");
119 fBmodelh = new TGLayoutHints(kLHintsLeft, 0,0,3,0);
123 AddFrame(f6, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
124
125 TGCompositeFrame *f7 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
126 TGLabel *fSizeLbl = new TGLabel(f7, "Size:");
129 fBsize->Resize(92, 20);
130 f7->AddFrame(fBsize, new TGLayoutHints(kLHintsLeft, 13, 1, 0, 0));
131 fBsize->Associate(this);
132 AddFrame(f7, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
133
134 fInit = kTRUE;
135}
136
137////////////////////////////////////////////////////////////////////////////////
138/// Destructor of fill editor.
139
141{
142 // children of TGButonGroup are not deleted
143 delete fBmode;
144 delete fBmode0;
145 delete fBmode1;
146 delete fBmodelh;
147}
148
149////////////////////////////////////////////////////////////////////////////////
150/// Connect signals to slots.
151
153{
154 fFixedAR->Connect("Toggled(Bool_t)","TPadEditor",this,"DoFixedAspectRatio(Bool_t)");
155 fCrosshair->Connect("Toggled(Bool_t)","TPadEditor",this,"DoCrosshair(Bool_t)");
156 fEditable->Connect("Toggled(Bool_t)","TPadEditor",this,"DoEditable(Bool_t)");
157 fGridX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoGridX(Bool_t)");
158 fGridY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoGridY(Bool_t)");
159 fTickX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoTickX(Bool_t)");
160 fTickY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoTickY(Bool_t)");
161 fLogX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogX(Bool_t)");
162 fLogY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogY(Bool_t)");
163 fLogZ->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogZ(Bool_t)");
164 fBgroup->Connect("Clicked(Int_t)","TPadEditor",this,"DoBorderMode()");
165 fBsize->Connect("Selected(Int_t)", "TPadEditor", this, "DoBorderSize(Int_t)");
166 fInit = kFALSE;
167}
168
169////////////////////////////////////////////////////////////////////////////////
170/// Pick up the used fill attributes.
171
173{
174 if (!obj || !obj->InheritsFrom("TPad"))
175 return;
176 fPadPointer = (TPad *)obj;
178 Bool_t on;
179
183
187
191
195
199
200 Int_t par;
201 par = fPadPointer->GetLogx();
202 if (par) fLogX->SetState(kButtonDown);
203 else fLogX->SetState(kButtonUp);
204
205 par = fPadPointer->GetLogy();
206 if (par) fLogY->SetState(kButtonDown);
207 else fLogY->SetState(kButtonUp);
208
209 par = fPadPointer->GetLogz();
210 if (par) fLogZ->SetState(kButtonDown);
211 else fLogZ->SetState(kButtonUp);
212
213 par = fPadPointer->GetTickx();
214 if (par) fTickX->SetState(kButtonDown);
216
217 par = fPadPointer->GetTicky();
218 if (par) fTickY->SetState(kButtonDown);
220
221 par = fPadPointer->GetBorderMode();
222 if (par == -1) {
223 fBgroup->SetButton(77, kTRUE);
225 } else if (par == 1) {
226 fBgroup->SetButton(79, kTRUE);
228 } else {
229 fBgroup->SetButton(78, kTRUE);
231 }
232 par = fPadPointer->GetBorderSize();
233 if (par < 1) par = 1;
234 if (par > 16) par = 16;
235 fBsize->Select(par);
236
238
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Exclude TAttLineEditor from this interface.
244
250
251////////////////////////////////////////////////////////////////////////////////
252/// Slot connected to the check box 'Editable'.
253
255{
256 if (fAvoidSignal) return;
258 Update();
259}
260
261////////////////////////////////////////////////////////////////////////////////
262/// Slot connected to the check box 'Crosshair'.
263
265{
266 if (fAvoidSignal) return;
268 Update();
269}
270
271////////////////////////////////////////////////////////////////////////////////
272/// Slot connected to the check box 'Fixed aspect ratio'.
273
280
281////////////////////////////////////////////////////////////////////////////////
282/// Slot connected to the check box 'GridX'.
283
285{
286 if (fAvoidSignal) return;
288 Update();
289}
290
291////////////////////////////////////////////////////////////////////////////////
292/// Slot connected to the check box 'GridY'.
293
295{
296 if (fAvoidSignal) return;
298 Update();
299}
300
301////////////////////////////////////////////////////////////////////////////////
302/// Slot connected to the check box 'LogX'.
303
305{
306 if (fAvoidSignal) return;
308 Update();
309}
310
311////////////////////////////////////////////////////////////////////////////////
312/// Slot connected to the check box 'LogY'.
313
315{
316 if (fAvoidSignal) return;
318 Update();
319}
320
321////////////////////////////////////////////////////////////////////////////////
322/// Slot connected to the check box 'LogZ'.
323
325{
326 if (fAvoidSignal) return;
328 Update();
329}
330
331////////////////////////////////////////////////////////////////////////////////
332/// Slot connected to the check box 'TickX'.
333
335{
336 if (fAvoidSignal) return;
338 Update();
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// Slot connected to the check box 'TickY'.
343
345{
346 if (fAvoidSignal) return;
348 Update();
349}
350
351////////////////////////////////////////////////////////////////////////////////
352/// Slot connected to the border mode settings.
353
355{
356 if (fAvoidSignal) return;
357 Int_t mode = 0;
358 if (fBmode->GetState() == kButtonDown) mode = -1;
359 else if (fBmode0->GetState() == kButtonDown) mode = 0;
360 else mode = 1;
361
362 if (!mode) {
364 } else {
366 }
368 Update();
369}
370
371////////////////////////////////////////////////////////////////////////////////
372/// Slot connected to the border size settings.
373
@ 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:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ 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:84
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:439
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: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 ChangeOptions(UInt_t options) override
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1035
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
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:94
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:71
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:543
~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:337
Short_t GetBorderMode() const override
Definition TPad.h:200
void SetBorderSize(Short_t bordersize) override
Definition TPad.h:327
Int_t GetTicky() const override
Definition TPad.h:240
Bool_t IsEditable() const override
Definition TPad.h:273
void SetTickx(Int_t value=1) override
Definition TPad.h:357
Bool_t GetGridx() const override
Definition TPad.h:236
void SetLogz(Int_t value=1) override
Set Lin/Log scale for Z.
Definition TPad.cxx:6182
void SetEditable(Bool_t mode=kTRUE) override
Set pad editable yes/no If a pad is not editable:
Definition TPad.cxx:6126
Int_t GetTickx() const override
Definition TPad.h:239
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition TPad.cxx:6171
Bool_t HasCrosshair() const override
Return kTRUE if the crosshair has been activated (via SetCrosshair).
Definition TPad.cxx:6713
Bool_t HasFixedAspectRatio() const override
Definition TPad.h:271
Bool_t GetGridy() const override
Definition TPad.h:237
Int_t GetLogz() const override
Definition TPad.h:259
void SetFixedAspectRatio(Bool_t fixed=kTRUE) override
Fix pad aspect ratio to current value if fixed is true.
Definition TPad.cxx:6102
Short_t GetBorderSize() const override
Definition TPad.h:201
void SetGridy(Int_t value=1) override
Definition TPad.h:338
Int_t GetLogy() const override
Definition TPad.h:258
void SetBorderMode(Short_t bordermode) override
Definition TPad.h:326
void SetTicky(Int_t value=1) override
Definition TPad.h:358
void SetLogx(Int_t value=1) override
Set Lin/Log scale for X.
Definition TPad.cxx:6157
void SetCrosshair(Int_t crhair=1) override
Set crosshair active/inactive.
Definition TPad.cxx:6735
Int_t GetLogx() const override
Definition TPad.h:257
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