mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 09:07:27 -05:00
Resolves issue with spectral and waterfall alignment with frequency
overlay. Minor edits to MPT and P25 config editors Resolved issue with channels not accepting channel config changes between restarts (processing chain was not being deleted) Minor edits to P25 decoder state
This commit is contained in:
@@ -446,16 +446,22 @@ public class OverlayPanel extends JPanel
|
||||
*/
|
||||
private double getAxisFromFrequency( long frequency )
|
||||
{
|
||||
//Determine frequency offset from middle
|
||||
double frequencyOffset = frequency - getMinDisplayFrequency();
|
||||
double screenWidth = (double)getSize().getWidth();
|
||||
|
||||
//Determine ratio of offset to bandwidth
|
||||
double pixelsPerBin = screenWidth / (double)mDFTSize.getSize();
|
||||
|
||||
double pixelOffsetToMinDisplayFrequency = pixelsPerBin * 2.0d;
|
||||
|
||||
//Calculate frequency offset from the min frequency
|
||||
double frequencyOffset = (double)( frequency - getMinDisplayFrequency() );
|
||||
|
||||
//Determine ratio of frequency offset to overall bandwidth
|
||||
double ratio = frequencyOffset / (double)getDisplayBandwidth();
|
||||
|
||||
//Calculate offset against the total width
|
||||
double xOffset = (double)getSize().getWidth() * ratio;
|
||||
//Apply the ratio to the screen width minus 1 bin width
|
||||
double screenOffset = screenWidth * ratio;
|
||||
|
||||
return xOffset;
|
||||
return pixelOffsetToMinDisplayFrequency + screenOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -749,9 +755,9 @@ public class OverlayPanel extends JPanel
|
||||
|
||||
private long getMinDisplayFrequency()
|
||||
{
|
||||
double bandwidthPerBin = (double)mBandwidth / (double)( mDFTSize.getSize() - 1 );
|
||||
double bandwidthPerBin = (double)mBandwidth / (double)( mDFTSize.getSize() );
|
||||
|
||||
return getMinFrequency() + (int)( mDFTZoomWindowOffset * bandwidthPerBin );
|
||||
return getMinFrequency() + (int)( ( mDFTZoomWindowOffset ) * bandwidthPerBin );
|
||||
}
|
||||
|
||||
private long getMaxDisplayFrequency()
|
||||
|
||||
@@ -214,14 +214,12 @@ public class SpectrumPanel extends JPanel
|
||||
float insideHeight = size.height - mSpectrumInset;
|
||||
|
||||
float scalor = insideHeight / -mDBScale;
|
||||
|
||||
float insideWidth = size.width;
|
||||
|
||||
int binCount = bins.length;
|
||||
/* Calculate based on bin size - 1, since bin 0 is rendered at zero
|
||||
* and the last bin is rendered at the width */
|
||||
float binSize = (float)size.width / ( (float)( bins.length ) );
|
||||
|
||||
float binSize = insideWidth / ( binCount );
|
||||
|
||||
for( int x = 0; x < binCount; x++ )
|
||||
for( int x = 0; x < bins.length; x++ )
|
||||
{
|
||||
float height;
|
||||
|
||||
@@ -236,8 +234,10 @@ public class SpectrumPanel extends JPanel
|
||||
{
|
||||
height = 0;
|
||||
}
|
||||
|
||||
float xAxis = (float)x * binSize;
|
||||
|
||||
spectrumShape.lineTo( ( x * binSize ), height );
|
||||
spectrumShape.lineTo( xAxis, height );
|
||||
}
|
||||
}
|
||||
//Otherwise show an empty spectrum
|
||||
|
||||
@@ -261,20 +261,24 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
|
||||
* @param multiplier - current zoom multiplier
|
||||
* @return x-axis pixel offset
|
||||
*/
|
||||
private int getPixelOffset( int multiplier )
|
||||
private double getPixelOffset( int multiplier )
|
||||
{
|
||||
int offset = 0;
|
||||
double offset = 0;
|
||||
|
||||
if( mZoom != 0 )
|
||||
{
|
||||
int zoomWidth = getWidth() * multiplier;
|
||||
double binPixelWidth = getBinPixelWidth( multiplier );
|
||||
|
||||
offset = -(int)( (double)zoomWidth / (double)mDFTSize *
|
||||
(double)( mDFTZoomWindowOffset ) );
|
||||
offset = -binPixelWidth * (double)( mDFTZoomWindowOffset );
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
private double getBinPixelWidth( int multiplier )
|
||||
{
|
||||
return ( (double)getWidth() * (double)multiplier ) / (double)mDFTSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the screen at each refresh
|
||||
@@ -283,15 +287,20 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
|
||||
{
|
||||
int multiplier = getZoomMultiplier();
|
||||
|
||||
int offset = getPixelOffset( multiplier );
|
||||
double binPixelWidth = getBinPixelWidth( multiplier );
|
||||
|
||||
int offset = (int)( getPixelOffset( multiplier ) - binPixelWidth );
|
||||
|
||||
// mLog.debug( "Offset:" + offset + " Pixel Offset:" + getPixelOffset( multiplier ) + " bin pixel width:" + binPixelWidth );
|
||||
|
||||
g.drawImage( mWaterfallImage,
|
||||
offset,
|
||||
0,
|
||||
getWidth() * multiplier,
|
||||
( getWidth() * multiplier ) + (int)binPixelWidth,
|
||||
mImageHeight,
|
||||
this );
|
||||
|
||||
|
||||
|
||||
Graphics2D graphics = (Graphics2D) g;
|
||||
|
||||
graphics.setColor( mColorSpectrumCursor );
|
||||
|
||||
Reference in New Issue
Block a user