Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveProjectionAxesEditor.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Author: Matevz Tadel 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, 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 
13 #include "TEveProjectionAxes.h"
14 #include "TEveGValuators.h"
15 
16 #include "TGComboBox.h"
17 #include "TGButton.h"
18 #include "TGLabel.h"
19 #include "TG3DLine.h"
20 
21 /** \class TEveProjectionAxesEditor
22 \ingroup TEve
23 GUI editor for TEveProjectionAxes.
24 */
25 
26 ClassImp(TEveProjectionAxesEditor);
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 
30 TEveProjectionAxesEditor::TEveProjectionAxesEditor(const TGWindow *p, Int_t width, Int_t height,
31  UInt_t options, Pixel_t back) :
32  TGedFrame(p, width, height, options | kVerticalFrame, back),
33  fM(0),
34 
35  fLabMode(0),
36  fAxesMode(0),
37 
38  fCenterFrame(0),
39  fDrawCenter(0),
40  fDrawOrigin(0)
41 {
42  // Constructor.
43 
44  MakeTitle("TEveProjectionAxis");
45  Int_t labw=52;
46 
47  {
48  TGHorizontalFrame* f = new TGHorizontalFrame(this);
49 
50  TGCompositeFrame *labfr = new TGHorizontalFrame(f, labw, 20, kFixedSize);
51  labfr->AddFrame(new TGLabel(labfr, "Labels:") , new TGLayoutHints(kLHintsLeft | kLHintsBottom));
52  f->AddFrame(labfr, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 0, 1, 1, 1));
53 
54  fLabMode = new TGComboBox(f, "Position");
55  fLabMode->AddEntry("Value", 1);
56  fLabMode->AddEntry("Position", 0);
57  fLabMode->GetTextEntry()->SetToolTipText("Set tick-marks on equidistant values/screen position.");
58  TGListBox* lb = fLabMode->GetListBox();
59  lb->Resize(lb->GetWidth(), 2*18);
60  fLabMode->Resize(80, 20);
61  fLabMode->Connect("Selected(Int_t)", "TEveProjectionAxesEditor", this, "DoLabMode(Int_t)");
62  f->AddFrame(fLabMode, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
63  AddFrame(f);
64  }
65 
66  {
67  TGHorizontalFrame* f = new TGHorizontalFrame(this);
68  TGCompositeFrame *labfr = new TGHorizontalFrame(f, labw, 20, kFixedSize);
69  labfr->AddFrame(new TGLabel(labfr, "Axes:") , new TGLayoutHints(kLHintsLeft | kLHintsBottom));
70  f->AddFrame(labfr, new TGLayoutHints(kLHintsLeft|kLHintsBottom, 0, 1, 1, 1));
71 
72 
73  fAxesMode = new TGComboBox(f, "All");
74  fAxesMode->AddEntry("Horizontal", TEveProjectionAxes::kHorizontal);
75  fAxesMode->AddEntry("Vertical",TEveProjectionAxes::kVertical);
76  fAxesMode->AddEntry("All", TEveProjectionAxes::kAll);
77  TGListBox* lb = fAxesMode->GetListBox();
78  lb->Resize(lb->GetWidth(), 2*18);
79  fAxesMode->Resize(80, 20);
80  fAxesMode->Connect("Selected(Int_t)", "TEveProjectionAxesEditor", this, "DoAxesMode(Int_t)");
81  f->AddFrame(fAxesMode, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
82  AddFrame(f);
83  }
84 
85  //______________________________________________________________________________
86 
87  // center tab
88  fCenterFrame = CreateEditorTabSubFrame("Center");
89 
90  TGCompositeFrame *title1 = new TGCompositeFrame(fCenterFrame, 180, 10,
91  kHorizontalFrame |
92  kLHintsExpandX |
93  kFixedWidth |
94  kOwnBackground);
95  title1->AddFrame(new TGLabel(title1, "Distortion Center"),
96  new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
97  title1->AddFrame(new TGHorizontal3DLine(title1),
98  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
99  fCenterFrame->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
100 
101 
102  {
103 
104  TGHorizontalFrame* hf1 = new TGHorizontalFrame(fCenterFrame);
105 
106  fDrawOrigin = new TGCheckButton(hf1, "DrawOrigin");
107  hf1->AddFrame(fDrawOrigin, new TGLayoutHints(kLHintsLeft, 2,1,0,4));
108  fDrawOrigin->Connect("Toggled(Bool_t)", "TEveProjectionAxesEditor", this, "DoDrawOrigin()");
109 
110 
111  fDrawCenter = new TGCheckButton(hf1, "DrawCenter");
112  hf1->AddFrame(fDrawCenter, new TGLayoutHints(kLHintsLeft, 2,1,0,4));
113  fDrawCenter->Connect("Toggled(Bool_t)", "TEveProjectionAxesEditor", this, "DoDrawCenter()");
114 
115  fCenterFrame->AddFrame(hf1, new TGLayoutHints(kLHintsTop, 0,0,0,0));
116 
117  }
118 }
119 
120 ////////////////////////////////////////////////////////////////////////////////
121 /// Set model object.
122 
123 void TEveProjectionAxesEditor::SetModel(TObject* obj)
124 {
125  fM = dynamic_cast<TEveProjectionAxes*>(obj);
126 
127  fLabMode->Select(fM->GetLabMode(), kFALSE);
128  fAxesMode->Select(fM->GetAxesMode(), kFALSE);
129  fDrawCenter->SetState(fM->GetDrawCenter() ? kButtonDown : kButtonUp);
130  fDrawOrigin->SetState(fM->GetDrawOrigin() ? kButtonDown : kButtonUp);
131 
132 }
133 
134 ////////////////////////////////////////////////////////////////////////////////
135 /// Slot for setting draw of origin.
136 
137 void TEveProjectionAxesEditor::DoDrawOrigin()
138 {
139  fM->SetDrawOrigin(fDrawOrigin->IsOn());
140  Update();
141 }
142 
143 ////////////////////////////////////////////////////////////////////////////////
144 /// Slot for setting draw of center.
145 
146 void TEveProjectionAxesEditor::DoDrawCenter()
147 {
148  fM->SetDrawCenter(fDrawCenter->IsOn());
149  Update();
150 }
151 
152 ////////////////////////////////////////////////////////////////////////////////
153 /// Slot for setting tick-mark step mode.
154 
155 void TEveProjectionAxesEditor::DoLabMode(Int_t mode)
156 {
157  TEveProjectionAxes::ELabMode em = (TEveProjectionAxes::ELabMode ) mode;
158  fM->SetLabMode(em);
159  Update();
160 }
161 
162 ////////////////////////////////////////////////////////////////////////////////
163 /// Slot for setting number of axes.
164 
165 void TEveProjectionAxesEditor::DoAxesMode(Int_t mode)
166 {
167  TEveProjectionAxes::EAxesMode em = (TEveProjectionAxes::EAxesMode ) mode;
168  fM->SetAxesMode(em);
169  Update();
170 }