reworked how context-menus are specified/activated

prepared for future reworks
some renames
This commit is contained in:
Jan W. Krieger 2019-01-28 10:46:38 +01:00
parent 75d8fc8314
commit 17a4473e4f
4 changed files with 188 additions and 100 deletions

View File

@ -102,11 +102,11 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) :
cmbLeftNoModMouseAction->addItem("PanPlotOnMove"); cmbLeftNoModMouseAction->addItem("PanPlotOnMove");
cmbLeftNoModMouseAction->addItem("PanPlotOnRelease"); cmbLeftNoModMouseAction->addItem("PanPlotOnRelease");
cmbLeftNoModMouseAction->addItem("ZoomRectangle"); cmbLeftNoModMouseAction->addItem("ZoomRectangle");
cmbLeftNoModMouseAction->addItem("RectangleEvents"); cmbLeftNoModMouseAction->addItem("DrawRectangleForEvent");
cmbLeftNoModMouseAction->addItem("CircleEvents"); cmbLeftNoModMouseAction->addItem("DrawCircleForEvent");
cmbLeftNoModMouseAction->addItem("EllipseEvents"); cmbLeftNoModMouseAction->addItem("DrawEllipseForEvent");
cmbLeftNoModMouseAction->addItem("LineEvents"); cmbLeftNoModMouseAction->addItem("DrawLineForEvent");
cmbLeftNoModMouseAction->addItem("ScribbleEvents"); cmbLeftNoModMouseAction->addItem("ScribbleForEvents");
cmbLeftNoModMouseAction->addItem("NoMouseAction"); cmbLeftNoModMouseAction->addItem("NoMouseAction");
cmbLeftNoModMouseAction->setCurrentIndex(2); cmbLeftNoModMouseAction->setCurrentIndex(2);
connect(cmbLeftNoModMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setLeftMouseAction(int))); connect(cmbLeftNoModMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setLeftMouseAction(int)));
@ -118,11 +118,11 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) :
cmbLeftCtrlModMouseAction->addItem("PanPlotOnMove"); cmbLeftCtrlModMouseAction->addItem("PanPlotOnMove");
cmbLeftCtrlModMouseAction->addItem("PanPlotOnRelease"); cmbLeftCtrlModMouseAction->addItem("PanPlotOnRelease");
cmbLeftCtrlModMouseAction->addItem("ZoomRectangle"); cmbLeftCtrlModMouseAction->addItem("ZoomRectangle");
cmbLeftCtrlModMouseAction->addItem("RectangleEvents"); cmbLeftCtrlModMouseAction->addItem("DrawRectangleForEvent");
cmbLeftCtrlModMouseAction->addItem("CircleEvents"); cmbLeftCtrlModMouseAction->addItem("DrawCircleForEvent");
cmbLeftCtrlModMouseAction->addItem("EllipseEvents"); cmbLeftCtrlModMouseAction->addItem("DrawEllipseForEvent");
cmbLeftCtrlModMouseAction->addItem("LineEvents"); cmbLeftCtrlModMouseAction->addItem("DrawLineForEvent");
cmbLeftCtrlModMouseAction->addItem("ScribbleEvents"); cmbLeftCtrlModMouseAction->addItem("ScribbleForEvents");
cmbLeftCtrlModMouseAction->addItem("NoMouseAction"); cmbLeftCtrlModMouseAction->addItem("NoMouseAction");
cmbLeftCtrlModMouseAction->setCurrentIndex(0); cmbLeftCtrlModMouseAction->setCurrentIndex(0);
connect(cmbLeftCtrlModMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setLeftCtrlMouseAction(int))); connect(cmbLeftCtrlModMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setLeftCtrlMouseAction(int)));
@ -134,21 +134,32 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) :
cmbRightNoModMouseAction->addItem("PanPlotOnMove"); cmbRightNoModMouseAction->addItem("PanPlotOnMove");
cmbRightNoModMouseAction->addItem("PanPlotOnRelease"); cmbRightNoModMouseAction->addItem("PanPlotOnRelease");
cmbRightNoModMouseAction->addItem("ZoomRectangle"); cmbRightNoModMouseAction->addItem("ZoomRectangle");
cmbRightNoModMouseAction->addItem("RectangleEvents"); cmbRightNoModMouseAction->addItem("DrawRectangleForEvent");
cmbRightNoModMouseAction->addItem("CircleEvents"); cmbRightNoModMouseAction->addItem("DrawCircleForEvent");
cmbRightNoModMouseAction->addItem("EllipseEvents"); cmbRightNoModMouseAction->addItem("DrawEllipseForEvent");
cmbRightNoModMouseAction->addItem("LineEvents"); cmbRightNoModMouseAction->addItem("DrawLineForEvent");
cmbRightNoModMouseAction->addItem("ScribbleEvents"); cmbRightNoModMouseAction->addItem("ScribbleForEvents");
cmbRightNoModMouseAction->addItem("ContextMenu"); cmbRightNoModMouseAction->addItem("ContextMenu");
cmbRightNoModMouseAction->setCurrentIndex(5); cmbRightNoModMouseAction->setCurrentIndex(5);
connect(cmbRightNoModMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setRightMouseAction(int))); connect(cmbRightNoModMouseAction, SIGNAL(currentIndexChanged(int)), this, SLOT(setRightMouseAction(int)));
setRightMouseAction(cmbRightNoModMouseAction->currentIndex()); setRightMouseAction(cmbRightNoModMouseAction->currentIndex());
// add a QComboBox that allows to set whether the right mouse button may show the context menu on a single click // add a QComboBox that allows to set whether the right mouse button may show the context menu on a single click
chkRightClickShowsContextMenu=new QCheckBox(this); cmbRightClickContextMenu=new QComboBox(this);
chkRightClickShowsContextMenu->setChecked(plot->isRightClickShowsContextMenuEnabled()); cmbRightClickContextMenu->addItem("StandardContextMenu");
layForm->addRow("mouse action: right-click shows context menu:", chkRightClickShowsContextMenu); cmbRightClickContextMenu->addItem("SpecialContextMenu");
connect(chkRightClickShowsContextMenu, SIGNAL(toggled(bool)), plot, SLOT(enableRightClickShowsContextMenu(bool))); cmbRightClickContextMenu->addItem("StandardAndSpecialContextMenu");
cmbRightClickContextMenu->addItem("NoContextMenu");
cmbRightClickContextMenu->setCurrentIndex(0);
layForm->addRow("mouse action: right-click context menu:", cmbRightClickContextMenu);
connect(cmbRightClickContextMenu, SIGNAL(currentIndexChanged(int)), this, SLOT(setRightClickContextMenu(int)));
// ... and add a special context menu
QMenu* special=new QMenu(plot);
special->addAction("Special entry 1 (no action!)");
special->addAction("Special entry 2 (no action!)");
special->addAction("Special entry 3 (no action!)");
special->addMenu("Special submenu")->addAction("Special subentry 1 (no action!)");
plot->setSpecialContextMenu(special);
// and add a QLabel to show the different events of the JKQTPlotter: // and add a QLabel to show the different events of the JKQTPlotter:
labMouseMoved=new QLabel(this); labMouseMoved=new QLabel(this);
@ -177,19 +188,19 @@ TestUserInteraction::TestUserInteraction(QWidget *parent) :
void TestUserInteraction::setLeftMouseAction(int index) void TestUserInteraction::setLeftMouseAction(int index)
{ {
if (index==cmbLeftNoModMouseAction->count()-1) plot->deregisterMouseDragAction(Qt::LeftButton, Qt::NoModifier); if (index==cmbLeftNoModMouseAction->count()-1) plot->deregisterMouseDragAction(Qt::LeftButton, Qt::NoModifier);
else plot->registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, static_cast<JKQTPlotter::MouseActionMode>(index)); else plot->registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, static_cast<JKQTPlotter::MouseDragActions>(index));
} }
void TestUserInteraction::setLeftCtrlMouseAction(int index) void TestUserInteraction::setLeftCtrlMouseAction(int index)
{ {
if (index==cmbLeftCtrlModMouseAction->count()-1) plot->deregisterMouseDragAction(Qt::LeftButton, Qt::ControlModifier); if (index==cmbLeftCtrlModMouseAction->count()-1) plot->deregisterMouseDragAction(Qt::LeftButton, Qt::ControlModifier);
else plot->registerMouseDragAction(Qt::LeftButton, Qt::ControlModifier, static_cast<JKQTPlotter::MouseActionMode>(index)); else plot->registerMouseDragAction(Qt::LeftButton, Qt::ControlModifier, static_cast<JKQTPlotter::MouseDragActions>(index));
} }
void TestUserInteraction::setRightMouseAction(int index) void TestUserInteraction::setRightMouseAction(int index)
{ {
if (index==cmbRightNoModMouseAction->count()-1) plot->deregisterMouseDragAction(Qt::RightButton, Qt::NoModifier); if (index==cmbRightNoModMouseAction->count()-1) plot->deregisterMouseDragAction(Qt::RightButton, Qt::NoModifier);
else plot->registerMouseDragAction(Qt::RightButton, Qt::NoModifier, static_cast<JKQTPlotter::MouseActionMode>(index)); else plot->registerMouseDragAction(Qt::RightButton, Qt::NoModifier, static_cast<JKQTPlotter::MouseDragActions>(index));
} }
void TestUserInteraction::setPlotMagnification(int index) void TestUserInteraction::setPlotMagnification(int index)
@ -197,6 +208,11 @@ void TestUserInteraction::setPlotMagnification(int index)
plot->setMagnification(cmbMagnification->itemData(index).toDouble()); plot->setMagnification(cmbMagnification->itemData(index).toDouble());
} }
void TestUserInteraction::setRightClickContextMenu(int index)
{
plot->setContextMenuMode(static_cast<JKQTPlotter::ContextMenuModes>(index));
}
void TestUserInteraction::plotMouseMove(double x, double y) void TestUserInteraction::plotMouseMove(double x, double y)
{ {
labMouseMoved->setText(QString("plotMouseMove(%1, %2)").arg(x).arg(y)); labMouseMoved->setText(QString("plotMouseMove(%1, %2)").arg(x).arg(y));

View File

@ -25,6 +25,7 @@ class TestUserInteraction : public QMainWindow
void setLeftCtrlMouseAction(int index); void setLeftCtrlMouseAction(int index);
void setRightMouseAction(int index); void setRightMouseAction(int index);
void setPlotMagnification(int index); void setPlotMagnification(int index);
void setRightClickContextMenu(int index);
void plotMouseMove(double x, double y); void plotMouseMove(double x, double y);
void plotMouseClicked(double x, double y, Qt::KeyboardModifiers modifiers, Qt::MouseButton button); void plotMouseClicked(double x, double y, Qt::KeyboardModifiers modifiers, Qt::MouseButton button);
@ -51,7 +52,7 @@ class TestUserInteraction : public QMainWindow
QComboBox* cmbLeftNoModMouseAction; QComboBox* cmbLeftNoModMouseAction;
QComboBox* cmbLeftCtrlModMouseAction; QComboBox* cmbLeftCtrlModMouseAction;
QComboBox* cmbRightNoModMouseAction; QComboBox* cmbRightNoModMouseAction;
QCheckBox* chkRightClickShowsContextMenu; QComboBox* cmbRightClickContextMenu;
QCheckBox* chkLogX; QCheckBox* chkLogX;
QCheckBox* chkLogY; QCheckBox* chkLogY;
QCheckBox* chkZoomByMouseWheel; QCheckBox* chkZoomByMouseWheel;

View File

@ -106,9 +106,9 @@ void JKQTPlotter::init(bool datastore_internal, QWidget* parent, JKQTPDatastore*
displayMousePosition=true; displayMousePosition=true;
displayToolbar=true; displayToolbar=true;
toolbarAlwaysOn=false; toolbarAlwaysOn=false;
rightClickShowsContextMenu=true; contextMenuMode=ContextMenuModes::StandardContextMenu;
registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, MouseActionMode::ZoomRectangle); registerMouseDragAction(Qt::LeftButton, Qt::NoModifier, MouseDragActions::ZoomRectangle);
registerMouseDragAction(Qt::LeftButton, Qt::ControlModifier, MouseActionMode::PanPlotOnMove); registerMouseDragAction(Qt::LeftButton, Qt::ControlModifier, MouseDragActions::PanPlotOnMove);
zoomByMouseWheel=true; zoomByMouseWheel=true;
@ -273,22 +273,22 @@ void JKQTPlotter::paintUserAction() {
double y2=plotter->y2p(mouseDragRectYEnd)*magnification; double y2=plotter->y2p(mouseDragRectYEnd)*magnification;
double dx=x2-x1; double dx=x2-x1;
double dy=y2-y1; double dy=y2-y1;
if ((currentMouseDragAction.mode==JKQTPlotter::ZoomRectangle) || (currentMouseDragAction.mode==JKQTPlotter::RectangleEvents)) { if ((currentMouseDragAction.mode==JKQTPlotter::ZoomRectangle) || (currentMouseDragAction.mode==JKQTPlotter::DrawRectangleForEvent)) {
painter.setOpacity(0.2); painter.setOpacity(0.2);
painter.fillRect(QRectF(x1, y1, x2-x1, y2-y1), QBrush(userActionColor)); painter.fillRect(QRectF(x1, y1, x2-x1, y2-y1), QBrush(userActionColor));
painter.setOpacity(1.0); painter.setOpacity(1.0);
painter.drawRect(QRectF(x1, y1, x2-x1, y2-y1)); painter.drawRect(QRectF(x1, y1, x2-x1, y2-y1));
} else if (currentMouseDragAction.mode==JKQTPlotter::CircleEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::DrawCircleForEvent) {
QColor zc=userActionColor; QColor zc=userActionColor;
zc.setAlphaF(0.2); zc.setAlphaF(0.2);
painter.setBrush(QBrush(zc)); painter.setBrush(QBrush(zc));
painter.drawEllipse(QPointF(x1, y1), qMin(fabs(dx), fabs(dy)), qMin(fabs(dx), fabs(dy))); painter.drawEllipse(QPointF(x1, y1), qMin(fabs(dx), fabs(dy)), qMin(fabs(dx), fabs(dy)));
} else if (currentMouseDragAction.mode==JKQTPlotter::EllipseEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::DrawEllipseForEvent) {
QColor zc=userActionColor; QColor zc=userActionColor;
zc.setAlphaF(0.2); zc.setAlphaF(0.2);
painter.setBrush(QBrush(zc)); painter.setBrush(QBrush(zc));
painter.drawEllipse(QPointF(x1, y1), fabs(dx), fabs(dy)); painter.drawEllipse(QPointF(x1, y1), fabs(dx), fabs(dy));
} else if (currentMouseDragAction.mode==JKQTPlotter::LineEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::DrawLineForEvent) {
QPen pp=p; QPen pp=p;
pp.setColor(userActionColor); pp.setColor(userActionColor);
painter.setPen(pp); painter.setPen(pp);
@ -321,16 +321,16 @@ void JKQTPlotter::mouseMoveEvent ( QMouseEvent * event ) {
} }
if (currentMouseDragAction.isValid()) { if (currentMouseDragAction.isValid()) {
if (( (currentMouseDragAction.mode==JKQTPlotter::ZoomRectangle) || if (( (currentMouseDragAction.mode==JKQTPlotter::ZoomRectangle) ||
(currentMouseDragAction.mode==JKQTPlotter::RectangleEvents) || (currentMouseDragAction.mode==JKQTPlotter::DrawRectangleForEvent) ||
(currentMouseDragAction.mode==JKQTPlotter::CircleEvents) || (currentMouseDragAction.mode==JKQTPlotter::DrawCircleForEvent) ||
(currentMouseDragAction.mode==JKQTPlotter::EllipseEvents) || (currentMouseDragAction.mode==JKQTPlotter::DrawEllipseForEvent) ||
(currentMouseDragAction.mode==JKQTPlotter::ScribbleEvents) || (currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents) ||
(currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove) || (currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove) ||
(currentMouseDragAction.mode==JKQTPlotter::PanPlotOnRelease) || (currentMouseDragAction.mode==JKQTPlotter::PanPlotOnRelease) ||
(currentMouseDragAction.mode==JKQTPlotter::LineEvents) ) && (currentMouseDragAction.mode==JKQTPlotter::DrawLineForEvent) ) &&
mouseDragingRectangle) mouseDragingRectangle)
{ {
if (currentMouseDragAction.mode==JKQTPlotter::ScribbleEvents || currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove) { if (currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents || currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove) {
// start is last event position // start is last event position
mouseDragRectXStart=mouseDragRectXEnd; mouseDragRectXStart=mouseDragRectXEnd;
mouseDragRectYStart=mouseDragRectYEnd; mouseDragRectYStart=mouseDragRectYEnd;
@ -347,7 +347,7 @@ void JKQTPlotter::mouseMoveEvent ( QMouseEvent * event ) {
if (currentMouseDragAction.mode==JKQTPlotter::ZoomRectangle) { if (currentMouseDragAction.mode==JKQTPlotter::ZoomRectangle) {
emit plotNewZoomRectangle(mouseDragRectXStart, mouseDragRectXEnd, mouseDragRectYStart, mouseDragRectYEnd, event->modifiers()); emit plotNewZoomRectangle(mouseDragRectXStart, mouseDragRectXEnd, mouseDragRectYStart, mouseDragRectYEnd, event->modifiers());
} }
if ((currentMouseDragAction.mode==JKQTPlotter::ScribbleEvents) && ((mouseDragRectXStart!=mouseDragRectXEnd) || (mouseDragRectYStart!=mouseDragRectYEnd)) ) { if ((currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents) && ((mouseDragRectXStart!=mouseDragRectXEnd) || (mouseDragRectYStart!=mouseDragRectYEnd)) ) {
emit userScribbleClick(mouseDragRectXEnd, mouseDragRectYEnd, event->modifiers(), false, false); emit userScribbleClick(mouseDragRectXEnd, mouseDragRectYEnd, event->modifiers(), false, false);
} }
if ((currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove) && ((mouseDragRectXStart!=mouseDragRectXEnd) || (mouseDragRectYStart!=mouseDragRectYEnd)) ) { if ((currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove) && ((mouseDragRectXStart!=mouseDragRectXEnd) || (mouseDragRectYStart!=mouseDragRectYEnd)) ) {
@ -393,9 +393,9 @@ void JKQTPlotter::mousePressEvent ( QMouseEvent * event ){
mouseDragRectYEndPixel=mouseDragRectYStartPixel=event->y(); mouseDragRectYEndPixel=mouseDragRectYStartPixel=event->y();
mouseDragingRectangle=true; mouseDragingRectangle=true;
oldImage=image; oldImage=image;
if (currentMouseDragAction.mode==JKQTPlotter::ScribbleEvents) emit userScribbleClick(mouseDragRectXStart, mouseDragRectYStart, event->modifiers(), true, false); if (currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents) emit userScribbleClick(mouseDragRectXStart, mouseDragRectYStart, event->modifiers(), true, false);
event->accept(); event->accept();
} else if (event->button()==Qt::RightButton && event->modifiers()==Qt::NoModifier && rightClickShowsContextMenu) { } else if (event->button()==Qt::RightButton && event->modifiers()==Qt::NoModifier && contextMenuMode!=NoContextMenu) {
mouseLastClickX=event->x(); mouseLastClickX=event->x();
mouseLastClickY=event->y(); mouseLastClickY=event->y();
openContextMenu(event->x(), event->y()); openContextMenu(event->x(), event->y());
@ -450,18 +450,18 @@ void JKQTPlotter::mouseReleaseEvent ( QMouseEvent * event ){
zoomRect.translate(mouseDragRectXStartPixel-mouseDragRectXEndPixel, mouseDragRectYStartPixel-mouseDragRectYEndPixel); zoomRect.translate(mouseDragRectXStartPixel-mouseDragRectXEndPixel, mouseDragRectYStartPixel-mouseDragRectYEndPixel);
} }
setXY(plotter->p2x(zoomRect.left()), plotter->p2x(zoomRect.right()), plotter->p2y(zoomRect.bottom()), plotter->p2y(zoomRect.top())); setXY(plotter->p2x(zoomRect.left()), plotter->p2x(zoomRect.right()), plotter->p2y(zoomRect.bottom()), plotter->p2y(zoomRect.top()));
} else if (currentMouseDragAction.mode==JKQTPlotter::RectangleEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::DrawRectangleForEvent) {
emit userRectangleFinished(x1, y1, x2-x1, y2-y1, event->modifiers()); emit userRectangleFinished(x1, y1, x2-x1, y2-y1, event->modifiers());
} else if (currentMouseDragAction.mode==JKQTPlotter::CircleEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::DrawCircleForEvent) {
emit userCircleFinished(x1, y1, qMin(fabs(x2-x1), fabs(y2-y1)), event->modifiers()); emit userCircleFinished(x1, y1, qMin(fabs(x2-x1), fabs(y2-y1)), event->modifiers());
} else if (currentMouseDragAction.mode==JKQTPlotter::EllipseEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::DrawEllipseForEvent) {
emit userEllipseFinished(x1, y1, fabs(x2-x1), fabs(y2-y1), event->modifiers()); emit userEllipseFinished(x1, y1, fabs(x2-x1), fabs(y2-y1), event->modifiers());
} else if (currentMouseDragAction.mode==JKQTPlotter::LineEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::DrawLineForEvent) {
emit userLineFinished(x1, y1, x2, y2, event->modifiers()); emit userLineFinished(x1, y1, x2, y2, event->modifiers());
} }
} }
if (currentMouseDragAction.mode!=JKQTPlotter::ZoomRectangle) update(); if (currentMouseDragAction.mode!=JKQTPlotter::ZoomRectangle) update();
if (currentMouseDragAction.mode==JKQTPlotter::ScribbleEvents) emit userScribbleClick(x1, y1, event->modifiers(), false, true); if (currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents) emit userScribbleClick(x1, y1, event->modifiers(), false, true);
event->accept(); event->accept();
} }
@ -478,7 +478,7 @@ void JKQTPlotter::mouseDoubleClickEvent ( QMouseEvent * event ){
mouseLastClickY=event->y(); mouseLastClickY=event->y();
if (event->button()==Qt::LeftButton) { if (event->button()==Qt::LeftButton) {
if (leftDoubleClickAction==LeftDoubleClickContextMenu) { if (leftDoubleClickAction==LeftDoubleClickContextMenu) {
openContextMenu(event->x(), event->y()); openStandardContextMenu(event->x(), event->y());
event->accept(); event->accept();
} else if (leftDoubleClickAction==LeftDoubleClickSpecialContextMenu) { } else if (leftDoubleClickAction==LeftDoubleClickSpecialContextMenu) {
openSpecialContextMenu(event->x(), event->y()); openSpecialContextMenu(event->x(), event->y());
@ -631,25 +631,25 @@ void JKQTPlotter::updateCursor() {
static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_zoom.png"); static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_zoom.png");
static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_zoom_mask.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_zoom_mask.png");
setCursor(QCursor(cursor, mask, 9, 14)); setCursor(QCursor(cursor, mask, 9, 14));
} else if (currentMouseDragAction.mode==JKQTPlotter::RectangleEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::DrawRectangleForEvent) {
static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_rectangle.png"); static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_rectangle.png");
static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_rectangle_mask.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_rectangle_mask.png");
setCursor(QCursor(cursor, mask, 9, 14)); setCursor(QCursor(cursor, mask, 9, 14));
} else if (currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove || currentMouseDragAction.mode==JKQTPlotter::PanPlotOnRelease) { } else if (currentMouseDragAction.mode==JKQTPlotter::PanPlotOnMove || currentMouseDragAction.mode==JKQTPlotter::PanPlotOnRelease) {
setCursor(QCursor(Qt::ClosedHandCursor)); setCursor(QCursor(Qt::ClosedHandCursor));
} else if (currentMouseDragAction.mode==JKQTPlotter::CircleEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::DrawCircleForEvent) {
static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_circle.png"); static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_circle.png");
static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_circle_mask.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_circle_mask.png");
setCursor(QCursor(cursor, mask, 9, 14)); setCursor(QCursor(cursor, mask, 9, 14));
} else if (currentMouseDragAction.mode==JKQTPlotter::EllipseEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::DrawEllipseForEvent) {
static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_ellipse.png"); static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_ellipse.png");
static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_ellipse_mask.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_ellipse_mask.png");
setCursor(QCursor(cursor, mask, 9, 14)); setCursor(QCursor(cursor, mask, 9, 14));
} else if (currentMouseDragAction.mode==JKQTPlotter::LineEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::DrawLineForEvent) {
static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_line.png"); static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_line.png");
static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_line_mask.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_line_mask.png");
setCursor(QCursor(cursor, mask, 9, 14)); setCursor(QCursor(cursor, mask, 9, 14));
} else if (currentMouseDragAction.mode==JKQTPlotter::ScribbleEvents) { } else if (currentMouseDragAction.mode==JKQTPlotter::ScribbleForEvents) {
static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_scribble.png"); static QBitmap cursor(":/JKQTPlotter/jkqtp_cursor_scribble.png");
static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_scribble_mask.png"); static QBitmap mask(":/JKQTPlotter/jkqtp_cursor_scribble_mask.png");
setCursor(QCursor(cursor, mask, 9, 14)); setCursor(QCursor(cursor, mask, 9, 14));
@ -878,15 +878,10 @@ void JKQTPlotter::setRightMouseButtonAction(const JKQTPlotter::RightMouseButtonA
this->rightMouseButtonAction = __value; this->rightMouseButtonAction = __value;
} }
void JKQTPlotter::enableRightClickShowsContextMenu(bool enabled) void JKQTPlotter::setContextMenuMode(JKQTPlotter::ContextMenuModes mode) {
{ contextMenuMode=mode;
this->rightClickShowsContextMenu=enabled;
} }
void JKQTPlotter::disableRightClickShowsContextMenu(bool disabled)
{
enableRightClickShowsContextMenu(!disabled);
}
JKQTPlotter::RightMouseButtonAction JKQTPlotter::getActionRightMouseButton() const JKQTPlotter::RightMouseButtonAction JKQTPlotter::getActionRightMouseButton() const
{ {
@ -903,11 +898,11 @@ JKQTPlotter::LeftDoubleClickAction JKQTPlotter::getActionLeftDoubleClick() const
return this->leftDoubleClickAction; return this->leftDoubleClickAction;
} }
QMenu *JKQTPlotter::getMenuSpecialContextMenu() const { QMenu *JKQTPlotter::getSpecialContextMenu() const {
return this->menuSpecialContextMenu; return this->menuSpecialContextMenu;
} }
void JKQTPlotter::setMenuSpecialContextMenu(QMenu *menu) void JKQTPlotter::setSpecialContextMenu(QMenu *menu)
{ {
menuSpecialContextMenu=menu; menuSpecialContextMenu=menu;
if (menuSpecialContextMenu) { if (menuSpecialContextMenu) {
@ -942,9 +937,8 @@ int JKQTPlotter::getMouseLastClickY() const {
return this->mouseLastClickY; return this->mouseLastClickY;
} }
bool JKQTPlotter::isRightClickShowsContextMenuEnabled() const JKQTPlotter::ContextMenuModes JKQTPlotter::getContextMenuMode() const {
{ return contextMenuMode;
return this->rightClickShowsContextMenu;
} }
void JKQTPlotter::setMagnification(double m) void JKQTPlotter::setMagnification(double m)
@ -980,13 +974,30 @@ void JKQTPlotter::populateToolbar(QToolBar *toolbar) const
} }
void JKQTPlotter::openContextMenu() void JKQTPlotter::openContextMenu()
{ {
openContextMenu(mouseLastClickX, mouseLastClickY); openContextMenu(mouseLastClickX, mouseLastClickY);
} }
void JKQTPlotter::openContextMenu(int x, int y) void JKQTPlotter::openContextMenu(int x, int y)
{
if (contextMenuMode==ContextMenuModes::StandardContextMenu) {
openStandardContextMenu(x,y);
} else if (contextMenuMode==ContextMenuModes::SpecialContextMenu) {
openSpecialContextMenu(x,y);
} else if (contextMenuMode==ContextMenuModes::StandardAndSpecialContextMenu) {
openStandardAndSpecialContextMenu(x,y);
}
}
void JKQTPlotter::openStandardContextMenu()
{
openStandardContextMenu(mouseLastClickX, mouseLastClickY);
}
void JKQTPlotter::openStandardContextMenu(int x, int y)
{ {
//qDebug()<<"openContextMenu("<<x<<y<<contextMenu<<")"; //qDebug()<<"openContextMenu("<<x<<y<<contextMenu<<")";
mouseContextX=plotter->p2x(x/magnification); mouseContextX=plotter->p2x(x/magnification);
@ -1022,7 +1033,34 @@ void JKQTPlotter::openSpecialContextMenu(int x, int y)
} }
} }
QHash<QPair<Qt::MouseButton,Qt::KeyboardModifier>, JKQTPlotter::MouseActionMode>::const_iterator JKQTPlotter::findMatchingMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const void JKQTPlotter::openStandardAndSpecialContextMenu()
{
openStandardAndSpecialContextMenu(mouseLastClickX, mouseLastClickY);
}
void JKQTPlotter::openStandardAndSpecialContextMenu(int x, int y)
{
//qDebug()<<"openContextMenu("<<x<<y<<contextMenu<<")";
mouseContextX=plotter->p2x(x/magnification);
mouseContextY=plotter->p2y((y-getPlotYOffset())/magnification);
contextMenu->close();
initContextMenu();
if (menuSpecialContextMenu) {
contextMenu->addSeparator();
for (QAction* act: menuSpecialContextMenu->actions()) {
contextMenu->addAction(act);
}
}
contextMenu->popup(mapToGlobal(QPoint(x,y)));
//qDebug()<<" -> "<<mapToGlobal(QPoint(x,y))<<contextMenu->size()<<contextMenu->pos()<<contextMenu->parent();
emit contextMenuOpened(mouseContextX, mouseContextY, contextMenu);
//qDebug()<<"openContextMenu("<<x<<y<<contextMenu<<") ... DONE";
}
QHash<QPair<Qt::MouseButton,Qt::KeyboardModifier>, JKQTPlotter::MouseDragActions>::const_iterator JKQTPlotter::findMatchingMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const
{ {
if (modifiers.testFlag(Qt::ShiftModifier)) { if (modifiers.testFlag(Qt::ShiftModifier)) {
return registeredMouseActionModes.find(qMakePair<Qt::MouseButton, Qt::KeyboardModifier>(button, Qt::ShiftModifier)); return registeredMouseActionModes.find(qMakePair<Qt::MouseButton, Qt::KeyboardModifier>(button, Qt::ShiftModifier));
@ -1051,7 +1089,7 @@ void JKQTPlotter::setPlotUpdateEnabled(bool enable)
//qDebug()<<objectName()<<" doDrawing="<<doDrawing; //qDebug()<<objectName()<<" doDrawing="<<doDrawing;
} }
void JKQTPlotter::registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifier modifier, JKQTPlotter::MouseActionMode action) void JKQTPlotter::registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifier modifier, JKQTPlotter::MouseDragActions action)
{ {
registeredMouseActionModes[qMakePair<Qt::MouseButton, Qt::KeyboardModifier>(button, modifier)]=action; registeredMouseActionModes[qMakePair<Qt::MouseButton, Qt::KeyboardModifier>(button, modifier)]=action;
} }
@ -1078,7 +1116,7 @@ JKQTPlotter::MouseDragAction::MouseDragAction():
} }
JKQTPlotter::MouseDragAction::MouseDragAction(Qt::MouseButton _mouseButton, Qt::KeyboardModifier _modifier, JKQTPlotter::MouseActionMode _mode): JKQTPlotter::MouseDragAction::MouseDragAction(Qt::MouseButton _mouseButton, Qt::KeyboardModifier _modifier, JKQTPlotter::MouseDragActions _mode):
mode(_mode), modifier(_modifier), mouseButton(_mouseButton), valid(true) mode(_mode), modifier(_modifier), mouseButton(_mouseButton), valid(true)
{ {

View File

@ -171,7 +171,9 @@ LIB_EXPORT void initJKQTPlotterResources();
* . * .
* *
* The right mouse button has a special role: If it is single-clicked and no JKQTPlotter::MouseActionMode is specified * The right mouse button has a special role: If it is single-clicked and no JKQTPlotter::MouseActionMode is specified
* for the vent, it opens the context menu, unless you call \c enableRightClickShowsContextMenu(false) . * for the vent, it opens the context menu, unless you call \c setContextMenuMoode(JKQTPlotter::NoContextMenu) .
* You can also use setContextMenuMoode() to specify which type of context menu is shown. See JKQTPlotter::ContextMenuModes
* for details on the available modes.
* *
* For any mouse-click, one of the following signals is emitted: * For any mouse-click, one of the following signals is emitted:
* - plotMouseClicked() for any single-click (during the pressDown-Event!) * - plotMouseClicked() for any single-click (during the pressDown-Event!)
@ -211,19 +213,47 @@ LIB_EXPORT void initJKQTPlotterResources();
class LIB_EXPORT JKQTPlotter: public QWidget { class LIB_EXPORT JKQTPlotter: public QWidget {
Q_OBJECT Q_OBJECT
public: public:
/** \brief availble user-action mode this JKQtPlotter use when mouse events occur. /** \brief Availble action this JKQtPlotter can perform when mouse events occur.
* This allows you to e.g. draw rectangles or lines over the plot and receive a signal, when the drawing finishes */ * This allows you to e.g. draw rectangles or lines over the plot and receive a signal, when the drawing finishes */
enum MouseActionMode { enum MouseDragActions {
PanPlotOnMove=0, /*!< \brief the user can drag the current plot window while keeping the left mouse-button pushed down (=panning), the new widow is applied/displayed whenever the mouse moves */ PanPlotOnMove=0, /*!< \brief the user can drag the current plot window while keeping the left mouse-button pushed down (=panning), the new widow is applied/displayed whenever the mouse moves */
PanPlotOnRelease, /*!< \brief the user can drag the current plot window while keeping the left mouse-button pushed down (=panning), the new widow is applied/displayed when the left mouse button is released */ PanPlotOnRelease, /*!< \brief the user can drag the current plot window while keeping the left mouse-button pushed down (=panning), the new widow is applied/displayed when the left mouse button is released */
ZoomRectangle, /*!< \brief draw a rectangle and when finish zoom to that rectangle */ ZoomRectangle, /*!< \brief draw a rectangle and when finish zoom to that rectangle */
RectangleEvents, /*!< \brief draw a rectangle and when finished execute the signal userRectangleFinished() */ DrawRectangleForEvent, /*!< \brief draw a rectangle and when finished execute the signal userRectangleFinished() */
CircleEvents, /*!< \brief draw a circle and when finished execute the signal userCircleFinished() */ DrawCircleForEvent, /*!< \brief draw a circle and when finished execute the signal userCircleFinished() */
EllipseEvents, /*!< \brief draw an ellipse and when finished execute the signal userEllipseFinished() */ DrawEllipseForEvent, /*!< \brief draw an ellipse and when finished execute the signal userEllipseFinished() */
LineEvents, /*!< \brief draw a line and when finished execute the signal userLineFinished() */ DrawLineForEvent, /*!< \brief draw a line and when finished execute the signal userLineFinished() */
ScribbleEvents, /*!< \brief let the user scribble on the plot (left mouse button is kept pressed) and call userScribbleClick() for each new position */ ScribbleForEvents, /*!< \brief let the user scribble on the plot (left mouse button is kept pressed) and call userScribbleClick() for each new position */
}; };
/** \brief actions that can be bound to a double-click of the mouse */
enum MouseDoubleClickActions {
ClickZoomsIn=0, /*!< \brief a (double-)click zooms into the plot at the current mouse location */
ClickZoomsOut, /*!< \brief a (double-)click zooms out of the plot at the current mouse location */
ClickOpensContextMenu, /*!< \brief a (double-)click opens the context menu */
ClickOpensSpecialContextMenu, /*!< \brief a (double-)click opens the special context menu \see setSpecialContextMenu() */
NoClickAction, /*!< \brief no action is performed */
};
/** \brief actions that can be bound to a mouse wheel event */
enum MouseWheelActions {
ZoomByWheel=0, /*!< \brief use the mouse-wheel for zooming */
PanByWheel, /*!< \brief use the mouse-wheel for panning the plot */
NoWheelAction, /*!< \brief no mouse-wheel action */
};
/** \brief modes for the context menu */
enum ContextMenuModes {
StandardContextMenu=0, /*!< \brief only show the standard context menu */
SpecialContextMenu, /*!< \brief only show the special context menu \see setSpecialContextMenu() */
StandardAndSpecialContextMenu, /*!< \brief show the standard context menu, with the special context menu incorporated \see setSpecialContextMenu() */
NoContextMenu, /*!< \brief don't show a context menu at all */
};
/** \brief options of how to react to a right mouse button click */ /** \brief options of how to react to a right mouse button click */
enum RightMouseButtonAction { enum RightMouseButtonAction {
RightMouseButtonNone=0, /*!< \brief do not perform any action on a right mouse button click */ RightMouseButtonNone=0, /*!< \brief do not perform any action on a right mouse button click */
@ -369,7 +399,7 @@ class LIB_EXPORT JKQTPlotter: public QWidget {
/** \brief registeres a certain mouse action \a action to be executed when a mouse drag operation is /** \brief registeres a certain mouse action \a action to be executed when a mouse drag operation is
* initialized with the given \a button and \a modifier */ * initialized with the given \a button and \a modifier */
void registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifier modifier, MouseActionMode action); void registerMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifier modifier, MouseDragActions action);
/** \brief deregisteres the mouse action to be executed when a mouse drag operation is /** \brief deregisteres the mouse action to be executed when a mouse drag operation is
* initialized with the given \a button and \a modifier */ * initialized with the given \a button and \a modifier */
void deregisterMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifier modifier); void deregisterMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifier modifier);
@ -383,11 +413,11 @@ class LIB_EXPORT JKQTPlotter: public QWidget {
\details Description of the parameter leftDoubleClickAction is: <BLOCKQUOTE>\copydoc leftDoubleClickAction </BLOCKQUOTE> \details Description of the parameter leftDoubleClickAction is: <BLOCKQUOTE>\copydoc leftDoubleClickAction </BLOCKQUOTE>
\see leftDoubleClickAction for more information */ \see leftDoubleClickAction for more information */
LeftDoubleClickAction getActionLeftDoubleClick() const; LeftDoubleClickAction getActionLeftDoubleClick() const;
/*! \brief returns the property menuSpecialContextMenu ( \copybrief menuSpecialContextMenu ). \details Description of the parameter menuSpecialContextMenu is: <BLOCKQUOTE>\copydoc menuSpecialContextMenu </BLOCKQUOTE>. \see menuSpecialContextMenu for more information */ /*! \brief returns the currently set special context menu object */
QMenu *getMenuSpecialContextMenu() const; QMenu *getSpecialContextMenu() const;
/*! \brief set the property menuSpecialContextMenu ( \copybrief menuSpecialContextMenu ). \details Description of the parameter menuSpecialContextMenu is: <BLOCKQUOTE>\copydoc menuSpecialContextMenu </BLOCKQUOTE>. \see menuSpecialContextMenu for more information */ /*! \brief sets a QMenu object to be used as special context menu */
void setMenuSpecialContextMenu(QMenu* menu); void setSpecialContextMenu(QMenu* menu);
/*! \brief returns the property zoomByMouseWheel ( \copybrief zoomByMouseWheel ). /*! \brief returns the property zoomByMouseWheel ( \copybrief zoomByMouseWheel ).
\details Description of the parameter zoomByMouseWheel is: <BLOCKQUOTE>\copydoc zoomByMouseWheel </BLOCKQUOTE> \details Description of the parameter zoomByMouseWheel is: <BLOCKQUOTE>\copydoc zoomByMouseWheel </BLOCKQUOTE>
\see zoomByMouseWheel for more information */ \see zoomByMouseWheel for more information */
@ -502,11 +532,9 @@ class LIB_EXPORT JKQTPlotter: public QWidget {
return getConstplotter()->getKeyFontSize(); return getConstplotter()->getKeyFontSize();
} }
/** \brief returns the currently set mode for the context menu \see ContextMenuModes, JKQTPLOTTER_USERMOUSEINTERACTION */
ContextMenuModes getContextMenuMode() const;
/** \brief checks, whether showing the context menu on a right-button click on the mouse is enabled
* \see enableRightClickShowsContextMenu(), disableRightClickShowsContextMenu(), JKQTPLOTTER_USERMOUSEINTERACTION
*/
bool isRightClickShowsContextMenuEnabled() const;
public slots: public slots:
/** \brief set the current plot magnification */ /** \brief set the current plot magnification */
@ -626,14 +654,9 @@ class LIB_EXPORT JKQTPlotter: public QWidget {
\see rightMouseButtonAction for more information */ \see rightMouseButtonAction for more information */
void setRightMouseButtonAction(const RightMouseButtonAction & __value); void setRightMouseButtonAction(const RightMouseButtonAction & __value);
/** \brief enables showing the context menu on a right-button click on the mouse
* \see disableRightClickShowsContextMenu(), JKQTPLOTTER_USERMOUSEINTERACTION /** \brief sets the mode if the standard context menu \see ContextMenuModes, JKQTPLOTTER_USERMOUSEINTERACTION */
*/ void setContextMenuMode(ContextMenuModes mode);
void enableRightClickShowsContextMenu(bool enabled=true);
/** \brief disables showing the context menu on a right-button click on the mouse
* \see enableRightClickShowsContextMenu(), JKQTPLOTTER_USERMOUSEINTERACTION
*/
void disableRightClickShowsContextMenu(bool disabled=true);
/** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x-axis to the other x-axis */ /** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x-axis to the other x-axis */
void synchronizeXAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTPlotter* sender); void synchronizeXAxis(double newxmin, double newxmax, double newymin, double newymax, JKQTPlotter* sender);
@ -650,11 +673,20 @@ class LIB_EXPORT JKQTPlotter: public QWidget {
void openContextMenu(); void openContextMenu();
/** \brief open the context menu at the mouse position \a x and \a y */ /** \brief open the context menu at the mouse position \a x and \a y */
void openContextMenu(int x, int y); void openContextMenu(int x, int y);
/** \brief open the standard context menu at the mouse position of the last click */
void openStandardContextMenu();
/** \brief open the standard context menu at the mouse position \a x and \a y */
void openStandardContextMenu(int x, int y);
/** \brief open the special context menu at the mouse position of the last click */ /** \brief open the special context menu at the mouse position of the last click */
void openSpecialContextMenu(); void openSpecialContextMenu();
/** \brief open the special context menu at the mouse position \a x and \a y */ /** \brief open the special context menu at the mouse position \a x and \a y */
void openSpecialContextMenu(int x, int y); void openSpecialContextMenu(int x, int y);
/** \brief open the standard context menu with the special context menu integrated at the mouse position of the last click */
void openStandardAndSpecialContextMenu();
/** \brief open the standard context menu with the special context menu integrated at the mouse position \a x and \a y */
void openStandardAndSpecialContextMenu(int x, int y);
/** \brief sets absolute minimum and maximum x-value to plot */ /** \brief sets absolute minimum and maximum x-value to plot */
inline void setAbsoluteX(double xminn, double xmaxx) { plotter->setAbsoluteX(xminn, xmaxx); } inline void setAbsoluteX(double xminn, double xmaxx) { plotter->setAbsoluteX(xminn, xmaxx); }
@ -794,8 +826,8 @@ class LIB_EXPORT JKQTPlotter: public QWidget {
struct LIB_EXPORT MouseDragAction { struct LIB_EXPORT MouseDragAction {
/** \brief constructs an invalid object */ /** \brief constructs an invalid object */
MouseDragAction(); MouseDragAction();
MouseDragAction(Qt::MouseButton _mouseButton, Qt::KeyboardModifier _modifier, MouseActionMode _mode); MouseDragAction(Qt::MouseButton _mouseButton, Qt::KeyboardModifier _modifier, MouseDragActions _mode);
MouseActionMode mode; MouseDragActions mode;
Qt::KeyboardModifier modifier; Qt::KeyboardModifier modifier;
Qt::MouseButton mouseButton; Qt::MouseButton mouseButton;
bool isValid() const; bool isValid() const;
@ -808,13 +840,10 @@ class LIB_EXPORT JKQTPlotter: public QWidget {
MouseDragAction currentMouseDragAction; MouseDragAction currentMouseDragAction;
/** \brief lists all availble mouse action modes */ /** \brief lists all availble mouse action modes */
QHash<QPair<Qt::MouseButton,Qt::KeyboardModifier>, MouseActionMode> registeredMouseActionModes; QHash<QPair<Qt::MouseButton,Qt::KeyboardModifier>, MouseDragActions> registeredMouseActionModes;
/** \brief searches registeredMouseActionModes for a matching action */ /** \brief searches registeredMouseActionModes for a matching action */
QHash<QPair<Qt::MouseButton,Qt::KeyboardModifier>, MouseActionMode>::const_iterator findMatchingMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const; QHash<QPair<Qt::MouseButton,Qt::KeyboardModifier>, MouseDragActions>::const_iterator findMatchingMouseDragAction(Qt::MouseButton button, Qt::KeyboardModifiers modifiers) const;
/** \brief specifies whether to show the context menu, when the right button of the mouse is clicked */
bool rightClickShowsContextMenu;
/** \brief you may overwrite this method to modify the given context emnu before it is displayed. /** \brief you may overwrite this method to modify the given context emnu before it is displayed.
* *
@ -1014,12 +1043,15 @@ class LIB_EXPORT JKQTPlotter: public QWidget {
double mousePosX; double mousePosX;
double mousePosY; double mousePosY;
/** \brief magnification factor for the display of the plot */
double magnification; double magnification;
QSize minSize; QSize minSize;
/** \brief the context menu object used by this JKQTPlotter */
QMenu* contextMenu; QMenu* contextMenu;
/** \brief current mode for the default context menu (i.e. the right-click context menu) */
ContextMenuModes contextMenuMode;
/** \brief x-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle) */ /** \brief x-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle) */
double mouseContextX; double mouseContextX;
/** \brief y-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle) */ /** \brief y-position of the mouse (in plot coordinates) when a user mouse-action was started (e.g. drawing a rectangle) */
@ -1029,8 +1061,9 @@ class LIB_EXPORT JKQTPlotter: public QWidget {
/** \brief y-position of the last mouse-click (in screen pixels) */ /** \brief y-position of the last mouse-click (in screen pixels) */
int mouseLastClickY; int mouseLastClickY;
QList<QMenu*> contextSubMenus; QList<QMenu*> contextSubMenus;
/** \brief fills the member contextMenu with all default and additionally registered actions, also calls modifyContextMenu() */
void initContextMenu(); void initContextMenu();
/** \brief set the current mouse cursor shappe according to currentMouseDragAction */
void updateCursor(); void updateCursor();