root / gr-qtgui / lib / constellationdisplayform.cc @ 3152d29d
History | View | Annotate | Download (2.6 kB)
| 1 | /* -*- c++ -*- */
|
|---|---|
| 2 | /*
|
| 3 | * Copyright 2012 Free Software Foundation, Inc. |
| 4 | * |
| 5 | * This file is part of GNU Radio |
| 6 | * |
| 7 | * GNU Radio is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3, or (at your option) |
| 10 | * any later version. |
| 11 | * |
| 12 | * GNU Radio is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Radio; see the file COPYING. If not, write to |
| 19 | * the Free Software Foundation, Inc., 51 Franklin Street, |
| 20 | * Boston, MA 02110-1301, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <cmath> |
| 24 | #include <QColorDialog> |
| 25 | #include <QMessageBox> |
| 26 | #include <constellationdisplayform.h> |
| 27 | #include <iostream> |
| 28 | |
| 29 | ConstellationDisplayForm::ConstellationDisplayForm(int nplots, QWidget* parent)
|
| 30 | : DisplayForm(nplots, parent) |
| 31 | {
|
| 32 | _intValidator = new QIntValidator(this); |
| 33 | _intValidator->setBottom(0);
|
| 34 | |
| 35 | _layout = new QGridLayout(this); |
| 36 | _displayPlot = new ConstellationDisplayPlot(nplots, this); |
| 37 | _layout->addWidget(_displayPlot, 0, 0); |
| 38 | setLayout(_layout); |
| 39 | |
| 40 | NPointsMenu *nptsmenu = new NPointsMenu(this); |
| 41 | _menu->addAction(nptsmenu); |
| 42 | connect(nptsmenu, SIGNAL(whichTrigger(int)),
|
| 43 | this, SLOT(SetNPoints(const int))); |
| 44 | |
| 45 | Reset(); |
| 46 | |
| 47 | connect(_displayPlot, SIGNAL(plotPointSelected(const QPointF)),
|
| 48 | this, SLOT(onPlotPointSelected(const QPointF))); |
| 49 | } |
| 50 | |
| 51 | ConstellationDisplayForm::~ConstellationDisplayForm() |
| 52 | {
|
| 53 | // Qt deletes children when parent is deleted
|
| 54 | |
| 55 | // Don't worry about deleting Display Plots - they are deleted when parents are deleted
|
| 56 | delete _intValidator;
|
| 57 | } |
| 58 | |
| 59 | ConstellationDisplayPlot* |
| 60 | ConstellationDisplayForm::getPlot() |
| 61 | {
|
| 62 | return ((ConstellationDisplayPlot*)_displayPlot);
|
| 63 | } |
| 64 | |
| 65 | void
|
| 66 | ConstellationDisplayForm::newData(const QEvent* updateEvent)
|
| 67 | {
|
| 68 | ConstUpdateEvent *tevent = (ConstUpdateEvent*)updateEvent; |
| 69 | const std::vector<double*> realDataPoints = tevent->getRealPoints(); |
| 70 | const std::vector<double*> imagDataPoints = tevent->getImagPoints(); |
| 71 | const uint64_t numDataPoints = tevent->getNumDataPoints();
|
| 72 | |
| 73 | getPlot()->PlotNewData(realDataPoints, |
| 74 | imagDataPoints, |
| 75 | numDataPoints, |
| 76 | d_update_time); |
| 77 | } |
| 78 | |
| 79 | void
|
| 80 | ConstellationDisplayForm::customEvent(QEvent * e) |
| 81 | {
|
| 82 | if(e->type() == ConstUpdateEvent::Type()) {
|
| 83 | newData(e); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | int
|
| 88 | ConstellationDisplayForm::GetNPoints() const
|
| 89 | {
|
| 90 | return d_npoints;
|
| 91 | } |
| 92 | |
| 93 | void
|
| 94 | ConstellationDisplayForm::SetNPoints(const int npoints) |
| 95 | {
|
| 96 | d_npoints = npoints; |
| 97 | } |