/* InspectBase.h		by Paul Kunz	December 1991
 * Base class for Inspectors of Tuples and Plots.
 *
 * $Id: InspectBase.m,v 1.16 1992/04/25 18:56:24 pfkeb Rel $
 *
 * Copyright (C)  1991  The Board of Trustees of
 * The Leland Stanford Junior University.  All Rights Reserved.
 */

#import "InspectBase.h"

#import "DrawDocument.h"
#import "HDraw.h"
#import "HGraphicView.h"
#import "NewInspector.h"
#import "Overlay.h"
#import "Plot.h"

@implementation InspectBase

- initInspFor:aDraw
{
    self = [super init];
    hDraw = aDraw;
    theInspector = [hDraw newInspector];
    return self;
}

- windowDidUpdate:sender
{
    [self load:[[hDraw currentDocument] view]];
    return self;
}
- load:aView
{
    id		graphic;
    BOOL        test;
    
    graphicView = aView;
    if ( !graphicView ) {
        selectedPlot = nil;	/* reset so that updateView can test it */
	firstPlot = nil;
	[self setTuple:NULL];
	return self;
    }
    test = [[graphicView window] isKeyWindow];
    if (!test)
	return self;	/* ignore events other than from main window */

    if ( [graphicView hasEmptySelection] ) {
	selectedPlot = nil;
	firstPlot = nil;
	[self updateEmptySelection];
	return self;
   }
    graphic = [graphicView firstPlot];
    if (!graphic) {
        [ self updateMultiSelection];
	return self;
    }
    selectedPlot = graphic;
    firstPlot = selectedPlot;
    [self updateView];
    return self;
}
- firstPlot
{
    if ( [graphicView hasEmptySelection] ) {
        return nil;
    }
    return firstPlot;
}

/* Methods to be over-ridden by derived class */
- updateView
{
    return self; /* to be over-ridden by derived class */
}
- updateEmptySelection
{
    return self; /* to be over-ridden by derived class */
}
- updateMultiSelection
{
    return self;
}
- setTuple:(ntuple) aTuple
{
    return self; /* to be over-ridden by derived class */
}
@end
