summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-02-19 18:34:30 -0500
committerTom Rondeau <trondeau@vt.edu>2013-02-19 20:10:32 -0500
commite09420595c730062b17630293eaafc8f37480b18 (patch)
tree050a584fddc5cfecdfe6c8b62d6c1bfb9f87cb50
parent43adf2bff2e7c05f407b86d9734f3bb67cdc7914 (diff)
qtgui: middle button now brings up context menu anywhere on plot.
Middle button + ctrl key allows panning of plot. Also updates grid toggle to use QAction's checkable state.
-rw-r--r--gr-qtgui/lib/DisplayPlot.cc2
-rw-r--r--gr-qtgui/lib/displayform.cc52
-rw-r--r--gr-qtgui/lib/displayform.h1
3 files changed, 16 insertions, 39 deletions
diff --git a/gr-qtgui/lib/DisplayPlot.cc b/gr-qtgui/lib/DisplayPlot.cc
index 3cbbb2e3c6..1c9de3d0ae 100644
--- a/gr-qtgui/lib/DisplayPlot.cc
+++ b/gr-qtgui/lib/DisplayPlot.cc
@@ -55,7 +55,7 @@ DisplayPlot::DisplayPlot(int nplots, QWidget* parent)
_panner = new QwtPlotPanner(canvas());
_panner->setAxisEnabled(QwtPlot::yRight, false);
- _panner->setMouseButton(Qt::MidButton);
+ _panner->setMouseButton(Qt::MidButton, Qt::ControlModifier);
// emit the position of clicks on widget
_picker = new QwtDblClickPlotPicker(canvas());
diff --git a/gr-qtgui/lib/displayform.cc b/gr-qtgui/lib/displayform.cc
index 094e71797a..1f0e27bee6 100644
--- a/gr-qtgui/lib/displayform.cc
+++ b/gr-qtgui/lib/displayform.cc
@@ -41,9 +41,11 @@ DisplayForm::DisplayForm(int nplots, QWidget* parent)
connect(_stop_act, SIGNAL(triggered()), this, SLOT(setStop()));
_stop_state = false;
- _grid_act = new QAction("Grid On", this);
+ _grid_act = new QAction("Grid", this);
+ _grid_act->setCheckable(true);
_grid_act->setStatusTip(tr("Toggle Grid on/off"));
- connect(_grid_act, SIGNAL(triggered()), this, SLOT(setGrid()));
+ connect(_grid_act, SIGNAL(triggered(bool)),
+ this, SLOT(setGrid(bool)));
_grid_state = false;
// Create a pop-up menu for manipulating the figure
@@ -144,33 +146,18 @@ DisplayForm::resizeEvent( QResizeEvent *e )
void
DisplayForm::mousePressEvent( QMouseEvent * e)
{
- if((e->button() == Qt::RightButton) && (_menu_on)) {
- QwtPlotLayout *plt = _displayPlot->plotLayout();
- QRectF cvs = plt->canvasRect();
-
- QRect plotrect;
- plotrect.setLeft(cvs.x()-plt->spacing()-plt->canvasMargin(0));
- plotrect.setRight(cvs.x()+cvs.width()+plt->spacing()+plt->canvasMargin(0));
- plotrect.setBottom(cvs.y()-plt->spacing()-plt->canvasMargin(0));
- plotrect.setTop(cvs.y()+cvs.width()+plt->spacing()+plt->canvasMargin(0));
-
- if(!plotrect.contains(e->pos())) {
- if(_stop_state == false)
- _stop_act->setText(tr("Stop"));
- else
- _stop_act->setText(tr("Start"));
-
- if(_grid_state == false)
- _grid_act->setText(tr("Grid On"));
- else
- _grid_act->setText(tr("Grid Off"));
-
- // Update the line titles if changed externally
- for(int i = 0; i < _nplots; i++) {
- _lines_menu[i]->setTitle(_displayPlot->getLineLabel(i));
- }
- _menu->exec(e->globalPos());
+ bool ctrloff = Qt::ControlModifier != QApplication::keyboardModifiers();
+ if((e->button() == Qt::MiddleButton) && ctrloff && (_menu_on)) {
+ if(_stop_state == false)
+ _stop_act->setText(tr("Stop"));
+ else
+ _stop_act->setText(tr("Start"));
+
+ // Update the line titles if changed externally
+ for(int i = 0; i < _nplots; i++) {
+ _lines_menu[i]->setTitle(_displayPlot->getLineLabel(i));
}
+ _menu->exec(e->globalPos());
}
}
@@ -341,15 +328,6 @@ DisplayForm::setGrid(bool on)
}
void
-DisplayForm::setGrid()
-{
- if(_grid_state == false)
- setGrid(true);
- else
- setGrid(false);
-}
-
-void
DisplayForm::saveFigure()
{
QPixmap qpix = QPixmap::grabWidget(this);
diff --git a/gr-qtgui/lib/displayform.h b/gr-qtgui/lib/displayform.h
index 11ccc50229..0d105bd83d 100644
--- a/gr-qtgui/lib/displayform.h
+++ b/gr-qtgui/lib/displayform.h
@@ -77,7 +77,6 @@ public slots:
void setStop();
void setGrid(bool on);
- void setGrid();
void saveFigure();