Skip to content

Commit

Permalink
SR Drag and Drop debugging
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/osirix/code/osirix@973 4e9e6e3d-4551-47eb-9dbe-a6127f9400a1
  • Loading branch information
Lance Pysher committed Aug 21, 2006
1 parent e647e05 commit cc79ee0
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 34 deletions.
9 changes: 3 additions & 6 deletions AllKeyImagesArrayController.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,25 @@ - (void)setContent:(id)content{
[super setContent:content];
if (keyImageMatrix)
[self updateMatrix];
[(DragMatrix *)keyImageMatrix setController:self];
}


- (void)updateMatrix{
int columns = [keyImageMatrix numberOfColumns];
while (columns-- > 0)
[keyImageMatrix removeColumn:columns];
int count = [[self content] count];
//while (count-- > 0)
// [keyImageMatrix addColumn];
//NSLog(@"columns after : %d", columns);

NSEnumerator *enumerator = [[self content] objectEnumerator];
DicomImage *image;
while (image = [enumerator nextObject]) {
NSImage *thumbnail = [image thumbnail];
if (thumbnail) {
//NSImageCell *cell = [[[NSImageCell alloc] initImageCell:thumbnail] autorelease];

NSButtonCell *cell = [[[NSButtonCell alloc] initImageCell:thumbnail] autorelease];
[keyImageMatrix addColumnWithCells:[NSArray arrayWithObject:cell]];
}
}

//keyImageMatrix

}
Expand Down
5 changes: 5 additions & 0 deletions Binaries/English.lproj/StructuredReport.nib/classes.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Binaries/English.lproj/StructuredReport.nib/info.nib

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Binaries/English.lproj/StructuredReport.nib/keyedobjects.nib
Binary file not shown.
4 changes: 3 additions & 1 deletion DragMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@
NSRect oldDrawRect, newDrawRect;
BOOL shouldDraw;
IBOutlet id arrayController;
NSArray *selection;
int srcRow, srcCol, dstRow, dstCol;
}
- (void) setController:(id)controller;
//- (void) setController:(id)controller;
// Private
- (NSEvent*) downEvent;
- (void) setDownEvent:(NSEvent *)event;
- (void) clearDragDestinationMembers;
-(NSArray *)selection;

@end

57 changes: 38 additions & 19 deletions DragMatrix.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

float INS_WIDTH = 2;
float CIRCLE_SIZE = 6;
NSString *pasteBoardTypeCover = @"Cover";
NSString *pasteBoardTypeCover = @"KeyIMages";

/*****************************************************************************
* Function - _scaledImage
Expand Down Expand Up @@ -68,6 +68,8 @@ - (id)initWithFrame:(NSRect)frame {
return self;
}



/*****************************************************************************
* Function - clearDragDestinationMembers
*
Expand All @@ -86,40 +88,51 @@ - (void) clearDragDestinationMembers {
* the caller if we'll accept the object.
*****************************************************************************/
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
[self clearDragDestinationMembers];
NSLog(@"Drag Entered");
if ([sender draggingSource] == self) {
[self clearDragDestinationMembers];
return NSDragOperationAll;
NSLog(@"NSDragOperationNone");
return NSDragOperationNone;
} else {
return NSDragOperationNone;
NSLog(@"NSDragOperationEvery");
return NSDragOperationEvery;

}
}

/*****************************************************************************
* Function - prepareDragOperation (implements NSDraggingDestination)
*
*
*
***************************************************************************/
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender{
NSLog(@"prepare drag");
return YES;
}

/*****************************************************************************
* Function - performDragOperation (implements NSDraggingDestination)
*
* Called after the user releases the drag object. Here we perform the
* result of the dragging.
*****************************************************************************/
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
NSLog(@"perform Drag");
if ([sender draggingSource] == self)
return NO;

NSPasteboard *pboard;
NSArray *types;

pboard = [sender draggingPasteboard];
types = [pboard types];
if ([types indexOfObject:pasteBoardTypeCover] != NSNotFound) {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
/*
NSString *keys[4] = {@"srcRow", @"srcCol", @"dstRow", @"dstCol"};
NSNumber *objects[4];
objects[0] = [NSNumber numberWithInt:srcRow];
objects[1] = [NSNumber numberWithInt:srcCol];
objects[2] = [NSNumber numberWithInt:dstRow];
objects[3] = [NSNumber numberWithInt:dstCol];
*/
NSDictionary *dict;
dict = [NSDictionary dictionaryWithObject:[arrayController selectedObjects] forKey:@"images"];
//[arrayController setSelectedObjects:[NSArray arrayWithObject:[[arrayController content] objectAtIndex:srcCol]]];
NSArray *array = [[sender draggingSource] selection];
//NSLog(@"Selection:
dict = [NSDictionary dictionaryWithObject:array forKey:@"images"];
[nc postNotificationName:@"DragMatrixImageMoved" object:self userInfo:dict];
}

