Update of /cvsroot/scopeapp/scopeapp/src
In directory usw-pr-cvs1:/tmp/cvs-serv4168
Added Files:
SpectrumView.h SpectrumView.m
Log Message:
Initial checkin of (incomplete) spectrum view code (currently skeleton only)
--- NEW FILE: SpectrumView.h ---
//
// SpectrumView.h
// MacCRO X
//
// Created by Philip Derrin on Sun Jul 14 2002.
// Copyright (c) 2002 Philip Derrin.
//
// This file is part of MacCRO X.
//
// MacCRO X 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.
//
// MacCRO X 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 MacCRO X; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// $Header: /cvsroot/scopeapp/scopeapp/src/SpectrumView.h,v 1.1 2002/10/29 04:24:46 narge Exp $
//
#import <AppKit/AppKit.h>
#import "TraceView.h"
@interface SpectrumView : TraceView {
// **** Controls ****
// Frequency scale
IBOutlet NSTextField* myFreqFrom;
IBOutlet NSTextField* myFreqTo;
IBOutlet NSButton* myFreqIsLogCheckbox;
// Amplitude scale
IBOutlet NSTextField* myAmpFrom;
IBOutlet NSTextField* myAmpTo;
IBOutlet NSButton* myAmpIsLogCheckbox;
IBOutlet NSPopupMenu* myAmpUnitsMenu;
// Accumulation settings
IBOutlet NSButton* myAccumulateCheckbox;
IBOutlet NSButton* myAccumulateReset;
// display settings
IBOutlet NSButton* myShowTimeCheckbox;
IBOutlet NSButton* myShowScaleCheckbox;
@protected
// spectrum analyser settings
double myXScale, myYScale;
double myGain;
BOOL myXIsLog, myYIsLog;
BOOL myShowTime, myShowScales;
}
-(IBAction) changedFreqScale: (id) sender;
-(IBAction) changedVoltScale: (id) sender;
-(IBAction) changedAccumulationSettings: (id) sender;
-(IBAction) changedDisplaySettings: (id) sender;
-(id) updateControls;
@end
--- NEW FILE: SpectrumView.m ---
//
// SpectrumView.m
// MacCRO X
//
// Created by Philip Derrin on Sun Jul 14 2002.
// Copyright (c) 2002 Philip Derrin.
//
// This file is part of MacCRO X.
//
// MacCRO X 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.
//
// MacCRO X 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 MacCRO X; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// $Header: /cvsroot/scopeapp/scopeapp/src/SpectrumView.m,v 1.1 2002/10/29 04:24:46 narge Exp $
//
#import "SpectrumView.h"
static double gVoltScales[7] = {0.01,0.02,0.05,0.1,0.2,0.5,1};
@implementation SpectrumView
- (void)awakeFromNib {
// FIXME testing hack - implement updateControls
myGain = 1.0;
myDataWanted[0] = 882; // FIXME add a control for this
myDataWanted[1] = 882; // FIXME add a control for this
myXScale = 1;
myYScale = 1;
[super awakeFromNib];
}
- (void) dealloc
{
[self stopDrawing];
/* currently nothing to deallocate */
[super dealloc];
}
-(IBAction) changedScale: (id) sender
{
if(sender == myYScaleSlider)
{
// if the scale slider moved, zero the fine slider
[myYFineSlider setIntValue: 0];
}
if(sender == myXScaleSlider)
{
[myXFineSlider setIntValue: 0];
}
[self stopDrawing];
myXScale = gVoltScales[[myXScaleSlider intValue]-1] *
pow(2.0, [myXFineSlider doubleValue]);
myYScale = gVoltScales[[myYScaleSlider intValue]-1] *
pow(2.0, [myYFineSlider doubleValue]);
[self startDrawing];
}
-(IBAction) changedDisplaySettings: (id) sender
{
myShowTime = [myShowTimeCheckbox intValue];
myShowScales = [myShowScaleCheckbox intValue];
}
// FIXME implement this function to set the controls appropriately from
// default / saved values
-(id) updateControls { return self; }
- (id)updateDisplay: (int) inTrace
{
double theScaleFactor[2];
float curX, curY;
unsigned long curSample;
theScaleFactor[0] = myGain * 1 / myXScale;
theScaleFactor[1] = myGain * 1 / myYScale;
[myDisplayLock lock];
[myBezierPaths[0] removeAllPoints];
// FIXME do fft & display data
#error
[myDisplayLock unlock];
return self;
}
@end
|