Skip to content

Commit

Permalink
améliorations DP
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/osirixplugins/code@95 bdd3870d-6ba2-4b59-8605-1de7af000970
  • Loading branch information
aglv committed Aug 11, 2010
1 parent 533b1d5 commit 3d80d47
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 715 deletions.
1 change: 0 additions & 1 deletion DiscPublishing/Classes/DiscPublishing.mm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ -(void)initPlugin {
}

-(void)observeOsirixWillTerminate:(NSNotification*)notification {
NSLog(@"observeOsirixWillTerminate");
[DiscPublishing SetQuitWhenDone:YES];
}

Expand Down
8 changes: 4 additions & 4 deletions DiscPublishing/Classes/DiscPublishingJob.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ -(void)start {
self.discType = [[self.info objectForKey:DiscPublishingJobInfoMediaTypeKey] unsignedIntValue];
self.volumeName = [self.info objectForKey:DiscPublishingJobInfoDiscNameKey];

self.type = JP_JOB_PRINT_ONLY; // TODO: reenable data
// self.type = JP_JOB_DATA;
// for (NSString* subpath in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:self.root error:NULL])
// [self.files addObject:[self.root stringByAppendingPathComponent:subpath]];
// self.type = JP_JOB_PRINT_ONLY; // TODO: reenable data
self.type = JP_JOB_DATA;
for (NSString* subpath in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:self.root error:NULL])
[self.files addObject:[self.root stringByAppendingPathComponent:subpath]];

// the merging of the template and csv is buggy in the framework, we do this ourselves
NSString* csvFile = [self.root stringByAppendingPathExtension:@"csv"];
Expand Down
26 changes: 13 additions & 13 deletions DiscPublishing/Classes/DiscPublishingPatientDisc.mm
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ +(NSString*)discNameForSeries:(NSArray*)series {
}