Expand Down Expand Up @@ -157,7 +170,7 @@ - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender {
int row, column;
float offsetx;

if ([sender draggingSource] != self)
if ([sender draggingSource] == self)
return NSDragOperationNone;

// Note that the matrix coordiante system is flipped such that the
Expand Down Expand Up @@ -257,6 +270,9 @@ - (void)startDrag:(NSEvent *)event {
// Note: _scaledImage is function we add to NSImageCell in our category.
//scaledImage = [[self cellAtRow:srcRow column:srcCol] _scaledImage];
scaledImage = [[self cellAtRow:srcRow column:srcCol] image];
[self selectCellAtRow:srcRow column:srcCol];
[arrayController setSelectionIndex:srcCol];
//[arrayController setSelectedObjects:[NSArray arrayWithObject:[[arrayController content] objectAtIndex:srcCol]]];
theDraggedCellFrame = [self cellFrameAtRow:srcRow column:srcCol];
size = [scaledImage size];
dragPoint.x = theDraggedCellFrame.origin.x
Expand Down Expand Up @@ -385,8 +401,11 @@ - (void)setDownEvent:(NSEvent *)event {
downEvent = [event retain];
}

- (void) setController:(id)controller{
arrayController = controller;

-(NSArray *)selection{
return [arrayController content];
}



@end
7 changes: 5 additions & 2 deletions SelectedKeyImagesArrayController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@


#import <Cocoa/Cocoa.h>
#import "AllKeyImagesArrayController.h"


@interface SelectedKeyImagesArrayController : NSArrayController {
IBOutlet NSMatrix *keyImageMatrix;
@interface SelectedKeyImagesArrayController : AllKeyImagesArrayController {

}

- (void)addKeyImages:(NSNotification *)note;

@end
24 changes: 24 additions & 0 deletions SelectedKeyImagesArrayController.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@

@implementation SelectedKeyImagesArrayController

- (void)awakeFromNib{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addKeyImages:) name:@"DragMatrixImageMoved" object:nil];
}

- (void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}




- (void)addKeyImages:(NSNotification *)note{
NSArray *keyImages = [[note userInfo] objectForKey:@"images"];
NSEnumerator *enumerator = [keyImages objectEnumerator];
id image;
while (image = [enumerator nextObject]){
if (![[self content] containsObject:image]) {
[self addObject:image];
[keyImageMatrix addColumn];
}
}

}


@end
2 changes: 1 addition & 1 deletion StructuredReport.mm
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ - (id)initWithStudy:(id)study contentsOfFile:(NSString *)file{
_doc->setManufacturer("OsiriX");

// get KeyImages
_keyImages = [[[_study keyImages] allObjects] retain];
//_keyImages = [[[_study keyImages] allObjects] retain];

}
}
Expand Down
5 changes: 4 additions & 1 deletion StructuredReportController.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@
- (void)setReportIndex:(NSIndexSet *)indexSet;

- (NSArray *) keyImagesInStudy;
- (void) setKeyImagesInStudy:(NSArray *)images;
- (void)setKeyImagesInStudy:(NSArray *)images;

- (NSArray *) keyImages;
- (void) setKeyImages:(NSArray *)keyImages;



Expand Down
13 changes: 11 additions & 2 deletions StructuredReportController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ - (IBAction)addKeyImages:(id)sender{
[alert addButtonWithTitle:@"Cancel"];
if ([alert runModal] == NSAlertFirstButtonReturn ) {
NSArray *images = [(NSSet *)[_study keyImages] allObjects];
[_report setKeyImages:images];
//[_report setKeyImages:images];
[self setKeyImages:images];
}

}
Expand Down Expand Up @@ -343,10 +344,18 @@ - (NSArray *) keyImagesInStudy{
return _keyImagesInStudy;
}

- (void) setkeyImagesInStudy:(NSArray *)images{
- (void)setKeyImagesInStudy:(NSArray *)images{
[_keyImagesInStudy release];
_keyImagesInStudy = [images retain];
}

- (NSArray *) keyImages{
return [_report keyImages];
}

- (void) setKeyImages:(NSArray *)keyImages{
[_report setKeyImages:keyImages];
}



Expand Down

0 comments on commit cc79ee0

Please sign in to comment.