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//////////////////////////////////////////////////////////////////////////
14// //
15// TPadEditor //
16// //
17// Editor of pad/canvas objects. //
18// color and fill style, //
19// 'Edit' check box sets pad/canvad editable, //
20// 'Crosshair' sets a cross hair on the pad, //
21// 'Fixed aspect ratio' can be set when resizing the pad //
22// 'TickX' and 'TickY' set ticks along the X and Y axis //
23// 'GridX' and 'GridY' set a grid along the X and Y axis //
24// pad/canvas border size can be set if a sinken or a raised //
25// border mode is selected; no border mode can be set to //
26// //
27//////////////////////////////////////////////////////////////////////////
28//Begin_Html
29/*
30<img src="gif/TPadEditor.gif">
31*/
32//End_Html
33
34#include "TPadEditor.h"
35#include "TGedEditor.h"
36#include "TGComboBox.h"
37#include "TGButtonGroup.h"
38#include "TGLabel.h"
39#include "TCanvas.h"
40
42
43enum EPadWid {
57};
58
59
60////////////////////////////////////////////////////////////////////////////////
61/// Constructor of TPad editor GUI.
62
64 Int_t height, UInt_t options, Pixel_t back)
65 : TGedFrame(p, width, height, options | kVerticalFrame, back)
66{
67 fPadPointer = 0;
68
69 MakeTitle("Pad/Canvas");
70
71 fFixedAR = new TGCheckButton(this, "Fixed aspect ratio", kPAD_FAR);
72 fFixedAR->SetToolTipText("Set fixed aspect ratio");
73 AddFrame(fFixedAR, new TGLayoutHints(kLHintsTop, 4, 1, 2, 1));
74
75 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
77 fCrosshair = new TGCheckButton(f3, "Crosshair", kPAD_CROSS);
78 fCrosshair->SetToolTipText("Set crosshair");
79 f3->AddFrame(fCrosshair, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
80 fGridX = new TGCheckButton(f3, "GridX", kPAD_GRIDX);
81 fGridX->SetToolTipText("Set grid along X");
82 f3->AddFrame(fGridX, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
83 fTickX = new TGCheckButton(f3, "TickX", kPAD_TICKX);
84 fTickX->SetToolTipText("Set tick marks along X");
85 f3->AddFrame(fTickX, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
86 f2->AddFrame(f3, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
87
89 fEditable = new TGCheckButton(f4, "Edit", kPAD_EDIT);
90 fEditable->SetToolTipText("Set editable mode");
91 f4->AddFrame(fEditable, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
92 fGridY = new TGCheckButton(f4, "GridY", kPAD_GRIDY);
93 fGridY->SetToolTipText("Set grid along Y");
94 f4->AddFrame(fGridY, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
95 fTickY = new TGCheckButton(f4, "TickY", kPAD_TICKY);
96 fTickY->SetToolTipText("Set tick marks along Y");
97 f4->AddFrame(fTickY, new TGLayoutHints(kLHintsTop, 3, 1, 1, 1));
98 f2->AddFrame(f4, new TGLayoutHints(kLHintsTop, 0, 1, 0, 0));
99
100 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
101
102 MakeTitle("Log Scale");
103
104 TGCompositeFrame *f5 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
105 fLogX = new TGCheckButton(f5, ":X", kPAD_LOGX);
106 fLogX->SetToolTipText("Set logarithmic scale along X");
107 f5->AddFrame(fLogX, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
108 fLogY = new TGCheckButton(f5, ":Y", kPAD_LOGY);
109 fLogY->SetToolTipText("Set logarithmic scale along Y");
110 f5->AddFrame(fLogY, new TGLayoutHints(kLHintsTop, 15, 1, 1, 1));
111 fLogZ = new TGCheckButton(f5, ":Z", kPAD_LOGZ);
112 fLogZ->SetToolTipText("Set logarithmic scale along Z");
113 f5->AddFrame(fLogZ, new TGLayoutHints(kLHintsTop, 15, 1, 1, 1));
114 AddFrame(f5, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
115
116 TGCompositeFrame *f6 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
117 fBgroup = new TGButtonGroup(f6,3,1,3,0, "Border Mode");
119 fBmode = new TGRadioButton(fBgroup, " Sunken border", 77);
120 fBmode->SetToolTipText("Set a sinken border of the pad/canvas");
121 fBmode0 = new TGRadioButton(fBgroup, " No border", 78);
122 fBmode0->SetToolTipText("Set no border of the pad/canvas");
123 fBmode1 = new TGRadioButton(fBgroup, " Raised border", 79);
124 fBmode1->SetToolTipText("Set a raised border of the pad/canvas");
125 fBmodelh = new TGLayoutHints(kLHintsLeft, 0,0,3,0);
129 AddFrame(f6, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
130
131 TGCompositeFrame *f7 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
132 TGLabel *fSizeLbl = new TGLabel(f7, "Size:");
133 f7->AddFrame(fSizeLbl, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 6, 1, 0, 0));
135 fBsize->Resize(92, 20);
136 f7->AddFrame(fBsize, new TGLayoutHints(kLHintsLeft, 13, 1, 0, 0));
137 fBsize->Associate(this);
138 AddFrame(f7, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
139
140 fInit = kTRUE;
141}
142
143////////////////////////////////////////////////////////////////////////////////
144/// Destructor of fill editor.
145
147{
148 // children of TGButonGroup are not deleted
149 delete fBmode;
150 delete fBmode0;
151 delete fBmode1;
152 delete fBmodelh;
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Connect signals to slots.
157
159{
160 fFixedAR->Connect("Toggled(Bool_t)","TPadEditor",this,"DoFixedAspectRatio(Bool_t)");
161 fCrosshair->Connect("Toggled(Bool_t)","TPadEditor",this,"DoCrosshair(Bool_t)");
162 fEditable->Connect("Toggled(Bool_t)","TPadEditor",this,"DoEditable(Bool_t)");
163 fGridX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoGridX(Bool_t)");
164 fGridY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoGridY(Bool_t)");
165 fTickX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoTickX(Bool_t)");
166 fTickY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoTickY(Bool_t)");
167 fLogX->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogX(Bool_t)");
168 fLogY->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogY(Bool_t)");
169 fLogZ->Connect("Toggled(Bool_t)","TPadEditor",this,"DoLogZ(Bool_t)");
170 fBgroup->Connect("Clicked(Int_t)","TPadEditor",this,"DoBorderMode()");
171 fBsize->Connect("Selected(Int_t)", "TPadEditor", this, "DoBorderSize(Int_t)");
172 fInit = kFALSE;
173}
174
175////////////////////////////////////////////////////////////////////////////////
176/// Pick up the used fill attributes.
177
179{
180 if (!obj || !obj->InheritsFrom("TPad"))
181 return;
182 fPadPointer = (TPad *)obj;
184 Bool_t on;
185
187 if (on) fFixedAR->SetState(kButtonDown);
189
193
194 on = fPadPointer->IsEditable();
197
198 on = fPadPointer->GetGridx();
199 if (on) fGridX->SetState(kButtonDown);
201
202 on = fPadPointer->GetGridy();
203 if (on) fGridY->SetState(kButtonDown);
205
206 Int_t par;
207 par = fPadPointer->GetLogx();
208 if (par) fLogX->SetState(kButtonDown);
209 else fLogX->SetState(kButtonUp);
210
211 par = fPadPointer->GetLogy();
212 if (par) fLogY->SetState(kButtonDown);
213 else fLogY->SetState(kButtonUp);
214
215 par = fPadPointer->GetLogz();
216 if (par) fLogZ->SetState(kButtonDown);
217 else fLogZ->SetState(kButtonUp);
218
219 par = fPadPointer->GetTickx();
220 if (par) fTickX->SetState(kButtonDown);
222
223 par = fPadPointer->GetTicky();
224 if (par) fTickY->SetState(kButtonDown);
226
227 par = fPadPointer->GetBorderMode();
228 if (par == -1) {
229 fBgroup->SetButton(77, kTRUE);
231 } else if (par == 1) {
232 fBgroup->SetButton(79, kTRUE);
234 } else {
235 fBgroup->SetButton(78, kTRUE);
237 }
238 par = fPadPointer->GetBorderSize();
239 if (par < 1) par = 1;
240 if (par > 16) par = 16;
241 fBsize->Select(par);
242
244
246}
247
248////////////////////////////////////////////////////////////////////////////////
249/// Exclude TAttLineEditor from this interface.
250
252{
253 fGedEditor->ExcludeClassEditor(TAttLine::Class());
255}
256
257////////////////////////////////////////////////////////////////////////////////
258/// Slot connected to the check box 'Editable'.
259
261{
262 if (fAvoidSignal) return;
264 Update();
265}
266
267////////////////////////////////////////////////////////////////////////////////
268/// Slot connected to the check box 'Crosshair'.
269
271{
272 if (fAvoidSignal) return;
274 Update();
275}
276
277////////////////////////////////////////////////////////////////////////////////
278/// Slot connected to the check box 'Fixed aspect ratio'.
279
281{
282 if (fAvoidSignal) return;
284 Update();
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Slot connected to the check box 'GridX'.
289
291{
292 if (fAvoidSignal) return;
294 Update();
295}
296
297////////////////////////////////////////////////////////////////////////////////
298/// Slot connected to the check box 'GridY'.
299
301{
302 if (fAvoidSignal) return;
304 Update();
305}
306
307////////////////////////////////////////////////////////////////////////////////
308/// Slot connected to the check box 'LogX'.
309
311{
312 if (fAvoidSignal) return;
313 fPadPointer->SetLogx(on);
314 Update();
315}
316
317////////////////////////////////////////////////////////////////////////////////
318/// Slot connected to the check box 'LogY'.
319
321{
322 if (fAvoidSignal) return;
323 fPadPointer->SetLogy(on);
324 Update();
325}
326
327////////////////////////////////////////////////////////////////////////////////
328/// Slot connected to the check box 'LogZ'.
329
331{
332 if (fAvoidSignal) return;
333 fPadPointer->SetLogz(on);
334 Update();
335}
336
337////////////////////////////////////////////////////////////////////////////////
338/// Slot connected to the check box 'TickX'.
339
341{
342 if (fAvoidSignal) return;
344 Update();
345}
346
347////////////////////////////////////////////////////////////////////////////////
348/// Slot connected to the check box 'TickY'.
349
351{
352 if (fAvoidSignal) return;
354 Update();
355}
356
357////////////////////////////////////////////////////////////////////////////////
358/// Slot connected to the border mode settings.
359
361{
362 if (fAvoidSignal) return;
363 Int_t mode = 0;
364 if (fBmode->GetState() == kButtonDown) mode = -1;
365 else if (fBmode0->GetState() == kButtonDown) mode = 0;
366 else mode = 1;
367
368 if (!mode) {
370 } else {
372 }
374 Update();
375}
376
377////////////////////////////////////////////////////////////////////////////////
378/// Slot connected to the border size settings.
379
381{
382 if (fAvoidSignal) return;
384 Update();
385}
@ 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
const Bool_t kFALSE
Definition RtypesCore.h:92
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
@ kLHintsLeft
Definition TGLayout.h:31
@ kLHintsCenterY
Definition TGLayout.h:35
@ kLHintsTop
Definition TGLayout.h:34
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
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
virtual void SetRadioButtonExclusive(Bool_t flag=kTRUE)
If enable is kTRUE, this button group will treat radio buttons as mutually exclusive,...
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=0)
Set layout hints for the specified button or if button=0 for all buttons.
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:398
virtual EButtonState GetState() const
Definition TGButton.h:112
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
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.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual void ChangeOptions(UInt_t options)
Change composite frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:1028
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:82
void ExcludeClassEditor(TClass *cl, Bool_t recurse=kFALSE)
Exclude editor for class cl from current construction.
virtual void ActivateBaseClassEditors(TClass *cl)
Provide list of editors for base-classes.
TGedEditor * fGedEditor
Definition TGedFrame.h:55
Bool_t fInit
Definition TGedFrame.h:54
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:57
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:445
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGRadioButton * fBmode0
Definition TPadEditor.h:47
virtual void DoGridX(Bool_t on)
Slot connected to the check box 'GridX'.
TGButtonGroup * fBgroup
Definition TPadEditor.h:51
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
Definition TPadEditor.h:41
TGCheckButton * fFixedAR
Definition TPadEditor.h:38
virtual void SetModel(TObject *obj)
Pick up the used fill attributes.
TGCheckButton * fLogZ
Definition TPadEditor.h:43
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
Definition TPadEditor.h:42
TGLineWidthComboBox * fBsize
Definition TPadEditor.h:50
virtual void DoBorderMode()
Slot connected to the border mode settings.
TGCheckButton * fTickX
Definition TPadEditor.h:44
virtual ~TPadEditor()
Destructor of fill editor.
TGRadioButton * fBmode1
Definition TPadEditor.h:48
TGCheckButton * fGridY
Definition TPadEditor.h:40
TGCheckButton * fCrosshair
Definition TPadEditor.h:37
virtual void DoFixedAspectRatio(Bool_t on)
Slot connected to the check box 'Fixed aspect ratio'.
TPad * fPadPointer
Definition TPadEditor.h:35
virtual void DoLogX(Bool_t on)
Slot connected to the check box 'LogX'.
TGCheckButton * fGridX
Definition TPadEditor.h:39
virtual void DoGridY(Bool_t on)
Slot connected to the check box 'GridY'.
TPadEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of TPad editor GUI.
TGRadioButton * fBmode
Definition TPadEditor.h:46
virtual void DoTickX(Bool_t on)
Slot connected to the check box 'TickX'.
TGCheckButton * fEditable
Definition TPadEditor.h:36
virtual void ActivateBaseClassEditors(TClass *cl)
Exclude TAttLineEditor from this interface.
TGCheckButton * fTickY
Definition TPadEditor.h:45
virtual void DoLogZ(Bool_t on)
Slot connected to the check box 'LogZ'.
TGLayoutHints * fBmodelh
Definition TPadEditor.h:49
The most important graphics class in the ROOT system.
Definition TPad.h:26
void SetGridx(Int_t value=1) override
Definition TPad.h:328
Short_t GetBorderMode() const override
Definition TPad.h:193
void SetBorderSize(Short_t bordersize) override
Definition TPad.h:318
Int_t GetTicky() const override
Definition TPad.h:233
void SetTickx(Int_t value=1) override
Definition TPad.h:348
Bool_t GetGridx() const override
Definition TPad.h:229
void SetLogz(Int_t value=1) override
Set Lin/Log scale for Z.
Definition TPad.cxx:5958
void SetEditable(Bool_t mode=kTRUE) override
Set pad editable yes/no If a pad is not editable:
Definition TPad.cxx:5902
Int_t GetTickx() const override
Definition TPad.h:232
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition TPad.cxx:5947
Bool_t HasCrosshair() const override
Return kTRUE if the crosshair has been activated (via SetCrosshair).
Definition TPad.cxx:6491
Bool_t HasFixedAspectRatio() const override
Definition TPad.h:264
Bool_t GetGridy() const override
Definition TPad.h:230
Int_t GetLogz() const override
Definition TPad.h:252
void SetFixedAspectRatio(Bool_t fixed=kTRUE) override
Fix pad aspect ratio to current value if fixed is true.
Definition TPad.cxx:5878
Short_t GetBorderSize() const override
Definition TPad.h:194
void SetGridy(Int_t value=1) override
Definition TPad.h:329
Int_t GetLogy() const override
Definition TPad.h:251
virtual Bool_t IsEditable() const override
Definition TPad.h:266
void SetBorderMode(Short_t bordermode) override
Definition TPad.h:317
void SetTicky(Int_t value=1) override
Definition TPad.h:349
void SetLogx(Int_t value=1) override
Set Lin/Log scale for X.
Definition TPad.cxx:5933
void SetCrosshair(Int_t crhair=1) override
Set crosshair active/inactive.
Definition TPad.cxx:6513
Int_t GetLogx() const override
Definition TPad.h:250
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:866