CMS 3D CMS Logo

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