NorMIT-nav  22.09
An IGT application
cxNeuroTrainingWidget.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 "cxNeuroTrainingWidget.h"
13 #include <boost/bind.hpp>
14 #include "cxApplication.h"
15 #include "cxSettings.h"
16 #include "cxLogger.h"
17 #include "cxStateService.h"
18 #include "cxRegistrationWidget.h"
20 #include "cxRegistrationService.h"
21 #include "cxMesh.h"
22 #include "cxRegServices.h"
23 #include "cxTrackingService.h"
24 
25 namespace cx
26 {
27 
28 NeuroTrainingWidget::NeuroTrainingWidget(RegServicesPtr services, ctkPluginContext* context, QWidget *parent) :
29  TrainingWidget(services, "NeuroSimulatorWidget", "Neuro Simulator", parent),
30  mPluginContext(context)
31 {
32  func_t transitionToStep1 = boost::bind(&NeuroTrainingWidget::onImport, this);
33  func_t transitionToStep2 = boost::bind(&NeuroTrainingWidget::onRegisterStep, this);
34  func_t transitionToStep3 = boost::bind(&NeuroTrainingWidget::onUse2DUSStep, this);
35  func_t transitionToStep4 = boost::bind(&NeuroTrainingWidget::on3DUSAcqStep, this);
36  func_t transitionToStep5 = boost::bind(&NeuroTrainingWidget::onShowAllUSStep, this);
37 
38  TrainingWidget::registrateTransition(transitionToStep1);
39  TrainingWidget::registrateTransition(transitionToStep2);
40  TrainingWidget::registrateTransition(transitionToStep3);
41  TrainingWidget::registrateTransition(transitionToStep4);
42  TrainingWidget::registrateTransition(transitionToStep5);
43 }
44 
46 {
47  this->setUSSimulatorInput(this->getFirstUSVolume());
48 // this->makeUnavailable("Kaisa");
49  this->makeUnavailable(imUS, true);
50 
51  this->changeWorkflowToImport();
52 }
53 
54 void NeuroTrainingWidget::setUSSimulatorInput(QString usUid)
55 {
56  if(usUid.isEmpty())
57  {
58  CX_LOG_DEBUG() << "NeuroTrainingWidget::setUSSimulatorInput: usUid is empty, not changing existing.";
59  return;
60  }
61  cx::StreamerService* streamerService = cx::StreamerServiceUtilities::getStreamerServiceFromType("ussimulator_streamer", mPluginContext);
62  SimulatedStreamerService* simulatorStreamerService = dynamic_cast<SimulatedStreamerService*>(streamerService);
63  if(simulatorStreamerService)
64  {
65  CX_LOG_INFO() << "Setting US simulator input to: " << usUid;
66  simulatorStreamerService->setImageToStream(usUid);
67  }
68  else
69  CX_LOG_WARNING() << "Cannot find SimulatedImageStreamerService";
70 }
71 
73 {
74  QWidget* registrationWidget = findMainWindowChildWithObjectName<QWidget*>("org_custusx_registration_gui_widget");
75  if(registrationWidget)
76  {
77  RegistrationWidget* widget = dynamic_cast<RegistrationWidget*>(registrationWidget);
78  if(widget)
79  {
80  widget->selectRegistrationMethod("ImageToPatient", "Fast");
81  }
82  }
83 }
84 
86 {
87  this->startTracking();
88 
89  this->changeWorkflowToRegistration();
90  this->setSurfaceForPointCloudRegistration("Kaisa");
92 }
93 
94 void NeuroTrainingWidget::setSurfaceForPointCloudRegistration(QString uidPart)
95 {
96  MeshPtr mesh = this->getMesh(uidPart);
97  if(mesh)
98  CX_LOG_INFO() << "Setting registration fixed data to: " << mesh->getUid();
99  mServices->registration()->setFixedData(mesh);
100 }
101 
103 {
104  this->changeWorkflowToUSAcquisition();
105 }
106 
108 {
109  this->changeWorkflowToUSAcquisition();
110 }
111 
113 {
114  this->makeAvailable(imUS, true);
115  this->changeWorkflowToNavigation();
116 }
117 
118 void NeuroTrainingWidget::startTracking()
119 {
120  mServices->tracking()->setState(Tool::tsTRACKING);;
121 }
122 
123 void NeuroTrainingWidget::changeWorkflowToImport()
124 {
125  mServices->state()->setWorkFlowState("PatientDataUid");
126 }
127 
128 void NeuroTrainingWidget::changeWorkflowToRegistration()
129 {
130  mServices->state()->setWorkFlowState("RegistrationUid");
131 }
132 
133 void NeuroTrainingWidget::changeWorkflowToUSAcquisition()
134 {
135  mServices->state()->setWorkFlowState("IntraOpImagingUid");
136 }
137 
138 void NeuroTrainingWidget::changeWorkflowToNavigation()
139 {
140  mServices->state()->setWorkFlowState("NavigationUid");
141 }
142 
143 } // cx
cxLogger.h
cx::TrainingWidget
Definition: cxTrainingWidget.h:39
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::TrainingWidget::getMesh
MeshPtr getMesh(QString uidPart)
Definition: cxTrainingWidget.cpp:191
cx::TrainingWidget::registrateTransition
void registrateTransition(func_t transition)
Definition: cxTrainingWidget.cpp:71
cx::TrainingWidget::getFirstUSVolume
QString getFirstUSVolume()
Definition: cxTrainingWidget.cpp:175
CX_LOG_INFO
#define CX_LOG_INFO
Definition: cxLogger.h:96
cx::NeuroTrainingWidget::onRegisterStep
void onRegisterStep()
Definition: cxNeuroTrainingWidget.cpp:85
cx::NeuroTrainingWidget::on3DUSAcqStep
void on3DUSAcqStep()
Definition: cxNeuroTrainingWidget.cpp:107
cx::TrainingWidget::makeUnavailable
void makeUnavailable(IMAGE_MODALITY modality, bool makeModalityUnavailable=false)
Definition: cxTrainingWidget.cpp:204
cx::NeuroTrainingWidget::changeImageToPatientRegistrationToFast
void changeImageToPatientRegistrationToFast()
Definition: cxNeuroTrainingWidget.cpp:72
cx::TrainingWidget::mServices
RegServicesPtr mServices
Definition: cxTrainingWidget.h:57
cx::NeuroTrainingWidget::onShowAllUSStep
void onShowAllUSStep()
Definition: cxNeuroTrainingWidget.cpp:112
imUS
imUS
Definition: cxDefinitions.h:154
cx::MeshPtr
boost::shared_ptr< class Mesh > MeshPtr
Definition: cxForwardDeclarations.h:48
cx::NeuroTrainingWidget::NeuroTrainingWidget
NeuroTrainingWidget(RegServicesPtr services, ctkPluginContext *context, QWidget *parent=NULL)
Definition: cxNeuroTrainingWidget.cpp:28
cxStreamerServiceUtilities.h
cxSettings.h
cx::RegistrationWidget
Definition: cxRegistrationWidget.h:71
cx::StreamerServiceUtilities::getStreamerServiceFromType
static StreamerService * getStreamerServiceFromType(QString name, ctkPluginContext *context)
Definition: cxStreamerServiceUtilities.cpp:21
cx::RegistrationWidget::selectRegistrationMethod
void selectRegistrationMethod(QString registrationType, QString registrationMethodName)
Definition: cxRegistrationWidget.cpp:125
cx::RegServicesPtr
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:20
cx::NeuroTrainingWidget::onImport
void onImport()
Definition: cxNeuroTrainingWidget.cpp:45
cxStateService.h
cx::TrainingWidget::func_t
boost::function< void(void)> func_t
Definition: cxTrainingWidget.h:50
cxNeuroTrainingWidget.h
cx::TrainingWidget::makeAvailable
void makeAvailable(IMAGE_MODALITY modality, bool makeModalityUnavailable)
Definition: cxTrainingWidget.cpp:211
CX_LOG_DEBUG
#define CX_LOG_DEBUG
Definition: cxLogger.h:95
cxRegistrationService.h
CX_LOG_WARNING
#define CX_LOG_WARNING
Definition: cxLogger.h:98
cxRegistrationWidget.h
cxRegServices.h
cxApplication.h
cx::Tool::tsTRACKING
@ tsTRACKING
emitting tracking data
Definition: cxTool.h:77
cxMesh.h
cxTrackingService.h
cx::StreamerService
Abstract class. Interface to Streamers.
Definition: cxStreamerService.h:42
cx::NeuroTrainingWidget::onUse2DUSStep
void onUse2DUSStep()
Definition: cxNeuroTrainingWidget.cpp:102