mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2025-01-13 01:10:33 +08:00
- added signal that is emitted, when a context-menu is opened
- added functions to read back the position where the context-menu was opened
This commit is contained in:
parent
bb98d3843e
commit
bb6baffa28
@ -60,6 +60,8 @@ JKQtPlotter::JKQtPlotter(QWidget *parent):
|
|||||||
|
|
||||||
void JKQtPlotter::init(bool datastore_internal, QWidget* parent, JKQTPdatastore* datast)
|
void JKQtPlotter::init(bool datastore_internal, QWidget* parent, JKQTPdatastore* datast)
|
||||||
{
|
{
|
||||||
|
mouseContextX=0;
|
||||||
|
mouseContextY=0;
|
||||||
setParent(parent);
|
setParent(parent);
|
||||||
connect(&resizeTimer, SIGNAL(timeout()), this, SLOT(delayedResizeEvent()));
|
connect(&resizeTimer, SIGNAL(timeout()), this, SLOT(delayedResizeEvent()));
|
||||||
doDrawing=false;
|
doDrawing=false;
|
||||||
@ -303,9 +305,12 @@ void JKQtPlotter::mousePressEvent ( QMouseEvent * event ){
|
|||||||
//update();
|
//update();
|
||||||
event->accept();
|
event->accept();
|
||||||
} else if (rightMouseButtonAction==JKQtPlotter::RightMouseButtonContextMenu) {
|
} else if (rightMouseButtonAction==JKQtPlotter::RightMouseButtonContextMenu) {
|
||||||
|
mouseContextX=plotter->p2x(event->x()/magnification);
|
||||||
|
mouseContextY=plotter->p2y((event->y()-getPlotYOffset())/magnification);
|
||||||
contextMenu->close();
|
contextMenu->close();
|
||||||
initContextMenu();
|
initContextMenu();
|
||||||
contextMenu->popup(event->globalPos());
|
contextMenu->popup(event->globalPos());
|
||||||
|
emit contextMenuOpened(mouseContextX, mouseContextY, contextMenu);
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,6 +202,9 @@ class LIB_EXPORT JKQtPlotter: public QWidget {
|
|||||||
|
|
||||||
JKQTPGET_SET_MACRO(bool, zoomByMouseWheel);
|
JKQTPGET_SET_MACRO(bool, zoomByMouseWheel);
|
||||||
|
|
||||||
|
JKQTPGetMacro(double, mouseContextX)
|
||||||
|
JKQTPGetMacro(double, mouseContextY)
|
||||||
|
|
||||||
inline JKQTPhorizontalAxis* getXAxis() { return plotter->getXAxis(); }
|
inline JKQTPhorizontalAxis* getXAxis() { return plotter->getXAxis(); }
|
||||||
inline JKQTPverticalAxis* getYAxis() { return plotter->getYAxis(); }
|
inline JKQTPverticalAxis* getYAxis() { return plotter->getYAxis(); }
|
||||||
inline JKQTPhorizontalAxis* get_xAxis() { return plotter->get_xAxis(); }
|
inline JKQTPhorizontalAxis* get_xAxis() { return plotter->get_xAxis(); }
|
||||||
@ -410,6 +413,8 @@ class LIB_EXPORT JKQtPlotter: public QWidget {
|
|||||||
void plotScalingRecalculated();
|
void plotScalingRecalculated();
|
||||||
/** \brief emitted before the plot scaling has been recalculated */
|
/** \brief emitted before the plot scaling has been recalculated */
|
||||||
void beforePlotScalingRecalculate();
|
void beforePlotScalingRecalculate();
|
||||||
|
/** \brief emitted when a context-emnu was opened at the given position */
|
||||||
|
void contextMenuOpened(double x, double y, QMenu* contextMenu);
|
||||||
|
|
||||||
|
|
||||||
/** \brief signal: emitted whenever the user selects a new x-y zoom range (by mouse) */
|
/** \brief signal: emitted whenever the user selects a new x-y zoom range (by mouse) */
|
||||||
@ -590,6 +595,8 @@ class LIB_EXPORT JKQtPlotter: public QWidget {
|
|||||||
QSize minSize;
|
QSize minSize;
|
||||||
|
|
||||||
QMenu* contextMenu;
|
QMenu* contextMenu;
|
||||||
|
double mouseContextX;
|
||||||
|
double mouseContextY;
|
||||||
QList<QMenu*> contextSubMenus;
|
QList<QMenu*> contextSubMenus;
|
||||||
void initContextMenu();
|
void initContextMenu();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user