+(void)generateDICOMDIRAtDirectory:(NSString*)root withDICOMFilesInDirectory:(NSString*)dicomPath {
if ([dicomPath hasPrefix:root]) {
/* if ([dicomPath hasPrefix:root]) {
NSUInteger index = root.length;
if ([dicomPath characterAtIndex:index] == '/')
++index;
dicomPath = [dicomPath substringFromIndex:index];
}
}*/

NSTask* dcmmkdirTask = [[NSTask alloc] init];
[dcmmkdirTask setEnvironment:[NSDictionary dictionaryWithObject:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"dicom.dic"] forKey:@"DCMDICTPATH"]];
Expand Down Expand Up @@ -228,7 +228,7 @@ -(void)main {
[DiscPublishingPatientDisc copyContentsOfDirectory:_options.auxiliaryDirPath toPath:discBaseDirPath];
if (_options.includeReports) {
NSString* reportsDiscBaseDirPath = [discBaseDirPath stringByAppendingPathComponent:@"Reports"];
[privateFiles addObject:reportsDiscBaseDirPath];
[privateFiles addObject:@"Reports"];
[[NSFileManager defaultManager] copyItemAtPath:reportsTmpPath toPath:reportsDiscBaseDirPath error:NULL];
}

Expand Down Expand Up @@ -300,7 +300,7 @@ -(void)main {
}

// generate DICOMDIR
[DiscPublishingPatientDisc generateDICOMDIRAtDirectory:discBaseDirPath withDICOMFilesInDirectory:dicomDiscBaseDirPath];
[DiscPublishingPatientDisc generateDICOMDIRAtDirectory:discBaseDirPath withDICOMFilesInDirectory:discBaseDirPath];
[privateFiles addObject:@"DICOMDIR"];

// move QTHTML files
Expand Down Expand Up @@ -458,13 +458,13 @@ +(NSArray*)prepareSeriesDataForImages:(NSArray*)imagesIn inDirectory:(NSString*)
NSString* dirPath = [[NSFileManager defaultManager] tmpFilePathInDir:basePath];
[[NSFileManager defaultManager] confirmDirectoryAtPath:dirPath];

// NSLog(@"dirPath is %@", dirPath);
NSLog(@"dirPath is %@", dirPath);

// copy files by considering anonymize
NSString* dicomDirPath = [dirPath stringByAppendingPathComponent:@"DICOM"];
[[NSFileManager defaultManager] confirmDirectoryAtPath:dicomDirPath];

// NSLog(@"copying %d files to %@", imagesIn.count, dicomDirPath);
NSLog(@"copying %d files to %@", imagesIn.count, dicomDirPath);

currentThread.status = [baseStatus stringByAppendingFormat:@" %@", options.anonymize? NSLocalizedString(@"Anonymizing files...", NULL) : NSLocalizedString(@"Copying files...", NULL) ];
NSMutableArray* fileNames = [NSMutableArray arrayWithCapacity:imagesIn.count];
Expand Down Expand Up @@ -503,7 +503,7 @@ +(NSArray*)prepareSeriesDataForImages:(NSArray*)imagesIn inDirectory:(NSString*)

[currentThread enterSubthreadWithRange:0.5:0.5];
currentThread.status = [baseStatus stringByAppendingFormat:@" %@", NSLocalizedString(@"Importing files...", NULL)];
// NSLog(@"importing %d images to context", fileNames.count);
NSLog(@"importing %d images to context", fileNames.count);

// NSString* dbPath = [dirPath stringByAppendingPathComponent:@"OsiriX Data"];
// [[NSFileManager defaultManager] confirmDirectoryAtPath:dbPath];
Expand All @@ -512,17 +512,17 @@ +(NSArray*)prepareSeriesDataForImages:(NSArray*)imagesIn inDirectory:(NSString*)
if (![[images objectAtIndex:i] pathString] || ![[[images objectAtIndex:i] pathString] hasPrefix:dirPath])
[images removeObjectAtIndex:i];

//NSLog(@"TEST %d files to %d images", fileNames.count, images.count);
NSLog(@" %d files to %d images", fileNames.count, images.count);

NSString* oldDirPath = dirPath;
dirPath = [self dirPathForSeries:[[images objectAtIndex:0] valueForKeyPath:@"series"] inBaseDir:basePath];
// NSLog(@"moving %@ to %@", oldDirPath, dirPath);
NSLog(@"moving %@ to %@", oldDirPath, dirPath);
[[NSFileManager defaultManager] moveItemAtPath:oldDirPath toPath:dirPath error:NULL];
for (DicomImage* image in images)
[image setPathString:[[image pathString] stringByReplacingCharactersInRange:NSMakeRange(0, [oldDirPath length]) withString:dirPath]];
dicomDirPath = [dicomDirPath stringByReplacingCharactersInRange:NSMakeRange(0, [oldDirPath length]) withString:dirPath];

// NSLog(@"decompressing");
NSLog(@"decompressing");

currentThread.progress = 0.3;
if (options.compression == CompressionDecompress || (options.compression == CompressionCompress && options.compressJPEGNotJPEG2000)) {
Expand All @@ -534,7 +534,7 @@ +(NSArray*)prepareSeriesDataForImages:(NSArray*)imagesIn inDirectory:(NSString*)
[[NSFileManager defaultManager] removeItemAtPath:beforeDicomDirPath error:NULL];
}

// NSLog(@"compressing");
NSLog(@"compressing");

currentThread.progress = 0.4;
if (options.compression == CompressionCompress) {
Expand All @@ -556,7 +556,7 @@ +(NSArray*)prepareSeriesDataForImages:(NSArray*)imagesIn inDirectory:(NSString*)

[DiscPublishingPatientDisc generateDICOMDIRAtDirectory:dirPath withDICOMFilesInDirectory:dicomDirPath];

// NSLog(@"generating QTHTML");
NSLog(@"generating QTHTML");

currentThread.progress = 0.7;
if (options.includeHTMLQT) {
Expand All @@ -567,7 +567,7 @@ +(NSArray*)prepareSeriesDataForImages:(NSArray*)imagesIn inDirectory:(NSString*)
[BrowserController exportQuicktime:sortedImages:htmlqtTmpPath:YES:NULL:seriesPaths];
}

// NSLog(@"done");
NSLog(@"done");
[currentThread exitSubthread];
currentThread.status = baseStatus;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ -(BOOL)robotOptionsObserveValueForKeyPath:(NSString*)keyPath ofObject:(id)obj ch
}

-(void)initRobotGetStatusTimerFireMethod:(NSTimer*)timer { // timer is this->robotOptionsTimer
//[patientModeAuxDirPathControl setEnabled:YES];
@try {
NSString* xml = [DiscPublishing GetStatusXML];
[robotOptionsTimer invalidate]; robotOptionsTimer = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
IBOutlet NSButton* patientModeLabelTemplateEditButton;
IBOutlet NSButton* archivingModeLabelTemplateEditButton;
IBOutlet NSPathControl* patientModeLabelTemplatePathControl;
IBOutlet NSPathControl* patientModeAuxDirPathControl;
IBOutlet NSPathControl* archivingModeLabelTemplatePathControl;

NSSize deltaFromPathControlBRToButtonTL;
Expand Down
31 changes: 29 additions & 2 deletions DiscPublishing/Classes/DiscPublishingPreferencesController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ -(void)awakeFromNib {
[defaultsController addObserver:self forKeyPath:valuesKeyPath(DiscPublishingPatientModeDiscCoverTemplatePathDefaultsKey) options:NSKeyValueObservingOptionInitial context:NULL];
[defaultsController addObserver:self forKeyPath:valuesKeyPath(DiscPublishingArchivingModeDiscCoverTemplatePathDefaultsKey) options:NSKeyValueObservingOptionInitial context:NULL];

NSString* zipPasswordToolTip = NSLocalizedString(@"The password must be at least 8 characters long. If this condition is not met then the files will not be zipped.", @"Preferences password warning");
NSString* zipPasswordToolTip = NSLocalizedString(@"The password must be at least 8 characters long. If this condition is not met then the password will not be applied.", @"Preferences password warning");
[patientModeZipPasswordWarningView setToolTip:zipPasswordToolTip];
[archivingModeZipPasswordWarningView setToolTip:zipPasswordToolTip];
NSString* auxDirToolTip = NSLocalizedString(@"The auxiliary directory must point to an existing directory. If the selected directory does not exist then no files are copied.", @"Preferences auxiliary directory warning");
[patientModeAuxiliaryDirWarningView setToolTip:auxDirToolTip];
[archivingModeAuxiliaryDirWarningView setToolTip:auxDirToolTip];

[self robotOptionsInit];
}

Expand Down Expand Up @@ -249,6 +249,27 @@ -(id)transformedValue:(NSString*)value {
@end


@interface DiscPublishingAuxDirPathTransformer: NSValueTransformer
@end
@implementation DiscPublishingAuxDirPathTransformer

+(Class)transformedValueClass {
return [NSString class];
}

+(BOOL)allowsReverseTransformation {
return NO;
}

-(id)transformedValue:(NSString*)value {
if (!value || ![[NSFileManager defaultManager] fileExistsAtPath:value])
return NSLocalizedString(@"/Undefined", NULL);
return value;
}

@end


@interface DiscPublishingPreferencesOptionsBoxTitleForMode: NSValueTransformer
@end
@implementation DiscPublishingPreferencesOptionsBoxTitleForMode
Expand All @@ -270,5 +291,11 @@ -(id)transformedValue:(id)value {
return NSLocalizedString(@"Options", NULL);
}



@end





9 changes: 8 additions & 1 deletion DiscPublishing/Classes/DiscPublishingToolAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,16 @@ -(void)applicationDidFinishLaunching:(NSNotification*)aNotification {
NSThread* thread = [[[NSThread alloc] initWithTarget:self selector:@selector(initDiscPublisherThread:) object:NULL] autorelease];
[thread start];

[self distributeNotificationsForThread:thread];
// [self distributeNotificationsForThread:thread];

NSLog(@"Welcome to DiscPublishingTool.");

// recover jobs, need folder XXX and files XXX.plist & XXX.jpg
// for (<#initial#>; <#condition#>; <#increment#>) {
// <#statements#>
// }


}

-(void)initDiscPublisherThread:(id)obj {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ +(void)discPublishingInitialize {
[NSNumber numberWithBool:NO], DiscPublishingPatientModeIncludeHTMLQTFlagDefaultsKey,
[NSNumber numberWithBool:YES], DiscPublishingPatientModeIncludeReportsFlagDefaultsKey,
[NSNumber numberWithBool:NO], DiscPublishingPatientModeIncludeAuxiliaryDirectoryFlagDefaultsKey,
// [[NSFileManager defaultManager] findSystemFolderOfType:kMusicDocumentsFolderType forDomain:kUserDomain], DiscPublishingPatientModeAuxiliaryDirectoryPathDefaultsKey, // TODO: check and fix
// [[NSFileManager defaultManager] findSystemFolderOfType:kMusicDocumentsFolderType forDomain:kUserDomain], DiscPublishingPatientModeAuxiliaryDirectoryPathDefaultsKey, // TODO: check and fix
[NSNumber numberWithUnsignedInt:CompressionCompress], DiscPublishingPatientModeCompressionDefaultsKey,
[NSNumber numberWithBool:NO], DiscPublishingPatientModeCompressJPEGNotJPEG2000DefaultsKey,
[NSNumber numberWithBool:NO], DiscPublishingPatientModeZipFlagDefaultsKey,
Expand Down Expand Up @@ -177,7 +177,9 @@ -(DiscPublishingOptions*)discPublishingPatientModeOptions {
options.zip = [self boolForKey:DiscPublishingPatientModeZipFlagDefaultsKey];
options.zipEncrypt = [self boolForKey:DiscPublishingPatientModeZipEncryptFlagDefaultsKey];
options.zipEncryptPassword = [self stringForKey:DiscPublishingPatientModeZipEncryptPasswordDefaultsKey];

options.discCoverTemplatePath = [self stringForKey:DiscPublishingPatientModeDiscCoverTemplatePathDefaultsKey];
if (!options.discCoverTemplatePath) options.discCoverTemplatePath = [NSUserDefaultsController discPublishingDefaultDiscCoverPath];

return [options autorelease];
}
Expand All @@ -196,8 +198,10 @@ -(DiscPublishingOptions*)discPublishingArchivingModeOptions {
options.zip = [self boolForKey:DiscPublishingArchivingModeZipFlagDefaultsKey];
options.zipEncrypt = [self boolForKey:DiscPublishingArchivingModeZipEncryptFlagDefaultsKey];
options.zipEncryptPassword = [self stringForKey:DiscPublishingArchivingModeZipEncryptPasswordDefaultsKey];
options.discCoverTemplatePath = [self stringForKey:DiscPublishingArchivingModeDiscCoverTemplatePathDefaultsKey];

options.discCoverTemplatePath = [self stringForKey:DiscPublishingArchivingModeDiscCoverTemplatePathDefaultsKey];
if (!options.discCoverTemplatePath) options.discCoverTemplatePath = [NSUserDefaultsController discPublishingDefaultDiscCoverPath];

return [options autorelease];
}

Expand Down
Loading

0 comments on commit 3d80d47

Please sign in to comment.