33 #include <QApplication>
34 #include <QDesktopWidget>
37 #include "ctkServiceTracker.h"
38 #include "ctkDICOMBrowser.h"
39 #include "ctkDICOMAppWidget.h"
41 #include "ctkDICOMTableManager.h"
42 #include "ctkDICOMObjectListWidget.h"
43 #include "ctkPluginContext.h"
61 mVerticalLayout(new QVBoxLayout(this)),
71 this->deleteDICOMDB();
82 void DicomWidget::createUI()
87 this->setToolTip(
"Import DICOM data");
91 "View",
"View header info for first selected series",
92 SLOT(onViewHeader()));
95 "Import",
"Import selected series into application",
96 SLOT(onImportIntoCustusXAction()));
102 mVerticalLayout->setMargin(0);
103 mVerticalLayout->addWidget(mBrowser);
105 this->setupDatabaseDirectory();
110 QString databaseDirectory =
profile()->getSettingsPath() +
"/DICOMDatabase";
112 return databaseDirectory;
115 void DicomWidget::setupDatabaseDirectory()
119 QDir qdir(databaseDirectory);
120 if ( !qdir.exists(databaseDirectory) )
122 if ( !qdir.mkpath(databaseDirectory) )
132 QStringList DicomWidget::currentSeriesSelection()
137 void DicomWidget::onViewHeader()
139 QStringList series = this->currentSeriesSelection();
140 std::cout << series.join(
"\n").toStdString() << std::endl;
143 for (
int i=0; i<series.size(); ++i)
145 QStringList current = this->
getDatabase()->filesForSeries(series[i]);
146 files.append(current);
150 ctkDICOMObjectListWidget* window =
new ctkDICOMObjectListWidget;
151 window->setWindowTitle(
"DICOM File Header");
152 window->setFileList(files);
154 QWidget* screen = qApp->desktop()->screen(qApp->desktop()->screenNumber(
this));
155 QRect rect = screen->geometry();
156 rect.setWidth(rect.width()*0.66);
157 window->setGeometry(rect);
162 void DicomWidget::onImportIntoCustusXAction()
164 QStringList series = this->currentSeriesSelection();
169 for (
unsigned i=0; i<series.size(); ++i)
171 this->importSeries(series[i]);
175 void DicomWidget::deleteDICOMDB()
178 bool autoDeleteDICOMDB =
settings()->
value(
"Automation/autoDeleteDICOMDatabase").toBool();
179 if(autoDeleteDICOMDB)
184 QStringList patients = database->patients();
185 foreach(QString patient , patients)
193 void DicomWidget::importSeries(QString seriesUid)
201 reportError(QString(
"Failed to convert DICOM series %1").arg(seriesUid));
205 this->loadIntoPatientModel(convertedImage, seriesUid);
208 void DicomWidget::loadIntoPatientModel(
ImagePtr image, QString seriesUid)
212 if (!services->patient()->isNull())
214 services->patient()->insertData(image);
215 services->view()->autoShowData(image);
216 report(QString(
"Loaded DICOM series %1 as %2").arg(seriesUid).arg(image->getName()));
220 reportWarning(QString(
"Failed to load DICOM series %1 as %2: no PatientModelService.").arg(seriesUid).arg(image->getName()));
#define CX_LOG_CHANNEL_INFO(channel)
cxResource_EXPORT ProfilePtr profile()
void reportError(QString msg)
boost::shared_ptr< class VisServices > VisServicesPtr
boost::shared_ptr< class Image > ImagePtr
void setDicomDatabase(ctkDICOMDatabase *database)
static VisServicesPtr create(ctkPluginContext *context)
#define CX_LOG_CHANNEL_WARNING(channel)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
ImagePtr convertToImage(QString seriesUid)
void reportWarning(QString msg)
Settings * settings()
Shortcut for accessing the settings instance.
#define CX_LOG_CHANNEL_ERROR(channel)