NorMIT-nav  2023.01.05-dev+develop.0da12
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 
cx::SpaceListenerPtr
boost::shared_ptr< class SpaceListener > SpaceListenerPtr
Definition: cxAxisConnector.h:23
cxSpaceListener.h
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::AxisConnector::mRep
AxesRepPtr mRep
axis
Definition: cxAxisConnector.h:40
cx::AxesRep::New
static AxesRepPtr New(const QString &uid="")
Definition: cxAxesRep.cpp:31
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cx::AxisConnector::mergeWith
void mergeWith(SpaceListenerPtr base)
Definition: cxAxisConnector.cpp:37
csREF
csREF
the data reference space (r) using LPS (left-posterior-superior) coordinates.
Definition: cxDefinitions.h:90
cxAxisConnector.h
cx::AxisConnector::mListener
SpaceListenerPtr mListener
Definition: cxAxisConnector.h:41
cxTool.h
cx::AxisConnector::connectTo
void connectTo(ToolPtr tool)
Definition: cxAxisConnector.cpp:44
cxPointMetric.h
cx::CoordinateSystem::toString
QString toString() const
Definition: cxCoordinateSystemHelpers.cpp:19
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cx::AxisConnector::AxisConnector
AxisConnector(CoordinateSystem space, SpaceProviderPtr spaceProvider)
Definition: cxAxisConnector.cpp:22
cxAxesRep.h
cx::similar
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
Definition: cxCameraStyleForView.cpp:506
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
cx::SpaceProviderPtr
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
Definition: cxLogicManager.h:23
cx::CoordinateSystem
Identification of a Coordinate system.
Definition: cxCoordinateSystemHelpers.h:31
cxSpaceProvider.h