[installation] Init with inital config for global
This commit is contained in:
70
include/gempa/gui/spectrogram/image.h
Normal file
70
include/gempa/gui/spectrogram/image.h
Normal file
@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2011 by gempa GmbH
|
||||
*
|
||||
* Author: Jan Becker
|
||||
* Email: jabe@gempa.de
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef __GEMPA_SPECTROGRAM_IMAGE_H__
|
||||
#define __GEMPA_SPECTROGRAM_IMAGE_H__
|
||||
|
||||
|
||||
#include <seiscomp/gui/core/gradient.h>
|
||||
#include <gempa/utils/lut.h>
|
||||
#include <gempa/gui/api.h>
|
||||
|
||||
#include <QImage>
|
||||
|
||||
|
||||
namespace Gempa {
|
||||
namespace Gui {
|
||||
|
||||
|
||||
template <typename T> class Spectrogram;
|
||||
|
||||
typedef Gempa::Utils::LUT<double,QRgb> ColorLUT;
|
||||
|
||||
template <int N>
|
||||
class StaticColorLUT : public Gempa::Utils::StaticLUT<double,QRgb,N> {
|
||||
public:
|
||||
StaticColorLUT() {}
|
||||
StaticColorLUT(const Seiscomp::Gui::Gradient &gradient) {
|
||||
generateFrom(gradient);
|
||||
}
|
||||
|
||||
public:
|
||||
bool setRangeFrom(const Seiscomp::Gui::Gradient &gradient) {
|
||||
if ( gradient.empty() ) return false;
|
||||
|
||||
double lower = gradient.begin().key();
|
||||
double upper = (--gradient.end()).key();
|
||||
Gempa::Utils::StaticLUT<double,QRgb,N>::setRange(lower, upper);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void generateFrom(const Seiscomp::Gui::Gradient &gradient) {
|
||||
if ( !setRangeFrom(gradient) ) return;
|
||||
for ( int i = 0; i < N; ++i )
|
||||
Utils::StaticLUT<double,QRgb,N>::_staticLUT[i] =
|
||||
gradient.colorAt(Utils::StaticLUT<double,QRgb,N>::indexToKey(i)).rgba();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool generateImageCW(QImage &img, const Spectrogram<T> *spec, const ColorLUT *lut,
|
||||
int width, int height, int columnOffset = 0,
|
||||
int columnWidth = -1);
|
||||
|
||||
template <typename T>
|
||||
bool generateImagePPS(QImage &img, const Spectrogram<T> *spec, const ColorLUT *lut,
|
||||
int width, int height, int columnOffset = 0,
|
||||
double pixelPerSecond = 1.0);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
179
include/gempa/gui/spectrogram/spectrogram.h
Normal file
179
include/gempa/gui/spectrogram/spectrogram.h
Normal file
@ -0,0 +1,179 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2011 by gempa GmbH
|
||||
*
|
||||
* Author: Jan Becker
|
||||
* Email: jabe@gempa.de
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef GEMPA_SPECTROGRAM_SPECTROGRAM_H
|
||||
#define GEMPA_SPECTROGRAM_SPECTROGRAM_H
|
||||
|
||||
|
||||
#include <seiscomp/core/typedarray.h>
|
||||
#include <seiscomp/core/record.h>
|
||||
#include <seiscomp/core/version.h>
|
||||
#include <seiscomp/math/filter.h>
|
||||
|
||||
|
||||
namespace Gempa {
|
||||
namespace Gui {
|
||||
|
||||
|
||||
template <typename T> class Spectrogram;
|
||||
template <typename T> class RecordSpectrogram;
|
||||
|
||||
typedef Spectrogram<float> SpectrogramF;
|
||||
TYPEDEF_SMARTPOINTER(SpectrogramF);
|
||||
TYPEDEF_CONST_SMARTPOINTER(SpectrogramF);
|
||||
|
||||
typedef Spectrogram<double> SpectrogramD;
|
||||
TYPEDEF_SMARTPOINTER(SpectrogramD);
|
||||
TYPEDEF_CONST_SMARTPOINTER(SpectrogramD);
|
||||
|
||||
|
||||
struct SpectrogramSettings {
|
||||
enum Unit {
|
||||
Hz,
|
||||
Seconds
|
||||
};
|
||||
|
||||
SpectrogramSettings();
|
||||
|
||||
bool fromString(const std::string &def);
|
||||
|
||||
double bandStart; // Start of (freq or period) band
|
||||
double bandEnd; // End of (freq or period) band
|
||||
Unit bandUnit; // Unit of start/end (frequenz or period)
|
||||
|
||||
int ranges; // Number of ranges to subdivide the band
|
||||
int bands; // Number of overlapping bands
|
||||
|
||||
bool logarithmic; // logarithmic ranges
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
class Spectrogram : public Seiscomp::Core::BaseObject {
|
||||
public:
|
||||
typedef Seiscomp::TypedArray<T> DataArray;
|
||||
#if SC_API_VERSION < SC_API_VERSION_CHECK(17,0,0)
|
||||
typedef typename Seiscomp::Core::SmartPointer<DataArray>::Impl DataArrayPtr;
|
||||
#else
|
||||
typedef Seiscomp::Core::SmartPointer<DataArray> DataArrayPtr;
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
Spectrogram();
|
||||
Spectrogram(const SpectrogramSettings &settings);
|
||||
~Spectrogram();
|
||||
|
||||
|
||||
public:
|
||||
void init(const SpectrogramSettings &settings);
|
||||
void initFrom(const Spectrogram<T> &other);
|
||||
|
||||
void setMaximumSeconds(double secs);
|
||||
|
||||
void setSamplingFrequency(double fsamp);
|
||||
double samplingFrequency() const;
|
||||
|
||||
void pushData(int n, const T *data);
|
||||
|
||||
void reset();
|
||||
|
||||
virtual void trimData(int start, int end, int *cutOffset = NULL);
|
||||
|
||||
const T *data() const;
|
||||
int columns() const;
|
||||
int rows() const;
|
||||
double minimum() const;
|
||||
double maximum() const;
|
||||
bool isNull() const;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void resetted();
|
||||
|
||||
|
||||
private:
|
||||
void resetData();
|
||||
void clearData();
|
||||
|
||||
void initFilters();
|
||||
void addFilter(double loFreq, double hiFreq, double maxPeriod);
|
||||
|
||||
|
||||
protected:
|
||||
typedef SpectrogramSettings Settings;
|
||||
typedef Seiscomp::Math::Filtering::InPlaceFilter<T> Filter;
|
||||
std::vector<Filter*> _filters;
|
||||
|
||||
T *_data;
|
||||
int _maxColumns;
|
||||
int _columns;
|
||||
int _startColumn;
|
||||
int _endColumn;
|
||||
int _rows;
|
||||
|
||||
double _fsamp;
|
||||
double _maxSeconds;
|
||||
|
||||
double _min, _max;
|
||||
|
||||
Settings _settings;
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef RecordSpectrogram<float> RecordSpectrogramF;
|
||||
TYPEDEF_SMARTPOINTER(RecordSpectrogramF);
|
||||
TYPEDEF_CONST_SMARTPOINTER(RecordSpectrogramF);
|
||||
|
||||
typedef RecordSpectrogram<double> RecordSpectrogramD;
|
||||
TYPEDEF_SMARTPOINTER(RecordSpectrogramD);
|
||||
TYPEDEF_CONST_SMARTPOINTER(RecordSpectrogramD);
|
||||
|
||||
|
||||
template <typename T>
|
||||
class RecordSpectrogram : public Spectrogram<T> {
|
||||
public:
|
||||
typedef Spectrogram<T> Base;
|
||||
|
||||
RecordSpectrogram();
|
||||
RecordSpectrogram(const SpectrogramSettings &settings);
|
||||
|
||||
|
||||
public:
|
||||
const Seiscomp::Core::Time &startTime() const;
|
||||
const Seiscomp::Core::Time &endTime() const;
|
||||
|
||||
int mapTime(const Seiscomp::Core::Time &t) const;
|
||||
|
||||
void feed(const Seiscomp::Record *rec);
|
||||
|
||||
virtual void trimData(int start, int end, int *cutOffset = NULL);
|
||||
void trim(const Seiscomp::Core::Time &start, const Seiscomp::Core::Time &end);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void resetted();
|
||||
|
||||
|
||||
private:
|
||||
bool _initialized;
|
||||
Seiscomp::Core::Time _startTime;
|
||||
Seiscomp::Core::Time _endTime;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#include <gempa/gui/spectrogram/spectrogram.ipp>
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
41
include/gempa/gui/spectrogram/spectrogram.ipp
Normal file
41
include/gempa/gui/spectrogram/spectrogram.ipp
Normal file
@ -0,0 +1,41 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2011 by gempa GmbH
|
||||
*
|
||||
* Author: Jan Becker
|
||||
* Email: jabe@gempa.de
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline double Spectrogram<T>::samplingFrequency() const {
|
||||
return _fsamp;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline const T *Spectrogram<T>::data() const {
|
||||
return _data;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline int Spectrogram<T>::columns() const {
|
||||
return _columns;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline int Spectrogram<T>::rows() const {
|
||||
return _rows;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline double Spectrogram<T>::minimum() const {
|
||||
return _min;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline double Spectrogram<T>::maximum() const {
|
||||
return _max;
|
||||
}
|
||||
116
include/gempa/gui/spectrogram/spectrogramrecordwidget.h
Normal file
116
include/gempa/gui/spectrogram/spectrogramrecordwidget.h
Normal file
@ -0,0 +1,116 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2011 by gempa GmbH
|
||||
*
|
||||
* Author: Jan Becker
|
||||
* Email: jabe@gempa.de
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef __GEMPA_SPECTROGRAM_SPECTROGRAMRECORDWIDGET_H__
|
||||
#define __GEMPA_SPECTROGRAM_SPECTROGRAMRECORDWIDGET_H__
|
||||
|
||||
|
||||
#include <seiscomp/gui/core/recordwidget.h>
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <gempa/gui/spectrogram/spectrogram.h>
|
||||
#endif
|
||||
#include <gempa/gui/spectrogram/image.h>
|
||||
|
||||
|
||||
// Required for g++ 4.4.7
|
||||
#if SC_API_VERSION >= SC_API_VERSION_CHECK(13,0,0)
|
||||
using Seiscomp::Core::intrusive_ptr_release;
|
||||
#endif
|
||||
|
||||
|
||||
namespace Gempa {
|
||||
namespace Gui {
|
||||
|
||||
|
||||
class SpectrogramRecordWidget : public Seiscomp::Gui::RecordWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SpectrogramRecordWidget(QWidget *parent=0);
|
||||
SpectrogramRecordWidget(const Seiscomp::DataModel::WaveformStreamID& streamID,
|
||||
QWidget *parent=0);
|
||||
|
||||
|
||||
public:
|
||||
void setSpectrogramSettings(double fromPeriod, double toPeriod,
|
||||
int ranges, int bandCount);
|
||||
void setSpectrogramSettings(const SpectrogramSettings &settings);
|
||||
|
||||
void setColorLUT(const ColorLUT *lut);
|
||||
void setSpectrogramSlot(int slot);
|
||||
|
||||
int spectrogramSlot() const { return _specSlot; }
|
||||
|
||||
void useFilteredRecords(bool);
|
||||
bool filteredRecordsUsed() const { return _useFilteredRecords; }
|
||||
|
||||
void fed(int slot, const Seiscomp::Record *rec);
|
||||
|
||||
void clearSpectrogramImages();
|
||||
|
||||
double minimumSpecValue() const { return _range.first; }
|
||||
double maximumSpecValue() const { return _range.second; }
|
||||
|
||||
bool isSpectrogramEnabled() const;
|
||||
bool isSpectrogramDisplayEnabled() const;
|
||||
|
||||
|
||||
public slots:
|
||||
//! Force a complete update of the spectrogram
|
||||
void recordsChanged();
|
||||
|
||||
void setSpectrogramEnabled(bool);
|
||||
void setSpectrogramDisplayEnabled(bool);
|
||||
|
||||
void setDrawSpectrogramInFront(bool);
|
||||
|
||||
|
||||
protected:
|
||||
void changedRecords(int slot, Seiscomp::RecordSequence *seq);
|
||||
void customPaintTracesBegin(QPainter &painter);
|
||||
void customPaintTracesEnd(QPainter &painter);
|
||||
|
||||
virtual void drawSpectrogram(QPainter &painter);
|
||||
|
||||
|
||||
private:
|
||||
void init();
|
||||
void feedSpectrogram(int slot, const Seiscomp::Record *rec);
|
||||
|
||||
|
||||
private:
|
||||
struct SpectrogramItem {
|
||||
SpectrogramItem() : startIndex(-1), scale(0) {}
|
||||
SpectrogramItem(RecordSpectrogramF *s) : spec(s), startIndex(-1), scale(0) {}
|
||||
|
||||
RecordSpectrogramFPtr spec;
|
||||
QImage img;
|
||||
int startIndex;
|
||||
double scale;
|
||||
};
|
||||
|
||||
using SpectrogramSequence = std::deque<SpectrogramItem>;
|
||||
SpectrogramSequence _specs;
|
||||
QPair<double,double> _range;
|
||||
const ColorLUT *_colorLUT;
|
||||
|
||||
bool _drawSpecOnTop;
|
||||
bool _enableSpecDisplay;
|
||||
bool _enableSpec;
|
||||
bool _useFilteredRecords;
|
||||
|
||||
SpectrogramSettings _specSettings;
|
||||
int _specSlot;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user