14 #include <ctkPluginContext.h>
15 #include <vtkImageData.h>
40 this->createInterconnectedDataAndSpace();
55 mUnavailableData.clear();
58 void PatientModelImplService::createInterconnectedDataAndSpace()
70 mActiveData.reset(
new ActiveData(patientModelService, session));
74 mDataService->setServices(spaceProvider, mFileManagerService);
76 mDataFactory.reset(
new DataFactory(patientModelService, spaceProvider));
77 mDataService->setDataFactory(mDataFactory);
79 mPatientData.reset(
new PatientData(mDataService, session, mFileManagerService));
82 void PatientModelImplService::shutdownInterconnectedDataAndSpace()
90 mDataService->clear();
111 this->shutdownInterconnectedDataAndSpace();
116 QString outputBasePath = this->patientData()->getActivePatientFolder();
118 this->dataService()->loadData(data, overWrite);
119 data->save(outputBasePath, mFileManagerService);
124 return dataService()->getDataFactory()->create(type, uid, name);
129 std::map<QString, DataPtr> retval = dataService()->getData();
133 for(
int i = 0; i < mUnavailableData.size(); ++i)
135 if (retval.count(mUnavailableData[i]))
136 retval.erase(mUnavailableData[i]);
146 std::map<QString, DataPtr>::const_iterator iter = dataMap.find(uid);
147 if (iter == dataMap.end())
154 std::map<QString, DataPtr> retval;
156 std::map<QString, DataPtr>::const_iterator iter = dataMap.begin();
157 for ( ; iter != dataMap.end(); ++iter)
159 if((iter->second->getParentSpace() == parent_uid))
160 if((of_type ==
"") || (iter->second->getType() == of_type))
161 retval[iter->first] = iter->second;
169 return dataService()->getPatientLandmarks();
174 return dataService()->getLandmarkProperties();
179 dataService()->setLandmarkName(uid, name);
184 return dataService()->get_rMpr();
189 this->patientData()->autoSave();
200 mUnavailableData.push_back(uid);
203 std::vector<QString>::iterator iter = std::find(mUnavailableData.begin(), mUnavailableData.end(), uid);
204 if(iter != mUnavailableData.end())
205 mUnavailableData.erase(iter);
211 return dataService()->getClinicalApplication();
216 dataService()->setClinicalApplication(application);
221 return dataService()->getStreams();
226 return this->patientData()->getActivePatientFolder();
231 return this->patientData()->isPatientValid();
236 return this->patientData()->importData(fileName, infoText);
241 this->patientData()->exportPatient(externalSpace);
246 this->patientData()->removeData(uid);
251 return dataService()->getPresetTransferFunctions3D();
256 this->dataService()->setCenter(center);
261 return this->dataService()->getCenter();
266 this->dataService()->setOperatingTable(ot);
271 return this->dataService()->getOperatingTable();
276 return dataService()->addLandmark();
281 return dataService()->deleteLandmarks();
286 dataService()->setLandmarkActive(uid, active);
291 return this->dataService()->get_rMpr_History();
309 void PatientModelImplService::probesChanged()
311 this->disconnectProbes();
313 this->connectProbes();
316 void PatientModelImplService::disconnectProbes()
318 for (std::map<QString, ToolPtr>::const_iterator iter = mProbeTools.begin(); iter != mProbeTools.end(); ++iter)
320 ProbePtr probe = iter->second->getProbe();
324 CX_LOG_WARNING() <<
"PatientModelImplService::disconnectProbes: Tool is not a probe: " << iter->second->getUid();
328 void PatientModelImplService::connectProbes()
330 ToolMap tools = mTrackingService->getTools();
331 for (ToolMap::const_iterator iter = tools.begin(); iter != tools.end(); ++iter)
337 mProbeTools[iter->first] = tool;
343 void PatientModelImplService::videoSourceAdded(
VideoSourcePtr source)
345 ToolPtr tool = this->getProbeTool(source->getUid());
349 QString uid = source->getUid() + tool->getUid();
350 QString name = source->getName() +
" - " + tool->getName();
351 TrackedStreamPtr trackedStream = this->dataService()->getTrackedStream(uid);
353 trackedStream = this->createSpecificData<TrackedStream>(uid, name);
354 trackedStream->setProbeTool(tool);
355 trackedStream->setVideoSource(source);
356 trackedStream->setSpaceProvider(mDataService->getSpaceProvider());
359 this->dataService()->loadData(trackedStream);
361 this->reEmitActiveTrackedStream(trackedStream);
364 void PatientModelImplService::reEmitActiveTrackedStream(
TrackedStreamPtr trackedStream)
366 if(mActiveData->getActive<TrackedStream>() == trackedStream)
367 mActiveData->setActive(trackedStream);
370 ToolPtr PatientModelImplService::getProbeTool(QString videoSourceUid)
372 for (std::map<QString, ToolPtr>::const_iterator iter = mProbeTools.begin(); iter != mProbeTools.end(); ++iter)
376 if(probe && probe->getAvailableVideoSources().contains(videoSourceUid))