Skip to content

Commit

Permalink
Removed zoom & pan buttons.
Browse files Browse the repository at this point in the history
Zoom is default.
Panning is done by pressing the control key.
  • Loading branch information
adeas31 committed Apr 6, 2017
1 parent 6f97c81 commit 9b947e8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 51 deletions.
1 change: 0 additions & 1 deletion OMPlot/OMPlotGUI/Plot.cpp
Expand Up @@ -63,7 +63,6 @@ Plot::Plot(PlotWindow *pParent)
// set canvas arrow
QwtPlotCanvas *pPlotCanvas = static_cast<QwtPlotCanvas*>(canvas());
pPlotCanvas->setFrameStyle(QFrame::NoFrame); /* Ticket #2679 point 6. Remove the default frame from the canvas. */
canvas()->setCursor(Qt::ArrowCursor);
setCanvasBackground(Qt::white);
setContentsMargins(10, 10, 10, 10);
setAxisScaleDraw(QwtPlot::yLeft, new ScaleDraw);
Expand Down
44 changes: 23 additions & 21 deletions OMPlot/OMPlotGUI/PlotPanner.cpp
Expand Up @@ -38,16 +38,16 @@ using namespace OMPlot;

#if QWT_VERSION >= 0x060100
PlotPanner::PlotPanner(QWidget *pCanvas, Plot *pParent)
: QwtPlotPanner(pCanvas)
: QwtPlotPanner(pCanvas)
{
#else
PlotPanner::PlotPanner(QwtPlotCanvas *pCanvas, Plot *pParent)
: QwtPlotPanner(pCanvas)
: QwtPlotPanner(pCanvas)
{
#endif
setEnabled(false);
connect(this, SIGNAL(moved(int,int)), SLOT(updateView(int, int)));
mpParentPlot = pParent;
setMouseButton(Qt::LeftButton, Qt::ControlModifier);
connect(this, SIGNAL(moved(int,int)), SLOT(updateView(int, int)));
mpParentPlot = pParent;

}

Expand All @@ -58,28 +58,30 @@ PlotPanner::~PlotPanner()

void PlotPanner::updateView(int dx, int dy)
{
plot()->updateAxes();
//moveCanvas(dx - pos().x(), dy - pos().y());
// plot()->setAxisAutoScale(QwtPlot::xBottom);
// plot()->setAxisAutoScale(QwtPlot::yLeft);
// canvas()->update();
// plot()->updateAxes();
plot()->updateLayout();
canvas()->updateGeometry();
canvas()->update();
plot()->replot();
Q_UNUSED(dx);
Q_UNUSED(dy);
plot()->updateAxes();
// moveCanvas(dx - pos().x(), dy - pos().y());
// plot()->setAxisAutoScale(QwtPlot::xBottom);
// plot()->setAxisAutoScale(QwtPlot::yLeft);
// canvas()->update();
// plot()->updateAxes();
plot()->updateLayout();
canvas()->updateGeometry();
canvas()->update();
plot()->replot();
}

void PlotPanner::widgetMousePressEvent(QMouseEvent *event)
{
if (mpParentPlot->getParentPlotWindow()->getPanButton()->isChecked())
mpParentPlot->canvas()->setCursor(Qt::ClosedHandCursor);
QwtPlotPanner::widgetMousePressEvent(event);
if (QApplication::keyboardModifiers() == Qt::ControlModifier) {
mpParentPlot->canvas()->setCursor(Qt::ClosedHandCursor);
}
QwtPlotPanner::widgetMousePressEvent(event);
}

void PlotPanner::widgetMouseReleaseEvent(QMouseEvent *event)
{
if (mpParentPlot->getParentPlotWindow()->getPanButton()->isChecked())
mpParentPlot->canvas()->setCursor(Qt::OpenHandCursor);
QwtPlotPanner::widgetMouseReleaseEvent(event);
mpParentPlot->canvas()->setCursor(Qt::CrossCursor);
QwtPlotPanner::widgetMouseReleaseEvent(event);
}
26 changes: 0 additions & 26 deletions OMPlot/OMPlotGUI/PlotWindow.cpp
Expand Up @@ -72,8 +72,6 @@ void PlotWindow::setUpWidget()
mpPlot = new Plot(this);
// set up the toolbar
setupToolbar();
// enable the zoom mode by default
mpZoomButton->setChecked(true);
// set the default values
// set the plot title
setTitle(tr("Plot by OpenModelica"));
Expand Down Expand Up @@ -171,20 +169,6 @@ void PlotWindow::setupToolbar()
{
QToolBar *toolBar = new QToolBar(this);
setContextMenuPolicy(Qt::NoContextMenu);
//ZOOM
mpZoomButton = new QToolButton(toolBar);
mpZoomButton->setText(tr("Zoom"));
mpZoomButton->setCheckable(true);
connect(mpZoomButton, SIGNAL(toggled(bool)), SLOT(enableZoomMode(bool)));
toolBar->addWidget(mpZoomButton);
toolBar->addSeparator();
//PAN
mpPanButton = new QToolButton(toolBar);
mpPanButton->setText(tr("Pan"));
mpPanButton->setCheckable(true);
connect(mpPanButton, SIGNAL(toggled(bool)), SLOT(enablePanMode(bool)));
toolBar->addWidget(mpPanButton);
toolBar->addSeparator();
// Auto scale
mpAutoScaleButton = new QToolButton(toolBar);
mpAutoScaleButton->setText(tr("Auto Scale"));
Expand All @@ -198,11 +182,6 @@ void PlotWindow::setupToolbar()
connect(fitInViewButton, SIGNAL(clicked()), SLOT(fitInView()));
toolBar->addWidget(fitInViewButton);
toolBar->addSeparator();
// make the buttons exclusive
QButtonGroup *pViewsButtonGroup = new QButtonGroup;
pViewsButtonGroup->setExclusive(true);
pViewsButtonGroup->addButton(mpZoomButton);
pViewsButtonGroup->addButton(mpPanButton);
//EXPORT
QToolButton *btnExport = new QToolButton(toolBar);
btnExport->setText(tr("Save"));
Expand Down Expand Up @@ -885,11 +864,6 @@ Plot* PlotWindow::getPlot()
return mpPlot;
}

QToolButton* PlotWindow::getPanButton()
{
return mpPanButton;
}

void PlotWindow::receiveMessage(QStringList arguments)
{
foreach (PlotCurve *pCurve, mpPlot->getPlotCurvesList())
Expand Down
3 changes: 0 additions & 3 deletions OMPlot/OMPlotGUI/PlotWindow.h
Expand Up @@ -68,8 +68,6 @@ class PlotWindow : public QMainWindow
QToolButton *mpGridButton;
QToolButton *mpDetailedGridButton;
QToolButton *mpNoGridButton;
QToolButton *mpZoomButton;
QToolButton *mpPanButton;
QToolButton *mpAutoScaleButton;
QToolButton *mpSetupButton;
QTextStream *mpTextStream;
Expand Down Expand Up @@ -129,7 +127,6 @@ class PlotWindow : public QMainWindow
QString getFooter();
void checkForErrors(QStringList variables, QStringList variablesPlotted);
Plot* getPlot();
QToolButton* getPanButton();
void receiveMessage(QStringList arguments);
void closeEvent(QCloseEvent *event);
signals:
Expand Down

0 comments on commit 9b947e8

Please sign in to comment.