35 #include <ctkPluginContext.h> 36 #include <vtkImageData.h> 60 this->createInterconnectedDataAndSpace();
75 mUnavailableData.clear();
78 void PatientModelImplService::createInterconnectedDataAndSpace()
89 mActiveData.reset(
new ActiveData(patientModelService, session));
93 mDataService->setSpaceProvider(spaceProvider);
95 mDataFactory.reset(
new DataFactory(patientModelService, spaceProvider));
96 mDataService->setDataFactory(mDataFactory);
98 mPatientData.reset(
new PatientData(mDataService, session));
101 void PatientModelImplService::shutdownInterconnectedDataAndSpace()
104 mPatientData.reset();
109 mDataService->clear();
112 mDataFactory.reset();
115 mDataService.reset();
130 this->shutdownInterconnectedDataAndSpace();
135 QString outputBasePath = this->patientData()->getActivePatientFolder();
137 this->dataService()->loadData(data);
138 data->save(outputBasePath);
143 return dataService()->getDataFactory()->create(type, uid, name);
148 std::map<QString, DataPtr> retval = dataService()->getData();
152 for(
int i = 0; i < mUnavailableData.size(); ++i)
154 if (retval.count(mUnavailableData[i]))
155 retval.erase(mUnavailableData[i]);
165 std::map<QString, DataPtr>::const_iterator iter = dataMap.find(uid);
166 if (iter == dataMap.end())
173 std::map<QString, DataPtr> retval;
175 std::map<QString, DataPtr>::const_iterator iter = dataMap.begin();
176 for ( ; iter != dataMap.end(); ++iter)
178 if((iter->second->getParentSpace() == parent_uid))
179 if((of_type ==
"") || (iter->second->getType() == of_type))
180 retval[iter->first] = iter->second;
188 return dataService()->getPatientLandmarks();
193 return dataService()->getLandmarkProperties();
198 dataService()->setLandmarkName(uid, name);
203 return dataService()->get_rMpr();
208 this->patientData()->autoSave();
219 mUnavailableData.push_back(uid);
222 std::vector<QString>::iterator iter = std::find(mUnavailableData.begin(), mUnavailableData.end(), uid);
223 if(iter != mUnavailableData.end())
224 mUnavailableData.erase(iter);
230 return dataService()->getClinicalApplication();
235 dataService()->setClinicalApplication(application);
240 return dataService()->getStreams();
245 return this->patientData()->getActivePatientFolder();
250 return this->patientData()->isPatientValid();
255 return this->patientData()->importData(fileName, infoText);
260 this->patientData()->exportPatient(externalSpace);
265 this->patientData()->removeData(uid);
270 return dataService()->getPresetTransferFunctions3D();
275 this->dataService()->setCenter(center);
280 return this->dataService()->getCenter();
285 this->dataService()->setOperatingTable(ot);
290 return this->dataService()->getOperatingTable();
295 return dataService()->addLandmark();
300 return dataService()->deleteLandmarks();
305 dataService()->setLandmarkActive(uid, active);
310 return this->dataService()->get_rMpr_History();
328 void PatientModelImplService::probesChanged()
330 this->disconnectProbes();
332 this->connectProbes();
335 void PatientModelImplService::disconnectProbes()
337 for (std::map<QString, ToolPtr>::const_iterator iter = mProbeTools.begin(); iter != mProbeTools.end(); ++iter)
339 ProbePtr probe = iter->second->getProbe();
343 CX_LOG_WARNING() <<
"PatientModelImplService::disconnectProbes: Tool is not a probe: " << iter->second->getUid();
347 void PatientModelImplService::connectProbes()
349 ToolMap tools = mTrackingService->getTools();
350 for (ToolMap::const_iterator iter = tools.begin(); iter != tools.end(); ++iter)
356 mProbeTools[iter->first] = tool;
362 void PatientModelImplService::videoSourceAdded(
VideoSourcePtr source)
364 ToolPtr tool = this->getProbeTool(source->getUid());
368 QString uid = source->getUid() + tool->getUid();
369 QString name = source->getName() +
" - " + tool->getName();
370 TrackedStreamPtr trackedStream = this->dataService()->getTrackedStream(uid);
372 trackedStream = this->createSpecificData<TrackedStream>(uid, name);
373 trackedStream->setProbeTool(tool);
374 trackedStream->setVideoSource(source);
375 trackedStream->setSpaceProvider(mDataService->getSpaceProvider());
378 this->dataService()->loadData(trackedStream);
380 this->reEmitActiveTrackedStream(trackedStream);
383 void PatientModelImplService::reEmitActiveTrackedStream(
TrackedStreamPtr trackedStream)
386 mActiveData->setActive(trackedStream);
389 ToolPtr PatientModelImplService::getProbeTool(QString videoSourceUid)
391 for (std::map<QString, ToolPtr>::const_iterator iter = mProbeTools.begin(); iter != mProbeTools.end(); ++iter)
395 if(probe && probe->getAvailableVideoSources().contains(videoSourceUid))
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
void rMprChanged()
emitted when the transformation between patient reference and (data) reference is set ...
virtual void setCenter(const Vector3D ¢er)
boost::shared_ptr< class RegistrationHistory > RegistrationHistoryPtr
OperatingTable getOperatingTable() const
virtual PresetTransferFunctions3DPtr getPresetTransferFunctions3D() const
void operatingTableChanged()
void dataAddedOrRemoved()
virtual bool isPatientValid() const
void landmarkPropertiesChanged()
emitted when global info about a landmark changed
boost::shared_ptr< class TrackedStream > TrackedStreamPtr
virtual Transform3D get_rMpr() const
get the patient registration transform
Provides the last active data of warious types.
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
virtual DataPtr importData(QString fileName, QString &infoText)
boost::shared_ptr< class TransferFunctions3DPresets > PresetTransferFunctions3DPtr
virtual DataPtr createData(QString type, QString uid, QString name)
virtual void deleteLandmarks()
Functionality for storing patient data in a folder on the disk and access to these data...
static SessionStorageServicePtr create(ctkPluginContext *pluginContext)
boost::shared_ptr< class ActiveData > ActiveDataPtr
void landmarkPropertiesChanged()
emitted when global info about a landmark changed
virtual ActiveDataPtr getActiveData() const
void centerChanged()
emitted when center is changed.
static VideoServicePtr create(ctkPluginContext *pluginContext)
A data set for video streams (2D/3D).
void centerChanged()
emitted when center is changed.
boost::shared_ptr< class DataManager > DataServicePtr
boost::shared_ptr< class Landmarks > LandmarksPtr
virtual void makeAvailable(const QString &uid, bool available)
Exclude this data from getDatas()
virtual void insertData(DataPtr data)
static TrackingServicePtr create(ctkPluginContext *pluginContext)
void setOperatingTable(const OperatingTable &ot)
boost::shared_ptr< Probe > ProbePtr
static PatientModelServicePtr create(ctkPluginContext *pluginContext)
boost::shared_ptr< class Data > DataPtr
void videoSourceAdded(VideoSourcePtr source)
static DataManagerImplPtr create(ActiveDataPtr activeData)
virtual void removeData(QString uid)
virtual std::map< QString, DataPtr > getChildren(QString parent_uid, QString of_type="") const
void reportWarning(QString msg)
void dataAddedOrRemoved()
std::map< QString, ToolPtr > ToolMap
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class VideoSource > VideoSourcePtr
virtual QString addLandmark()
void clinicalApplicationChanged()
void videoAddedToTrackedStream()
virtual Vector3D getCenter() const
current common center point for user viewing.
virtual QString getActivePatientFolder() const
virtual LandmarksPtr getPatientLandmarks() const
landmark defined in patient space
void operatingTableChanged()
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
virtual CLINICAL_VIEW getClinicalApplication() const
virtual void setLandmarkActive(QString uid, bool active)
virtual std::map< QString, VideoSourcePtr > getStreams() const
virtual void exportPatient(PATIENT_COORDINATE_SYSTEM externalSpace)
boost::shared_ptr< PatientData > PatientDataPtr
virtual ~PatientModelImplService()
virtual std::map< QString, DataPtr > getDatas(DataFilter filter) const
PatientModelImplService(ctkPluginContext *context)
virtual RegistrationHistoryPtr get_rMpr_History() const
The OperatingTable class.
boost::shared_ptr< class DataFactory > DataFactoryPtr
virtual std::map< QString, LandmarkProperty > getLandmarkProperties() const
virtual void setLandmarkName(QString uid, QString name)
void requireUnique(int use_count, QString objectName)
void clinicalApplicationChanged()
virtual void setClinicalApplication(CLINICAL_VIEW application)
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
virtual DataPtr getData(const QString &uid) const
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr