245 lines
7.3 KiB
C++
245 lines
7.3 KiB
C++
#include "gtl_gui_apfc_chart.h"
|
|
|
|
namespace gtl {
|
|
namespace gui {
|
|
|
|
apfc_chart::apfc_chart(QWidget* parent)
|
|
: chart(parent)
|
|
, _afc(0)
|
|
, _pfc(0)
|
|
, _frequency(200)
|
|
, _resolution(10)
|
|
, _window(5)
|
|
, _lines(20)
|
|
, _average(1)
|
|
, _overlap(0)
|
|
, _threshold(50)
|
|
{
|
|
set_axis_y_mode(true);
|
|
}
|
|
|
|
apfc_chart::~apfc_chart()
|
|
{
|
|
if(_apfc)
|
|
delete _apfc;
|
|
}
|
|
|
|
void apfc_chart::set_x_log(bool value)
|
|
{
|
|
|
|
}
|
|
|
|
chart_series *apfc_chart::create_series(analog_data *ai)
|
|
{
|
|
|
|
if(!_series.size())
|
|
_ref = ai;
|
|
|
|
if(_series.size() == 1 && static_cast<chart_series*>(_series[0])->ad() != _ref)
|
|
_ref = _data;
|
|
|
|
_data = ai;
|
|
|
|
while(_series.size())
|
|
remove_series(static_cast<chart_series*>(_series.back()));
|
|
|
|
|
|
if(!_apfc)
|
|
{
|
|
_apfc = new gtl::math::apfc(_ref, _data);
|
|
connect(_apfc, >l::math::apfc::afc_changed, this, >l::gui::apfc_chart::afc_changed);
|
|
connect(_apfc, >l::math::apfc::pfc_changed, this, >l::gui::apfc_chart::pfc_changed);
|
|
connect(_apfc, >l::math::apfc::frequency_changed, this, >l::gui::apfc_chart::frequency_changed);
|
|
connect(_apfc, >l::math::apfc::resolution_changed, this, >l::gui::apfc_chart::resolution_changed);
|
|
connect(_apfc, >l::math::apfc::window_changed, this, >l::gui::apfc_chart::window_changed);
|
|
connect(_apfc, >l::math::apfc::lines_changed, this, >l::gui::apfc_chart::lines_changed);
|
|
connect(_apfc, >l::math::apfc::average_changed, this, >l::gui::apfc_chart::average_changed);
|
|
connect(_apfc, >l::math::apfc::overlap_changed, this, >l::gui::apfc_chart::overlap_changed);
|
|
connect(_apfc, >l::math::apfc::threshold_changed, this, >l::gui::apfc_chart::threshold_changed);
|
|
|
|
_apfc->set_average(_average);
|
|
_apfc->set_overlap(_overlap);
|
|
_apfc->set_frequency(_frequency);
|
|
_apfc->set_lines(_lines);
|
|
_apfc->set_window(static_cast<gtl::math::apfc::windows>(_window));
|
|
_apfc->set_afc(static_cast<gtl::math::apfc::afcs>(_afc));
|
|
_apfc->set_pfc(static_cast<gtl::math::apfc::pfcs>(_pfc));
|
|
_apfc->set_threshold(_threshold);
|
|
}
|
|
_apfc->set_ref(_ref);
|
|
_apfc->set_data(_data);
|
|
|
|
_signals.clear();
|
|
_signals.push_back(_ref->name());
|
|
_signals.push_back(_data->name());
|
|
emit signals_changed(&_signals);
|
|
|
|
|
|
apfc_series *seriesA = new apfc_series(is_updating(), true, _apfc, _ref, _axis_x, _axis_y);
|
|
seriesA->set_name(tr("AFC"));
|
|
add_series(seriesA);
|
|
|
|
apfc_series *series = new apfc_series(is_updating(), false, _apfc, _data, _axis_x, _axis_y);
|
|
series->set_name(tr("PFC"));
|
|
series->update();
|
|
|
|
return series;
|
|
}
|
|
|
|
qreal apfc_chart::threshold() const
|
|
{
|
|
if(_apfc)
|
|
return _apfc->threshold();
|
|
return _threshold;
|
|
}
|
|
|
|
void apfc_chart::set_threshold(qreal newThreshold)
|
|
{
|
|
if (qFuzzyCompare(_threshold, newThreshold))
|
|
return;
|
|
_threshold = newThreshold;
|
|
if(_apfc && _ref && _data)
|
|
_apfc->set_threshold(_threshold);
|
|
}
|
|
|
|
int apfc_chart::afc() const
|
|
{
|
|
if(_apfc)
|
|
return static_cast<int>(_apfc->afc());
|
|
return _afc;
|
|
}
|
|
|
|
void apfc_chart::set_afc(int newAfc)
|
|
{
|
|
if (_afc == newAfc)
|
|
return;
|
|
_afc = newAfc;
|
|
if(_apfc && _ref && _data)
|
|
_apfc->set_afc(static_cast<gtl::math::apfc::afcs>(_afc));
|
|
}
|
|
|
|
int apfc_chart::pfc() const
|
|
{
|
|
if(_apfc)
|
|
return static_cast<int>(_apfc->pfc());
|
|
return _pfc;
|
|
}
|
|
|
|
void apfc_chart::set_pfc(int newPfc)
|
|
{
|
|
if (_pfc == newPfc)
|
|
return;
|
|
_pfc = newPfc;
|
|
if(_apfc && _ref && _data)
|
|
_apfc->set_pfc(static_cast<gtl::math::apfc::pfcs>(_pfc));
|
|
}
|
|
|
|
qreal apfc_chart::frequency() const
|
|
{
|
|
if(_apfc)
|
|
return _apfc->frequency();
|
|
return _frequency;
|
|
}
|
|
|
|
void apfc_chart::set_frequency(qreal newFrequency)
|
|
{
|
|
if (qFuzzyCompare(_frequency, newFrequency))
|
|
return;
|
|
_frequency = newFrequency;
|
|
if(_apfc && _ref && _data)
|
|
_apfc->set_frequency(_frequency);
|
|
}
|
|
|
|
qreal apfc_chart::resolution() const
|
|
{
|
|
if(_apfc)
|
|
return _apfc->resolution();
|
|
return _resolution;
|
|
}
|
|
|
|
void apfc_chart::set_resolution(qreal newResolution)
|
|
{
|
|
if (qFuzzyCompare(_resolution, newResolution))
|
|
return;
|
|
_resolution = newResolution;
|
|
if(_apfc && _ref && _data)
|
|
_apfc->set_resolution(_resolution);
|
|
}
|
|
|
|
int apfc_chart::window() const
|
|
{
|
|
if(_apfc)
|
|
return static_cast<int>(_apfc->window());
|
|
return _window;
|
|
}
|
|
|
|
void apfc_chart::set_window(int newWindow)
|
|
{
|
|
if (_window == newWindow)
|
|
return;
|
|
_window = newWindow;
|
|
if(_apfc && _ref && _data)
|
|
_apfc->set_window(static_cast<gtl::math::apfc::windows>(_window));
|
|
}
|
|
|
|
int apfc_chart::lines() const
|
|
{
|
|
if(_apfc)
|
|
return _apfc->lines();
|
|
return _lines;
|
|
}
|
|
|
|
void apfc_chart::set_lines(int newLines)
|
|
{
|
|
if (_lines == newLines)
|
|
return;
|
|
_lines = newLines;
|
|
if(_apfc && _ref && _data)
|
|
_apfc->set_lines(_lines);
|
|
}
|
|
|
|
int apfc_chart::average() const
|
|
{
|
|
if(_apfc)
|
|
return _apfc->average();
|
|
return _average;
|
|
}
|
|
|
|
void apfc_chart::set_average(int newAverage)
|
|
{
|
|
if (_average == newAverage)
|
|
return;
|
|
_average = newAverage;
|
|
if(_apfc && _ref && _data)
|
|
_apfc->set_average(_average);
|
|
}
|
|
|
|
qreal apfc_chart::overlap() const
|
|
{
|
|
if(_apfc)
|
|
return _apfc->overlap();
|
|
return _overlap;
|
|
}
|
|
|
|
void apfc_chart::set_overlap(qreal newOverlap)
|
|
{
|
|
if (qFuzzyCompare(_overlap, newOverlap))
|
|
return;
|
|
_overlap = newOverlap;
|
|
if(_apfc && _ref && _data)
|
|
_apfc->set_overlap(_overlap);
|
|
}
|
|
|
|
void apfc_chart::set_ref(const QString &name)
|
|
{
|
|
if(_apfc && name != _ref->name())
|
|
{
|
|
std::swap(_ref, _data);
|
|
_apfc->set_ref(_ref);
|
|
_apfc->set_data(_data);
|
|
}
|
|
}
|
|
|
|
} // namespace gui
|
|
} // namespace gtl
|