Logo ROOT   6.08/07
Reference Guide
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 
43 enum 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 
76  TGCompositeFrame *f3 = new TGCompositeFrame(f2, 40, 20, kVerticalFrame);
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 
88  TGCompositeFrame *f4 = new TGCompositeFrame(f2, 40, 20, kVerticalFrame);
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);
128  f6->AddFrame(fBgroup, new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 4, 1, 0, 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);
188  else fFixedAR->SetState(kButtonUp);
189 
190  on = fPadPointer->HasCrosshair();
191  if (on) fCrosshair->SetState(kButtonDown);
193 
194  on = fPadPointer->IsEditable();
195  if (on) fEditable->SetState(kButtonDown);
197 
198  on = fPadPointer->GetGridx();
199  if (on) fGridX->SetState(kButtonDown);
200  else fGridX->SetState(kButtonUp);
201 
202  on = fPadPointer->GetGridy();
203  if (on) fGridY->SetState(kButtonDown);
204  else fGridY->SetState(kButtonUp);
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);
221  else fTickX->SetState(kButtonUp);
222 
223  par = fPadPointer->GetTicky();
224  if (par) fTickY->SetState(kButtonDown);
225  else fTickY->SetState(kButtonUp);
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 {
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;
293  fPadPointer->SetGridx(on);
294  Update();
295 }
296 
297 ////////////////////////////////////////////////////////////////////////////////
298 /// Slot connected to the check box 'GridY'.
299 
301 {
302  if (fAvoidSignal) return;
303  fPadPointer->SetGridy(on);
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;
343  fPadPointer->SetTickx(on);
344  Update();
345 }
346 
347 ////////////////////////////////////////////////////////////////////////////////
348 /// Slot connected to the check box 'TickY'.
349 
351 {
352  if (fAvoidSignal) return;
353  fPadPointer->SetTicky(on);
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  }
373  fPadPointer->SetBorderMode(mode);
374  Update();
375 }
376 
377 ////////////////////////////////////////////////////////////////////////////////
378 /// Slot connected to the border size settings.
379 
381 {
382  if (fAvoidSignal) return;
383  fPadPointer->SetBorderSize(size);
384  Update();
385 }
virtual void SetGridx(Int_t value=1)
Definition: TPad.h:319
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
double par[1]
Definition: unuranDistr.cxx:38
virtual void DoCrosshair(Bool_t on)
Slot connected to the check box &#39;Crosshair&#39;.
Definition: TPadEditor.cxx:270
virtual void SetTickx(Int_t value=1)
Definition: TPad.h:339
virtual void DoFixedAspectRatio(Bool_t on)
Slot connected to the check box &#39;Fixed aspect ratio&#39;.
Definition: TPadEditor.cxx:280
virtual void ActivateBaseClassEditors(TClass *cl)
Exclude TAttLineEditor from this interface.
Definition: TPadEditor.cxx:251
TGCheckButton * fLogY
Definition: TPadEditor.h:44
virtual Short_t GetBorderSize() const
Definition: TPad.h:192
Int_t GetTickx() const
Definition: TPad.h:224
TGCheckButton * fGridX
Definition: TPadEditor.h:41
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 ConnectSignals2Slots()
Connect signals to slots.
Definition: TPadEditor.cxx:158
virtual void SetFixedAspectRatio(Bool_t fixed=kTRUE)
Fix pad aspect ratio to current value if fixed is true.
Definition: TPad.cxx:5278
Int_t GetTicky() const
Definition: TPad.h:225
virtual void SetBorderMode(Short_t bordermode)
Definition: TPad.h:308
EPadWid
Definition: TPadEditor.cxx:43
Int_t GetLogz() const
Definition: TPad.h:244
TGCheckButton * fTickY
Definition: TPadEditor.h:47
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void DoGridX(Bool_t on)
Slot connected to the check box &#39;GridX&#39;.
Definition: TPadEditor.cxx:290
void ExcludeClassEditor(TClass *cl, Bool_t recurse=kFALSE)
Exclude editor for class cl from current construction.
Definition: TGedEditor.cxx:578
const char * Class
Definition: TXMLSetup.cxx:64
TGCheckButton * fTickX
Definition: TPadEditor.h:46
Int_t GetLogx() const
Definition: TPad.h:242
Int_t GetLogy() const
Definition: TPad.h:243
Bool_t fAvoidSignal
Definition: TGedFrame.h:58
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.
Definition: TPadEditor.cxx:63
ULong_t Pixel_t
Definition: GuiTypes.h:41
virtual void DoBorderMode()
Slot connected to the border mode settings.
Definition: TPadEditor.cxx:360
virtual void SetCrosshair(Int_t crhair=1)
Set crosshair active/inactive.
Definition: TPad.cxx:5892
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition: TGedFrame.cxx:73
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...
Definition: TGComboBox.cxx:443
TGCompositeFrame(const TGCompositeFrame &)
virtual void SetRadioButtonExclusive(Bool_t flag=kTRUE)
If enable is kTRUE, this button group will treat radio buttons as mutually exclusive, and other buttons according to IsExclusive().
TGCheckButton * fEditable
Definition: TPadEditor.h:38
virtual void DoLogX(Bool_t on)
Slot connected to the check box &#39;LogX&#39;.
Definition: TPadEditor.cxx:310
virtual void SetLogx(Int_t value=1)
Set Lin/Log scale for X.
Definition: TPad.cxx:5333
virtual EButtonState GetState() const
Definition: TGButton.h:116
virtual void SetEditable(Bool_t mode=kTRUE)
Set pad editable yes/no If a pad is not editable:
Definition: TPad.cxx:5302
TGCheckButton * fLogX
Definition: TPadEditor.h:43
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:1137
virtual ~TPadEditor()
Destructor of fill editor.
Definition: TPadEditor.cxx:146
Bool_t GetGridy() const
Definition: TPad.h:222
virtual void DoEditable(Bool_t on)
Slot connected to the check box &#39;Editable&#39;.
Definition: TPadEditor.cxx:260
virtual void SetLayoutHints(TGLayoutHints *l, TGButton *button=0)
Set layout hints for the specified button or if button=0 for all buttons.
virtual Bool_t HasCrosshair() const
Return kTRUE if the crosshair has been activated (via SetCrosshair).
Definition: TPad.cxx:5870
TGCheckButton * fLogZ
Definition: TPadEditor.h:45
virtual void SetTicky(Int_t value=1)
Definition: TPad.h:340
virtual Bool_t IsEditable() const
Definition: TPad.h:258
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:90
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:488
virtual void DoGridY(Bool_t on)
Slot connected to the check box &#39;GridY&#39;.
Definition: TPadEditor.cxx:300
unsigned int UInt_t
Definition: RtypesCore.h:42
The most important graphics class in the ROOT system.
Definition: TPad.h:37
virtual void ChangeOptions(UInt_t options)
Change composite frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:1025
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
TGRadioButton * fBmode1
Definition: TPadEditor.h:50
virtual void DoLogY(Bool_t on)
Slot connected to the check box &#39;LogY&#39;.
Definition: TPadEditor.cxx:320
TPad * fPadPointer
Definition: TPadEditor.h:37
virtual void SetEnabled(Bool_t on=kTRUE)
Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
Definition: TGComboBox.cxx:628
TGLineWidthComboBox * fBsize
Definition: TPadEditor.h:52
Bool_t GetGridx() const
Definition: TPad.h:221
#define ClassImp(name)
Definition: Rtypes.h:279
virtual void DoTickX(Bool_t on)
Slot connected to the check box &#39;TickX&#39;.
Definition: TPadEditor.cxx:340
virtual void SetGridy(Int_t value=1)
Definition: TPad.h:320
TGLayoutHints * fBmodelh
Definition: TPadEditor.h:51
TGCheckButton * fGridY
Definition: TPadEditor.h:42
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
Mother of all ROOT objects.
Definition: TObject.h:37
TGButtonGroup * fBgroup
Definition: TPadEditor.h:53
TGRadioButton * fBmode
Definition: TPadEditor.h:48
virtual void SetModel(TObject *obj)
Pick up the used fill attributes.
Definition: TPadEditor.cxx:178
Bool_t fInit
Definition: TGedFrame.h:55
double f2(const double *x)
virtual Short_t GetBorderMode() const
Definition: TPad.h:191
virtual void DoTickY(Bool_t on)
Slot connected to the check box &#39;TickY&#39;.
Definition: TPadEditor.cxx:350
TGCheckButton * fCrosshair
Definition: TPadEditor.h:39
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
virtual void DoBorderSize(Int_t size)
Slot connected to the border size settings.
Definition: TPadEditor.cxx:380
virtual void SetBorderSize(Short_t bordersize)
Definition: TPad.h:309
TGRadioButton * fBmode0
Definition: TPadEditor.h:49
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetLogz(Int_t value=1)
Set Lin/Log scale for Z.
Definition: TPad.cxx:5358
TGedEditor * fGedEditor
Definition: TGedFrame.h:56
virtual void DoLogZ(Bool_t on)
Slot connected to the check box &#39;LogZ&#39;.
Definition: TPadEditor.cxx:330
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
Bool_t HasFixedAspectRatio() const
Definition: TPad.h:256
TGCheckButton * fFixedAR
Definition: TPadEditor.h:40
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.
Definition: TPad.cxx:5347
virtual void ActivateBaseClassEditors(TClass *cl)
Provide list of editors for base-classes.
Definition: TGedFrame.cxx:168