CustusX  18.04-rc6
An IGT application
cxActiveToolProxy.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #include "cxActiveToolProxy.h"
13 #include "cxTrackingService.h"
14 #include "cxTool.h"
15 
16 namespace cx
17 {
18 
19 ActiveToolProxy::ActiveToolProxy(TrackingServicePtr trackingService) :
20  mTrackingService(trackingService)
21 {
22  connect(mTrackingService.get(), &TrackingService::activeToolChanged, this, &ActiveToolProxy::activeToolChangedSlot);
23  connect(mTrackingService.get(), &TrackingService::stateChanged, this, &ActiveToolProxy::trackingStateChanged);
24 
25  if (mTrackingService->getActiveTool())
26  this->activeToolChangedSlot(mTrackingService->getActiveTool()->getUid());
27 }
28 
29 void ActiveToolProxy::trackingStateChanged()
30 {
31  if (mTrackingService->getState() != Tool::tsTRACKING)
32  emit tps(0);
33 }
34 
35 void ActiveToolProxy::activeToolChangedSlot(const QString& uid)
36 {
37  if (mTool && mTool->getUid() == uid)
38  return;
39 
40  if (mTool)
41  {
42  disconnect(mTool.get(), SIGNAL(toolTransformAndTimestamp(Transform3D, double)), this,
43  SIGNAL(toolTransformAndTimestamp(Transform3D, double)));
44  disconnect(mTool.get(), &Tool::toolVisible, this, &ActiveToolProxy::toolVisible);
45  disconnect(mTool.get(), &Tool::tooltipOffset, this, &ActiveToolProxy::tooltipOffset);
46  disconnect(mTool.get(), &Tool::toolProbeSector, this, &ActiveToolProxy::toolProbeSector);
47  disconnect(mTool.get(), &Tool::tps, this, &ActiveToolProxy::tps);
48 
49  emit tps(0);
50  }
51 
52  mTool = mTrackingService->getActiveTool();
53 
54  if (mTool)
55  {
56  connect(mTool.get(), SIGNAL(toolTransformAndTimestamp(Transform3D, double)), this,
57  SIGNAL(toolTransformAndTimestamp(Transform3D, double)));
58  connect(mTool.get(), &Tool::toolVisible, this, &ActiveToolProxy::toolVisible);
59  connect(mTool.get(), &Tool::tooltipOffset, this, &ActiveToolProxy::tooltipOffset);
60  connect(mTool.get(), &Tool::toolProbeSector, this, &ActiveToolProxy::toolProbeSector);
61  connect(mTool.get(), &Tool::tps, this, &ActiveToolProxy::tps);
62 
63  emit activeToolChanged(mTool->getUid());
64  emit toolVisible(mTool->getVisible());
65  emit toolTransformAndTimestamp(mTool->get_prMt(), mTool->getTimestamp());
66  emit tooltipOffset(mTool->getTooltipOffset());
67  }
68 }
69 
70 }
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class TrackingService > TrackingServicePtr
void toolProbeSector()
void activeToolChanged(const QString &uId)
void toolVisible(bool visible)
void tooltipOffset(double offset)
void tooltipOffset(double offset)
void toolVisible(bool visible)
void tps(int)
emitting tracking data
Definition: cxTool.h:77
Namespace for all CustusX production code.