CMS 3D CMS Logo

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 }
FW3DViewDistanceMeasureTool::m_action
EPickAction m_action
Definition: FW3DViewDistanceMeasureTool.h:32
FW3DViewDistanceMeasureTool::buildGUI
TGCompositeFrame * buildGUI(TGCompositeFrame *p)
Definition: FW3DViewDistanceMeasureTool.cc:70
FW3DViewDistanceMeasureTool::m_bp1
TGTextButton * m_bp1
Definition: FW3DViewDistanceMeasureTool.h:35
FW3DViewDistanceMeasureTool::refCurrentVertex
TGLVector3 & refCurrentVertex()
Definition: FW3DViewDistanceMeasureTool.cc:58
FW3DViewDistanceMeasureTool::m_pnt1
TGLVector3 m_pnt1
Definition: FW3DViewDistanceMeasureTool.h:30
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
FW3DViewDistanceMeasureTool::Print
void Print() const
Definition: FW3DViewDistanceMeasureTool.cc:14
FW3DViewDistanceMeasureTool::m_ldist
TGLabel * m_ldist
Definition: FW3DViewDistanceMeasureTool.h:39
FW3DViewDistanceMeasureTool::FW3DViewDistanceMeasureTool
FW3DViewDistanceMeasureTool()
Definition: FW3DViewDistanceMeasureTool.cc:11
FW3DViewDistanceMeasureTool::kNone
Definition: FW3DViewDistanceMeasureTool.h:14
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
FW3DViewDistanceMeasureTool::m_lp2
TGLabel * m_lp2
Definition: FW3DViewDistanceMeasureTool.h:38
b
double b
Definition: hdecay.h:118
FW3DViewDistanceMeasureTool.h
FW3DViewDistanceMeasureTool::m_lp1
TGLabel * m_lp1
Definition: FW3DViewDistanceMeasureTool.h:37
a
double a
Definition: hdecay.h:119
FW3DViewDistanceMeasureTool::setActionPnt2
void setActionPnt2()
Definition: FW3DViewDistanceMeasureTool.cc:51
FW3DViewDistanceMeasureTool::m_bp2
TGTextButton * m_bp2
Definition: FW3DViewDistanceMeasureTool.h:36
FW3DViewDistanceMeasureTool::kPnt2
Definition: FW3DViewDistanceMeasureTool.h:14
FW3DViewDistanceMeasureTool::resetAction
void resetAction()
Definition: FW3DViewDistanceMeasureTool.cc:22
WDecay::kNone
Definition: TopGenEvent.h:27
FW3DViewDistanceMeasureTool::kPnt1
Definition: FW3DViewDistanceMeasureTool.h:14
ztail.d
d
Definition: ztail.py:151
FW3DViewDistanceMeasureTool::m_pnt2
TGLVector3 m_pnt2
Definition: FW3DViewDistanceMeasureTool.h:31
FW3DViewDistanceMeasureTool::setActionPnt1
void setActionPnt1()
Definition: FW3DViewDistanceMeasureTool.cc:44