CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FW3DViewDistanceMeasureTool.cc
Go to the documentation of this file.
2 #include "TGFrame.h"
3 #include "TGButton.h"
4 #include "TGLabel.h"
5 #include "TG3DLine.h"
6 
7 namespace {
8 const char * lbpformat="(%.2f, %.2f, %.2f)";
9 }
10 
12  m_action(kNone), m_bp1(0), m_bp2(0),
13  m_lp1(0), m_lp2(0), m_ldist(0)
14 {
15 }
16 
18 {
19  printf("==============================================\n");
20  m_pnt1.Dump();
21  m_pnt2.Dump();
22  TGLVector3 a = m_pnt1 - m_pnt2;
23  printf("Distance:\n%f \n", a.Mag());
24 }
25 
27 {
28  // printf("Reset ACTION !!!! \n");
29  m_action = kNone;
30  m_bp1->SetState(kButtonUp);
31  m_lp1->SetText( Form(lbpformat, m_pnt1.X(), m_pnt1.Y(), m_pnt1.Z()));
32 
33  m_bp2->SetState(kButtonUp);
34  m_lp2->SetText( Form(lbpformat, m_pnt2.X(), m_pnt2.Y(), m_pnt2.Z()));
35 
36  TGLVector3 d = m_pnt2 - m_pnt1;
37  m_ldist->SetText(Form("%.2f", d.Mag()));
38 
39  {
40  TGCompositeFrame* p = (TGCompositeFrame*)(m_ldist->GetParent());
41  p->Resize(p->GetDefaultSize());
42  }
43  {
44  TGCompositeFrame* p = (TGCompositeFrame*)(m_ldist->GetParent()->GetParent());
45  p->Layout();
46  }
47 }
48 
50 {
51  // printf("Action ! 1111 \n");
52  m_action = kPnt1;
53  m_bp1->SetState(kButtonEngaged);
54  m_bp2->SetState(kButtonUp);
55 }
56 
58 {
59  // printf("Action ! 222 \n");
60  m_action = kPnt2;
61  m_bp2->SetState(kButtonEngaged);
62  m_bp1->SetState(kButtonUp);
63 }
64 
66 {
67  //assert (m_action != kNone);
68  if (m_action == kNone) {
69  printf("ERROR refCurrentVertex m_action == kNone \n");
70  return m_pnt1 ;
71  }
72  if (m_action == kPnt1)
73  return m_pnt1;
74  else
75  return m_pnt2;
76 
77 }
78 
79 TGCompositeFrame* FW3DViewDistanceMeasureTool::buildGUI(TGCompositeFrame* p)
80 {
81  TGVerticalFrame* vf = new TGVerticalFrame(p);
82 
83  {
84  TGHorizontalFrame* hf = new TGHorizontalFrame(vf);
85  TGLabel* lb = new TGLabel(hf, "Distance: ");
86  hf->AddFrame(lb);
87  m_ldist = new TGLabel(hf, " --- ");
88  hf->AddFrame(m_ldist);
89  vf->AddFrame(hf);
90  }
91  {
92  TGHorizontalFrame* hf = new TGHorizontalFrame(vf);
93 
94  m_bp1 = new TGTextButton(hf, "Pick Point1");
95  m_bp1->Connect("Clicked()", "FW3DViewDistanceMeasureTool", this, "setActionPnt1()");
96  m_bp1->SetToolTipText("Click on the butto to pick the first point in viewer.");
97  hf->AddFrame( m_bp1, new TGLayoutHints(kLHintsNormal, 0, 5, 4, 4));
98 
99  m_lp1 = new TGLabel(hf, Form(lbpformat, m_pnt1.X(), m_pnt1.Y(), m_pnt1.Z()));
100  hf->AddFrame(m_lp1, new TGLayoutHints(kLHintsNormal, 0, 1, 4, 4));
101 
102  vf->AddFrame(hf);
103  }
104 
105  {
106  TGHorizontalFrame* hf = new TGHorizontalFrame(vf);
107 
108  m_bp2 = new TGTextButton(hf, "Pick Point2");
109  m_bp2->Connect("Clicked()", "FW3DViewDistanceMeasureTool", this, "setActionPnt2()");
110  m_bp2->SetToolTipText("Click on the butto to pick the secoond point in viewer.");
111  hf->AddFrame( m_bp2, new TGLayoutHints(kLHintsExpandX, 0, 5, 4, 4));
112 
113  m_lp2 = new TGLabel(hf, Form(lbpformat, m_pnt2.X(), m_pnt2.Y(), m_pnt2.Z()));
114  hf->AddFrame(m_lp2, new TGLayoutHints(kLHintsNormal, 0, 1, 4, 4));
115 
116  vf->AddFrame(hf);
117  }
118 
119  {
120  TGHorizontalFrame* hf = new TGHorizontalFrame(vf);
121  TGTextButton* b = new TGTextButton(hf, "Print distance to terminal");
122  b->Connect("Clicked()", "FW3DViewDistanceMeasureTool", this, "Print()");
123  hf->AddFrame(b, new TGLayoutHints(kLHintsNormal, 0, 5, 4, 4));
124  vf->AddFrame(hf);
125  }
126  return vf;
127 
128 }
TGCompositeFrame * buildGUI(TGCompositeFrame *p)
tuple d
Definition: ztail.py:151
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121