GNU Radio 3.7.1 C++ API
form_menus.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2012 Free Software Foundation, Inc.
00004  *
00005  * This file is part of GNU Radio
00006  *
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  *
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef FORM_MENUS_H
00024 #define FORM_MENUS_H
00025 
00026 #include <stdexcept>
00027 #include <vector>
00028 #include <QtGui/QtGui>
00029 #include <qwt_symbol.h>
00030 #include <gnuradio/filter/firdes.h>
00031 #include <gnuradio/qtgui/qtgui_types.h>
00032 
00033 class LineColorMenu: public QMenu
00034 {
00035   Q_OBJECT
00036 
00037 public:
00038   LineColorMenu(int which, QWidget *parent)
00039     : QMenu("Line Color", parent), d_which(which)
00040   {
00041     d_act.push_back(new QAction("Blue", this));
00042     d_act.push_back(new QAction("Red", this));
00043     d_act.push_back(new QAction("Green", this));
00044     d_act.push_back(new QAction("Black", this));
00045     d_act.push_back(new QAction("Cyan", this));
00046     d_act.push_back(new QAction("Magenta", this));
00047     d_act.push_back(new QAction("Yellow", this));
00048     d_act.push_back(new QAction("Gray", this));
00049     d_act.push_back(new QAction("Dark Red", this));
00050     d_act.push_back(new QAction("Dark Green", this));
00051     d_act.push_back(new QAction("Dark Blue", this));
00052     d_act.push_back(new QAction("Dark Gray", this));
00053 
00054     connect(d_act[0], SIGNAL(triggered()), this, SLOT(getBlue()));
00055     connect(d_act[1], SIGNAL(triggered()), this, SLOT(getRed()));
00056     connect(d_act[2], SIGNAL(triggered()), this, SLOT(getGreen()));
00057     connect(d_act[3], SIGNAL(triggered()), this, SLOT(getBlack()));
00058     connect(d_act[4], SIGNAL(triggered()), this, SLOT(getCyan()));
00059     connect(d_act[5], SIGNAL(triggered()), this, SLOT(getMagenta()));
00060     connect(d_act[6], SIGNAL(triggered()), this, SLOT(getYellow()));
00061     connect(d_act[7], SIGNAL(triggered()), this, SLOT(getGray()));
00062     connect(d_act[8], SIGNAL(triggered()), this, SLOT(getDarkRed()));
00063     connect(d_act[9], SIGNAL(triggered()), this, SLOT(getDarkGreen()));
00064     connect(d_act[10], SIGNAL(triggered()), this, SLOT(getDarkBlue()));
00065     connect(d_act[11], SIGNAL(triggered()), this, SLOT(getDarkGray()));
00066 
00067     QListIterator<QAction*> i(d_act);
00068     while(i.hasNext()) {
00069       QAction *a = i.next();
00070       addAction(a);
00071     }
00072   }
00073 
00074   ~LineColorMenu()
00075   {}
00076 
00077   int getNumActions() const
00078   {
00079     return d_act.size();
00080   }
00081   
00082   QAction * getAction(int which)
00083   {
00084     if(which < d_act.size())
00085       return d_act[which];
00086     else
00087       throw std::runtime_error("LineColorMenu::getAction: which out of range.\n");
00088   }
00089 
00090 signals:
00091   void whichTrigger(int which, const QString &name);
00092 
00093 public slots:
00094   void getBlue() { emit whichTrigger(d_which, "blue"); }
00095   void getRed() { emit whichTrigger(d_which, "red"); }
00096   void getGreen() { emit whichTrigger(d_which, "green"); }
00097   void getBlack() { emit whichTrigger(d_which, "black"); }
00098   void getCyan() { emit whichTrigger(d_which, "cyan"); }
00099   void getMagenta() { emit whichTrigger(d_which, "magenta"); }
00100   void getYellow() { emit whichTrigger(d_which, "yellow"); }
00101   void getGray() { emit whichTrigger(d_which, "gray"); }
00102   void getDarkRed() { emit whichTrigger(d_which, "darkred"); }
00103   void getDarkGreen() { emit whichTrigger(d_which, "darkgreen"); }
00104   void getDarkBlue() { emit whichTrigger(d_which, "darkblue"); }
00105   void getDarkGray() { emit whichTrigger(d_which, "darkgray"); }
00106 
00107 private:
00108   QList<QAction *> d_act;
00109   int d_which;
00110 };
00111 
00112 
00113 /********************************************************************/
00114 
00115 
00116 class LineWidthMenu: public QMenu
00117 {
00118   Q_OBJECT
00119 
00120 public:
00121   LineWidthMenu(int which, QWidget *parent)
00122     : QMenu("Line Width", parent), d_which(which)
00123   {
00124     d_act.push_back(new QAction("1", this));
00125     d_act.push_back(new QAction("2", this));
00126     d_act.push_back(new QAction("3", this));
00127     d_act.push_back(new QAction("4", this));
00128     d_act.push_back(new QAction("5", this));
00129     d_act.push_back(new QAction("6", this));
00130     d_act.push_back(new QAction("7", this));
00131     d_act.push_back(new QAction("8", this));
00132     d_act.push_back(new QAction("9", this));
00133     d_act.push_back(new QAction("10", this));
00134 
00135     connect(d_act[0], SIGNAL(triggered()), this, SLOT(getOne()));
00136     connect(d_act[1], SIGNAL(triggered()), this, SLOT(getTwo()));
00137     connect(d_act[2], SIGNAL(triggered()), this, SLOT(getThree()));
00138     connect(d_act[3], SIGNAL(triggered()), this, SLOT(getFour()));
00139     connect(d_act[4], SIGNAL(triggered()), this, SLOT(getFive()));
00140     connect(d_act[5], SIGNAL(triggered()), this, SLOT(getSix()));
00141     connect(d_act[6], SIGNAL(triggered()), this, SLOT(getSeven()));
00142     connect(d_act[7], SIGNAL(triggered()), this, SLOT(getEight()));
00143     connect(d_act[8], SIGNAL(triggered()), this, SLOT(getNine()));
00144     connect(d_act[9], SIGNAL(triggered()), this, SLOT(getTen()));
00145 
00146     QListIterator<QAction*> i(d_act);
00147     while(i.hasNext()) {
00148       QAction *a = i.next();
00149       addAction(a);
00150     }
00151   }
00152 
00153   ~LineWidthMenu()
00154   {}
00155 
00156   int getNumActions() const
00157   {
00158     return d_act.size();
00159   }
00160   
00161   QAction * getAction(int which)
00162   {
00163     if(which < d_act.size())
00164       return d_act[which];
00165     else
00166       throw std::runtime_error("LineWidthMenu::getAction: which out of range.\n");
00167   }
00168 
00169 signals:
00170   void whichTrigger(int which, int width);
00171 
00172 public slots:
00173   void getOne()   { emit whichTrigger(d_which, 1); }
00174   void getTwo()   { emit whichTrigger(d_which, 2); }
00175   void getThree() { emit whichTrigger(d_which, 3); }
00176   void getFour()  { emit whichTrigger(d_which, 4); }
00177   void getFive()  { emit whichTrigger(d_which, 5); }
00178   void getSix()   { emit whichTrigger(d_which, 6); }
00179   void getSeven() { emit whichTrigger(d_which, 7); }
00180   void getEight() { emit whichTrigger(d_which, 8); }
00181   void getNine()  { emit whichTrigger(d_which, 9); }
00182   void getTen()   { emit whichTrigger(d_which, 10); }
00183 
00184 private:
00185   QList<QAction *> d_act;
00186   int d_which;
00187 };
00188 
00189 
00190 /********************************************************************/
00191 
00192 
00193 class LineStyleMenu: public QMenu
00194 {
00195   Q_OBJECT
00196 
00197 public:
00198   LineStyleMenu(int which, QWidget *parent)
00199     : QMenu("Line Style", parent), d_which(which)
00200   {
00201     d_act.push_back(new QAction("None", this));
00202     d_act.push_back(new QAction("Solid", this));
00203     d_act.push_back(new QAction("Dash", this));
00204     d_act.push_back(new QAction("Dots", this));
00205     d_act.push_back(new QAction("Dash-Dot", this));
00206     d_act.push_back(new QAction("Dash-Dot-Dot", this));
00207 
00208     connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone()));
00209     connect(d_act[1], SIGNAL(triggered()), this, SLOT(getSolid()));
00210     connect(d_act[2], SIGNAL(triggered()), this, SLOT(getDash()));
00211     connect(d_act[3], SIGNAL(triggered()), this, SLOT(getDots()));
00212     connect(d_act[4], SIGNAL(triggered()), this, SLOT(getDashDot()));
00213     connect(d_act[5], SIGNAL(triggered()), this, SLOT(getDashDotDot()));
00214 
00215     QListIterator<QAction*> i(d_act);
00216     while(i.hasNext()) {
00217       QAction *a = i.next();
00218       addAction(a);
00219     }
00220   }
00221 
00222   ~LineStyleMenu()
00223   {}
00224 
00225   int getNumActions() const
00226   {
00227     return d_act.size();
00228   }
00229   
00230   QAction * getAction(int which)
00231   {
00232     if(which < d_act.size())
00233       return d_act[which];
00234     else
00235       throw std::runtime_error("LineStyleMenu::getAction: which out of range.\n");
00236   }
00237 
00238 signals:
00239   void whichTrigger(int which, Qt::PenStyle);
00240 
00241 public slots:
00242   void getNone()      { emit whichTrigger(d_which, Qt::NoPen); }
00243   void getSolid()      { emit whichTrigger(d_which, Qt::SolidLine); }
00244   void getDash()       { emit whichTrigger(d_which, Qt::DashLine); }
00245   void getDots()       { emit whichTrigger(d_which, Qt::DotLine); }
00246   void getDashDot()    { emit whichTrigger(d_which, Qt::DashDotLine); }
00247   void getDashDotDot() { emit whichTrigger(d_which, Qt::DashDotDotLine); }
00248 
00249 private:
00250   QList<QAction *> d_act;
00251   int d_which;
00252 };
00253 
00254 
00255 /********************************************************************/
00256 
00257 
00258 class LineMarkerMenu: public QMenu
00259 {
00260   Q_OBJECT
00261 
00262 public:
00263   LineMarkerMenu(int which, QWidget *parent)
00264     : QMenu("Line Marker", parent), d_which(which)
00265   {
00266     d_act.push_back(new QAction("None", this));
00267     d_act.push_back(new QAction("Circle", this));
00268     d_act.push_back(new QAction("Rectangle", this));
00269     d_act.push_back(new QAction("Diamond", this));
00270     d_act.push_back(new QAction("Triangle", this));
00271     d_act.push_back(new QAction("Down Triangle", this));
00272     d_act.push_back(new QAction("Left Triangle", this));
00273     d_act.push_back(new QAction("Right Triangle", this));
00274     d_act.push_back(new QAction("Cross", this));
00275     d_act.push_back(new QAction("X-Cross", this));
00276     d_act.push_back(new QAction("Horiz. Line", this));
00277     d_act.push_back(new QAction("Vert. Line", this));
00278     d_act.push_back(new QAction("Star 1", this));
00279     d_act.push_back(new QAction("Star 2", this));
00280     d_act.push_back(new QAction("Hexagon", this));
00281 
00282     connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone()));
00283     connect(d_act[1], SIGNAL(triggered()), this, SLOT(getCircle()));
00284     connect(d_act[2], SIGNAL(triggered()), this, SLOT(getRect()));
00285     connect(d_act[3], SIGNAL(triggered()), this, SLOT(getDiamond()));
00286     connect(d_act[4], SIGNAL(triggered()), this, SLOT(getTriangle()));
00287     connect(d_act[5], SIGNAL(triggered()), this, SLOT(getDTriangle()));
00288     connect(d_act[6], SIGNAL(triggered()), this, SLOT(getLTriangle()));
00289     connect(d_act[7], SIGNAL(triggered()), this, SLOT(getRTriangle()));
00290     connect(d_act[8], SIGNAL(triggered()), this, SLOT(getCross()));
00291     connect(d_act[9], SIGNAL(triggered()), this, SLOT(getXCross()));
00292     connect(d_act[10], SIGNAL(triggered()), this, SLOT(getHLine()));
00293     connect(d_act[11], SIGNAL(triggered()), this, SLOT(getVLine()));
00294     connect(d_act[12], SIGNAL(triggered()), this, SLOT(getStar1()));
00295     connect(d_act[13], SIGNAL(triggered()), this, SLOT(getStar2()));
00296     connect(d_act[14], SIGNAL(triggered()), this, SLOT(getHexagon()));
00297 
00298     QListIterator<QAction*> i(d_act);
00299     while(i.hasNext()) {
00300       QAction *a = i.next();
00301       addAction(a);
00302     }
00303   }
00304 
00305   ~LineMarkerMenu()
00306   {}
00307 
00308   int getNumActions() const
00309   {
00310     return d_act.size();
00311   }
00312   
00313   QAction * getAction(int which)
00314   {
00315     if(which < d_act.size())
00316       return d_act[which];
00317     else
00318       throw std::runtime_error("LineMarkerMenu::getAction: which out of range.\n");
00319   }
00320 
00321 signals:
00322   void whichTrigger(int which, QwtSymbol::Style);
00323 
00324 public slots:
00325   void getNone()      { emit whichTrigger(d_which, QwtSymbol::NoSymbol); }
00326   void getCircle()    { emit whichTrigger(d_which, QwtSymbol::Ellipse); }
00327   void getRect()      { emit whichTrigger(d_which, QwtSymbol::Rect); }
00328   void getDiamond()   { emit whichTrigger(d_which, QwtSymbol::Diamond); }
00329   void getTriangle()  { emit whichTrigger(d_which, QwtSymbol::Triangle); }
00330   void getDTriangle() { emit whichTrigger(d_which, QwtSymbol::DTriangle); }
00331   void getLTriangle() { emit whichTrigger(d_which, QwtSymbol::LTriangle); }
00332   void getRTriangle() { emit whichTrigger(d_which, QwtSymbol::RTriangle); }
00333   void getCross()     { emit whichTrigger(d_which, QwtSymbol::Cross); }
00334   void getXCross()    { emit whichTrigger(d_which, QwtSymbol::XCross); }
00335   void getHLine()     { emit whichTrigger(d_which, QwtSymbol::HLine); }
00336   void getVLine()     { emit whichTrigger(d_which, QwtSymbol::VLine); }
00337   void getStar1()     { emit whichTrigger(d_which, QwtSymbol::Star1); }
00338   void getStar2()     { emit whichTrigger(d_which, QwtSymbol::Star2); }
00339   void getHexagon()   { emit whichTrigger(d_which, QwtSymbol::Hexagon); }
00340 
00341 private:
00342   QList<QAction *> d_act;
00343   int d_which;
00344 };
00345 
00346 
00347 /********************************************************************/
00348 
00349 
00350 class MarkerAlphaMenu: public QMenu
00351 {
00352   Q_OBJECT
00353 
00354 public:
00355   MarkerAlphaMenu(int which, QWidget *parent)
00356     : QMenu("Line Transparency", parent), d_which(which)
00357   {
00358     d_act.push_back(new QAction("None", this));
00359     d_act.push_back(new QAction("Low", this));
00360     d_act.push_back(new QAction("Medium", this));
00361     d_act.push_back(new QAction("High", this));
00362     d_act.push_back(new QAction("Off", this));
00363 
00364     connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone()));
00365     connect(d_act[1], SIGNAL(triggered()), this, SLOT(getLow()));
00366     connect(d_act[2], SIGNAL(triggered()), this, SLOT(getMedium()));
00367     connect(d_act[3], SIGNAL(triggered()), this, SLOT(getHigh()));
00368     connect(d_act[4], SIGNAL(triggered()), this, SLOT(getOff()));
00369 
00370     QListIterator<QAction*> i(d_act);
00371     while(i.hasNext()) {
00372       QAction *a = i.next();
00373       addAction(a);
00374     }
00375   }
00376 
00377   ~MarkerAlphaMenu()
00378   {}
00379 
00380   int getNumActions() const
00381   {
00382     return d_act.size();
00383   }
00384   
00385   QAction * getAction(int which)
00386   {
00387     if(which < d_act.size())
00388       return d_act[which];
00389     else
00390       throw std::runtime_error("MarkerAlphaMenu::getAction: which out of range.\n");
00391   }
00392 
00393 signals:
00394   void whichTrigger(int which, int);
00395 
00396 public slots:
00397   void getNone()   { emit whichTrigger(d_which, 255); }
00398   void getLow()    { emit whichTrigger(d_which, 200); }
00399   void getMedium() { emit whichTrigger(d_which, 125); }
00400   void getHigh()   { emit whichTrigger(d_which, 50); }
00401   void getOff()    { emit whichTrigger(d_which, 0); }
00402 
00403 private:
00404   QList<QAction *> d_act;
00405   int d_which;
00406 };
00407 
00408 
00409 /********************************************************************/
00410 
00411 
00412 class LineTitleAction: public QAction
00413 {
00414   Q_OBJECT
00415 
00416 public:
00417   LineTitleAction(int which, QWidget *parent)
00418     : QAction("Line Title", parent), d_which(which)
00419   {
00420     d_diag = new QDialog(parent);
00421     d_diag->setModal(true);
00422 
00423     d_text = new QLineEdit();
00424 
00425     QGridLayout *layout = new QGridLayout(d_diag);
00426     QPushButton *btn_ok = new QPushButton(tr("OK"));
00427     QPushButton *btn_cancel = new QPushButton(tr("Cancel"));
00428 
00429     layout->addWidget(d_text, 0, 0, 1, 2);
00430     layout->addWidget(btn_ok, 1, 0);
00431     layout->addWidget(btn_cancel, 1, 1);
00432 
00433     connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText()));
00434     connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close()));
00435 
00436     connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag()));
00437   }
00438 
00439   ~LineTitleAction()
00440   {}
00441   
00442 signals:
00443   void whichTrigger(int which, const QString &text);
00444 
00445 public slots:
00446   void getTextDiag()
00447   {
00448     d_diag->exec();
00449   }
00450 
00451 private slots:
00452   void getText()
00453   { 
00454     emit whichTrigger(d_which, d_text->text());
00455     d_diag->accept();
00456   }
00457 
00458 private:
00459   int d_which;
00460 
00461   QDialog *d_diag;
00462   QLineEdit *d_text;
00463 };
00464 
00465 
00466 /********************************************************************/
00467 
00468 
00469 class OtherAction: public QAction
00470 {
00471   Q_OBJECT
00472 
00473 public:
00474   OtherAction(QWidget *parent)
00475     : QAction("Other", parent)
00476   {
00477     d_diag = new QDialog(parent);
00478     d_diag->setModal(true);
00479 
00480     d_text = new QLineEdit();
00481 
00482     QGridLayout *layout = new QGridLayout(d_diag);
00483     QPushButton *btn_ok = new QPushButton(tr("OK"));
00484     QPushButton *btn_cancel = new QPushButton(tr("Cancel"));
00485 
00486     layout->addWidget(d_text, 0, 0, 1, 2);
00487     layout->addWidget(btn_ok, 1, 0);
00488     layout->addWidget(btn_cancel, 1, 1);
00489 
00490     connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText()));
00491     connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close()));
00492 
00493     connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag()));
00494   }
00495 
00496   ~OtherAction()
00497   {}
00498 
00499 signals:
00500   void whichTrigger(const QString &text);
00501 
00502 public slots:
00503   void getTextDiag()
00504   {
00505     d_diag->exec();
00506   }
00507 
00508 private slots:
00509   void getText()
00510   { 
00511     emit whichTrigger(d_text->text());
00512     d_diag->accept();
00513   }
00514 
00515 private:
00516   QDialog *d_diag;
00517   QLineEdit *d_text;
00518 };
00519 
00520 /********************************************************************/
00521 
00522 
00523 class OtherDualAction: public QAction
00524 {
00525   Q_OBJECT
00526 
00527 public:
00528   OtherDualAction(QString label0, QString label1, QWidget *parent)
00529     : QAction("Other", parent)
00530   {
00531     d_diag = new QDialog(parent);
00532     d_diag->setModal(true);
00533 
00534     d_text0 = new QLineEdit();
00535     d_text1 = new QLineEdit();
00536     
00537     QLabel *_label0 = new QLabel(label0);
00538     QLabel *_label1 = new QLabel(label1);
00539 
00540     QGridLayout *layout = new QGridLayout(d_diag);
00541     QPushButton *btn_ok = new QPushButton(tr("OK"));
00542     QPushButton *btn_cancel = new QPushButton(tr("Cancel"));
00543 
00544     layout->addWidget(_label0, 0, 0, 1, 2);
00545     layout->addWidget(_label1, 1, 0, 1, 2);
00546 
00547     layout->addWidget(d_text0, 0, 1, 1, 2);
00548     layout->addWidget(d_text1, 1, 1, 1, 2);
00549     layout->addWidget(btn_ok, 2, 0);
00550     layout->addWidget(btn_cancel, 2, 1);
00551 
00552     connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText()));
00553     connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close()));
00554 
00555     connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag()));
00556   }
00557 
00558   ~OtherDualAction()
00559   {}
00560 
00561 signals:
00562   void whichTrigger(const QString &text0, const QString &text1);
00563 
00564 public slots:
00565   void getTextDiag()
00566   {
00567     d_diag->exec();
00568   }
00569 
00570 private slots:
00571   void getText()
00572   { 
00573     emit whichTrigger(d_text0->text(), d_text1->text());
00574     d_diag->accept();
00575   }
00576 
00577 private:
00578   QDialog *d_diag;
00579   QLineEdit *d_text0;
00580   QLineEdit *d_text1;
00581 };
00582 
00583 
00584 /********************************************************************/
00585 
00586 
00587 class FFTSizeMenu: public QMenu
00588 {
00589   Q_OBJECT
00590 
00591 public:
00592   FFTSizeMenu(QWidget *parent)
00593     : QMenu("FFT Size", parent)
00594   {
00595     d_act.push_back(new QAction("32", this));
00596     d_act.push_back(new QAction("64", this));
00597     d_act.push_back(new QAction("128", this));
00598     d_act.push_back(new QAction("256", this));
00599     d_act.push_back(new QAction("512", this));
00600     d_act.push_back(new QAction("1024", this));
00601     d_act.push_back(new QAction("2048", this));
00602     d_act.push_back(new QAction("4096", this));
00603     d_act.push_back(new QAction("8192", this));
00604     d_act.push_back(new QAction("16384", this));
00605     d_act.push_back(new QAction("32768", this));
00606     d_act.push_back(new OtherAction(this));
00607 
00608     connect(d_act[0], SIGNAL(triggered()), this, SLOT(get05()));
00609     connect(d_act[1], SIGNAL(triggered()), this, SLOT(get06()));
00610     connect(d_act[2], SIGNAL(triggered()), this, SLOT(get07()));
00611     connect(d_act[3], SIGNAL(triggered()), this, SLOT(get08()));
00612     connect(d_act[4], SIGNAL(triggered()), this, SLOT(get09()));
00613     connect(d_act[5], SIGNAL(triggered()), this, SLOT(get10()));
00614     connect(d_act[6], SIGNAL(triggered()), this, SLOT(get11()));
00615     connect(d_act[7], SIGNAL(triggered()), this, SLOT(get12()));
00616     connect(d_act[8], SIGNAL(triggered()), this, SLOT(get13()));
00617     connect(d_act[9], SIGNAL(triggered()), this, SLOT(get14()));
00618     connect(d_act[10], SIGNAL(triggered()), this, SLOT(get15()));
00619     connect(d_act[11], SIGNAL(whichTrigger(const QString&)),
00620              this, SLOT(getOther(const QString&)));
00621 
00622      QListIterator<QAction*> i(d_act);
00623      while(i.hasNext()) {
00624        QAction *a = i.next();
00625        addAction(a);
00626      }
00627    }
00628 
00629    ~FFTSizeMenu()
00630    {}
00631 
00632    int getNumActions() const
00633    {
00634      return d_act.size();
00635    }
00636 
00637    QAction * getAction(int which)
00638    {
00639      if(which < d_act.size())
00640        return d_act[which];
00641      else
00642        throw std::runtime_error("FFTSizeMenu::getAction: which out of range.\n");
00643    }
00644 
00645  signals:
00646    void whichTrigger(int size);
00647 
00648  public slots:
00649    void get05() { emit whichTrigger(32); }
00650    void get06() { emit whichTrigger(64); }
00651    void get07() { emit whichTrigger(128); }
00652    void get08() { emit whichTrigger(256); }
00653    void get09() { emit whichTrigger(512); }
00654    void get10() { emit whichTrigger(1024); }
00655    void get11() { emit whichTrigger(2048); }
00656    void get12() { emit whichTrigger(4096); }
00657    void get13() { emit whichTrigger(8192); }
00658    void get14() { emit whichTrigger(16384); }
00659    void get15() { emit whichTrigger(32768); }
00660    void getOther(const QString &str) 
00661    {
00662      int value = str.toInt();
00663      emit whichTrigger(value);
00664    }
00665 
00666 private:
00667   QList<QAction *> d_act;
00668   OtherAction *d_other;
00669 };
00670 
00671 
00672 /********************************************************************/
00673 
00674 
00675 class FFTAverageMenu: public QMenu
00676 {
00677   Q_OBJECT
00678 
00679 public:
00680   FFTAverageMenu(QWidget *parent)
00681     : QMenu("FFT Average", parent)
00682   {
00683     d_act.push_back(new QAction("Off", this));
00684     d_act.push_back(new QAction("High", this));
00685     d_act.push_back(new QAction("Medium", this));
00686     d_act.push_back(new QAction("Low", this));
00687     d_act.push_back(new OtherAction(this));
00688 
00689     connect(d_act[0], SIGNAL(triggered()), this, SLOT(getOff()));
00690     connect(d_act[1], SIGNAL(triggered()), this, SLOT(getHigh()));
00691     connect(d_act[2], SIGNAL(triggered()), this, SLOT(getMedium()));
00692     connect(d_act[3], SIGNAL(triggered()), this, SLOT(getLow()));
00693     connect(d_act[4], SIGNAL(whichTrigger(const QString&)),
00694              this, SLOT(getOther(const QString&)));
00695 
00696      QListIterator<QAction*> i(d_act);
00697      while(i.hasNext()) {
00698        QAction *a = i.next();
00699        addAction(a);
00700      }
00701    }
00702 
00703    ~FFTAverageMenu()
00704    {}
00705 
00706    int getNumActions() const
00707    {
00708      return d_act.size();
00709    }
00710 
00711    QAction * getAction(int which)
00712    {
00713      if(which < d_act.size())
00714        return d_act[which];
00715      else
00716        throw std::runtime_error("FFTSizeMenu::getAction: which out of range.\n");
00717    }
00718 
00719  signals:
00720    void whichTrigger(float alpha);
00721 
00722  public slots:
00723    void getOff() { emit whichTrigger(1.0); }
00724    void getHigh() { emit whichTrigger(0.05); }
00725    void getMedium() { emit whichTrigger(0.1); }
00726    void getLow() { emit whichTrigger(0.2); }
00727    void getOther(const QString &str) 
00728    {
00729      float value = str.toFloat();
00730      emit whichTrigger(value);
00731    }
00732 
00733 private:
00734   QList<QAction *> d_act;
00735   OtherAction *d_other;
00736 };
00737 
00738 
00739 /********************************************************************/
00740 
00741 
00742 class FFTWindowMenu: public QMenu
00743 {
00744   Q_OBJECT
00745 
00746 public:
00747   FFTWindowMenu(QWidget *parent)
00748     : QMenu("FFT Window", parent)
00749   {
00750     d_act.push_back(new QAction("None", this));
00751     d_act.push_back(new QAction("Hamming", this));
00752     d_act.push_back(new QAction("Hann", this));
00753     d_act.push_back(new QAction("Blackman", this));
00754     d_act.push_back(new QAction("Blackman-harris", this));
00755     d_act.push_back(new QAction("Rectangular", this));
00756     d_act.push_back(new QAction("Kaiser", this));
00757 
00758     connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone()));
00759     connect(d_act[1], SIGNAL(triggered()), this, SLOT(getHamming()));
00760     connect(d_act[2], SIGNAL(triggered()), this, SLOT(getHann()));
00761     connect(d_act[3], SIGNAL(triggered()), this, SLOT(getBlackman()));
00762     connect(d_act[4], SIGNAL(triggered()), this, SLOT(getBlackmanharris()));
00763     connect(d_act[5], SIGNAL(triggered()), this, SLOT(getRectangular()));
00764     connect(d_act[6], SIGNAL(triggered()), this, SLOT(getKaiser()));
00765 
00766     QListIterator<QAction*> i(d_act);
00767     while(i.hasNext()) {
00768       QAction *a = i.next();
00769       addAction(a);
00770     }
00771   }
00772 
00773   ~FFTWindowMenu()
00774   {}
00775 
00776   int getNumActions() const
00777   {
00778     return d_act.size();
00779   }
00780   
00781   QAction * getAction(int which)
00782   {
00783     if(which < d_act.size())
00784       return d_act[which];
00785     else
00786       throw std::runtime_error("FFTWindowMenu::getAction: which out of range.\n");
00787   }
00788 
00789 signals:
00790   void whichTrigger(const gr::filter::firdes::win_type type);
00791 
00792 public slots:
00793   void getNone() { emit whichTrigger(gr::filter::firdes::WIN_NONE); }
00794   void getHamming() { emit whichTrigger(gr::filter::firdes::WIN_HAMMING); }
00795   void getHann() { emit whichTrigger(gr::filter::firdes::WIN_HANN); }
00796   void getBlackman() { emit whichTrigger(gr::filter::firdes::WIN_BLACKMAN); }
00797   void getBlackmanharris() { emit whichTrigger(gr::filter::firdes::WIN_BLACKMAN_hARRIS); }
00798   void getRectangular() { emit whichTrigger(gr::filter::firdes::WIN_RECTANGULAR); }
00799   void getKaiser() { emit whichTrigger(gr::filter::firdes::WIN_KAISER); }
00800 
00801 private:
00802   QList<QAction *> d_act;
00803   int d_which;
00804 };
00805 
00806 
00807 /********************************************************************/
00808 
00809 
00810 class NPointsMenu: public QAction
00811 {
00812   Q_OBJECT
00813 
00814 public:
00815   NPointsMenu(QWidget *parent)
00816     : QAction("Number of Points", parent)
00817   {
00818     d_diag = new QDialog(parent);
00819     d_diag->setModal(true);
00820 
00821     d_text = new QLineEdit();
00822 
00823     QGridLayout *layout = new QGridLayout(d_diag);
00824     QPushButton *btn_ok = new QPushButton(tr("OK"));
00825     QPushButton *btn_cancel = new QPushButton(tr("Cancel"));
00826 
00827     layout->addWidget(d_text, 0, 0, 1, 2);
00828     layout->addWidget(btn_ok, 1, 0);
00829     layout->addWidget(btn_cancel, 1, 1);
00830 
00831     connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText()));
00832     connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close()));
00833 
00834     connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag()));
00835   }
00836 
00837   ~NPointsMenu()
00838   {}
00839 
00840 signals:
00841   void whichTrigger(const int npts);
00842 
00843 public slots:
00844   void getTextDiag()
00845   {
00846     d_diag->show();
00847   }
00848 
00849 private slots:
00850   void getText()
00851   { 
00852     emit whichTrigger(d_text->text().toInt());
00853     d_diag->accept();
00854   }
00855 
00856 private:
00857   QDialog *d_diag;
00858   QLineEdit *d_text;
00859 };
00860 
00861 
00862 /********************************************************************/
00863 
00864 
00865 class ColorMapMenu: public QMenu
00866 {
00867   Q_OBJECT
00868 
00869 public:
00870   ColorMapMenu(int which, QWidget *parent)
00871     : QMenu("Color Map", parent), d_which(which)
00872   {
00873     d_act.push_back(new QAction("Multi-Color", this));
00874     d_act.push_back(new QAction("White Hot", this));
00875     d_act.push_back(new QAction("Black Hot", this));
00876     d_act.push_back(new QAction("Incandescent", this));
00877     d_act.push_back(new QAction("Other", this));
00878     //d_act.push_back(new OtherDualAction("Min Intensity: ", "Max Intensity: ", this));
00879 
00880     connect(d_act[0], SIGNAL(triggered()), this, SLOT(getMultiColor()));
00881     connect(d_act[1], SIGNAL(triggered()), this, SLOT(getWhiteHot()));
00882     connect(d_act[2], SIGNAL(triggered()), this, SLOT(getBlackHot()));
00883     connect(d_act[3], SIGNAL(triggered()), this, SLOT(getIncandescent()));
00884     connect(d_act[4], SIGNAL(triggered()), this, SLOT(getOther()));
00885 
00886      QListIterator<QAction*> i(d_act);
00887      while(i.hasNext()) {
00888        QAction *a = i.next();
00889        addAction(a);
00890      }
00891 
00892      d_max_value = QColor("white");
00893      d_min_value = QColor("white");
00894    }
00895 
00896    ~ColorMapMenu()
00897    {}
00898 
00899    int getNumActions() const
00900    {
00901      return d_act.size();
00902    }
00903 
00904    QAction * getAction(int which)
00905    {
00906      if(which < d_act.size())
00907        return d_act[which];
00908      else
00909        throw std::runtime_error("ColorMapMenu::getAction: which out of range.\n");
00910    }
00911 
00912  signals:
00913   void whichTrigger(int which, const int type,
00914                     const QColor &min_color=QColor(),
00915                     const QColor &max_color=QColor());
00916 
00917  public slots:
00918   void getMultiColor() { emit whichTrigger(d_which, INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR); }
00919   void getWhiteHot() { emit whichTrigger(d_which, INTENSITY_COLOR_MAP_TYPE_WHITE_HOT); }
00920   void getBlackHot() { emit whichTrigger(d_which, INTENSITY_COLOR_MAP_TYPE_BLACK_HOT); }
00921   void getIncandescent() { emit whichTrigger(d_which, INTENSITY_COLOR_MAP_TYPE_INCANDESCENT); }
00922   //void getOther(d_which, const QString &min_str, const QString &max_str)
00923   void getOther()
00924   {
00925     QMessageBox::information(this, "Set low and high intensities",
00926        "In the next windows, select the low and then the high intensity colors.",
00927        QMessageBox::Ok);
00928     d_min_value = QColorDialog::getColor(d_min_value, this);
00929     d_max_value = QColorDialog::getColor(d_max_value, this);
00930 
00931     emit whichTrigger(d_which, INTENSITY_COLOR_MAP_TYPE_USER_DEFINED,
00932                       d_min_value, d_max_value);
00933   }
00934 
00935 private:
00936   QList<QAction *> d_act;
00937   OtherDualAction *d_other;
00938   QColor d_max_value, d_min_value;
00939   int d_which;
00940 };
00941 
00942 
00943 /********************************************************************/
00944 
00945 
00946 class PopupMenu: public QAction
00947 {
00948   Q_OBJECT
00949 
00950 public:
00951   PopupMenu(QString desc, QWidget *parent)
00952     : QAction(desc, parent)
00953   {
00954     d_diag = new QDialog(parent);
00955     d_diag->setModal(true);
00956 
00957     d_text = new QLineEdit();
00958 
00959     QGridLayout *layout = new QGridLayout(d_diag);
00960     QPushButton *btn_ok = new QPushButton(tr("OK"));
00961     QPushButton *btn_cancel = new QPushButton(tr("Cancel"));
00962 
00963     layout->addWidget(d_text, 0, 0, 1, 2);
00964     layout->addWidget(btn_ok, 1, 0);
00965     layout->addWidget(btn_cancel, 1, 1);
00966 
00967     connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText()));
00968     connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close()));
00969 
00970     connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag()));
00971   }
00972 
00973   ~PopupMenu()
00974   {}
00975 
00976 signals:
00977   void whichTrigger(const QString data);
00978 
00979 public slots:
00980   void getTextDiag()
00981   {
00982     d_diag->show();
00983   }
00984 
00985 private slots:
00986   void getText()
00987   { 
00988     emit whichTrigger(d_text->text());
00989     d_diag->accept();
00990   }
00991 
00992 private:
00993   QDialog *d_diag;
00994   QLineEdit *d_text;
00995 };
00996 
00997 
00998 /********************************************************************/
00999 
01000 
01001 #endif /* FORM_MENUS_H */