Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEveArrowEditor.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 
12 #include "TEveArrowEditor.h"
13 #include "TEveArrow.h"
14 #include "TVirtualPad.h"
15 #include "TGLabel.h"
16 #include "TEveGValuators.h"
17 
18 /** \class TEveArrowEditor
19 \ingroup TEve
20 GUI editor for TEveArrow.
21 */
22 
23 ClassImp(TEveArrowEditor);
24 
25 ////////////////////////////////////////////////////////////////////////////////
26 
27 TEveArrowEditor::TEveArrowEditor(const TGWindow *p, Int_t width, Int_t height,
28  UInt_t options, Pixel_t back) :
29  TGedFrame(p, width, height, options | kVerticalFrame, back),
30  fM(0),
31 
32  fTubeR(0),
33  fConeR(0),
34  fConeL(0),
35 
36  fOrigin(0),
37  fVector(0)
38 {
39  // Constructor.
40 
41  MakeTitle("TEveArrow");
42  Int_t labelW = 51;
43 
44  fTubeR = new TEveGValuator(this, "TubeR:", 90, 0);
45  fTubeR->SetLabelWidth(labelW);
46  fTubeR->SetNELength(6);
47  fTubeR->Build();
48  fTubeR->SetLimits(0.001, 1, 101, TGNumberFormat::kNESRealThree);
49  fTubeR->Connect("ValueSet(Double_t)", "TEveArrowEditor", this, "DoTubeR()");
50  AddFrame(fTubeR, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
51 
52  fConeR = new TEveGValuator(this, "ConeR:", 90, 0);
53  fConeR->SetLabelWidth(labelW);
54  fConeR->SetNELength(6);
55  fConeR->Build();
56  fConeR->SetLimits(0.001, 1, 101, TGNumberFormat::kNESRealThree);
57  fConeR->Connect("ValueSet(Double_t)", "TEveArrowEditor", this, "DoConeR()");
58  AddFrame(fConeR, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
59 
60  fConeL = new TEveGValuator(this, "ConeL:", 90, 0);
61  fConeL->SetLabelWidth(labelW);
62  fConeL->SetNELength(6);
63  fConeL->Build();
64  fConeL->SetLimits(0.001, 1, 101, TGNumberFormat::kNESRealThree);
65  fConeL->Connect("ValueSet(Double_t)", "TEveArrowEditor", this, "DoConeL()");
66  AddFrame(fConeL, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
67 
68  TGFont *font = gClient->GetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
69  {
70  TGHorizontalFrame* hfp = new TGHorizontalFrame(this);
71  TGLabel* labp = new TGLabel(hfp, "Origin");
72  labp->SetTextFont(font);
73  hfp->AddFrame(labp);
74  AddFrame(hfp, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,2,0));
75  fOrigin = new TEveGTriVecValuator(this, "Origin", 160, 20);
76  fOrigin->SetNELength(6);
77  fOrigin->Build(kFALSE, "", "", "");
78  fOrigin->SetLimits(-1e5, 1e5, TGNumberFormat::kNESRealThree);
79  AddFrame(fOrigin, new TGLayoutHints(kLHintsTop , 0,0,0,0));
80  }
81 
82  {
83  TGHorizontalFrame* hfp = new TGHorizontalFrame(this);
84  TGLabel* labp = new TGLabel(hfp, "Vector");
85  labp->SetTextFont(font);
86  hfp->AddFrame(labp);
87  AddFrame(hfp, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0,0,2,0));
88  fVector = new TEveGTriVecValuator(this, "Vector", 160, 20);
89  fVector->SetNELength(6);
90  fVector->Build(kFALSE, "", "", "");
91  fVector->SetLimits(-1e5, 1e5, TGNumberFormat::kNESRealThree);
92  AddFrame(fVector, new TGLayoutHints(kLHintsTop , 0,0,0,0));
93  }
94 
95  fVector->Connect("ValueSet()", "TEveArrowEditor", this, "DoVertex()");
96  fOrigin->Connect("ValueSet()", "TEveArrowEditor", this, "DoVertex()");
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Set model object.
101 
102 void TEveArrowEditor::SetModel(TObject* obj)
103 {
104  fM = dynamic_cast<TEveArrow*>(obj);
105 
106  fTubeR->SetValue(fM->fTubeR);
107  fTubeR->SetValue(fM->fTubeR);
108  fConeL->SetValue(fM->fConeL);
109 
110  fOrigin->SetValues(&fM->fOrigin[0]);
111  fVector->SetValues(&fM->fVector[0]);
112 }
113 
114 ////////////////////////////////////////////////////////////////////////////////
115 /// Slot for TubeR.
116 
117 void TEveArrowEditor::DoTubeR()
118 {
119  fM->SetTubeR(fTubeR->GetValue());
120  Update();
121 }
122 
123 ////////////////////////////////////////////////////////////////////////////////
124 /// Slot for ConeR.
125 
126 void TEveArrowEditor::DoConeR()
127 {
128  fM->SetConeR(fConeR->GetValue());
129  Update();
130 }
131 
132 ////////////////////////////////////////////////////////////////////////////////
133 /// Slot for ConeL.
134 
135 void TEveArrowEditor::DoConeL()
136 {
137  fM->SetConeL(fConeL->GetValue());
138  Update();
139 }
140 
141 ////////////////////////////////////////////////////////////////////////////////
142 /// Slot for origin and vector.
143 
144 void TEveArrowEditor::DoVertex()
145 {
146  Double_t v[3];
147  fOrigin->GetValues(v);
148  fM->fOrigin.Set(v);
149  fVector->GetValues(v);
150  fM->fVector.Set(v);
151  fM->StampGeom();
152  Update();
153 }