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");
112 fBgroup->SetRadioButtonExclusive(kTRUE);
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);
120 fBgroup->SetLayoutHints(fBmodelh, fBmode);
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:");
127 f7->AddFrame(fSizeLbl, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 6, 1, 0, 0));
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
180 on = fPadPointer->HasFixedAspectRatio();
181 if (on) fFixedAR->SetState(kButtonDown);
182 else fFixedAR->SetState(kButtonUp);
183
184 on = fPadPointer->HasCrosshair();
185 if (on) fCrosshair->SetState(kButtonDown);
186 else fCrosshair->SetState(kButtonUp);
187
188 on = fPadPointer->IsEditable();
189 if (on) fEditable->SetState(kButtonDown);
190 else fEditable->SetState(kButtonUp);
191
192 on = fPadPointer->GetGridx();
193 if (on) fGridX->SetState(kButtonDown);
194 else fGridX->SetState(kButtonUp);
195
196 on = fPadPointer->GetGridy();
197 if (on) fGridY->SetState(kButtonDown);
198 else fGridY->SetState(kButtonUp);
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);
215 else fTickX->SetState(kButtonUp);
216
217 par = fPadPointer->GetTicky();
218 if (par) fTickY->SetState(kButtonDown);
219 else fTickY->SetState(kButtonUp);
220
221 par = fPadPointer->GetBorderMode();
222 if (par == -1) {
223 fBgroup->SetButton(77, kTRUE);
224 fBsize->SetEnabled(kTRUE);
225 } else if (par == 1) {
226 fBgroup->SetButton(79, kTRUE);
227 fBsize->SetEnabled(kTRUE);
228 } else {
229 fBgroup->SetButton(78, kTRUE);
230 fBsize->SetEnabled(kFALSE);
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;
257 fPadPointer->SetEditable(on);
258 Update();
259}
260
261////////////////////////////////////////////////////////////////////////////////
262/// Slot connected to the check box 'Crosshair'.
263
265{
266 if (fAvoidSignal) return;
267 fPadPointer->SetCrosshair(on);
268 Update();
269}
270
271////////////////////////////////////////////////////////////////////////////////
272/// Slot connected to the check box 'Fixed aspect ratio'.
273
275{
276 if (fAvoidSignal) return;
277 fPadPointer->SetFixedAspectRatio(on);
278 Update();
279}
280
281////////////////////////////////////////////////////////////////////////////////
282/// Slot connected to the check box 'GridX'.
283
285{
286 if (fAvoidSignal) return;
287 fPadPointer->SetGridx(on);
288 Update();
289}
290
291////////////////////////////////////////////////////////////////////////////////
292/// Slot connected to the check box 'GridY'.
293
295{
296 if (fAvoidSignal) return;
297 fPadPointer->SetGridy(on);
298 Update();
299}
300
301////////////////////////////////////////////////////////////////////////////////
302/// Slot connected to the check box 'LogX'.
303
305{
306 if (fAvoidSignal) return;
307 fPadPointer->SetLogx(on);
308 Update();
309}
310
311////////////////////////////////////////////////////////////////////////////////
312/// Slot connected to the check box 'LogY'.
313
315{
316 if (fAvoidSignal) return;
317 fPadPointer->SetLogy(on);
318 Update();
319}
320
321////////////////////////////////////////////////////////////////////////////////
322/// Slot connected to the check box 'LogZ'.
323
325{
326 if (fAvoidSignal) return;
327 fPadPointer->SetLogz(on);
328 Update();
329}
330
331////////////////////////////////////////////////////////////////////////////////
332/// Slot connected to the check box 'TickX'.
333
335{
336 if (fAvoidSignal) return;
337 fPadPointer->SetTickx(on);
338 Update();
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// Slot connected to the check box 'TickY'.
343
345{
346 if (fAvoidSignal) return;
347 fPadPointer->SetTicky(on);
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) {
363 fBsize->SetEnabled(kFALSE);
364 } else {
365 fBsize->SetEnabled(kTRUE);
366 }
367 fPadPointer->SetBorderMode(mode);
368 Update();
369}
370
371////////////////////////////////////////////////////////////////////////////////
372/// Slot connected to the border size settings.
373
375{
376 if (fAvoidSignal) return;
377 fPadPointer->SetBorderSize(size);
378 Update();
379}
@ kChildFrame
Definition GuiTypes.h:380
@ kVerticalFrame
Definition GuiTypes.h:382
@ kFitWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:383
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kCOLOR
@ 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
EPadWid
@ kPAD_TICKX
@ kPAD_BSIZE
@ kPAD_FAR
@ kPAD_TICKY
@ kPAD_LOGX
@ kPAD_CROSS
@ kPAD_GRIDX
@ kPAD_LOGY
@ kPAD_EDIT
@ kPAD_LOGZ
@ 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.
Selects different options.
Definition TGButton.h:264
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
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
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void ActivateBaseClassEditors(TClass *cl)
Provide list of editors for base-classes.
TGedEditor * fGedEditor
manager of this frame
Definition TGedFrame.h:48
TGedFrame(const TGedFrame &)=delete
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:42
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:549
~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