35 #include <QDomDocument>
39 #include <QTextStream>
40 #include <QApplication>
50 #include <vtkPolyData.h>
51 #include <vtkPointData.h>
66 mDataManager(dataManager),
81 return mSession->getRootFolder();
86 return mSession->isValid();
89 void PatientData::onCleared()
91 mDataManager->clear();
94 void PatientData::onSessionLoad(QDomElement &node)
96 XMLNodeParser root(node);
97 QDomElement dataManagerNode = root.descend(
"managers/datamanager").node().toElement();
99 if (!dataManagerNode.isNull())
100 mDataManager->parseXml(dataManagerNode, mSession->getRootFolder());
103 void PatientData::onSessionSave(QDomElement &node)
105 XMLNodeAdder root(node);
106 QDomElement managerNode = root.descend(
"managers").node().toElement();
108 mDataManager->addXml(managerNode);
113 for (DataManager::ImagesMap::iterator iter = images.begin(); iter != images.end(); ++iter)
116 mSession->getRootFolder() +
"/" + iter->second->getFilename());
117 customReader->setTransform(iter->second->get_rMd());
124 if (
settings()->value(
"Automation/autoSave").toBool())
130 QString targetFolder = mSession->getRootFolder() +
"/Export/"
134 for (DataManager::ImagesMap::iterator iter = images.begin(); iter != images.end(); ++iter)
136 iter->second->save(targetFolder);
140 for (DataManager::MeshMap::iterator iter = meshes.begin(); iter != meshes.end(); ++iter)
148 report(
"Nifti export: rotated data " + mesh->getName() +
" 180* around Z-axis.");
153 mesh = mDataManager->getDataFactory()->createSpecific<
Mesh>(mesh->getUid(), mesh->getName());
155 mesh->setFilename(
"Images");
156 mesh->save(targetFolder);
159 report(
"Exported patient data to " + targetFolder +
".");
164 if (fileName.isEmpty())
166 QString text =
"Import canceled";
168 infoText =
"<font color=red>" + text +
"</font>";
172 QFileInfo fileInfo(fileName);
176 if (mDataManager->getData(uid))
178 QString text =
"Data with uid " + uid +
" already exists. Import canceled.";
180 infoText =
"<font color=red>" + text +
"</font>";
185 DataPtr data = mDataManager->loadData(uid, fileName);
188 QString text =
"Error with data file: " + fileName +
" Import canceled.";
190 infoText =
"<font color=red>" + text +
"</font>";
193 data->setAcquisitionTime(QDateTime::currentDateTime());
195 data->save(mSession->getRootFolder());
198 infoText = infoText.split(
"<br>", QString::SkipEmptyParts).join(
"<br>");
QString getActivePatientFolder() const
void isLoading(QDomElement &root)
emitted while loading a session. Xml storage is available, getRootFolder() is set to loaded value...
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
std::map< QString, MeshPtr > MeshMap
QString timestampSecondsFormat()
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
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
void reportWarning(QString msg)
void setVtkPolyData(const vtkPolyDataPtr &polyData)
void exportPatient(bool niftiFormat)
std::map< QString, ImagePtr > ImagesMap
Settings * settings()
Shortcut for accessing the settings instance.
void cleared()
emitted when session is cleared, before isLoading is called
QString changeExtension(QString name, QString ext)
void removeData(QString uid)
PatientData(DataServicePtr dataManager, SessionStorageServicePtr session)
Transform3D createTransformRotateZ(const double angle)
bool isPatientValid() const
boost::shared_ptr< class Mesh > MeshPtr
void isSaving(QDomElement &root)
xml storage is available
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr