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
|
/***************************************************************************
SonagramWindow.h - window for showing a sonagram
-------------------
begin : Fri Jul 28 2000
copyright : (C) 2000 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef SONAGRAM_WINDOW_H
#define SONAGRAM_WINDOW_H
#include "config.h"
#include <QTimer>
#include <KMainWindow>
class QImage;
/** height of the overview widget in a sonagram window [pixels] */
#define SONAGRAM_OVERVIEW_HEIGHT 30
namespace Kwave
{
class ImageView;
class ScaleWidget;
/**
* Window for displaying a sonagram with scale, status bar and
* a small menu.
*/
class SonagramWindow: public KMainWindow
{
Q_OBJECT
public:
/**
* Constructor.
* @param parent the parent widget
* @param name reference to the initial name of the signal (used for
* setting the window title, might be an empty string)
*/
SonagramWindow(QWidget *parent, const QString &name);
/**
* Destructor.
*/
~SonagramWindow() override;
/**
* Sets a new sonagram image to display.
* @param image the bitmap with the sonagram
*/
void setImage(QImage image);
/**
* Sets a new overview bitmap for the signal space
*/
void setOverView(const QImage &image);
/**
* Inserts a slice into the current image. If the slice contains more
* data than fits into the image, the remaining rest will be ignored,
* if less data is present, it will be filled with 0xFF. The previous
* content of the image slice will be cleared or updated in all cases.
* @param slice_nr index of the slice (horizontal position) [0..n-1]
* @param slice array with the byte data
*/
void insertSlice(const unsigned int slice_nr, const QByteArray &slice);
public slots:
/** closes the sonagram window */
void close();
/** not implemented yet */
void save();
/** not implemented yet */
void load();
/** not implemented yet */
void toSignal();
/**
* Sets the name of the signal / title of the window
* @param name the name of the signal
*/
void setName(const QString &name);
/**
* Sets a new color mode. If the mode is different from the current
* one, the image will be automatically refreshed.
*/
void setColorMode(int mode);
/**
* Used to update the display of the current position of the cursor.
* Position is given in coordinates of the QImage.
* @param pos current cursor position
*/
void cursorPosChanged(const QPoint pos);
/**
* sets information about the number of fft points (needed
* for translating cursor coordinates into time)
* @param points the number of fft points [1...]
*/
void setPoints(unsigned int points);
/**
* sets information about the sample rate (needed for
* translating cursor coordinates into time
* @param rate sample rate in samples per second
*/
void setRate(double rate);
private slots:
/** refreshes the image, connected to m_refresh_timer */
void refresh_view();
protected:
/** updates the scale widgets */
void updateScaleWidgets();
/**
* adjust the brightness so that the color space is optimally
* used and the user doesn't just see a white image
*/
void adjustBrightness();
/**
* Translates pixel coordinates relative to the lower left corner
* of the QImage into time and frequency coordinates of the signal.
* This requires a valid sample rate to be set, otherwise the
* time coordinate will be returned as zero.
* @param p a QPoint with the pixel position, upper left is 0/0
* @param ms pointer to a double that receives the time coordinate
* in milliseconds (can be 0 to ignore)
* @param f pointer to a double that receives the frequency
* coordinate (can be 0 to ignore)
*/
void translatePixels2TF(const QPoint p, double *ms, double *f);
private:
/** status bar label for time */
QLabel *m_status_time;
/** status bar label for frequency */
QLabel *m_status_freq;
/** status bar label for amplitude */
QLabel *m_status_ampl;
/** the QImage to be displayed */
QImage m_image;
/**
* the color mode to be used. Currently only 0 (black/white)
* and 1 (rainbow colors) are used.
*/
int m_color_mode;
/** an ImageView to display the m_image and fit it into our window */
Kwave::ImageView *m_view;
/** short overview over the signal */
Kwave::ImageView *m_overview;
/** number of fft points */
unsigned int m_points;
/** sample rate, needed for translating pixel coordinates */
double m_rate;
/** widget for the scale on the time (x) axis */
Kwave::ScaleWidget *m_xscale;
/** widget for the scale on the frequency (y) axis */
Kwave::ScaleWidget *m_yscale;
/** timer used for refreshing the view from time to time */
QTimer m_refresh_timer;
/** histogram of color indices, used for auto-contrast */
unsigned int m_histogram[256];
};
}
#endif // _SONOGRAM_WINDOW_H_
//***************************************************************************
//***************************************************************************
|