Fraxinus  2023.01.05-dev+develop.0da12
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
Abstract class. Interface to Simulated Streamers.
NeuroTrainingWidget(RegServicesPtr services, ctkPluginContext *context, QWidget *parent=NULL)
void selectRegistrationMethod(QString registrationType, QString registrationMethodName)
#define CX_LOG_INFO
Definition: cxLogger.h:96
void registrateTransition(func_t transition)
void makeAvailable(IMAGE_MODALITY modality, bool makeModalityUnavailable)
MeshPtr getMesh(QString uidPart)
virtual void setImageToStream(QString imageUid)=0
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:20
RegServicesPtr mServices
void makeUnavailable(IMAGE_MODALITY modality, bool makeModalityUnavailable=false)
#define CX_LOG_DEBUG
Definition: cxLogger.h:95
imUS
#define CX_LOG_WARNING
Definition: cxLogger.h:98
boost::function< void(void)> func_t
emitting tracking data
Definition: cxTool.h:77
Abstract class. Interface to Streamers.
boost::shared_ptr< class Mesh > MeshPtr
static StreamerService * getStreamerServiceFromType(QString name, ctkPluginContext *context)
Namespace for all CustusX production code.