1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940
|
//
// Lynkeos
// $Id: MyProcessStackView.m 585 2018-09-08 21:30:37Z j-etienne $
//
// Created by Jean-Etienne LAMIAUD on Sat Oct 27 2007.
// Copyright (c) 2007-2014. Jean-Etienne LAMIAUD
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#include "MyProcessStackView.h"
#include "MyDocument.h"
#include "MyPluginsController.h"
#include "ProcessStackManager.h"
/*!
* @abstract Custom cell used to place NSViews in the outline view cells
*/
@interface MyViewCell : NSTextFieldCell
{
NSView *_view; //!< The view to display in the outline view
}
@end
/*!
* @abstract Custom cell used to place NSButton in the outline view cells
*/
@interface MyButtonCell : NSButtonCell
{
BOOL _isValid; //!< Wether the view contains a button or nothing
}
@end
/*!
* @abstract Custom cell used to place NSPopup in the outline view cells
*/
@interface MyPopupButtonCell : NSPopUpButtonCell
{
BOOL _isValid; //!< Wether the view contains a popup or nothing
}
@end
/*!
* @abstract Private methods of MyProcessStackView
*/
@interface MyProcessStackView(Private)
//! Deactivate and remove all views in the stack
- (void) tidyStack ;
//! Reload the stack with the relevant process views
- (void) reloadList ;
//! Process the notification for selection change in the list
- (void) hilightChange:(NSNotification*)notif ;
//! Process the notification for processing start
- (void) processStarted:(NSNotification*)notif ;
//! Process the notification for processing end
- (void) processEnded:(NSNotification*)notif ;
//! Process the notification for end of the last processing in the stack
- (void) processStackEnded:(NSNotification*)notif ;
//! Remove a processing from the stack
- (void) deleteProcessing:(id <LynkeosProcessingView>)pView ;
//! Add a processing in the stack
- (void) addProcessing:(NSArray*)indexes ;
@end
@implementation MyViewCell
- (id) init
{
if ( (self = [super init]) != nil )
_view = nil;
return( self );
}
- (void) setObjectValue:(id <NSCopying>)object
{
id val = nil;
if ( [(NSObject*)object isKindOfClass:[NSView class]] )
_view = (NSView*)object ;
else
{
val = object;
_view = nil ;
}
[super setObjectValue:val];
}
- (id) objectValue
{
if ( _view != nil )
return( _view );
else
return( [super objectValue] );
}
- (void) drawWithFrame:(NSRect) cellFrame inView:(NSView *) controlView
{
if ( _view != nil )
{
[_view setFrame: cellFrame];
if ( [_view superview] != controlView )
[controlView addSubview: _view];
}
[super drawWithFrame: cellFrame inView: controlView];
}
@end
@implementation MyButtonCell
- (void) setObjectValue:(id <NSCopying>)object
{
_isValid = (object != nil);
if ( _isValid )
[super setObjectValue:object];
}
- (void) drawWithFrame:(NSRect) cellFrame inView:(NSView *) controlView
{
if ( _isValid )
[super drawWithFrame:cellFrame inView:controlView];
}
@end
@implementation MyPopupButtonCell
- (void) setObjectValue:(id <NSCopying>)object
{
_isValid = (object != nil);
[super setObjectValue:object];
}
- (void) drawWithFrame:(NSRect) cellFrame inView:(NSView *) controlView
{
if ( _isValid )
[super drawWithFrame:cellFrame inView:controlView];
}
@end
@implementation MyProcessStackView(Private)
- (void) tidyStack
{
if ( _item != nil )
[_item release];
_item = nil;
if ( _stack != nil )
[_stack release];
_stack = nil;
NSEnumerator *procViewList = [_procViewControllers objectEnumerator];
id <LynkeosProcessingView> v;
while( (v = [procViewList nextObject]) != nil )
[v setActiveView:NO];
NSView *sub;
while ( (sub = [[_view subviews] lastObject]) != nil )
[sub removeFromSuperviewWithoutNeedingDisplay];
[_procViewControllers removeAllObjects];
}
- (void) reloadList
{
// Delete all processing views
NSView *v;
while ( (v = [[_view subviews] lastObject]) != nil )
[v removeFromSuperviewWithoutNeedingDisplay];
[_view reloadData];
}
- (void) hilightChange:(NSNotification*)notif
{
LynkeosImageProcessingParameter *param;
LynkeosProcessableImage *item;
NSTableColumn *tableColumn = [_view tableColumnWithIdentifier:@"process"];
double columnWidth = [tableColumn minWidth];
// Get the new item
[_window getItemToProcess:&item andParameter:¶m forView:self];
if ( item != _item )
{
// Tidy things before updating
[self tidyStack];
_item = item;
// Retrieve the new stack if any
if ( _item != nil )
{
[_item retain];
_stack = (NSMutableArray*)[_item getProcessingParameterWithRef:
K_PROCESS_STACK_REF
forProcessing:nil goUp:NO];
// Look for the new process views
if ( _stack != nil )
{
NSArray *procViews =[[MyPluginsController defaultPluginController]
getProcessingViews];
const NSUInteger nProcViews = [procViews count];
[_stack retain];
NSEnumerator *procList = [_stack objectEnumerator];
LynkeosImageProcessingParameter *param;
while( (param = [procList nextObject]) != nil )
{
Class c = [param processingClass];
id <NSObject> config = nil;
LynkeosProcessingViewRegistry *pView = nil;
NSUInteger i;
for( i = 0; i < nProcViews; i++ )
{
pView = [procViews objectAtIndex:i];
if ( [pView->controller isViewControllingProcess:c
withConfig:&config] )
break;
}
// And instantiate each with ourself as window and document proxy
NSAssert( i < nProcViews && pView != nil,
@"Process without view" );
id <LynkeosProcessingView> view = [[(id <LynkeosProcessingView>)
[pView->controller alloc] initWithWindowController:self
document:self
configuration:config]
autorelease];
// Put it in the process view array
[_procViewControllers addObject:view];
[view setActiveView:YES];
double viewWidth= [[view getProcessingView] frame].size.width;
if ( viewWidth > columnWidth )
columnWidth = viewWidth;
}
}
}
// Finally, redisplay the outline view
[self reloadList];
[tableColumn setMinWidth:columnWidth];
if ( [tableColumn maxWidth] < columnWidth )
[tableColumn setMaxWidth:columnWidth];
if ( [tableColumn width] < columnWidth )
[tableColumn setWidth:columnWidth];
NSEnumerator *procEnum = [_procViewControllers objectEnumerator];
id <LynkeosProcessingView> view;
while ( (view = [procEnum nextObject]) != nil )
[_view expandItem:view];
// And the image
[_imageView displayItem:_item];
}
}
- (void) processStarted:(NSNotification*)notif
{
// If the stack was created for this process, get it now
if ( _stack == nil )
{
_stack = (NSMutableArray*)[_item getProcessingParameterWithRef:
K_PROCESS_STACK_REF
forProcessing:nil goUp:NO];
if ( _stack != nil )
[_stack retain];
}
_isProcessing = YES;
// Propagate the notification to the "sub processing views"
[[NSNotificationCenter defaultCenter] postNotificationName:[notif name]
object:self
userInfo:[notif userInfo]];
}
- (void) processEnded:(NSNotification*)notif
{
// Propagate the notification to the "sub processing views"
[[NSNotificationCenter defaultCenter] postNotificationName:[notif name]
object:self
userInfo:[notif userInfo]];
}
- (void) processStackEnded:(NSNotification*)notif
{
_isProcessing = NO;
// Propagate the notification to the "sub processing views"
[[NSNotificationCenter defaultCenter] postNotificationName:[notif name]
object:self
userInfo:[notif userInfo]];
[_imageView displayItem:_item];
}
- (void) deleteProcessing:(id <LynkeosProcessingView>)pView
{
NSUInteger idx = [_procViewControllers indexOfObject:pView];
// Delete the processing
[pView setActiveView:NO];
NSView *v = [pView getProcessingView];
if ( [[_view subviews] indexOfObject:v] != NSNotFound )
[v removeFromSuperviewWithoutNeedingDisplay];
[_procViewControllers removeObjectAtIndex:idx];
[_stack removeObjectAtIndex:idx];
[self reloadList];
// Update the processings result
if ( [_stack count] > 0 )
{
LynkeosImageProcessingParameter *param;
if ( idx < [_stack count] )
param = [_stack objectAtIndex:idx];
else
param = [_stack lastObject];
[self startProcess:[param processingClass]
forItem:_item parameters:param];
}
else
{
[_item revertToOriginal];
[self processStackEnded:nil];
}
}
- (void) addProcessing:(NSArray*)indexes
{
// Retrieve the indexes
NSUInteger stackIdx = [[indexes objectAtIndex:0] unsignedLongValue];
NSInteger processIndex = [[indexes objectAtIndex:1] longValue];
// Allocate the processing view
LynkeosProcessingViewRegistry *reg =
[[[MyPluginsController defaultPluginController] getProcessingViews]
objectAtIndex:processIndex];
id <LynkeosProcessingView> pView =
[[[reg->controller alloc] initWithWindowController:self
document:self
configuration:reg->config] autorelease];
// Insert it in the processing view array
if ( stackIdx == NSNotFound )
[_procViewControllers addObject:pView];
else
[_procViewControllers insertObject:pView atIndex:stackIdx];
// Put a placeholder in the parameters stack (so that we give a nil parameter
// to this processing view)
if ( _stack == nil )
{
// Create a brand new one
_stack = [[NSMutableArray array] retain];
[_item setProcessingParameter:(id <LynkeosProcessingParameter>)_stack
withRef:K_PROCESS_STACK_REF forProcessing:nil];
}
if ( stackIdx == NSNotFound )
{
[_stack addObject:[NSNull null]];
stackIdx = [_stack count]-1;
}
else
[_stack insertObject:[NSNull null] atIndex:stackIdx];
// Activate the new view
[pView setActiveView:YES];
// Get the processing parameters and put them in the params array
LynkeosImageProcessingParameter *param =
(LynkeosImageProcessingParameter*)[pView getCurrentParameters];
[param setProcessingClass:[pView processingClass]];
[_stack replaceObjectAtIndex:stackIdx withObject:param];
// Reload the table
[self reloadList];
}
@end
@implementation MyProcessStackView
- (id) init
{
if ( (self = [super init]) != nil )
{
_window = nil;
_document = nil;
_imageView = nil;
_item = nil;
_stack = nil;
_procViewControllers = [[NSMutableArray array] retain];
_isProcessing = NO;
[NSBundle loadNibNamed:@"MyProcessStackView" owner:self];
// Detach the outline view from the original scrollview (it will be put
// inside another one)
[_view removeFromSuperviewWithoutNeedingDisplay];
[_view retain];
_defaultRowHeight = [_view rowHeight];
// Set the custom cell for the process column
_processCell = [[MyViewCell alloc] initTextCell:@""];
// Set the custom cell for the delete column
_deleteCell = [[MyButtonCell alloc] initTextCell:@"-"];
[_deleteCell setButtonType: NSMomentaryPushInButton];
[_deleteCell setBezelStyle:NSCircularBezelStyle];
[_deleteCell setControlSize:NSSmallControlSize];
// And set the custom popup cell for the add column
_addCell = [[MyPopupButtonCell alloc] initTextCell:@""];
[_addCell addItemWithTitle:NSLocalizedString(@"AddProcess",
@"Process stack add menu title")];
NSEnumerator *procViews =
[[[MyPluginsController defaultPluginController] getProcessingViews]
objectEnumerator];
NSInteger pViewIndex = 0;
LynkeosProcessingViewRegistry *procView;
while ( (procView = [procViews nextObject]) != nil )
{
NSString *title, *toolTitle, *key, *tip;
NSImage *icon;
if ( [procView->controller processingViewKindForConfig:
procView->config] == ImageProcessingKind )
{
[procView->controller getProcessingTitle:&title
toolTitle:&toolTitle key:&key
icon:&icon tip:&tip
forConfig:nil];
[_addCell addItemWithTitle:title];
[[_addCell lastItem] setTag:pViewIndex];
}
pViewIndex++;
}
[_addCell setControlSize:NSSmallControlSize];
[_addCell setFont:[NSFont menuFontOfSize:10.0]];
// Set the custom cell for the outline column
_outlineCell = [[MyButtonCell alloc] initTextCell:@""];
[_outlineCell setEditable: YES];
[_outlineCell setAllowsMixedState: NO];
[_outlineCell setButtonType: NSSwitchButton];
[_outlineCell setControlSize:NSSmallControlSize];
}
return( self );
}
- (id) initWithWindowController: (id <LynkeosWindowController>)window
document: (id <LynkeosViewDocument>)document
configuration: (id <NSObject>)config
{
NSAssert( config == nil,
@"Process stack manager does not support configuration" );
if ( (self = [self init]) != nil )
{
// Register the document and window
_window = (MyImageListWindow*)window;
_document = document;
_imageView = [_window getImageView];
}
return( self );
}
- (void) dealloc
{
if (_item != nil )
[_item release];
if ( _stack != nil )
[_stack release];
[_procViewControllers release];
[_view release];
[_outlineCell release];
[_processCell release];
[_deleteCell release];
[_addCell release];
[super dealloc];
}
#pragma mark = Outline View Delegate
- (NSCell*) outlineView:(NSOutlineView *)outlineView
dataCellForTableColumn:(NSTableColumn *)tableColumn
item:(id)item
{
if ( tableColumn == nil )
return( nil );
id columnId = [tableColumn identifier];
if ( [columnId isEqual:@"outline"] )
return( _outlineCell );
else if ( [columnId isEqual:@"process"] )
return( _processCell );
else if ( [columnId isEqual:@"delete"] )
return( _deleteCell);
else if ( [columnId isEqual:@"add"] )
return( _addCell );
else
return( nil );
}
- (BOOL) outlineView:(NSOutlineView*)outlineView shouldSelectItem:(id)item
{
return ( [item conformsToProtocol:@protocol(LynkeosProcessingView)]
&& !_isProcessing );
}
- (BOOL) outlineView:(NSOutlineView *)outlineView shouldExpandItem:(id)item
{
LynkeosImageProcessingParameter *params;
return ( item != self
&& [item conformsToProtocol:@protocol(LynkeosProcessingView)]
&& ( (params = (LynkeosImageProcessingParameter*)
[item getCurrentParameters]) == nil
|| ![params isExcluded] ) );
}
- (void)outlineViewItemDidExpand:(NSNotification *)notification
{
// This may have pushed some cells out of the clip view,
// which have not been redrawn and which view is still in the clip view
NSRect outLineRect = [_view visibleRect];
NSInteger r, nr = [_view numberOfRows];
for ( r = 0; r < nr; r++ )
{
id item = [_view itemAtRow:r];
if ( [item isKindOfClass:[NSView class]] // Views are second level items
&& !NSIntersectsRect([_view rectOfRow:r], outLineRect)
&& [item superview] != nil )
[item removeFromSuperview];
}
}
- (void)outlineViewItemDidCollapse:(NSNotification *)notification
{
id <LynkeosProcessingView> v =
[[notification userInfo] objectForKey:@"NSObject"];
NSAssert( [v conformsToProtocol:@protocol(LynkeosProcessingView)],
@"Attempt to collapse a non view item" );
[[v getProcessingView] removeFromSuperview];
}
- (id) outlineView:(NSOutlineView *)outlineView child:(NSInteger)index
ofItem:(id)item
{
if ( item == nil )
{
NSUInteger cnt = [_procViewControllers count];
if ( index > 0 )
{
if ( (NSUInteger)index <= cnt )
return( [_procViewControllers objectAtIndex:cnt-index] );
else
return(nil);
}
else
return( self );
}
else
{
if ( item == self )
return( nil );
else
{
NSAssert( [item conformsToProtocol:@protocol(LynkeosProcessingView)],
@"First level item shall be a processing view");
NSAssert( index == 0, @"No more than one process per pane" );
return( [item getProcessingView] );
}
}
}
- (BOOL) outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
return ( item != self
&& [item conformsToProtocol:@protocol(LynkeosProcessingView)] );
}
- (NSInteger) outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
if ( item == nil )
return( [_procViewControllers count]+1 );
else if ( item != self
&& [item conformsToProtocol:@protocol(LynkeosProcessingView)] )
return( 1 );
else
return( 0 );
}
- (id) outlineView:(NSOutlineView *)outlineView
objectValueForTableColumn:(NSTableColumn *)tableColumn
byItem:(id)item
{
id columnId = [tableColumn identifier];
BOOL isTitle = [item conformsToProtocol:@protocol(LynkeosProcessingView)];
if ( [columnId isEqual:@"outline"] )
{
if ( isTitle && item != self )
{
LynkeosImageProcessingParameter *param =
(LynkeosImageProcessingParameter*)[item getCurrentParameters];
NSAssert( param != nil,
@"Inconsistent image processing without parameters" );
return( [NSNumber numberWithBool:![param isExcluded]] );
}
else
return( nil );
}
else if ( [columnId isEqual:@"process"] )
{
if ( item == self )
return( nil );
else if ( isTitle )
{
NSString *title, *toolTitle, *key, *tip;
NSImage *icon;
[[item class] getProcessingTitle:&title toolTitle:&toolTitle key:&key
icon:&icon tip:&tip forConfig:nil];
return( title );
}
else
return( item );
}
else if ( [columnId isEqual:@"delete"] )
{
if ( isTitle && item != self )
return( [NSNumber numberWithInt:NSOffState] );
else
return( nil );
}
else if ( [columnId isEqual:@"add"] )
{
if ( isTitle )
return( [NSNumber numberWithInt:0] );
else
return( nil );
}
else
return( nil );
}
- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object
forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
// Do not change the stack while processing
if ( _isProcessing )
return;
id columnId = [tableColumn identifier];
NSAssert( [item conformsToProtocol:@protocol(LynkeosProcessingView)],
@"setObjectValue not on a view" );
if ( item != self && [columnId isEqual:@"outline"] )
{
BOOL excluded = ![object boolValue];
// Mark whether this process is used
LynkeosImageProcessingParameter *param =
(LynkeosImageProcessingParameter*)[item getCurrentParameters];
[param setExcluded:excluded];
if ( excluded )
[outlineView collapseItem:item];
// Update the processings result by restarting
[self startProcess:[param processingClass]
forItem:_item parameters:param];
}
else if ( item != self && [columnId isEqual:@"delete"] )
{
// Delete the processing (after a while because deleting view content
// inside one of its delegate method is not safe).
[[NSRunLoop currentRunLoop] performSelector:@selector(deleteProcessing:)
target:self
argument:item
order:0
modes:
[NSArray arrayWithObject:NSDefaultRunLoopMode]];
}
else if ( [columnId isEqual:@"add"] )
{
// Insert a processing (same remark as above)
[[NSRunLoop currentRunLoop] performSelector:@selector(addProcessing:)
target:self
argument:
[NSArray arrayWithObjects:
[NSNumber numberWithUnsignedLong:
[_procViewControllers indexOfObject:item]],
[NSNumber numberWithLong:
[[_addCell itemAtIndex:
[object intValue]] tag]],
nil]
order:0
modes:
[NSArray arrayWithObject:NSDefaultRunLoopMode]];
}
}
- (CGFloat) outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
{
if ( [item conformsToProtocol:@protocol(LynkeosProcessingView)] )
// On this line, we display the process name
return( _defaultRowHeight );
else
// This one is for displaying the process view (which is "item")
return( [item frame].size.height );
}
#pragma mark = LynkeosWindowController protocol
- (NSDictionary*) windowSizes
{
[self doesNotRecognizeSelector:_cmd];
return( nil );
}
// We manage the image view, do not let the process controllers access it
- (id <LynkeosImageView>) getImageView { return( nil ); }
- (id <LynkeosImageView>) getRealImageView { return( _imageView ); }
- (id <LynkeosProcessableItem>) highlightedItem { return( [_window highlightedItem] ); }
- (void) highlightItem :(id <LynkeosProcessableItem>)item { [_window highlightItem:item]; }
- (void) setListSelectionAuthorization: (BOOL)auth { ; }
- (void) setDataModeSelectionAuthorization: (BOOL)auth { ; }
- (void) setItemSelectionAuthorization: (BOOL)auth { ; }
- (void) setItemEditionAuthorization: (BOOL)auth { ; }
- (void) reloadData { [_window reloadData]; }
- (void) setProcessing:(Class)c andIdent:(NSString*)ident
authorization:(BOOL)auth
{ [_window setProcessing:c andIdent:ident authorization:auth]; }
- (void) getItemToProcess:(LynkeosProcessableImage**)item
andParameter:(LynkeosImageProcessingParameter**)param
forView:(id <LynkeosProcessingView>)sender
{
NSUInteger idx = [_procViewControllers indexOfObject:sender];
NSAssert( idx != NSNotFound, @"Calling process view not in the stack" );
*item = _item;
*param = [_stack objectAtIndex:idx];
if ( [*param isEqual:[NSNull null]] )
*param = nil;
}
- (void) saveImage:(LynkeosStandardImageBuffer*)image
withBlack:(double*)black white:(double*)white gamma:(double*)gamma
{ [_window saveImage:image withBlack:black white:white gamma:gamma]; }
- (LynkeosStandardImageBuffer*) loadImage
{ return( [_window loadImage] ); }
- (void)reloadItem:(id<LynkeosProcessableItem>)item { [_window reloadItem:item]; }
#pragma mark = LynkeosViewDocument protocol
- (void) startProcess: (Class) processingClass
withEnumerator: (NSEnumerator*)enumerator
parameters:(id <NSObject>)params
{ [self doesNotRecognizeSelector:_cmd]; }
- (void) startProcess: (Class) processingClass
forItem: (LynkeosProcessableImage*)item
parameters: (LynkeosImageProcessingParameter*)params
{
NSAssert( item == _item, @"Inconsistent item for processing");
// Just pass it on to the document
[_document startProcess:processingClass
forItem:item
parameters:params];
}
- (void) stopProcess { [_document stopProcess]; }
- (oneway void) itemWasProcessed:(id <LynkeosProcessableItem>)item
{ [self doesNotRecognizeSelector:_cmd]; }
- (id <LynkeosImageList>) imageList { return( [_document imageList] ); }
- (id <LynkeosImageList>) darkFrameList { return( [_document darkFrameList] ); }
- (id <LynkeosImageList>) flatFieldList { return( [_document flatFieldList] ); }
- (id <LynkeosImageList>) currentList { return( [_document currentList] ); }
- (ListMode_t) listMode { return( [_document listMode] ); }
- (DataMode_t) dataMode { return( [_document dataMode] ); }
- (id <LynkeosProcessingParameter>) getProcessingParameterWithRef:(NSString*)ref
forProcessing:(NSString*)processing
{
return( [_document getProcessingParameterWithRef:ref
forProcessing:processing
goUp:YES] );
}
- (id <LynkeosProcessingParameter>) getProcessingParameterWithRef:(NSString*)ref
forProcessing:(NSString*)processing
goUp:(BOOL)goUp
{
return( [_document getProcessingParameterWithRef:ref
forProcessing:processing
goUp:goUp] );
}
- (void) setProcessingParameter:(id <LynkeosProcessingParameter>)parameter
withRef:(NSString*)ref
forProcessing:(NSString*)processing
{
[_document setProcessingParameter:parameter
withRef:ref
forProcessing:processing];
}
- (void) setListMode :(ListMode_t)mode
{ [_document setListMode:mode]; }
- (void) setDataMode:(DataMode_t)mode
{ [_document setDataMode:mode]; }
#pragma mark = LynkeosProcessingView protocol
+ (BOOL) isStandardProcessingViewController { return(YES); }
+ (ProcessingViewKind_t) processingViewKindForConfig:(id <NSObject>)config
{
NSAssert( config == nil,
@"Process stack manager does not support configuration" );
return(OtherProcessingKind);
}
+ (BOOL) isViewControllingProcess:(Class)processingClass
withConfig:(id <NSObject>*)config
{
*config = nil;
return( NO );
}
+ (void) getProcessingTitle:(NSString**)title
toolTitle:(NSString**)tooTitle
key:(NSString**)key
icon:(NSImage**)icon
tip:(NSString**)tip
forConfig:(id <NSObject>)config
{
NSAssert( config == nil,
@"Process stack manager does not support configuration" );
*title = NSLocalizedString(@"ProcessStackMenu",
@"Process stack menu title");
*tooTitle = NSLocalizedString(@"ProcessStackTool",
@"Process stack tool title");
*key = @"p";
*icon = [NSImage imageNamed:@"ProcessStack"];
*tip = NSLocalizedString(@"ProcessStackTip",@"Process Stack tooltip");
}
+ (unsigned int) allowedDisplaysForConfig:(id <NSObject>)config
{
NSAssert( config == nil,
@"Process stack manager does not support configuration" );
return( BottomTab|BottomTab_NoList|SeparateView|SeparateView_NoList );
}
- (NSView*) getProcessingView { return( _view ); }
- (LynkeosProcessingViewFrame_t) preferredDisplay { return( SeparateView ); }
- (void) setActiveView:(BOOL)active
{
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
if ( active )
{
// Authorize the selections
[_window setListSelectionAuthorization:NO];
[_window setDataModeSelectionAuthorization:YES];
[_window setItemSelectionAuthorization:YES];
[_window setItemEditionAuthorization:NO];
// Delete the selection rectangle
[_imageView removeAllSelections];
[_imageView setSelectionMode:NoSelection];
// Register for notifications
[center addObserver:self
selector:@selector(hilightChange:)
name: LynkeosHilightedItemDidChangeNotification
object:_window];
[center addObserver:self
selector:@selector(processStarted:)
name: LynkeosProcessStartedNotification
object:_document];
[center addObserver:self
selector:@selector(processEnded:)
name: LynkeosProcessEndedNotification
object:_document];
[center addObserver:self
selector:@selector(processStackEnded:)
name: LynkeosProcessStackEndedNotification
object:_document];
[center addObserver:self
selector:@selector(hilightChange:)
name: LynkeosDataModeChangeNotification
object:_document];
// Synchronize the display
[self hilightChange:nil];
}
else
{
// Stop receiving notifications
[center removeObserver:self];
// And get rid of all the processing controllers
[self tidyStack];
[_view reloadData];
}
}
- (id <LynkeosProcessingParameter>) getCurrentParameters
{
// This is not a real processing view
[self doesNotRecognizeSelector:_cmd];
return( nil );
}
- (Class) processingClass
{
// This is not a real processing view
[self doesNotRecognizeSelector:_cmd];
return( nil );
}
@end
|