20 #define QT_NO_CAST_TO_ASCII 22 #include <dcmtk/dcmdata/dcdeftag.h> 23 #include <dcmtk/dcmdata/dcstack.h> 24 #include <dcmtk/dcmdata/dcitem.h> 25 #include <dcmtk/dcmdata/dcelem.h> 97 int step = ( int ) ( 100.0 / d->
series.size() );
100 for (
int s = 0; s < d->
series.size(); s++ ) {
101 QDir serieDir ( d->
outputDir + QDir::separator() + d->
series.at ( s ) );
103 if ( !serieDir.exists() )
108 bool proceed =
false;
109 bool proceedIndex =
false;
111 static const OFString Patient (
"PATIENT" );
112 static const OFString Study (
"STUDY" );
113 static const OFString Series (
"SERIES" );
114 static const OFString Image (
"IMAGE" );
119 if ( !d->
dcmObject->findAndGetElements ( DCM_Item, itemsTmp ).good() )
122 while ( itemsTmp.card() > 0 ) {
137 OFCondition condition = lobj->findAndGetElements ( DCM_DirectoryRecordType, dirent );
139 if ( !condition.good() ) {
144 while ( dirent.card() ) {
145 DcmElement* elt = ( DcmElement* ) dirent.top();
147 elt->getOFStringArray ( cur );
149 if ( cur ==Patient ) {
152 if ( lobj->findAndGetElement ( DCM_PatientName, lelt ).good() )
153 lelt->getOFStringArray ( strName );
156 if ( cur == Study ) {
159 if ( lobj->findAndGetElement ( DCM_StudyDate, lelt ).good() )
160 lelt->getOFStringArray ( strDate );
163 if ( cur == Series ) {
166 if ( lobj->findAndGetElement ( DCM_SeriesInstanceUID, lelt ).good() ) {
168 lelt->getOFStringArray ( strID );
169 proceed = ( QString ( strID.c_str() ) == d->
series.at ( s ) );
173 if ( lobj->findAndGetElement ( DCM_SeriesDescription, lelt ).good() )
174 lelt->getOFStringArray ( strDesc );
178 if ( ( cur == Image ) && proceed ) {
181 if ( lobj->findAndGetElement ( DCM_ReferencedSOPInstanceUIDInFile, lelt ).good() ) {
183 lelt->getOFStringArray ( strNumber );
186 proceedIndex = ( QString ( strNumber.c_str() ) == d->
uid );
199 if ( lobj->findAndGetElement ( DCM_ReferencedFileID, lelt ).good() ) {
200 OFString strFilename;
201 lelt->getOFStringArray ( strFilename );
204 d->
filenames.append ( this->fixFilename ( QString ( strFilename.c_str() ) ) );
207 if ( proceedIndex ) {
208 d->
filenames.append ( this->fixFilename ( QString ( strFilename.c_str() ) ) );
214 if ( lobj->findAndGetElement ( DCM_SeriesDescription, lelt ).good() )
215 lelt->getOFStringArray ( strDesc );
227 for (
int i = 0; i < d->
filenames.size(); i++ ) {
230 if ( image.exists() ) {
232 zeroStr.fill ( QChar (
'0' ), 5 - QString::number ( i ).size() );
233 QString newFile(serieDir.absolutePath() + QDir::separator() +
"ima" + zeroStr + QString::number ( i ));
235 QFile(newFile).setPermissions(QFileDevice::WriteOwner);
254 QString QtDcmMoveDicomdir::fixFilename (
const QString & name )
const 256 QString tmpName(name);
258 tmpName.replace ( QChar (
'/' ), QDir::separator() ).replace ( QChar (
'\\' ), QDir::separator() );
259 QString filename = basename + QDir::separator() + tmpName.toUpper();
261 if ( ! QFile ( filename ).exists() ) {
262 filename = basename + QDir::separator() + tmpName.toLower();
virtual ~QtDcmMoveDicomdir()
void setDcmItem(DcmItem *item)
QtDcmMoveDicomdir(QObject *parent)
static QtDcmManager * instance()
void setSeries(const QStringList &series)
void previewSlice(const QString &filename)
void updateProgress(int i)
QtDcmMoveDicomdir::eMoveMode mode
void setMode(eMoveMode mode)
void setImageId(const QString &uid)
void setOutputDir(const QString &dir)
void setImportDir(const QString &dir)
void serieMoved(const QString &directory, const QString &serie, int number)