12 #include <QApplication> 13 #include <QDesktopWidget> 16 #include "ctkServiceTracker.h" 17 #include "ctkDICOMBrowser.h" 18 #include "ctkDICOMAppWidget.h" 20 #include "ctkDICOMTableManager.h" 21 #include "ctkDICOMObjectListWidget.h" 22 #include "ctkPluginContext.h" 26 #include "cxDicomConverter.h" 30 #include "cxDicomImageReader.h" 40 mVerticalLayout(new QVBoxLayout(this)),
43 mDicomShowAdvancedSettingsString(
"Dicom/ShowAdvanced")
51 this->deleteDICOMDB();
62 void DicomWidget::createUI()
67 this->setToolTip(
"Import DICOM data");
70 QIcon(
":/icons/open_icon_library/eye.png.png"),
71 "View info",
"View the header info for the first selected series",
72 SLOT(onViewHeader()));
75 QIcon(
":/icons/open_icon_library/arrow-right-3.png"),
76 "Import selected",
"Import the selected DICOM series into the application as a volume",
77 SLOT(onImportIntoCustusXAction()));
80 QIcon(
":/icons/open_icon_library/system-run-5.png"),
81 "Advanced",
"Toggle advanced options",
82 SLOT(toggleDetailsSlot()));
88 this->showOrHideDetails();
90 mVerticalLayout->setMargin(0);
91 mVerticalLayout->addWidget(mBrowser);
93 this->setupDatabaseDirectory();
96 void DicomWidget::toggleDetailsSlot()
98 bool newShowAdvancedValue = !
settings()->
value(mDicomShowAdvancedSettingsString,
"true").toBool();
99 settings()->
setValue(mDicomShowAdvancedSettingsString, newShowAdvancedValue);
100 this->showOrHideDetails();
103 void DicomWidget::showOrHideDetails()
105 bool showAdvanced =
settings()->
value(mDicomShowAdvancedSettingsString).toBool();
107 mViewHeaderAction->setVisible(showAdvanced);
110 action->setVisible(showAdvanced);
117 QString databaseDirectory =
profile()->getSettingsPath() +
"/DICOMDatabase";
119 return databaseDirectory;
122 void DicomWidget::setupDatabaseDirectory()
126 QDir qdir(databaseDirectory);
127 if ( !qdir.exists(databaseDirectory) )
129 if ( !qdir.mkpath(databaseDirectory) )
139 QStringList DicomWidget::currentSeriesSelection()
144 void DicomWidget::onViewHeader()
146 QStringList series = this->currentSeriesSelection();
147 std::cout << series.join(
"\n").toStdString() << std::endl;
150 for (
int i=0; i<series.size(); ++i)
152 QStringList current = this->
getDatabase()->filesForSeries(series[i]);
153 files.append(current);
157 ctkDICOMObjectListWidget* window =
new ctkDICOMObjectListWidget;
158 window->setWindowTitle(
"DICOM File Header");
159 window->setFileList(files);
161 QWidget* screen = qApp->desktop()->screen(qApp->desktop()->screenNumber(
this));
162 QRect rect = screen->geometry();
163 rect.setWidth(rect.width()*0.66);
164 window->setGeometry(rect);
169 void DicomWidget::onImportIntoCustusXAction()
171 QStringList series = this->currentSeriesSelection();
176 for (
unsigned i=0; i<series.size(); ++i)
178 this->importSeries(series[i]);
182 void DicomWidget::deleteDICOMDB()
185 bool autoDeleteDICOMDB =
settings()->
value(
"Automation/autoDeleteDICOMDatabase").toBool();
186 if(autoDeleteDICOMDB)
191 QStringList patients = database->patients();
192 foreach(QString patient , patients)
200 void DicomWidget::importSeries(QString seriesUid)
208 reportError(QString(
"Failed to convert DICOM series %1").arg(seriesUid));
212 this->loadIntoPatientModel(convertedImage, seriesUid);
215 void DicomWidget::loadIntoPatientModel(
ImagePtr image, QString seriesUid)
219 if (!services->patient()->isNull())
221 services->patient()->insertData(image);
222 services->view()->autoShowData(image);
223 report(QString(
"Loaded DICOM series %1 as %2").arg(seriesUid).arg(image->getName()));
227 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
void setValue(const QString &key, const QVariant &value)
ImagePtr convertToImage(QString seriesUid)
void reportWarning(QString msg)
Settings * settings()
Shortcut for accessing the settings instance.
#define CX_LOG_CHANNEL_ERROR(channel)
Namespace for all CustusX production code.