CustusX  22.04-rc2
An IGT application
cxAxisConnector.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 #include "cxAxisConnector.h"
12 
13 #include "cxPointMetric.h"
14 #include "cxAxesRep.h"
15 #include "cxTool.h"
16 #include "cxSpaceListener.h"
17 #include "cxSpaceProvider.h"
18 
19 namespace cx
20 {
21 
23 {
24  mSpaceProvider = spaceProvider;
25  mListener = mSpaceProvider->createListener();
26  mListener->setSpace(space);
27  connect(mListener.get(), SIGNAL(changed()), this, SLOT(changedSlot()));
28 
29  mRep = AxesRep::New(space.toString() + "_axis");
30  mRep->setCaption(space.toString(), Vector3D(1, 0, 0));
31  mRep->setShowAxesLabels(false);
32  mRep->setFontSize(0.08);
33  mRep->setAxisLength(0.03);
34  this->changedSlot();
35 }
36 
38 {
39  mBase = base;
40  connect(mBase.get(), SIGNAL(changed()), this, SLOT(changedSlot()));
41  this->changedSlot();
42 }
43 
45 {
46  mTool = tool;
47  connect(mTool.get(), SIGNAL(toolVisible(bool)), this, SLOT(changedSlot()));
48  this->changedSlot();
49 }
50 
51 void AxisConnector::changedSlot()
52 {
53  Transform3D rMs = mSpaceProvider->get_toMfrom(mListener->getSpace(), CoordinateSystem(csREF));
54  mRep->setTransform(rMs);
55 
56  mRep->setVisible(true);
57 
58  // if connected to tool: check visibility
59  if (mTool)
60  mRep->setVisible(mTool->getVisible());
61 
62  // Dont show if equal to base
63  if (mBase)
64  {
65  Transform3D rMb = mSpaceProvider->get_toMfrom(mBase->getSpace(), CoordinateSystem(csREF));
66  if (similar(rMb, rMs))
67  mRep->setVisible(false);
68  }
69 
70 }
71 
72 
73 } // namespace cx
74 
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
static AxesRepPtr New(const QString &uid="")
Definition: cxAxesRep.cpp:31
csREF
the data reference space (r) using LPS (left-posterior-superior) coordinates.
Definition: cxDefinitions.h:90
void mergeWith(SpaceListenerPtr base)
SpaceListenerPtr mListener
void connectTo(ToolPtr tool)
Identification of a Coordinate system.
AxisConnector(CoordinateSystem space, SpaceProviderPtr spaceProvider)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
AxesRepPtr mRep
axis
boost::shared_ptr< class SpaceListener > SpaceListenerPtr
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr