CustusX  18.04
An IGT application
cxLandmarkListener.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 "cxLandmarkListener.h"
13 #include "cxLandmarkRep.h"
14 #include "cxRegistrationService.h"
15 #include "cxViewService.h"
16 #include "cxRepContainer.h"
17 
18 namespace cx
19 {
20 
22  mServices(services),
23  mImage2Image(false),
24  mUseOnlyOneSourceUpdatedFromOutside(false)
25 {
26  mFixedLandmarkSource = ImageLandmarksSource::New();
27  mMovingLandmarkSource = ImageLandmarksSource::New();
28 
29  connect(mServices->registration().get(), &RegistrationService::fixedDataChanged, this, &LandmarkListener::updateFixed);
30  connect(mServices->registration().get(), &RegistrationService::movingDataChanged, this, &LandmarkListener::updateMoving);
31 }
32 
34 {
35  disconnect(mServices->registration().get(), &RegistrationService::fixedDataChanged, this, &LandmarkListener::updateFixed);
36  disconnect(mServices->registration().get(), &RegistrationService::movingDataChanged, this, &LandmarkListener::updateMoving);
37 }
38 
40 {
41  mImage2Image = useI2I;
42 }
43 
45 {
46  mUseOnlyOneSourceUpdatedFromOutside = useOnlyOneSourceUpdatedFromOutside;
47  disconnect(mServices->registration().get(), &RegistrationService::fixedDataChanged, this, &LandmarkListener::updateFixed);
48  disconnect(mServices->registration().get(), &RegistrationService::movingDataChanged, this, &LandmarkListener::updateMoving);
49 }
50 
51 
52 void LandmarkListener::updateFixed()
53 {
54  mFixedLandmarkSource->setData(mServices->registration()->getFixedData());
55 }
56 
57 void LandmarkListener::updateMoving()
58 {
59  mMovingLandmarkSource->setData(mServices->registration()->getMovingData());
60 }
61 
63 {
64  if(!mUseOnlyOneSourceUpdatedFromOutside)
65  return;
66  mFixedLandmarkSource->setData(data);
67 }
68 
70 {
71  return mFixedLandmarkSource->getData();
72 }
73 
75 {
76  if(!mServices->view()->get3DView(0, 0))
77  return;
78 
79  LandmarkRepPtr rep = mServices->view()->get3DReps(0, 0)->findFirst<LandmarkRep>();
80 
81  if (rep)
82  {
83  rep->setPrimarySource(mFixedLandmarkSource);
84  rep->setSecondaryColor(QColor::fromRgbF(0, 0.6, 0.8));
85 // rep->setSecondaryColor(QColor::fromRgbF(0, 0.9, 0.5));
86 
87  if (mUseOnlyOneSourceUpdatedFromOutside)
88  rep->setSecondarySource(LandmarksSourcePtr());//Only show one source
89  else if(mImage2Image)
90  rep->setSecondarySource(mMovingLandmarkSource);//I2I reg
91  else
92  rep->setSecondarySource(PatientLandmarksSource::New(mServices->patient()));//I2P reg
93  }
94 }
95 
97 {
98  if(!mServices->view()->get3DView(0, 0))
99  return;
100 
101  LandmarkRepPtr rep = mServices->view()->get3DReps(0, 0)->findFirst<LandmarkRep>();
102  if (rep)
103  {
105  rep->setSecondarySource(LandmarksSourcePtr());
106  }
107 }
108 
109 } //cx
void useOnlyOneSourceUpdatedFromOutside(bool useOnlyOneSourceUpdatedFromOutside=true)
static ImageLandmarksSourcePtr New()
Definition: cxLandmarkRep.h:73
void useI2IRegistration(bool useI2I=true)
void fixedDataChanged(QString uid)
boost::shared_ptr< class Data > DataPtr
static PatientLandmarksSourcePtr New(PatientModelServicePtr dataManager)
Definition: cxLandmarkRep.h:58
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:20
void setPrimarySource(LandmarksSourcePtr primary)
void movingDataChanged(QString uid)
boost::shared_ptr< LandmarksSource > LandmarksSourcePtr
Definition: cxLandmarkRep.h:51
void setLandmarkSource(DataPtr data)
boost::shared_ptr< class LandmarkRep > LandmarkRepPtr
LandmarkListener(RegServicesPtr services)
Namespace for all CustusX production code.