GNU Radio 3.7.0-50 C++ API
form_menus.h
Go to the documentation of this file.
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 #ifndef FORM_MENUS_H
24 #define FORM_MENUS_H
25 
26 #include <stdexcept>
27 #include <vector>
28 #include <QtGui/QtGui>
29 #include <qwt_symbol.h>
30 #include <gnuradio/filter/firdes.h>
32 
33 class LineColorMenu: public QMenu
34 {
35  Q_OBJECT
36 
37 public:
38  LineColorMenu(int which, QWidget *parent)
39  : QMenu("Line Color", parent), d_which(which)
40  {
41  d_act.push_back(new QAction("Blue", this));
42  d_act.push_back(new QAction("Red", this));
43  d_act.push_back(new QAction("Green", this));
44  d_act.push_back(new QAction("Black", this));
45  d_act.push_back(new QAction("Cyan", this));
46  d_act.push_back(new QAction("Magenta", this));
47  d_act.push_back(new QAction("Yellow", this));
48  d_act.push_back(new QAction("Gray", this));
49  d_act.push_back(new QAction("Dark Red", this));
50  d_act.push_back(new QAction("Dark Green", this));
51  d_act.push_back(new QAction("Dark Blue", this));
52  d_act.push_back(new QAction("Dark Gray", this));
53 
54  connect(d_act[0], SIGNAL(triggered()), this, SLOT(getBlue()));
55  connect(d_act[1], SIGNAL(triggered()), this, SLOT(getRed()));
56  connect(d_act[2], SIGNAL(triggered()), this, SLOT(getGreen()));
57  connect(d_act[3], SIGNAL(triggered()), this, SLOT(getBlack()));
58  connect(d_act[4], SIGNAL(triggered()), this, SLOT(getCyan()));
59  connect(d_act[5], SIGNAL(triggered()), this, SLOT(getMagenta()));
60  connect(d_act[6], SIGNAL(triggered()), this, SLOT(getYellow()));
61  connect(d_act[7], SIGNAL(triggered()), this, SLOT(getGray()));
62  connect(d_act[8], SIGNAL(triggered()), this, SLOT(getDarkRed()));
63  connect(d_act[9], SIGNAL(triggered()), this, SLOT(getDarkGreen()));
64  connect(d_act[10], SIGNAL(triggered()), this, SLOT(getDarkBlue()));
65  connect(d_act[11], SIGNAL(triggered()), this, SLOT(getDarkGray()));
66 
67  QListIterator<QAction*> i(d_act);
68  while(i.hasNext()) {
69  QAction *a = i.next();
70  addAction(a);
71  }
72  }
73 
75  {}
76 
77  int getNumActions() const
78  {
79  return d_act.size();
80  }
81 
82  QAction * getAction(int which)
83  {
84  if(which < d_act.size())
85  return d_act[which];
86  else
87  throw std::runtime_error("LineColorMenu::getAction: which out of range.\n");
88  }
89 
90 signals:
91  void whichTrigger(int which, const QString &name);
92 
93 public slots:
94  void getBlue() { emit whichTrigger(d_which, "blue"); }
95  void getRed() { emit whichTrigger(d_which, "red"); }
96  void getGreen() { emit whichTrigger(d_which, "green"); }
97  void getBlack() { emit whichTrigger(d_which, "black"); }
98  void getCyan() { emit whichTrigger(d_which, "cyan"); }
99  void getMagenta() { emit whichTrigger(d_which, "magenta"); }
100  void getYellow() { emit whichTrigger(d_which, "yellow"); }
101  void getGray() { emit whichTrigger(d_which, "gray"); }
102  void getDarkRed() { emit whichTrigger(d_which, "darkred"); }
103  void getDarkGreen() { emit whichTrigger(d_which, "darkgreen"); }
104  void getDarkBlue() { emit whichTrigger(d_which, "darkblue"); }
105  void getDarkGray() { emit whichTrigger(d_which, "darkgray"); }
106 
107 private:
108  QList<QAction *> d_act;
109  int d_which;
110 };
111 
112 
113 /********************************************************************/
114 
115 
116 class LineWidthMenu: public QMenu
117 {
118  Q_OBJECT
119 
120 public:
121  LineWidthMenu(int which, QWidget *parent)
122  : QMenu("Line Width", parent), d_which(which)
123  {
124  d_act.push_back(new QAction("1", this));
125  d_act.push_back(new QAction("2", this));
126  d_act.push_back(new QAction("3", this));
127  d_act.push_back(new QAction("4", this));
128  d_act.push_back(new QAction("5", this));
129  d_act.push_back(new QAction("6", this));
130  d_act.push_back(new QAction("7", this));
131  d_act.push_back(new QAction("8", this));
132  d_act.push_back(new QAction("9", this));
133  d_act.push_back(new QAction("10", this));
134 
135  connect(d_act[0], SIGNAL(triggered()), this, SLOT(getOne()));
136  connect(d_act[1], SIGNAL(triggered()), this, SLOT(getTwo()));
137  connect(d_act[2], SIGNAL(triggered()), this, SLOT(getThree()));
138  connect(d_act[3], SIGNAL(triggered()), this, SLOT(getFour()));
139  connect(d_act[4], SIGNAL(triggered()), this, SLOT(getFive()));
140  connect(d_act[5], SIGNAL(triggered()), this, SLOT(getSix()));
141  connect(d_act[6], SIGNAL(triggered()), this, SLOT(getSeven()));
142  connect(d_act[7], SIGNAL(triggered()), this, SLOT(getEight()));
143  connect(d_act[8], SIGNAL(triggered()), this, SLOT(getNine()));
144  connect(d_act[9], SIGNAL(triggered()), this, SLOT(getTen()));
145 
146  QListIterator<QAction*> i(d_act);
147  while(i.hasNext()) {
148  QAction *a = i.next();
149  addAction(a);
150  }
151  }
152 
154  {}
155 
156  int getNumActions() const
157  {
158  return d_act.size();
159  }
160 
161  QAction * getAction(int which)
162  {
163  if(which < d_act.size())
164  return d_act[which];
165  else
166  throw std::runtime_error("LineWidthMenu::getAction: which out of range.\n");
167  }
168 
169 signals:
170  void whichTrigger(int which, int width);
171 
172 public slots:
173  void getOne() { emit whichTrigger(d_which, 1); }
174  void getTwo() { emit whichTrigger(d_which, 2); }
175  void getThree() { emit whichTrigger(d_which, 3); }
176  void getFour() { emit whichTrigger(d_which, 4); }
177  void getFive() { emit whichTrigger(d_which, 5); }
178  void getSix() { emit whichTrigger(d_which, 6); }
179  void getSeven() { emit whichTrigger(d_which, 7); }
180  void getEight() { emit whichTrigger(d_which, 8); }
181  void getNine() { emit whichTrigger(d_which, 9); }
182  void getTen() { emit whichTrigger(d_which, 10); }
183 
184 private:
185  QList<QAction *> d_act;
186  int d_which;
187 };
188 
189 
190 /********************************************************************/
191 
192 
193 class LineStyleMenu: public QMenu
194 {
195  Q_OBJECT
196 
197 public:
198  LineStyleMenu(int which, QWidget *parent)
199  : QMenu("Line Style", parent), d_which(which)
200  {
201  d_act.push_back(new QAction("None", this));
202  d_act.push_back(new QAction("Solid", this));
203  d_act.push_back(new QAction("Dash", this));
204  d_act.push_back(new QAction("Dots", this));
205  d_act.push_back(new QAction("Dash-Dot", this));
206  d_act.push_back(new QAction("Dash-Dot-Dot", this));
207 
208  connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone()));
209  connect(d_act[1], SIGNAL(triggered()), this, SLOT(getSolid()));
210  connect(d_act[2], SIGNAL(triggered()), this, SLOT(getDash()));
211  connect(d_act[3], SIGNAL(triggered()), this, SLOT(getDots()));
212  connect(d_act[4], SIGNAL(triggered()), this, SLOT(getDashDot()));
213  connect(d_act[5], SIGNAL(triggered()), this, SLOT(getDashDotDot()));
214 
215  QListIterator<QAction*> i(d_act);
216  while(i.hasNext()) {
217  QAction *a = i.next();
218  addAction(a);
219  }
220  }
221 
223  {}
224 
225  int getNumActions() const
226  {
227  return d_act.size();
228  }
229 
230  QAction * getAction(int which)
231  {
232  if(which < d_act.size())
233  return d_act[which];
234  else
235  throw std::runtime_error("LineStyleMenu::getAction: which out of range.\n");
236  }
237 
238 signals:
239  void whichTrigger(int which, Qt::PenStyle);
240 
241 public slots:
242  void getNone() { emit whichTrigger(d_which, Qt::NoPen); }
243  void getSolid() { emit whichTrigger(d_which, Qt::SolidLine); }
244  void getDash() { emit whichTrigger(d_which, Qt::DashLine); }
245  void getDots() { emit whichTrigger(d_which, Qt::DotLine); }
246  void getDashDot() { emit whichTrigger(d_which, Qt::DashDotLine); }
247  void getDashDotDot() { emit whichTrigger(d_which, Qt::DashDotDotLine); }
248 
249 private:
250  QList<QAction *> d_act;
251  int d_which;
252 };
253 
254 
255 /********************************************************************/
256 
257 
258 class LineMarkerMenu: public QMenu
259 {
260  Q_OBJECT
261 
262 public:
263  LineMarkerMenu(int which, QWidget *parent)
264  : QMenu("Line Marker", parent), d_which(which)
265  {
266  d_act.push_back(new QAction("None", this));
267  d_act.push_back(new QAction("Circle", this));
268  d_act.push_back(new QAction("Rectangle", this));
269  d_act.push_back(new QAction("Diamond", this));
270  d_act.push_back(new QAction("Triangle", this));
271  d_act.push_back(new QAction("Down Triangle", this));
272  d_act.push_back(new QAction("Left Triangle", this));
273  d_act.push_back(new QAction("Right Triangle", this));
274  d_act.push_back(new QAction("Cross", this));
275  d_act.push_back(new QAction("X-Cross", this));
276  d_act.push_back(new QAction("Horiz. Line", this));
277  d_act.push_back(new QAction("Vert. Line", this));
278  d_act.push_back(new QAction("Star 1", this));
279  d_act.push_back(new QAction("Star 2", this));
280  d_act.push_back(new QAction("Hexagon", this));
281 
282  connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone()));
283  connect(d_act[1], SIGNAL(triggered()), this, SLOT(getCircle()));
284  connect(d_act[2], SIGNAL(triggered()), this, SLOT(getRect()));
285  connect(d_act[3], SIGNAL(triggered()), this, SLOT(getDiamond()));
286  connect(d_act[4], SIGNAL(triggered()), this, SLOT(getTriangle()));
287  connect(d_act[5], SIGNAL(triggered()), this, SLOT(getDTriangle()));
288  connect(d_act[6], SIGNAL(triggered()), this, SLOT(getLTriangle()));
289  connect(d_act[7], SIGNAL(triggered()), this, SLOT(getRTriangle()));
290  connect(d_act[8], SIGNAL(triggered()), this, SLOT(getCross()));
291  connect(d_act[9], SIGNAL(triggered()), this, SLOT(getXCross()));
292  connect(d_act[10], SIGNAL(triggered()), this, SLOT(getHLine()));
293  connect(d_act[11], SIGNAL(triggered()), this, SLOT(getVLine()));
294  connect(d_act[12], SIGNAL(triggered()), this, SLOT(getStar1()));
295  connect(d_act[13], SIGNAL(triggered()), this, SLOT(getStar2()));
296  connect(d_act[14], SIGNAL(triggered()), this, SLOT(getHexagon()));
297 
298  QListIterator<QAction*> i(d_act);
299  while(i.hasNext()) {
300  QAction *a = i.next();
301  addAction(a);
302  }
303  }
304 
306  {}
307 
308  int getNumActions() const
309  {
310  return d_act.size();
311  }
312 
313  QAction * getAction(int which)
314  {
315  if(which < d_act.size())
316  return d_act[which];
317  else
318  throw std::runtime_error("LineMarkerMenu::getAction: which out of range.\n");
319  }
320 
321 signals:
322  void whichTrigger(int which, QwtSymbol::Style);
323 
324 public slots:
325  void getNone() { emit whichTrigger(d_which, QwtSymbol::NoSymbol); }
326  void getCircle() { emit whichTrigger(d_which, QwtSymbol::Ellipse); }
327  void getRect() { emit whichTrigger(d_which, QwtSymbol::Rect); }
328  void getDiamond() { emit whichTrigger(d_which, QwtSymbol::Diamond); }
329  void getTriangle() { emit whichTrigger(d_which, QwtSymbol::Triangle); }
330  void getDTriangle() { emit whichTrigger(d_which, QwtSymbol::DTriangle); }
331  void getLTriangle() { emit whichTrigger(d_which, QwtSymbol::LTriangle); }
332  void getRTriangle() { emit whichTrigger(d_which, QwtSymbol::RTriangle); }
333  void getCross() { emit whichTrigger(d_which, QwtSymbol::Cross); }
334  void getXCross() { emit whichTrigger(d_which, QwtSymbol::XCross); }
335  void getHLine() { emit whichTrigger(d_which, QwtSymbol::HLine); }
336  void getVLine() { emit whichTrigger(d_which, QwtSymbol::VLine); }
337  void getStar1() { emit whichTrigger(d_which, QwtSymbol::Star1); }
338  void getStar2() { emit whichTrigger(d_which, QwtSymbol::Star2); }
339  void getHexagon() { emit whichTrigger(d_which, QwtSymbol::Hexagon); }
340 
341 private:
342  QList<QAction *> d_act;
343  int d_which;
344 };
345 
346 
347 /********************************************************************/
348 
349 
350 class MarkerAlphaMenu: public QMenu
351 {
352  Q_OBJECT
353 
354 public:
355  MarkerAlphaMenu(int which, QWidget *parent)
356  : QMenu("Line Transparency", parent), d_which(which)
357  {
358  d_act.push_back(new QAction("None", this));
359  d_act.push_back(new QAction("Low", this));
360  d_act.push_back(new QAction("Medium", this));
361  d_act.push_back(new QAction("High", this));
362  d_act.push_back(new QAction("Off", this));
363 
364  connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone()));
365  connect(d_act[1], SIGNAL(triggered()), this, SLOT(getLow()));
366  connect(d_act[2], SIGNAL(triggered()), this, SLOT(getMedium()));
367  connect(d_act[3], SIGNAL(triggered()), this, SLOT(getHigh()));
368  connect(d_act[4], SIGNAL(triggered()), this, SLOT(getOff()));
369 
370  QListIterator<QAction*> i(d_act);
371  while(i.hasNext()) {
372  QAction *a = i.next();
373  addAction(a);
374  }
375  }
376 
378  {}
379 
380  int getNumActions() const
381  {
382  return d_act.size();
383  }
384 
385  QAction * getAction(int which)
386  {
387  if(which < d_act.size())
388  return d_act[which];
389  else
390  throw std::runtime_error("MarkerAlphaMenu::getAction: which out of range.\n");
391  }
392 
393 signals:
394  void whichTrigger(int which, int);
395 
396 public slots:
397  void getNone() { emit whichTrigger(d_which, 255); }
398  void getLow() { emit whichTrigger(d_which, 200); }
399  void getMedium() { emit whichTrigger(d_which, 125); }
400  void getHigh() { emit whichTrigger(d_which, 50); }
401  void getOff() { emit whichTrigger(d_which, 0); }
402 
403 private:
404  QList<QAction *> d_act;
405  int d_which;
406 };
407 
408 
409 /********************************************************************/
410 
411 
412 class LineTitleAction: public QAction
413 {
414  Q_OBJECT
415 
416 public:
417  LineTitleAction(int which, QWidget *parent)
418  : QAction("Line Title", parent), d_which(which)
419  {
420  d_diag = new QDialog(parent);
421  d_diag->setModal(true);
422 
423  d_text = new QLineEdit();
424 
425  QGridLayout *layout = new QGridLayout(d_diag);
426  QPushButton *btn_ok = new QPushButton(tr("OK"));
427  QPushButton *btn_cancel = new QPushButton(tr("Cancel"));
428 
429  layout->addWidget(d_text, 0, 0, 1, 2);
430  layout->addWidget(btn_ok, 1, 0);
431  layout->addWidget(btn_cancel, 1, 1);
432 
433  connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText()));
434  connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close()));
435 
436  connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag()));
437  }
438 
440  {}
441 
442 signals:
443  void whichTrigger(int which, const QString &text);
444 
445 public slots:
446  void getTextDiag()
447  {
448  d_diag->exec();
449  }
450 
451 private slots:
452  void getText()
453  {
454  emit whichTrigger(d_which, d_text->text());
455  d_diag->accept();
456  }
457 
458 private:
459  int d_which;
460 
461  QDialog *d_diag;
462  QLineEdit *d_text;
463 };
464 
465 
466 /********************************************************************/
467 
468 
469 class OtherAction: public QAction
470 {
471  Q_OBJECT
472 
473 public:
474  OtherAction(QWidget *parent)
475  : QAction("Other", parent)
476  {
477  d_diag = new QDialog(parent);
478  d_diag->setModal(true);
479 
480  d_text = new QLineEdit();
481 
482  QGridLayout *layout = new QGridLayout(d_diag);
483  QPushButton *btn_ok = new QPushButton(tr("OK"));
484  QPushButton *btn_cancel = new QPushButton(tr("Cancel"));
485 
486  layout->addWidget(d_text, 0, 0, 1, 2);
487  layout->addWidget(btn_ok, 1, 0);
488  layout->addWidget(btn_cancel, 1, 1);
489 
490  connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText()));
491  connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close()));
492 
493  connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag()));
494  }
495 
497  {}
498 
499 signals:
500  void whichTrigger(const QString &text);
501 
502 public slots:
503  void getTextDiag()
504  {
505  d_diag->exec();
506  }
507 
508 private slots:
509  void getText()
510  {
511  emit whichTrigger(d_text->text());
512  d_diag->accept();
513  }
514 
515 private:
516  QDialog *d_diag;
517  QLineEdit *d_text;
518 };
519 
520 /********************************************************************/
521 
522 
523 class OtherDualAction: public QAction
524 {
525  Q_OBJECT
526 
527 public:
528  OtherDualAction(QString label0, QString label1, QWidget *parent)
529  : QAction("Other", parent)
530  {
531  d_diag = new QDialog(parent);
532  d_diag->setModal(true);
533 
534  d_text0 = new QLineEdit();
535  d_text1 = new QLineEdit();
536 
537  QLabel *_label0 = new QLabel(label0);
538  QLabel *_label1 = new QLabel(label1);
539 
540  QGridLayout *layout = new QGridLayout(d_diag);
541  QPushButton *btn_ok = new QPushButton(tr("OK"));
542  QPushButton *btn_cancel = new QPushButton(tr("Cancel"));
543 
544  layout->addWidget(_label0, 0, 0, 1, 2);
545  layout->addWidget(_label1, 1, 0, 1, 2);
546 
547  layout->addWidget(d_text0, 0, 1, 1, 2);
548  layout->addWidget(d_text1, 1, 1, 1, 2);
549  layout->addWidget(btn_ok, 2, 0);
550  layout->addWidget(btn_cancel, 2, 1);
551 
552  connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText()));
553  connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close()));
554 
555  connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag()));
556  }
557 
559  {}
560 
561 signals:
562  void whichTrigger(const QString &text0, const QString &text1);
563 
564 public slots:
565  void getTextDiag()
566  {
567  d_diag->exec();
568  }
569 
570 private slots:
571  void getText()
572  {
573  emit whichTrigger(d_text0->text(), d_text1->text());
574  d_diag->accept();
575  }
576 
577 private:
578  QDialog *d_diag;
579  QLineEdit *d_text0;
580  QLineEdit *d_text1;
581 };
582 
583 
584 /********************************************************************/
585 
586 
587 class FFTSizeMenu: public QMenu
588 {
589  Q_OBJECT
590 
591 public:
592  FFTSizeMenu(QWidget *parent)
593  : QMenu("FFT Size", parent)
594  {
595  d_act.push_back(new QAction("32", this));
596  d_act.push_back(new QAction("64", this));
597  d_act.push_back(new QAction("128", this));
598  d_act.push_back(new QAction("256", this));
599  d_act.push_back(new QAction("512", this));
600  d_act.push_back(new QAction("1024", this));
601  d_act.push_back(new QAction("2048", this));
602  d_act.push_back(new QAction("4096", this));
603  d_act.push_back(new QAction("8192", this));
604  d_act.push_back(new QAction("16384", this));
605  d_act.push_back(new QAction("32768", this));
606  d_act.push_back(new OtherAction(this));
607 
608  connect(d_act[0], SIGNAL(triggered()), this, SLOT(get05()));
609  connect(d_act[1], SIGNAL(triggered()), this, SLOT(get06()));
610  connect(d_act[2], SIGNAL(triggered()), this, SLOT(get07()));
611  connect(d_act[3], SIGNAL(triggered()), this, SLOT(get08()));
612  connect(d_act[4], SIGNAL(triggered()), this, SLOT(get09()));
613  connect(d_act[5], SIGNAL(triggered()), this, SLOT(get10()));
614  connect(d_act[6], SIGNAL(triggered()), this, SLOT(get11()));
615  connect(d_act[7], SIGNAL(triggered()), this, SLOT(get12()));
616  connect(d_act[8], SIGNAL(triggered()), this, SLOT(get13()));
617  connect(d_act[9], SIGNAL(triggered()), this, SLOT(get14()));
618  connect(d_act[10], SIGNAL(triggered()), this, SLOT(get15()));
619  connect(d_act[11], SIGNAL(whichTrigger(const QString&)),
620  this, SLOT(getOther(const QString&)));
621 
622  QListIterator<QAction*> i(d_act);
623  while(i.hasNext()) {
624  QAction *a = i.next();
625  addAction(a);
626  }
627  }
628 
630  {}
631 
632  int getNumActions() const
633  {
634  return d_act.size();
635  }
636 
637  QAction * getAction(int which)
638  {
639  if(which < d_act.size())
640  return d_act[which];
641  else
642  throw std::runtime_error("FFTSizeMenu::getAction: which out of range.\n");
643  }
644 
645  signals:
646  void whichTrigger(int size);
647 
648  public slots:
649  void get05() { emit whichTrigger(32); }
650  void get06() { emit whichTrigger(64); }
651  void get07() { emit whichTrigger(128); }
652  void get08() { emit whichTrigger(256); }
653  void get09() { emit whichTrigger(512); }
654  void get10() { emit whichTrigger(1024); }
655  void get11() { emit whichTrigger(2048); }
656  void get12() { emit whichTrigger(4096); }
657  void get13() { emit whichTrigger(8192); }
658  void get14() { emit whichTrigger(16384); }
659  void get15() { emit whichTrigger(32768); }
660  void getOther(const QString &str)
661  {
662  int value = str.toInt();
663  emit whichTrigger(value);
664  }
665 
666 private:
667  QList<QAction *> d_act;
668  OtherAction *d_other;
669 };
670 
671 
672 /********************************************************************/
673 
674 
675 class FFTAverageMenu: public QMenu
676 {
677  Q_OBJECT
678 
679 public:
680  FFTAverageMenu(QWidget *parent)
681  : QMenu("FFT Average", parent)
682  {
683  d_act.push_back(new QAction("Off", this));
684  d_act.push_back(new QAction("High", this));
685  d_act.push_back(new QAction("Medium", this));
686  d_act.push_back(new QAction("Low", this));
687  d_act.push_back(new OtherAction(this));
688 
689  connect(d_act[0], SIGNAL(triggered()), this, SLOT(getOff()));
690  connect(d_act[1], SIGNAL(triggered()), this, SLOT(getHigh()));
691  connect(d_act[2], SIGNAL(triggered()), this, SLOT(getMedium()));
692  connect(d_act[3], SIGNAL(triggered()), this, SLOT(getLow()));
693  connect(d_act[4], SIGNAL(whichTrigger(const QString&)),
694  this, SLOT(getOther(const QString&)));
695 
696  QListIterator<QAction*> i(d_act);
697  while(i.hasNext()) {
698  QAction *a = i.next();
699  addAction(a);
700  }
701  }
702 
704  {}
705 
706  int getNumActions() const
707  {
708  return d_act.size();
709  }
710 
711  QAction * getAction(int which)
712  {
713  if(which < d_act.size())
714  return d_act[which];
715  else
716  throw std::runtime_error("FFTSizeMenu::getAction: which out of range.\n");
717  }
718 
719  signals:
720  void whichTrigger(float alpha);
721 
722  public slots:
723  void getOff() { emit whichTrigger(1.0); }
724  void getHigh() { emit whichTrigger(0.05); }
725  void getMedium() { emit whichTrigger(0.1); }
726  void getLow() { emit whichTrigger(0.2); }
727  void getOther(const QString &str)
728  {
729  float value = str.toFloat();
730  emit whichTrigger(value);
731  }
732 
733 private:
734  QList<QAction *> d_act;
735  OtherAction *d_other;
736 };
737 
738 
739 /********************************************************************/
740 
741 
742 class FFTWindowMenu: public QMenu
743 {
744  Q_OBJECT
745 
746 public:
747  FFTWindowMenu(QWidget *parent)
748  : QMenu("FFT Window", parent)
749  {
750  d_act.push_back(new QAction("None", this));
751  d_act.push_back(new QAction("Hamming", this));
752  d_act.push_back(new QAction("Hann", this));
753  d_act.push_back(new QAction("Blackman", this));
754  d_act.push_back(new QAction("Blackman-harris", this));
755  d_act.push_back(new QAction("Rectangular", this));
756  d_act.push_back(new QAction("Kaiser", this));
757 
758  connect(d_act[0], SIGNAL(triggered()), this, SLOT(getNone()));
759  connect(d_act[1], SIGNAL(triggered()), this, SLOT(getHamming()));
760  connect(d_act[2], SIGNAL(triggered()), this, SLOT(getHann()));
761  connect(d_act[3], SIGNAL(triggered()), this, SLOT(getBlackman()));
762  connect(d_act[4], SIGNAL(triggered()), this, SLOT(getBlackmanharris()));
763  connect(d_act[5], SIGNAL(triggered()), this, SLOT(getRectangular()));
764  connect(d_act[6], SIGNAL(triggered()), this, SLOT(getKaiser()));
765 
766  QListIterator<QAction*> i(d_act);
767  while(i.hasNext()) {
768  QAction *a = i.next();
769  addAction(a);
770  }
771  }
772 
774  {}
775 
776  int getNumActions() const
777  {
778  return d_act.size();
779  }
780 
781  QAction * getAction(int which)
782  {
783  if(which < d_act.size())
784  return d_act[which];
785  else
786  throw std::runtime_error("FFTWindowMenu::getAction: which out of range.\n");
787  }
788 
789 signals:
791 
792 public slots:
800 
801 private:
802  QList<QAction *> d_act;
803  int d_which;
804 };
805 
806 
807 /********************************************************************/
808 
809 
810 class NPointsMenu: public QAction
811 {
812  Q_OBJECT
813 
814 public:
815  NPointsMenu(QWidget *parent)
816  : QAction("Number of Points", parent)
817  {
818  d_diag = new QDialog(parent);
819  d_diag->setModal(true);
820 
821  d_text = new QLineEdit();
822 
823  QGridLayout *layout = new QGridLayout(d_diag);
824  QPushButton *btn_ok = new QPushButton(tr("OK"));
825  QPushButton *btn_cancel = new QPushButton(tr("Cancel"));
826 
827  layout->addWidget(d_text, 0, 0, 1, 2);
828  layout->addWidget(btn_ok, 1, 0);
829  layout->addWidget(btn_cancel, 1, 1);
830 
831  connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText()));
832  connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close()));
833 
834  connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag()));
835  }
836 
838  {}
839 
840 signals:
841  void whichTrigger(const int npts);
842 
843 public slots:
844  void getTextDiag()
845  {
846  d_diag->show();
847  }
848 
849 private slots:
850  void getText()
851  {
852  emit whichTrigger(d_text->text().toInt());
853  d_diag->accept();
854  }
855 
856 private:
857  QDialog *d_diag;
858  QLineEdit *d_text;
859 };
860 
861 
862 /********************************************************************/
863 
864 
865 class ColorMapMenu: public QMenu
866 {
867  Q_OBJECT
868 
869 public:
870  ColorMapMenu(int which, QWidget *parent)
871  : QMenu("Color Map", parent), d_which(which)
872  {
873  d_act.push_back(new QAction("Multi-Color", this));
874  d_act.push_back(new QAction("White Hot", this));
875  d_act.push_back(new QAction("Black Hot", this));
876  d_act.push_back(new QAction("Incandescent", this));
877  d_act.push_back(new QAction("Other", this));
878  //d_act.push_back(new OtherDualAction("Min Intensity: ", "Max Intensity: ", this));
879 
880  connect(d_act[0], SIGNAL(triggered()), this, SLOT(getMultiColor()));
881  connect(d_act[1], SIGNAL(triggered()), this, SLOT(getWhiteHot()));
882  connect(d_act[2], SIGNAL(triggered()), this, SLOT(getBlackHot()));
883  connect(d_act[3], SIGNAL(triggered()), this, SLOT(getIncandescent()));
884  connect(d_act[4], SIGNAL(triggered()), this, SLOT(getOther()));
885 
886  QListIterator<QAction*> i(d_act);
887  while(i.hasNext()) {
888  QAction *a = i.next();
889  addAction(a);
890  }
891 
892  d_max_value = QColor("white");
893  d_min_value = QColor("white");
894  }
895 
897  {}
898 
899  int getNumActions() const
900  {
901  return d_act.size();
902  }
903 
904  QAction * getAction(int which)
905  {
906  if(which < d_act.size())
907  return d_act[which];
908  else
909  throw std::runtime_error("ColorMapMenu::getAction: which out of range.\n");
910  }
911 
912  signals:
913  void whichTrigger(int which, const int type,
914  const QColor &min_color=QColor(),
915  const QColor &max_color=QColor());
916 
917  public slots:
922  //void getOther(d_which, const QString &min_str, const QString &max_str)
923  void getOther()
924  {
925  QMessageBox::information(this, "Set low and high intensities",
926  "In the next windows, select the low and then the high intensity colors.",
927  QMessageBox::Ok);
928  d_min_value = QColorDialog::getColor(d_min_value, this);
929  d_max_value = QColorDialog::getColor(d_max_value, this);
930 
932  d_min_value, d_max_value);
933  }
934 
935 private:
936  QList<QAction *> d_act;
937  OtherDualAction *d_other;
938  QColor d_max_value, d_min_value;
939  int d_which;
940 };
941 
942 
943 /********************************************************************/
944 
945 
946 class PopupMenu: public QAction
947 {
948  Q_OBJECT
949 
950 public:
951  PopupMenu(QString desc, QWidget *parent)
952  : QAction(desc, parent)
953  {
954  d_diag = new QDialog(parent);
955  d_diag->setModal(true);
956 
957  d_text = new QLineEdit();
958 
959  QGridLayout *layout = new QGridLayout(d_diag);
960  QPushButton *btn_ok = new QPushButton(tr("OK"));
961  QPushButton *btn_cancel = new QPushButton(tr("Cancel"));
962 
963  layout->addWidget(d_text, 0, 0, 1, 2);
964  layout->addWidget(btn_ok, 1, 0);
965  layout->addWidget(btn_cancel, 1, 1);
966 
967  connect(btn_ok, SIGNAL(clicked()), this, SLOT(getText()));
968  connect(btn_cancel, SIGNAL(clicked()), d_diag, SLOT(close()));
969 
970  connect(this, SIGNAL(triggered()), this, SLOT(getTextDiag()));
971  }
972 
974  {}
975 
976 signals:
977  void whichTrigger(const QString data);
978 
979 public slots:
980  void getTextDiag()
981  {
982  d_diag->show();
983  }
984 
985 private slots:
986  void getText()
987  {
988  emit whichTrigger(d_text->text());
989  d_diag->accept();
990  }
991 
992 private:
993  QDialog *d_diag;
994  QLineEdit *d_text;
995 };
996 
997 
998 /********************************************************************/
999 
1000 
1001 #endif /* FORM_MENUS_H */