14 #include <QDomDocument> 18 #include <QTextStream> 19 #include <QApplication> 29 #include <vtkPolyData.h> 30 #include <vtkPointData.h> 45 mDataManager(dataManager),
47 mFileManagerService(fileManager)
61 return mSession->getRootFolder();
66 return mSession->isValid();
69 void PatientData::onCleared()
71 mDataManager->clear();
74 void PatientData::onSessionLoad(QDomElement &node)
77 QDomElement dataManagerNode = root.
descend(
"managers/datamanager").
node().toElement();
79 if (!dataManagerNode.isNull())
80 mDataManager->parseXml(dataManagerNode, mSession->getRootFolder());
83 void PatientData::onSessionSave(QDomElement &node)
86 QDomElement managerNode = root.
descend(
"managers").
node().toElement();
88 mDataManager->addXml(managerNode);
93 for (DataManager::ImagesMap::iterator iter = images.begin(); iter != images.end(); ++iter)
95 if(!iter->second->getFilename().isEmpty())
98 customReader->setTransform(iter->second->get_rMd());
106 if (
settings()->value(
"Automation/autoSave").toBool())
112 QString targetFolder = mSession->getRootFolder() +
"/Export/" 116 for (DataManager::ImagesMap::iterator iter = images.begin(); iter != images.end(); ++iter)
118 iter->second->save(targetFolder, mFileManagerService);
122 for (DataManager::MeshMap::iterator iter = meshes.begin(); iter != meshes.end(); ++iter)
132 mesh = mDataManager->getDataFactory()->createSpecific<
Mesh>(mesh->getUid(), mesh->getName());
134 mesh->setFilename(
"Images");
135 mesh->save(targetFolder, mFileManagerService);
138 report(
"Exported patient data to " + targetFolder +
".");
143 if (fileName.isEmpty())
145 QString text =
"Import canceled";
147 infoText =
"<font color=red>" + text +
"</font>";
151 QFileInfo fileInfo(fileName);
155 if (mDataManager->getData(uid))
157 QString text =
"Data with uid " + uid +
" already exists. Import canceled.";
159 infoText =
"<font color=red>" + text +
"</font>";
164 DataPtr data = mDataManager->loadData(uid, fileName);
167 QString text =
"Error with data file: " + fileName +
" Import canceled.";
169 infoText =
"<font color=red>" + text +
"</font>";
172 data->setAcquisitionTime(QDateTime::currentDateTime());
173 data->save(mSession->getRootFolder(), mFileManagerService);
176 infoText = infoText.split(
"<br>", QString::SkipEmptyParts).join(
"<br>");
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
QString getActivePatientFolder() const
void isLoading(QDomElement &root)
emitted while loading a session. Xml storage is available, getRootFolder() is set to loaded value...
XMLNodeAdder descend(QString path)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
cxResource_EXPORT Transform3D createTransformFromReferenceToExternal(PATIENT_COORDINATE_SYSTEM external)
void exportPatient(PATIENT_COORDINATE_SYSTEM externalSpace)
std::map< QString, MeshPtr > MeshMap
QString timestampSecondsFormat()
DataPtr importData(QString fileName, QString &infoText)
Import data into CustusX.
boost::shared_ptr< class DataManager > DataServicePtr
void sessionChanged()
emitted after change to a new session (new or loaded or cleared)
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class CustomMetaImage > CustomMetaImagePtr
PatientData(DataServicePtr dataManager, SessionStorageServicePtr session, FileManagerServicePtr fileManager)
void reportWarning(QString msg)
void setVtkPolyData(const vtkPolyDataPtr &polyData)
std::map< QString, ImagePtr > ImagesMap
XMLNodeParser descend(QString path)
Settings * settings()
Shortcut for accessing the settings instance.
void cleared()
emitted when session is cleared, before isLoading is called
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
QString changeExtension(QString name, QString ext)
void removeData(QString uid)
bool isPatientValid() const
boost::shared_ptr< class Mesh > MeshPtr
void isSaving(QDomElement &root)
xml storage is available
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
Namespace for all CustusX production code.