Fraxinus  17.12-rc4
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #include "cxNeuroTrainingWidget.h"
34 #include <boost/bind.hpp>
35 #include "cxApplication.h"
36 #include "cxSettings.h"
37 #include "cxLogger.h"
38 #include "cxStateService.h"
39 #include "cxRegistrationWidget.h"
41 #include "cxRegistrationService.h"
42 #include "cxMesh.h"
43 #include "cxRegServices.h"
44 #include "cxTrackingService.h"
45 
46 namespace cx
47 {
48 
49 NeuroTrainingWidget::NeuroTrainingWidget(RegServicesPtr services, ctkPluginContext* context, QWidget *parent) :
50  TrainingWidget(services, "NeuroSimulatorWidget", "Neuro Simulator", parent),
51  mPluginContext(context)
52 {
53  func_t transitionToStep1 = boost::bind(&NeuroTrainingWidget::onImport, this);
54  func_t transitionToStep2 = boost::bind(&NeuroTrainingWidget::onRegisterStep, this);
55  func_t transitionToStep3 = boost::bind(&NeuroTrainingWidget::onUse2DUSStep, this);
56  func_t transitionToStep4 = boost::bind(&NeuroTrainingWidget::on3DUSAcqStep, this);
57  func_t transitionToStep5 = boost::bind(&NeuroTrainingWidget::onShowAllUSStep, this);
58 
59  TrainingWidget::registrateTransition(transitionToStep1);
60  TrainingWidget::registrateTransition(transitionToStep2);
61  TrainingWidget::registrateTransition(transitionToStep3);
62  TrainingWidget::registrateTransition(transitionToStep4);
63  TrainingWidget::registrateTransition(transitionToStep5);
64 }
65 
67 {
68  this->setUSSimulatorInput(this->getFirstUSVolume());
69 // this->makeUnavailable("Kaisa");
70  this->makeUnavailable("US", true);
71 
72  this->changeWorkflowToImport();
73 }
74 
75 void NeuroTrainingWidget::setUSSimulatorInput(QString usUid)
76 {
77  if(usUid.isEmpty())
78  {
79  CX_LOG_DEBUG() << "NeuroTrainingWidget::setUSSimulatorInput: usUid is empty, not changing existing.";
80  return;
81  }
82  cx::StreamerService* streamerService = cx::StreamerServiceUtilities::getStreamerServiceFromType("ussimulator_streamer", mPluginContext);
83  SimulatedStreamerService* simulatorStreamerService = dynamic_cast<SimulatedStreamerService*>(streamerService);
84  if(simulatorStreamerService)
85  {
86  CX_LOG_INFO() << "Setting US simulator input to: " << usUid;
87  simulatorStreamerService->setImageToStream(usUid);
88  }
89  else
90  CX_LOG_WARNING() << "Cannot find SimulatedImageStreamerService";
91 }
92 
94 {
95  QWidget* registrationWidget = findMainWindowChildWithObjectName<QWidget*>("org_custusx_registration_gui_widget");
96  if(registrationWidget)
97  {
98  RegistrationWidget* widget = dynamic_cast<RegistrationWidget*>(registrationWidget);
99  if(widget)
100  {
101  widget->selectRegistrationMethod("ImageToPatient", "Fast");
102  }
103  }
104 }
105 
107 {
108  this->startTracking();
109 
110  this->changeWorkflowToRegistration();
111  this->setSurfaceForPointCloudRegistration("Kaisa");
113 }
114 
115 void NeuroTrainingWidget::setSurfaceForPointCloudRegistration(QString uidPart)
116 {
117  MeshPtr mesh = this->getMesh(uidPart);
118  if(mesh)
119  CX_LOG_INFO() << "Setting registration fixed data to: " << mesh->getUid();
120  mServices->registration()->setFixedData(mesh);
121 }
122 
124 {
125  this->changeWorkflowToUSAcquisition();
126 }
127 
129 {
130  this->changeWorkflowToUSAcquisition();
131 }
132 
134 {
135  this->makeAvailable("US", true);
136  this->changeWorkflowToNavigation();
137 }
138 
139 void NeuroTrainingWidget::startTracking()
140 {
141  mServices->tracking()->setState(Tool::tsTRACKING);;
142 }
143 
144 void NeuroTrainingWidget::changeWorkflowToImport()
145 {
146  mServices->state()->setWorkFlowState("PatientDataUid");
147 }
148 
149 void NeuroTrainingWidget::changeWorkflowToRegistration()
150 {
151  mServices->state()->setWorkFlowState("RegistrationUid");
152 }
153 
154 void NeuroTrainingWidget::changeWorkflowToUSAcquisition()
155 {
156  mServices->state()->setWorkFlowState("IntraOpImagingUid");
157 }
158 
159 void NeuroTrainingWidget::changeWorkflowToNavigation()
160 {
161  mServices->state()->setWorkFlowState("NavigationUid");
162 }
163 
164 } // 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:117
void registrateTransition(func_t transition)
void makeAvailable(QString uidPart, bool makeModalityUnavailable)
MeshPtr getMesh(QString uidPart)
virtual void setImageToStream(QString imageUid)=0
boost::shared_ptr< class RegServices > RegServicesPtr
Definition: cxRegServices.h:41
RegServicesPtr mServices
#define CX_LOG_DEBUG
Definition: cxLogger.h:116
#define CX_LOG_WARNING
Definition: cxLogger.h:119
void makeUnavailable(QString uidPart, bool makeModalityUnavailable=false)
boost::function< void(void)> func_t
emitting tracking data
Definition: cxTool.h:98
Abstract class. Interface to Streamers.
boost::shared_ptr< class Mesh > MeshPtr
static StreamerService * getStreamerServiceFromType(QString name, ctkPluginContext *context)
Namespace for all CustusX production code.