Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TCurlyArcEditor.cxx
Go to the documentation of this file.
1 // @(#)root/ged:$Id$
2 // Author: Ilka Antcheva, Otto Schaile 15/12/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, 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 // TCurlyArcEditor //
15 // //
16 // Implements GUI for editing CurlyArc attributes: radius, phi1, phi2. // //
17 // //
18 //////////////////////////////////////////////////////////////////////////
19 //Begin_Html
20 /*
21 <img src="gif/TCurlyArcEditor.gif">
22 */
23 //End_Html
24 
25 
26 #include "TCurlyArcEditor.h"
27 #include "TGLabel.h"
28 #include "TGNumberEntry.h"
29 #include "TCurlyArc.h"
30 #include <iostream>
31 
32 ClassImp(TCurlyArcEditor);
33 
34 enum ECurlyArcWid {
35  kCRLA_RAD,
36  kCRLA_FMIN,
37  kCRLA_FMAX,
38  kCRLA_CX,
39  kCRLA_CY
40 };
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Constructor of CurlyArc GUI.
44 
45 TCurlyArcEditor::TCurlyArcEditor(const TGWindow *p, Int_t width,
46  Int_t height, UInt_t options, Pixel_t back)
47  : TGedFrame(p, width, height, options | kVerticalFrame, back)
48 {
49  fCurlyArc = 0;
50 
51  MakeTitle("Curly Arc");
52 
53  TGCompositeFrame *f3 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
54  AddFrame(f3, new TGLayoutHints(kLHintsTop, 1, 1, 2, 0));
55 
56  TGCompositeFrame *f3a = new TGCompositeFrame(f3, 80, 20);
57  f3->AddFrame(f3a, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
58 
59  TGLabel *fRadiusLabel = new TGLabel(f3a, "Radius:");
60  f3a->AddFrame(fRadiusLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 5, 5));
61 
62  TGLabel *fPhiminLabel = new TGLabel(f3a, "Phimin:");
63  f3a->AddFrame(fPhiminLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 5, 5));
64 
65  TGLabel *fPhimaxLabel = new TGLabel(f3a, "Phimax:");
66  f3a->AddFrame(fPhimaxLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 5, 5));
67 
68  TGLabel *fCenterXLabel = new TGLabel(f3a, "Center X:");
69  f3a->AddFrame(fCenterXLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 6, 5));
70 
71  TGLabel *fCenterYLabel = new TGLabel(f3a, "Y:");
72  f3a->AddFrame(fCenterYLabel, new TGLayoutHints(kLHintsNormal, 49, 0, 6, 0));
73 
74  TGCompositeFrame *f3b = new TGCompositeFrame(f3, 80, 20);
75  f3->AddFrame(f3b, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
76 
77  fRadiusEntry = new TGNumberEntry(f3b, 0.02, 7, kCRLA_RAD,
78  TGNumberFormat::kNESRealThree,
79  TGNumberFormat::kNEANonNegative,
80  TGNumberFormat::kNELNoLimits);
81  fRadiusEntry->GetNumberEntry()->SetToolTipText("Set radius of arc.");
82  f3b->AddFrame(fRadiusEntry, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
83 
84  fPhiminEntry = new TGNumberEntry(f3b, 0, 7, kCRLA_FMIN,
85  TGNumberFormat::kNESInteger,
86  TGNumberFormat::kNEANonNegative,
87  TGNumberFormat::kNELLimitMinMax, 0, 360);
88  fPhiminEntry->GetNumberEntry()->SetToolTipText("Set Phimin in degrees.");
89  f3b->AddFrame(fPhiminEntry, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
90 
91  fPhimaxEntry = new TGNumberEntry(f3b, 0, 7, kCRLA_FMAX,
92  TGNumberFormat::kNESInteger,
93  TGNumberFormat::kNEANonNegative,
94  TGNumberFormat::kNELLimitMinMax, 0, 360);
95  fPhimaxEntry->GetNumberEntry()->SetToolTipText("Set Phimax in degrees.");
96  f3b->AddFrame(fPhimaxEntry, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
97 
98  fCenterXEntry = new TGNumberEntry(f3b, 0.0, 7, kCRLA_CX,
99  TGNumberFormat::kNESRealThree,
100  TGNumberFormat::kNEANonNegative,
101  TGNumberFormat::kNELNoLimits);
102  fCenterXEntry->GetNumberEntry()->SetToolTipText("Set center X coordinate.");
103  f3b->AddFrame(fCenterXEntry, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
104 
105  fCenterYEntry = new TGNumberEntry(f3b, 0.0, 7, kCRLA_CY,
106  TGNumberFormat::kNESRealThree,
107  TGNumberFormat::kNEANonNegative,
108  TGNumberFormat::kNELNoLimits);
109  fCenterYEntry->GetNumberEntry()->SetToolTipText("Set center Y coordinate.");
110  f3b->AddFrame(fCenterYEntry, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
111 
112 }
113 
114 ////////////////////////////////////////////////////////////////////////////////
115 /// Destructor of CurlyArc editor.
116 
117 TCurlyArcEditor::~TCurlyArcEditor()
118 {
119 }
120 
121 ////////////////////////////////////////////////////////////////////////////////
122 /// Connect signals to slots.
123 
124 void TCurlyArcEditor::ConnectSignals2Slots()
125 {
126  fCenterXEntry->Connect("ValueSet(Long_t)", "TCurlyArcEditor", this, "DoCenterXY()");
127  (fCenterXEntry->GetNumberEntry())->Connect("ReturnPressed()", "TCurlyArcEditor", this, "DoCenterXY()");
128  fCenterYEntry->Connect("ValueSet(Long_t)", "TCurlyArcEditor", this, "DoCenterXY()");
129  (fCenterYEntry->GetNumberEntry())->Connect("ReturnPressed()", "TCurlyArcEditor", this, "DoCenterXY()");
130  fRadiusEntry->Connect("ValueSet(Long_t)", "TCurlyArcEditor", this, "DoRadius()");
131  (fRadiusEntry->GetNumberEntry())->Connect("ReturnPressed()", "TCurlyArcEditor", this, "DoRadius()");
132  fPhiminEntry->Connect("ValueSet(Long_t)", "TCurlyArcEditor", this, "DoPhimin()");
133  (fPhiminEntry->GetNumberEntry())->Connect("ReturnPressed()", "TCurlyArcEditor", this, "DoPhimin()");
134  fPhimaxEntry->Connect("ValueSet(Long_t)", "TCurlyArcEditor", this, "DoPhimax()");
135  (fPhimaxEntry->GetNumberEntry())->Connect("ReturnPressed()", "TCurlyArcEditor", this, "DoPhimax()");
136 
137  fInit = kFALSE;
138 }
139 
140 ////////////////////////////////////////////////////////////////////////////////
141 /// Pick up the used curly arc attributes.
142 
143 void TCurlyArcEditor::SetModel(TObject* obj)
144 {
145  fCurlyArc = (TCurlyArc *)obj;
146  fAvoidSignal = kTRUE;
147 
148  Double_t val = fCurlyArc->GetRadius();
149  fRadiusEntry->SetNumber(val);
150 
151  val = fCurlyArc->GetPhimin();
152  fPhiminEntry->SetNumber(val);
153 
154  val = fCurlyArc->GetPhimax();
155  fPhimaxEntry->SetNumber(val);
156 
157  val = fCurlyArc->GetStartX();
158  fCenterXEntry->SetNumber(val);
159 
160  val = fCurlyArc->GetStartY();
161  fCenterYEntry->SetNumber(val);
162 
163  if (fInit) ConnectSignals2Slots();
164 
165  fAvoidSignal = kFALSE;
166 }
167 
168 ////////////////////////////////////////////////////////////////////////////////
169 /// Slot connected to set center .
170 
171 void TCurlyArcEditor::DoCenterXY()
172 {
173  if (fAvoidSignal) return;
174  fCurlyArc->SetCenter((Double_t)fCenterXEntry->GetNumber(), (Double_t)fCenterYEntry->GetNumber());
175  fCurlyArc->Paint(fCurlyArc->GetDrawOption());
176  Update();
177 }
178 
179 ////////////////////////////////////////////////////////////////////////////////
180 /// Slot connected to the radius setting.
181 
182 void TCurlyArcEditor::DoRadius()
183 {
184  if (fAvoidSignal) return;
185  fCurlyArc->SetRadius((Double_t)fRadiusEntry->GetNumber());
186  fCurlyArc->Paint(fCurlyArc->GetDrawOption());
187  Update();
188 }
189 
190 ////////////////////////////////////////////////////////////////////////////////
191 /// Slot connected to the phimin setting.
192 
193 void TCurlyArcEditor::DoPhimin()
194 {
195  if (fAvoidSignal) return;
196  fCurlyArc->SetPhimin((Double_t)fPhiminEntry->GetNumber());
197  fCurlyArc->Paint(fCurlyArc->GetDrawOption());
198  Update();
199 }
200 
201 ////////////////////////////////////////////////////////////////////////////////
202 /// Slot connected to the phimax setting.
203 
204 void TCurlyArcEditor::DoPhimax()
205 {
206  if (fAvoidSignal) return;
207  fCurlyArc->SetPhimax((Double_t)fPhimaxEntry->GetNumber());
208  fCurlyArc->Paint(fCurlyArc->GetDrawOption());
209  Update();
210 }